Initial implementation of light-weight idle mode.
This mode turns on after the screen has been off for 15 minutes,
and then cycles through 15 minutes of idle and 1 minute of
maintenance, ragardless of whether the device is moving around.
It currently only impacts network access and sync/job scheduling.
It does not remove access to wake locks or alarms for any apps.
It also doesn't report in the public API that the device is in
idle mode (since it isn't modifying the behavior of the power
manager) -- this is probably what we desire, since we don't want
stuff like GCM to be reporting these frequent changes.
We'll probably at least want to have the alarm manager do some
kind of more aggressive batching of alarms in this most (not allowing
more than one wakeup every minute?). That's for the future.
Also updated batterystats to include this new information, which
means the format of some of the data has changed -- device_idle
is no longer a flag, but an enum of (off, light, full), and there
is no information about time spent in light modes.
Also added new data about the maximum duration spent in both light
and full idle modes, to get a better understanding of how those
are behaving.
And did a little cleanup of DeviceIdleController, removing the
sensing alarm which was redundant with the regular alarm.
Change-Id: Ibeea6659577dc02deff58f048f97fcd9b0223307
diff --git a/core/java/android/os/BatteryStats.java b/core/java/android/os/BatteryStats.java
index 8e86a53..1aa5c66 100644
--- a/core/java/android/os/BatteryStats.java
+++ b/core/java/android/os/BatteryStats.java
@@ -169,7 +169,7 @@
/**
* Current version of checkin data format.
*/
- static final String CHECKIN_VERSION = "15";
+ static final String CHECKIN_VERSION = "16";
/**
* Old version, we hit 9 and ran out of room, need to remove.
@@ -468,8 +468,8 @@
* @param cluster the index of the CPU cluster.
* @param step the index of the CPU speed. This is not the actual speed of the CPU.
* @param which one of STATS_SINCE_CHARGED, STATS_SINCE_UNPLUGGED, or STATS_CURRENT.
- * @see PowerProfile.getNumCpuClusters()
- * @see PowerProfile.getNumSpeedStepsInCpuCluster(int)
+ * @see com.android.internal.os.PowerProfile#getNumCpuClusters()
+ * @see com.android.internal.os.PowerProfile#getNumSpeedStepsInCpuCluster(int)
*/
public abstract long getTimeAtCpuSpeed(int cluster, int step, int which);
@@ -1135,14 +1135,15 @@
public static final int STATE2_WIFI_RUNNING_FLAG = 1<<29;
public static final int STATE2_WIFI_ON_FLAG = 1<<28;
public static final int STATE2_FLASHLIGHT_FLAG = 1<<27;
- public static final int STATE2_DEVICE_IDLE_FLAG = 1<<26;
- public static final int STATE2_CHARGING_FLAG = 1<<25;
- public static final int STATE2_PHONE_IN_CALL_FLAG = 1<<24;
- public static final int STATE2_BLUETOOTH_ON_FLAG = 1<<23;
- public static final int STATE2_CAMERA_FLAG = 1<<22;
+ public static final int STATE2_DEVICE_IDLE_SHIFT = 25;
+ public static final int STATE2_DEVICE_IDLE_MASK = 0x3 << STATE2_DEVICE_IDLE_SHIFT;
+ public static final int STATE2_CHARGING_FLAG = 1<<24;
+ public static final int STATE2_PHONE_IN_CALL_FLAG = 1<<23;
+ public static final int STATE2_BLUETOOTH_ON_FLAG = 1<<22;
+ public static final int STATE2_CAMERA_FLAG = 1<<21;
public static final int MOST_INTERESTING_STATES2 =
- STATE2_POWER_SAVE_FLAG | STATE2_WIFI_ON_FLAG | STATE2_DEVICE_IDLE_FLAG
+ STATE2_POWER_SAVE_FLAG | STATE2_WIFI_ON_FLAG | STATE2_DEVICE_IDLE_MASK
| STATE2_CHARGING_FLAG | STATE2_PHONE_IN_CALL_FLAG | STATE2_BLUETOOTH_ON_FLAG;
public static final int SETTLE_TO_ZERO_STATES2 = 0xffff0000 & ~MOST_INTERESTING_STATES2;
@@ -1620,36 +1621,57 @@
public abstract int getPowerSaveModeEnabledCount(int which);
/**
+ * Constant for device idle mode: not active.
+ */
+ public static final int DEVICE_IDLE_MODE_OFF = 0;
+
+ /**
+ * Constant for device idle mode: active in lightweight mode.
+ */
+ public static final int DEVICE_IDLE_MODE_LIGHT = 1;
+
+ /**
+ * Constant for device idle mode: active in full mode.
+ */
+ public static final int DEVICE_IDLE_MODE_FULL = 2;
+
+ /**
* Returns the time in microseconds that device has been in idle mode while
* running on battery.
*
* {@hide}
*/
- public abstract long getDeviceIdleModeEnabledTime(long elapsedRealtimeUs, int which);
+ public abstract long getDeviceIdleModeTime(int mode, long elapsedRealtimeUs, int which);
/**
* Returns the number of times that the devie has gone in to idle mode.
*
* {@hide}
*/
- public abstract int getDeviceIdleModeEnabledCount(int which);
+ public abstract int getDeviceIdleModeCount(int mode, int which);
+
+ /**
+ * Return the longest duration we spent in a particular device idle mode (fully in the
+ * mode, not in idle maintenance etc).
+ */
+ public abstract long getLongestDeviceIdleModeTime(int mode);
/**
* Returns the time in microseconds that device has been in idling while on
- * battery. This is broader than {@link #getDeviceIdleModeEnabledTime} -- it
+ * battery. This is broader than {@link #getDeviceIdleModeTime} -- it
* counts all of the time that we consider the device to be idle, whether or not
* it is currently in the actual device idle mode.
*
* {@hide}
*/
- public abstract long getDeviceIdlingTime(long elapsedRealtimeUs, int which);
+ public abstract long getDeviceIdlingTime(int mode, long elapsedRealtimeUs, int which);
/**
* Returns the number of times that the devie has started idling.
*
* {@hide}
*/
- public abstract int getDeviceIdlingCount(int which);
+ public abstract int getDeviceIdlingCount(int mode, int which);
/**
* Returns the number of times that connectivity state changed.
@@ -1847,7 +1869,10 @@
new BitDescription(HistoryItem.STATE2_WIFI_RUNNING_FLAG, "wifi_running", "Ww"),
new BitDescription(HistoryItem.STATE2_WIFI_ON_FLAG, "wifi", "W"),
new BitDescription(HistoryItem.STATE2_FLASHLIGHT_FLAG, "flashlight", "fl"),
- new BitDescription(HistoryItem.STATE2_DEVICE_IDLE_FLAG, "device_idle", "di"),
+ new BitDescription(HistoryItem.STATE2_DEVICE_IDLE_MASK,
+ HistoryItem.STATE2_DEVICE_IDLE_SHIFT, "device_idle", "di",
+ new String[] { "off", "light", "full", "???" },
+ new String[] { "off", "light", "full", "???" }),
new BitDescription(HistoryItem.STATE2_CHARGING_FLAG, "charging", "ch"),
new BitDescription(HistoryItem.STATE2_PHONE_IN_CALL_FLAG, "phone_in_call", "Pcl"),
new BitDescription(HistoryItem.STATE2_BLUETOOTH_ON_FLAG, "bluetooth", "b"),
@@ -2529,8 +2554,14 @@
final long screenOnTime = getScreenOnTime(rawRealtime, which);
final long interactiveTime = getInteractiveTime(rawRealtime, which);
final long powerSaveModeEnabledTime = getPowerSaveModeEnabledTime(rawRealtime, which);
- final long deviceIdleModeEnabledTime = getDeviceIdleModeEnabledTime(rawRealtime, which);
- final long deviceIdlingTime = getDeviceIdlingTime(rawRealtime, which);
+ final long deviceIdleModeLightTime = getDeviceIdleModeTime(DEVICE_IDLE_MODE_LIGHT,
+ rawRealtime, which);
+ final long deviceIdleModeFullTime = getDeviceIdleModeTime(DEVICE_IDLE_MODE_FULL,
+ rawRealtime, which);
+ final long deviceLightIdlingTime = getDeviceIdlingTime(DEVICE_IDLE_MODE_LIGHT,
+ rawRealtime, which);
+ final long deviceIdlingTime = getDeviceIdlingTime(DEVICE_IDLE_MODE_FULL,
+ rawRealtime, which);
final int connChanges = getNumConnectivityChange(which);
final long phoneOnTime = getPhoneOnTime(rawRealtime, which);
@@ -2613,11 +2644,15 @@
fullWakeLockTimeTotal / 1000, partialWakeLockTimeTotal / 1000,
getMobileRadioActiveTime(rawRealtime, which) / 1000,
getMobileRadioActiveAdjustedTime(which) / 1000, interactiveTime / 1000,
- powerSaveModeEnabledTime / 1000, connChanges, deviceIdleModeEnabledTime / 1000,
- getDeviceIdleModeEnabledCount(which), deviceIdlingTime / 1000,
- getDeviceIdlingCount(which),
+ powerSaveModeEnabledTime / 1000, connChanges, deviceIdleModeFullTime / 1000,
+ getDeviceIdleModeCount(DEVICE_IDLE_MODE_FULL, which), deviceIdlingTime / 1000,
+ getDeviceIdlingCount(DEVICE_IDLE_MODE_FULL, which),
getMobileRadioActiveCount(which),
- getMobileRadioActiveUnknownTime(which) / 1000);
+ getMobileRadioActiveUnknownTime(which) / 1000, deviceIdleModeLightTime / 1000,
+ getDeviceIdleModeCount(DEVICE_IDLE_MODE_LIGHT, which), deviceLightIdlingTime / 1000,
+ getDeviceIdlingCount(DEVICE_IDLE_MODE_LIGHT, which),
+ getLongestDeviceIdleModeTime(DEVICE_IDLE_MODE_LIGHT),
+ getLongestDeviceIdleModeTime(DEVICE_IDLE_MODE_FULL));
// Dump screen brightness stats
Object[] args = new Object[NUM_SCREEN_BRIGHTNESS_BINS];
@@ -3082,8 +3117,14 @@
final long screenOnTime = getScreenOnTime(rawRealtime, which);
final long interactiveTime = getInteractiveTime(rawRealtime, which);
final long powerSaveModeEnabledTime = getPowerSaveModeEnabledTime(rawRealtime, which);
- final long deviceIdleModeEnabledTime = getDeviceIdleModeEnabledTime(rawRealtime, which);
- final long deviceIdlingTime = getDeviceIdlingTime(rawRealtime, which);
+ final long deviceIdleModeLightTime = getDeviceIdleModeTime(DEVICE_IDLE_MODE_LIGHT,
+ rawRealtime, which);
+ final long deviceIdleModeFullTime = getDeviceIdleModeTime(DEVICE_IDLE_MODE_FULL,
+ rawRealtime, which);
+ final long deviceLightIdlingTime = getDeviceIdlingTime(DEVICE_IDLE_MODE_LIGHT,
+ rawRealtime, which);
+ final long deviceIdlingTime = getDeviceIdlingTime(DEVICE_IDLE_MODE_FULL,
+ rawRealtime, which);
final long phoneOnTime = getPhoneOnTime(rawRealtime, which);
final long wifiRunningTime = getGlobalWifiRunningTime(rawRealtime, which);
final long wifiOnTime = getWifiOnTime(rawRealtime, which);
@@ -3127,26 +3168,54 @@
sb.append(")");
pw.println(sb.toString());
}
- if (deviceIdlingTime != 0) {
+ if (deviceLightIdlingTime != 0) {
sb.setLength(0);
sb.append(prefix);
- sb.append(" Device idling: ");
- formatTimeMs(sb, deviceIdlingTime / 1000);
+ sb.append(" Device light idling: ");
+ formatTimeMs(sb, deviceLightIdlingTime / 1000);
sb.append("(");
- sb.append(formatRatioLocked(deviceIdlingTime, whichBatteryRealtime));
- sb.append(") "); sb.append(getDeviceIdlingCount(which));
+ sb.append(formatRatioLocked(deviceLightIdlingTime, whichBatteryRealtime));
+ sb.append(") "); sb.append(getDeviceIdlingCount(DEVICE_IDLE_MODE_LIGHT, which));
sb.append("x");
pw.println(sb.toString());
}
- if (deviceIdleModeEnabledTime != 0) {
+ if (deviceIdleModeLightTime != 0) {
sb.setLength(0);
sb.append(prefix);
- sb.append(" Idle mode time: ");
- formatTimeMs(sb, deviceIdleModeEnabledTime / 1000);
+ sb.append(" Idle mode light time: ");
+ formatTimeMs(sb, deviceIdleModeLightTime / 1000);
sb.append("(");
- sb.append(formatRatioLocked(deviceIdleModeEnabledTime, whichBatteryRealtime));
- sb.append(") "); sb.append(getDeviceIdleModeEnabledCount(which));
+ sb.append(formatRatioLocked(deviceIdleModeLightTime, whichBatteryRealtime));
+ sb.append(") ");
+ sb.append(getDeviceIdleModeCount(DEVICE_IDLE_MODE_LIGHT, which));
sb.append("x");
+ sb.append(" -- longest ");
+ formatTimeMs(sb, getLongestDeviceIdleModeTime(DEVICE_IDLE_MODE_LIGHT));
+ pw.println(sb.toString());
+ }
+ if (deviceIdlingTime != 0) {
+ sb.setLength(0);
+ sb.append(prefix);
+ sb.append(" Device full idling: ");
+ formatTimeMs(sb, deviceIdlingTime / 1000);
+ sb.append("(");
+ sb.append(formatRatioLocked(deviceIdlingTime, whichBatteryRealtime));
+ sb.append(") "); sb.append(getDeviceIdlingCount(DEVICE_IDLE_MODE_FULL, which));
+ sb.append("x");
+ pw.println(sb.toString());
+ }
+ if (deviceIdleModeFullTime != 0) {
+ sb.setLength(0);
+ sb.append(prefix);
+ sb.append(" Idle mode full time: ");
+ formatTimeMs(sb, deviceIdleModeFullTime / 1000);
+ sb.append("(");
+ sb.append(formatRatioLocked(deviceIdleModeFullTime, whichBatteryRealtime));
+ sb.append(") ");
+ sb.append(getDeviceIdleModeCount(DEVICE_IDLE_MODE_FULL, which));
+ sb.append("x");
+ sb.append(" -- longest ");
+ formatTimeMs(sb, getLongestDeviceIdleModeTime(DEVICE_IDLE_MODE_FULL));
pw.println(sb.toString());
}
if (phoneOnTime != 0) {
diff --git a/core/java/android/os/IPowerManager.aidl b/core/java/android/os/IPowerManager.aidl
index 9fdbec3..dd10df3 100644
--- a/core/java/android/os/IPowerManager.aidl
+++ b/core/java/android/os/IPowerManager.aidl
@@ -47,6 +47,7 @@
boolean isPowerSaveMode();
boolean setPowerSaveMode(boolean mode);
boolean isDeviceIdleMode();
+ boolean isLightDeviceIdleMode();
void reboot(boolean confirm, String reason, boolean wait);
void shutdown(boolean confirm, String reason, boolean wait);
diff --git a/core/java/android/os/PowerManager.java b/core/java/android/os/PowerManager.java
index 69974fa..1cffa832 100644
--- a/core/java/android/os/PowerManager.java
+++ b/core/java/android/os/PowerManager.java
@@ -910,6 +910,26 @@
}
/**
+ * Returns true if the device is currently in light idle mode. This happens when a device
+ * has had its screen off for a short time, switching it into a batching mode where we
+ * execute jobs, syncs, networking on a batching schedule. You can monitor for changes to
+ * this state with {@link #ACTION_LIGHT_DEVICE_IDLE_MODE_CHANGED}.
+ *
+ * @return Returns true if currently in active light device idle mode, else false. This is
+ * when light idle mode restrictions are being actively applied; it will return false if the
+ * device is in a long-term idle mode but currently running a maintenance window where
+ * restrictions have been lifted.
+ * @hide
+ */
+ public boolean isLightDeviceIdleMode() {
+ try {
+ return mService.isLightDeviceIdleMode();
+ } catch (RemoteException e) {
+ return false;
+ }
+ }
+
+ /**
* Return whether the given application package name is on the device's power whitelist.
* Apps can be placed on the whitelist through the settings UI invoked by
* {@link android.provider.Settings#ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS}.
@@ -961,6 +981,15 @@
= "android.os.action.DEVICE_IDLE_MODE_CHANGED";
/**
+ * Intent that is broadcast when the state of {@link #isLightDeviceIdleMode()} changes.
+ * This broadcast is only sent to registered receivers.
+ * @hide
+ */
+ @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION)
+ public static final String ACTION_LIGHT_DEVICE_IDLE_MODE_CHANGED
+ = "android.os.action.LIGHT_DEVICE_IDLE_MODE_CHANGED";
+
+ /**
* @hide Intent that is broadcast when the set of power save whitelist apps has changed.
* This broadcast is only sent to registered receivers.
*/
diff --git a/core/java/android/os/PowerManagerInternal.java b/core/java/android/os/PowerManagerInternal.java
index b6d0fcb..9801e1b 100644
--- a/core/java/android/os/PowerManagerInternal.java
+++ b/core/java/android/os/PowerManagerInternal.java
@@ -148,7 +148,9 @@
public void onLowPowerModeChanged(boolean enabled);
}
- public abstract void setDeviceIdleMode(boolean enabled);
+ public abstract boolean setDeviceIdleMode(boolean enabled);
+
+ public abstract boolean setLightDeviceIdleMode(boolean enabled);
public abstract void setDeviceIdleWhitelist(int[] appids);
diff --git a/core/java/com/android/internal/app/IBatteryStats.aidl b/core/java/com/android/internal/app/IBatteryStats.aidl
index 3cddbf6..3b9b8db 100644
--- a/core/java/com/android/internal/app/IBatteryStats.aidl
+++ b/core/java/com/android/internal/app/IBatteryStats.aidl
@@ -117,7 +117,7 @@
void noteWifiRadioPowerState(int powerState, long timestampNs);
void noteNetworkInterfaceType(String iface, int type);
void noteNetworkStatsEnabled();
- void noteDeviceIdleMode(boolean enabled, String activeReason, int activeUid);
+ void noteDeviceIdleMode(int mode, String activeReason, int activeUid);
void setBatteryState(int status, int health, int plugType, int level, int temp, int volt);
long getAwakeTimeBattery();
long getAwakeTimePlugged();
diff --git a/core/java/com/android/internal/os/BatteryStatsImpl.java b/core/java/com/android/internal/os/BatteryStatsImpl.java
index 64b7768..f73df00 100644
--- a/core/java/com/android/internal/os/BatteryStatsImpl.java
+++ b/core/java/com/android/internal/os/BatteryStatsImpl.java
@@ -105,7 +105,7 @@
private static final int MAGIC = 0xBA757475; // 'BATSTATS'
// Current on-disk Parcel version
- private static final int VERSION = 132 + (USE_OLD_HISTORY ? 1000 : 0);
+ private static final int VERSION = 135 + (USE_OLD_HISTORY ? 1000 : 0);
// Maximum number of items we will record in the history.
private static final int MAX_HISTORY_ITEMS = 2000;
@@ -338,8 +338,15 @@
boolean mDeviceIdling;
StopwatchTimer mDeviceIdlingTimer;
- boolean mDeviceIdleModeEnabled;
- StopwatchTimer mDeviceIdleModeEnabledTimer;
+ boolean mDeviceLightIdling;
+ StopwatchTimer mDeviceLightIdlingTimer;
+
+ int mDeviceIdleMode;
+ long mLastIdleTimeStart;
+ long mLongestLightIdleTime;
+ long mLongestFullIdleTime;
+ StopwatchTimer mDeviceIdleModeLightTimer;
+ StopwatchTimer mDeviceIdleModeFullTimer;
boolean mPhoneOn;
StopwatchTimer mPhoneOnTimer;
@@ -3219,42 +3226,69 @@
}
}
- public void noteDeviceIdleModeLocked(boolean enabled, String activeReason, int activeUid) {
+ public void noteDeviceIdleModeLocked(int mode, String activeReason, int activeUid) {
final long elapsedRealtime = SystemClock.elapsedRealtime();
final long uptime = SystemClock.uptimeMillis();
- boolean nowIdling = enabled;
- if (mDeviceIdling && !enabled && activeReason == null) {
+ boolean nowIdling = mode == DEVICE_IDLE_MODE_FULL;
+ if (mDeviceIdling && !nowIdling && activeReason == null) {
// We don't go out of general idling mode until explicitly taken out of
// device idle through going active or significant motion.
nowIdling = true;
}
+ boolean nowLightIdling = mode == DEVICE_IDLE_MODE_LIGHT;
+ if (mDeviceLightIdling && !nowLightIdling && !nowIdling && activeReason == null) {
+ // We don't go out of general light idling mode until explicitly taken out of
+ // device idle through going active or significant motion.
+ nowLightIdling = true;
+ }
+ if (activeReason != null && (mDeviceIdling || mDeviceLightIdling)) {
+ addHistoryEventLocked(elapsedRealtime, uptime, HistoryItem.EVENT_ACTIVE,
+ activeReason, activeUid);
+ }
if (mDeviceIdling != nowIdling) {
mDeviceIdling = nowIdling;
int stepState = nowIdling ? STEP_LEVEL_MODE_DEVICE_IDLE : 0;
mModStepMode |= (mCurStepMode&STEP_LEVEL_MODE_DEVICE_IDLE) ^ stepState;
mCurStepMode = (mCurStepMode&~STEP_LEVEL_MODE_DEVICE_IDLE) | stepState;
- if (enabled) {
+ if (nowIdling) {
mDeviceIdlingTimer.startRunningLocked(elapsedRealtime);
} else {
mDeviceIdlingTimer.stopRunningLocked(elapsedRealtime);
}
}
- if (mDeviceIdleModeEnabled != enabled) {
- mDeviceIdleModeEnabled = enabled;
- addHistoryEventLocked(elapsedRealtime, uptime, HistoryItem.EVENT_ACTIVE,
- activeReason != null ? activeReason : "", activeUid);
- if (enabled) {
- mHistoryCur.states2 |= HistoryItem.STATE2_DEVICE_IDLE_FLAG;
- if (DEBUG_HISTORY) Slog.v(TAG, "Device idle mode enabled to: "
- + Integer.toHexString(mHistoryCur.states2));
- mDeviceIdleModeEnabledTimer.startRunningLocked(elapsedRealtime);
+ if (mDeviceLightIdling != nowLightIdling) {
+ mDeviceLightIdling = nowLightIdling;
+ if (nowLightIdling) {
+ mDeviceLightIdlingTimer.startRunningLocked(elapsedRealtime);
} else {
- mHistoryCur.states2 &= ~HistoryItem.STATE2_DEVICE_IDLE_FLAG;
- if (DEBUG_HISTORY) Slog.v(TAG, "Device idle mode disabled to: "
- + Integer.toHexString(mHistoryCur.states2));
- mDeviceIdleModeEnabledTimer.stopRunningLocked(elapsedRealtime);
+ mDeviceLightIdlingTimer.stopRunningLocked(elapsedRealtime);
}
+ }
+ if (mDeviceIdleMode != mode) {
+ mHistoryCur.states2 = (mHistoryCur.states2 & ~HistoryItem.STATE2_DEVICE_IDLE_MASK)
+ | (mode << HistoryItem.STATE2_DEVICE_IDLE_SHIFT);
+ if (DEBUG_HISTORY) Slog.v(TAG, "Device idle mode changed to: "
+ + Integer.toHexString(mHistoryCur.states2));
addHistoryRecordLocked(elapsedRealtime, uptime);
+ long lastDuration = elapsedRealtime - mLastIdleTimeStart;
+ mLastIdleTimeStart = elapsedRealtime;
+ if (mDeviceIdleMode == DEVICE_IDLE_MODE_LIGHT) {
+ if (lastDuration > mLongestLightIdleTime) {
+ mLongestLightIdleTime = lastDuration;
+ }
+ mDeviceIdleModeLightTimer.stopRunningLocked(elapsedRealtime);
+ } else if (mDeviceIdleMode == DEVICE_IDLE_MODE_FULL) {
+ if (lastDuration > mLongestFullIdleTime) {
+ mLongestFullIdleTime = lastDuration;
+ }
+ mDeviceIdleModeFullTimer.stopRunningLocked(elapsedRealtime);
+ }
+ if (mode == DEVICE_IDLE_MODE_LIGHT) {
+ mDeviceIdleModeLightTimer.startRunningLocked(elapsedRealtime);
+ } else if (mode == DEVICE_IDLE_MODE_FULL) {
+ mDeviceIdleModeFullTimer.startRunningLocked(elapsedRealtime);
+ }
+ mDeviceIdleMode = mode;
}
}
@@ -4140,20 +4174,55 @@
return mPowerSaveModeEnabledTimer.getCountLocked(which);
}
- @Override public long getDeviceIdleModeEnabledTime(long elapsedRealtimeUs, int which) {
- return mDeviceIdleModeEnabledTimer.getTotalTimeLocked(elapsedRealtimeUs, which);
+ @Override public long getDeviceIdleModeTime(int mode, long elapsedRealtimeUs,
+ int which) {
+ switch (mode) {
+ case DEVICE_IDLE_MODE_LIGHT:
+ return mDeviceIdleModeLightTimer.getTotalTimeLocked(elapsedRealtimeUs, which);
+ case DEVICE_IDLE_MODE_FULL:
+ return mDeviceIdleModeFullTimer.getTotalTimeLocked(elapsedRealtimeUs, which);
+ }
+ return 0;
}
- @Override public int getDeviceIdleModeEnabledCount(int which) {
- return mDeviceIdleModeEnabledTimer.getCountLocked(which);
+ @Override public int getDeviceIdleModeCount(int mode, int which) {
+ switch (mode) {
+ case DEVICE_IDLE_MODE_LIGHT:
+ return mDeviceIdleModeLightTimer.getCountLocked(which);
+ case DEVICE_IDLE_MODE_FULL:
+ return mDeviceIdleModeFullTimer.getCountLocked(which);
+ }
+ return 0;
}
- @Override public long getDeviceIdlingTime(long elapsedRealtimeUs, int which) {
- return mDeviceIdlingTimer.getTotalTimeLocked(elapsedRealtimeUs, which);
+ @Override public long getLongestDeviceIdleModeTime(int mode) {
+ switch (mode) {
+ case DEVICE_IDLE_MODE_LIGHT:
+ return mLongestLightIdleTime;
+ case DEVICE_IDLE_MODE_FULL:
+ return mLongestFullIdleTime;
+ }
+ return 0;
}
- @Override public int getDeviceIdlingCount(int which) {
- return mDeviceIdlingTimer.getCountLocked(which);
+ @Override public long getDeviceIdlingTime(int mode, long elapsedRealtimeUs, int which) {
+ switch (mode) {
+ case DEVICE_IDLE_MODE_LIGHT:
+ return mDeviceLightIdlingTimer.getTotalTimeLocked(elapsedRealtimeUs, which);
+ case DEVICE_IDLE_MODE_FULL:
+ return mDeviceIdlingTimer.getTotalTimeLocked(elapsedRealtimeUs, which);
+ }
+ return 0;
+ }
+
+ @Override public int getDeviceIdlingCount(int mode, int which) {
+ switch (mode) {
+ case DEVICE_IDLE_MODE_LIGHT:
+ return mDeviceLightIdlingTimer.getCountLocked(which);
+ case DEVICE_IDLE_MODE_FULL:
+ return mDeviceIdlingTimer.getCountLocked(which);
+ }
+ return 0;
}
@Override public int getNumConnectivityChange(int which) {
@@ -6855,7 +6924,9 @@
}
mInteractiveTimer = new StopwatchTimer(null, -10, null, mOnBatteryTimeBase);
mPowerSaveModeEnabledTimer = new StopwatchTimer(null, -2, null, mOnBatteryTimeBase);
- mDeviceIdleModeEnabledTimer = new StopwatchTimer(null, -11, null, mOnBatteryTimeBase);
+ mDeviceIdleModeLightTimer = new StopwatchTimer(null, -11, null, mOnBatteryTimeBase);
+ mDeviceIdleModeFullTimer = new StopwatchTimer(null, -14, null, mOnBatteryTimeBase);
+ mDeviceLightIdlingTimer = new StopwatchTimer(null, -15, null, mOnBatteryTimeBase);
mDeviceIdlingTimer = new StopwatchTimer(null, -12, null, mOnBatteryTimeBase);
mPhoneOnTimer = new StopwatchTimer(null, -3, null, mOnBatteryTimeBase);
for (int i=0; i<SignalStrength.NUM_SIGNAL_STRENGTH_BINS; i++) {
@@ -7484,7 +7555,11 @@
}
mInteractiveTimer.reset(false);
mPowerSaveModeEnabledTimer.reset(false);
- mDeviceIdleModeEnabledTimer.reset(false);
+ mLongestLightIdleTime = 0;
+ mLongestFullIdleTime = 0;
+ mDeviceIdleModeLightTimer.reset(false);
+ mDeviceIdleModeFullTimer.reset(false);
+ mDeviceLightIdlingTimer.reset(false);
mDeviceIdlingTimer.reset(false);
mPhoneOnTimer.reset(false);
mAudioOnTimer.reset(false);
@@ -9224,7 +9299,11 @@
mInteractiveTimer.readSummaryFromParcelLocked(in);
mPhoneOn = false;
mPowerSaveModeEnabledTimer.readSummaryFromParcelLocked(in);
- mDeviceIdleModeEnabledTimer.readSummaryFromParcelLocked(in);
+ mLongestLightIdleTime = in.readLong();
+ mLongestFullIdleTime = in.readLong();
+ mDeviceIdleModeLightTimer.readSummaryFromParcelLocked(in);
+ mDeviceIdleModeFullTimer.readSummaryFromParcelLocked(in);
+ mDeviceLightIdlingTimer.readSummaryFromParcelLocked(in);
mDeviceIdlingTimer.readSummaryFromParcelLocked(in);
mPhoneOnTimer.readSummaryFromParcelLocked(in);
for (int i=0; i<SignalStrength.NUM_SIGNAL_STRENGTH_BINS; i++) {
@@ -9558,7 +9637,11 @@
}
mInteractiveTimer.writeSummaryFromParcelLocked(out, NOWREAL_SYS);
mPowerSaveModeEnabledTimer.writeSummaryFromParcelLocked(out, NOWREAL_SYS);
- mDeviceIdleModeEnabledTimer.writeSummaryFromParcelLocked(out, NOWREAL_SYS);
+ out.writeLong(mLongestLightIdleTime);
+ out.writeLong(mLongestFullIdleTime);
+ mDeviceIdleModeLightTimer.writeSummaryFromParcelLocked(out, NOWREAL_SYS);
+ mDeviceIdleModeFullTimer.writeSummaryFromParcelLocked(out, NOWREAL_SYS);
+ mDeviceLightIdlingTimer.writeSummaryFromParcelLocked(out, NOWREAL_SYS);
mDeviceIdlingTimer.writeSummaryFromParcelLocked(out, NOWREAL_SYS);
mPhoneOnTimer.writeSummaryFromParcelLocked(out, NOWREAL_SYS);
for (int i=0; i<SignalStrength.NUM_SIGNAL_STRENGTH_BINS; i++) {
@@ -9892,7 +9975,11 @@
mInteractiveTimer = new StopwatchTimer(null, -10, null, mOnBatteryTimeBase, in);
mPhoneOn = false;
mPowerSaveModeEnabledTimer = new StopwatchTimer(null, -2, null, mOnBatteryTimeBase, in);
- mDeviceIdleModeEnabledTimer = new StopwatchTimer(null, -11, null, mOnBatteryTimeBase, in);
+ mLongestLightIdleTime = in.readLong();
+ mLongestFullIdleTime = in.readLong();
+ mDeviceIdleModeLightTimer = new StopwatchTimer(null, -14, null, mOnBatteryTimeBase, in);
+ mDeviceIdleModeFullTimer = new StopwatchTimer(null, -11, null, mOnBatteryTimeBase, in);
+ mDeviceLightIdlingTimer = new StopwatchTimer(null, -15, null, mOnBatteryTimeBase, in);
mDeviceIdlingTimer = new StopwatchTimer(null, -12, null, mOnBatteryTimeBase, in);
mPhoneOnTimer = new StopwatchTimer(null, -3, null, mOnBatteryTimeBase, in);
for (int i=0; i<SignalStrength.NUM_SIGNAL_STRENGTH_BINS; i++) {
@@ -10053,7 +10140,11 @@
}
mInteractiveTimer.writeToParcel(out, uSecRealtime);
mPowerSaveModeEnabledTimer.writeToParcel(out, uSecRealtime);
- mDeviceIdleModeEnabledTimer.writeToParcel(out, uSecRealtime);
+ out.writeLong(mLongestLightIdleTime);
+ out.writeLong(mLongestFullIdleTime);
+ mDeviceIdleModeLightTimer.writeToParcel(out, uSecRealtime);
+ mDeviceIdleModeFullTimer.writeToParcel(out, uSecRealtime);
+ mDeviceLightIdlingTimer.writeToParcel(out, uSecRealtime);
mDeviceIdlingTimer.writeToParcel(out, uSecRealtime);
mPhoneOnTimer.writeToParcel(out, uSecRealtime);
for (int i=0; i<SignalStrength.NUM_SIGNAL_STRENGTH_BINS; i++) {
@@ -10188,8 +10279,12 @@
mInteractiveTimer.logState(pr, " ");
pr.println("*** Power save mode timer:");
mPowerSaveModeEnabledTimer.logState(pr, " ");
- pr.println("*** Device idle mode timer:");
- mDeviceIdleModeEnabledTimer.logState(pr, " ");
+ pr.println("*** Device idle mode light timer:");
+ mDeviceIdleModeLightTimer.logState(pr, " ");
+ pr.println("*** Device idle mode full timer:");
+ mDeviceIdleModeFullTimer.logState(pr, " ");
+ pr.println("*** Device light idling timer:");
+ mDeviceLightIdlingTimer.logState(pr, " ");
pr.println("*** Device idling timer:");
mDeviceIdlingTimer.logState(pr, " ");
pr.println("*** Phone timer:");