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

Commit e889fc9f authored by Jakob Schneider's avatar Jakob Schneider
Browse files

Add additional null checks for icon fetching of archived apps.

Test: n/a
Bug: 323186526
Change-Id: I9e58551bf319b57efafebcd4be2e6b858cd4bdaa
parent 80f831d8
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -803,6 +803,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);
@@ -828,7 +829,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);
@@ -884,6 +885,7 @@ public class PackageArchiver {
        return bitmap;
    }

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