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

Commit 65c43bcb authored by Riddle Hsu's avatar Riddle Hsu Committed by Android (Google) Code Review
Browse files

Merge "Disallow unchecked message removal on shared handler"

parents 7a3cf53a e2a90aa2
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ public final class AnimationThread extends ServiceThread {
            sInstance = new AnimationThread();
            sInstance.start();
            sInstance.getLooper().setTraceTag(Trace.TRACE_TAG_WINDOW_MANAGER);
            sHandler = new Handler(sInstance.getLooper());
            sHandler = makeSharedHandler(sInstance.getLooper());
        }
    }

+1 −1
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ public final class SurfaceAnimationThread extends ServiceThread {
            sInstance = new SurfaceAnimationThread();
            sInstance.start();
            sInstance.getLooper().setTraceTag(Trace.TRACE_TAG_WINDOW_MANAGER);
            sHandler = new Handler(sInstance.getLooper());
            sHandler = makeSharedHandler(sInstance.getLooper());
        }
    }

+0 −4
Original line number Diff line number Diff line
@@ -47,10 +47,6 @@ class SystemServiceTestsBase {
        mLockRule.waitForLocked(mSystemServicesTestRule::waitUntilWindowAnimatorIdle);
    }

    void cleanupWindowManagerHandlers() {
        mLockRule.waitForLocked(mSystemServicesTestRule::cleanupWindowManagerHandlers);
    }

    boolean waitHandlerIdle(Handler handler) {
        return waitHandlerIdle(handler, 0 /* timeout */);
    }
+0 −14
Original line number Diff line number Diff line
@@ -370,8 +370,6 @@ public class SystemServicesTestRule implements TestRule {
        // This makes sure the posted messages without delay are processed, e.g.
        // DisplayPolicy#release, WindowManagerService#setAnimationScale.
        waitUntilWindowManagerHandlersIdle();
        // Clear all posted messages with delay, so they don't be executed at unexpected times.
        cleanupWindowManagerHandlers();
        // Needs to explicitly dispose current static threads because there could be messages
        // scheduled at a later time, and all mocks are invalid when it's executed.
        DisplayThread.dispose();
@@ -460,18 +458,6 @@ public class SystemServicesTestRule implements TestRule {
        return proc;
    }

    void cleanupWindowManagerHandlers() {
        final WindowManagerService wm = getWindowManagerService();
        if (wm == null) {
            return;
        }
        wm.mH.removeCallbacksAndMessages(null);
        wm.mAnimationHandler.removeCallbacksAndMessages(null);
        // This is a different handler object than the wm.mAnimationHandler above.
        AnimationThread.getHandler().removeCallbacksAndMessages(null);
        SurfaceAnimationThread.getHandler().removeCallbacksAndMessages(null);
    }

    void waitUntilWindowManagerHandlersIdle() {
        final WindowManagerService wm = getWindowManagerService();
        if (wm == null) {