diff options
author | Dianne Hackborn <hackbod@google.com> | 2014-05-14 11:42:00 -0700 |
---|---|---|
committer | Dianne Hackborn <hackbod@google.com> | 2014-05-15 13:32:29 -0700 |
commit | cbefd8dd2befcb768f911a63becc427ec4c13250 (patch) | |
tree | 083c53ca606811b4ccfbda8d013f29497b7efbd0 /core | |
parent | e7db83426e9979a0b6ecf124a013dc944dd3ccce (diff) | |
download | frameworks_base-cbefd8dd2befcb768f911a63becc427ec4c13250.zip frameworks_base-cbefd8dd2befcb768f911a63becc427ec4c13250.tar.gz frameworks_base-cbefd8dd2befcb768f911a63becc427ec4c13250.tar.bz2 |
Battery stats more wake history, power save mode.
Add new option for battery stats to record the full wake
lock history, and recording the current power save mode.
Also add in some additional error constants when generating
Binder error exceptions.
And fix issue #14974572: Avoid repeating wakeup_reason at
the beginning of history
Change-Id: I7c1a2ab9569de216634f63d8ad69f1294ef1d235
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/os/BatteryStats.java | 110 | ||||
-rw-r--r-- | core/java/android/os/PowerManagerInternal.java | 8 | ||||
-rw-r--r-- | core/java/com/android/internal/app/IBatteryStats.aidl | 9 | ||||
-rw-r--r-- | core/java/com/android/internal/os/BatteryStatsImpl.java | 125 | ||||
-rw-r--r-- | core/jni/android_util_Binder.cpp | 32 |
5 files changed, 211 insertions, 73 deletions
diff --git a/core/java/android/os/BatteryStats.java b/core/java/android/os/BatteryStats.java index 4857533..cf0caed 100644 --- a/core/java/android/os/BatteryStats.java +++ b/core/java/android/os/BatteryStats.java @@ -31,7 +31,6 @@ import android.telephony.SignalStrength; import android.text.format.DateFormat; import android.util.Printer; import android.util.SparseArray; -import android.util.SparseBooleanArray; import android.util.SparseIntArray; import android.util.TimeUtils; import com.android.internal.os.BatterySipper; @@ -601,6 +600,7 @@ public abstract class BatteryStats implements Parcelable { public int states; public static final int STATE2_VIDEO_ON_FLAG = 1<<0; + public static final int STATE2_LOW_POWER_FLAG = 1<<1; public int states2; // The wake lock that was acquired at this point. @@ -622,8 +622,11 @@ public abstract class BatteryStats implements Parcelable { public static final int EVENT_TOP = 0x0003; // Event is about an application package that is at the top of the screen. public static final int EVENT_SYNC = 0x0004; + // Events for all additional wake locks aquired/release within a wake block. + // These are not generated by default. + public static final int EVENT_WAKE_LOCK = 0x0005; // Number of event types. - public static final int EVENT_COUNT = 0x0005; + public static final int EVENT_COUNT = 0x0006; // Mask to extract out only the type part of the event. public static final int EVENT_TYPE_MASK = ~(EVENT_FLAG_START|EVENT_FLAG_FINISH); @@ -635,6 +638,8 @@ public abstract class BatteryStats implements Parcelable { public static final int EVENT_TOP_FINISH = EVENT_TOP | EVENT_FLAG_FINISH; public static final int EVENT_SYNC_START = EVENT_SYNC | EVENT_FLAG_START; public static final int EVENT_SYNC_FINISH = EVENT_SYNC | EVENT_FLAG_FINISH; + public static final int EVENT_WAKE_LOCK_START = EVENT_WAKE_LOCK | EVENT_FLAG_START; + public static final int EVENT_WAKE_LOCK_FINISH = EVENT_WAKE_LOCK | EVENT_FLAG_FINISH; // For CMD_EVENT. public int eventCode; @@ -887,6 +892,11 @@ public abstract class BatteryStats implements Parcelable { return true; } + public void removeEvents(int code) { + int idx = code&HistoryItem.EVENT_TYPE_MASK; + mActiveEvents[idx] = null; + } + public HashMap<String, SparseIntArray> getStateForEvent(int code) { return mActiveEvents[code]; } @@ -997,6 +1007,21 @@ public abstract class BatteryStats implements Parcelable { long elapsedRealtimeUs, int which); /** + * Returns the time in microseconds that low power mode has been enabled while the device was + * running on battery. + * + * {@hide} + */ + public abstract long getLowPowerModeEnabledTime(long elapsedRealtimeUs, int which); + + /** + * Returns the number of times that low power mode was enabled. + * + * {@hide} + */ + public abstract int getLowPowerModeEnabledCount(int which); + + /** * Returns the time in microseconds that the phone has been on while the device was * running on battery. * @@ -1157,14 +1182,15 @@ public abstract class BatteryStats implements Parcelable { public static final BitDescription[] HISTORY_STATE2_DESCRIPTIONS = new BitDescription[] { new BitDescription(HistoryItem.STATE2_VIDEO_ON_FLAG, "video", "v"), + new BitDescription(HistoryItem.STATE2_LOW_POWER_FLAG, "low_power", "lp"), }; public static final String[] HISTORY_EVENT_NAMES = new String[] { - "null", "proc", "fg", "top", "sync" + "null", "proc", "fg", "top", "sync", "wake_lock_in" }; public static final String[] HISTORY_EVENT_CHECKIN_NAMES = new String[] { - "Enl", "Epr", "Efg", "Etp", "Esy" + "Enl", "Epr", "Efg", "Etp", "Esy", "Ewl" }; /** @@ -1630,11 +1656,12 @@ public abstract class BatteryStats implements Parcelable { final long totalUptime = computeUptime(rawUptime, which); final long screenOnTime = getScreenOnTime(rawRealtime, which); final long interactiveTime = getInteractiveTime(rawRealtime, which); + final long lowPowerModeEnabledTime = getLowPowerModeEnabledTime(rawRealtime, which); final long phoneOnTime = getPhoneOnTime(rawRealtime, which); final long wifiOnTime = getWifiOnTime(rawRealtime, which); final long wifiRunningTime = getGlobalWifiRunningTime(rawRealtime, which); final long bluetoothOnTime = getBluetoothOnTime(rawRealtime, which); - + StringBuilder sb = new StringBuilder(128); SparseArray<? extends Uid> uidStats = getUidStats(); @@ -1699,7 +1726,8 @@ public abstract class BatteryStats implements Parcelable { mobileRxTotalBytes, mobileTxTotalBytes, wifiRxTotalBytes, wifiTxTotalBytes, fullWakeLockTimeTotal, partialWakeLockTimeTotal, 0 /*legacy input event count*/, getMobileRadioActiveTime(rawRealtime, which), - getMobileRadioActiveAdjustedTime(which), interactiveTime / 1000); + getMobileRadioActiveAdjustedTime(which), interactiveTime / 1000, + lowPowerModeEnabledTime / 1000); // Dump screen brightness stats Object[] args = new Object[NUM_SCREEN_BRIGHTNESS_BINS]; @@ -2092,32 +2120,20 @@ public abstract class BatteryStats implements Parcelable { final long screenOnTime = getScreenOnTime(rawRealtime, which); final long interactiveTime = getInteractiveTime(rawRealtime, which); + final long lowPowerModeEnabledTime = getLowPowerModeEnabledTime(rawRealtime, which); final long phoneOnTime = getPhoneOnTime(rawRealtime, which); final long wifiRunningTime = getGlobalWifiRunningTime(rawRealtime, which); final long wifiOnTime = getWifiOnTime(rawRealtime, which); final long bluetoothOnTime = getBluetoothOnTime(rawRealtime, which); sb.setLength(0); sb.append(prefix); - sb.append(" Interactive: "); formatTimeMs(sb, interactiveTime / 1000); - sb.append("("); sb.append(formatRatioLocked(interactiveTime, whichBatteryRealtime)); - sb.append(")"); - pw.println(sb.toString()); - sb.setLength(0); - sb.append(prefix); sb.append(" Screen on: "); formatTimeMs(sb, screenOnTime / 1000); sb.append("("); sb.append(formatRatioLocked(screenOnTime, whichBatteryRealtime)); sb.append(") "); sb.append(getScreenOnCount(which)); - sb.append("x, Active phone call: "); formatTimeMs(sb, phoneOnTime / 1000); - sb.append("("); sb.append(formatRatioLocked(phoneOnTime, whichBatteryRealtime)); + sb.append("x, Interactive: "); formatTimeMs(sb, interactiveTime / 1000); + sb.append("("); sb.append(formatRatioLocked(interactiveTime, whichBatteryRealtime)); sb.append(")"); pw.println(sb.toString()); - if (phoneOnTime != 0) { - sb.setLength(0); - sb.append(prefix); - sb.append(" Active phone call: "); formatTimeMs(sb, phoneOnTime / 1000); - sb.append("("); sb.append(formatRatioLocked(phoneOnTime, whichBatteryRealtime)); - sb.append(") "); sb.append(getPhoneOnCount(which)); - } sb.setLength(0); sb.append(prefix); sb.append(" Screen brightnesses:"); @@ -2139,7 +2155,24 @@ public abstract class BatteryStats implements Parcelable { } if (!didOne) sb.append(" (no activity)"); pw.println(sb.toString()); - + if (lowPowerModeEnabledTime != 0) { + sb.setLength(0); + sb.append(prefix); + sb.append(" Low power mode enabled: "); + formatTimeMs(sb, lowPowerModeEnabledTime / 1000); + sb.append("("); + sb.append(formatRatioLocked(lowPowerModeEnabledTime, whichBatteryRealtime)); + sb.append(")"); + pw.println(sb.toString()); + } + if (phoneOnTime != 0) { + sb.setLength(0); + sb.append(prefix); + sb.append(" Active phone call: "); formatTimeMs(sb, phoneOnTime / 1000); + sb.append("("); sb.append(formatRatioLocked(phoneOnTime, whichBatteryRealtime)); + sb.append(") "); sb.append(getPhoneOnCount(which)); + } + // Calculate wakelock times across all uids. long fullWakeLockTimeTotalMicros = 0; long partialWakeLockTimeTotalMicros = 0; @@ -3004,6 +3037,8 @@ public abstract class BatteryStats implements Parcelable { pw.print(rec.numReadInts); pw.print(") "); } else { + pw.print(BATTERY_STATS_CHECKIN_VERSION); pw.print(','); + pw.print(HISTORY_DATA); pw.print(','); if (lastTime < 0) { pw.print(rec.time - baseTime); } else { @@ -3190,6 +3225,7 @@ public abstract class BatteryStats implements Parcelable { } pw.println(); oldState = rec.states; + oldState2 = rec.states2; } } } @@ -3266,21 +3302,25 @@ public abstract class BatteryStats implements Parcelable { if (rec.cmd == HistoryItem.CMD_CURRENT_TIME || rec.cmd == HistoryItem.CMD_RESET) { printed = true; + hprinter.printNextItem(pw, rec, baseTime, checkin, + (flags&DUMP_VERBOSE) != 0); + rec.cmd = HistoryItem.CMD_UPDATE; } else if (rec.currentTime != 0) { printed = true; byte cmd = rec.cmd; rec.cmd = HistoryItem.CMD_CURRENT_TIME; - if (checkin) { - pw.print(BATTERY_STATS_CHECKIN_VERSION); pw.print(','); - pw.print(HISTORY_DATA); pw.print(','); - } hprinter.printNextItem(pw, rec, baseTime, checkin, (flags&DUMP_VERBOSE) != 0); rec.cmd = cmd; } if (tracker != null) { - int oldCode = rec.eventCode; - HistoryTag oldTag = rec.eventTag; + if (rec.cmd != HistoryItem.CMD_UPDATE) { + hprinter.printNextItem(pw, rec, baseTime, checkin, + (flags&DUMP_VERBOSE) != 0); + rec.cmd = HistoryItem.CMD_UPDATE; + } + int oldEventCode = rec.eventCode; + HistoryTag oldEventTag = rec.eventTag; rec.eventTag = new HistoryTag(); for (int i=0; i<HistoryItem.EVENT_COUNT; i++) { HashMap<String, SparseIntArray> active @@ -3296,24 +3336,18 @@ public abstract class BatteryStats implements Parcelable { rec.eventTag.string = ent.getKey(); rec.eventTag.uid = uids.keyAt(j); rec.eventTag.poolIdx = uids.valueAt(j); - if (checkin) { - pw.print(BATTERY_STATS_CHECKIN_VERSION); pw.print(','); - pw.print(HISTORY_DATA); pw.print(','); - } hprinter.printNextItem(pw, rec, baseTime, checkin, (flags&DUMP_VERBOSE) != 0); + rec.wakeReasonTag = null; + rec.wakelockTag = null; } } } - rec.eventCode = oldCode; - rec.eventTag = oldTag; + rec.eventCode = oldEventCode; + rec.eventTag = oldEventTag; tracker = null; } } - if (checkin) { - pw.print(BATTERY_STATS_CHECKIN_VERSION); pw.print(','); - pw.print(HISTORY_DATA); pw.print(','); - } hprinter.printNextItem(pw, rec, baseTime, checkin, (flags&DUMP_VERBOSE) != 0); } else if (rec.eventCode != HistoryItem.EVENT_NONE) { diff --git a/core/java/android/os/PowerManagerInternal.java b/core/java/android/os/PowerManagerInternal.java index cb3d528..69b828f 100644 --- a/core/java/android/os/PowerManagerInternal.java +++ b/core/java/android/os/PowerManagerInternal.java @@ -55,6 +55,14 @@ public abstract class PowerManagerInternal { */ public abstract void setUserActivityTimeoutOverrideFromWindowManager(long timeoutMillis); + public abstract boolean getLowPowerModeEnabled(); + + public interface LowPowerModeListener { + public void onLowPowerModeChanged(boolean enabled); + } + + public abstract void registerLowPowerModeObserver(LowPowerModeListener listener); + // TODO: Remove this and retrieve as a local service instead. public abstract void setPolicy(WindowManagerPolicy policy); } diff --git a/core/java/com/android/internal/app/IBatteryStats.aidl b/core/java/com/android/internal/app/IBatteryStats.aidl index 04547495..0769b08 100644 --- a/core/java/com/android/internal/app/IBatteryStats.aidl +++ b/core/java/com/android/internal/app/IBatteryStats.aidl @@ -46,14 +46,15 @@ interface IBatteryStats { void noteStartWakelock(int uid, int pid, String name, String historyName, int type, boolean unimportantForLogging); - void noteStopWakelock(int uid, int pid, String name, int type); + void noteStopWakelock(int uid, int pid, String name, String historyName, int type); void noteStartWakelockFromSource(in WorkSource ws, int pid, String name, String historyName, int type, boolean unimportantForLogging); - void noteChangeWakelockFromSource(in WorkSource ws, int pid, String name, int type, - in WorkSource newWs, int newPid, String newName, + void noteChangeWakelockFromSource(in WorkSource ws, int pid, String name, String histyoryName, + int type, in WorkSource newWs, int newPid, String newName, String newHistoryName, int newType, boolean newUnimportantForLogging); - void noteStopWakelockFromSource(in WorkSource ws, int pid, String name, int type); + void noteStopWakelockFromSource(in WorkSource ws, int pid, String name, String historyName, + int type); void noteVibratorOn(int uid, long durationMillis); void noteVibratorOff(int uid); diff --git a/core/java/com/android/internal/os/BatteryStatsImpl.java b/core/java/com/android/internal/os/BatteryStatsImpl.java index 7bd5b12..956c86d 100644 --- a/core/java/com/android/internal/os/BatteryStatsImpl.java +++ b/core/java/com/android/internal/os/BatteryStatsImpl.java @@ -48,7 +48,6 @@ import android.util.PrintWriterPrinter; import android.util.Printer; import android.util.Slog; import android.util.SparseArray; -import android.util.SparseBooleanArray; import android.util.SparseIntArray; import android.util.TimeUtils; import android.view.Display; @@ -89,7 +88,7 @@ public final class BatteryStatsImpl extends BatteryStats { private static final int MAGIC = 0xBA757475; // 'BATSTATS' // Current on-disk Parcel version - private static final int VERSION = 105 + (USE_OLD_HISTORY ? 1000 : 0); + private static final int VERSION = 106 + (USE_OLD_HISTORY ? 1000 : 0); // Maximum number of items we will record in the history. private static final int MAX_HISTORY_ITEMS = 2000; @@ -236,6 +235,7 @@ public final class BatteryStatsImpl extends BatteryStats { int mWakeLockNesting; boolean mWakeLockImportant; + public boolean mRecordAllWakeLocks; int mScreenState = Display.STATE_UNKNOWN; StopwatchTimer mScreenOnTimer; @@ -246,6 +246,9 @@ public final class BatteryStatsImpl extends BatteryStats { boolean mInteractive; StopwatchTimer mInteractiveTimer; + boolean mLowPowerModeEnabled; + StopwatchTimer mLowPowerModeEnabledTimer; + boolean mPhoneOn; StopwatchTimer mPhoneOnTimer; @@ -2314,6 +2317,14 @@ public final class BatteryStatsImpl extends BatteryStats { private String mInitialAcquireWakeName; private int mInitialAcquireWakeUid = -1; + public void setRecordAllWakeLocksLocked(boolean enabled) { + mRecordAllWakeLocks = enabled; + if (!enabled) { + // Clear out any existing state. + mActiveEvents.removeEvents(HistoryItem.EVENT_WAKE_LOCK); + } + } + public void noteStartWakeLocked(int uid, int pid, String name, String historyName, int type, boolean unimportantForLogging, long elapsedRealtime, long uptime) { uid = mapUid(uid); @@ -2321,27 +2332,33 @@ public final class BatteryStatsImpl extends BatteryStats { // Only care about partial wake locks, since full wake locks // will be canceled when the user puts the screen to sleep. aggregateLastWakeupUptimeLocked(uptime); + historyName = historyName == null || mRecordAllWakeLocks ? name : historyName; if (mWakeLockNesting == 0) { mHistoryCur.states |= HistoryItem.STATE_WAKE_LOCK_FLAG; if (DEBUG_HISTORY) Slog.v(TAG, "Start wake lock to: " + Integer.toHexString(mHistoryCur.states)); mHistoryCur.wakelockTag = mHistoryCur.localWakelockTag; - mHistoryCur.wakelockTag.string = mInitialAcquireWakeName - = historyName != null ? historyName : name; + mHistoryCur.wakelockTag.string = mInitialAcquireWakeName = historyName; mHistoryCur.wakelockTag.uid = mInitialAcquireWakeUid = uid; mWakeLockImportant = !unimportantForLogging; addHistoryRecordLocked(elapsedRealtime, uptime); - } else if (!mWakeLockImportant && !unimportantForLogging) { + } else if (!mRecordAllWakeLocks && !mWakeLockImportant && !unimportantForLogging) { if (mHistoryLastWritten.wakelockTag != null) { // We'll try to update the last tag. mHistoryLastWritten.wakelockTag = null; mHistoryCur.wakelockTag = mHistoryCur.localWakelockTag; - mHistoryCur.wakelockTag.string = mInitialAcquireWakeName - = historyName != null ? historyName : name; + mHistoryCur.wakelockTag.string = mInitialAcquireWakeName = historyName; mHistoryCur.wakelockTag.uid = mInitialAcquireWakeUid = uid; addHistoryRecordLocked(elapsedRealtime, uptime); } mWakeLockImportant = true; + } else if (mRecordAllWakeLocks) { + if (mActiveEvents.updateState(HistoryItem.EVENT_WAKE_LOCK_START, historyName, + uid, 0)) { + return; + } + addHistoryEventLocked(elapsedRealtime, uptime, HistoryItem.EVENT_WAKE_LOCK_START, + historyName, uid); } mWakeLockNesting++; } @@ -2354,24 +2371,33 @@ public final class BatteryStatsImpl extends BatteryStats { } } - public void noteStopWakeLocked(int uid, int pid, String name, int type, long elapsedRealtime, - long uptime) { + public void noteStopWakeLocked(int uid, int pid, String name, String historyName, int type, + long elapsedRealtime, long uptime) { uid = mapUid(uid); if (type == WAKE_TYPE_PARTIAL) { mWakeLockNesting--; + historyName = historyName == null || mRecordAllWakeLocks ? name : historyName; if (mWakeLockNesting == 0) { mHistoryCur.states &= ~HistoryItem.STATE_WAKE_LOCK_FLAG; if (DEBUG_HISTORY) Slog.v(TAG, "Stop wake lock to: " + Integer.toHexString(mHistoryCur.states)); - if ((name != null && !name.equals(mInitialAcquireWakeName)) + if (mRecordAllWakeLocks + || (historyName != null && !historyName.equals(mInitialAcquireWakeName)) || uid != mInitialAcquireWakeUid) { mHistoryCur.wakelockTag = mHistoryCur.localWakelockTag; - mHistoryCur.wakelockTag.string = name; + mHistoryCur.wakelockTag.string = historyName; mHistoryCur.wakelockTag.uid = uid; } mInitialAcquireWakeName = null; mInitialAcquireWakeUid = -1; addHistoryRecordLocked(elapsedRealtime, uptime); + } else if (mRecordAllWakeLocks) { + if (mActiveEvents.updateState(HistoryItem.EVENT_WAKE_LOCK_FINISH, historyName, + uid, 0)) { + return; + } + addHistoryEventLocked(elapsedRealtime, uptime, HistoryItem.EVENT_WAKE_LOCK_FINISH, + historyName, uid); } } if (uid >= 0) { @@ -2391,8 +2417,8 @@ public final class BatteryStatsImpl extends BatteryStats { } } - public void noteChangeWakelockFromSourceLocked(WorkSource ws, int pid, String name, int type, - WorkSource newWs, int newPid, String newName, + public void noteChangeWakelockFromSourceLocked(WorkSource ws, int pid, String name, + String historyName, int type, WorkSource newWs, int newPid, String newName, String newHistoryName, int newType, boolean newUnimportantForLogging) { final long elapsedRealtime = SystemClock.elapsedRealtime(); final long uptime = SystemClock.uptimeMillis(); @@ -2406,16 +2432,17 @@ public final class BatteryStatsImpl extends BatteryStats { } final int NO = ws.size(); for (int i=0; i<NO; i++) { - noteStopWakeLocked(ws.get(i), pid, name, type, elapsedRealtime, uptime); + noteStopWakeLocked(ws.get(i), pid, name, historyName, type, elapsedRealtime, uptime); } } - public void noteStopWakeFromSourceLocked(WorkSource ws, int pid, String name, int type) { + public void noteStopWakeFromSourceLocked(WorkSource ws, int pid, String name, + String historyName, int type) { final long elapsedRealtime = SystemClock.elapsedRealtime(); final long uptime = SystemClock.uptimeMillis(); final int N = ws.size(); for (int i=0; i<N; i++) { - noteStopWakeLocked(ws.get(i), pid, name, type, elapsedRealtime, uptime); + noteStopWakeLocked(ws.get(i), pid, name, historyName, type, elapsedRealtime, uptime); } } @@ -2684,7 +2711,7 @@ public final class BatteryStatsImpl extends BatteryStats { mScreenBrightnessTimer[mScreenBrightnessBin].stopRunningLocked(elapsedRealtime); } - noteStopWakeLocked(-1, -1, "screen", WAKE_TYPE_PARTIAL, + noteStopWakeLocked(-1, -1, "screen", "screen", WAKE_TYPE_PARTIAL, elapsedRealtime, uptime); updateTimeBasesLocked(mOnBatteryTimeBase.isRunning(), true, @@ -2780,6 +2807,26 @@ public final class BatteryStatsImpl extends BatteryStats { } } + public void noteLowPowerMode(boolean enabled) { + if (mLowPowerModeEnabled != enabled) { + final long elapsedRealtime = SystemClock.elapsedRealtime(); + final long uptime = SystemClock.uptimeMillis(); + mLowPowerModeEnabled = enabled; + if (enabled) { + mHistoryCur.states2 |= HistoryItem.STATE2_LOW_POWER_FLAG; + if (DEBUG_HISTORY) Slog.v(TAG, "Low power mode enabled to: " + + Integer.toHexString(mHistoryCur.states2)); + mLowPowerModeEnabledTimer.startRunningLocked(elapsedRealtime); + } else { + mHistoryCur.states2 &= ~HistoryItem.STATE2_LOW_POWER_FLAG; + if (DEBUG_HISTORY) Slog.v(TAG, "Low power mode disabled to: " + + Integer.toHexString(mHistoryCur.states2)); + mLowPowerModeEnabledTimer.stopRunningLocked(elapsedRealtime); + } + addHistoryRecordLocked(elapsedRealtime, uptime); + } + } + public void notePhoneOnLocked() { if (!mPhoneOn) { final long elapsedRealtime = SystemClock.elapsedRealtime(); @@ -3443,6 +3490,14 @@ public final class BatteryStatsImpl extends BatteryStats { return mInteractiveTimer.getTotalTimeLocked(elapsedRealtimeUs, which); } + @Override public long getLowPowerModeEnabledTime(long elapsedRealtimeUs, int which) { + return mLowPowerModeEnabledTimer.getTotalTimeLocked(elapsedRealtimeUs, which); + } + + @Override public int getLowPowerModeEnabledCount(int which) { + return mLowPowerModeEnabledTimer.getCountLocked(which); + } + @Override public long getPhoneOnTime(long elapsedRealtimeUs, int which) { return mPhoneOnTimer.getTotalTimeLocked(elapsedRealtimeUs, which); } @@ -5489,7 +5544,8 @@ public final class BatteryStatsImpl extends BatteryStats { for (int i=0; i<NUM_SCREEN_BRIGHTNESS_BINS; i++) { mScreenBrightnessTimer[i] = new StopwatchTimer(null, -100-i, null, mOnBatteryTimeBase); } - mPhoneOnTimer = new StopwatchTimer(null, -2, null, mOnBatteryTimeBase); + mLowPowerModeEnabledTimer = new StopwatchTimer(null, -2, null, mOnBatteryTimeBase); + mPhoneOnTimer = new StopwatchTimer(null, -3, null, mOnBatteryTimeBase); for (int i=0; i<SignalStrength.NUM_SIGNAL_STRENGTH_BINS; i++) { mPhoneSignalStrengthsTimer[i] = new StopwatchTimer(null, -200-i, null, mOnBatteryTimeBase); @@ -5508,18 +5564,18 @@ public final class BatteryStatsImpl extends BatteryStats { mMobileRadioActiveAdjustedTime = new LongSamplingCounter(mOnBatteryTimeBase); mMobileRadioActiveUnknownTime = new LongSamplingCounter(mOnBatteryTimeBase); mMobileRadioActiveUnknownCount = new LongSamplingCounter(mOnBatteryTimeBase); - mWifiOnTimer = new StopwatchTimer(null, -3, null, mOnBatteryTimeBase); - mGlobalWifiRunningTimer = new StopwatchTimer(null, -4, null, mOnBatteryTimeBase); + mWifiOnTimer = new StopwatchTimer(null, -4, null, mOnBatteryTimeBase); + mGlobalWifiRunningTimer = new StopwatchTimer(null, -5, null, mOnBatteryTimeBase); for (int i=0; i<NUM_WIFI_STATES; i++) { mWifiStateTimer[i] = new StopwatchTimer(null, -600-i, null, mOnBatteryTimeBase); } - mBluetoothOnTimer = new StopwatchTimer(null, -5, null, mOnBatteryTimeBase); + mBluetoothOnTimer = new StopwatchTimer(null, -6, null, mOnBatteryTimeBase); for (int i=0; i< NUM_BLUETOOTH_STATES; i++) { mBluetoothStateTimer[i] = new StopwatchTimer(null, -500-i, null, mOnBatteryTimeBase); } - mAudioOnTimer = new StopwatchTimer(null, -6, null, mOnBatteryTimeBase); - mVideoOnTimer = new StopwatchTimer(null, -7, null, mOnBatteryTimeBase); - mInteractiveTimer = new StopwatchTimer(null, -8, null, mOnBatteryTimeBase); + mAudioOnTimer = new StopwatchTimer(null, -7, null, mOnBatteryTimeBase); + mVideoOnTimer = new StopwatchTimer(null, -8, null, mOnBatteryTimeBase); + mInteractiveTimer = new StopwatchTimer(null, -9, null, mOnBatteryTimeBase); mOnBattery = mOnBatteryInternal = false; long uptime = SystemClock.uptimeMillis() * 1000; long realtime = SystemClock.elapsedRealtime() * 1000; @@ -5765,6 +5821,7 @@ public final class BatteryStatsImpl extends BatteryStats { mScreenBrightnessTimer[i].reset(false); } mInteractiveTimer.reset(false); + mLowPowerModeEnabledTimer.reset(false); mPhoneOnTimer.reset(false); mAudioOnTimer.reset(false); mVideoOnTimer.reset(false); @@ -6915,6 +6972,7 @@ public final class BatteryStatsImpl extends BatteryStats { mInteractive = false; mInteractiveTimer.readSummaryFromParcelLocked(in); mPhoneOn = false; + mLowPowerModeEnabledTimer.readSummaryFromParcelLocked(in); mPhoneOnTimer.readSummaryFromParcelLocked(in); for (int i=0; i<SignalStrength.NUM_SIGNAL_STRENGTH_BINS; i++) { mPhoneSignalStrengthsTimer[i].readSummaryFromParcelLocked(in); @@ -7169,6 +7227,7 @@ public final class BatteryStatsImpl extends BatteryStats { mScreenBrightnessTimer[i].writeSummaryFromParcelLocked(out, NOWREAL_SYS); } mInteractiveTimer.writeSummaryFromParcelLocked(out, NOWREAL_SYS); + mLowPowerModeEnabledTimer.writeSummaryFromParcelLocked(out, NOWREAL_SYS); mPhoneOnTimer.writeSummaryFromParcelLocked(out, NOWREAL_SYS); for (int i=0; i<SignalStrength.NUM_SIGNAL_STRENGTH_BINS; i++) { mPhoneSignalStrengthsTimer[i].writeSummaryFromParcelLocked(out, NOWREAL_SYS); @@ -7431,7 +7490,8 @@ public final class BatteryStatsImpl extends BatteryStats { in); } mPhoneOn = false; - mPhoneOnTimer = new StopwatchTimer(null, -2, null, mOnBatteryTimeBase, in); + mLowPowerModeEnabledTimer = new StopwatchTimer(null, -2, null, mOnBatteryTimeBase, in); + mPhoneOnTimer = new StopwatchTimer(null, -3, null, mOnBatteryTimeBase, in); for (int i=0; i<SignalStrength.NUM_SIGNAL_STRENGTH_BINS; i++) { mPhoneSignalStrengthsTimer[i] = new StopwatchTimer(null, -200-i, null, mOnBatteryTimeBase, in); @@ -7453,25 +7513,25 @@ public final class BatteryStatsImpl extends BatteryStats { mMobileRadioActiveUnknownTime = new LongSamplingCounter(mOnBatteryTimeBase, in); mMobileRadioActiveUnknownCount = new LongSamplingCounter(mOnBatteryTimeBase, in); mWifiOn = false; - mWifiOnTimer = new StopwatchTimer(null, -3, null, mOnBatteryTimeBase, in); + mWifiOnTimer = new StopwatchTimer(null, -4, null, mOnBatteryTimeBase, in); mGlobalWifiRunning = false; - mGlobalWifiRunningTimer = new StopwatchTimer(null, -4, null, mOnBatteryTimeBase, in); + mGlobalWifiRunningTimer = new StopwatchTimer(null, -5, null, mOnBatteryTimeBase, in); for (int i=0; i<NUM_WIFI_STATES; i++) { mWifiStateTimer[i] = new StopwatchTimer(null, -600-i, null, mOnBatteryTimeBase, in); } mBluetoothOn = false; - mBluetoothOnTimer = new StopwatchTimer(null, -5, null, mOnBatteryTimeBase, in); + mBluetoothOnTimer = new StopwatchTimer(null, -6, null, mOnBatteryTimeBase, in); for (int i=0; i< NUM_BLUETOOTH_STATES; i++) { mBluetoothStateTimer[i] = new StopwatchTimer(null, -500-i, null, mOnBatteryTimeBase, in); } mAudioOn = false; - mAudioOnTimer = new StopwatchTimer(null, -6, null, mOnBatteryTimeBase); + mAudioOnTimer = new StopwatchTimer(null, -7, null, mOnBatteryTimeBase); mVideoOn = false; - mVideoOnTimer = new StopwatchTimer(null, -7, null, mOnBatteryTimeBase); + mVideoOnTimer = new StopwatchTimer(null, -8, null, mOnBatteryTimeBase); mInteractive = false; - mInteractiveTimer = new StopwatchTimer(null, -8, null, mOnBatteryTimeBase, in); + mInteractiveTimer = new StopwatchTimer(null, -9, null, mOnBatteryTimeBase, in); mDischargeUnplugLevel = in.readInt(); mDischargePlugLevel = in.readInt(); mDischargeCurrentLevel = in.readInt(); @@ -7570,6 +7630,7 @@ public final class BatteryStatsImpl extends BatteryStats { mScreenBrightnessTimer[i].writeToParcel(out, uSecRealtime); } mInteractiveTimer.writeToParcel(out, uSecRealtime); + mLowPowerModeEnabledTimer.writeToParcel(out, uSecRealtime); mPhoneOnTimer.writeToParcel(out, uSecRealtime); for (int i=0; i<SignalStrength.NUM_SIGNAL_STRENGTH_BINS; i++) { mPhoneSignalStrengthsTimer[i].writeToParcel(out, uSecRealtime); @@ -7688,6 +7749,8 @@ public final class BatteryStatsImpl extends BatteryStats { } pr.println("*** Interactive timer:"); mInteractiveTimer.logState(pr, " "); + pr.println("*** Low power mode timer:"); + mLowPowerModeEnabledTimer.logState(pr, " "); pr.println("*** Phone timer:"); mPhoneOnTimer.logState(pr, " "); for (int i=0; i<SignalStrength.NUM_SIGNAL_STRENGTH_BINS; i++) { diff --git a/core/jni/android_util_Binder.cpp b/core/jni/android_util_Binder.cpp index 662af89..d82fc96 100644 --- a/core/jni/android_util_Binder.cpp +++ b/core/jni/android_util_Binder.cpp @@ -697,6 +697,38 @@ void signalExceptionForError(JNIEnv* env, jobject obj, status_t err, jniThrowException(env, "java/lang/RuntimeException", "Not allowed to write file descriptors here"); break; + case -EBADF: + jniThrowException(env, "java/lang/RuntimeException", + "Bad file descriptor"); + break; + case -ENFILE: + jniThrowException(env, "java/lang/RuntimeException", + "File table overflow"); + break; + case -EMFILE: + jniThrowException(env, "java/lang/RuntimeException", + "Too many open files"); + break; + case -EFBIG: + jniThrowException(env, "java/lang/RuntimeException", + "File too large"); + break; + case -ENOSPC: + jniThrowException(env, "java/lang/RuntimeException", + "No space left on device"); + break; + case -ESPIPE: + jniThrowException(env, "java/lang/RuntimeException", + "Illegal seek"); + break; + case -EROFS: + jniThrowException(env, "java/lang/RuntimeException", + "Read-only file system"); + break; + case -EMLINK: + jniThrowException(env, "java/lang/RuntimeException", + "Too many links"); + break; default: ALOGE("Unknown binder error code. 0x%" PRIx32, err); String8 msg; |