diff --git a/app/src/main/java/com/topjohnwu/magisk/data/database/PolicyDao.kt b/app/src/main/java/com/topjohnwu/magisk/data/database/PolicyDao.kt index e8ef9ddf2..16ce52afb 100644 --- a/app/src/main/java/com/topjohnwu/magisk/data/database/PolicyDao.kt +++ b/app/src/main/java/com/topjohnwu/magisk/data/database/PolicyDao.kt @@ -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() diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/surequest/SuRequestViewModel.kt b/app/src/main/java/com/topjohnwu/magisk/ui/surequest/SuRequestViewModel.kt index b5abb974a..e452db355 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/surequest/SuRequestViewModel.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/surequest/SuRequestViewModel.kt @@ -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