Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 059610e8 authored by Nate Myren's avatar Nate Myren
Browse files

Add exception check to util methods

Add a catch for NameNotFoundExceptions for the package label and icon
util methods
Test: Uninstall app while on settings screen, and observe
Fixes: 147143320

Change-Id: I4b38f510502078889c208cebf298b280d23cddf3
parent 08b0c391
Loading
Loading
Loading
Loading
+14 −6
Original line number Diff line number Diff line
@@ -230,9 +230,13 @@ object KotlinUtils {
     * @return The package's icon, or null, if the package does not exist
     */
    fun getBadgedPackageIcon(app: Application, packageName: String, user: UserHandle): Drawable? {
        return try {
            val userContext = Utils.getUserContext(app, user)
            val appInfo = userContext.packageManager.getApplicationInfo(packageName, 0)
        return Utils.getBadgedIcon(app, appInfo)
            Utils.getBadgedIcon(app, appInfo)
        } catch (e: PackageManager.NameNotFoundException) {
            null
        }
    }

    /**
@@ -245,9 +249,13 @@ object KotlinUtils {
     * @return The package's label
     */
    fun getPackageLabel(app: Application, packageName: String, user: UserHandle): String {
        return try {
            val userContext = Utils.getUserContext(app, user)
            val appInfo = userContext.packageManager.getApplicationInfo(packageName, 0)
        return Utils.getFullAppLabel(appInfo, app)
            Utils.getFullAppLabel(appInfo, app)
        } catch (e: PackageManager.NameNotFoundException) {
            packageName
        }
    }

    /**