summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings
diff options
context:
space:
mode:
authorjackqdyulei <jackqdyulei@google.com>2017-05-25 15:26:03 -0700
committerjackqdyulei <jackqdyulei@google.com>2017-05-30 15:51:29 -0700
commitde3bb7194d13fa033e78de5b4c3478fda5612f7e (patch)
tree7b33dd2afdf28d695905c9c80d2ed05b8e301e2a /src/com/android/settings
parent141e442e2685da8efb6d7e73c47bdb09804fbe28 (diff)
downloadpackages_apps_Settings-de3bb7194d13fa033e78de5b4c3478fda5612f7e.tar.gz
packages_apps_Settings-de3bb7194d13fa033e78de5b4c3478fda5612f7e.tar.bz2
packages_apps_Settings-de3bb7194d13fa033e78de5b4c3478fda5612f7e.zip
Add method to calculate last full charge time
Bug: 38481300 Test: RunSettingsRoboTests Change-Id: Icd551921f263352eb01d0c6ada62d277c8699507
Diffstat (limited to 'src/com/android/settings')
-rw-r--r--src/com/android/settings/fuelgauge/BatteryUtils.java13
-rw-r--r--src/com/android/settings/fuelgauge/PowerUsageSummary.java12
2 files changed, 18 insertions, 7 deletions
diff --git a/src/com/android/settings/fuelgauge/BatteryUtils.java b/src/com/android/settings/fuelgauge/BatteryUtils.java
index 194b2fbd46..a9792afafe 100644
--- a/src/com/android/settings/fuelgauge/BatteryUtils.java
+++ b/src/com/android/settings/fuelgauge/BatteryUtils.java
@@ -261,6 +261,19 @@ public class BatteryUtils {
});
}
+ /**
+ * Calculate the time since last full charge, including the device off time
+ *
+ * @param batteryStatsHelper utility class that contains the data
+ * @param currentTimeMs current wall time
+ * @return time in millis
+ */
+ public long calculateLastFullChargeTime(BatteryStatsHelper batteryStatsHelper,
+ long currentTimeMs) {
+ return currentTimeMs - batteryStatsHelper.getStats().getStartClockTime();
+
+ }
+
private long convertUsToMs(long timeUs) {
return timeUs / 1000;
}
diff --git a/src/com/android/settings/fuelgauge/PowerUsageSummary.java b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
index 275b78c4c8..adea925529 100644
--- a/src/com/android/settings/fuelgauge/PowerUsageSummary.java
+++ b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
@@ -24,7 +24,6 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.content.Loader;
import android.content.res.TypedArray;
-import android.content.res.Resources;
import android.database.Cursor;
import android.graphics.drawable.Drawable;
import android.net.Uri;
@@ -42,13 +41,11 @@ import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceGroup;
import android.text.TextUtils;
import android.text.format.DateUtils;
-import android.text.format.Formatter;
import android.util.Log;
import android.util.SparseArray;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
-import android.widget.TextView;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.internal.os.BatterySipper;
@@ -490,12 +487,13 @@ public class PowerUsageSummary extends PowerUsageBase implements
BatteryInfo batteryInfo = getBatteryInfo(elapsedRealtimeUs, batteryBroadcast);
mBatteryHeaderPreferenceController.updateHeaderPreference(batteryInfo);
- final long runningTime = mBatteryUtils.calculateRunningTimeBasedOnStatsType(mStatsHelper,
- mStatsType);
+ final long lastFullChargeTime = mBatteryUtils.calculateLastFullChargeTime(mStatsHelper,
+ System.currentTimeMillis());
updateScreenPreference();
- updateLastFullChargePreference(runningTime);
+ updateLastFullChargePreference(lastFullChargeTime);
- final CharSequence timeSequence = Utils.formatElapsedTime(context, runningTime, false);
+ final CharSequence timeSequence = Utils.formatElapsedTime(context, lastFullChargeTime,
+ false);
final int resId = mShowAllApps ? R.string.power_usage_list_summary_device
: R.string.power_usage_list_summary;
mAppListGroup.setTitle(TextUtils.expandTemplate(getText(resId), timeSequence));