Don't hold the battery stats lock while waiting for completion

Bug: 169013495
Test: Manual

Change-Id: I40b53e5c22eba7e635febdf5b5fc4370c93fdf1d
This commit is contained in:
Jing Ji
2020-09-21 11:36:15 -07:00
parent a28729b629
commit 4835023e37

View File

@@ -276,15 +276,13 @@ public final class BatteryStatsService extends IBatteryStats.Stub
}
private void awaitCompletion() {
synchronized (mLock) {
final CountDownLatch latch = new CountDownLatch(1);
mHandler.post(() -> {
latch.countDown();
});
try {
latch.await();
} catch (InterruptedException e) {
}
final CountDownLatch latch = new CountDownLatch(1);
mHandler.post(() -> {
latch.countDown();
});
try {
latch.await();
} catch (InterruptedException e) {
}
}