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

Commit 4edc37f2 authored by Oli Thompson's avatar Oli Thompson Committed by Automerger Merge Worker
Browse files

Merge "Fix null pointer exception when getting app label for headless app"...

Merge "Fix null pointer exception when getting app label for headless app" into udc-qpr-dev am: 9369c760

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/24443488



Change-Id: Iaf694e15f936805b9b7878d4b422f3218210b346
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents e84f770b 9369c760
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -344,15 +344,22 @@ public class CrossProfileApps {
        // If there is a label for the launcher intent, then use that as it is typically shorter.
        // Otherwise, just use the top-level application name.
        Intent launchIntent = pm.getLaunchIntentForPackage(mContext.getPackageName());
        if (launchIntent == null) {
            return getDefaultCallingApplicationLabel();
        }
        List<ResolveInfo> infos =
                pm.queryIntentActivities(
                        launchIntent, PackageManager.ResolveInfoFlags.of(MATCH_DEFAULT_ONLY));
        if (infos.size() > 0) {
            return infos.get(0).loadLabel(pm);
        }
        return getDefaultCallingApplicationLabel();
    }

    private CharSequence getDefaultCallingApplicationLabel() {
        return mContext.getApplicationInfo()
                .loadSafeLabel(
                        pm,
                        mContext.getPackageManager(),
                        /* ellipsizeDip= */ 0,
                        TextUtils.SAFE_STRING_FLAG_SINGLE_LINE
                                | TextUtils.SAFE_STRING_FLAG_TRIM);