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

Commit 87ca2ade authored by Chris Poultney's avatar Chris Poultney
Browse files

Clarify semantics of changingToSame function

WallpaperManagerService#changingToSame takes both the "new" wallpaper
component and the "new" WallpaperData to decide if the new live
wallpaper is the same as the old. But it only used two fields from
WallpaperData, both of which still referred to the current wallpaper.
This change makes the "new" versus "current" semantics clear.

Bug: 347235611
Test: switching live wallpapers works as expected
Flag: EXEMPT cleanup
Change-Id: Ifb9198337a3dfade196d0e18423c2050433bebb4
parent a27cfdeb
Loading
Loading
Loading
Loading
+10 −7
Original line number Diff line number Diff line
@@ -3169,7 +3169,8 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
                final WallpaperDestinationChangeHandler
                        liveSync = new WallpaperDestinationChangeHandler(
                        newWallpaper);
                boolean same = changingToSame(name, newWallpaper);
                boolean same = changingToSame(name, newWallpaper.connection,
                        newWallpaper.wallpaperComponent);

                /*
                 * If we have a shared system+lock wallpaper, and we reapply the same wallpaper
@@ -3257,14 +3258,15 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
        return name == null || name.equals(mDefaultWallpaperComponent);
    }

    private boolean changingToSame(ComponentName componentName, WallpaperData wallpaper) {
        if (wallpaper.connection != null) {
            final ComponentName wallpaperName = wallpaper.wallpaperComponent;
            if (isDefaultComponent(componentName) && isDefaultComponent(wallpaperName)) {
    private boolean changingToSame(ComponentName newComponentName,
            WallpaperConnection currentConnection, ComponentName currentComponentName) {
        if (currentConnection != null) {
            if (isDefaultComponent(newComponentName) && isDefaultComponent(currentComponentName)) {
                if (DEBUG) Slog.v(TAG, "changingToSame: still using default");
                // Still using default wallpaper.
                return true;
            } else if (wallpaperName != null && wallpaperName.equals(componentName)) {
            } else if (currentComponentName != null && currentComponentName.equals(
                    newComponentName)) {
                // Changing to same wallpaper.
                if (DEBUG) Slog.v(TAG, "same wallpaper");
                return true;
@@ -3279,7 +3281,8 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
            Slog.v(TAG, "bindWallpaperComponentLocked: componentName=" + componentName);
        }
        // Has the component changed?
        if (!force && changingToSame(componentName, wallpaper)) {
        if (!force && changingToSame(componentName, wallpaper.connection,
                wallpaper.wallpaperComponent)) {
            try {
                if (DEBUG_LIVE) {
                    Slog.v(TAG, "Changing to the same component, ignoring");