Skip to content

Commit

Permalink
Report no permission as not running
Browse files Browse the repository at this point in the history
  • Loading branch information
RikkaW committed Feb 21, 2021
1 parent a526d6b commit 41f02c3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)
}

Expand All @@ -46,7 +53,7 @@ class HomeViewModel : ViewModel() {
} catch (e: CancellationException) {

} catch (e: Throwable) {
_serviceStatus.postValue(Resource.error(e))
_serviceStatus.postValue(Resource.error(e, ServiceStatus()))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

0 comments on commit 41f02c3

Please sign in to comment.