Loading core/java/android/os/BatteryStats.java +10 −12 Original line number Diff line number Diff line Loading @@ -1165,25 +1165,23 @@ public abstract class BatteryStats implements Parcelable { public static final int EVENT_USER_FOREGROUND = 0x0008; // Event for connectivity changed. public static final int EVENT_CONNECTIVITY_CHANGED = 0x0009; // Event for significant motion taking us out of idle mode. public static final int EVENT_SIGNIFICANT_MOTION = 0x000a; // Event for becoming active taking us out of idle mode. public static final int EVENT_ACTIVE = 0x000b; public static final int EVENT_ACTIVE = 0x000a; // Event for a package being installed. public static final int EVENT_PACKAGE_INSTALLED = 0x000c; public static final int EVENT_PACKAGE_INSTALLED = 0x000b; // Event for a package being uninstalled. public static final int EVENT_PACKAGE_UNINSTALLED = 0x000d; public static final int EVENT_PACKAGE_UNINSTALLED = 0x000c; // Event for a package being uninstalled. public static final int EVENT_ALARM = 0x000e; public static final int EVENT_ALARM = 0x000d; // Record that we have decided we need to collect new stats data. public static final int EVENT_COLLECT_EXTERNAL_STATS = 0x000f; public static final int EVENT_COLLECT_EXTERNAL_STATS = 0x000e; // Event for a package becoming inactive due to being unused for a period of time. public static final int EVENT_PACKAGE_INACTIVE = 0x0010; public static final int EVENT_PACKAGE_INACTIVE = 0x000f; // Event for a package becoming active due to an interaction. public static final int EVENT_PACKAGE_ACTIVE = 0x0011; public static final int EVENT_PACKAGE_ACTIVE = 0x0010; // Number of event types. public static final int EVENT_COUNT = 0x0012; public static final int EVENT_COUNT = 0x0011; // Mask to extract out only the type part of the event. public static final int EVENT_TYPE_MASK = ~(EVENT_FLAG_START|EVENT_FLAG_FINISH); Loading Loading @@ -1840,12 +1838,12 @@ public abstract class BatteryStats implements Parcelable { public static final String[] HISTORY_EVENT_NAMES = new String[] { "null", "proc", "fg", "top", "sync", "wake_lock_in", "job", "user", "userfg", "conn", "motion", "active", "pkginst", "pkgunin", "alarm", "stats", "inactive", "active" "active", "pkginst", "pkgunin", "alarm", "stats", "inactive", "active" }; public static final String[] HISTORY_EVENT_CHECKIN_NAMES = new String[] { "Enl", "Epr", "Efg", "Etp", "Esy", "Ewl", "Ejb", "Eur", "Euf", "Ecn", "Esm", "Eac", "Epi", "Epu", "Eal", "Est", "Eai", "Eaa" "Eac", "Epi", "Epu", "Eal", "Est", "Eai", "Eaa" }; /** Loading core/java/android/os/IDeviceIdleController.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -28,4 +28,5 @@ interface IDeviceIdleController { int[] getAppIdTempWhitelist(); boolean isPowerSaveWhitelistApp(String name); void addPowerSaveTempWhitelistApp(String name, long duration, int userId); void exitIdle(String reason); } core/java/com/android/internal/app/IBatteryStats.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -116,7 +116,7 @@ interface IBatteryStats { void noteWifiRadioPowerState(int powerState, long timestampNs); void noteNetworkInterfaceType(String iface, int type); void noteNetworkStatsEnabled(); void noteDeviceIdleMode(boolean enabled, boolean fromActive, boolean fromMotion); void noteDeviceIdleMode(boolean enabled, String activeReason, int activeUid); void setBatteryState(int status, int health, int plugType, int level, int temp, int volt); long getAwakeTimeBattery(); long getAwakeTimePlugged(); Loading core/java/com/android/internal/os/BatteryStatsImpl.java +5 −11 Original line number Diff line number Diff line Loading @@ -106,7 +106,7 @@ public final class BatteryStatsImpl extends BatteryStats { private static final int MAGIC = 0xBA757475; // 'BATSTATS' // Current on-disk Parcel version private static final int VERSION = 127 + (USE_OLD_HISTORY ? 1000 : 0); private static final int VERSION = 128 + (USE_OLD_HISTORY ? 1000 : 0); // Maximum number of items we will record in the history. private static final int MAX_HISTORY_ITEMS = 2000; Loading Loading @@ -3187,11 +3187,11 @@ public final class BatteryStatsImpl extends BatteryStats { } } public void noteDeviceIdleModeLocked(boolean enabled, boolean fromActive, boolean fromMotion) { public void noteDeviceIdleModeLocked(boolean enabled, String activeReason, int activeUid) { final long elapsedRealtime = SystemClock.elapsedRealtime(); final long uptime = SystemClock.uptimeMillis(); boolean nowIdling = enabled; if (mDeviceIdling && !enabled && !fromActive && !fromMotion) { if (mDeviceIdling && !enabled && 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; Loading @@ -3209,14 +3209,8 @@ public final class BatteryStatsImpl extends BatteryStats { } if (mDeviceIdleModeEnabled != enabled) { mDeviceIdleModeEnabled = enabled; if (fromMotion) { addHistoryEventLocked(elapsedRealtime, uptime, HistoryItem.EVENT_SIGNIFICANT_MOTION, "", 0); } if (fromActive) { addHistoryEventLocked(elapsedRealtime, uptime, HistoryItem.EVENT_ACTIVE, "", 0); } activeReason != null ? activeReason : "", activeUid); if (enabled) { mHistoryCur.states2 |= HistoryItem.STATE2_DEVICE_IDLE_FLAG; if (DEBUG_HISTORY) Slog.v(TAG, "Device idle mode enabled to: " Loading services/core/java/com/android/server/DeviceIdleController.java +30 −16 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ import android.os.Looper; import android.os.Message; import android.os.PowerManager; import android.os.PowerManagerInternal; import android.os.Process; import android.os.RemoteException; import android.os.ServiceManager; import android.os.SystemClock; Loading Loading @@ -487,7 +488,7 @@ public class DeviceIdleController extends SystemService mLocalPowerManager.setDeviceIdleMode(true); try { mNetworkPolicyManager.setDeviceIdleMode(true); mBatteryStats.noteDeviceIdleMode(true, false, false); mBatteryStats.noteDeviceIdleMode(true, null, Process.myUid()); } catch (RemoteException e) { } getContext().sendBroadcastAsUser(mIdleIntent, UserHandle.ALL); Loading @@ -496,18 +497,19 @@ public class DeviceIdleController extends SystemService mLocalPowerManager.setDeviceIdleMode(false); try { mNetworkPolicyManager.setDeviceIdleMode(false); mBatteryStats.noteDeviceIdleMode(false, false, false); mBatteryStats.noteDeviceIdleMode(false, null, Process.myUid()); } catch (RemoteException e) { } getContext().sendBroadcastAsUser(mIdleIntent, UserHandle.ALL); } break; case MSG_REPORT_ACTIVE: { boolean fromMotion = msg.arg1 != 0; String activeReason = (String)msg.obj; int activeUid = msg.arg1; boolean needBroadcast = msg.arg2 != 0; mLocalPowerManager.setDeviceIdleMode(false); try { mNetworkPolicyManager.setDeviceIdleMode(false); mBatteryStats.noteDeviceIdleMode(false, !fromMotion, fromMotion); mBatteryStats.noteDeviceIdleMode(false, activeReason, activeUid); } catch (RemoteException e) { } if (needBroadcast) { Loading Loading @@ -578,6 +580,12 @@ public class DeviceIdleController extends SystemService } } @Override public void exitIdle(String reason) { getContext().enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER, null); exitIdleInternal(reason); } @Override protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) { DeviceIdleController.this.dump(fd, pw, args); } Loading Loading @@ -818,6 +826,12 @@ public class DeviceIdleController extends SystemService } } public void exitIdleInternal(String reason) { synchronized (this) { becomeActiveLocked(reason, Binder.getCallingUid()); } } void updateDisplayLocked() { mCurDisplay = mDisplayManager.getDisplay(Display.DEFAULT_DISPLAY); // We consider any situation where the display is showing something to be it on, Loading @@ -830,7 +844,7 @@ public class DeviceIdleController extends SystemService becomeInactiveIfAppropriateLocked(); } else if (screenOn) { mScreenOn = true; becomeActiveLocked("screen"); becomeActiveLocked("screen", Process.myUid()); } } Loading @@ -841,21 +855,21 @@ public class DeviceIdleController extends SystemService becomeInactiveIfAppropriateLocked(); } else if (charging) { mCharging = charging; becomeActiveLocked("charging"); becomeActiveLocked("charging", Process.myUid()); } } void scheduleReportActiveLocked(boolean fromMotion) { Message msg = mHandler.obtainMessage(MSG_REPORT_ACTIVE, fromMotion ? 1 : 0, mState == STATE_IDLE ? 1 : 0); void scheduleReportActiveLocked(String activeReason, int activeUid) { Message msg = mHandler.obtainMessage(MSG_REPORT_ACTIVE, activeUid, mState == STATE_IDLE ? 1 : 0, activeReason); mHandler.sendMessage(msg); } void becomeActiveLocked(String reason) { if (DEBUG) Slog.i(TAG, "becomeActiveLocked, reason = " + reason); void becomeActiveLocked(String activeReason, int activeUid) { if (DEBUG) Slog.i(TAG, "becomeActiveLocked, reason = " + activeReason); if (mState != STATE_ACTIVE) { EventLogTags.writeDeviceIdle(STATE_ACTIVE, reason); scheduleReportActiveLocked(false); EventLogTags.writeDeviceIdle(STATE_ACTIVE, activeReason); scheduleReportActiveLocked(activeReason, activeUid); mState = STATE_ACTIVE; mInactiveTimeout = mConstants.INACTIVE_TIMEOUT; mNextIdlePendingDelay = 0; Loading Loading @@ -896,7 +910,7 @@ public class DeviceIdleController extends SystemService if ((now+mConstants.MIN_TIME_TO_ALARM) > mAlarmManager.getNextWakeFromIdleTime()) { // Whoops, there is an upcoming alarm. We don't actually want to go idle. if (mState != STATE_ACTIVE) { becomeActiveLocked("alarm"); becomeActiveLocked("alarm", Process.myUid()); } return; } Loading Loading @@ -954,7 +968,7 @@ public class DeviceIdleController extends SystemService // state to wait again for no motion. Note that we only monitor for significant // motion after moving out of the inactive state, so no need to worry about that. if (mState != STATE_ACTIVE) { scheduleReportActiveLocked(true); scheduleReportActiveLocked("motion", Process.myUid()); mState = STATE_ACTIVE; mInactiveTimeout = mConstants.MOTION_INACTIVE_TIMEOUT; EventLogTags.writeDeviceIdle(mState, "motion"); Loading Loading @@ -1240,7 +1254,7 @@ public class DeviceIdleController extends SystemService synchronized (this) { if (!mIdleDisabled) { mIdleDisabled = true; becomeActiveLocked("disabled"); becomeActiveLocked("disabled", Process.myUid()); pw.println("Idle mode disabled"); } } Loading Loading
core/java/android/os/BatteryStats.java +10 −12 Original line number Diff line number Diff line Loading @@ -1165,25 +1165,23 @@ public abstract class BatteryStats implements Parcelable { public static final int EVENT_USER_FOREGROUND = 0x0008; // Event for connectivity changed. public static final int EVENT_CONNECTIVITY_CHANGED = 0x0009; // Event for significant motion taking us out of idle mode. public static final int EVENT_SIGNIFICANT_MOTION = 0x000a; // Event for becoming active taking us out of idle mode. public static final int EVENT_ACTIVE = 0x000b; public static final int EVENT_ACTIVE = 0x000a; // Event for a package being installed. public static final int EVENT_PACKAGE_INSTALLED = 0x000c; public static final int EVENT_PACKAGE_INSTALLED = 0x000b; // Event for a package being uninstalled. public static final int EVENT_PACKAGE_UNINSTALLED = 0x000d; public static final int EVENT_PACKAGE_UNINSTALLED = 0x000c; // Event for a package being uninstalled. public static final int EVENT_ALARM = 0x000e; public static final int EVENT_ALARM = 0x000d; // Record that we have decided we need to collect new stats data. public static final int EVENT_COLLECT_EXTERNAL_STATS = 0x000f; public static final int EVENT_COLLECT_EXTERNAL_STATS = 0x000e; // Event for a package becoming inactive due to being unused for a period of time. public static final int EVENT_PACKAGE_INACTIVE = 0x0010; public static final int EVENT_PACKAGE_INACTIVE = 0x000f; // Event for a package becoming active due to an interaction. public static final int EVENT_PACKAGE_ACTIVE = 0x0011; public static final int EVENT_PACKAGE_ACTIVE = 0x0010; // Number of event types. public static final int EVENT_COUNT = 0x0012; public static final int EVENT_COUNT = 0x0011; // Mask to extract out only the type part of the event. public static final int EVENT_TYPE_MASK = ~(EVENT_FLAG_START|EVENT_FLAG_FINISH); Loading Loading @@ -1840,12 +1838,12 @@ public abstract class BatteryStats implements Parcelable { public static final String[] HISTORY_EVENT_NAMES = new String[] { "null", "proc", "fg", "top", "sync", "wake_lock_in", "job", "user", "userfg", "conn", "motion", "active", "pkginst", "pkgunin", "alarm", "stats", "inactive", "active" "active", "pkginst", "pkgunin", "alarm", "stats", "inactive", "active" }; public static final String[] HISTORY_EVENT_CHECKIN_NAMES = new String[] { "Enl", "Epr", "Efg", "Etp", "Esy", "Ewl", "Ejb", "Eur", "Euf", "Ecn", "Esm", "Eac", "Epi", "Epu", "Eal", "Est", "Eai", "Eaa" "Eac", "Epi", "Epu", "Eal", "Est", "Eai", "Eaa" }; /** Loading
core/java/android/os/IDeviceIdleController.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -28,4 +28,5 @@ interface IDeviceIdleController { int[] getAppIdTempWhitelist(); boolean isPowerSaveWhitelistApp(String name); void addPowerSaveTempWhitelistApp(String name, long duration, int userId); void exitIdle(String reason); }
core/java/com/android/internal/app/IBatteryStats.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -116,7 +116,7 @@ interface IBatteryStats { void noteWifiRadioPowerState(int powerState, long timestampNs); void noteNetworkInterfaceType(String iface, int type); void noteNetworkStatsEnabled(); void noteDeviceIdleMode(boolean enabled, boolean fromActive, boolean fromMotion); void noteDeviceIdleMode(boolean enabled, String activeReason, int activeUid); void setBatteryState(int status, int health, int plugType, int level, int temp, int volt); long getAwakeTimeBattery(); long getAwakeTimePlugged(); Loading
core/java/com/android/internal/os/BatteryStatsImpl.java +5 −11 Original line number Diff line number Diff line Loading @@ -106,7 +106,7 @@ public final class BatteryStatsImpl extends BatteryStats { private static final int MAGIC = 0xBA757475; // 'BATSTATS' // Current on-disk Parcel version private static final int VERSION = 127 + (USE_OLD_HISTORY ? 1000 : 0); private static final int VERSION = 128 + (USE_OLD_HISTORY ? 1000 : 0); // Maximum number of items we will record in the history. private static final int MAX_HISTORY_ITEMS = 2000; Loading Loading @@ -3187,11 +3187,11 @@ public final class BatteryStatsImpl extends BatteryStats { } } public void noteDeviceIdleModeLocked(boolean enabled, boolean fromActive, boolean fromMotion) { public void noteDeviceIdleModeLocked(boolean enabled, String activeReason, int activeUid) { final long elapsedRealtime = SystemClock.elapsedRealtime(); final long uptime = SystemClock.uptimeMillis(); boolean nowIdling = enabled; if (mDeviceIdling && !enabled && !fromActive && !fromMotion) { if (mDeviceIdling && !enabled && 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; Loading @@ -3209,14 +3209,8 @@ public final class BatteryStatsImpl extends BatteryStats { } if (mDeviceIdleModeEnabled != enabled) { mDeviceIdleModeEnabled = enabled; if (fromMotion) { addHistoryEventLocked(elapsedRealtime, uptime, HistoryItem.EVENT_SIGNIFICANT_MOTION, "", 0); } if (fromActive) { addHistoryEventLocked(elapsedRealtime, uptime, HistoryItem.EVENT_ACTIVE, "", 0); } activeReason != null ? activeReason : "", activeUid); if (enabled) { mHistoryCur.states2 |= HistoryItem.STATE2_DEVICE_IDLE_FLAG; if (DEBUG_HISTORY) Slog.v(TAG, "Device idle mode enabled to: " Loading
services/core/java/com/android/server/DeviceIdleController.java +30 −16 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ import android.os.Looper; import android.os.Message; import android.os.PowerManager; import android.os.PowerManagerInternal; import android.os.Process; import android.os.RemoteException; import android.os.ServiceManager; import android.os.SystemClock; Loading Loading @@ -487,7 +488,7 @@ public class DeviceIdleController extends SystemService mLocalPowerManager.setDeviceIdleMode(true); try { mNetworkPolicyManager.setDeviceIdleMode(true); mBatteryStats.noteDeviceIdleMode(true, false, false); mBatteryStats.noteDeviceIdleMode(true, null, Process.myUid()); } catch (RemoteException e) { } getContext().sendBroadcastAsUser(mIdleIntent, UserHandle.ALL); Loading @@ -496,18 +497,19 @@ public class DeviceIdleController extends SystemService mLocalPowerManager.setDeviceIdleMode(false); try { mNetworkPolicyManager.setDeviceIdleMode(false); mBatteryStats.noteDeviceIdleMode(false, false, false); mBatteryStats.noteDeviceIdleMode(false, null, Process.myUid()); } catch (RemoteException e) { } getContext().sendBroadcastAsUser(mIdleIntent, UserHandle.ALL); } break; case MSG_REPORT_ACTIVE: { boolean fromMotion = msg.arg1 != 0; String activeReason = (String)msg.obj; int activeUid = msg.arg1; boolean needBroadcast = msg.arg2 != 0; mLocalPowerManager.setDeviceIdleMode(false); try { mNetworkPolicyManager.setDeviceIdleMode(false); mBatteryStats.noteDeviceIdleMode(false, !fromMotion, fromMotion); mBatteryStats.noteDeviceIdleMode(false, activeReason, activeUid); } catch (RemoteException e) { } if (needBroadcast) { Loading Loading @@ -578,6 +580,12 @@ public class DeviceIdleController extends SystemService } } @Override public void exitIdle(String reason) { getContext().enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER, null); exitIdleInternal(reason); } @Override protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) { DeviceIdleController.this.dump(fd, pw, args); } Loading Loading @@ -818,6 +826,12 @@ public class DeviceIdleController extends SystemService } } public void exitIdleInternal(String reason) { synchronized (this) { becomeActiveLocked(reason, Binder.getCallingUid()); } } void updateDisplayLocked() { mCurDisplay = mDisplayManager.getDisplay(Display.DEFAULT_DISPLAY); // We consider any situation where the display is showing something to be it on, Loading @@ -830,7 +844,7 @@ public class DeviceIdleController extends SystemService becomeInactiveIfAppropriateLocked(); } else if (screenOn) { mScreenOn = true; becomeActiveLocked("screen"); becomeActiveLocked("screen", Process.myUid()); } } Loading @@ -841,21 +855,21 @@ public class DeviceIdleController extends SystemService becomeInactiveIfAppropriateLocked(); } else if (charging) { mCharging = charging; becomeActiveLocked("charging"); becomeActiveLocked("charging", Process.myUid()); } } void scheduleReportActiveLocked(boolean fromMotion) { Message msg = mHandler.obtainMessage(MSG_REPORT_ACTIVE, fromMotion ? 1 : 0, mState == STATE_IDLE ? 1 : 0); void scheduleReportActiveLocked(String activeReason, int activeUid) { Message msg = mHandler.obtainMessage(MSG_REPORT_ACTIVE, activeUid, mState == STATE_IDLE ? 1 : 0, activeReason); mHandler.sendMessage(msg); } void becomeActiveLocked(String reason) { if (DEBUG) Slog.i(TAG, "becomeActiveLocked, reason = " + reason); void becomeActiveLocked(String activeReason, int activeUid) { if (DEBUG) Slog.i(TAG, "becomeActiveLocked, reason = " + activeReason); if (mState != STATE_ACTIVE) { EventLogTags.writeDeviceIdle(STATE_ACTIVE, reason); scheduleReportActiveLocked(false); EventLogTags.writeDeviceIdle(STATE_ACTIVE, activeReason); scheduleReportActiveLocked(activeReason, activeUid); mState = STATE_ACTIVE; mInactiveTimeout = mConstants.INACTIVE_TIMEOUT; mNextIdlePendingDelay = 0; Loading Loading @@ -896,7 +910,7 @@ public class DeviceIdleController extends SystemService if ((now+mConstants.MIN_TIME_TO_ALARM) > mAlarmManager.getNextWakeFromIdleTime()) { // Whoops, there is an upcoming alarm. We don't actually want to go idle. if (mState != STATE_ACTIVE) { becomeActiveLocked("alarm"); becomeActiveLocked("alarm", Process.myUid()); } return; } Loading Loading @@ -954,7 +968,7 @@ public class DeviceIdleController extends SystemService // state to wait again for no motion. Note that we only monitor for significant // motion after moving out of the inactive state, so no need to worry about that. if (mState != STATE_ACTIVE) { scheduleReportActiveLocked(true); scheduleReportActiveLocked("motion", Process.myUid()); mState = STATE_ACTIVE; mInactiveTimeout = mConstants.MOTION_INACTIVE_TIMEOUT; EventLogTags.writeDeviceIdle(mState, "motion"); Loading Loading @@ -1240,7 +1254,7 @@ public class DeviceIdleController extends SystemService synchronized (this) { if (!mIdleDisabled) { mIdleDisabled = true; becomeActiveLocked("disabled"); becomeActiveLocked("disabled", Process.myUid()); pw.println("Idle mode disabled"); } } Loading