Make accessing mWaitingForDrawn thread-safe

mWaitingForDrawn can be accessed by multiple threads, but it was not
protected by the mWindowMap lock perfectly.

Change-Id: I128ba1a00f40af83b051c0d1df4350d0635a9dff
This commit is contained in:
tiger_huang
2016-02-23 20:34:52 +08:00
parent 5af6dd5463
commit 53d1e66080

View File

@@ -11982,6 +11982,7 @@ public class WindowManagerService extends IWindowManager.Stub
@Override
public void waitForAllWindowsDrawn(Runnable callback, long timeout) {
boolean allWindowsDrawn = false;
synchronized (mWindowMap) {
mWaitingForDrawnCallback = callback;
final WindowList windows = getDefaultWindowListLocked();
@@ -12002,13 +12003,16 @@ public class WindowManagerService extends IWindowManager.Stub
}
}
requestTraversalLocked();
mH.removeMessages(H.WAITING_FOR_DRAWN_TIMEOUT);
if (mWaitingForDrawn.isEmpty()) {
allWindowsDrawn = true;
} else {
mH.sendEmptyMessageDelayed(H.WAITING_FOR_DRAWN_TIMEOUT, timeout);
checkDrawnWindowsLocked();
}
}
mH.removeMessages(H.WAITING_FOR_DRAWN_TIMEOUT);
if (mWaitingForDrawn.isEmpty()) {
if (allWindowsDrawn) {
callback.run();
} else {
mH.sendEmptyMessageDelayed(H.WAITING_FOR_DRAWN_TIMEOUT, timeout);
checkDrawnWindowsLocked();
}
}