mirror of
https://github.com/awfixers-stuff/OwnDroid.git
synced 2026-03-23 11:05:59 +00:00
fix crash when wipe data
This commit is contained in:
@@ -19,8 +19,8 @@ android {
|
|||||||
applicationId = "com.bintianqi.owndroid"
|
applicationId = "com.bintianqi.owndroid"
|
||||||
minSdk = 21
|
minSdk = 21
|
||||||
targetSdk = 34
|
targetSdk = 34
|
||||||
versionCode = 25
|
versionCode = 26
|
||||||
versionName = "5.0"
|
versionName = "5.1"
|
||||||
multiDexEnabled = false
|
multiDexEnabled = false
|
||||||
//signingConfig = signingConfigs.getByName("testkey")
|
//signingConfig = signingConfigs.getByName("testkey")
|
||||||
}
|
}
|
||||||
@@ -52,6 +52,10 @@ android {
|
|||||||
packaging {
|
packaging {
|
||||||
resources {
|
resources {
|
||||||
excludes += "/META-INF/{AL2.0,LGPL2.1}"
|
excludes += "/META-INF/{AL2.0,LGPL2.1}"
|
||||||
|
excludes += "/META-INF/**.version"
|
||||||
|
excludes += "kotlin/**"
|
||||||
|
excludes += "**.bin"
|
||||||
|
excludes += "kotlin-tooling-metadata.json"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
androidResources {
|
androidResources {
|
||||||
@@ -60,7 +64,6 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("org.apache.commons:commons-io:1.3.2")
|
|
||||||
implementation("androidx.activity:activity-compose:1.8.2")
|
implementation("androidx.activity:activity-compose:1.8.2")
|
||||||
implementation("androidx.compose.ui:ui")
|
implementation("androidx.compose.ui:ui")
|
||||||
implementation("androidx.compose.ui:ui-graphics")
|
implementation("androidx.compose.ui:ui-graphics")
|
||||||
|
|||||||
@@ -191,7 +191,7 @@ private fun ResetPasswordToken(){
|
|||||||
if(!myDpm.isResetPasswordTokenActive(myComponent)){
|
if(!myDpm.isResetPasswordTokenActive(myComponent)){
|
||||||
try{ activateToken(myContext) }
|
try{ activateToken(myContext) }
|
||||||
catch(e:NullPointerException){ Toast.makeText(myContext, myContext.getString(R.string.please_set_a_token), Toast.LENGTH_SHORT).show() }
|
catch(e:NullPointerException){ Toast.makeText(myContext, myContext.getString(R.string.please_set_a_token), Toast.LENGTH_SHORT).show() }
|
||||||
}else{ Toast.makeText(myContext, "已经激活", Toast.LENGTH_SHORT).show() }
|
}else{ Toast.makeText(myContext, myContext.getString(R.string.token_already_activated), Toast.LENGTH_SHORT).show() }
|
||||||
},
|
},
|
||||||
enabled = isDeviceOwner(myDpm)||isProfileOwner(myDpm),
|
enabled = isDeviceOwner(myDpm)||isProfileOwner(myDpm),
|
||||||
modifier = Modifier.fillMaxWidth()
|
modifier = Modifier.fillMaxWidth()
|
||||||
|
|||||||
@@ -88,9 +88,9 @@ fun DpmPermissions(navCtrl:NavHostController){
|
|||||||
){
|
){
|
||||||
composable(route = "Home"){Home(localNavCtrl,scrollState)}
|
composable(route = "Home"){Home(localNavCtrl,scrollState)}
|
||||||
composable(route = "Shizuku"){ShizukuActivate()}
|
composable(route = "Shizuku"){ShizukuActivate()}
|
||||||
composable(route = "DeviceAdmin"){DeviceAdmin(navCtrl)}
|
composable(route = "DeviceAdmin"){DeviceAdmin()}
|
||||||
composable(route = "ProfileOwner"){ProfileOwner()}
|
composable(route = "ProfileOwner"){ProfileOwner()}
|
||||||
composable(route = "DeviceOwner"){DeviceOwner(navCtrl)}
|
composable(route = "DeviceOwner"){DeviceOwner()}
|
||||||
composable(route = "DeviceInfo"){DeviceInfo()}
|
composable(route = "DeviceInfo"){DeviceInfo()}
|
||||||
composable(route = "SpecificID"){SpecificID()}
|
composable(route = "SpecificID"){SpecificID()}
|
||||||
composable(route = "OrgName"){OrgName()}
|
composable(route = "OrgName"){OrgName()}
|
||||||
@@ -187,7 +187,7 @@ private fun LockScreenInfo(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun DeviceAdmin(navCtrl: NavHostController){
|
private fun DeviceAdmin(){
|
||||||
val myContext = LocalContext.current
|
val myContext = LocalContext.current
|
||||||
val myDpm = myContext.getSystemService(ComponentActivity.DEVICE_POLICY_SERVICE) as DevicePolicyManager
|
val myDpm = myContext.getSystemService(ComponentActivity.DEVICE_POLICY_SERVICE) as DevicePolicyManager
|
||||||
val myComponent = ComponentName(myContext,Receiver::class.java)
|
val myComponent = ComponentName(myContext,Receiver::class.java)
|
||||||
@@ -261,7 +261,7 @@ private fun ProfileOwner(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun DeviceOwner(navCtrl: NavHostController){
|
private fun DeviceOwner(){
|
||||||
val myContext = LocalContext.current
|
val myContext = LocalContext.current
|
||||||
val myDpm = myContext.getSystemService(ComponentActivity.DEVICE_POLICY_SERVICE) as DevicePolicyManager
|
val myDpm = myContext.getSystemService(ComponentActivity.DEVICE_POLICY_SERVICE) as DevicePolicyManager
|
||||||
val co = rememberCoroutineScope()
|
val co = rememberCoroutineScope()
|
||||||
|
|||||||
@@ -733,9 +733,7 @@ private fun WipeData(){
|
|||||||
value = reason, onValueChange = {reason=it},
|
value = reason, onValueChange = {reason=it},
|
||||||
label = {Text(stringResource(R.string.reason))},
|
label = {Text(stringResource(R.string.reason))},
|
||||||
enabled = !confirmed,
|
enabled = !confirmed,
|
||||||
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done),
|
modifier = Modifier.fillMaxWidth().padding(vertical = 3.dp)
|
||||||
keyboardActions = KeyboardActions(onDone = {focusMgr.clearFocus()}),
|
|
||||||
modifier = Modifier.focusable().fillMaxWidth().padding(vertical = 3.dp)
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Spacer(Modifier.padding(vertical = 5.dp))
|
Spacer(Modifier.padding(vertical = 5.dp))
|
||||||
@@ -761,8 +759,11 @@ private fun WipeData(){
|
|||||||
}
|
}
|
||||||
Button(
|
Button(
|
||||||
onClick = {
|
onClick = {
|
||||||
if(VERSION.SDK_INT>=28){myDpm.wipeData(flag,reason)}
|
if(VERSION.SDK_INT>=28&&reason!=""){
|
||||||
else{myDpm.wipeData(flag)}
|
myDpm.wipeData(flag,reason)
|
||||||
|
}else{
|
||||||
|
myDpm.wipeData(flag)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
colors = ButtonDefaults.buttonColors(containerColor = colorScheme.error, contentColor = colorScheme.onError),
|
colors = ButtonDefaults.buttonColors(containerColor = colorScheme.error, contentColor = colorScheme.onError),
|
||||||
enabled = confirmed&&(VERSION.SDK_INT<34||(VERSION.SDK_INT>=34&&!userManager.isSystemUser)),
|
enabled = confirmed&&(VERSION.SDK_INT<34||(VERSION.SDK_INT>=34&&!userManager.isSystemUser)),
|
||||||
|
|||||||
@@ -420,6 +420,7 @@
|
|||||||
<string name="password_failed_attempts_is">密码已错误次数:%1$s</string>
|
<string name="password_failed_attempts_is">密码已错误次数:%1$s</string>
|
||||||
<string name="is_using_unified_password">个人与工作应用密码一致:%1$s</string>
|
<string name="is_using_unified_password">个人与工作应用密码一致:%1$s</string>
|
||||||
<string name="reset_password_token">密码重置令牌</string>
|
<string name="reset_password_token">密码重置令牌</string>
|
||||||
|
<string name="token_already_activated">令牌已经激活</string>
|
||||||
<string name="clear">清除</string>
|
<string name="clear">清除</string>
|
||||||
<string name="set">设置</string>
|
<string name="set">设置</string>
|
||||||
<string name="please_set_a_token">请先设置令牌</string>
|
<string name="please_set_a_token">请先设置令牌</string>
|
||||||
|
|||||||
@@ -434,6 +434,7 @@
|
|||||||
<string name="password_failed_attempts_is">Password failed attempts: %1$s</string>
|
<string name="password_failed_attempts_is">Password failed attempts: %1$s</string>
|
||||||
<string name="is_using_unified_password">Unified password: %1$s</string>
|
<string name="is_using_unified_password">Unified password: %1$s</string>
|
||||||
<string name="reset_password_token">Reset password token</string>
|
<string name="reset_password_token">Reset password token</string>
|
||||||
|
<string name="token_already_activated">Token already activated</string>
|
||||||
<string name="clear">Clear</string>
|
<string name="clear">Clear</string>
|
||||||
<string name="set">Set</string>
|
<string name="set">Set</string>
|
||||||
<string name="please_set_a_token">Please set a token</string>
|
<string name="please_set_a_token">Please set a token</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user