Skip to content

Commit 6e2ef49

Browse files
muhomorrthestinger
authored andcommitted
prevent RpcProvider from crashing when it receives an invalid call
1 parent 12be4f0 commit 6e2ef49

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

app/src/main/java/app/grapheneos/apps/RpcProvider.kt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,17 @@ class RpcProvider : ContentProvider() {
2929
when (method) {
3030
"update_package" -> {
3131
val callingPackage = callingPackage!!
32+
val pkgName = arg!!
3233
val callback = extras?.maybeGetParcelable<Messenger>("callback")
3334
CoroutineScope(Dispatchers.Main).launch {
34-
val res: Boolean = updatePackage(callingPackage, arg!!)
35-
callback?.send(Message().apply { arg1 = res.toInt() })
35+
val res = runCatching {
36+
updatePackage(callingPackage, pkgName)
37+
}
38+
res.exceptionOrNull()?.let {
39+
Log.e("RpcProvider", method, it)
40+
}
41+
val resBool = res.getOrNull() ?: false
42+
callback?.send(Message().apply { arg1 = resBool.toInt() })
3643
}
3744
return null
3845
}

0 commit comments

Comments
 (0)