diff --git a/manager/src/main/java/moe/shizuku/manager/home/HomeViewModel.kt b/manager/src/main/java/moe/shizuku/manager/home/HomeViewModel.kt index c849a4717..ae37606ed 100644 --- a/manager/src/main/java/moe/shizuku/manager/home/HomeViewModel.kt +++ b/manager/src/main/java/moe/shizuku/manager/home/HomeViewModel.kt @@ -8,8 +8,11 @@ import androidx.lifecycle.viewModelScope import kotlinx.coroutines.CancellationException import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch +import moe.shizuku.manager.BuildConfig +import moe.shizuku.manager.Manifest import moe.shizuku.manager.model.ServiceStatus import moe.shizuku.manager.utils.Logger.LOGGER +import moe.shizuku.manager.utils.ShizukuSystemApis import moe.shizuku.manager.viewmodel.Resource import rikka.shizuku.Shizuku @@ -35,6 +38,10 @@ class HomeViewModel : ViewModel() { } } else null val permissionTest = Shizuku.checkRemotePermission("android.permission.GRANT_RUNTIME_PERMISSIONS") == PackageManager.PERMISSION_GRANTED + + // Before a526d6bb, server will not exit on uninstall, manager installed later will get not permission + // Run a random remote transaction here, report no permission as not running + ShizukuSystemApis.checkPermission(Manifest.permission.API_V23, BuildConfig.APPLICATION_ID, 0) return ServiceStatus(uid, apiVersion, patchVersion, seContext, permissionTest) } @@ -46,7 +53,7 @@ class HomeViewModel : ViewModel() { } catch (e: CancellationException) { } catch (e: Throwable) { - _serviceStatus.postValue(Resource.error(e)) + _serviceStatus.postValue(Resource.error(e, ServiceStatus())) } } } diff --git a/manager/src/main/java/moe/shizuku/manager/model/ServiceStatus.kt b/manager/src/main/java/moe/shizuku/manager/model/ServiceStatus.kt index a28e15758..86dcd13a3 100644 --- a/manager/src/main/java/moe/shizuku/manager/model/ServiceStatus.kt +++ b/manager/src/main/java/moe/shizuku/manager/model/ServiceStatus.kt @@ -3,12 +3,12 @@ package moe.shizuku.manager.model import rikka.shizuku.Shizuku data class ServiceStatus( - val uid: Int = - 1, + val uid: Int = -1, val apiVersion: Int = -1, val patchVersion: Int = -1, val seContext: String? = null, val permission: Boolean = false ) { val isRunning: Boolean - get() = Shizuku.pingBinder() + get() = uid != -1 && Shizuku.pingBinder() } \ No newline at end of file