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

Commit d720a4e3 authored by Chris Poultney's avatar Chris Poultney
Browse files

Remove obsolete "next component" field from WallpaperData

Justification: b/365991991#comment2

Fixes: 365991991
Flag: android.app.remove_next_wallpaper_component
Test: See b/365991991#comment3
Change-Id: I488c75349269b61817f0ac624c6c97b21e15866d
parent 23ff628d
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
package: "android.app"
container: "system"
flag {
  name: "remove_next_wallpaper_component"
  namespace: "systemui"
  description: "Remove deprecated field WallpaperData#nextWallpaperComponent. Only effective after rebooting."
  bug: "365991991"
}
+3 −0
Original line number Diff line number Diff line
@@ -80,8 +80,11 @@ class WallpaperData {
     */
    ComponentName wallpaperComponent;

    // TODO(b/347235611) Remove this field
    /**
     * The component name of the wallpaper that should be set next.
     *
     * @deprecated
     */
    ComponentName nextWallpaperComponent;

+28 −10
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.server.wallpaper;

import static android.app.Flags.removeNextWallpaperComponent;
import static android.app.WallpaperManager.FLAG_LOCK;
import static android.app.WallpaperManager.FLAG_SYSTEM;
import static android.app.WallpaperManager.ORIENTATION_UNKNOWN;
@@ -187,6 +188,16 @@ public class WallpaperDataParser {
                        }

                        String comp = parser.getAttributeValue(null, "component");
                        if (removeNextWallpaperComponent()) {
                            wallpaperToParse.wallpaperComponent = comp != null
                                    ? ComponentName.unflattenFromString(comp)
                                    : null;
                            if (wallpaperToParse.wallpaperComponent == null
                                    || "android".equals(wallpaperToParse.wallpaperComponent
                                    .getPackageName())) {
                                wallpaperToParse.wallpaperComponent = mImageWallpaper;
                            }
                        } else {
                            wallpaperToParse.nextWallpaperComponent = comp != null
                                    ? ComponentName.unflattenFromString(comp)
                                    : null;
@@ -195,6 +206,7 @@ public class WallpaperDataParser {
                                    .getPackageName())) {
                                wallpaperToParse.nextWallpaperComponent = mImageWallpaper;
                            }
                        }

                        if (multiCrop()) {
                            parseWallpaperAttributes(parser, wallpaperToParse, keepDimensionHints);
@@ -206,11 +218,15 @@ public class WallpaperDataParser {
                            Slog.v(TAG, "cropRect:" + wallpaper.cropHint);
                            Slog.v(TAG, "primaryColors:" + wallpaper.primaryColors);
                            Slog.v(TAG, "mName:" + wallpaper.name);
                            if (removeNextWallpaperComponent()) {
                                Slog.v(TAG, "mWallpaperComponent:" + wallpaper.wallpaperComponent);
                            } else {
                                Slog.v(TAG, "mNextWallpaperComponent:"
                                        + wallpaper.nextWallpaperComponent);
                            }
                        }
                    }
                }
            } while (type != XmlPullParser.END_DOCUMENT);
            success = true;
        } catch (FileNotFoundException e) {
@@ -324,7 +340,9 @@ public class WallpaperDataParser {
                getAttributeInt(parser, "totalCropTop", 0),
                getAttributeInt(parser, "totalCropRight", 0),
                getAttributeInt(parser, "totalCropBottom", 0));
        if (multiCrop() && mImageWallpaper.equals(wallpaper.nextWallpaperComponent)) {
        ComponentName componentName = removeNextWallpaperComponent() ? wallpaper.wallpaperComponent
                : wallpaper.nextWallpaperComponent;
        if (multiCrop() && mImageWallpaper.equals(componentName)) {
            wallpaper.mCropHints = new SparseArray<>();
            for (Pair<Integer, String> pair: screenDimensionPairs()) {
                Rect cropHint = new Rect(
+47 −26
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import static android.Manifest.permission.INTERACT_ACROSS_USERS_FULL;
import static android.Manifest.permission.MANAGE_EXTERNAL_STORAGE;
import static android.Manifest.permission.READ_WALLPAPER_INTERNAL;
import static android.app.ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND;
import static android.app.Flags.removeNextWallpaperComponent;
import static android.app.WallpaperManager.COMMAND_REAPPLY;
import static android.app.WallpaperManager.FLAG_LOCK;
import static android.app.WallpaperManager.FLAG_SYSTEM;
@@ -1474,6 +1475,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
                    }
                }
            }
            if (!removeNextWallpaperComponent()) {
                if (wallpaper.nextWallpaperComponent != null) {
                    int change = isPackageDisappearing(wallpaper.nextWallpaperComponent
                            .getPackageName());
@@ -1482,6 +1484,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
                        wallpaper.nextWallpaperComponent = null;
                    }
                }
            }
            if (wallpaper.wallpaperComponent != null
                    && isPackageModified(wallpaper.wallpaperComponent.getPackageName())) {
                try {
@@ -1494,16 +1497,19 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
                    clearWallpaperLocked(wallpaper.mWhich, wallpaper.userId, false, null);
                }
            }
            if (!removeNextWallpaperComponent()) {
                if (wallpaper.nextWallpaperComponent != null
                        && isPackageModified(wallpaper.nextWallpaperComponent.getPackageName())) {
                    try {
                    mContext.getPackageManager().getServiceInfo(wallpaper.nextWallpaperComponent,
                        mContext.getPackageManager().getServiceInfo(
                                wallpaper.nextWallpaperComponent,
                                PackageManager.MATCH_DIRECT_BOOT_AWARE
                                        | PackageManager.MATCH_DIRECT_BOOT_UNAWARE);
                    } catch (NameNotFoundException e) {
                        wallpaper.nextWallpaperComponent = null;
                    }
                }
            }
            return changed;
        }
    }
