DO NOT MERGE: Update BatteryStatsImpl to handle change in no. of freqs.
Bug: 62240247
Test: cts-tradefed run singleCommand cts-dev -m CtsIncidentHostTestCases -t \
com.android.server.cts.BatteryStatsValidationTest
Change-Id: I1328fe7bf29229e9563cde6eea80addf2b91ea5d
This commit is contained in:
@@ -3667,25 +3667,29 @@ public abstract class BatteryStats implements Parcelable {
|
||||
0 /* old cpu power, keep for compatibility */);
|
||||
}
|
||||
|
||||
final long[] cpuFreqTimeMs = u.getCpuFreqTimes(which);
|
||||
// If total cpuFreqTimes is null, then we don't need to check for screenOffCpuFreqTimes.
|
||||
if (cpuFreqTimeMs != null) {
|
||||
sb.setLength(0);
|
||||
for (int i = 0; i < cpuFreqTimeMs.length; ++i) {
|
||||
sb.append((i == 0 ? "" : ",") + cpuFreqTimeMs[i]);
|
||||
}
|
||||
final long[] screenOffCpuFreqTimeMs = u.getScreenOffCpuFreqTimes(which);
|
||||
if (screenOffCpuFreqTimeMs != null) {
|
||||
for (int i = 0; i < screenOffCpuFreqTimeMs.length; ++i) {
|
||||
sb.append("," + screenOffCpuFreqTimeMs[i]);
|
||||
}
|
||||
} else {
|
||||
// If the cpuFreqs is null, then don't bother checking for cpu freq times.
|
||||
if (cpuFreqs != null) {
|
||||
final long[] cpuFreqTimeMs = u.getCpuFreqTimes(which);
|
||||
// If total cpuFreqTimes is null, then we don't need to check for
|
||||
// screenOffCpuFreqTimes.
|
||||
if (cpuFreqTimeMs != null && cpuFreqTimeMs.length == cpuFreqs.length) {
|
||||
sb.setLength(0);
|
||||
for (int i = 0; i < cpuFreqTimeMs.length; ++i) {
|
||||
sb.append(",0");
|
||||
sb.append((i == 0 ? "" : ",") + cpuFreqTimeMs[i]);
|
||||
}
|
||||
final long[] screenOffCpuFreqTimeMs = u.getScreenOffCpuFreqTimes(which);
|
||||
if (screenOffCpuFreqTimeMs != null) {
|
||||
for (int i = 0; i < screenOffCpuFreqTimeMs.length; ++i) {
|
||||
sb.append("," + screenOffCpuFreqTimeMs[i]);
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < cpuFreqTimeMs.length; ++i) {
|
||||
sb.append(",0");
|
||||
}
|
||||
}
|
||||
dumpLine(pw, uid, category, CPU_TIMES_AT_FREQ_DATA, UID_TIMES_TYPE_ALL,
|
||||
cpuFreqTimeMs.length, sb.toString());
|
||||
}
|
||||
dumpLine(pw, uid, category, CPU_TIMES_AT_FREQ_DATA, UID_TIMES_TYPE_ALL,
|
||||
cpuFreqTimeMs.length, sb.toString());
|
||||
}
|
||||
|
||||
final ArrayMap<String, ? extends BatteryStats.Uid.Proc> processStats
|
||||
|
||||
@@ -1063,6 +1063,10 @@ public class BatteryStatsImpl extends BatteryStats {
|
||||
}
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return mCounts == null ? 0 : mCounts.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear state of this counter.
|
||||
*/
|
||||
@@ -10526,11 +10530,13 @@ public class BatteryStatsImpl extends BatteryStats {
|
||||
return;
|
||||
}
|
||||
final Uid u = getUidStatsLocked(uid);
|
||||
if (u.mCpuFreqTimeMs == null) {
|
||||
if (u.mCpuFreqTimeMs == null
|
||||
|| u.mCpuFreqTimeMs.getSize() != cpuFreqTimeMs.length) {
|
||||
u.mCpuFreqTimeMs = new LongSamplingCounterArray(mOnBatteryTimeBase);
|
||||
}
|
||||
u.mCpuFreqTimeMs.addCountLocked(cpuFreqTimeMs);
|
||||
if (u.mScreenOffCpuFreqTimeMs == null) {
|
||||
if (u.mScreenOffCpuFreqTimeMs == null
|
||||
|| u.mScreenOffCpuFreqTimeMs.getSize() != cpuFreqTimeMs.length) {
|
||||
u.mScreenOffCpuFreqTimeMs = new LongSamplingCounterArray(
|
||||
mOnBatteryScreenOffTimeBase);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user