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

Commit bae9abd2 authored by Jakob Schneider's avatar Jakob Schneider Committed by Android (Google) Code Review
Browse files

Merge "Add additional null checks for icon fetching of archived apps." into main

parents 46fad8a4 e889fc9f
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -819,6 +819,7 @@ public class PackageArchiver {
     * <p> The icon is returned without any treatment/overlay. In the rare case the app had multiple
     * launcher activities, only one of the icons is returned arbitrarily.
     */
    @Nullable
    public Bitmap getArchivedAppIcon(@NonNull String packageName, @NonNull UserHandle user,
            String callingPackageName) {
        Objects.requireNonNull(packageName);
@@ -844,7 +845,7 @@ public class PackageArchiver {
        // In the rare case the archived app defined more than two launcher activities, we choose
        // the first one arbitrarily.
        Bitmap icon = decodeIcon(archiveState.getActivityInfos().get(0));
        if (getAppOpsManager().checkOp(
        if (icon != null && getAppOpsManager().checkOp(
                AppOpsManager.OP_ARCHIVE_ICON_OVERLAY, callingUid, callingPackageName)
                == MODE_ALLOWED) {
            icon = includeCloudOverlay(icon);
@@ -900,6 +901,7 @@ public class PackageArchiver {
        return bitmap;
    }

    @Nullable
    Bitmap includeCloudOverlay(Bitmap bitmap) {
        Drawable cloudDrawable =
                mContext.getResources()
@@ -920,7 +922,9 @@ public class PackageArchiver {
        final int iconSize = mContext.getSystemService(
                ActivityManager.class).getLauncherLargeIconSize();
        Bitmap appIconWithCloudOverlay = drawableToBitmap(layerDrawable, iconSize);
        if (bitmap != null) {
            bitmap.recycle();
        }
        return appIconWithCloudOverlay;
    }