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

Commit 53810d70 authored by Steve Kondik's avatar Steve Kondik Committed by Gerrit Code Review
Browse files

Merge "Fix for the race in Wallpaperservice" into gingerbread

parents d765ad15 a0c92d49
Loading
Loading
Loading
Loading
+13 −5
Original line number Original line Diff line number Diff line
@@ -763,6 +763,7 @@ public abstract class WallpaperService extends Service {
        }
        }
        
        
        void detach() {
        void detach() {
           synchronized (mLock) {
            if (mDestroyed) {
            if (mDestroyed) {
                return;
                return;
            }
            }
@@ -806,6 +807,7 @@ public abstract class WallpaperService extends Service {
            }
            }
           }
           }
        }
        }
    }
    
    
    class IWallpaperEngineWrapper extends IWallpaperEngine.Stub
    class IWallpaperEngineWrapper extends IWallpaperEngine.Stub
            implements HandlerCaller.Callback {
            implements HandlerCaller.Callback {
@@ -874,13 +876,17 @@ public abstract class WallpaperService extends Service {
                    }
                    }
                    Engine engine = onCreateEngine();
                    Engine engine = onCreateEngine();
                    mEngine = engine;
                    mEngine = engine;
                    synchronized (mActiveEngines) {
                        mActiveEngines.add(engine);
                        mActiveEngines.add(engine);
                    }
                    engine.attach(this);
                    engine.attach(this);
                    return;
                    return;
                }
                }
                case DO_DETACH: {
                case DO_DETACH: {
                    mActiveEngines.remove(mEngine);
                    mEngine.detach();
                    mEngine.detach();
                    synchronized (mActiveEngines) {
                        mActiveEngines.remove(mEngine);
                    }
                    return;
                    return;
                }
                }
                case DO_SET_DESIRED_SIZE: {
                case DO_SET_DESIRED_SIZE: {
@@ -958,11 +964,13 @@ public abstract class WallpaperService extends Service {
    @Override
    @Override
    public void onDestroy() {
    public void onDestroy() {
        super.onDestroy();
        super.onDestroy();
        synchronized (mActiveEngines) {
           for (int i=0; i<mActiveEngines.size(); i++) {
           for (int i=0; i<mActiveEngines.size(); i++) {
               mActiveEngines.get(i).detach();
               mActiveEngines.get(i).detach();
           }
           }
           mActiveEngines.clear();
           mActiveEngines.clear();
        }
        }
    }


    /**
    /**
     * Implement to return the implementation of the internal accessibility
     * Implement to return the implementation of the internal accessibility