mirror of
https://github.com/awfixers-stuff/OwnDroid.git
synced 2026-03-23 19:15:58 +00:00
Handle Dhizuku errors better (#154)
This commit is contained in:
@@ -23,6 +23,7 @@ import com.bintianqi.owndroid.R
|
||||
import com.bintianqi.owndroid.SharedPrefs
|
||||
import com.bintianqi.owndroid.createShortcuts
|
||||
import com.bintianqi.owndroid.myPrivilege
|
||||
import com.bintianqi.owndroid.updatePrivilege
|
||||
import com.rosan.dhizuku.api.Dhizuku
|
||||
import com.rosan.dhizuku.api.DhizukuBinderWrapper
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
@@ -526,3 +527,16 @@ fun handlePrivilegeChange(context: Context) {
|
||||
sp.isApiEnabled = false
|
||||
}
|
||||
}
|
||||
|
||||
fun checkPrivilege(context: Context) {
|
||||
val sp = SharedPrefs(context)
|
||||
if (sp.dhizuku) {
|
||||
if (Dhizuku.init(context)) {
|
||||
if (!dhizukuPermissionGranted()) { dhizukuErrorStatus.value = 2 }
|
||||
} else {
|
||||
sp.dhizuku = false
|
||||
dhizukuErrorStatus.value = 1
|
||||
}
|
||||
}
|
||||
updatePrivilege(context)
|
||||
}
|
||||
|
||||
@@ -118,8 +118,7 @@ import kotlinx.serialization.json.Json
|
||||
@OptIn(ExperimentalMaterial3Api::class, ExperimentalLayoutApi::class)
|
||||
@Composable
|
||||
fun WorkModesScreen(
|
||||
params: WorkModes, onNavigateUp: () -> Unit, onActivate: () -> Unit, onDeactivate: () -> Unit,
|
||||
onNavigate: (Any) -> Unit
|
||||
params: WorkModes, onNavigateUp: () -> Unit, onActivate: () -> Unit, onNavigate: (Any) -> Unit
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
val coroutine = rememberCoroutineScope()
|
||||
@@ -129,10 +128,7 @@ fun WorkModesScreen(
|
||||
LaunchedEffect(privilege) {
|
||||
if (!params.canNavigateUp && privilege.device) {
|
||||
delay(1000)
|
||||
if (dialog != 3) {
|
||||
dialog = 0
|
||||
onActivate() // Activated by ADB command, return to home screen
|
||||
}
|
||||
if (dialog != 3) dialog = 3 // Activated by ADB command
|
||||
}
|
||||
}
|
||||
Scaffold(
|
||||
@@ -379,7 +375,6 @@ fun WorkModesScreen(
|
||||
dialog = 0
|
||||
updatePrivilege(context)
|
||||
handlePrivilegeChange(context)
|
||||
onDeactivate()
|
||||
},
|
||||
enabled = time == 0,
|
||||
colors = ButtonDefaults.textButtonColors(contentColor = colorScheme.error)
|
||||
|
||||
Reference in New Issue
Block a user