diff options
6 files changed, 127 insertions, 23 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml index 720b998..f5bcaaf 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -2037,13 +2037,17 @@ found in the list of installed applications.</string> <string name="battery_stats_on_battery"><xliff:g id="time">%1$s</xliff:g> on battery</string> <!-- Battery usage duration --> <string name="battery_stats_duration"><xliff:g id="time">%1$s</xliff:g> since unplugged</string> - <!-- Label for battery stats charging state graph --> + <!-- [CHAR LIMIT=25] Label for battery stats charging state graph --> <string name="battery_stats_charging_label">Charging</string> - <!-- Label for battery stats screen on state graph --> + <!-- [CHAR LIMIT=25] Label for battery stats screen on state graph --> <string name="battery_stats_screen_on_label">Screen on</string> - <!-- Label for battery stats gps on state graph --> + <!-- [CHAR LIMIT=25] Label for battery stats gps on state graph --> <string name="battery_stats_gps_on_label">GPS on</string> - <!-- Label for battery stats phone signal strength graph --> + <!-- [CHAR LIMIT=25] Label for battery stats wifi running state graph --> + <string name="battery_stats_wifi_running_label">WIFI</string> + <!-- [CHAR LIMIT=25] Label for battery stats wake lock state graph --> + <string name="battery_stats_wake_lock_label">Awake</string> + <!-- [CHAR LIMIT=25] Label for battery stats phone signal strength graph --> <string name="battery_stats_phone_signal_label">Phone signal</string> <!-- Battery usage during last unplugged period --> <string name="battery_stats_last_duration">@string/menu_stats_last_unplugged</string> @@ -2083,6 +2087,8 @@ found in the list of installed applications.</string> <string name="usage_type_cpu">CPU total</string> <!-- Label for CPU usage in foreground --> <string name="usage_type_cpu_foreground">CPU foreground</string> + <!-- [CHAR LIMIT=25] Label for keeping device from sleeping --> + <string name="usage_type_wake_lock">Keep awake</string> <!-- Label for GPU usage time --> <string name="usage_type_gps">GPS</string> <!-- Label for Phone usage time --> diff --git a/src/com/android/settings/applications/RunningProcessesView.java b/src/com/android/settings/applications/RunningProcessesView.java index 7dbd8f8..f2d8e9e 100644 --- a/src/com/android/settings/applications/RunningProcessesView.java +++ b/src/com/android/settings/applications/RunningProcessesView.java @@ -115,11 +115,11 @@ public class RunningProcessesView extends FrameLayout } if (uptimeView != null) { - if (mItem.mActiveSince >= 0) { + if (mFirstRunTime >= 0) { //Log.i("foo", "Time for " + mItem.mDisplayLabel // + ": " + (SystemClock.uptimeMillis()-mFirstRunTime)); uptimeView.setText(DateUtils.formatElapsedTime(builder, - (SystemClock.uptimeMillis()-mFirstRunTime)/1000)); + (SystemClock.elapsedRealtime()-mFirstRunTime)/1000)); } else { boolean isService = false; if (mItem instanceof RunningState.MergedItem) { diff --git a/src/com/android/settings/applications/RunningServiceDetails.java b/src/com/android/settings/applications/RunningServiceDetails.java index d57cd4a..6346ec2 100644 --- a/src/com/android/settings/applications/RunningServiceDetails.java +++ b/src/com/android/settings/applications/RunningServiceDetails.java @@ -92,8 +92,8 @@ public class RunningServiceDetails extends Activity & ApplicationInfo.FLAG_SYSTEM) != 0; ApplicationErrorReport.RunningServiceInfo info = new ApplicationErrorReport.RunningServiceInfo(); - if (mActiveItem.mItem.mActiveSince >= 0) { - info.durationMillis = SystemClock.uptimeMillis()-mActiveItem.mFirstRunTime; + if (mActiveItem.mFirstRunTime >= 0) { + info.durationMillis = SystemClock.elapsedRealtime()-mActiveItem.mFirstRunTime; } else { info.durationMillis = -1; } diff --git a/src/com/android/settings/fuelgauge/BatteryHistoryChart.java b/src/com/android/settings/fuelgauge/BatteryHistoryChart.java index 7750eca..25d8609 100644 --- a/src/com/android/settings/fuelgauge/BatteryHistoryChart.java +++ b/src/com/android/settings/fuelgauge/BatteryHistoryChart.java @@ -53,6 +53,8 @@ public class BatteryHistoryChart extends View { final Paint mChargingPaint = new Paint(); final Paint mScreenOnPaint = new Paint(); final Paint mGpsOnPaint = new Paint(); + final Paint mWifiRunningPaint = new Paint(); + final Paint mWakeLockPaint = new Paint(); final Paint[] mPhoneSignalPaints = new Paint[NUM_PHONE_SIGNALS]; final int[] mPhoneSignalColors = new int[] { 0x00000000, 0xffa00000, 0xffa0a000, 0xff808020, @@ -67,6 +69,8 @@ public class BatteryHistoryChart extends View { final Path mChargingPath = new Path(); final Path mScreenOnPath = new Path(); final Path mGpsOnPath = new Path(); + final Path mWifiRunningPath = new Path(); + final Path mWakeLockPath = new Path(); int mFontSize; @@ -77,6 +81,8 @@ public class BatteryHistoryChart extends View { String mChargingLabel; String mScreenOnLabel; String mGpsOnLabel; + String mWifiRunningLabel; + String mWakeLockLabel; String mPhoneSignalLabel; int mTextAscent; @@ -91,6 +97,8 @@ public class BatteryHistoryChart extends View { int mChargingOffset; int mScreenOnOffset; int mGpsOnOffset; + int mWifiRunningOffset; + int mWakeLockOffset; int mPhoneSignalOffset; int mLevelOffset; int mLevelTop; @@ -107,6 +115,8 @@ public class BatteryHistoryChart extends View { long mHistEnd; int mBatLow; int mBatHigh; + boolean mHaveWifi; + boolean mHaveGps; public BatteryHistoryChart(Context context, AttributeSet attrs) { super(context, attrs); @@ -125,6 +135,10 @@ public class BatteryHistoryChart extends View { mScreenOnPaint.setStyle(Paint.Style.STROKE); mGpsOnPaint.setARGB(255, 0, 0, 255); mGpsOnPaint.setStyle(Paint.Style.STROKE); + mWifiRunningPaint.setARGB(255, 0, 0, 255); + mWifiRunningPaint.setStyle(Paint.Style.STROKE); + mWakeLockPaint.setARGB(255, 0, 0, 255); + mWakeLockPaint.setStyle(Paint.Style.STROKE); for (int i=0; i<NUM_PHONE_SIGNALS; i++) { mPhoneSignalPaints[i] = new Paint(); mPhoneSignalPaints[i].setColor(mPhoneSignalColors[i]); @@ -278,6 +292,8 @@ public class BatteryHistoryChart extends View { mChargingLabel = getContext().getString(R.string.battery_stats_charging_label); mScreenOnLabel = getContext().getString(R.string.battery_stats_screen_on_label); mGpsOnLabel = getContext().getString(R.string.battery_stats_gps_on_label); + mWifiRunningLabel = getContext().getString(R.string.battery_stats_wifi_running_label); + mWakeLockLabel = getContext().getString(R.string.battery_stats_wake_lock_label); mPhoneSignalLabel = getContext().getString(R.string.battery_stats_phone_signal_label); BatteryStats.HistoryItem rec = stats.getHistory(); @@ -287,6 +303,7 @@ public class BatteryHistoryChart extends View { byte lastLevel = -1; mBatLow = 0; mBatHigh = 100; + int aggrStates = 0; while (rec != null) { pos++; if (rec.cmd == HistoryItem.CMD_UPDATE) { @@ -299,10 +316,13 @@ public class BatteryHistoryChart extends View { lastInteresting = pos; mHistEnd = rec.time; } + aggrStates |= rec.states; } rec = rec.next; } mNumHist = lastInteresting; + mHaveGps = (aggrStates&HistoryItem.STATE_GPS_ON_FLAG) != 0; + mHaveWifi = (aggrStates&HistoryItem.STATE_WIFI_RUNNING_FLAG) != 0; if (mHistEnd <= mHistStart) mHistEnd = mHistStart+1; mTotalDurationString = Utils.formatElapsedTime(getContext(), mHistEnd - mHistStart); @@ -325,7 +345,7 @@ public class BatteryHistoryChart extends View { void finishPaths(int w, int h, int levelh, int startX, int y, Path curLevelPath, int lastX, boolean lastCharging, boolean lastScreenOn, boolean lastGpsOn, - int lastPhoneSignal, Path lastPath) { + boolean lastWifiRunning, boolean lastWakeLock, int lastPhoneSignal, Path lastPath) { if (curLevelPath != null) { if (lastX >= 0 && lastX < w) { if (lastPath != null) { @@ -347,6 +367,12 @@ public class BatteryHistoryChart extends View { if (lastGpsOn) { mGpsOnPath.lineTo(w, h-mGpsOnOffset); } + if (lastWifiRunning) { + mWifiRunningPath.lineTo(w, h-mWifiRunningOffset); + } + if (lastWakeLock) { + mWakeLockPath.lineTo(w, h-mWakeLockOffset); + } if (lastPhoneSignal != 0) { addPhoneSignalTick(w, 0); } @@ -376,17 +402,22 @@ public class BatteryHistoryChart extends View { mChargingPaint.setStrokeWidth(mLineWidth); mScreenOnPaint.setStrokeWidth(mLineWidth); mGpsOnPaint.setStrokeWidth(mLineWidth); + mWifiRunningPaint.setStrokeWidth(mLineWidth); + mWakeLockPaint.setStrokeWidth(mLineWidth); if (mLargeMode) { int barOffset = textHeight + mLineWidth; - mScreenOnOffset = mLineWidth; - mGpsOnOffset = mScreenOnOffset + barOffset; - mPhoneSignalOffset = mGpsOnOffset + barOffset; - mChargingOffset = mPhoneSignalOffset + barOffset; - mLevelOffset = mChargingOffset + barOffset + mLineWidth; + mChargingOffset = mLineWidth; + mScreenOnOffset = mChargingOffset + barOffset; + mWakeLockOffset = mScreenOnOffset + barOffset; + mWifiRunningOffset = mWakeLockOffset + barOffset; + mGpsOnOffset = mHaveWifi ? (mWifiRunningOffset + barOffset) : mWakeLockOffset; + mPhoneSignalOffset = mHaveGps ? (mGpsOnOffset + barOffset) : mWifiRunningOffset; + mLevelOffset = mPhoneSignalOffset + barOffset + mLineWidth; mPhoneSignalTicks = new int[w+2]; } else { - mScreenOnOffset = mGpsOnOffset = mLineWidth; + mScreenOnOffset = mGpsOnOffset = mWifiRunningOffset + = mWakeLockOffset = mLineWidth; mChargingOffset = mLineWidth*2; mPhoneSignalOffset = 0; mLevelOffset = mLineWidth*3; @@ -399,6 +430,8 @@ public class BatteryHistoryChart extends View { mBatCriticalPath.reset(); mScreenOnPath.reset(); mGpsOnPath.reset(); + mWifiRunningPath.reset(); + mWakeLockPath.reset(); mChargingPath.reset(); final long timeStart = mHistStart; @@ -416,6 +449,7 @@ public class BatteryHistoryChart extends View { Path curLevelPath = null; Path lastLinePath = null; boolean lastCharging = false, lastScreenOn = false, lastGpsOn = false; + boolean lastWifiRunning = false, lastWakeLock = false; int lastPhoneSignalBin = 0; final int N = mNumHist; while (rec != null && i < N) { @@ -487,6 +521,28 @@ public class BatteryHistoryChart extends View { lastGpsOn = gpsOn; } + final boolean wifiRunning = + (rec.states&HistoryItem.STATE_WIFI_RUNNING_FLAG) != 0; + if (wifiRunning != lastWifiRunning) { + if (wifiRunning) { + mWifiRunningPath.moveTo(x, h-mWifiRunningOffset); + } else { + mWifiRunningPath.lineTo(x, h-mWifiRunningOffset); + } + lastWifiRunning = wifiRunning; + } + + final boolean wakeLock = + (rec.states&HistoryItem.STATE_WAKE_LOCK_FLAG) != 0; + if (wakeLock != lastWakeLock) { + if (wakeLock) { + mWakeLockPath.moveTo(x, h-mWakeLockOffset); + } else { + mWakeLockPath.lineTo(x, h-mWakeLockOffset); + } + lastWakeLock = wakeLock; + } + if (mLargeMode) { int bin; if (((rec.states&HistoryItem.STATE_PHONE_STATE_MASK) @@ -509,12 +565,12 @@ public class BatteryHistoryChart extends View { } else if (curLevelPath != null) { finishPaths(x+1, h, levelh, startX, lastY, curLevelPath, lastX, - lastCharging, lastScreenOn, lastGpsOn, lastPhoneSignalBin, - lastLinePath); + lastCharging, lastScreenOn, lastGpsOn, lastWifiRunning, + lastWakeLock, lastPhoneSignalBin, lastLinePath); lastX = lastY = -1; curLevelPath = null; lastLinePath = null; - lastCharging = lastScreenOn = lastGpsOn = false; + lastCharging = lastScreenOn = lastGpsOn = lastWakeLock = false; lastPhoneSignalBin = 0; } @@ -523,7 +579,8 @@ public class BatteryHistoryChart extends View { } finishPaths(w, h, levelh, startX, lastY, curLevelPath, lastX, - lastCharging, lastScreenOn, lastGpsOn, lastPhoneSignalBin, lastLinePath); + lastCharging, lastScreenOn, lastGpsOn, lastWifiRunning, + lastWakeLock, lastPhoneSignalBin, lastLinePath); } @Override @@ -571,15 +628,33 @@ public class BatteryHistoryChart extends View { if (!mChargingPath.isEmpty()) { canvas.drawPath(mChargingPath, mChargingPaint); } - if (!mGpsOnPath.isEmpty()) { - canvas.drawPath(mGpsOnPath, mGpsOnPaint); + if (mHaveGps) { + if (!mGpsOnPath.isEmpty()) { + canvas.drawPath(mGpsOnPath, mGpsOnPaint); + } + } + if (mHaveWifi) { + if (!mWifiRunningPath.isEmpty()) { + canvas.drawPath(mWifiRunningPath, mWifiRunningPaint); + } + } + if (!mWakeLockPath.isEmpty()) { + canvas.drawPath(mWakeLockPath, mWakeLockPaint); } if (mLargeMode) { canvas.drawText(mPhoneSignalLabel, 0, height - mPhoneSignalOffset - mTextDescent, mTextPaint); - canvas.drawText(mGpsOnLabel, 0, - height - mGpsOnOffset - mTextDescent, mTextPaint); + if (mHaveGps) { + canvas.drawText(mGpsOnLabel, 0, + height - mGpsOnOffset - mTextDescent, mTextPaint); + } + if (mHaveWifi) { + canvas.drawText(mWifiRunningLabel, 0, + height - mWifiRunningOffset - mTextDescent, mTextPaint); + } + canvas.drawText(mWakeLockLabel, 0, + height - mWakeLockOffset - mTextDescent, mTextPaint); canvas.drawText(mChargingLabel, 0, height - mChargingOffset - mTextDescent, mTextPaint); canvas.drawText(mScreenOnLabel, 0, diff --git a/src/com/android/settings/fuelgauge/BatterySipper.java b/src/com/android/settings/fuelgauge/BatterySipper.java index 8125146..fc967d3 100644 --- a/src/com/android/settings/fuelgauge/BatterySipper.java +++ b/src/com/android/settings/fuelgauge/BatterySipper.java @@ -46,6 +46,7 @@ class BatterySipper implements Comparable<BatterySipper> { long cpuTime; long gpsTime; long cpuFgTime; + long wakeLockTime; double percent; double noCoveragePercent; String defaultPackageName; diff --git a/src/com/android/settings/fuelgauge/PowerUsageSummary.java b/src/com/android/settings/fuelgauge/PowerUsageSummary.java index c20caf6..3ff7080 100644 --- a/src/com/android/settings/fuelgauge/PowerUsageSummary.java +++ b/src/com/android/settings/fuelgauge/PowerUsageSummary.java @@ -160,6 +160,7 @@ public class PowerUsageSummary extends PreferenceActivity implements Runnable { types = new int[] { R.string.usage_type_cpu, R.string.usage_type_cpu_foreground, + R.string.usage_type_wake_lock, R.string.usage_type_gps, R.string.usage_type_data_send, R.string.usage_type_data_recv, @@ -169,6 +170,7 @@ public class PowerUsageSummary extends PreferenceActivity implements Runnable { values = new double[] { sipper.cpuTime, sipper.cpuFgTime, + sipper.wakeLockTime, sipper.gpsTime, uid != null? uid.getTcpBytesSent(mStatsType) : 0, uid != null? uid.getTcpBytesReceived(mStatsType) : 0, @@ -340,6 +342,7 @@ public class PowerUsageSummary extends PreferenceActivity implements Runnable { Map<String, ? extends BatteryStats.Uid.Proc> processStats = u.getProcessStats(); long cpuTime = 0; long cpuFgTime = 0; + long wakelockTime = 0; long gpsTime = 0; if (processStats.size() > 0) { // Process CPU time @@ -384,6 +387,24 @@ public class PowerUsageSummary extends PreferenceActivity implements Runnable { } power /= 1000; + // Process wake lock usage + Map<String, ? extends BatteryStats.Uid.Wakelock> wakelockStats = u.getWakelockStats(); + for (Map.Entry<String, ? extends BatteryStats.Uid.Wakelock> wakelockEntry + : wakelockStats.entrySet()) { + Uid.Wakelock wakelock = wakelockEntry.getValue(); + BatteryStats.Timer timer = wakelock.getWakeTime(BatteryStats.WAKE_TYPE_FULL); + if (timer != null) { + wakelockTime += timer.getTotalTimeLocked(uSecTime, which); + } + timer = wakelock.getWakeTime(BatteryStats.WAKE_TYPE_PARTIAL); + if (timer != null) { + wakelockTime += timer.getTotalTimeLocked(uSecTime, which); + } + // Note: not considering window, since that is just the system + // keeping the screen on while the app is running. + } + wakelockTime /= 1000; // convert to millis + // Add cost of data traffic power += (u.getTcpBytesReceived(mStatsType) + u.getTcpBytesSent(mStatsType)) * averageCostPerByte; @@ -424,6 +445,7 @@ public class PowerUsageSummary extends PreferenceActivity implements Runnable { app.cpuTime = cpuTime; app.gpsTime = gpsTime; app.cpuFgTime = cpuFgTime; + app.wakeLockTime = wakelockTime; mUsageList.add(app); } if (power > mMaxPower) mMaxPower = power; |