summaryrefslogtreecommitdiff
path: root/core/java/android/os/AggregateBatteryConsumer.java
diff options
context:
space:
mode:
authorDmitri Plotnikov <dplotnikov@google.com>2021-04-23 15:08:29 -0700
committerDmitri Plotnikov <dplotnikov@google.com>2021-04-30 13:09:32 -0700
commitd3545200232e988bf994ea32b0acc6ba97f26484 (patch)
tree9b9ac1ea05588197766d2e63fa557cea581fdd74 /core/java/android/os/AggregateBatteryConsumer.java
parent7fc1313d39666e52d0b48ce55e8639372e4f7c01 (diff)
Aggregate power data in AggregateBatteryConsumers
as opposed to SystemBatteryConsumers, which will be removed in a follow-up CL Bug: 186006876 Test: atest FrameworksCoreTests:com.android.internal.os.BatteryStatsTests Change-Id: Ie4166217be211d92293c2a107762801a7d3c206f
Diffstat (limited to 'core/java/android/os/AggregateBatteryConsumer.java')
-rw-r--r--core/java/android/os/AggregateBatteryConsumer.java74
1 files changed, 74 insertions, 0 deletions
diff --git a/core/java/android/os/AggregateBatteryConsumer.java b/core/java/android/os/AggregateBatteryConsumer.java
new file mode 100644
index 000000000000..bcf41cce7e7c
--- /dev/null
+++ b/core/java/android/os/AggregateBatteryConsumer.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.os;
+
+import android.annotation.NonNull;
+
+/**
+ * Contains power consumption data across the entire device.
+ *
+ * {@hide}
+ */
+public final class AggregateBatteryConsumer extends BatteryConsumer implements Parcelable {
+
+ public AggregateBatteryConsumer(@NonNull Builder builder) {
+ super(builder.mPowerComponentsBuilder.build());
+ }
+
+ private AggregateBatteryConsumer(@NonNull Parcel source) {
+ super(new PowerComponents(source));
+ }
+
+ @Override
+ public void writeToParcel(@NonNull Parcel dest, int flags) {
+ super.writeToParcel(dest, flags);
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @NonNull
+ public static final Creator<AggregateBatteryConsumer> CREATOR =
+ new Creator<AggregateBatteryConsumer>() {
+ public AggregateBatteryConsumer createFromParcel(@NonNull Parcel source) {
+ return new AggregateBatteryConsumer(source);
+ }
+
+ public AggregateBatteryConsumer[] newArray(int size) {
+ return new AggregateBatteryConsumer[size];
+ }
+ };
+
+ /**
+ * Builder for DeviceBatteryConsumer.
+ */
+ public static final class Builder extends BaseBuilder<AggregateBatteryConsumer.Builder> {
+ public Builder(@NonNull String[] customPowerComponentNames, boolean includePowerModels) {
+ super(customPowerComponentNames, includePowerModels);
+ }
+
+ /**
+ * Creates a read-only object out of the Builder values.
+ */
+ @NonNull
+ public AggregateBatteryConsumer build() {
+ return new AggregateBatteryConsumer(this);
+ }
+ }
+}