summaryrefslogtreecommitdiff
path: root/core/java/android/os/UidBatteryConsumer.java
diff options
context:
space:
mode:
authorDmitri Plotnikov <dplotnikov@google.com>2020-12-15 18:10:14 -0800
committerDmitri Plotnikov <dplotnikov@google.com>2020-12-18 18:10:00 -0800
commit8677b4eb5bf9b9929a3c2cc3cace74383442e4ef (patch)
treef03330a79d24e6aadc723dbc53dff0ddc815abdf /core/java/android/os/UidBatteryConsumer.java
parenteb197bf6a4fac20e6109273af8473c3238a7d867 (diff)
Add SystemBatteryConsumer for the Bluetooth drain type
Bug: 175644968 Test: mp :BatteryStatsViewer && adb shell am start -n com.android.frameworks.core.batterystatsviewer/.BatteryStatsViewerActivity Change-Id: I2adde65a63faf18f0120f281ab1fcd5373f25091
Diffstat (limited to 'core/java/android/os/UidBatteryConsumer.java')
-rw-r--r--core/java/android/os/UidBatteryConsumer.java21
1 files changed, 21 insertions, 0 deletions
diff --git a/core/java/android/os/UidBatteryConsumer.java b/core/java/android/os/UidBatteryConsumer.java
index c5da22b2dc55..31617668be08 100644
--- a/core/java/android/os/UidBatteryConsumer.java
+++ b/core/java/android/os/UidBatteryConsumer.java
@@ -29,11 +29,21 @@ public final class UidBatteryConsumer extends BatteryConsumer implements Parcela
private final int mUid;
@Nullable
private final String mPackageWithHighestDrain;
+ private boolean mSystemComponent;
public int getUid() {
return mUid;
}
+ /**
+ * Returns true if this battery consumer is considered to be a part of the operating
+ * system itself. For example, the UidBatteryConsumer with the UID {@link Process#BLUETOOTH_UID}
+ * is a system component.
+ */
+ public boolean isSystemComponent() {
+ return mSystemComponent;
+ }
+
@Nullable
public String getPackageWithHighestDrain() {
return mPackageWithHighestDrain;
@@ -42,6 +52,7 @@ public final class UidBatteryConsumer extends BatteryConsumer implements Parcela
private UidBatteryConsumer(@NonNull Builder builder) {
super(builder.mPowerComponentsBuilder.build());
mUid = builder.mUid;
+ mSystemComponent = builder.mSystemComponent;
mPackageWithHighestDrain = builder.mPackageWithHighestDrain;
}
@@ -84,6 +95,7 @@ public final class UidBatteryConsumer extends BatteryConsumer implements Parcela
private final BatteryStats.Uid mBatteryStatsUid;
private final int mUid;
private String mPackageWithHighestDrain;
+ private boolean mSystemComponent;
public Builder(int customPowerComponentCount, int customTimeComponentCount,
boolean includeModeledComponents, BatteryStats.Uid batteryStatsUid) {
@@ -117,5 +129,14 @@ public final class UidBatteryConsumer extends BatteryConsumer implements Parcela
mPackageWithHighestDrain = packageName;
return this;
}
+
+ /**
+ * Marks the UidBatteryConsumer as part of the system. For example,
+ * the UidBatteryConsumer with the UID {@link Process#BLUETOOTH_UID} is considered
+ * as a system component.
+ */
+ public void setSystemComponent(boolean systemComponent) {
+ mSystemComponent = systemComponent;
+ }
}
}