Skip to content

Commit 59d72c8

Browse files
Adam LesinskiAndroid (Google) Code Review
authored andcommitted
Merge "BatteryStats: Add debug logging to find source of b/22716723" into mnc-dev
2 parents d9b0f84 + fbabe7d commit 59d72c8

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

core/java/com/android/internal/os/BatteryStatsImpl.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7915,6 +7915,8 @@ public void updateKernelWakelocksLocked() {
79157915
return;
79167916
}
79177917

7918+
// Record whether we've seen a non-zero time (for debugging b/22716723).
7919+
boolean seenNonZeroTime = false;
79187920
for (Map.Entry<String, KernelWakelockStats.Entry> ent : wakelockStats.entrySet()) {
79197921
String name = ent.getKey();
79207922
KernelWakelockStats.Entry kws = ent.getValue();
@@ -7928,17 +7930,31 @@ public void updateKernelWakelocksLocked() {
79287930
kwlt.updateCurrentReportedCount(kws.mCount);
79297931
kwlt.updateCurrentReportedTotalTime(kws.mTotalTime);
79307932
kwlt.setUpdateVersion(kws.mVersion);
7933+
7934+
if (kws.mVersion != wakelockStats.kernelWakelockVersion)
7935+
seenNonZeroTime |= kws.mTotalTime > 0;
79317936
}
79327937

7938+
int numWakelocksSetStale = 0;
79337939
if (wakelockStats.size() != mKernelWakelockStats.size()) {
79347940
// Set timers to stale if they didn't appear in /proc/wakelocks this time.
79357941
for (Map.Entry<String, SamplingTimer> ent : mKernelWakelockStats.entrySet()) {
79367942
SamplingTimer st = ent.getValue();
79377943
if (st.getUpdateVersion() != wakelockStats.kernelWakelockVersion) {
79387944
st.setStale();
7945+
numWakelocksSetStale++;
79397946
}
79407947
}
79417948
}
7949+
7950+
if (!seenNonZeroTime) {
7951+
Slog.wtf(TAG, "All kernel wakelocks had time of zero");
7952+
}
7953+
7954+
if (numWakelocksSetStale == mKernelWakelockStats.size()) {
7955+
Slog.wtf(TAG, "All kernel wakelocks were set stale. new version=" +
7956+
wakelockStats.kernelWakelockVersion);
7957+
}
79427958
}
79437959

79447960
// We use an anonymous class to access these variables,

core/java/com/android/internal/os/KernelWakelockReader.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,16 @@ public final KernelWakelockStats readKernelWakelockStats(KernelWakelockStats sta
7575
is = new FileInputStream(sWakeupSourceFile);
7676
wakeup_sources = true;
7777
} catch (java.io.FileNotFoundException e2) {
78+
Slog.wtf(TAG, "neither " + sWakelockFile + " nor " +
79+
sWakeupSourceFile + " exists");
7880
return null;
7981
}
8082
}
8183

8284
len = is.read(buffer);
8385
is.close();
8486
} catch (java.io.IOException e) {
87+
Slog.wtf(TAG, "failed to read kernel wakelocks", e);
8588
return null;
8689
}
8790

@@ -171,6 +174,13 @@ private KernelWakelockStats parseProcWakelocks(byte[] wlBuffer, int len, boolean
171174
numUpdatedWlNames++;
172175
}
173176
}
177+
} else if (!parsed) {
178+
try {
179+
Slog.wtf(TAG, "Failed to parse proc line: " +
180+
new String(wlBuffer, startIndex, endIndex - startIndex));
181+
} catch (Exception e) {
182+
Slog.wtf(TAG, "Failed to parse proc line!");
183+
}
174184
}
175185
startIndex = endIndex;
176186
}

0 commit comments

Comments
 (0)