Merge "Disallow unchecked message removal on shared handler"
This commit is contained in:
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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 */);
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user