From e78a9805b8aa6f150802ec5aa071a68c54049867 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Pomini?= Date: Mon, 19 Jun 2023 12:45:01 +0000 Subject: [PATCH] use new clearWallpaperLocked method everywhere The old clear method had a lot of references. Replace these references with a call to the new clear method. Now, everything that tries to clear the wallpaper will call setWallpaperComponent(..) and not directly bindWallpaperComponentLocked. Flag: lockscreen lwp Bug: 273443374 Test: atest WallpaperManagerTest Change-Id: I2c7e8c3b4bcaf5a378e5f3b903075c422e2c432a --- .../wallpaper/WallpaperManagerService.java | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java index 9b2cdd72a338c..a790dfd8b7681 100644 --- a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java +++ b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java @@ -1993,7 +1993,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub WallpaperData data = null; synchronized (mLock) { if (mIsLockscreenLiveWallpaperEnabled) { - clearWallpaperLocked(callingPackage, false, which, userId); + clearWallpaperLocked(callingPackage, false, which, userId, null); } else { clearWallpaperLocked(false, which, userId, null); } @@ -2014,7 +2014,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub } private void clearWallpaperLocked(String callingPackage, boolean defaultFailed, - int which, int userId) { + int which, int userId, IRemoteCallback reply) { // Might need to bring it in the first time to establish our rewrite if (!mWallpaperMap.contains(userId)) { @@ -2068,9 +2068,15 @@ public class WallpaperManagerService extends IWallpaperManager.Stub withCleanCallingIdentity(() -> clearWallpaperComponentLocked(wallpaper)); } - // TODO(b/266818039) remove this version of the method private void clearWallpaperLocked(boolean defaultFailed, int which, int userId, IRemoteCallback reply) { + + if (mIsLockscreenLiveWallpaperEnabled) { + String callingPackage = mPackageManagerInternal.getNameForUid(getCallingUid()); + clearWallpaperLocked(callingPackage, defaultFailed, which, userId, reply); + return; + } + if (which != FLAG_SYSTEM && which != FLAG_LOCK) { throw new IllegalArgumentException("Must specify exactly one kind of wallpaper to clear"); } @@ -3234,15 +3240,21 @@ public class WallpaperManagerService extends IWallpaperManager.Stub boolean setWallpaperComponent(ComponentName name, String callingPackage, @SetWallpaperFlags int which, int userId) { if (mIsLockscreenLiveWallpaperEnabled) { - return setWallpaperComponentInternal(name, callingPackage, which, userId); + return setWallpaperComponentInternal(name, callingPackage, which, userId, null); } else { setWallpaperComponentInternalLegacy(name, callingPackage, which, userId); return true; } } + private boolean setWallpaperComponent(ComponentName name, @SetWallpaperFlags int which, + int userId) { + String callingPackage = mPackageManagerInternal.getNameForUid(getCallingUid()); + return setWallpaperComponentInternal(name, callingPackage, which, userId, null); + } + private boolean setWallpaperComponentInternal(ComponentName name, String callingPackage, - @SetWallpaperFlags int which, int userIdIn) { + @SetWallpaperFlags int which, int userIdIn, IRemoteCallback reply) { if (DEBUG) { Slog.v(TAG, "Setting new live wallpaper: which=" + which + ", component: " + name); } @@ -3291,6 +3303,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub Slog.d(TAG, "publish system wallpaper changed!"); } liveSync.complete(); + if (reply != null) reply.sendResult(null); } };