Loading core/java/android/os/AggregateBatteryConsumer.java +11 −3 Original line number Diff line number Diff line Loading @@ -85,7 +85,7 @@ public final class AggregateBatteryConsumer extends BatteryConsumer { throw new XmlPullParserException("Invalid XML parser state"); } consumerBuilder.setConsumedPower( consumerBuilder.addConsumedPower( parser.getAttributeDouble(null, BatteryUsageStats.XML_ATTR_POWER)); while (!(eventType == XmlPullParser.END_TAG && parser.getName().equals( Loading Loading @@ -131,12 +131,20 @@ public final class AggregateBatteryConsumer extends BatteryConsumer { return this; } /** * Adds the total power included in this aggregate. */ public Builder addConsumedPower(double consumedPowerMah) { mData.putDouble(COLUMN_INDEX_CONSUMED_POWER, mData.getDouble(COLUMN_INDEX_CONSUMED_POWER) + consumedPowerMah); return this; } /** * Adds power and usage duration from the supplied AggregateBatteryConsumer. */ public void add(AggregateBatteryConsumer aggregateBatteryConsumer) { setConsumedPower(mData.getDouble(COLUMN_INDEX_CONSUMED_POWER) + aggregateBatteryConsumer.getConsumedPower()); addConsumedPower(aggregateBatteryConsumer.getConsumedPower()); mPowerComponentsBuilder.addPowerAndDuration(aggregateBatteryConsumer.mPowerComponents); } Loading core/java/android/os/BatteryConsumer.java +30 −0 Original line number Diff line number Diff line Loading @@ -1064,7 +1064,9 @@ public abstract class BatteryConsumer { * @param componentId The ID of the power component, e.g. * {@link BatteryConsumer#POWER_COMPONENT_CPU}. * @param componentPower Amount of consumed power in mAh. * @deprecated use {@link #addConsumedPower} */ @Deprecated @NonNull public T setConsumedPower(@PowerComponentId int componentId, double componentPower) { return setConsumedPower(componentId, componentPower, POWER_MODEL_POWER_PROFILE); Loading @@ -1076,7 +1078,9 @@ public abstract class BatteryConsumer { * @param componentId The ID of the power component, e.g. * {@link BatteryConsumer#POWER_COMPONENT_CPU}. * @param componentPower Amount of consumed power in mAh. * @deprecated use {@link #addConsumedPower} */ @Deprecated @SuppressWarnings("unchecked") @NonNull public T setConsumedPower(@PowerComponentId int componentId, double componentPower, Loading @@ -1102,6 +1106,21 @@ public abstract class BatteryConsumer { return (T) this; } @SuppressWarnings("unchecked") @NonNull public T addConsumedPower(@PowerComponentId int componentId, double componentPower) { mPowerComponentsBuilder.addConsumedPower(getKey(componentId, PROCESS_STATE_UNSPECIFIED), componentPower, POWER_MODEL_UNDEFINED); return (T) this; } @SuppressWarnings("unchecked") @NonNull public T addConsumedPower(Key key, double componentPower) { mPowerComponentsBuilder.addConsumedPower(key, componentPower, POWER_MODEL_UNDEFINED); return (T) this; } @SuppressWarnings("unchecked") @NonNull public T addConsumedPower(Key key, double componentPower, @PowerModel int powerModel) { Loading @@ -1115,7 +1134,9 @@ public abstract class BatteryConsumer { * @param componentId The ID of the power component, e.g. * {@link UidBatteryConsumer#POWER_COMPONENT_CPU}. * @param componentUsageTimeMillis Amount of time in microseconds. * @deprecated use {@link #addUsageDurationMillis} */ @Deprecated @SuppressWarnings("unchecked") @NonNull public T setUsageDurationMillis(@PowerComponentId int componentId, Loading @@ -1126,6 +1147,7 @@ public abstract class BatteryConsumer { return (T) this; } @Deprecated @SuppressWarnings("unchecked") @NonNull public T setUsageDurationMillis(Key key, long componentUsageTimeMillis) { Loading @@ -1133,6 +1155,14 @@ public abstract class BatteryConsumer { return (T) this; } @NonNull public T addUsageDurationMillis(@PowerComponentId int componentId, long componentUsageTimeMillis) { mPowerComponentsBuilder.addUsageDurationMillis( getKey(componentId, PROCESS_STATE_UNSPECIFIED), componentUsageTimeMillis); return (T) this; } @SuppressWarnings("unchecked") @NonNull public T addUsageDurationMillis(Key key, long componentUsageTimeMillis) { Loading core/java/android/os/BatteryUsageStats.java +1 −1 Original line number Diff line number Diff line Loading @@ -209,7 +209,7 @@ public final class BatteryUsageStats implements Parcelable, Closeable { } builder.getAggregateBatteryConsumerBuilder(AGGREGATE_BATTERY_CONSUMER_SCOPE_ALL_APPS) .setConsumedPower(totalPowerMah); .addConsumedPower(totalPowerMah); mAggregateBatteryConsumers = new AggregateBatteryConsumer[AGGREGATE_BATTERY_CONSUMER_SCOPE_COUNT]; Loading core/java/android/os/PowerComponents.java +10 −2 Original line number Diff line number Diff line Loading @@ -439,8 +439,8 @@ class PowerComponents { } final BatteryConsumer.Key key = builder.mData.layout.getKey(componentId, processState, screenState, powerState); builder.setConsumedPower(key, powerMah, model); builder.setUsageDurationMillis(key, durationMs); builder.addConsumedPower(key, powerMah, model); builder.addUsageDurationMillis(key, durationMs); break; } } Loading Loading @@ -468,6 +468,10 @@ class PowerComponents { } } /** * @deprecated use {@link #addConsumedPower(BatteryConsumer.Key, double, int)} */ @Deprecated @NonNull public Builder setConsumedPower(BatteryConsumer.Key key, double componentPower, int powerModel) { Loading @@ -489,6 +493,10 @@ class PowerComponents { return this; } /** * @deprecated use {@link #addUsageDurationMillis(BatteryConsumer.Key, long)} */ @Deprecated @NonNull public Builder setUsageDurationMillis(BatteryConsumer.Key key, long componentUsageDurationMillis) { Loading core/java/android/os/UidBatteryConsumer.java +4 −13 Original line number Diff line number Diff line Loading @@ -210,12 +210,6 @@ public final class UidBatteryConsumer extends BatteryConsumer { serializer.attribute(null, BatteryUsageStats.XML_ATTR_HIGHEST_DRAIN_PACKAGE, packageWithHighestDrain); } serializer.attributeLong(null, BatteryUsageStats.XML_ATTR_TIME_IN_FOREGROUND, getTimeInProcessStateMs(PROCESS_STATE_FOREGROUND)); serializer.attributeLong(null, BatteryUsageStats.XML_ATTR_TIME_IN_BACKGROUND, getTimeInProcessStateMs(PROCESS_STATE_BACKGROUND)); serializer.attributeLong(null, BatteryUsageStats.XML_ATTR_TIME_IN_FOREGROUND_SERVICE, getTimeInProcessStateMs(PROCESS_STATE_FOREGROUND_SERVICE)); mPowerComponents.writeToXml(serializer); serializer.endTag(null, BatteryUsageStats.XML_TAG_UID); } Loading @@ -235,13 +229,6 @@ public final class UidBatteryConsumer extends BatteryConsumer { consumerBuilder.setPackageWithHighestDrain( parser.getAttributeValue(null, BatteryUsageStats.XML_ATTR_HIGHEST_DRAIN_PACKAGE)); consumerBuilder.setTimeInProcessStateMs(PROCESS_STATE_FOREGROUND, parser.getAttributeLong(null, BatteryUsageStats.XML_ATTR_TIME_IN_FOREGROUND)); consumerBuilder.setTimeInProcessStateMs(PROCESS_STATE_BACKGROUND, parser.getAttributeLong(null, BatteryUsageStats.XML_ATTR_TIME_IN_BACKGROUND)); consumerBuilder.setTimeInProcessStateMs(PROCESS_STATE_FOREGROUND_SERVICE, parser.getAttributeLong(null, BatteryUsageStats.XML_ATTR_TIME_IN_FOREGROUND_SERVICE)); while (!(eventType == XmlPullParser.END_TAG && parser.getName().equals(BatteryUsageStats.XML_TAG_UID)) && eventType != XmlPullParser.END_DOCUMENT) { Loading Loading @@ -335,7 +322,11 @@ public final class UidBatteryConsumer extends BatteryConsumer { /** * Sets the duration, in milliseconds, that this UID was active in a particular process * state, such as foreground service. * * @deprecated time in process is now derived from the * {@link BatteryConsumer#POWER_COMPONENT_BASE} duration */ @Deprecated @NonNull public Builder setTimeInProcessStateMs(@ProcessState int state, long timeInProcessStateMs) { Key key = getKey(POWER_COMPONENT_BASE, state); Loading Loading
core/java/android/os/AggregateBatteryConsumer.java +11 −3 Original line number Diff line number Diff line Loading @@ -85,7 +85,7 @@ public final class AggregateBatteryConsumer extends BatteryConsumer { throw new XmlPullParserException("Invalid XML parser state"); } consumerBuilder.setConsumedPower( consumerBuilder.addConsumedPower( parser.getAttributeDouble(null, BatteryUsageStats.XML_ATTR_POWER)); while (!(eventType == XmlPullParser.END_TAG && parser.getName().equals( Loading Loading @@ -131,12 +131,20 @@ public final class AggregateBatteryConsumer extends BatteryConsumer { return this; } /** * Adds the total power included in this aggregate. */ public Builder addConsumedPower(double consumedPowerMah) { mData.putDouble(COLUMN_INDEX_CONSUMED_POWER, mData.getDouble(COLUMN_INDEX_CONSUMED_POWER) + consumedPowerMah); return this; } /** * Adds power and usage duration from the supplied AggregateBatteryConsumer. */ public void add(AggregateBatteryConsumer aggregateBatteryConsumer) { setConsumedPower(mData.getDouble(COLUMN_INDEX_CONSUMED_POWER) + aggregateBatteryConsumer.getConsumedPower()); addConsumedPower(aggregateBatteryConsumer.getConsumedPower()); mPowerComponentsBuilder.addPowerAndDuration(aggregateBatteryConsumer.mPowerComponents); } Loading
core/java/android/os/BatteryConsumer.java +30 −0 Original line number Diff line number Diff line Loading @@ -1064,7 +1064,9 @@ public abstract class BatteryConsumer { * @param componentId The ID of the power component, e.g. * {@link BatteryConsumer#POWER_COMPONENT_CPU}. * @param componentPower Amount of consumed power in mAh. * @deprecated use {@link #addConsumedPower} */ @Deprecated @NonNull public T setConsumedPower(@PowerComponentId int componentId, double componentPower) { return setConsumedPower(componentId, componentPower, POWER_MODEL_POWER_PROFILE); Loading @@ -1076,7 +1078,9 @@ public abstract class BatteryConsumer { * @param componentId The ID of the power component, e.g. * {@link BatteryConsumer#POWER_COMPONENT_CPU}. * @param componentPower Amount of consumed power in mAh. * @deprecated use {@link #addConsumedPower} */ @Deprecated @SuppressWarnings("unchecked") @NonNull public T setConsumedPower(@PowerComponentId int componentId, double componentPower, Loading @@ -1102,6 +1106,21 @@ public abstract class BatteryConsumer { return (T) this; } @SuppressWarnings("unchecked") @NonNull public T addConsumedPower(@PowerComponentId int componentId, double componentPower) { mPowerComponentsBuilder.addConsumedPower(getKey(componentId, PROCESS_STATE_UNSPECIFIED), componentPower, POWER_MODEL_UNDEFINED); return (T) this; } @SuppressWarnings("unchecked") @NonNull public T addConsumedPower(Key key, double componentPower) { mPowerComponentsBuilder.addConsumedPower(key, componentPower, POWER_MODEL_UNDEFINED); return (T) this; } @SuppressWarnings("unchecked") @NonNull public T addConsumedPower(Key key, double componentPower, @PowerModel int powerModel) { Loading @@ -1115,7 +1134,9 @@ public abstract class BatteryConsumer { * @param componentId The ID of the power component, e.g. * {@link UidBatteryConsumer#POWER_COMPONENT_CPU}. * @param componentUsageTimeMillis Amount of time in microseconds. * @deprecated use {@link #addUsageDurationMillis} */ @Deprecated @SuppressWarnings("unchecked") @NonNull public T setUsageDurationMillis(@PowerComponentId int componentId, Loading @@ -1126,6 +1147,7 @@ public abstract class BatteryConsumer { return (T) this; } @Deprecated @SuppressWarnings("unchecked") @NonNull public T setUsageDurationMillis(Key key, long componentUsageTimeMillis) { Loading @@ -1133,6 +1155,14 @@ public abstract class BatteryConsumer { return (T) this; } @NonNull public T addUsageDurationMillis(@PowerComponentId int componentId, long componentUsageTimeMillis) { mPowerComponentsBuilder.addUsageDurationMillis( getKey(componentId, PROCESS_STATE_UNSPECIFIED), componentUsageTimeMillis); return (T) this; } @SuppressWarnings("unchecked") @NonNull public T addUsageDurationMillis(Key key, long componentUsageTimeMillis) { Loading
core/java/android/os/BatteryUsageStats.java +1 −1 Original line number Diff line number Diff line Loading @@ -209,7 +209,7 @@ public final class BatteryUsageStats implements Parcelable, Closeable { } builder.getAggregateBatteryConsumerBuilder(AGGREGATE_BATTERY_CONSUMER_SCOPE_ALL_APPS) .setConsumedPower(totalPowerMah); .addConsumedPower(totalPowerMah); mAggregateBatteryConsumers = new AggregateBatteryConsumer[AGGREGATE_BATTERY_CONSUMER_SCOPE_COUNT]; Loading
core/java/android/os/PowerComponents.java +10 −2 Original line number Diff line number Diff line Loading @@ -439,8 +439,8 @@ class PowerComponents { } final BatteryConsumer.Key key = builder.mData.layout.getKey(componentId, processState, screenState, powerState); builder.setConsumedPower(key, powerMah, model); builder.setUsageDurationMillis(key, durationMs); builder.addConsumedPower(key, powerMah, model); builder.addUsageDurationMillis(key, durationMs); break; } } Loading Loading @@ -468,6 +468,10 @@ class PowerComponents { } } /** * @deprecated use {@link #addConsumedPower(BatteryConsumer.Key, double, int)} */ @Deprecated @NonNull public Builder setConsumedPower(BatteryConsumer.Key key, double componentPower, int powerModel) { Loading @@ -489,6 +493,10 @@ class PowerComponents { return this; } /** * @deprecated use {@link #addUsageDurationMillis(BatteryConsumer.Key, long)} */ @Deprecated @NonNull public Builder setUsageDurationMillis(BatteryConsumer.Key key, long componentUsageDurationMillis) { Loading
core/java/android/os/UidBatteryConsumer.java +4 −13 Original line number Diff line number Diff line Loading @@ -210,12 +210,6 @@ public final class UidBatteryConsumer extends BatteryConsumer { serializer.attribute(null, BatteryUsageStats.XML_ATTR_HIGHEST_DRAIN_PACKAGE, packageWithHighestDrain); } serializer.attributeLong(null, BatteryUsageStats.XML_ATTR_TIME_IN_FOREGROUND, getTimeInProcessStateMs(PROCESS_STATE_FOREGROUND)); serializer.attributeLong(null, BatteryUsageStats.XML_ATTR_TIME_IN_BACKGROUND, getTimeInProcessStateMs(PROCESS_STATE_BACKGROUND)); serializer.attributeLong(null, BatteryUsageStats.XML_ATTR_TIME_IN_FOREGROUND_SERVICE, getTimeInProcessStateMs(PROCESS_STATE_FOREGROUND_SERVICE)); mPowerComponents.writeToXml(serializer); serializer.endTag(null, BatteryUsageStats.XML_TAG_UID); } Loading @@ -235,13 +229,6 @@ public final class UidBatteryConsumer extends BatteryConsumer { consumerBuilder.setPackageWithHighestDrain( parser.getAttributeValue(null, BatteryUsageStats.XML_ATTR_HIGHEST_DRAIN_PACKAGE)); consumerBuilder.setTimeInProcessStateMs(PROCESS_STATE_FOREGROUND, parser.getAttributeLong(null, BatteryUsageStats.XML_ATTR_TIME_IN_FOREGROUND)); consumerBuilder.setTimeInProcessStateMs(PROCESS_STATE_BACKGROUND, parser.getAttributeLong(null, BatteryUsageStats.XML_ATTR_TIME_IN_BACKGROUND)); consumerBuilder.setTimeInProcessStateMs(PROCESS_STATE_FOREGROUND_SERVICE, parser.getAttributeLong(null, BatteryUsageStats.XML_ATTR_TIME_IN_FOREGROUND_SERVICE)); while (!(eventType == XmlPullParser.END_TAG && parser.getName().equals(BatteryUsageStats.XML_TAG_UID)) && eventType != XmlPullParser.END_DOCUMENT) { Loading Loading @@ -335,7 +322,11 @@ public final class UidBatteryConsumer extends BatteryConsumer { /** * Sets the duration, in milliseconds, that this UID was active in a particular process * state, such as foreground service. * * @deprecated time in process is now derived from the * {@link BatteryConsumer#POWER_COMPONENT_BASE} duration */ @Deprecated @NonNull public Builder setTimeInProcessStateMs(@ProcessState int state, long timeInProcessStateMs) { Key key = getKey(POWER_COMPONENT_BASE, state); Loading