diff options
author | Selim Cinek <cinek@google.com> | 2014-03-05 22:17:26 +0100 |
---|---|---|
committer | Selim Cinek <cinek@google.com> | 2014-03-06 14:10:04 +0100 |
commit | ebebadb56d6b3eab6e11dae9d48d639f0af4946d (patch) | |
tree | a09a0aae16b23ca78abaf75da304c1dc92acb3eb /services/core/java | |
parent | e0ebe276e58cf50719d625631a569bda2f52ff5f (diff) | |
download | frameworks_base-ebebadb56d6b3eab6e11dae9d48d639f0af4946d.zip frameworks_base-ebebadb56d6b3eab6e11dae9d48d639f0af4946d.tar.gz frameworks_base-ebebadb56d6b3eab6e11dae9d48d639f0af4946d.tar.bz2 |
Fixed a bug where the current wallpaper could be reset on an update
There is a race condition which caused the wallpaper to be reset
on an app update since the broadcast notifying the service is async.
This CL corrects this behaviour by enforcing that we only reset the
wallpaper if its service was shut down twice in a certain timeframe.
Before, the condition falsely was checking whether the service was
started in the last couple of millis instead of killed.
Bug: 11901821
Change-Id: Icfbc7a5df63215079a83805c5187a3182b192757
Diffstat (limited to 'services/core/java')
-rw-r--r-- | services/core/java/com/android/server/wallpaper/WallpaperManagerService.java | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java index 97ea52c..87953fe 100644 --- a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java +++ b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java @@ -230,7 +230,6 @@ public class WallpaperManagerService extends IWallpaperManager.Stub { public void onServiceConnected(ComponentName name, IBinder service) { synchronized (mLock) { if (mWallpaper.connection == this) { - mWallpaper.lastDiedTime = SystemClock.uptimeMillis(); mService = IWallpaperService.Stub.asInterface(service); attachServiceLocked(this, mWallpaper); // XXX should probably do saveSettingsLocked() later @@ -250,11 +249,21 @@ public class WallpaperManagerService extends IWallpaperManager.Stub { if (mWallpaper.connection == this) { Slog.w(TAG, "Wallpaper service gone: " + mWallpaper.wallpaperComponent); if (!mWallpaper.wallpaperUpdating - && (mWallpaper.lastDiedTime + MIN_WALLPAPER_CRASH_TIME) - > SystemClock.uptimeMillis() && mWallpaper.userId == mCurrentUserId) { - Slog.w(TAG, "Reverting to built-in wallpaper!"); - clearWallpaperLocked(true, mWallpaper.userId, null); + // There is a race condition which causes + // {@link #mWallpaper.wallpaperUpdating} to be false even if it is + // currently updating since the broadcast notifying us is async. + // This race is overcome by the general rule that we only reset the + // wallpaper if its service was shut down twice + // during {@link #MIN_WALLPAPER_CRASH_TIME} millis. + if (mWallpaper.lastDiedTime != 0 + && mWallpaper.lastDiedTime + MIN_WALLPAPER_CRASH_TIME + > SystemClock.uptimeMillis()) { + Slog.w(TAG, "Reverting to built-in wallpaper!"); + clearWallpaperLocked(true, mWallpaper.userId, null); + } else { + mWallpaper.lastDiedTime = SystemClock.uptimeMillis(); + } } } } @@ -938,7 +947,6 @@ public class WallpaperManagerService extends IWallpaperManager.Stub { } wallpaper.wallpaperComponent = componentName; wallpaper.connection = newConn; - wallpaper.lastDiedTime = SystemClock.uptimeMillis(); newConn.mReply = reply; try { if (wallpaper.userId == mCurrentUserId) { |