Merge "Don't remove UID data in readKernelCpuUid*TimesLocked" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
83a5e6ed18
@@ -13120,13 +13120,11 @@ public class BatteryStatsImpl extends BatteryStats {
|
||||
if (Process.isIsolated(uid)) {
|
||||
// This could happen if the isolated uid mapping was removed before that process
|
||||
// was actually killed.
|
||||
mCpuUidUserSysTimeReader.removeUid(uid);
|
||||
if (DEBUG) Slog.d(TAG, "Got readings for an isolated uid: " + uid);
|
||||
return;
|
||||
}
|
||||
if (!mUserInfoProvider.exists(UserHandle.getUserId(uid))) {
|
||||
if (DEBUG) Slog.d(TAG, "Got readings for an invalid user's uid " + uid);
|
||||
mCpuUidUserSysTimeReader.removeUid(uid);
|
||||
return;
|
||||
}
|
||||
final Uid u = getUidStatsLocked(uid, elapsedRealtimeMs, startTimeMs);
|
||||
@@ -13231,19 +13229,16 @@ public class BatteryStatsImpl extends BatteryStats {
|
||||
mWakeLockAllocationsUs = null;
|
||||
final long startTimeMs = mClocks.uptimeMillis();
|
||||
final long elapsedRealtimeMs = mClocks.elapsedRealtime();
|
||||
final List<Integer> uidsToRemove = new ArrayList<>();
|
||||
// If power is being accumulated for attribution, data needs to be read immediately.
|
||||
final boolean forceRead = powerAccumulator != null;
|
||||
mCpuUidFreqTimeReader.readDelta(forceRead, (uid, cpuFreqTimeMs) -> {
|
||||
uid = mapUid(uid);
|
||||
if (Process.isIsolated(uid)) {
|
||||
uidsToRemove.add(uid);
|
||||
if (DEBUG) Slog.d(TAG, "Got freq readings for an isolated uid: " + uid);
|
||||
return;
|
||||
}
|
||||
if (!mUserInfoProvider.exists(UserHandle.getUserId(uid))) {
|
||||
if (DEBUG) Slog.d(TAG, "Got freq readings for an invalid user's uid " + uid);
|
||||
uidsToRemove.add(uid);
|
||||
return;
|
||||
}
|
||||
final Uid u = getUidStatsLocked(uid, elapsedRealtimeMs, startTimeMs);
|
||||
@@ -13307,9 +13302,6 @@ public class BatteryStatsImpl extends BatteryStats {
|
||||
}
|
||||
}
|
||||
});
|
||||
for (int uid : uidsToRemove) {
|
||||
mCpuUidFreqTimeReader.removeUid(uid);
|
||||
}
|
||||
|
||||
final long elapsedTimeMs = mClocks.uptimeMillis() - startTimeMs;
|
||||
if (DEBUG_ENERGY_CPU || elapsedTimeMs >= 100) {
|
||||
@@ -13361,25 +13353,19 @@ public class BatteryStatsImpl extends BatteryStats {
|
||||
public void readKernelUidCpuActiveTimesLocked(boolean onBattery) {
|
||||
final long startTimeMs = mClocks.uptimeMillis();
|
||||
final long elapsedRealtimeMs = mClocks.elapsedRealtime();
|
||||
final List<Integer> uidsToRemove = new ArrayList<>();
|
||||
mCpuUidActiveTimeReader.readDelta(false, (uid, cpuActiveTimesMs) -> {
|
||||
uid = mapUid(uid);
|
||||
if (Process.isIsolated(uid)) {
|
||||
uidsToRemove.add(uid);
|
||||
if (DEBUG) Slog.w(TAG, "Got active times for an isolated uid: " + uid);
|
||||
return;
|
||||
}
|
||||
if (!mUserInfoProvider.exists(UserHandle.getUserId(uid))) {
|
||||
if (DEBUG) Slog.w(TAG, "Got active times for an invalid user's uid " + uid);
|
||||
uidsToRemove.add(uid);
|
||||
return;
|
||||
}
|
||||
final Uid u = getUidStatsLocked(uid, elapsedRealtimeMs, startTimeMs);
|
||||
u.mCpuActiveTimeMs.addCountLocked(cpuActiveTimesMs, onBattery);
|
||||
});
|
||||
for (int uid : uidsToRemove) {
|
||||
mCpuUidActiveTimeReader.removeUid(uid);
|
||||
}
|
||||
|
||||
final long elapsedTimeMs = mClocks.uptimeMillis() - startTimeMs;
|
||||
if (DEBUG_ENERGY_CPU || elapsedTimeMs >= 100) {
|
||||
@@ -13400,19 +13386,16 @@ public class BatteryStatsImpl extends BatteryStats {
|
||||
@Nullable CpuDeltaPowerAccumulator powerAccumulator) {
|
||||
final long startTimeMs = mClocks.uptimeMillis();
|
||||
final long elapsedRealtimeMs = mClocks.elapsedRealtime();
|
||||
final List<Integer> uidsToRemove = new ArrayList<>();
|
||||
// If power is being accumulated for attribution, data needs to be read immediately.
|
||||
final boolean forceRead = powerAccumulator != null;
|
||||
mCpuUidClusterTimeReader.readDelta(forceRead, (uid, cpuClusterTimesMs) -> {
|
||||
uid = mapUid(uid);
|
||||
if (Process.isIsolated(uid)) {
|
||||
uidsToRemove.add(uid);
|
||||
if (DEBUG) Slog.w(TAG, "Got cluster times for an isolated uid: " + uid);
|
||||
return;
|
||||
}
|
||||
if (!mUserInfoProvider.exists(UserHandle.getUserId(uid))) {
|
||||
if (DEBUG) Slog.w(TAG, "Got cluster times for an invalid user's uid " + uid);
|
||||
uidsToRemove.add(uid);
|
||||
return;
|
||||
}
|
||||
final Uid u = getUidStatsLocked(uid, elapsedRealtimeMs, startTimeMs);
|
||||
@@ -13422,9 +13405,6 @@ public class BatteryStatsImpl extends BatteryStats {
|
||||
powerAccumulator.addCpuClusterDurationsMs(u, cpuClusterTimesMs);
|
||||
}
|
||||
});
|
||||
for (int uid : uidsToRemove) {
|
||||
mCpuUidClusterTimeReader.removeUid(uid);
|
||||
}
|
||||
|
||||
final long elapsedTimeMs = mClocks.uptimeMillis() - startTimeMs;
|
||||
if (DEBUG_ENERGY_CPU || elapsedTimeMs >= 100) {
|
||||
|
||||
@@ -363,7 +363,6 @@ public class BatteryStatsCpuTimesTest {
|
||||
assertEquals("Unexpected system cpu time for uid=" + testUids[i],
|
||||
uidTimesUs[i][1], u.getSystemCpuTimeUs(STATS_SINCE_CHARGED));
|
||||
}
|
||||
verify(mCpuUidUserSysTimeReader).removeUid(isolatedUid);
|
||||
|
||||
// Add an isolated uid mapping and repeat the test.
|
||||
|
||||
@@ -453,7 +452,6 @@ public class BatteryStatsCpuTimesTest {
|
||||
}
|
||||
assertNull("There shouldn't be an entry for invalid uid=" + invalidUid,
|
||||
mBatteryStatsImpl.getUidStats().get(invalidUid));
|
||||
verify(mCpuUidUserSysTimeReader).removeUid(invalidUid);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -943,7 +941,6 @@ public class BatteryStatsCpuTimesTest {
|
||||
assertNull("Unexpected screen-off cpu times for uid=" + testUids[i],
|
||||
u.getScreenOffCpuFreqTimes(STATS_SINCE_CHARGED));
|
||||
}
|
||||
verify(mCpuUidFreqTimeReader).removeUid(isolatedUid);
|
||||
|
||||
|
||||
// Add an isolated uid mapping and repeat the test.
|
||||
@@ -1038,7 +1035,6 @@ public class BatteryStatsCpuTimesTest {
|
||||
}
|
||||
assertNull("There shouldn't be an entry for invalid uid=" + invalidUid,
|
||||
mBatteryStatsImpl.getUidStats().get(invalidUid));
|
||||
verify(mCpuUidFreqTimeReader).removeUid(invalidUid);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1142,7 +1138,6 @@ public class BatteryStatsCpuTimesTest {
|
||||
}
|
||||
assertNull("There shouldn't be an entry for invalid uid=" + invalidUid,
|
||||
mBatteryStatsImpl.getUidStats().get(invalidUid));
|
||||
verify(mCpuUidActiveTimeReader).removeUid(invalidUid);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1259,7 +1254,6 @@ public class BatteryStatsCpuTimesTest {
|
||||
}
|
||||
assertNull("There shouldn't be an entry for invalid uid=" + invalidUid,
|
||||
mBatteryStatsImpl.getUidStats().get(invalidUid));
|
||||
verify(mCpuUidClusterTimeReader).removeUid(invalidUid);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user