diff options
author | Dianne Hackborn <hackbod@google.com> | 2009-11-20 16:27:27 -0800 |
---|---|---|
committer | Dianne Hackborn <hackbod@google.com> | 2009-11-20 16:27:27 -0800 |
commit | af1f42be96a6ffa7a9b63e199e1614281ea3282d (patch) | |
tree | 33f6c78984cb8210b2c60e926d6dd422e7ac6271 | |
parent | 1824ec8c127e3a8ef602d027e3c10d81f28320e8 (diff) | |
download | frameworks_base-af1f42be96a6ffa7a9b63e199e1614281ea3282d.zip frameworks_base-af1f42be96a6ffa7a9b63e199e1614281ea3282d.tar.gz frameworks_base-af1f42be96a6ffa7a9b63e199e1614281ea3282d.tar.bz2 |
Fix issue #2271668: Live Wallpaper Force-Close when changing from live wallpaper to picasa wallpaper
The detach of the wallpaper engine was coming in after the containing
service was destroyed. This was possible because these are different
IPC interfaces so will not be serialized. The fix is to keep track
of all of the active engines in the serice, and detach any remaining
ones when the service is destroyed.
Change-Id: I8810786a777dd4f7b15cfbd2e0da25866a4f3ec5
-rw-r--r-- | core/java/android/service/wallpaper/WallpaperService.java | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/core/java/android/service/wallpaper/WallpaperService.java b/core/java/android/service/wallpaper/WallpaperService.java index ccb8f1c..45719e4 100644 --- a/core/java/android/service/wallpaper/WallpaperService.java +++ b/core/java/android/service/wallpaper/WallpaperService.java @@ -44,6 +44,8 @@ import android.view.ViewRoot; import android.view.WindowManager; import android.view.WindowManagerImpl; +import java.util.ArrayList; + /** * A wallpaper service is responsible for showing a live wallpaper behind * applications that would like to sit on top of it. This service object @@ -83,6 +85,8 @@ public abstract class WallpaperService extends Service { private static final int MSG_TOUCH_EVENT = 10040; private Looper mCallbackLooper; + private final ArrayList<Engine> mActiveEngines + = new ArrayList<Engine>(); static final class WallpaperCommand { String action; @@ -596,8 +600,10 @@ public abstract class WallpaperService extends Service { } void doVisibilityChanged(boolean visible) { - mVisible = visible; - reportVisibility(); + if (!mDestroyed) { + mVisible = visible; + reportVisibility(); + } } void reportVisibility() { @@ -666,6 +672,10 @@ public abstract class WallpaperService extends Service { } void detach() { + if (mDestroyed) { + return; + } + mDestroyed = true; if (mVisible) { @@ -773,10 +783,12 @@ public abstract class WallpaperService extends Service { } Engine engine = onCreateEngine(); mEngine = engine; + mActiveEngines.add(engine); engine.attach(this); return; } case DO_DETACH: { + mActiveEngines.remove(mEngine); mEngine.detach(); return; } @@ -844,6 +856,20 @@ public abstract class WallpaperService extends Service { } } + @Override + public void onCreate() { + super.onCreate(); + } + + @Override + public void onDestroy() { + super.onDestroy(); + for (int i=0; i<mActiveEngines.size(); i++) { + mActiveEngines.get(i).detach(); + } + mActiveEngines.clear(); + } + /** * Implement to return the implementation of the internal accessibility * service interface. Subclasses should not override. |