@@ -1628,7 +1634,14 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
        WallpaperData wallpaper = mWallpaperMap.get(UserHandle.USER_SYSTEM);
        // If we think we're going to be using the system image wallpaper imagery, make
        // sure we have something to render
        if (mImageWallpaper.equals(wallpaper.nextWallpaperComponent)) {
        boolean isImageComponent;
        if (removeNextWallpaperComponent()) {
            isImageComponent = wallpaper.wallpaperComponent == null
                    || mImageWallpaper.equals(wallpaper.wallpaperComponent);
        } else {
            isImageComponent = mImageWallpaper.equals(wallpaper.nextWallpaperComponent);
        }
        if (isImageComponent) {
            // No crop file? Make sure we've finished the processing sequence if necessary
            if (!wallpaper.cropExists()) {
                if (DEBUG) {
@@ -1877,8 +1890,13 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
            if ((wallpaper.mWhich & FLAG_SYSTEM) != 0) mHomeWallpaperWaitingForUnlock = false;
            if ((wallpaper.mWhich & FLAG_LOCK) != 0) mLockWallpaperWaitingForUnlock = false;

            final ComponentName cname = wallpaper.wallpaperComponent != null ?
                    wallpaper.wallpaperComponent : wallpaper.nextWallpaperComponent;
            final ComponentName cname;
            if (removeNextWallpaperComponent()) {
                cname = wallpaper.wallpaperComponent;
            } else {
                cname = (wallpaper.wallpaperComponent != null)
                        ? wallpaper.wallpaperComponent : wallpaper.nextWallpaperComponent;
            }
            if (!bindWallpaperComponentLocked(cname, true, false, wallpaper, reply)) {
                // We failed to bind the desired wallpaper, but that might
                // happen if the wallpaper isn't direct-boot aware
@@ -1905,10 +1923,12 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
            return;
        }
        Slog.w(TAG, "Wallpaper isn't direct boot aware; using fallback until unlocked");
        if (!removeNextWallpaperComponent()) {
            // We might end up persisting the current wallpaper data
            // while locked, so pretend like the component was actually
            // bound into place
            wallpaper.wallpaperComponent = wallpaper.nextWallpaperComponent;
        }
        final WallpaperData fallback = new WallpaperData(wallpaper.userId, wallpaper.mWhich);

        // files from the previous static wallpaper may still be stored in memory.
@@ -3788,10 +3808,12 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
            wallpaper = mWallpaperMap.get(UserHandle.USER_SYSTEM);
            wallpaper.wallpaperId = makeWallpaperIdLocked();    // always bump id at restore
            wallpaper.allowBackup = true;   // by definition if it was restored
            if (wallpaper.nextWallpaperComponent != null
                    && !wallpaper.nextWallpaperComponent.equals(mImageWallpaper)) {
            ComponentName componentName =
                    removeNextWallpaperComponent() ? wallpaper.wallpaperComponent
                            : wallpaper.nextWallpaperComponent;
            if (componentName != null && !componentName.equals(mImageWallpaper)) {
                wallpaper.mBindSource = BindSource.RESTORE_SETTINGS_LIVE_SUCCESS;
                if (!bindWallpaperComponentLocked(wallpaper.nextWallpaperComponent, false, false,
                if (!bindWallpaperComponentLocked(componentName, false, false,
                        wallpaper, null)) {
                    // No such live wallpaper or other failure; fall back to the default
                    // live wallpaper (since the profile being restored indicated that the
@@ -3815,8 +3837,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
                if (success) {
                    mWallpaperCropper.generateCrop(wallpaper); // based on the new image + metadata
                    wallpaper.mBindSource = BindSource.RESTORE_SETTINGS_STATIC;
                    bindWallpaperComponentLocked(wallpaper.nextWallpaperComponent, true, false,
                            wallpaper, null);
                    bindWallpaperComponentLocked(componentName, true, false, wallpaper, null);
                }
            }
        }