Loading core/java/android/service/dreams/DreamService.java +3 −0 Original line number Diff line number Diff line Loading @@ -1363,6 +1363,9 @@ public class DreamService extends Service implements Window.Callback { * Tells the dream to come to the front (which in turn tells the overlay to come to the front). */ private void comeToFront() { if (mOverlayConnection == null) { return; } mOverlayConnection.addConsumer(overlay -> { try { overlay.comeToFront(); Loading services/tests/dreamservicetests/src/com/android/server/dreams/DreamServiceTest.java +36 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; Loading Loading @@ -215,4 +216,39 @@ public class DreamServiceTest { // Ensure service does not crash from only receiving up event. environment.dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_SPACE)); } @Test @EnableFlags(Flags.FLAG_DREAM_HANDLES_BEING_OBSCURED) public void testComeToFront() throws Exception { TestDreamEnvironment environment = new TestDreamEnvironment.Builder(mTestableLooper) .setDreamOverlayPresent(true) .build(); environment.advance(TestDreamEnvironment.DREAM_STATE_STARTED); // Call comeToFront through binder. environment.resetClientInvocations(); environment.comeToFront(); mTestableLooper.processAllMessages(); // Overlay client receives call. verify(environment.getDreamOverlayClient()).comeToFront(); } @Test @EnableFlags(Flags.FLAG_DREAM_HANDLES_BEING_OBSCURED) public void testComeToFront_noOverlay() throws Exception { // Dream environment with no overlay present TestDreamEnvironment environment = new TestDreamEnvironment.Builder(mTestableLooper) .setDreamOverlayPresent(false) .build(); environment.advance(TestDreamEnvironment.DREAM_STATE_STARTED); // Call comeToFront through binder. environment.resetClientInvocations(); environment.comeToFront(); mTestableLooper.processAllMessages(); // Overlay client receives call. verify(environment.getDreamOverlayClient(), never()).comeToFront(); } } services/tests/dreamservicetests/src/com/android/server/dreams/TestDreamEnvironment.java +5 −1 Original line number Diff line number Diff line Loading @@ -398,10 +398,14 @@ public class TestDreamEnvironment { mService.dispatchKeyEvent(event); } private void wakeDream() throws RemoteException { private void wakeDream() { mService.wakeUp(); } void comeToFront() throws RemoteException { mDreamServiceWrapper.comeToFront(); } /** * Retrieves the dream overlay callback. */ Loading Loading
core/java/android/service/dreams/DreamService.java +3 −0 Original line number Diff line number Diff line Loading @@ -1363,6 +1363,9 @@ public class DreamService extends Service implements Window.Callback { * Tells the dream to come to the front (which in turn tells the overlay to come to the front). */ private void comeToFront() { if (mOverlayConnection == null) { return; } mOverlayConnection.addConsumer(overlay -> { try { overlay.comeToFront(); Loading
services/tests/dreamservicetests/src/com/android/server/dreams/DreamServiceTest.java +36 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; Loading Loading @@ -215,4 +216,39 @@ public class DreamServiceTest { // Ensure service does not crash from only receiving up event. environment.dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_SPACE)); } @Test @EnableFlags(Flags.FLAG_DREAM_HANDLES_BEING_OBSCURED) public void testComeToFront() throws Exception { TestDreamEnvironment environment = new TestDreamEnvironment.Builder(mTestableLooper) .setDreamOverlayPresent(true) .build(); environment.advance(TestDreamEnvironment.DREAM_STATE_STARTED); // Call comeToFront through binder. environment.resetClientInvocations(); environment.comeToFront(); mTestableLooper.processAllMessages(); // Overlay client receives call. verify(environment.getDreamOverlayClient()).comeToFront(); } @Test @EnableFlags(Flags.FLAG_DREAM_HANDLES_BEING_OBSCURED) public void testComeToFront_noOverlay() throws Exception { // Dream environment with no overlay present TestDreamEnvironment environment = new TestDreamEnvironment.Builder(mTestableLooper) .setDreamOverlayPresent(false) .build(); environment.advance(TestDreamEnvironment.DREAM_STATE_STARTED); // Call comeToFront through binder. environment.resetClientInvocations(); environment.comeToFront(); mTestableLooper.processAllMessages(); // Overlay client receives call. verify(environment.getDreamOverlayClient(), never()).comeToFront(); } }
services/tests/dreamservicetests/src/com/android/server/dreams/TestDreamEnvironment.java +5 −1 Original line number Diff line number Diff line Loading @@ -398,10 +398,14 @@ public class TestDreamEnvironment { mService.dispatchKeyEvent(event); } private void wakeDream() throws RemoteException { private void wakeDream() { mService.wakeUp(); } void comeToFront() throws RemoteException { mDreamServiceWrapper.comeToFront(); } /** * Retrieves the dream overlay callback. */ Loading