Loading core/java/android/service/dreams/DreamService.java +43 −54 Original line number Diff line number Diff line Loading @@ -455,7 +455,7 @@ public class DreamService extends Service implements Window.Callback { // Simply wake up in the case the device is not locked. if (!keyguardManager.isKeyguardLocked()) { wakeUp(false); wakeUp(); return true; } Loading @@ -477,11 +477,11 @@ public class DreamService extends Service implements Window.Callback { if (!mInteractive) { if (mDebug) Slog.v(mTag, "Waking up on keyEvent"); wakeUp(false); wakeUp(); return true; } else if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { if (mDebug) Slog.v(mTag, "Waking up on back key"); wakeUp(false); wakeUp(); return true; } return mWindow.superDispatchKeyEvent(event); Loading @@ -492,7 +492,7 @@ public class DreamService extends Service implements Window.Callback { public boolean dispatchKeyShortcutEvent(KeyEvent event) { if (!mInteractive) { if (mDebug) Slog.v(mTag, "Waking up on keyShortcutEvent"); wakeUp(false); wakeUp(); return true; } return mWindow.superDispatchKeyShortcutEvent(event); Loading @@ -505,7 +505,7 @@ public class DreamService extends Service implements Window.Callback { // but finish()es on any other kind of activity if (!mInteractive && event.getActionMasked() == MotionEvent.ACTION_UP) { if (mDebug) Slog.v(mTag, "Waking up on touchEvent"); wakeUp(false); wakeUp(); return true; } return mWindow.superDispatchTouchEvent(event); Loading @@ -516,7 +516,7 @@ public class DreamService extends Service implements Window.Callback { public boolean dispatchTrackballEvent(MotionEvent event) { if (!mInteractive) { if (mDebug) Slog.v(mTag, "Waking up on trackballEvent"); wakeUp(false); wakeUp(); return true; } return mWindow.superDispatchTrackballEvent(event); Loading @@ -527,7 +527,7 @@ public class DreamService extends Service implements Window.Callback { public boolean dispatchGenericMotionEvent(MotionEvent event) { if (!mInteractive) { if (mDebug) Slog.v(mTag, "Waking up on genericMotionEvent"); wakeUp(false); wakeUp(); return true; } return mWindow.superDispatchGenericMotionEvent(event); Loading Loading @@ -925,11 +925,7 @@ public class DreamService extends Service implements Window.Callback { } } /** * Updates doze state. Note that this must be called on the mHandler. */ private void updateDoze() { mHandler.post(() -> { private synchronized void updateDoze() { if (mDreamToken == null) { Slog.w(mTag, "Updating doze without a dream token."); return; Loading @@ -955,7 +951,6 @@ public class DreamService extends Service implements Window.Callback { // system server died } } }); } /** Loading @@ -971,7 +966,6 @@ public class DreamService extends Service implements Window.Callback { */ @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) public void stopDozing() { mHandler.post(() -> { if (mDozing) { mDozing = false; try { Loading @@ -980,7 +974,6 @@ public class DreamService extends Service implements Window.Callback { // system server died } } }); } /** Loading Loading @@ -1208,7 +1201,7 @@ public class DreamService extends Service implements Window.Callback { @Override public void onExitRequested() { // Simply finish dream when exit is requested. mHandler.post(() -> finishInternal()); mHandler.post(() -> finish()); } @Override Loading Loading @@ -1306,13 +1299,9 @@ public class DreamService extends Service implements Window.Callback { * </p> */ public final void finish() { mHandler.post(this::finishInternal); } private void finishInternal() { // If there is an active overlay connection, signal that the dream is ending before // continuing. Note that the overlay cannot rely on the unbound state, since another // dream might have bound to it in the meantime. // continuing. Note that the overlay cannot rely on the unbound state, since another dream // might have bound to it in the meantime. if (mOverlayConnection != null) { mOverlayConnection.addConsumer(overlay -> { try { Loading Loading @@ -1368,7 +1357,7 @@ public class DreamService extends Service implements Window.Callback { * </p> */ public final void wakeUp() { mHandler.post(()-> wakeUp(false)); wakeUp(false); } /** Loading Loading @@ -1570,7 +1559,7 @@ public class DreamService extends Service implements Window.Callback { if (mActivity != null && !mActivity.isFinishing()) { mActivity.finishAndRemoveTask(); } else { finishInternal(); finish(); } mDreamToken = null; Loading Loading @@ -1730,7 +1719,7 @@ public class DreamService extends Service implements Window.Callback { // the window reference in order to fully release the DreamActivity. mWindow = null; mActivity = null; finishInternal(); finish(); } if (mOverlayConnection != null && mDreamStartOverlayConsumer != null) { Loading services/tests/dreamservicetests/src/com/android/server/dreams/TestDreamEnvironment.java +0 −1 Original line number Diff line number Diff line Loading @@ -328,7 +328,6 @@ public class TestDreamEnvironment { case DREAM_STATE_STARTED -> startDream(); case DREAM_STATE_WOKEN -> wakeDream(); } mTestableLooper.processAllMessages(); } while (mCurrentDreamState < state); return true; Loading Loading
core/java/android/service/dreams/DreamService.java +43 −54 Original line number Diff line number Diff line Loading @@ -455,7 +455,7 @@ public class DreamService extends Service implements Window.Callback { // Simply wake up in the case the device is not locked. if (!keyguardManager.isKeyguardLocked()) { wakeUp(false); wakeUp(); return true; } Loading @@ -477,11 +477,11 @@ public class DreamService extends Service implements Window.Callback { if (!mInteractive) { if (mDebug) Slog.v(mTag, "Waking up on keyEvent"); wakeUp(false); wakeUp(); return true; } else if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { if (mDebug) Slog.v(mTag, "Waking up on back key"); wakeUp(false); wakeUp(); return true; } return mWindow.superDispatchKeyEvent(event); Loading @@ -492,7 +492,7 @@ public class DreamService extends Service implements Window.Callback { public boolean dispatchKeyShortcutEvent(KeyEvent event) { if (!mInteractive) { if (mDebug) Slog.v(mTag, "Waking up on keyShortcutEvent"); wakeUp(false); wakeUp(); return true; } return mWindow.superDispatchKeyShortcutEvent(event); Loading @@ -505,7 +505,7 @@ public class DreamService extends Service implements Window.Callback { // but finish()es on any other kind of activity if (!mInteractive && event.getActionMasked() == MotionEvent.ACTION_UP) { if (mDebug) Slog.v(mTag, "Waking up on touchEvent"); wakeUp(false); wakeUp(); return true; } return mWindow.superDispatchTouchEvent(event); Loading @@ -516,7 +516,7 @@ public class DreamService extends Service implements Window.Callback { public boolean dispatchTrackballEvent(MotionEvent event) { if (!mInteractive) { if (mDebug) Slog.v(mTag, "Waking up on trackballEvent"); wakeUp(false); wakeUp(); return true; } return mWindow.superDispatchTrackballEvent(event); Loading @@ -527,7 +527,7 @@ public class DreamService extends Service implements Window.Callback { public boolean dispatchGenericMotionEvent(MotionEvent event) { if (!mInteractive) { if (mDebug) Slog.v(mTag, "Waking up on genericMotionEvent"); wakeUp(false); wakeUp(); return true; } return mWindow.superDispatchGenericMotionEvent(event); Loading Loading @@ -925,11 +925,7 @@ public class DreamService extends Service implements Window.Callback { } } /** * Updates doze state. Note that this must be called on the mHandler. */ private void updateDoze() { mHandler.post(() -> { private synchronized void updateDoze() { if (mDreamToken == null) { Slog.w(mTag, "Updating doze without a dream token."); return; Loading @@ -955,7 +951,6 @@ public class DreamService extends Service implements Window.Callback { // system server died } } }); } /** Loading @@ -971,7 +966,6 @@ public class DreamService extends Service implements Window.Callback { */ @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) public void stopDozing() { mHandler.post(() -> { if (mDozing) { mDozing = false; try { Loading @@ -980,7 +974,6 @@ public class DreamService extends Service implements Window.Callback { // system server died } } }); } /** Loading Loading @@ -1208,7 +1201,7 @@ public class DreamService extends Service implements Window.Callback { @Override public void onExitRequested() { // Simply finish dream when exit is requested. mHandler.post(() -> finishInternal()); mHandler.post(() -> finish()); } @Override Loading Loading @@ -1306,13 +1299,9 @@ public class DreamService extends Service implements Window.Callback { * </p> */ public final void finish() { mHandler.post(this::finishInternal); } private void finishInternal() { // If there is an active overlay connection, signal that the dream is ending before // continuing. Note that the overlay cannot rely on the unbound state, since another // dream might have bound to it in the meantime. // continuing. Note that the overlay cannot rely on the unbound state, since another dream // might have bound to it in the meantime. if (mOverlayConnection != null) { mOverlayConnection.addConsumer(overlay -> { try { Loading Loading @@ -1368,7 +1357,7 @@ public class DreamService extends Service implements Window.Callback { * </p> */ public final void wakeUp() { mHandler.post(()-> wakeUp(false)); wakeUp(false); } /** Loading Loading @@ -1570,7 +1559,7 @@ public class DreamService extends Service implements Window.Callback { if (mActivity != null && !mActivity.isFinishing()) { mActivity.finishAndRemoveTask(); } else { finishInternal(); finish(); } mDreamToken = null; Loading Loading @@ -1730,7 +1719,7 @@ public class DreamService extends Service implements Window.Callback { // the window reference in order to fully release the DreamActivity. mWindow = null; mActivity = null; finishInternal(); finish(); } if (mOverlayConnection != null && mDreamStartOverlayConsumer != null) { Loading
services/tests/dreamservicetests/src/com/android/server/dreams/TestDreamEnvironment.java +0 −1 Original line number Diff line number Diff line Loading @@ -328,7 +328,6 @@ public class TestDreamEnvironment { case DREAM_STATE_STARTED -> startDream(); case DREAM_STATE_WOKEN -> wakeDream(); } mTestableLooper.processAllMessages(); } while (mCurrentDreamState < state); return true; Loading