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

Commit 82451db7 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Fixes blank lock screen wallpaper after change wp from home to both"...

Merge "Fixes blank lock screen wallpaper after change wp from home to both" into udc-dev am: 2d7c7aa6

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/22907819



Change-Id: Ie8539c8505fd8d508d9f7547186f9166e437a3e9
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 7b35805d 2d7c7aa6
Loading
Loading
Loading
Loading
+29 −25
Original line number Original line Diff line number Diff line
@@ -1353,9 +1353,6 @@ public class WallpaperManagerService extends IWallpaperManager.Stub


        void complete() {
        void complete() {
            // Only changes from home+lock to just home or lock need attention
            // Only changes from home+lock to just home or lock need attention
            // If setting the wallpaper fails, this callback will be called
            // when the wallpaper is detached, in which case wallpapers may have
            // already changed. Make sure we're not overwriting a more recent wallpaper.
            if (mNewWallpaper.mSystemWasBoth) {
            if (mNewWallpaper.mSystemWasBoth) {
                if (DEBUG) {
                if (DEBUG) {
                    Slog.v(TAG, "Handling change from system+lock wallpaper");
                    Slog.v(TAG, "Handling change from system+lock wallpaper");
@@ -1378,7 +1375,8 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
                                    mOriginalSystem.wallpaperComponent;
                                    mOriginalSystem.wallpaperComponent;
                            lockWp.connection = mOriginalSystem.connection;
                            lockWp.connection = mOriginalSystem.connection;
                            lockWp.connection.mWallpaper = lockWp;
                            lockWp.connection.mWallpaper = lockWp;
                            updateEngineFlags(mOriginalSystem, FLAG_LOCK);
                            mOriginalSystem.mWhich = FLAG_LOCK;
                            updateEngineFlags(mOriginalSystem);
                            notifyWallpaperColorsChanged(lockWp, FLAG_LOCK);
                            notifyWallpaperColorsChanged(lockWp, FLAG_LOCK);
                        } else {
                        } else {
                            // Failed rename, use current system wp for both
                            // Failed rename, use current system wp for both
@@ -1387,7 +1385,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
                            }
                            }
                            WallpaperData currentSystem = mWallpaperMap.get(mNewWallpaper.userId);
                            WallpaperData currentSystem = mWallpaperMap.get(mNewWallpaper.userId);
                            currentSystem.mWhich = FLAG_SYSTEM | FLAG_LOCK;
                            currentSystem.mWhich = FLAG_SYSTEM | FLAG_LOCK;
                            updateEngineFlags(currentSystem, FLAG_SYSTEM | FLAG_LOCK);
                            updateEngineFlags(currentSystem);
                            mLockWallpaperMap.remove(mNewWallpaper.userId);
                            mLockWallpaperMap.remove(mNewWallpaper.userId);
                        }
                        }
                    } else {
                    } else {
@@ -1396,7 +1394,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
                            Slog.v(TAG, "live system+lock to system success");
                            Slog.v(TAG, "live system+lock to system success");
                        }
                        }
                        mOriginalSystem.mWhich = FLAG_LOCK;
                        mOriginalSystem.mWhich = FLAG_LOCK;
                        updateEngineFlags(mOriginalSystem, FLAG_LOCK);
                        updateEngineFlags(mOriginalSystem);
                        mLockWallpaperMap.put(mNewWallpaper.userId, mOriginalSystem);
                        mLockWallpaperMap.put(mNewWallpaper.userId, mOriginalSystem);
                        mLastLockWallpaper = mOriginalSystem;
                        mLastLockWallpaper = mOriginalSystem;
                        notifyWallpaperColorsChanged(mOriginalSystem, FLAG_LOCK);
                        notifyWallpaperColorsChanged(mOriginalSystem, FLAG_LOCK);
@@ -1409,7 +1407,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
                    WallpaperData currentSystem = mWallpaperMap.get(mNewWallpaper.userId);
                    WallpaperData currentSystem = mWallpaperMap.get(mNewWallpaper.userId);
                    if (currentSystem.wallpaperId == mOriginalSystem.wallpaperId) {
                    if (currentSystem.wallpaperId == mOriginalSystem.wallpaperId) {
                        currentSystem.mWhich = FLAG_SYSTEM;
                        currentSystem.mWhich = FLAG_SYSTEM;
                        updateEngineFlags(currentSystem, FLAG_SYSTEM);
                        updateEngineFlags(currentSystem);
                    }
                    }
                }
                }
            }
            }
@@ -1422,24 +1420,6 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
                Slog.v(TAG, "new lastLockWp: " + mLastLockWallpaper);
                Slog.v(TAG, "new lastLockWp: " + mLastLockWallpaper);
            }
            }
        }
        }

        private void updateEngineFlags(WallpaperData wallpaper, @SetWallpaperFlags int which) {
            if (wallpaper.connection == null) {
                return;
            }
            wallpaper.connection.forEachDisplayConnector(
                    connector -> {
                        try {
                            if (connector.mEngine != null) {
                                connector.mEngine.setWallpaperFlags(which);
                                mWindowManagerInternal.setWallpaperShowWhenLocked(
                                        connector.mToken, (which & FLAG_LOCK) != 0);
                            }
                        } catch (RemoteException e) {
                            Slog.e(TAG, "Failed to update wallpaper engine flags", e);
                        }
                    });
        }
    }
    }


    class MyPackageMonitor extends PackageMonitor {
    class MyPackageMonitor extends PackageMonitor {
@@ -3095,6 +3075,9 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
                                newWallpaper.userId);
                                newWallpaper.userId);
                        if (lockedWallpaper != null) {
                        if (lockedWallpaper != null) {
                            detachWallpaperLocked(lockedWallpaper);
                            detachWallpaperLocked(lockedWallpaper);
                            if (same) {
                                updateEngineFlags(newWallpaper);
                            }
                        }
                        }
                        mLockWallpaperMap.remove(newWallpaper.userId);
                        mLockWallpaperMap.remove(newWallpaper.userId);
                    }
                    }
@@ -3430,6 +3413,27 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
        }
        }
    }
    }


    // Updates the given wallpaper's Engine so that its destination flags are the same as those of
    // the wallpaper, e.g., after a wallpaper has been changed from displaying on home+lock to home
    // or lock only.
    private void updateEngineFlags(WallpaperData wallpaper) {
        if (wallpaper.connection == null) {
            return;
        }
        wallpaper.connection.forEachDisplayConnector(
                connector -> {
                    try {
                        if (connector.mEngine != null) {
                            connector.mEngine.setWallpaperFlags(wallpaper.mWhich);
                            mWindowManagerInternal.setWallpaperShowWhenLocked(
                                    connector.mToken, (wallpaper.mWhich & FLAG_LOCK) != 0);
                        }
                    } catch (RemoteException e) {
                        Slog.e(TAG, "Failed to update wallpaper engine flags", e);
                    }
                });
    }

    private void clearWallpaperComponentLocked(WallpaperData wallpaper) {
    private void clearWallpaperComponentLocked(WallpaperData wallpaper) {
        wallpaper.wallpaperComponent = null;
        wallpaper.wallpaperComponent = null;
        detachWallpaperLocked(wallpaper);
        detachWallpaperLocked(wallpaper);