fix: crash with disable com.android.stk app (#60)
All checks were successful
/ build-debug (push) Successful in 5m40s
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:
parent
6f8aef8ea8
commit
071304349a
1 changed files with 10 additions and 7 deletions
|
@ -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) =
|
||||
|
|
Loading…
Reference in a new issue