Loading core/java/android/os/PowerManager.java +21 −3 Original line number Diff line number Diff line Loading @@ -298,10 +298,10 @@ public final class PowerManager { public static final int USER_ACTIVITY_FLAG_NO_CHANGE_LIGHTS = 1 << 0; /** * Go to sleep reason code: Going to sleep due by user request. * Go to sleep reason code: Going to sleep due by application request. * @hide */ public static final int GO_TO_SLEEP_REASON_USER = 0; public static final int GO_TO_SLEEP_REASON_APPLICATION = 0; /** * Go to sleep reason code: Going to sleep due by request of the Loading @@ -316,6 +316,24 @@ public final class PowerManager { */ public static final int GO_TO_SLEEP_REASON_TIMEOUT = 2; /** * Go to sleep reason code: Going to sleep due to the lid switch being closed. * @hide */ public static final int GO_TO_SLEEP_REASON_LID_SWITCH = 3; /** * Go to sleep reason code: Going to sleep due to the power button being pressed. * @hide */ public static final int GO_TO_SLEEP_REASON_POWER_BUTTON = 4; /** * Go to sleep reason code: Going to sleep due to HDMI. * @hide */ public static final int GO_TO_SLEEP_REASON_HDMI = 5; /** * The value to pass as the 'reason' argument to reboot() to * reboot into recovery mode (for applying system updates, doing Loading Loading @@ -513,7 +531,7 @@ public final class PowerManager { * @see #wakeUp */ public void goToSleep(long time) { goToSleep(time, GO_TO_SLEEP_REASON_USER, 0); goToSleep(time, GO_TO_SLEEP_REASON_APPLICATION, 0); } /** Loading policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +8 −6 Original line number Diff line number Diff line Loading @@ -845,16 +845,16 @@ public class PhoneWindowManager implements WindowManagerPolicy { break; case SHORT_PRESS_POWER_GO_TO_SLEEP: mPowerManager.goToSleep(eventTime, PowerManager.GO_TO_SLEEP_REASON_USER, 0); PowerManager.GO_TO_SLEEP_REASON_POWER_BUTTON, 0); break; case SHORT_PRESS_POWER_REALLY_GO_TO_SLEEP: mPowerManager.goToSleep(eventTime, PowerManager.GO_TO_SLEEP_REASON_USER, PowerManager.GO_TO_SLEEP_REASON_POWER_BUTTON, PowerManager.GO_TO_SLEEP_FLAG_NO_DOZE); break; case SHORT_PRESS_POWER_REALLY_GO_TO_SLEEP_AND_GO_HOME: mPowerManager.goToSleep(eventTime, PowerManager.GO_TO_SLEEP_REASON_USER, PowerManager.GO_TO_SLEEP_REASON_POWER_BUTTON, PowerManager.GO_TO_SLEEP_FLAG_NO_DOZE); launchHomeFromHotKey(); break; Loading Loading @@ -4290,7 +4290,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { } if ((mEndcallBehavior & Settings.System.END_BUTTON_BEHAVIOR_SLEEP) != 0) { mPowerManager.goToSleep(event.getEventTime()); mPowerManager.goToSleep(event.getEventTime(), PowerManager.GO_TO_SLEEP_REASON_POWER_BUTTON, 0); isWakeKey = false; } } Loading Loading @@ -4347,7 +4348,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { if (!mPowerManager.isInteractive()) { useHapticFeedback = false; // suppress feedback if already non-interactive } mPowerManager.goToSleep(event.getEventTime()); mPowerManager.goToSleep(event.getEventTime(), PowerManager.GO_TO_SLEEP_REASON_POWER_BUTTON, 0); isWakeKey = false; break; } Loading Loading @@ -5252,7 +5254,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { private void applyLidSwitchState() { if (mLidState == LID_CLOSED && mLidControlsSleep) { mPowerManager.goToSleep(SystemClock.uptimeMillis(), PowerManager.GO_TO_SLEEP_REASON_USER, PowerManager.GO_TO_SLEEP_REASON_LID_SWITCH, PowerManager.GO_TO_SLEEP_FLAG_NO_DOZE); } Loading services/core/java/com/android/server/hdmi/HdmiControlService.java +1 −1 Original line number Diff line number Diff line Loading @@ -1585,7 +1585,7 @@ public final class HdmiControlService extends SystemService { assertRunOnServiceThread(); mStandbyMessageReceived = true; PowerManager pm = (PowerManager) getContext().getSystemService(Context.POWER_SERVICE); pm.goToSleep(SystemClock.uptimeMillis()); pm.goToSleep(SystemClock.uptimeMillis(), PowerManager.GO_TO_SLEEP_REASON_HDMI, 0); // PowerManger will send the broadcast Intent.ACTION_SCREEN_OFF and after this gets // the intent, the sequence will continue at onStandby(). } Loading services/core/java/com/android/server/power/PowerManagerService.java +51 −37 Original line number Diff line number Diff line Loading @@ -771,7 +771,7 @@ public final class PowerManagerService extends com.android.server.SystemService notifyAcquire = true; } applyWakeLockFlagsOnAcquireLocked(wakeLock); applyWakeLockFlagsOnAcquireLocked(wakeLock, uid); mDirty |= DIRTY_WAKE_LOCKS; updatePowerStateLocked(); if (notifyAcquire) { Loading @@ -796,10 +796,10 @@ public final class PowerManagerService extends com.android.server.SystemService return false; } private void applyWakeLockFlagsOnAcquireLocked(WakeLock wakeLock) { private void applyWakeLockFlagsOnAcquireLocked(WakeLock wakeLock, int uid) { if ((wakeLock.mFlags & PowerManager.ACQUIRE_CAUSES_WAKEUP) != 0 && isScreenLock(wakeLock)) { wakeUpNoUpdateLocked(SystemClock.uptimeMillis()); wakeUpNoUpdateLocked(SystemClock.uptimeMillis(), uid); } } Loading Loading @@ -994,17 +994,17 @@ public final class PowerManagerService extends com.android.server.SystemService return false; } private void wakeUpInternal(long eventTime) { private void wakeUpInternal(long eventTime, int uid) { synchronized (mLock) { if (wakeUpNoUpdateLocked(eventTime)) { if (wakeUpNoUpdateLocked(eventTime, uid)) { updatePowerStateLocked(); } } } private boolean wakeUpNoUpdateLocked(long eventTime) { private boolean wakeUpNoUpdateLocked(long eventTime, int uid) { if (DEBUG_SPEW) { Slog.d(TAG, "wakeUpNoUpdateLocked: eventTime=" + eventTime); Slog.d(TAG, "wakeUpNoUpdateLocked: eventTime=" + eventTime + ", uid=" + uid); } if (eventTime < mLastSleepTime || mWakefulness == WAKEFULNESS_AWAKE Loading @@ -1014,13 +1014,13 @@ public final class PowerManagerService extends com.android.server.SystemService switch (mWakefulness) { case WAKEFULNESS_ASLEEP: Slog.i(TAG, "Waking up from sleep..."); Slog.i(TAG, "Waking up from sleep (uid " + uid +")..."); break; case WAKEFULNESS_DREAMING: Slog.i(TAG, "Waking up from dream..."); Slog.i(TAG, "Waking up from dream (uid " + uid +")..."); break; case WAKEFULNESS_DOZING: Slog.i(TAG, "Waking up from dozing..."); Slog.i(TAG, "Waking up from dozing (uid " + uid +")..."); break; } Loading @@ -1030,13 +1030,13 @@ public final class PowerManagerService extends com.android.server.SystemService setInteractiveStateLocked(true, 0); userActivityNoUpdateLocked( eventTime, PowerManager.USER_ACTIVITY_EVENT_OTHER, 0, Process.SYSTEM_UID); eventTime, PowerManager.USER_ACTIVITY_EVENT_OTHER, 0, uid); return true; } private void goToSleepInternal(long eventTime, int reason, int flags) { private void goToSleepInternal(long eventTime, int reason, int flags, int uid) { synchronized (mLock) { if (goToSleepNoUpdateLocked(eventTime, reason, flags)) { if (goToSleepNoUpdateLocked(eventTime, reason, flags, uid)) { updatePowerStateLocked(); } } Loading @@ -1045,10 +1045,10 @@ public final class PowerManagerService extends com.android.server.SystemService // This method is called goToSleep for historical reasons but we actually start // dozing before really going to sleep. @SuppressWarnings("deprecation") private boolean goToSleepNoUpdateLocked(long eventTime, int reason, int flags) { private boolean goToSleepNoUpdateLocked(long eventTime, int reason, int flags, int uid) { if (DEBUG_SPEW) { Slog.d(TAG, "goToSleepNoUpdateLocked: eventTime=" + eventTime + ", reason=" + reason + ", flags=" + flags); + ", reason=" + reason + ", flags=" + flags + ", uid=" + uid); } if (eventTime < mLastWakeTime Loading @@ -1060,14 +1060,24 @@ public final class PowerManagerService extends com.android.server.SystemService switch (reason) { case PowerManager.GO_TO_SLEEP_REASON_DEVICE_ADMIN: Slog.i(TAG, "Going to sleep due to device administration policy..."); Slog.i(TAG, "Going to sleep due to device administration policy " + "(uid " + uid +")..."); break; case PowerManager.GO_TO_SLEEP_REASON_TIMEOUT: Slog.i(TAG, "Going to sleep due to screen timeout..."); Slog.i(TAG, "Going to sleep due to screen timeout (uid " + uid +")..."); break; case PowerManager.GO_TO_SLEEP_REASON_LID_SWITCH: Slog.i(TAG, "Going to sleep due to lid switch (uid " + uid +")..."); break; case PowerManager.GO_TO_SLEEP_REASON_POWER_BUTTON: Slog.i(TAG, "Going to sleep due to power button (uid " + uid +")..."); break; case PowerManager.GO_TO_SLEEP_REASON_HDMI: Slog.i(TAG, "Going to sleep due to HDMI standby (uid " + uid +")..."); break; default: Slog.i(TAG, "Going to sleep by user request..."); reason = PowerManager.GO_TO_SLEEP_REASON_USER; Slog.i(TAG, "Going to sleep by application request (uid " + uid +")..."); reason = PowerManager.GO_TO_SLEEP_REASON_APPLICATION; break; } Loading @@ -1094,22 +1104,22 @@ public final class PowerManagerService extends com.android.server.SystemService // Skip dozing if requested. if ((flags & PowerManager.GO_TO_SLEEP_FLAG_NO_DOZE) != 0) { reallyGoToSleepNoUpdateLocked(eventTime); reallyGoToSleepNoUpdateLocked(eventTime, uid); } return true; } private void napInternal(long eventTime) { private void napInternal(long eventTime, int uid) { synchronized (mLock) { if (napNoUpdateLocked(eventTime)) { if (napNoUpdateLocked(eventTime, uid)) { updatePowerStateLocked(); } } } private boolean napNoUpdateLocked(long eventTime) { private boolean napNoUpdateLocked(long eventTime, int uid) { if (DEBUG_SPEW) { Slog.d(TAG, "napNoUpdateLocked: eventTime=" + eventTime); Slog.d(TAG, "napNoUpdateLocked: eventTime=" + eventTime + ", uid=" + uid); } if (eventTime < mLastWakeTime || mWakefulness != WAKEFULNESS_AWAKE Loading @@ -1117,7 +1127,7 @@ public final class PowerManagerService extends com.android.server.SystemService return false; } Slog.i(TAG, "Nap time..."); Slog.i(TAG, "Nap time (uid " + uid +")..."); mDirty |= DIRTY_WAKEFULNESS; mWakefulness = WAKEFULNESS_DREAMING; Loading @@ -1127,9 +1137,10 @@ public final class PowerManagerService extends com.android.server.SystemService } // Done dozing, drop everything and go to sleep. private boolean reallyGoToSleepNoUpdateLocked(long eventTime) { private boolean reallyGoToSleepNoUpdateLocked(long eventTime, int uid) { if (DEBUG_SPEW) { Slog.d(TAG, "reallyGoToSleepNoUpdateLocked: eventTime=" + eventTime); Slog.d(TAG, "reallyGoToSleepNoUpdateLocked: eventTime=" + eventTime + ", uid=" + uid); } if (eventTime < mLastWakeTime || mWakefulness == WAKEFULNESS_ASLEEP Loading @@ -1137,7 +1148,7 @@ public final class PowerManagerService extends com.android.server.SystemService return false; } Slog.i(TAG, "Sleeping..."); Slog.i(TAG, "Sleeping (uid " + uid +")..."); mDirty |= DIRTY_WAKEFULNESS; mWakefulness = WAKEFULNESS_ASLEEP; Loading Loading @@ -1251,7 +1262,7 @@ public final class PowerManagerService extends com.android.server.SystemService final long now = SystemClock.uptimeMillis(); if (shouldWakeUpWhenPluggedOrUnpluggedLocked(wasPowered, oldPlugType, dockedOnWirelessCharger)) { wakeUpNoUpdateLocked(now); wakeUpNoUpdateLocked(now, Process.SYSTEM_UID); } userActivityNoUpdateLocked( now, PowerManager.USER_ACTIVITY_EVENT_OTHER, 0, Process.SYSTEM_UID); Loading Loading @@ -1509,10 +1520,10 @@ public final class PowerManagerService extends com.android.server.SystemService } final long time = SystemClock.uptimeMillis(); if (shouldNapAtBedTimeLocked()) { changed = napNoUpdateLocked(time); changed = napNoUpdateLocked(time, Process.SYSTEM_UID); } else { changed = goToSleepNoUpdateLocked(time, PowerManager.GO_TO_SLEEP_REASON_TIMEOUT, 0); PowerManager.GO_TO_SLEEP_REASON_TIMEOUT, 0, Process.SYSTEM_UID); } } } Loading Loading @@ -1659,10 +1670,10 @@ public final class PowerManagerService extends com.android.server.SystemService // Dream has ended or will be stopped. Update the power state. if (isItBedTimeYetLocked()) { goToSleepNoUpdateLocked(SystemClock.uptimeMillis(), PowerManager.GO_TO_SLEEP_REASON_TIMEOUT, 0); PowerManager.GO_TO_SLEEP_REASON_TIMEOUT, 0, Process.SYSTEM_UID); updatePowerStateLocked(); } else { wakeUpNoUpdateLocked(SystemClock.uptimeMillis()); wakeUpNoUpdateLocked(SystemClock.uptimeMillis(), Process.SYSTEM_UID); updatePowerStateLocked(); } } else if (wakefulness == WAKEFULNESS_DOZING) { Loading @@ -1671,7 +1682,7 @@ public final class PowerManagerService extends com.android.server.SystemService } // Doze has ended or will be stopped. Update the power state. reallyGoToSleepNoUpdateLocked(SystemClock.uptimeMillis()); reallyGoToSleepNoUpdateLocked(SystemClock.uptimeMillis(), Process.SYSTEM_UID); updatePowerStateLocked(); } } Loading Loading @@ -2852,9 +2863,10 @@ public final class PowerManagerService extends com.android.server.SystemService mContext.enforceCallingOrSelfPermission( android.Manifest.permission.DEVICE_POWER, null); final int uid = Binder.getCallingUid(); final long ident = Binder.clearCallingIdentity(); try { wakeUpInternal(eventTime); wakeUpInternal(eventTime, uid); } finally { Binder.restoreCallingIdentity(ident); } Loading @@ -2869,9 +2881,10 @@ public final class PowerManagerService extends com.android.server.SystemService mContext.enforceCallingOrSelfPermission( android.Manifest.permission.DEVICE_POWER, null); final int uid = Binder.getCallingUid(); final long ident = Binder.clearCallingIdentity(); try { goToSleepInternal(eventTime, reason, flags); goToSleepInternal(eventTime, reason, flags, uid); } finally { Binder.restoreCallingIdentity(ident); } Loading @@ -2886,9 +2899,10 @@ public final class PowerManagerService extends com.android.server.SystemService mContext.enforceCallingOrSelfPermission( android.Manifest.permission.DEVICE_POWER, null); final int uid = Binder.getCallingUid(); final long ident = Binder.clearCallingIdentity(); try { napInternal(eventTime); napInternal(eventTime, uid); } finally { Binder.restoreCallingIdentity(ident); } Loading Loading
core/java/android/os/PowerManager.java +21 −3 Original line number Diff line number Diff line Loading @@ -298,10 +298,10 @@ public final class PowerManager { public static final int USER_ACTIVITY_FLAG_NO_CHANGE_LIGHTS = 1 << 0; /** * Go to sleep reason code: Going to sleep due by user request. * Go to sleep reason code: Going to sleep due by application request. * @hide */ public static final int GO_TO_SLEEP_REASON_USER = 0; public static final int GO_TO_SLEEP_REASON_APPLICATION = 0; /** * Go to sleep reason code: Going to sleep due by request of the Loading @@ -316,6 +316,24 @@ public final class PowerManager { */ public static final int GO_TO_SLEEP_REASON_TIMEOUT = 2; /** * Go to sleep reason code: Going to sleep due to the lid switch being closed. * @hide */ public static final int GO_TO_SLEEP_REASON_LID_SWITCH = 3; /** * Go to sleep reason code: Going to sleep due to the power button being pressed. * @hide */ public static final int GO_TO_SLEEP_REASON_POWER_BUTTON = 4; /** * Go to sleep reason code: Going to sleep due to HDMI. * @hide */ public static final int GO_TO_SLEEP_REASON_HDMI = 5; /** * The value to pass as the 'reason' argument to reboot() to * reboot into recovery mode (for applying system updates, doing Loading Loading @@ -513,7 +531,7 @@ public final class PowerManager { * @see #wakeUp */ public void goToSleep(long time) { goToSleep(time, GO_TO_SLEEP_REASON_USER, 0); goToSleep(time, GO_TO_SLEEP_REASON_APPLICATION, 0); } /** Loading
policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +8 −6 Original line number Diff line number Diff line Loading @@ -845,16 +845,16 @@ public class PhoneWindowManager implements WindowManagerPolicy { break; case SHORT_PRESS_POWER_GO_TO_SLEEP: mPowerManager.goToSleep(eventTime, PowerManager.GO_TO_SLEEP_REASON_USER, 0); PowerManager.GO_TO_SLEEP_REASON_POWER_BUTTON, 0); break; case SHORT_PRESS_POWER_REALLY_GO_TO_SLEEP: mPowerManager.goToSleep(eventTime, PowerManager.GO_TO_SLEEP_REASON_USER, PowerManager.GO_TO_SLEEP_REASON_POWER_BUTTON, PowerManager.GO_TO_SLEEP_FLAG_NO_DOZE); break; case SHORT_PRESS_POWER_REALLY_GO_TO_SLEEP_AND_GO_HOME: mPowerManager.goToSleep(eventTime, PowerManager.GO_TO_SLEEP_REASON_USER, PowerManager.GO_TO_SLEEP_REASON_POWER_BUTTON, PowerManager.GO_TO_SLEEP_FLAG_NO_DOZE); launchHomeFromHotKey(); break; Loading Loading @@ -4290,7 +4290,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { } if ((mEndcallBehavior & Settings.System.END_BUTTON_BEHAVIOR_SLEEP) != 0) { mPowerManager.goToSleep(event.getEventTime()); mPowerManager.goToSleep(event.getEventTime(), PowerManager.GO_TO_SLEEP_REASON_POWER_BUTTON, 0); isWakeKey = false; } } Loading Loading @@ -4347,7 +4348,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { if (!mPowerManager.isInteractive()) { useHapticFeedback = false; // suppress feedback if already non-interactive } mPowerManager.goToSleep(event.getEventTime()); mPowerManager.goToSleep(event.getEventTime(), PowerManager.GO_TO_SLEEP_REASON_POWER_BUTTON, 0); isWakeKey = false; break; } Loading Loading @@ -5252,7 +5254,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { private void applyLidSwitchState() { if (mLidState == LID_CLOSED && mLidControlsSleep) { mPowerManager.goToSleep(SystemClock.uptimeMillis(), PowerManager.GO_TO_SLEEP_REASON_USER, PowerManager.GO_TO_SLEEP_REASON_LID_SWITCH, PowerManager.GO_TO_SLEEP_FLAG_NO_DOZE); } Loading
services/core/java/com/android/server/hdmi/HdmiControlService.java +1 −1 Original line number Diff line number Diff line Loading @@ -1585,7 +1585,7 @@ public final class HdmiControlService extends SystemService { assertRunOnServiceThread(); mStandbyMessageReceived = true; PowerManager pm = (PowerManager) getContext().getSystemService(Context.POWER_SERVICE); pm.goToSleep(SystemClock.uptimeMillis()); pm.goToSleep(SystemClock.uptimeMillis(), PowerManager.GO_TO_SLEEP_REASON_HDMI, 0); // PowerManger will send the broadcast Intent.ACTION_SCREEN_OFF and after this gets // the intent, the sequence will continue at onStandby(). } Loading
services/core/java/com/android/server/power/PowerManagerService.java +51 −37 Original line number Diff line number Diff line Loading @@ -771,7 +771,7 @@ public final class PowerManagerService extends com.android.server.SystemService notifyAcquire = true; } applyWakeLockFlagsOnAcquireLocked(wakeLock); applyWakeLockFlagsOnAcquireLocked(wakeLock, uid); mDirty |= DIRTY_WAKE_LOCKS; updatePowerStateLocked(); if (notifyAcquire) { Loading @@ -796,10 +796,10 @@ public final class PowerManagerService extends com.android.server.SystemService return false; } private void applyWakeLockFlagsOnAcquireLocked(WakeLock wakeLock) { private void applyWakeLockFlagsOnAcquireLocked(WakeLock wakeLock, int uid) { if ((wakeLock.mFlags & PowerManager.ACQUIRE_CAUSES_WAKEUP) != 0 && isScreenLock(wakeLock)) { wakeUpNoUpdateLocked(SystemClock.uptimeMillis()); wakeUpNoUpdateLocked(SystemClock.uptimeMillis(), uid); } } Loading Loading @@ -994,17 +994,17 @@ public final class PowerManagerService extends com.android.server.SystemService return false; } private void wakeUpInternal(long eventTime) { private void wakeUpInternal(long eventTime, int uid) { synchronized (mLock) { if (wakeUpNoUpdateLocked(eventTime)) { if (wakeUpNoUpdateLocked(eventTime, uid)) { updatePowerStateLocked(); } } } private boolean wakeUpNoUpdateLocked(long eventTime) { private boolean wakeUpNoUpdateLocked(long eventTime, int uid) { if (DEBUG_SPEW) { Slog.d(TAG, "wakeUpNoUpdateLocked: eventTime=" + eventTime); Slog.d(TAG, "wakeUpNoUpdateLocked: eventTime=" + eventTime + ", uid=" + uid); } if (eventTime < mLastSleepTime || mWakefulness == WAKEFULNESS_AWAKE Loading @@ -1014,13 +1014,13 @@ public final class PowerManagerService extends com.android.server.SystemService switch (mWakefulness) { case WAKEFULNESS_ASLEEP: Slog.i(TAG, "Waking up from sleep..."); Slog.i(TAG, "Waking up from sleep (uid " + uid +")..."); break; case WAKEFULNESS_DREAMING: Slog.i(TAG, "Waking up from dream..."); Slog.i(TAG, "Waking up from dream (uid " + uid +")..."); break; case WAKEFULNESS_DOZING: Slog.i(TAG, "Waking up from dozing..."); Slog.i(TAG, "Waking up from dozing (uid " + uid +")..."); break; } Loading @@ -1030,13 +1030,13 @@ public final class PowerManagerService extends com.android.server.SystemService setInteractiveStateLocked(true, 0); userActivityNoUpdateLocked( eventTime, PowerManager.USER_ACTIVITY_EVENT_OTHER, 0, Process.SYSTEM_UID); eventTime, PowerManager.USER_ACTIVITY_EVENT_OTHER, 0, uid); return true; } private void goToSleepInternal(long eventTime, int reason, int flags) { private void goToSleepInternal(long eventTime, int reason, int flags, int uid) { synchronized (mLock) { if (goToSleepNoUpdateLocked(eventTime, reason, flags)) { if (goToSleepNoUpdateLocked(eventTime, reason, flags, uid)) { updatePowerStateLocked(); } } Loading @@ -1045,10 +1045,10 @@ public final class PowerManagerService extends com.android.server.SystemService // This method is called goToSleep for historical reasons but we actually start // dozing before really going to sleep. @SuppressWarnings("deprecation") private boolean goToSleepNoUpdateLocked(long eventTime, int reason, int flags) { private boolean goToSleepNoUpdateLocked(long eventTime, int reason, int flags, int uid) { if (DEBUG_SPEW) { Slog.d(TAG, "goToSleepNoUpdateLocked: eventTime=" + eventTime + ", reason=" + reason + ", flags=" + flags); + ", reason=" + reason + ", flags=" + flags + ", uid=" + uid); } if (eventTime < mLastWakeTime Loading @@ -1060,14 +1060,24 @@ public final class PowerManagerService extends com.android.server.SystemService switch (reason) { case PowerManager.GO_TO_SLEEP_REASON_DEVICE_ADMIN: Slog.i(TAG, "Going to sleep due to device administration policy..."); Slog.i(TAG, "Going to sleep due to device administration policy " + "(uid " + uid +")..."); break; case PowerManager.GO_TO_SLEEP_REASON_TIMEOUT: Slog.i(TAG, "Going to sleep due to screen timeout..."); Slog.i(TAG, "Going to sleep due to screen timeout (uid " + uid +")..."); break; case PowerManager.GO_TO_SLEEP_REASON_LID_SWITCH: Slog.i(TAG, "Going to sleep due to lid switch (uid " + uid +")..."); break; case PowerManager.GO_TO_SLEEP_REASON_POWER_BUTTON: Slog.i(TAG, "Going to sleep due to power button (uid " + uid +")..."); break; case PowerManager.GO_TO_SLEEP_REASON_HDMI: Slog.i(TAG, "Going to sleep due to HDMI standby (uid " + uid +")..."); break; default: Slog.i(TAG, "Going to sleep by user request..."); reason = PowerManager.GO_TO_SLEEP_REASON_USER; Slog.i(TAG, "Going to sleep by application request (uid " + uid +")..."); reason = PowerManager.GO_TO_SLEEP_REASON_APPLICATION; break; } Loading @@ -1094,22 +1104,22 @@ public final class PowerManagerService extends com.android.server.SystemService // Skip dozing if requested. if ((flags & PowerManager.GO_TO_SLEEP_FLAG_NO_DOZE) != 0) { reallyGoToSleepNoUpdateLocked(eventTime); reallyGoToSleepNoUpdateLocked(eventTime, uid); } return true; } private void napInternal(long eventTime) { private void napInternal(long eventTime, int uid) { synchronized (mLock) { if (napNoUpdateLocked(eventTime)) { if (napNoUpdateLocked(eventTime, uid)) { updatePowerStateLocked(); } } } private boolean napNoUpdateLocked(long eventTime) { private boolean napNoUpdateLocked(long eventTime, int uid) { if (DEBUG_SPEW) { Slog.d(TAG, "napNoUpdateLocked: eventTime=" + eventTime); Slog.d(TAG, "napNoUpdateLocked: eventTime=" + eventTime + ", uid=" + uid); } if (eventTime < mLastWakeTime || mWakefulness != WAKEFULNESS_AWAKE Loading @@ -1117,7 +1127,7 @@ public final class PowerManagerService extends com.android.server.SystemService return false; } Slog.i(TAG, "Nap time..."); Slog.i(TAG, "Nap time (uid " + uid +")..."); mDirty |= DIRTY_WAKEFULNESS; mWakefulness = WAKEFULNESS_DREAMING; Loading @@ -1127,9 +1137,10 @@ public final class PowerManagerService extends com.android.server.SystemService } // Done dozing, drop everything and go to sleep. private boolean reallyGoToSleepNoUpdateLocked(long eventTime) { private boolean reallyGoToSleepNoUpdateLocked(long eventTime, int uid) { if (DEBUG_SPEW) { Slog.d(TAG, "reallyGoToSleepNoUpdateLocked: eventTime=" + eventTime); Slog.d(TAG, "reallyGoToSleepNoUpdateLocked: eventTime=" + eventTime + ", uid=" + uid); } if (eventTime < mLastWakeTime || mWakefulness == WAKEFULNESS_ASLEEP Loading @@ -1137,7 +1148,7 @@ public final class PowerManagerService extends com.android.server.SystemService return false; } Slog.i(TAG, "Sleeping..."); Slog.i(TAG, "Sleeping (uid " + uid +")..."); mDirty |= DIRTY_WAKEFULNESS; mWakefulness = WAKEFULNESS_ASLEEP; Loading Loading @@ -1251,7 +1262,7 @@ public final class PowerManagerService extends com.android.server.SystemService final long now = SystemClock.uptimeMillis(); if (shouldWakeUpWhenPluggedOrUnpluggedLocked(wasPowered, oldPlugType, dockedOnWirelessCharger)) { wakeUpNoUpdateLocked(now); wakeUpNoUpdateLocked(now, Process.SYSTEM_UID); } userActivityNoUpdateLocked( now, PowerManager.USER_ACTIVITY_EVENT_OTHER, 0, Process.SYSTEM_UID); Loading Loading @@ -1509,10 +1520,10 @@ public final class PowerManagerService extends com.android.server.SystemService } final long time = SystemClock.uptimeMillis(); if (shouldNapAtBedTimeLocked()) { changed = napNoUpdateLocked(time); changed = napNoUpdateLocked(time, Process.SYSTEM_UID); } else { changed = goToSleepNoUpdateLocked(time, PowerManager.GO_TO_SLEEP_REASON_TIMEOUT, 0); PowerManager.GO_TO_SLEEP_REASON_TIMEOUT, 0, Process.SYSTEM_UID); } } } Loading Loading @@ -1659,10 +1670,10 @@ public final class PowerManagerService extends com.android.server.SystemService // Dream has ended or will be stopped. Update the power state. if (isItBedTimeYetLocked()) { goToSleepNoUpdateLocked(SystemClock.uptimeMillis(), PowerManager.GO_TO_SLEEP_REASON_TIMEOUT, 0); PowerManager.GO_TO_SLEEP_REASON_TIMEOUT, 0, Process.SYSTEM_UID); updatePowerStateLocked(); } else { wakeUpNoUpdateLocked(SystemClock.uptimeMillis()); wakeUpNoUpdateLocked(SystemClock.uptimeMillis(), Process.SYSTEM_UID); updatePowerStateLocked(); } } else if (wakefulness == WAKEFULNESS_DOZING) { Loading @@ -1671,7 +1682,7 @@ public final class PowerManagerService extends com.android.server.SystemService } // Doze has ended or will be stopped. Update the power state. reallyGoToSleepNoUpdateLocked(SystemClock.uptimeMillis()); reallyGoToSleepNoUpdateLocked(SystemClock.uptimeMillis(), Process.SYSTEM_UID); updatePowerStateLocked(); } } Loading Loading @@ -2852,9 +2863,10 @@ public final class PowerManagerService extends com.android.server.SystemService mContext.enforceCallingOrSelfPermission( android.Manifest.permission.DEVICE_POWER, null); final int uid = Binder.getCallingUid(); final long ident = Binder.clearCallingIdentity(); try { wakeUpInternal(eventTime); wakeUpInternal(eventTime, uid); } finally { Binder.restoreCallingIdentity(ident); } Loading @@ -2869,9 +2881,10 @@ public final class PowerManagerService extends com.android.server.SystemService mContext.enforceCallingOrSelfPermission( android.Manifest.permission.DEVICE_POWER, null); final int uid = Binder.getCallingUid(); final long ident = Binder.clearCallingIdentity(); try { goToSleepInternal(eventTime, reason, flags); goToSleepInternal(eventTime, reason, flags, uid); } finally { Binder.restoreCallingIdentity(ident); } Loading @@ -2886,9 +2899,10 @@ public final class PowerManagerService extends com.android.server.SystemService mContext.enforceCallingOrSelfPermission( android.Manifest.permission.DEVICE_POWER, null); final int uid = Binder.getCallingUid(); final long ident = Binder.clearCallingIdentity(); try { napInternal(eventTime); napInternal(eventTime, uid); } finally { Binder.restoreCallingIdentity(ident); } Loading