summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2014-01-28 01:00:21 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-01-28 01:00:22 +0000
commit4a4cfbe7d80256caea84e0f4bcf043178fd30d1c (patch)
tree3b8a5c58afa4ca29b2c40f1665dcbd94eb5bf3b7
parente742799cae886e0e9b2eb5514e58bab27e34a0ee (diff)
parent5f4a5f9536eb171bf21a9293198d90c9891e7205 (diff)
downloadframeworks_base-4a4cfbe7d80256caea84e0f4bcf043178fd30d1c.zip
frameworks_base-4a4cfbe7d80256caea84e0f4bcf043178fd30d1c.tar.gz
frameworks_base-4a4cfbe7d80256caea84e0f4bcf043178fd30d1c.tar.bz2
Merge "Add "start time" timestamp to battery stats."
-rw-r--r--core/java/android/os/BatteryStats.java13
-rw-r--r--core/java/com/android/internal/os/BatteryStatsImpl.java17
2 files changed, 24 insertions, 6 deletions
diff --git a/core/java/android/os/BatteryStats.java b/core/java/android/os/BatteryStats.java
index 1ce958b..2afea1f 100644
--- a/core/java/android/os/BatteryStats.java
+++ b/core/java/android/os/BatteryStats.java
@@ -27,6 +27,7 @@ import java.util.Map;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.telephony.SignalStrength;
+import android.text.format.DateFormat;
import android.util.Printer;
import android.util.SparseArray;
import android.util.TimeUtils;
@@ -895,6 +896,11 @@ public abstract class BatteryStats implements Parcelable {
public abstract long getNetworkActivityPackets(int type, int which);
/**
+ * Return the wall clock time when battery stats data collection started.
+ */
+ public abstract long getStartClockTime();
+
+ /**
* Return whether we are currently running on battery.
*/
public abstract boolean getIsOnBattery();
@@ -1210,7 +1216,8 @@ public abstract class BatteryStats implements Parcelable {
dumpLine(pw, 0 /* uid */, category, BATTERY_DATA,
which == STATS_SINCE_CHARGED ? getStartCount() : "N/A",
whichBatteryRealtime / 1000, whichBatteryUptime / 1000,
- totalRealtime / 1000, totalUptime / 1000);
+ totalRealtime / 1000, totalUptime / 1000,
+ getStartClockTime());
// Calculate wakelock times across all uids.
long fullWakeLockTimeTotal = 0;
@@ -1587,7 +1594,9 @@ public abstract class BatteryStats implements Parcelable {
formatTimeMs(sb, totalUptime / 1000);
sb.append("uptime, ");
pw.println(sb.toString());
-
+ pw.print(" Start clock time: ");
+ pw.println(DateFormat.format("yyyy-MM-dd-HH-mm-ss", getStartClockTime()).toString());
+
final long screenOnTime = getScreenOnTime(batteryRealtime, which);
final long phoneOnTime = getPhoneOnTime(batteryRealtime, which);
final long wifiRunningTime = getGlobalWifiRunningTime(batteryRealtime, which);
diff --git a/core/java/com/android/internal/os/BatteryStatsImpl.java b/core/java/com/android/internal/os/BatteryStatsImpl.java
index 70ba4e3..7425445 100644
--- a/core/java/com/android/internal/os/BatteryStatsImpl.java
+++ b/core/java/com/android/internal/os/BatteryStatsImpl.java
@@ -87,7 +87,7 @@ public final class BatteryStatsImpl extends BatteryStats {
private static final int MAGIC = 0xBA757475; // 'BATSTATS'
// Current on-disk Parcel version
- private static final int VERSION = 70 + (USE_OLD_HISTORY ? 1000 : 0);
+ private static final int VERSION = 71 + (USE_OLD_HISTORY ? 1000 : 0);
// Maximum number of items we will record in the history.
private static final int MAX_HISTORY_ITEMS = 2000;
@@ -209,6 +209,8 @@ public final class BatteryStatsImpl extends BatteryStats {
int mStartCount;
+ long mStartClockTime;
+
long mBatteryUptime;
long mBatteryLastUptime;
long mBatteryRealtime;
@@ -2842,6 +2844,10 @@ public final class BatteryStatsImpl extends BatteryStats {
}
}
+ @Override public long getStartClockTime() {
+ return mStartClockTime;
+ }
+
@Override public boolean getIsOnBattery() {
return mOnBattery;
}
@@ -4959,6 +4965,7 @@ public final class BatteryStatsImpl extends BatteryStats {
}
void initTimes() {
+ mStartClockTime = System.currentTimeMillis();
mBatteryRealtime = mTrackBatteryPastUptime = 0;
mBatteryUptime = mTrackBatteryPastRealtime = 0;
mUptimeStart = mTrackBatteryUptimeStart = SystemClock.uptimeMillis() * 1000;
@@ -5832,6 +5839,7 @@ public final class BatteryStatsImpl extends BatteryStats {
mBatteryRealtime = in.readLong();
mUptime = in.readLong();
mRealtime = in.readLong();
+ mStartClockTime = in.readLong();
mDischargeUnplugLevel = in.readInt();
mDischargeCurrentLevel = in.readInt();
mLowDischargeAmountSinceCharge = in.readInt();
@@ -6040,9 +6048,7 @@ public final class BatteryStatsImpl extends BatteryStats {
* @param out the Parcel to be written to.
*/
public void writeSummaryToParcel(Parcel out) {
- // Need to update with current kernel wake lock counts.
- updateKernelWakelocksLocked();
- updateNetworkActivityLocked();
+ pullPendingStateUpdatesLocked();
final long NOW_SYS = SystemClock.uptimeMillis() * 1000;
final long NOWREAL_SYS = SystemClock.elapsedRealtime() * 1000;
@@ -6058,6 +6064,7 @@ public final class BatteryStatsImpl extends BatteryStats {
out.writeLong(computeBatteryRealtime(NOWREAL_SYS, STATS_SINCE_CHARGED));
out.writeLong(computeUptime(NOW_SYS, STATS_SINCE_CHARGED));
out.writeLong(computeRealtime(NOWREAL_SYS, STATS_SINCE_CHARGED));
+ out.writeLong(mStartClockTime);
out.writeInt(mDischargeUnplugLevel);
out.writeInt(mDischargeCurrentLevel);
out.writeInt(getLowDischargeAmountSinceCharge());
@@ -6293,6 +6300,7 @@ public final class BatteryStatsImpl extends BatteryStats {
mBatteryLastUptime = 0;
mBatteryRealtime = in.readLong();
mBatteryLastRealtime = 0;
+ mStartClockTime = in.readLong();
mScreenOn = false;
mScreenOnTimer = new StopwatchTimer(null, -1, null, mUnpluggables, in);
for (int i=0; i<NUM_SCREEN_BRIGHTNESS_BINS; i++) {
@@ -6408,6 +6416,7 @@ public final class BatteryStatsImpl extends BatteryStats {
out.writeInt(mStartCount);
out.writeLong(mBatteryUptime);
out.writeLong(mBatteryRealtime);
+ out.writeLong(mStartClockTime);
mScreenOnTimer.writeToParcel(out, batteryRealtime);
for (int i=0; i<NUM_SCREEN_BRIGHTNESS_BINS; i++) {
mScreenBrightnessTimer[i].writeToParcel(out, batteryRealtime);