Loading core/java/android/os/BatteryStats.java +5 −2 Original line number Diff line number Diff line Loading @@ -5296,8 +5296,11 @@ public abstract class BatteryStats implements Parcelable { } if (bs.customMeasuredPowerMah != null) { for (int idx = 0; idx < bs.customMeasuredPowerMah.length; idx++) { final double customPowerMah = bs.customMeasuredPowerMah[idx]; if (customPowerMah != 0) { pw.print(" custom[" + idx + "]="); printmAh(pw, bs.customMeasuredPowerMah[idx]); printmAh(pw, customPowerMah); } } } pw.print(" )"); Loading core/java/com/android/internal/os/BatteryStatsImpl.java +19 −11 Original line number Diff line number Diff line Loading @@ -1002,8 +1002,12 @@ public class BatteryStatsImpl extends BatteryStats { int mWifiRadioPowerState = DataConnectionRealTimeInfo.DC_POWER_STATE_LOW; /** * Accumulated energy consumption, that is not attributed to individual uids, of various * consumers while on battery. * Accumulated global (generally, device-wide total) energy consumption of various consumers * while on battery. * Its '<b>custom</b> energy buckets' correspond to the * {@link android.hardware.power.stats.EnergyConsumer.ordinal}s of (custom) energy consumer * type {@link android.hardware.power.stats.EnergyConsumerType#OTHER}). * * If energy consumer data is completely unavailable this will be null. */ @GuardedBy("this") Loading Loading @@ -7533,9 +7537,16 @@ public class BatteryStatsImpl extends BatteryStats { */ private final ArraySet<BinderCallStats> mBinderCallStats = new ArraySet<>(); /** Measured energies attributed to this uid while on battery. */ // We do not use a SparseArray<LongSamplingCounters> since it would cause lots of // unnecessary timebase references, and we're just going to use on-battery anyway... /** * Measured energies attributed to this uid while on battery. * Its '<b>custom</b> energy buckets' correspond to the * {@link android.hardware.power.stats.EnergyConsumer.ordinal}s of (custom) energy consumer * type {@link android.hardware.power.stats.EnergyConsumerType#OTHER}). * * Will be null if energy consumer data is completely unavailable (in which case * {@link #mGlobalMeasuredEnergyStats} will also be null) or if the power usage by this uid * is 0 for every bucket. */ private MeasuredEnergyStats mUidMeasuredEnergyStats; /** Loading Loading @@ -12523,11 +12534,8 @@ public class BatteryStatsImpl extends BatteryStats { final int uidInt = mapUid(uidEnergies.keyAt(i)); final long uidEnergyUJ = uidEnergies.valueAt(i); if (uidEnergyUJ == 0) continue; // TODO: Worry about uids not in BSI currently, including uninstalled uids 'coming back' // Specifically: What if the uid had been removed? We'll re-create it now. // And if we instead use getAvailableUidStatsLocked() and chec for null, then we might // not create a Uid even when we should be (say, the app's first event, somehow, was to // use GPU). I guess that CPU/kernel data might already have this problem? // TODO(b/180030409): Worry about dead Uids (no longer in BSI) being revived by this, // or converse problem of not creating a new Uid if its first blame is recorded here. final Uid uidObj = getUidStatsLocked(uidInt); uidObj.addEnergyToCustomBucketLocked(uidEnergyUJ, customEnergyBucket, true); } Loading Loading @@ -14541,7 +14549,7 @@ public class BatteryStatsImpl extends BatteryStats { return; } dumpMeasuredEnergyStatsLocked(pw, "non-uid usage", mGlobalMeasuredEnergyStats); dumpMeasuredEnergyStatsLocked(pw, "global usage", mGlobalMeasuredEnergyStats); int size = mUidStats.size(); for (int i = 0; i < size; i++) { services/core/java/com/android/server/am/BatteryExternalStatsWorker.java +6 −6 Original line number Diff line number Diff line Loading @@ -149,7 +149,7 @@ class BatteryExternalStatsWorker implements BatteryStatsImpl.ExternalStatsSync { * Maps an {@link EnergyConsumerType} to it's corresponding {@link EnergyConsumer#id}s, * unless it is of {@link EnergyConsumer#type}=={@link EnergyConsumerType#OTHER} */ // TODO: Hook this up (it isn't used yet) // TODO(b/180029015): Hook this up (it isn't used yet) @GuardedBy("mWorkerLock") private @Nullable SparseArray<int[]> mEnergyConsumerTypeToIdMap = null; Loading Loading @@ -818,14 +818,14 @@ class BatteryExternalStatsWorker implements BatteryStatsImpl.ExternalStatsSync { if (energyConsumerIds.isEmpty()) { return null; } // TODO: Query *specific* subsystems from HAL based on energyConsumerIds.toArray() // TODO(b/180029015): Query specific subsystems from HAL based on energyConsumerIds.toArray return getEnergyConsumptionData(); } @GuardedBy("mWorkerLock") private void addEnergyConsumerIdLocked( List<Integer> energyConsumerIds, @EnergyConsumerType int type) { final int consumerId = 0; // TODO: Use mEnergyConsumerTypeToIdMap to get this final int consumerId = 0; // TODO(b/180029015): Use mEnergyConsumerTypeToIdMap to get this energyConsumerIds.add(consumerId); } Loading @@ -840,7 +840,7 @@ class BatteryExternalStatsWorker implements BatteryStatsImpl.ExternalStatsSync { return null; } // TODO: Initialize typeToIds // TODO(b/180029015): Initialize typeToIds // Maps type -> {ids} (1:n map, since multiple ids might have the same type) // final SparseArray<SparseIntArray> typeToIds = new SparseArray<>(); Loading @@ -862,9 +862,9 @@ class BatteryExternalStatsWorker implements BatteryStatsImpl.ExternalStatsSync { } } idToConsumer.put(consumer.id, consumer); // TODO: Also populate typeToIds map // TODO(b/180029015): Also populate typeToIds map } // TODO: Store typeToIds in mEnergyConsumerTypeToIdMap. // TODO(b/180029015): Store typeToIds in mEnergyConsumerTypeToIdMap. return idToConsumer; } } Loading
core/java/android/os/BatteryStats.java +5 −2 Original line number Diff line number Diff line Loading @@ -5296,8 +5296,11 @@ public abstract class BatteryStats implements Parcelable { } if (bs.customMeasuredPowerMah != null) { for (int idx = 0; idx < bs.customMeasuredPowerMah.length; idx++) { final double customPowerMah = bs.customMeasuredPowerMah[idx]; if (customPowerMah != 0) { pw.print(" custom[" + idx + "]="); printmAh(pw, bs.customMeasuredPowerMah[idx]); printmAh(pw, customPowerMah); } } } pw.print(" )"); Loading
core/java/com/android/internal/os/BatteryStatsImpl.java +19 −11 Original line number Diff line number Diff line Loading @@ -1002,8 +1002,12 @@ public class BatteryStatsImpl extends BatteryStats { int mWifiRadioPowerState = DataConnectionRealTimeInfo.DC_POWER_STATE_LOW; /** * Accumulated energy consumption, that is not attributed to individual uids, of various * consumers while on battery. * Accumulated global (generally, device-wide total) energy consumption of various consumers * while on battery. * Its '<b>custom</b> energy buckets' correspond to the * {@link android.hardware.power.stats.EnergyConsumer.ordinal}s of (custom) energy consumer * type {@link android.hardware.power.stats.EnergyConsumerType#OTHER}). * * If energy consumer data is completely unavailable this will be null. */ @GuardedBy("this") Loading Loading @@ -7533,9 +7537,16 @@ public class BatteryStatsImpl extends BatteryStats { */ private final ArraySet<BinderCallStats> mBinderCallStats = new ArraySet<>(); /** Measured energies attributed to this uid while on battery. */ // We do not use a SparseArray<LongSamplingCounters> since it would cause lots of // unnecessary timebase references, and we're just going to use on-battery anyway... /** * Measured energies attributed to this uid while on battery. * Its '<b>custom</b> energy buckets' correspond to the * {@link android.hardware.power.stats.EnergyConsumer.ordinal}s of (custom) energy consumer * type {@link android.hardware.power.stats.EnergyConsumerType#OTHER}). * * Will be null if energy consumer data is completely unavailable (in which case * {@link #mGlobalMeasuredEnergyStats} will also be null) or if the power usage by this uid * is 0 for every bucket. */ private MeasuredEnergyStats mUidMeasuredEnergyStats; /** Loading Loading @@ -12523,11 +12534,8 @@ public class BatteryStatsImpl extends BatteryStats { final int uidInt = mapUid(uidEnergies.keyAt(i)); final long uidEnergyUJ = uidEnergies.valueAt(i); if (uidEnergyUJ == 0) continue; // TODO: Worry about uids not in BSI currently, including uninstalled uids 'coming back' // Specifically: What if the uid had been removed? We'll re-create it now. // And if we instead use getAvailableUidStatsLocked() and chec for null, then we might // not create a Uid even when we should be (say, the app's first event, somehow, was to // use GPU). I guess that CPU/kernel data might already have this problem? // TODO(b/180030409): Worry about dead Uids (no longer in BSI) being revived by this, // or converse problem of not creating a new Uid if its first blame is recorded here. final Uid uidObj = getUidStatsLocked(uidInt); uidObj.addEnergyToCustomBucketLocked(uidEnergyUJ, customEnergyBucket, true); } Loading Loading @@ -14541,7 +14549,7 @@ public class BatteryStatsImpl extends BatteryStats { return; } dumpMeasuredEnergyStatsLocked(pw, "non-uid usage", mGlobalMeasuredEnergyStats); dumpMeasuredEnergyStatsLocked(pw, "global usage", mGlobalMeasuredEnergyStats); int size = mUidStats.size(); for (int i = 0; i < size; i++) {
services/core/java/com/android/server/am/BatteryExternalStatsWorker.java +6 −6 Original line number Diff line number Diff line Loading @@ -149,7 +149,7 @@ class BatteryExternalStatsWorker implements BatteryStatsImpl.ExternalStatsSync { * Maps an {@link EnergyConsumerType} to it's corresponding {@link EnergyConsumer#id}s, * unless it is of {@link EnergyConsumer#type}=={@link EnergyConsumerType#OTHER} */ // TODO: Hook this up (it isn't used yet) // TODO(b/180029015): Hook this up (it isn't used yet) @GuardedBy("mWorkerLock") private @Nullable SparseArray<int[]> mEnergyConsumerTypeToIdMap = null; Loading Loading @@ -818,14 +818,14 @@ class BatteryExternalStatsWorker implements BatteryStatsImpl.ExternalStatsSync { if (energyConsumerIds.isEmpty()) { return null; } // TODO: Query *specific* subsystems from HAL based on energyConsumerIds.toArray() // TODO(b/180029015): Query specific subsystems from HAL based on energyConsumerIds.toArray return getEnergyConsumptionData(); } @GuardedBy("mWorkerLock") private void addEnergyConsumerIdLocked( List<Integer> energyConsumerIds, @EnergyConsumerType int type) { final int consumerId = 0; // TODO: Use mEnergyConsumerTypeToIdMap to get this final int consumerId = 0; // TODO(b/180029015): Use mEnergyConsumerTypeToIdMap to get this energyConsumerIds.add(consumerId); } Loading @@ -840,7 +840,7 @@ class BatteryExternalStatsWorker implements BatteryStatsImpl.ExternalStatsSync { return null; } // TODO: Initialize typeToIds // TODO(b/180029015): Initialize typeToIds // Maps type -> {ids} (1:n map, since multiple ids might have the same type) // final SparseArray<SparseIntArray> typeToIds = new SparseArray<>(); Loading @@ -862,9 +862,9 @@ class BatteryExternalStatsWorker implements BatteryStatsImpl.ExternalStatsSync { } } idToConsumer.put(consumer.id, consumer); // TODO: Also populate typeToIds map // TODO(b/180029015): Also populate typeToIds map } // TODO: Store typeToIds in mEnergyConsumerTypeToIdMap. // TODO(b/180029015): Store typeToIds in mEnergyConsumerTypeToIdMap. return idToConsumer; } }