diff options
| author | 2023-08-30 12:49:25 +0000 | |
|---|---|---|
| committer | 2023-09-13 10:02:50 +0000 | |
| commit | c65d91dd3ab27672860585377aef01cdfcb888b5 (patch) | |
| tree | 56210a06b72eb50bb77d68faa5016c0bb19806bc | |
| parent | 1e68053f67a6f91da7fc946be547d4ee3e892708 (diff) | |
Update wallpaper packageMonitor & tryToRebind for LWP
Without this, a wallpaper crash on lock screen will lead to a black lock
screen, instead of a revert to the default wallpaper.
Flag: lockscreen lwp
Bug: 298366419
Test: atest WallpaperManagerTest
Test: manual: put two different wallpapers on home & lock and run adb
shell am force-stop <name of the lock screen wallpaper process>
Change-Id: I466acd7e80dd876f29a4baa650c68e4546b312f4
| -rw-r--r-- | services/core/java/com/android/server/wallpaper/WallpaperManagerService.java | 57 |
1 files changed, 34 insertions, 23 deletions
diff --git a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java index e50f1cde5722..3c2d0fcb8cdf 100644 --- a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java +++ b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java @@ -1005,11 +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(FLAG_SYSTEM, mWallpaper.userId, null); + int which = mIsLockscreenLiveWallpaperEnabled ? mWallpaper.mWhich : FLAG_SYSTEM; + clearWallpaperLocked(which, mWallpaper.userId, null); } } }; @@ -1189,7 +1189,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub } else { // Timeout Slog.w(TAG, "Reverting to built-in wallpaper!"); - clearWallpaperLocked(FLAG_SYSTEM, mWallpaper.userId, null); + clearWallpaperLocked(mWallpaper.mWhich, mWallpaper.userId, null); final String flattened = wpService.flattenToString(); EventLog.writeEvent(EventLogTags.WP_WALLPAPER_CRASHED, flattened.substring(0, Math.min(flattened.length(), @@ -1228,7 +1228,8 @@ public class WallpaperManagerService extends IWallpaperManager.Stub } else { if (mLmkLimitRebindRetries <= 0) { Slog.w(TAG, "Reverting to built-in wallpaper due to lmk!"); - clearWallpaperLocked(FLAG_SYSTEM, mWallpaper.userId, null); + clearWallpaperLocked( + mWallpaper.mWhich, mWallpaper.userId, null); mLmkLimitRebindRetries = LMK_RECONNECT_REBIND_RETRIES; return; } @@ -1470,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) { @@ -1483,7 +1483,9 @@ public class WallpaperManagerService extends IWallpaperManager.Stub wallpaper, null)) { Slog.w(TAG, "Wallpaper " + wpService + " no longer available; reverting to default"); - clearWallpaperLocked(FLAG_SYSTEM, wallpaper.userId, null); + int which = mIsLockscreenLiveWallpaperEnabled + ? wallpaper.mWhich : FLAG_SYSTEM; + clearWallpaperLocked(which, wallpaper.userId, null); } } } @@ -1496,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); } } } @@ -1513,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) { @@ -1538,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; } @@ -1553,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); } } @@ -1562,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()); @@ -1571,7 +1569,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub if (doit) { Slog.w(TAG, "Wallpaper uninstalled, removing: " + wallpaper.wallpaperComponent); - clearWallpaperLocked(FLAG_SYSTEM, wallpaper.userId, null); + clearWallpaperLocked(which, wallpaper.userId, null); } } } @@ -1592,7 +1590,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub } catch (NameNotFoundException e) { Slog.w(TAG, "Wallpaper component gone, removing: " + wallpaper.wallpaperComponent); - clearWallpaperLocked(FLAG_SYSTEM, wallpaper.userId, null); + clearWallpaperLocked(which, wallpaper.userId, null); } } if (wallpaper.nextWallpaperComponent != null @@ -1708,7 +1706,8 @@ public class WallpaperManagerService extends IWallpaperManager.Stub if (DEBUG) { Slog.i(TAG, "Unable to regenerate crop; resetting"); } - clearWallpaperLocked(FLAG_SYSTEM, UserHandle.USER_SYSTEM, null); + int which = isLockscreenLiveWallpaperEnabled() ? wallpaper.mWhich : FLAG_SYSTEM; + clearWallpaperLocked(which, UserHandle.USER_SYSTEM, null); } } else { if (DEBUG) { @@ -2827,6 +2826,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; |