commit 3c00f5da50c6084165d8259d3a42dd0800473b75 parent 0702eff34b77caad7dc4865bc1da92dd9f8ff40e Author: t-p-white <towhite@mozilla.com> Date: Thu, 16 Oct 2025 12:13:22 +0000 Bug 1994679 - Added `throws`doc to getPackageInfoCompat for UnsupportedOperationException and handling the exception in getApplicationInstalledTime r=android-reviewers,rebecatudor273,anpopa Differential Revision: https://phabricator.services.mozilla.com/D268852 Diffstat:
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/mobile/android/android-components/components/support/utils/src/main/java/mozilla/components/support/utils/ext/PackageManager.kt b/mobile/android/android-components/components/support/utils/src/main/java/mozilla/components/support/utils/ext/PackageManager.kt @@ -40,10 +40,12 @@ fun PackageManager.resolveActivityCompat(intent: Intent, flag: Int): ResolveInfo } /** - * Get a package info with a specified flag + * Get a package info with a specified flag. * * @param packageName The name of the package to check for. - * @throws PackageManager.NameNotFoundException if the package for [packageName] is not installed. + * + * @throws PackageManager.NameNotFoundException (API >= 33) if the package for [packageName] is not installed. + * @throws UnsupportedOperationException (API <= 32) if getPackageInfo is not implemented in subclass. */ fun PackageManager.getPackageInfoCompat(packageName: String, flag: Int): PackageInfo { return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/ext/Context.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/ext/Context.kt @@ -189,4 +189,7 @@ fun Context.getApplicationInstalledTime(logger: Logger): Long = try { } catch (e: PackageManager.NameNotFoundException) { logger.warn("Unable to retrieve package info for $packageName", e) 0L +} catch (e: UnsupportedOperationException) { + logger.warn("Unable to retrieve package info for $packageName", e) + 0L }