Fix potential deadlock in shutdown in HistoricalRegistry

Ensure that the memory lock is released before calling
persistPendingHistory in HistoricalRegistry.

Bug: 172776374
Test: none
Change-Id: I909de9f83cd43c695d0db99f82252ce36a0b972b
(cherry picked from commit 42387ceaed)
This commit is contained in:
Nate Myren
2020-11-13 13:55:14 -08:00
parent 7e4dc690c6
commit 4a2d4ddf6e

View File

@@ -669,11 +669,13 @@ final class HistoricalRegistry {
void shutdown() { void shutdown() {
synchronized (mInMemoryLock) { synchronized (mInMemoryLock) {
if (mMode != AppOpsManager.HISTORICAL_MODE_DISABLED) { if (mMode == AppOpsManager.HISTORICAL_MODE_DISABLED) {
return;
}
}
// Do not call persistPendingHistory inside the memory lock, due to possible deadlock
persistPendingHistory(); persistPendingHistory();
} }
}
}
void persistPendingHistory() { void persistPendingHistory() {
final List<HistoricalOps> pendingWrites; final List<HistoricalOps> pendingWrites;