summaryrefslogtreecommitdiff
path: root/src/com/android/loganalysis/item
diff options
context:
space:
mode:
authorHector Tellez <htellez@google.com>2016-03-04 19:56:20 -0800
committerHector Tellez <htellez@google.com>2016-03-09 17:07:51 -0800
commite952089725398c8fa8b617ca7bdde840a38849fd (patch)
tree99028f4322d29b98ebc4dd40962484f4b98d2d7d /src/com/android/loganalysis/item
parent61a8a07e6770a403ebdb2d55dffcb33409573357 (diff)
downloadloganalysis-e952089725398c8fa8b617ca7bdde840a38849fd.tar.gz
Adds projected battery life analysis.
Change-Id: I25bcb84f5d62802dcb51d9a3ceae60929eb89606
Diffstat (limited to 'src/com/android/loganalysis/item')
-rw-r--r--src/com/android/loganalysis/item/BatteryDischargeStatsInfoItem.java119
-rw-r--r--src/com/android/loganalysis/item/DumpsysBatteryStatsItem.java19
2 files changed, 138 insertions, 0 deletions
diff --git a/src/com/android/loganalysis/item/BatteryDischargeStatsInfoItem.java b/src/com/android/loganalysis/item/BatteryDischargeStatsInfoItem.java
new file mode 100644
index 0000000..8c15b92
--- /dev/null
+++ b/src/com/android/loganalysis/item/BatteryDischargeStatsInfoItem.java
@@ -0,0 +1,119 @@
+/*
+ * Copyright (C) 2016 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 com.android.loganalysis.item;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * An {@link IItem} used to store information of the battery discharge.
+ */
+public class BatteryDischargeStatsInfoItem extends GenericItem {
+
+ /** Constant for JSON output */
+ public static final String MAX_PERCENTAGE = "MAX_PERCENTAGE";
+ /** Constant for JSON output */
+ public static final String MIN_PERCENTAGE = "MIN_PERCENTAGE";
+ /** Constant for JSON output */
+ public static final String DISCHARGE_PERCENTAGE = "DISCHARGE_PERCENTAGE";
+ /** Constant for JSON output */
+ public static final String DISCHARGE_DURATION = "DISCHARGE_DURATION";
+ /** Constant for JSON output */
+ public static final String PROJECTED_BATTERY_LIFE = "PROJECTED_BATTERY_LIFE";
+
+ private static final Set<String> ATTRIBUTES = new HashSet<>(Arrays.asList(MAX_PERCENTAGE,
+ MIN_PERCENTAGE, DISCHARGE_PERCENTAGE, DISCHARGE_DURATION, PROJECTED_BATTERY_LIFE));
+
+ /**
+ * The constructor for {@link BatteryDischargeStatsInfoItem}.
+ */
+ public BatteryDischargeStatsInfoItem() {
+ super(ATTRIBUTES);
+ }
+
+ /**
+ * Set the maximum percentage.
+ */
+ public void setMaxPercentage(int percentage) {
+ setAttribute(MAX_PERCENTAGE, percentage);
+ }
+
+ /**
+ * Set the minimum percentage.
+ */
+ public void setMinPercentage(int percentage) {
+ setAttribute(MIN_PERCENTAGE, percentage);
+ }
+
+ /**
+ * Set the discharge percentage.
+ */
+ public void setDischargePercentage(int dischargePercentage) {
+ setAttribute(DISCHARGE_PERCENTAGE, dischargePercentage);
+ }
+
+ /**
+ * Set the discharge duration.
+ */
+ public void setDischargeDuration(long dischargeDuration) {
+ setAttribute(DISCHARGE_DURATION, dischargeDuration);
+ }
+
+ /**
+ * Set the projected battery life.
+ */
+ public void setProjectedBatteryLife(long projectedBatteryLife) {
+ setAttribute(PROJECTED_BATTERY_LIFE, projectedBatteryLife);
+ }
+
+ /**
+ * Get the maximum percentage.
+ */
+ public int getMaxPercentage() {
+ return (int) getAttribute(MAX_PERCENTAGE);
+ }
+
+ /**
+ * Get the minimum percentage.
+ */
+ public int getMinPercentage() {
+ return (int) getAttribute(MIN_PERCENTAGE);
+ }
+
+ /**
+ * Get the discharge percentage.
+ */
+ public int getDischargePercentage() {
+ return (int) getAttribute(DISCHARGE_PERCENTAGE);
+ }
+
+ /**
+ * Get the discharge duration.
+ */
+ public long getDischargeDuration() {
+ return (long) getAttribute(DISCHARGE_DURATION);
+ }
+
+ /**
+ * Get the projected battery life.
+ */
+ public long getProjectedBatteryLife() {
+ return (long) getAttribute(PROJECTED_BATTERY_LIFE);
+ }
+
+}
diff --git a/src/com/android/loganalysis/item/DumpsysBatteryStatsItem.java b/src/com/android/loganalysis/item/DumpsysBatteryStatsItem.java
index 1039324..8b7a800 100644
--- a/src/com/android/loganalysis/item/DumpsysBatteryStatsItem.java
+++ b/src/com/android/loganalysis/item/DumpsysBatteryStatsItem.java
@@ -27,9 +27,12 @@ public class DumpsysBatteryStatsItem implements IItem {
public static final String SUMMARY = "SUMMARY";
/** Constant for JSON output */
public static final String DETAILED_STATS = "DETAILED_STATS";
+ /** Constant for JSON output */
+ public static final String DISCHARGE_STATS = "DISCHARGE_STATS";
private BatteryStatsSummaryInfoItem mBatteryStatsSummaryItem;
private BatteryStatsDetailedInfoItem mDetailedBatteryStatsItem;
+ private BatteryDischargeStatsInfoItem mDischargeStatsItem;
/**
* Set the battery stats summary {@link BatteryStatsSummaryInfoItem}
@@ -46,6 +49,13 @@ public class DumpsysBatteryStatsItem implements IItem {
}
/**
+ * Set the battery steps info item {@link BatteryDischargeStatsInfoItem}
+ */
+ public void setBatteryDischargeStatsItem(BatteryDischargeStatsInfoItem item){
+ mDischargeStatsItem = item;
+ }
+
+ /**
* Get the battery stats summary {@link BatteryStatsSummaryInfoItem}
*/
public BatteryStatsSummaryInfoItem getBatteryStatsSummaryItem() {
@@ -59,6 +69,12 @@ public class DumpsysBatteryStatsItem implements IItem {
return mDetailedBatteryStatsItem;
}
+ /**
+ * Get the battery steps info item {@link BatteryDischargeStatsInfoItem}
+ */
+ public BatteryDischargeStatsInfoItem getBatteryDischargeStatsItem() {
+ return mDischargeStatsItem;
+ }
/**
* {@inheritDoc}
@@ -89,6 +105,9 @@ public class DumpsysBatteryStatsItem implements IItem {
if (mDetailedBatteryStatsItem != null) {
batteryStatsComponent.put(DETAILED_STATS, mDetailedBatteryStatsItem.toJson());
}
+ if (mDischargeStatsItem != null) {
+ batteryStatsComponent.put(DISCHARGE_STATS, mDischargeStatsItem.toJson());
+ }
} catch (JSONException e) {
// ignore
}