fix permission poups and add settings to see permission state

This commit is contained in:
2026-03-10 03:59:51 +05:00
parent 86bf14f9d9
commit ffdb600c1c
4 changed files with 331 additions and 13 deletions

View File

@@ -15,12 +15,36 @@ object RootManager {
)
}
suspend fun hasRoot(): Boolean = withContext(Dispatchers.IO) {
Shell.isAppGrantedRoot() == true
/**
* Check if root was previously granted (cached status, no popup).
* Returns true if granted, false if denied, null if unknown.
*/
fun isRootGrantedCached(): Boolean? {
return Shell.isAppGrantedRoot()
}
/**
* Check if root is available. Will trigger Magisk popup if not previously decided.
*/
suspend fun hasRoot(): Boolean = withContext(Dispatchers.IO) {
try {
// getShell() initializes the shell and checks root status with Magisk
// If already granted, Magisk will auto-approve silently
Shell.getShell().isRoot
} catch (e: Exception) {
false
}
}
/**
* Request root access. Will trigger Magisk popup.
*/
suspend fun requestRoot(): Boolean = withContext(Dispatchers.IO) {
Shell.getShell().isRoot
try {
Shell.getShell().isRoot
} catch (e: Exception) {
false
}
}
suspend fun executeCommand(command: String): CommandResult = withContext(Dispatchers.IO) {