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() { class LSPApplication : Application() {
companion object { companion object {
var shizukuAlive = false var shizukuBinderAvalable = false
var shizukuGranted by mutableStateOf(false) var shizukuGranted by mutableStateOf(false)
}
override fun onCreate() { init {
super.onCreate() Shizuku.addBinderReceivedListenerSticky {
Shizuku.addBinderReceivedListener { shizukuBinderAvalable = true
shizukuAlive = true shizukuGranted = Shizuku.checkSelfPermission() == PackageManager.PERMISSION_GRANTED
shizukuGranted = Shizuku.checkSelfPermission() == PackageManager.PERMISSION_GRANTED }
} Shizuku.addBinderDeadListener {
Shizuku.addBinderDeadListener { shizukuBinderAvalable = false
shizukuAlive = false shizukuGranted = false
shizukuGranted = false }
} }
} }
} }

View File

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

View File

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