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

Commit 9369c760 authored by Oli Thompson's avatar Oli Thompson Committed by Android (Google) Code Review
Browse files

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

parents a21164e9 c05c4cd9
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);