Merge "KernelWakelockReader: provide class level lock when updates staleStats" am: b9f60a53c3
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1534034 MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: Ie4eb5e35e166e9578351b11b565136a68ce8b31f
This commit is contained in:
@@ -78,13 +78,16 @@ public class KernelWakelockReader {
|
|||||||
boolean useSystemSuspend = (new File(sSysClassWakeupDir)).exists();
|
boolean useSystemSuspend = (new File(sSysClassWakeupDir)).exists();
|
||||||
|
|
||||||
if (useSystemSuspend) {
|
if (useSystemSuspend) {
|
||||||
// Get both kernel and native wakelock stats from SystemSuspend
|
// static read/write lock protection for sKernelWakelockUpdateVersion
|
||||||
updateVersion(staleStats);
|
synchronized (KernelWakelockReader.class) {
|
||||||
if (getWakelockStatsFromSystemSuspend(staleStats) == null) {
|
// Get both kernel and native wakelock stats from SystemSuspend
|
||||||
Slog.w(TAG, "Failed to get wakelock stats from SystemSuspend");
|
updateVersion(staleStats);
|
||||||
return null;
|
if (getWakelockStatsFromSystemSuspend(staleStats) == null) {
|
||||||
|
Slog.w(TAG, "Failed to get wakelock stats from SystemSuspend");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return removeOldStats(staleStats);
|
||||||
}
|
}
|
||||||
return removeOldStats(staleStats);
|
|
||||||
} else {
|
} else {
|
||||||
Arrays.fill(mKernelWakelockBuffer, (byte) 0);
|
Arrays.fill(mKernelWakelockBuffer, (byte) 0);
|
||||||
int len = 0;
|
int len = 0;
|
||||||
@@ -141,14 +144,17 @@ public class KernelWakelockReader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateVersion(staleStats);
|
// static read/write lock protection for sKernelWakelockUpdateVersion
|
||||||
// Get native wakelock stats from SystemSuspend
|
synchronized (KernelWakelockReader.class) {
|
||||||
if (getWakelockStatsFromSystemSuspend(staleStats) == null) {
|
updateVersion(staleStats);
|
||||||
Slog.w(TAG, "Failed to get Native wakelock stats from SystemSuspend");
|
// Get native wakelock stats from SystemSuspend
|
||||||
|
if (getWakelockStatsFromSystemSuspend(staleStats) == null) {
|
||||||
|
Slog.w(TAG, "Failed to get Native wakelock stats from SystemSuspend");
|
||||||
|
}
|
||||||
|
// Get kernel wakelock stats
|
||||||
|
parseProcWakelocks(mKernelWakelockBuffer, len, wakeup_sources, staleStats);
|
||||||
|
return removeOldStats(staleStats);
|
||||||
}
|
}
|
||||||
// Get kernel wakelock stats
|
|
||||||
parseProcWakelocks(mKernelWakelockBuffer, len, wakeup_sources, staleStats);
|
|
||||||
return removeOldStats(staleStats);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user