Store App lock password hash in shared prefs

Add workflow release.yml
Fix R8 error
This commit is contained in:
BinTianqi
2025-04-13 09:05:05 +08:00
parent 5110536b59
commit a30a9abb3c
17 changed files with 99 additions and 106 deletions

View File

@@ -137,71 +137,6 @@ fun Context.getReceiver(): ComponentName {
val dhizukuErrorStatus = MutableStateFlow(0)
fun Context.resetDevicePolicy() {
val dpm = getDPM()
val receiver = getReceiver()
RestrictionData.getAllRestrictions().forEach {
dpm.clearUserRestriction(receiver, it.id)
}
dpm.accountTypesWithManagementDisabled?.forEach {
dpm.setAccountManagementDisabled(receiver, it, false)
}
if (VERSION.SDK_INT >= 30) {
dpm.setConfiguredNetworksLockdownState(receiver, false)
dpm.setAutoTimeZoneEnabled(receiver, true)
dpm.setAutoTimeEnabled(receiver, true)
dpm.setCommonCriteriaModeEnabled(receiver, false)
try {
val frp = FactoryResetProtectionPolicy.Builder().setFactoryResetProtectionEnabled(false).setFactoryResetProtectionAccounts(listOf())
dpm.setFactoryResetProtectionPolicy(receiver, frp.build())
} catch(_: Exception) {}
dpm.setUserControlDisabledPackages(receiver, listOf())
}
if (VERSION.SDK_INT >= 33) {
dpm.minimumRequiredWifiSecurityLevel = DevicePolicyManager.WIFI_SECURITY_OPEN
dpm.wifiSsidPolicy = null
}
if (VERSION.SDK_INT >= 28) {
dpm.getOverrideApns(receiver).forEach { dpm.removeOverrideApn(receiver, it.id) }
dpm.setKeepUninstalledPackages(receiver, listOf())
}
dpm.setCameraDisabled(receiver, false)
dpm.setScreenCaptureDisabled(receiver, false)
dpm.setMasterVolumeMuted(receiver, false)
try {
if(VERSION.SDK_INT >= 31) dpm.isUsbDataSignalingEnabled = true
} catch (_: Exception) { }
if (VERSION.SDK_INT >= 23) {
dpm.setPermissionPolicy(receiver, DevicePolicyManager.PERMISSION_POLICY_PROMPT)
dpm.setSystemUpdatePolicy(receiver, SystemUpdatePolicy.createAutomaticInstallPolicy())
}
if (VERSION.SDK_INT >= 24) {
dpm.setAlwaysOnVpnPackage(receiver, null, false)
dpm.setPackagesSuspended(receiver, arrayOf(), false)
}
dpm.setPermittedInputMethods(receiver, null)
dpm.setPermittedAccessibilityServices(receiver, null)
packageManager.getInstalledApplications(0).forEach {
if (dpm.isUninstallBlocked(receiver, it.packageName)) dpm.setUninstallBlocked(receiver, it.packageName, false)
}
if (VERSION.SDK_INT >= 26) {
dpm.setRequiredStrongAuthTimeout(receiver, 0)
dpm.clearResetPasswordToken(receiver)
}
if (VERSION.SDK_INT >= 31) {
dpm.requiredPasswordComplexity = DevicePolicyManager.PASSWORD_COMPLEXITY_NONE
}
dpm.setKeyguardDisabledFeatures(receiver, 0)
dpm.setMaximumTimeToLock(receiver, 0)
dpm.setPasswordExpirationTimeout(receiver, 0)
dpm.setMaximumFailedPasswordsForWipe(receiver, 0)
dpm.setPasswordHistoryLength(receiver, 0)
if (VERSION.SDK_INT < 31) {
dpm.setPasswordQuality(receiver, DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED)
}
dpm.setRecommendedGlobalProxy(receiver, null)
}
data class PermissionItem(
val permission: String,
@StringRes val label: Int,

View File

@@ -763,7 +763,7 @@ fun WifiSecurityLevelScreen(onNavigateUp: () -> Unit) {
val dpm = context.getDPM()
var selectedWifiSecLevel by remember { mutableIntStateOf(0) }
LaunchedEffect(Unit) { selectedWifiSecLevel = dpm.minimumRequiredWifiSecurityLevel }
MySmallTitleScaffold(R.string.min_wifi_security_level, onNavigateUp, 0.dp) {
MyScaffold(R.string.min_wifi_security_level, onNavigateUp, 0.dp) {
FullWidthRadioButtonItem(R.string.wifi_security_open, selectedWifiSecLevel == WIFI_SECURITY_OPEN) { selectedWifiSecLevel = WIFI_SECURITY_OPEN }
FullWidthRadioButtonItem("WEP, WPA(2)-PSK", selectedWifiSecLevel == WIFI_SECURITY_PERSONAL) { selectedWifiSecLevel = WIFI_SECURITY_PERSONAL }
FullWidthRadioButtonItem("WPA-EAP", selectedWifiSecLevel == WIFI_SECURITY_ENTERPRISE_EAP) { selectedWifiSecLevel = WIFI_SECURITY_ENTERPRISE_EAP }
@@ -809,8 +809,6 @@ fun WifiSsidPolicyScreen(onNavigateUp: () -> Unit) {
AnimatedVisibility(selectedPolicyType != -1) {
var inputSsid by remember { mutableStateOf("") }
Column(Modifier.padding(horizontal = HorizontalPadding)) {
Text(stringResource(R.string.ssid_list_is))
if(ssidList.isEmpty()) Text(stringResource(R.string.none))
Column(modifier = Modifier.animateContentSize()) {
for(i in ssidList) {
ListItem(i.bytes.decodeToString()) { ssidList -= i }

View File

@@ -247,7 +247,13 @@ fun WorkModesScreen(
Icon(Icons.Default.MoreVert, null)
}
DropdownMenu(expanded, { expanded = false }) {
DropdownMenuItem({ Text(stringResource(R.string.deactivate)) }, { dialog = 4 })
DropdownMenuItem(
{ Text(stringResource(R.string.deactivate)) },
{
expanded = false
dialog = 4
}
)
if(!privilege.dhizuku && VERSION.SDK_INT >= 28) DropdownMenuItem(
{ Text(stringResource(R.string.transfer_ownership)) },
{
@@ -404,7 +410,10 @@ fun WorkModesScreen(
Text(stringResource(R.string.confirm))
}
},
onDismissRequest = {}
onDismissRequest = {
dialog = 0
if(operationSucceed && !params.canNavigateUp) onActivate()
}
)
if(dialog == 4) AlertDialog(
title = { Text(stringResource(R.string.deactivate)) },
@@ -422,6 +431,7 @@ fun WorkModesScreen(
dpm.clearProfileOwner(ComponentName(context, Receiver::class.java))
}
}
dialog = 0
updatePrivilege(context)
handlePrivilegeChange(context)
onDeactivate()
@@ -498,7 +508,7 @@ fun activateUsingDhizuku(context: Context, callback: (Boolean, Boolean, String?)
callback(true, false, null)
}
}
if(Dhizuku.init()) {
if(Dhizuku.init(context)) {
if(Dhizuku.isPermissionGranted()) {
doTransfer()
} else {
@@ -519,7 +529,7 @@ fun activateDhizukuMode(context: Context, callback: (Boolean, Boolean, String?)
SharedPrefs(context).dhizuku = true
callback(true, true, null)
}
if(Dhizuku.init()) {
if(Dhizuku.init(context)) {
if(Dhizuku.isPermissionGranted()) {
onSucceed()
} else {