Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dbf3d3ac authored by Dianne Hackborn's avatar Dianne Hackborn Committed by Android Git Automerger
Browse files

am af1f42be: Fix issue #2271668: Live Wallpaper Force-Close when changing from...

am af1f42be: Fix issue #2271668: Live Wallpaper Force-Close when changing from live wallpaper to picasa wallpaper

Merge commit 'af1f42be' into eclair-mr2

* commit 'af1f42be':
  Fix issue #2271668: Live Wallpaper Force-Close when changing from live wallpaper to picasa wallpaper
parents f2900600 af1f42be
Loading
Loading
Loading
Loading
+28 −2
Original line number Diff line number Diff line
@@ -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,9 +600,11 @@ public abstract class WallpaperService extends Service {
        }
        
        void doVisibilityChanged(boolean visible) {
            if (!mDestroyed) {
                mVisible = visible;
                reportVisibility();
            }
        }
        
        void reportVisibility() {
            if (!mDestroyed) {
@@ -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.