perf: 优化 shizuku 错误提示

This commit is contained in:
lisonge 2023-12-06 17:10:07 +08:00
parent 5a38217c5c
commit 4f9ba7ec04
2 changed files with 9 additions and 2 deletions

View File

@ -31,7 +31,12 @@ import kotlin.reflect.typeOf
fun newActivityTaskManager(): IActivityTaskManager? {
return SystemServiceHelper.getSystemService("activity_task").let(::ShizukuBinderWrapper)
val service = SystemServiceHelper.getSystemService("activity_task")
if (service == null) {
LogUtils.d("shizuku 无法获取 activity_task")
return null
}
return service.let(::ShizukuBinderWrapper)
.let(IActivityTaskManager.Stub::asInterface)
}

View File

@ -120,7 +120,7 @@ fun DebugPage() {
onCheckedChange = { enableShizuku ->
if (enableShizuku) {
appScope.launchTry(Dispatchers.IO) {
// 验方法是否适配, 再允许使用 shizuku
// 验方法是否适配, 再允许使用 shizuku
val tasks = newActivityTaskManager()?.safeGetTasks()?.firstOrNull()
if (tasks != null) {
updateStorage(
@ -128,6 +128,8 @@ fun DebugPage() {
enableShizuku = true
)
)
} else {
ToastUtils.showShort("Shizuku方法校验失败,无法使用")
}
}
} else {