summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorDmitri Plotnikov <dplotnikov@google.com>2021-10-05 18:03:22 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2021-10-05 18:03:22 +0000
commit17be86c4f77b5085959f0b795e1c4a6217bafca2 (patch)
treef1e1a06cebce5f6336b299c449b909d5707d7624 /core/java/android
parent5154782c90dcdeedcaed2d7cb11873a99cc087bc (diff)
parentd9bf639edc1729364b1c2c992d996d1fb6ff1479 (diff)
Merge "Writing battery history tags into the history buffer"
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/os/BatteryStats.java6
-rw-r--r--core/java/android/os/BatteryUsageStats.java30
2 files changed, 9 insertions, 27 deletions
diff --git a/core/java/android/os/BatteryStats.java b/core/java/android/os/BatteryStats.java
index fb9911811da9..dd387dadd4dd 100644
--- a/core/java/android/os/BatteryStats.java
+++ b/core/java/android/os/BatteryStats.java
@@ -1908,6 +1908,10 @@ public abstract class BatteryStats implements Parcelable {
public final HistoryTag localWakeReasonTag = new HistoryTag();
public final HistoryTag localEventTag = new HistoryTag();
+ // Includes a tag's first occurrence in the parcel, so the value of the tag is written
+ // rather than just its index in the history tag pool.
+ public boolean tagsFirstOccurrence;
+
@UnsupportedAppUsage
public HistoryItem() {
}
@@ -2014,6 +2018,7 @@ public abstract class BatteryStats implements Parcelable {
wakeReasonTag = null;
eventCode = EVENT_NONE;
eventTag = null;
+ tagsFirstOccurrence = false;
}
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
@@ -2061,6 +2066,7 @@ public abstract class BatteryStats implements Parcelable {
} else {
eventTag = null;
}
+ tagsFirstOccurrence = o.tagsFirstOccurrence;
currentTime = o.currentTime;
}
diff --git a/core/java/android/os/BatteryUsageStats.java b/core/java/android/os/BatteryUsageStats.java
index 591b665f97a2..d37c0eb5f1d2 100644
--- a/core/java/android/os/BatteryUsageStats.java
+++ b/core/java/android/os/BatteryUsageStats.java
@@ -133,7 +133,6 @@ public final class BatteryUsageStats implements Parcelable, Closeable {
private final List<UserBatteryConsumer> mUserBatteryConsumers;
private final AggregateBatteryConsumer[] mAggregateBatteryConsumers;
private final Parcel mHistoryBuffer;
- private final List<BatteryStats.HistoryTag> mHistoryTagPool;
private CursorWindow mBatteryConsumersCursorWindow;
private BatteryUsageStats(@NonNull Builder builder) {
@@ -145,7 +144,6 @@ public final class BatteryUsageStats implements Parcelable, Closeable {
mDischargedPowerLowerBound = builder.mDischargedPowerLowerBoundMah;
mDischargedPowerUpperBound = builder.mDischargedPowerUpperBoundMah;
mHistoryBuffer = builder.mHistoryBuffer;
- mHistoryTagPool = builder.mHistoryTagPool;
mBatteryTimeRemainingMs = builder.mBatteryTimeRemainingMs;
mChargeTimeRemainingMs = builder.mChargeTimeRemainingMs;
mCustomPowerComponentNames = builder.mCustomPowerComponentNames;
@@ -283,7 +281,7 @@ public final class BatteryUsageStats implements Parcelable, Closeable {
/**
* Returns the names of custom power components in order, so the first name in the array
* corresponds to the custom componentId
- * {@link BatteryConsumer.FIRST_CUSTOM_POWER_COMPONENT_ID}.
+ * {@link BatteryConsumer#FIRST_CUSTOM_POWER_COMPONENT_ID}.
*/
@NonNull
public String[] getCustomPowerComponentNames() {
@@ -299,8 +297,7 @@ public final class BatteryUsageStats implements Parcelable, Closeable {
throw new IllegalStateException(
"Battery history was not requested in the BatteryUsageStatsQuery");
}
- return new BatteryStatsHistoryIterator(new BatteryStatsHistory(mHistoryBuffer),
- mHistoryTagPool);
+ return new BatteryStatsHistoryIterator(new BatteryStatsHistory(mHistoryBuffer));
}
@Override
@@ -361,19 +358,8 @@ public final class BatteryUsageStats implements Parcelable, Closeable {
mHistoryBuffer = Parcel.obtain();
mHistoryBuffer.unmarshall(historyBlob, 0, historyBlob.length);
-
- int historyTagCount = source.readInt();
- mHistoryTagPool = new ArrayList<>(historyTagCount);
- for (int i = 0; i < historyTagCount; i++) {
- BatteryStats.HistoryTag tag = new BatteryStats.HistoryTag();
- tag.string = source.readString();
- tag.uid = source.readInt();
- tag.poolIdx = source.readInt();
- mHistoryTagPool.add(tag);
- }
} else {
mHistoryBuffer = null;
- mHistoryTagPool = null;
}
}
@@ -395,13 +381,6 @@ public final class BatteryUsageStats implements Parcelable, Closeable {
if (mHistoryBuffer != null) {
dest.writeBoolean(true);
dest.writeBlob(mHistoryBuffer.marshall());
- dest.writeInt(mHistoryTagPool.size());
- for (int i = mHistoryTagPool.size() - 1; i >= 0; i--) {
- final BatteryStats.HistoryTag tag = mHistoryTagPool.get(i);
- dest.writeString(tag.string);
- dest.writeInt(tag.uid);
- dest.writeInt(tag.poolIdx);
- }
} else {
dest.writeBoolean(false);
}
@@ -769,7 +748,6 @@ public final class BatteryUsageStats implements Parcelable, Closeable {
private final SparseArray<UserBatteryConsumer.Builder> mUserBatteryConsumerBuilders =
new SparseArray<>();
private Parcel mHistoryBuffer;
- private List<BatteryStats.HistoryTag> mHistoryTagPool;
public Builder(@NonNull String[] customPowerComponentNames) {
this(customPowerComponentNames, false);
@@ -888,10 +866,8 @@ public final class BatteryUsageStats implements Parcelable, Closeable {
* Sets the parceled recent history.
*/
@NonNull
- public Builder setBatteryHistory(Parcel historyBuffer,
- List<BatteryStats.HistoryTag> historyTagPool) {
+ public Builder setBatteryHistory(Parcel historyBuffer) {
mHistoryBuffer = historyBuffer;
- mHistoryTagPool = historyTagPool;
return this;
}