catch android.os.DeadSystemException
This commit is contained in:
parent
62cea47d57
commit
7d307b267c
1 changed files with 6 additions and 2 deletions
|
@ -16,8 +16,12 @@ fun PackageManager.safeGetInstalledPackages(flags: Int): List<PackageInfo> =
|
||||||
* Safe version of queryBroadcastReceivers depending on Android version running
|
* Safe version of queryBroadcastReceivers depending on Android version running
|
||||||
*/
|
*/
|
||||||
fun PackageManager.safeQueryBroadcastReceivers(intent: Intent, flags: Int): List<ResolveInfo> =
|
fun PackageManager.safeQueryBroadcastReceivers(intent: Intent, flags: Int): List<ResolveInfo> =
|
||||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.TIRAMISU) queryBroadcastReceivers(intent, PackageManager.ResolveInfoFlags.of(flags.toLong()))
|
try {
|
||||||
else @Suppress("DEPRECATION") queryBroadcastReceivers(intent, flags)
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.TIRAMISU) queryBroadcastReceivers(intent, PackageManager.ResolveInfoFlags.of(flags.toLong()))
|
||||||
|
else @Suppress("DEPRECATION") queryBroadcastReceivers(intent, flags)
|
||||||
|
} catch (ignored: Exception) {
|
||||||
|
emptyList()
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Safe version of getPackageInfo depending on Android version running
|
* Safe version of getPackageInfo depending on Android version running
|
||||||
|
|
Loading…
Reference in a new issue