From 7d307b267cd07f02f1f37b9ad6cda83f91b32427 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 9 May 2023 11:56:39 +0200 Subject: [PATCH] catch android.os.DeadSystemException --- .../shared/extensions/PackageManagerExtension.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app-wear-shared/shared/src/main/java/info/nightscout/shared/extensions/PackageManagerExtension.kt b/app-wear-shared/shared/src/main/java/info/nightscout/shared/extensions/PackageManagerExtension.kt index 003236cd9e..928d0fdcda 100644 --- a/app-wear-shared/shared/src/main/java/info/nightscout/shared/extensions/PackageManagerExtension.kt +++ b/app-wear-shared/shared/src/main/java/info/nightscout/shared/extensions/PackageManagerExtension.kt @@ -16,8 +16,12 @@ fun PackageManager.safeGetInstalledPackages(flags: Int): List = * Safe version of queryBroadcastReceivers depending on Android version running */ fun PackageManager.safeQueryBroadcastReceivers(intent: Intent, flags: Int): List = - 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) + try { + 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