Fixed crash where new application asks for root access

This commit is contained in:
Viktor De Pasquale 2019-05-13 15:56:27 +02:00
parent 337fda2023
commit 0850401dc4
2 changed files with 3 additions and 2 deletions

View File

@ -44,7 +44,7 @@ class PolicyDao(
condition {
equals("uid", uid)
}
}.map { it.first().toPolicy(context.packageManager) }
}.map { it.firstOrNull()?.toPolicy(context.packageManager) }
.doOnError {
if (it is PackageManager.NameNotFoundException) {
delete(uid).subscribe()

View File

@ -110,7 +110,8 @@ class SuRequestViewModel(
val bundle = connector.readSocketInput()
val uid = bundle.getString("uid")?.toIntOrNull() ?: return false
appRepo.deleteOutdated().blockingGet() // wrong!
policy = appRepo.fetch(uid).blockingGet() ?: uid.toPolicy(packageManager)
policy = runCatching { appRepo.fetch(uid).blockingGet() }
.getOrDefault(uid.toPolicy(packageManager))
} catch (e: IOException) {
e.printStackTrace()
return false