Fix IdleableHandlerThread.

Occasionally, ConnectivityServiceTest fails with "BUG: only one
idle handler allowed". I have not been able to reproduce this
consistently, but code inspection reveals an unsafe access to
mIdleHandler inside queueIdle. Wrap that in a synchronized block.

Change-Id: I27307e2e55fa8d937d7f043bd436894091c3c667
This commit is contained in:
Lorenzo Colitti
2016-03-02 21:47:42 +09:00
parent 1e01f0872e
commit 6114f2bbb1

View File

@@ -161,9 +161,11 @@ public class ConnectivityServiceTest extends AndroidTestCase {
assertNull("BUG: only one idle handler allowed", mIdleHandler);
mIdleHandler = new IdleHandler() {
public boolean queueIdle() {
cv.open();
mIdleHandler = null;
return false; // Remove the handler.
synchronized (queue) {
cv.open();
mIdleHandler = null;
return false; // Remove the handler.
}
}
};
queue.addIdleHandler(mIdleHandler);