Fix Shizuku connection

This commit is contained in:
Nullptr 2022-03-18 11:59:41 +08:00
parent 955606b51a
commit ebb70a4d63
3 changed files with 11 additions and 22 deletions

View File

@ -12,19 +12,18 @@ const val TAG = "LSPatch Manager"
class LSPApplication : Application() {
companion object {
var shizukuAlive = false
var shizukuBinderAvalable = false
var shizukuGranted by mutableStateOf(false)
}
override fun onCreate() {
super.onCreate()
Shizuku.addBinderReceivedListener {
shizukuAlive = true
init {
Shizuku.addBinderReceivedListenerSticky {
shizukuBinderAvalable = true
shizukuGranted = Shizuku.checkSelfPermission() == PackageManager.PERMISSION_GRANTED
}
Shizuku.addBinderDeadListener {
shizukuAlive = false
shizukuBinderAvalable = false
shizukuGranted = false
}
}
}
}

View File

@ -87,7 +87,7 @@ private fun ShizukuCard() {
ElevatedCard(
modifier = Modifier.clickable {
if (LSPApplication.shizukuAlive && !LSPApplication.shizukuGranted) {
if (LSPApplication.shizukuBinderAvalable && !LSPApplication.shizukuGranted) {
Shizuku.requestPermission(114514)
}
},

View File

@ -8,13 +8,7 @@ android {
}
buildTypes {
debug {
isDebuggable = true
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
release {
isDebuggable = false
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
@ -25,10 +19,6 @@ android {
path("src/main/jni/CMakeLists.txt")
}
}
lint {
abortOnError = false
}
}
androidComponents.onVariants { variant ->