diff options
| author | 2023-09-14 21:11:48 +0000 | |
|---|---|---|
| committer | 2023-09-14 21:11:48 +0000 | |
| commit | fd13c5f2d2d2263e8f043f5f6b4dc26e0f939af1 (patch) | |
| tree | 4468f1ed0e9e9ca0def9ecd16b629e1eb6f21e09 | |
| parent | de159db9e960049618a85b77ee4c123171e7f34d (diff) | |
| parent | 6365e73524465b94aadb1777cf7f7dcfc83edcec (diff) | |
Merge "Update wallpaper packageMonitor & tryToRebind for LWP" into udc-qpr-dev-plus-aosp
| -rw-r--r-- | services/core/java/com/android/server/wallpaper/WallpaperManagerService.java | 59 |
1 files changed, 34 insertions, 25 deletions
diff --git a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java index 1fe1575a2b06..81c4dcdd5f52 100644 --- a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java +++ b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java @@ -1005,12 +1005,11 @@ public class WallpaperManagerService extends IWallpaperManager.Stub return; } - if (!mWallpaper.wallpaperUpdating - && mWallpaper.userId == mCurrentUserId) { + if (!mWallpaper.wallpaperUpdating && mWallpaper.userId == mCurrentUserId) { Slog.w(TAG, "Wallpaper reconnect timed out for " + mWallpaper.wallpaperComponent + ", reverting to built-in wallpaper!"); - clearWallpaperLocked(true, FLAG_SYSTEM, mWallpaper.userId, - null); + int which = mIsLockscreenLiveWallpaperEnabled ? mWallpaper.mWhich : FLAG_SYSTEM; + clearWallpaperLocked(true, which, mWallpaper.userId, null); } } }; @@ -1190,7 +1189,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub } else { // Timeout Slog.w(TAG, "Reverting to built-in wallpaper!"); - clearWallpaperLocked(true, FLAG_SYSTEM, mWallpaper.userId, null); + clearWallpaperLocked(true, mWallpaper.mWhich, mWallpaper.userId, null); final String flattened = wpService.flattenToString(); EventLog.writeEvent(EventLogTags.WP_WALLPAPER_CRASHED, flattened.substring(0, Math.min(flattened.length(), @@ -1228,8 +1227,8 @@ public class WallpaperManagerService extends IWallpaperManager.Stub mLmkLimitRebindRetries = LMK_RECONNECT_REBIND_RETRIES; } else { if (mLmkLimitRebindRetries <= 0) { - Slog.w(TAG, "Reverting to built-in wallpaper due to lmk!"); - clearWallpaperLocked(true, FLAG_SYSTEM, mWallpaper.userId, + Slog.w(TAG, "Reverting to built-in wallpaper due to lmk!"); + clearWallpaperLocked(true, mWallpaper.mWhich, mWallpaper.userId, null); mLmkLimitRebindRetries = LMK_RECONNECT_REBIND_RETRIES; return; @@ -1472,8 +1471,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub if (mCurrentUserId != getChangingUserId()) { return; } - WallpaperData wallpaper = mWallpaperMap.get(mCurrentUserId); - if (wallpaper != null) { + for (WallpaperData wallpaper: getWallpapers()) { final ComponentName wpService = wallpaper.wallpaperComponent; if (wpService != null && wpService.getPackageName().equals(packageName)) { if (DEBUG_LIVE) { @@ -1485,7 +1483,9 @@ public class WallpaperManagerService extends IWallpaperManager.Stub wallpaper, null)) { Slog.w(TAG, "Wallpaper " + wpService + " no longer available; reverting to default"); - clearWallpaperLocked(false, FLAG_SYSTEM, wallpaper.userId, null); + int which = mIsLockscreenLiveWallpaperEnabled + ? wallpaper.mWhich : FLAG_SYSTEM; + clearWallpaperLocked(false, which, wallpaper.userId, null); } } } @@ -1498,13 +1498,11 @@ public class WallpaperManagerService extends IWallpaperManager.Stub if (mCurrentUserId != getChangingUserId()) { return; } - WallpaperData wallpaper = mWallpaperMap.get(mCurrentUserId); - if (wallpaper != null) { - if (wallpaper.wallpaperComponent == null - || !wallpaper.wallpaperComponent.getPackageName().equals(packageName)) { - return; + for (WallpaperData wallpaper: getWallpapers()) { + if (wallpaper.wallpaperComponent != null + && wallpaper.wallpaperComponent.getPackageName().equals(packageName)) { + doPackagesChangedLocked(true, wallpaper); } - doPackagesChangedLocked(true, wallpaper); } } } @@ -1515,8 +1513,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub if (mCurrentUserId != getChangingUserId()) { return; } - WallpaperData wallpaper = mWallpaperMap.get(mCurrentUserId); - if (wallpaper != null) { + for (WallpaperData wallpaper: getWallpapers()) { if (wallpaper.wallpaperComponent != null && wallpaper.wallpaperComponent.getPackageName().equals(packageName)) { if (DEBUG_LIVE) { @@ -1540,8 +1537,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub if (mCurrentUserId != getChangingUserId()) { return false; } - WallpaperData wallpaper = mWallpaperMap.get(mCurrentUserId); - if (wallpaper != null) { + for (WallpaperData wallpaper: getWallpapers()) { boolean res = doPackagesChangedLocked(doit, wallpaper); changed |= res; } @@ -1555,8 +1551,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub if (mCurrentUserId != getChangingUserId()) { return; } - WallpaperData wallpaper = mWallpaperMap.get(mCurrentUserId); - if (wallpaper != null) { + for (WallpaperData wallpaper: getWallpapers()) { doPackagesChangedLocked(true, wallpaper); } } @@ -1564,6 +1559,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub boolean doPackagesChangedLocked(boolean doit, WallpaperData wallpaper) { boolean changed = false; + int which = mIsLockscreenLiveWallpaperEnabled ? wallpaper.mWhich : FLAG_SYSTEM; if (wallpaper.wallpaperComponent != null) { int change = isPackageDisappearing(wallpaper.wallpaperComponent .getPackageName()); @@ -1573,7 +1569,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub if (doit) { Slog.w(TAG, "Wallpaper uninstalled, removing: " + wallpaper.wallpaperComponent); - clearWallpaperLocked(false, FLAG_SYSTEM, wallpaper.userId, null); + clearWallpaperLocked(false, which, wallpaper.userId, null); } } } @@ -1594,7 +1590,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub } catch (NameNotFoundException e) { Slog.w(TAG, "Wallpaper component gone, removing: " + wallpaper.wallpaperComponent); - clearWallpaperLocked(false, FLAG_SYSTEM, wallpaper.userId, null); + clearWallpaperLocked(false, which, wallpaper.userId, null); } } if (wallpaper.nextWallpaperComponent != null @@ -1709,7 +1705,8 @@ public class WallpaperManagerService extends IWallpaperManager.Stub if (DEBUG) { Slog.i(TAG, "Unable to regenerate crop; resetting"); } - clearWallpaperLocked(false, FLAG_SYSTEM, UserHandle.USER_SYSTEM, null); + int which = isLockscreenLiveWallpaperEnabled() ? wallpaper.mWhich : FLAG_SYSTEM; + clearWallpaperLocked(false, which, UserHandle.USER_SYSTEM, null); } } else { if (DEBUG) { @@ -2831,6 +2828,18 @@ public class WallpaperManagerService extends IWallpaperManager.Stub : new WallpaperData[0]; } + // TODO(b/266818039) remove + private WallpaperData[] getWallpapers() { + WallpaperData systemWallpaper = mWallpaperMap.get(mCurrentUserId); + WallpaperData lockWallpaper = mLockWallpaperMap.get(mCurrentUserId); + boolean systemValid = systemWallpaper != null; + boolean lockValid = lockWallpaper != null && !isLockscreenLiveWallpaperEnabled(); + return systemValid && lockValid ? new WallpaperData[]{systemWallpaper, lockWallpaper} + : systemValid ? new WallpaperData[]{systemWallpaper} + : lockValid ? new WallpaperData[]{lockWallpaper} + : new WallpaperData[0]; + } + private IWallpaperEngine getEngine(int which, int userId, int displayId) { WallpaperData wallpaperData = findWallpaperAtDisplay(userId, displayId); if (wallpaperData == null) return null; |