Loading core/java/android/os/PowerManager.java +19 −0 Original line number Diff line number Diff line Loading @@ -525,6 +525,25 @@ public final class PowerManager { @Retention(RetentionPolicy.SOURCE) public @interface WakeReason{} /** * @hide */ @IntDef(prefix = { "GO_TO_SLEEP_REASON_" }, value = { GO_TO_SLEEP_REASON_APPLICATION, GO_TO_SLEEP_REASON_DEVICE_ADMIN, GO_TO_SLEEP_REASON_TIMEOUT, GO_TO_SLEEP_REASON_LID_SWITCH, GO_TO_SLEEP_REASON_POWER_BUTTON, GO_TO_SLEEP_REASON_HDMI, GO_TO_SLEEP_REASON_SLEEP_BUTTON, GO_TO_SLEEP_REASON_ACCESSIBILITY, GO_TO_SLEEP_REASON_FORCE_SUSPEND, GO_TO_SLEEP_REASON_INATTENTIVE, GO_TO_SLEEP_REASON_QUIESCENT }) @Retention(RetentionPolicy.SOURCE) public @interface GoToSleepReason{} /** * Wake up reason code: Waking for an unknown reason. * @hide Loading core/java/android/view/WindowManagerPolicyConstants.java +39 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.view; import android.annotation.IntDef; import android.os.PowerManager; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; Loading Loading @@ -108,6 +109,27 @@ public interface WindowManagerPolicyConstants { void onPointerEvent(MotionEvent motionEvent); } @IntDef(prefix = { "OFF_BECAUSE_OF_" }, value = { OFF_BECAUSE_OF_ADMIN, OFF_BECAUSE_OF_USER, OFF_BECAUSE_OF_TIMEOUT, }) @Retention(RetentionPolicy.SOURCE) public @interface OffReason{} static @OffReason int translateSleepReasonToOffReason( @PowerManager.GoToSleepReason int reason) { switch (reason) { case PowerManager.GO_TO_SLEEP_REASON_DEVICE_ADMIN: return OFF_BECAUSE_OF_ADMIN; case PowerManager.GO_TO_SLEEP_REASON_TIMEOUT: case PowerManager.GO_TO_SLEEP_REASON_INATTENTIVE: return OFF_BECAUSE_OF_TIMEOUT; default: return OFF_BECAUSE_OF_USER; } } /** Screen turned off because of a device admin */ int OFF_BECAUSE_OF_ADMIN = 1; /** Screen turned off because of power button */ Loading Loading @@ -137,6 +159,23 @@ public interface WindowManagerPolicyConstants { } } static @OnReason int translateWakeReasonToOnReason(@PowerManager.WakeReason int reason) { switch (reason) { case PowerManager.WAKE_REASON_POWER_BUTTON: case PowerManager.WAKE_REASON_PLUGGED_IN: case PowerManager.WAKE_REASON_GESTURE: case PowerManager.WAKE_REASON_CAMERA_LAUNCH: case PowerManager.WAKE_REASON_WAKE_KEY: case PowerManager.WAKE_REASON_WAKE_MOTION: case PowerManager.WAKE_REASON_LID: return ON_BECAUSE_OF_USER; case PowerManager.WAKE_REASON_APPLICATION: return ON_BECAUSE_OF_APPLICATION; default: return ON_BECAUSE_OF_UNKNOWN; } } /** Screen turned on because of a user-initiated action. */ int ON_BECAUSE_OF_USER = 1; /** Screen turned on because of an application request or event */ Loading core/java/com/android/internal/policy/IKeyguardService.aidl +10 −7 Original line number Diff line number Diff line Loading @@ -42,26 +42,29 @@ oneway interface IKeyguardService { /** * Called when the device has started going to sleep. * * @param why {@link #OFF_BECAUSE_OF_USER}, {@link #OFF_BECAUSE_OF_ADMIN}, * or {@link #OFF_BECAUSE_OF_TIMEOUT}. * @param pmSleepReason One of PowerManager.GO_TO_SLEEP_REASON_*, detailing the specific reason * we're going to sleep, such as GO_TO_SLEEP_REASON_POWER_BUTTON or GO_TO_SLEEP_REASON_TIMEOUT. */ void onStartedGoingToSleep(int reason); void onStartedGoingToSleep(int pmSleepReason); /** * Called when the device has finished going to sleep. * * @param why {@link #OFF_BECAUSE_OF_USER}, {@link #OFF_BECAUSE_OF_ADMIN}, * or {@link #OFF_BECAUSE_OF_TIMEOUT}. * @param pmSleepReason One of PowerManager.GO_TO_SLEEP_REASON_*, detailing the specific reason * we're going to sleep, such as GO_TO_SLEEP_REASON_POWER_BUTTON or GO_TO_SLEEP_REASON_TIMEOUT. * @param cameraGestureTriggered whether the camera gesture was triggered between * {@link #onStartedGoingToSleep} and this method; if it's been * triggered, we shouldn't lock the device. */ void onFinishedGoingToSleep(int reason, boolean cameraGestureTriggered); void onFinishedGoingToSleep(int pmSleepReason, boolean cameraGestureTriggered); /** * Called when the device has started waking up. * @param pmWakeReason One of PowerManager.WAKE_REASON_*, detailing the reason we're waking up, * such as WAKE_REASON_POWER_BUTTON or WAKE_REASON_GESTURE. */ void onStartedWakingUp(); void onStartedWakingUp(int pmWakeReason); /** * Called when the device has finished waking up. Loading packages/SystemUI/src/com/android/systemui/keyguard/KeyguardLifecyclesDispatcher.java +14 −2 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.systemui.keyguard; import android.os.Handler; import android.os.Message; import android.os.PowerManager; import com.android.systemui.dagger.SysUISingleton; Loading Loading @@ -53,6 +54,17 @@ public class KeyguardLifecyclesDispatcher { mHandler.obtainMessage(what).sendToTarget(); } /** * @param what Message to send. * @param pmReason Reason this message was triggered - this should be a value from either * {@link PowerManager.WakeReason} or {@link PowerManager.GoToSleepReason}. */ void dispatch(int what, int pmReason) { final Message message = mHandler.obtainMessage(what); message.arg1 = pmReason; message.sendToTarget(); } private Handler mHandler = new Handler() { @Override public void handleMessage(Message msg) { Loading @@ -70,13 +82,13 @@ public class KeyguardLifecyclesDispatcher { mScreenLifecycle.dispatchScreenTurnedOff(); break; case STARTED_WAKING_UP: mWakefulnessLifecycle.dispatchStartedWakingUp(); mWakefulnessLifecycle.dispatchStartedWakingUp(msg.arg1 /* pmReason */); break; case FINISHED_WAKING_UP: mWakefulnessLifecycle.dispatchFinishedWakingUp(); break; case STARTED_GOING_TO_SLEEP: mWakefulnessLifecycle.dispatchStartedGoingToSleep(); mWakefulnessLifecycle.dispatchStartedGoingToSleep(msg.arg1 /* pmReason */); break; case FINISHED_GOING_TO_SLEEP: mWakefulnessLifecycle.dispatchFinishedGoingToSleep(); Loading packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java +14 −7 Original line number Diff line number Diff line Loading @@ -24,9 +24,11 @@ import android.os.Binder; import android.os.Bundle; import android.os.Debug; import android.os.IBinder; import android.os.PowerManager; import android.os.Process; import android.os.Trace; import android.util.Log; import android.view.WindowManagerPolicyConstants; import com.android.internal.policy.IKeyguardDismissCallback; import com.android.internal.policy.IKeyguardDrawnCallback; Loading Loading @@ -117,27 +119,32 @@ public class KeyguardService extends Service { } @Override // Binder interface public void onStartedGoingToSleep(int reason) { public void onStartedGoingToSleep(@PowerManager.GoToSleepReason int pmSleepReason) { checkPermission(); mKeyguardViewMediator.onStartedGoingToSleep(reason); mKeyguardViewMediator.onStartedGoingToSleep( WindowManagerPolicyConstants.translateSleepReasonToOffReason(pmSleepReason)); mKeyguardLifecyclesDispatcher.dispatch( KeyguardLifecyclesDispatcher.STARTED_GOING_TO_SLEEP); KeyguardLifecyclesDispatcher.STARTED_GOING_TO_SLEEP, pmSleepReason); } @Override // Binder interface public void onFinishedGoingToSleep(int reason, boolean cameraGestureTriggered) { public void onFinishedGoingToSleep( @PowerManager.GoToSleepReason int pmSleepReason, boolean cameraGestureTriggered) { checkPermission(); mKeyguardViewMediator.onFinishedGoingToSleep(reason, cameraGestureTriggered); mKeyguardViewMediator.onFinishedGoingToSleep( WindowManagerPolicyConstants.translateSleepReasonToOffReason(pmSleepReason), cameraGestureTriggered); mKeyguardLifecyclesDispatcher.dispatch( KeyguardLifecyclesDispatcher.FINISHED_GOING_TO_SLEEP); } @Override // Binder interface public void onStartedWakingUp() { public void onStartedWakingUp(@PowerManager.WakeReason int pmWakeReason) { Trace.beginSection("KeyguardService.mBinder#onStartedWakingUp"); checkPermission(); mKeyguardViewMediator.onStartedWakingUp(); mKeyguardLifecyclesDispatcher.dispatch(KeyguardLifecyclesDispatcher.STARTED_WAKING_UP); mKeyguardLifecyclesDispatcher.dispatch( KeyguardLifecyclesDispatcher.STARTED_WAKING_UP, pmWakeReason); Trace.endSection(); } Loading Loading
core/java/android/os/PowerManager.java +19 −0 Original line number Diff line number Diff line Loading @@ -525,6 +525,25 @@ public final class PowerManager { @Retention(RetentionPolicy.SOURCE) public @interface WakeReason{} /** * @hide */ @IntDef(prefix = { "GO_TO_SLEEP_REASON_" }, value = { GO_TO_SLEEP_REASON_APPLICATION, GO_TO_SLEEP_REASON_DEVICE_ADMIN, GO_TO_SLEEP_REASON_TIMEOUT, GO_TO_SLEEP_REASON_LID_SWITCH, GO_TO_SLEEP_REASON_POWER_BUTTON, GO_TO_SLEEP_REASON_HDMI, GO_TO_SLEEP_REASON_SLEEP_BUTTON, GO_TO_SLEEP_REASON_ACCESSIBILITY, GO_TO_SLEEP_REASON_FORCE_SUSPEND, GO_TO_SLEEP_REASON_INATTENTIVE, GO_TO_SLEEP_REASON_QUIESCENT }) @Retention(RetentionPolicy.SOURCE) public @interface GoToSleepReason{} /** * Wake up reason code: Waking for an unknown reason. * @hide Loading
core/java/android/view/WindowManagerPolicyConstants.java +39 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.view; import android.annotation.IntDef; import android.os.PowerManager; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; Loading Loading @@ -108,6 +109,27 @@ public interface WindowManagerPolicyConstants { void onPointerEvent(MotionEvent motionEvent); } @IntDef(prefix = { "OFF_BECAUSE_OF_" }, value = { OFF_BECAUSE_OF_ADMIN, OFF_BECAUSE_OF_USER, OFF_BECAUSE_OF_TIMEOUT, }) @Retention(RetentionPolicy.SOURCE) public @interface OffReason{} static @OffReason int translateSleepReasonToOffReason( @PowerManager.GoToSleepReason int reason) { switch (reason) { case PowerManager.GO_TO_SLEEP_REASON_DEVICE_ADMIN: return OFF_BECAUSE_OF_ADMIN; case PowerManager.GO_TO_SLEEP_REASON_TIMEOUT: case PowerManager.GO_TO_SLEEP_REASON_INATTENTIVE: return OFF_BECAUSE_OF_TIMEOUT; default: return OFF_BECAUSE_OF_USER; } } /** Screen turned off because of a device admin */ int OFF_BECAUSE_OF_ADMIN = 1; /** Screen turned off because of power button */ Loading Loading @@ -137,6 +159,23 @@ public interface WindowManagerPolicyConstants { } } static @OnReason int translateWakeReasonToOnReason(@PowerManager.WakeReason int reason) { switch (reason) { case PowerManager.WAKE_REASON_POWER_BUTTON: case PowerManager.WAKE_REASON_PLUGGED_IN: case PowerManager.WAKE_REASON_GESTURE: case PowerManager.WAKE_REASON_CAMERA_LAUNCH: case PowerManager.WAKE_REASON_WAKE_KEY: case PowerManager.WAKE_REASON_WAKE_MOTION: case PowerManager.WAKE_REASON_LID: return ON_BECAUSE_OF_USER; case PowerManager.WAKE_REASON_APPLICATION: return ON_BECAUSE_OF_APPLICATION; default: return ON_BECAUSE_OF_UNKNOWN; } } /** Screen turned on because of a user-initiated action. */ int ON_BECAUSE_OF_USER = 1; /** Screen turned on because of an application request or event */ Loading
core/java/com/android/internal/policy/IKeyguardService.aidl +10 −7 Original line number Diff line number Diff line Loading @@ -42,26 +42,29 @@ oneway interface IKeyguardService { /** * Called when the device has started going to sleep. * * @param why {@link #OFF_BECAUSE_OF_USER}, {@link #OFF_BECAUSE_OF_ADMIN}, * or {@link #OFF_BECAUSE_OF_TIMEOUT}. * @param pmSleepReason One of PowerManager.GO_TO_SLEEP_REASON_*, detailing the specific reason * we're going to sleep, such as GO_TO_SLEEP_REASON_POWER_BUTTON or GO_TO_SLEEP_REASON_TIMEOUT. */ void onStartedGoingToSleep(int reason); void onStartedGoingToSleep(int pmSleepReason); /** * Called when the device has finished going to sleep. * * @param why {@link #OFF_BECAUSE_OF_USER}, {@link #OFF_BECAUSE_OF_ADMIN}, * or {@link #OFF_BECAUSE_OF_TIMEOUT}. * @param pmSleepReason One of PowerManager.GO_TO_SLEEP_REASON_*, detailing the specific reason * we're going to sleep, such as GO_TO_SLEEP_REASON_POWER_BUTTON or GO_TO_SLEEP_REASON_TIMEOUT. * @param cameraGestureTriggered whether the camera gesture was triggered between * {@link #onStartedGoingToSleep} and this method; if it's been * triggered, we shouldn't lock the device. */ void onFinishedGoingToSleep(int reason, boolean cameraGestureTriggered); void onFinishedGoingToSleep(int pmSleepReason, boolean cameraGestureTriggered); /** * Called when the device has started waking up. * @param pmWakeReason One of PowerManager.WAKE_REASON_*, detailing the reason we're waking up, * such as WAKE_REASON_POWER_BUTTON or WAKE_REASON_GESTURE. */ void onStartedWakingUp(); void onStartedWakingUp(int pmWakeReason); /** * Called when the device has finished waking up. Loading
packages/SystemUI/src/com/android/systemui/keyguard/KeyguardLifecyclesDispatcher.java +14 −2 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.systemui.keyguard; import android.os.Handler; import android.os.Message; import android.os.PowerManager; import com.android.systemui.dagger.SysUISingleton; Loading Loading @@ -53,6 +54,17 @@ public class KeyguardLifecyclesDispatcher { mHandler.obtainMessage(what).sendToTarget(); } /** * @param what Message to send. * @param pmReason Reason this message was triggered - this should be a value from either * {@link PowerManager.WakeReason} or {@link PowerManager.GoToSleepReason}. */ void dispatch(int what, int pmReason) { final Message message = mHandler.obtainMessage(what); message.arg1 = pmReason; message.sendToTarget(); } private Handler mHandler = new Handler() { @Override public void handleMessage(Message msg) { Loading @@ -70,13 +82,13 @@ public class KeyguardLifecyclesDispatcher { mScreenLifecycle.dispatchScreenTurnedOff(); break; case STARTED_WAKING_UP: mWakefulnessLifecycle.dispatchStartedWakingUp(); mWakefulnessLifecycle.dispatchStartedWakingUp(msg.arg1 /* pmReason */); break; case FINISHED_WAKING_UP: mWakefulnessLifecycle.dispatchFinishedWakingUp(); break; case STARTED_GOING_TO_SLEEP: mWakefulnessLifecycle.dispatchStartedGoingToSleep(); mWakefulnessLifecycle.dispatchStartedGoingToSleep(msg.arg1 /* pmReason */); break; case FINISHED_GOING_TO_SLEEP: mWakefulnessLifecycle.dispatchFinishedGoingToSleep(); Loading
packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java +14 −7 Original line number Diff line number Diff line Loading @@ -24,9 +24,11 @@ import android.os.Binder; import android.os.Bundle; import android.os.Debug; import android.os.IBinder; import android.os.PowerManager; import android.os.Process; import android.os.Trace; import android.util.Log; import android.view.WindowManagerPolicyConstants; import com.android.internal.policy.IKeyguardDismissCallback; import com.android.internal.policy.IKeyguardDrawnCallback; Loading Loading @@ -117,27 +119,32 @@ public class KeyguardService extends Service { } @Override // Binder interface public void onStartedGoingToSleep(int reason) { public void onStartedGoingToSleep(@PowerManager.GoToSleepReason int pmSleepReason) { checkPermission(); mKeyguardViewMediator.onStartedGoingToSleep(reason); mKeyguardViewMediator.onStartedGoingToSleep( WindowManagerPolicyConstants.translateSleepReasonToOffReason(pmSleepReason)); mKeyguardLifecyclesDispatcher.dispatch( KeyguardLifecyclesDispatcher.STARTED_GOING_TO_SLEEP); KeyguardLifecyclesDispatcher.STARTED_GOING_TO_SLEEP, pmSleepReason); } @Override // Binder interface public void onFinishedGoingToSleep(int reason, boolean cameraGestureTriggered) { public void onFinishedGoingToSleep( @PowerManager.GoToSleepReason int pmSleepReason, boolean cameraGestureTriggered) { checkPermission(); mKeyguardViewMediator.onFinishedGoingToSleep(reason, cameraGestureTriggered); mKeyguardViewMediator.onFinishedGoingToSleep( WindowManagerPolicyConstants.translateSleepReasonToOffReason(pmSleepReason), cameraGestureTriggered); mKeyguardLifecyclesDispatcher.dispatch( KeyguardLifecyclesDispatcher.FINISHED_GOING_TO_SLEEP); } @Override // Binder interface public void onStartedWakingUp() { public void onStartedWakingUp(@PowerManager.WakeReason int pmWakeReason) { Trace.beginSection("KeyguardService.mBinder#onStartedWakingUp"); checkPermission(); mKeyguardViewMediator.onStartedWakingUp(); mKeyguardLifecyclesDispatcher.dispatch(KeyguardLifecyclesDispatcher.STARTED_WAKING_UP); mKeyguardLifecyclesDispatcher.dispatch( KeyguardLifecyclesDispatcher.STARTED_WAKING_UP, pmWakeReason); Trace.endSection(); } Loading