fix: crash with disable com.android.stk app (#60)
All checks were successful
/ build-debug (push) Successful in 5m40s

```console
pm disable-user com.android.stk
```

after running this command, the app will crash when launched

Reviewed-on: #60
Co-authored-by: septs <github@septs.pw>
Co-committed-by: septs <github@septs.pw>
This commit is contained in:
septs 2024-11-12 02:42:25 +01:00 committed by Peter Cai
parent 6f8aef8ea8
commit 071304349a

View file

@ -34,13 +34,16 @@ class SIMToolkit(private val context: Context) {
null
}
private fun getActivities(packageName: String) = try {
val pm = context.packageManager
val packageInfo = pm.getPackageInfo(packageName, PackageManager.GET_ACTIVITIES)
packageInfo.activities!!.filter { it.exported }
.map { ComponentName(it.packageName, it.name) }
} catch (_: PackageManager.NameNotFoundException) {
emptyList()
private fun getActivities(packageName: String): List<ComponentName> {
return try {
val pm = context.packageManager
val packageInfo = pm.getPackageInfo(packageName, PackageManager.GET_ACTIVITIES)
val activities = packageInfo.activities
if (activities.isNullOrEmpty()) return emptyList()
activities.filter { it.exported }.map { ComponentName(it.packageName, it.name) }
} catch (_: PackageManager.NameNotFoundException) {
emptyList()
}
}
private fun getComponentNames(@ArrayRes id: Int) =