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

Commit 4306a924 authored by Daniel Nishi's avatar Daniel Nishi
Browse files

Upstream getApplicationLabel().

Bug: 37435967
Test: Used in StorageManager robotest
Change-Id: Ia8862322b0cab13e66d544ccf266f0cd5ec6bc89
parent 1466c161
Loading
Loading
Loading
Loading
+16 −0
Original line number Original line Diff line number Diff line
@@ -107,4 +107,20 @@ public class AppUtils {
        return false;
        return false;
    }
    }


    /** Returns the label for a given package. */
    public static CharSequence getApplicationLabel(
            PackageManager packageManager, String packageName) {
        try {
            final ApplicationInfo appInfo =
                    packageManager.getApplicationInfo(
                            packageName,
                            PackageManager.MATCH_DISABLED_COMPONENTS
                                    | PackageManager.MATCH_ANY_USER);
            return appInfo.loadLabel(packageManager);
        } catch (PackageManager.NameNotFoundException e) {
            Log.w(TAG, "Unable to find info for package: " + packageName);
        }
        return null;
    }

}
}