Request Shizuku permission before enter Shizuku screen

Bind Shizuku service automatically after enter Shizuku functions page
This commit is contained in:
BinTianqi
2024-12-15 12:01:09 +08:00
parent 867668832e
commit 3fb4fb078f
10 changed files with 84 additions and 155 deletions

View File

@@ -3,23 +3,18 @@ package com.bintianqi.owndroid.dpm
import android.system.Os
import androidx.annotation.Keep
import com.bintianqi.owndroid.IUserService
import kotlinx.coroutines.flow.MutableStateFlow
import java.io.BufferedReader
import java.io.InputStreamReader
val shizukuService = MutableStateFlow<IUserService?>(null)
@Keep
class ShizukuService: IUserService.Stub() {
override fun destroy() { }
override fun execute(command: String): String {
var result = ""
val process: Process
try {
process = Runtime.getRuntime().exec(command)
val exitCode = process.waitFor()
if(exitCode != 0){ result += "Error: $exitCode" }
if(exitCode != 0) { result += "Error: $exitCode" }
} catch(e: Exception) {
e.printStackTrace()
return e.toString()
@@ -34,11 +29,8 @@ class ShizukuService: IUserService.Stub() {
} catch(e: NullPointerException) {
e.printStackTrace()
}
if(result == "") { return "No result" }
return result
}
override fun getUid(): Int {
return Os.getuid()
}
override fun getUid(): Int = Os.getuid()
}