Merge "KernelWakelockReader: provide class level lock when updates staleStats"
This commit is contained in:
@@ -78,13 +78,16 @@ public class KernelWakelockReader {
|
||||
boolean useSystemSuspend = (new File(sSysClassWakeupDir)).exists();
|
||||
|
||||
if (useSystemSuspend) {
|
||||
// Get both kernel and native wakelock stats from SystemSuspend
|
||||
updateVersion(staleStats);
|
||||
if (getWakelockStatsFromSystemSuspend(staleStats) == null) {
|
||||
Slog.w(TAG, "Failed to get wakelock stats from SystemSuspend");
|
||||
return null;
|
||||
// static read/write lock protection for sKernelWakelockUpdateVersion
|
||||
synchronized (KernelWakelockReader.class) {
|
||||
// Get both kernel and native wakelock stats from SystemSuspend
|
||||
updateVersion(staleStats);
|
||||
if (getWakelockStatsFromSystemSuspend(staleStats) == null) {
|
||||
Slog.w(TAG, "Failed to get wakelock stats from SystemSuspend");
|
||||
return null;
|
||||
}
|
||||
return removeOldStats(staleStats);
|
||||
}
|
||||
return removeOldStats(staleStats);
|
||||
} else {
|
||||
Arrays.fill(mKernelWakelockBuffer, (byte) 0);
|
||||
int len = 0;
|
||||
@@ -141,14 +144,17 @@ public class KernelWakelockReader {
|
||||
}
|
||||
}
|
||||
|
||||
updateVersion(staleStats);
|
||||
// Get native wakelock stats from SystemSuspend
|
||||
if (getWakelockStatsFromSystemSuspend(staleStats) == null) {
|
||||
Slog.w(TAG, "Failed to get Native wakelock stats from SystemSuspend");
|
||||
// static read/write lock protection for sKernelWakelockUpdateVersion
|
||||
synchronized (KernelWakelockReader.class) {
|
||||
updateVersion(staleStats);
|
||||
// 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