mirror of
https://github.com/awfixers-stuff/OwnDroid.git
synced 2026-03-24 03:16:00 +00:00
edit proguard rules, keep IDevicePolicyManager
support getting device admin permission from Dhizuku
This commit is contained in:
@@ -45,6 +45,11 @@ val Context.isProfileOwner: Boolean
|
||||
return dpm.isProfileOwnerApp("com.bintianqi.owndroid")
|
||||
}
|
||||
|
||||
val Context.isDeviceAdmin: Boolean
|
||||
get() {
|
||||
return getDPM().isAdminActive(getReceiver())
|
||||
}
|
||||
|
||||
val Context.dpcPackageName: String
|
||||
get() {
|
||||
val sharedPref = getSharedPreferences("data", Context.MODE_PRIVATE)
|
||||
|
||||
@@ -139,13 +139,13 @@ private fun Home(navCtrl:NavHostController,scrollState: ScrollState) {
|
||||
if(VERSION.SDK_INT >= 26 && (context.isDeviceOwner || context.isProfileOwner)) {
|
||||
SubPageItem(R.string.reset_password_token, "", R.drawable.key_vertical_fill0) { navCtrl.navigate("ResetPasswordToken") }
|
||||
}
|
||||
if(dpm.isAdminActive(receiver) || context.isDeviceOwner || context.isProfileOwner) {
|
||||
if(context.isDeviceAdmin || context.isDeviceOwner || context.isProfileOwner) {
|
||||
SubPageItem(R.string.reset_password, "", R.drawable.lock_reset_fill0) { navCtrl.navigate("ResetPassword") }
|
||||
}
|
||||
if(VERSION.SDK_INT >= 31 && (context.isDeviceOwner || context.isProfileOwner)) {
|
||||
SubPageItem(R.string.required_password_complexity, "", R.drawable.password_fill0) { navCtrl.navigate("RequirePasswordComplexity") }
|
||||
}
|
||||
if(dpm.isAdminActive(receiver)) {
|
||||
if(context.isDeviceAdmin) {
|
||||
SubPageItem(R.string.disable_keyguard_features, "", R.drawable.screen_lock_portrait_fill0) { navCtrl.navigate("DisableKeyguardFeatures") }
|
||||
}
|
||||
if(context.isDeviceOwner) {
|
||||
@@ -153,7 +153,7 @@ private fun Home(navCtrl:NavHostController,scrollState: ScrollState) {
|
||||
SubPageItem(R.string.pwd_expiration_timeout, "", R.drawable.lock_clock_fill0) { navCtrl.navigate("PasswordTimeout") }
|
||||
SubPageItem(R.string.max_pwd_fail, "", R.drawable.no_encryption_fill0) { navCtrl.navigate("MaxPasswordFail") }
|
||||
}
|
||||
if(dpm.isAdminActive(receiver)){
|
||||
if(context.isDeviceAdmin){
|
||||
SubPageItem(R.string.pwd_history, "", R.drawable.history_fill0) { navCtrl.navigate("PasswordHistoryLength") }
|
||||
}
|
||||
if(VERSION.SDK_INT >= 26 && (context.isDeviceOwner || context.isProfileOwner)) {
|
||||
@@ -188,7 +188,7 @@ private fun PasswordInfo() {
|
||||
if(context.isDeviceOwner || context.isProfileOwner) {
|
||||
Text(stringResource(R.string.is_password_sufficient, dpm.isActivePasswordSufficient))
|
||||
}
|
||||
if(dpm.isAdminActive(receiver)) {
|
||||
if(context.isDeviceAdmin) {
|
||||
val pwdFailedAttempts = dpm.currentFailedPasswordAttempts
|
||||
Text(text = stringResource(R.string.password_failed_attempts_is, pwdFailedAttempts))
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ import androidx.navigation.compose.composable
|
||||
import androidx.navigation.compose.currentBackStackEntryAsState
|
||||
import androidx.navigation.compose.rememberNavController
|
||||
import com.bintianqi.owndroid.R
|
||||
import com.bintianqi.owndroid.Receiver
|
||||
import com.bintianqi.owndroid.backToHomeStateFlow
|
||||
import com.bintianqi.owndroid.ui.*
|
||||
import com.rosan.dhizuku.api.Dhizuku
|
||||
@@ -109,7 +110,7 @@ private fun Home(localNavCtrl:NavHostController,listScrollState:ScrollState) {
|
||||
)
|
||||
}
|
||||
SubPageItem(
|
||||
R.string.device_admin, stringResource(if(dpm.isAdminActive(receiver)) R.string.activated else R.string.deactivated),
|
||||
R.string.device_admin, stringResource(if(context.isDeviceAdmin) R.string.activated else R.string.deactivated),
|
||||
operation = { localNavCtrl.navigate("DeviceAdmin") }
|
||||
)
|
||||
if(!context.isDeviceOwner) {
|
||||
@@ -139,7 +140,7 @@ private fun Home(localNavCtrl:NavHostController,listScrollState:ScrollState) {
|
||||
if(VERSION.SDK_INT >= 24 && (context.isDeviceOwner || dpm.isOrgProfile(receiver))) {
|
||||
SubPageItem(R.string.device_owner_lock_screen_info, "", R.drawable.screen_lock_portrait_fill0) { localNavCtrl.navigate("LockScreenInfo") }
|
||||
}
|
||||
if(VERSION.SDK_INT >= 24 && dpm.isAdminActive(receiver)) {
|
||||
if(VERSION.SDK_INT >= 24 && context.isDeviceAdmin) {
|
||||
SubPageItem(R.string.support_msg, "", R.drawable.chat_fill0) { localNavCtrl.navigate("SupportMsg") }
|
||||
}
|
||||
if(VERSION.SDK_INT >= 28 && (context.isDeviceOwner || context.isProfileOwner)) {
|
||||
@@ -222,12 +223,12 @@ private fun DeviceAdmin() {
|
||||
val context = LocalContext.current
|
||||
val dpm = context.getDPM()
|
||||
val receiver = context.getReceiver()
|
||||
var showDeactivateButton by remember { mutableStateOf(dpm.isAdminActive(receiver)) }
|
||||
var showDeactivateButton by remember { mutableStateOf(context.isDeviceAdmin) }
|
||||
var deactivateDialog by remember { mutableStateOf(false) }
|
||||
Column(modifier = Modifier.fillMaxSize().verticalScroll(rememberScrollState()).padding(horizontal = 8.dp)) {
|
||||
Spacer(Modifier.padding(vertical = 10.dp))
|
||||
Text(text = stringResource(R.string.device_admin), style = typography.headlineLarge)
|
||||
Text(text = stringResource(if(dpm.isAdminActive(receiver)) R.string.activated else R.string.deactivated), style = typography.titleLarge)
|
||||
Text(text = stringResource(if(context.isDeviceAdmin) R.string.activated else R.string.deactivated), style = typography.titleLarge)
|
||||
Spacer(Modifier.padding(vertical = 5.dp))
|
||||
AnimatedVisibility(showDeactivateButton) {
|
||||
Button(
|
||||
@@ -270,8 +271,8 @@ private fun DeviceAdmin() {
|
||||
co.launch{
|
||||
delay(300)
|
||||
deactivateDialog = false
|
||||
showDeactivateButton = dpm.isAdminActive(receiver)
|
||||
backToHomeStateFlow.value = !dpm.isAdminActive(receiver)
|
||||
showDeactivateButton = context.isDeviceAdmin
|
||||
backToHomeStateFlow.value = !context.isDeviceAdmin
|
||||
}
|
||||
}
|
||||
) {
|
||||
|
||||
@@ -50,7 +50,7 @@ fun ShizukuActivate() {
|
||||
var enabled by remember { mutableStateOf(false) }
|
||||
var bindShizuku by remember { mutableStateOf(false) }
|
||||
var outputText by remember { mutableStateOf("") }
|
||||
var showDeviceAdminButton by remember { mutableStateOf(!dpm.isAdminActive(receiver)) }
|
||||
var showDeviceAdminButton by remember { mutableStateOf(!context.isDeviceAdmin) }
|
||||
var showProfileOwnerButton by remember { mutableStateOf(!context.isProfileOwner) }
|
||||
var showDeviceOwnerButton by remember { mutableStateOf(!context.isDeviceOwner) }
|
||||
var showOrgProfileOwnerButton by remember { mutableStateOf(true) }
|
||||
@@ -124,7 +124,7 @@ fun ShizukuActivate() {
|
||||
outputText = service!!.execute(context.getString(R.string.dpm_activate_da_command))
|
||||
outputTextScrollState.animateScrollTo(0)
|
||||
delay(500)
|
||||
showDeviceAdminButton = !dpm.isAdminActive(receiver)
|
||||
showDeviceAdminButton = !context.isDeviceAdmin
|
||||
}
|
||||
},
|
||||
enabled = enabled
|
||||
|
||||
@@ -224,7 +224,7 @@ private fun Home(navCtrl: NavHostController, scrollState: ScrollState, rebootDia
|
||||
if(VERSION.SDK_INT >= 30 && (context.isDeviceOwner || dpm.isOrgProfile(receiver))) {
|
||||
SubPageItem(R.string.frp_policy, "", R.drawable.device_reset_fill0) { navCtrl.navigate("FRP") }
|
||||
}
|
||||
if(dangerousFeatures && dpm.isAdminActive(receiver) && !(VERSION.SDK_INT >= 24 && context.isProfileOwner && dpm.isManagedProfile(receiver))) {
|
||||
if(dangerousFeatures && context.isDeviceAdmin && !(VERSION.SDK_INT >= 24 && context.isProfileOwner && dpm.isManagedProfile(receiver))) {
|
||||
SubPageItem(R.string.wipe_data, "", R.drawable.device_reset_fill0) { navCtrl.navigate("WipeData") }
|
||||
}
|
||||
Spacer(Modifier.padding(vertical = 30.dp))
|
||||
@@ -337,7 +337,7 @@ private fun Keyguard() {
|
||||
var flag by remember { mutableIntStateOf(0) }
|
||||
Button(
|
||||
onClick = { dpm.lockNow() },
|
||||
enabled = dpm.isAdminActive(receiver),
|
||||
enabled = context.isDeviceAdmin,
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
Text(stringResource(R.string.lock_now))
|
||||
|
||||
Reference in New Issue
Block a user