Loading services/core/java/com/android/server/wm/AppWindowToken.java +3 −3 Original line number Diff line number Diff line Loading @@ -173,10 +173,9 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree boolean showForAllUsers, int targetSdk, int orientation, int rotationAnimationHint, int configChanges, boolean launchTaskBehind, boolean alwaysFocusable, AppWindowContainerController controller) { this(service, token, voiceInteraction, dc); this(service, token, voiceInteraction, dc, fullscreen); setController(controller); mInputDispatchingTimeoutNanos = inputDispatchingTimeoutNanos; mFillsParent = fullscreen; mShowForAllUsers = showForAllUsers; mTargetSdk = targetSdk; mOrientation = orientation; Loading @@ -191,11 +190,12 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree } AppWindowToken(WindowManagerService service, IApplicationToken token, boolean voiceInteraction, DisplayContent dc) { DisplayContent dc, boolean fillsParent) { super(service, token != null ? token.asBinder() : null, TYPE_APPLICATION, true, dc, false /* ownerCanManageAppTokens */); appToken = token; mVoiceInteraction = voiceInteraction; mFillsParent = fillsParent; mInputApplicationHandle = new InputApplicationHandle(this); mAppAnimator = new AppWindowAnimator(this, service); } Loading services/tests/servicestests/src/com/android/server/wm/AppWindowTokenTests.java +5 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.server.wm; import org.junit.Test; import org.junit.Ignore; import org.junit.runner.RunWith; import android.platform.test.annotations.Presubmit; Loading Loading @@ -70,6 +71,7 @@ public class AppWindowTokenTests extends WindowTestsBase { // The base application window should be below all other windows. assertEquals(baseWin, token.getFirstChild()); token.removeImmediately(); } @Test Loading @@ -86,6 +88,7 @@ public class AppWindowTokenTests extends WindowTestsBase { assertEquals(window1, token.findMainWindow()); final WindowState window2 = createWindow(null, TYPE_APPLICATION_STARTING, token, "window2"); assertEquals(window2, token.findMainWindow()); token.removeImmediately(); } @Test Loading Loading @@ -123,6 +126,8 @@ public class AppWindowTokenTests extends WindowTestsBase { } @Test @Ignore // TODO(b/35034729): Need to fix before re-enabling public void testLandscapeSeascapeRotationByPolicy() throws Exception { // Some plumbing to get the service ready for rotation updates. sWm.mDisplayReady = true; Loading services/tests/servicestests/src/com/android/server/wm/TaskPositionerTests.java +9 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.server.wm; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; Loading Loading @@ -77,6 +78,7 @@ public class TaskPositionerTests extends WindowTestsBase { * as does some basic tests (e.g. dragging in Y only will keep X stable). */ @Test @Ignore public void testBasicFreeWindowResizing() throws Exception { final Rect r = new Rect(100, 220, 700, 520); final int midY = (r.top + r.bottom) / 2; Loading Loading @@ -137,6 +139,7 @@ public class TaskPositionerTests extends WindowTestsBase { * This tests that by dragging any edge, the fixed / opposite edge(s) remains anchored. */ @Test @Ignore public void testFreeWindowResizingTestAllEdges() throws Exception { final Rect r = new Rect(100, 220, 700, 520); final int midX = (r.left + r.right) / 2; Loading Loading @@ -221,6 +224,7 @@ public class TaskPositionerTests extends WindowTestsBase { * right things upon resizing when dragged from the top left corner. */ @Test @Ignore public void testLandscapePreservedWindowResizingDragTopLeft() throws Exception { final Rect r = new Rect(100, 220, 700, 520); Loading Loading @@ -258,6 +262,7 @@ public class TaskPositionerTests extends WindowTestsBase { * right things upon resizing when dragged from the left corner. */ @Test @Ignore public void testLandscapePreservedWindowResizingDragLeft() throws Exception { final Rect r = new Rect(100, 220, 700, 520); final int midY = (r.top + r.bottom) / 2; Loading Loading @@ -298,6 +303,7 @@ public class TaskPositionerTests extends WindowTestsBase { * right things upon resizing when dragged from the top corner. */ @Test @Ignore public void testLandscapePreservedWindowResizingDragTop() throws Exception { final Rect r = new Rect(100, 220, 700, 520); final int midX = (r.left + r.right) / 2; Loading Loading @@ -334,6 +340,7 @@ public class TaskPositionerTests extends WindowTestsBase { * right things upon resizing when dragged from the top left corner. */ @Test @Ignore public void testPortraitPreservedWindowResizingDragTopLeft() throws Exception { final Rect r = new Rect(330, 100, 630, 600); Loading Loading @@ -366,6 +373,7 @@ public class TaskPositionerTests extends WindowTestsBase { * right things upon resizing when dragged from the left corner. */ @Test @Ignore public void testPortraitPreservedWindowResizingDragLeft() throws Exception { final Rect r = new Rect(330, 100, 630, 600); final int midY = (r.top + r.bottom) / 2; Loading Loading @@ -408,6 +416,7 @@ public class TaskPositionerTests extends WindowTestsBase { * right things upon resizing when dragged from the top corner. */ @Test @Ignore public void testPortraitPreservedWindowResizingDragTop() throws Exception { final Rect r = new Rect(330, 100, 630, 600); final int midX = (r.left + r.right) / 2; Loading services/tests/servicestests/src/com/android/server/wm/TestWindowManagerPolicy.java +17 −0 Original line number Diff line number Diff line Loading @@ -18,8 +18,12 @@ package com.android.server.wm; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.any; import static org.mockito.Mockito.doAnswer; import org.mockito.invocation.InvocationOnMock; import android.annotation.Nullable; import android.app.ActivityManagerInternal; import android.content.Context; import android.content.res.CompatibilityInfo; import android.content.res.Configuration; Loading Loading @@ -64,6 +68,19 @@ class TestWindowManagerPolicy implements WindowManagerPolicy { LocalServices.addService(PowerManagerInternal.class, mock(PowerManagerInternal.class)); } if (LocalServices.getService(ActivityManagerInternal.class) == null) { LocalServices.addService(ActivityManagerInternal.class, mock(ActivityManagerInternal.class)); final ActivityManagerInternal am = LocalServices.getService(ActivityManagerInternal.class); doAnswer((InvocationOnMock invocationOnMock) -> { final Runnable runnable = invocationOnMock.getArgumentAt(0, Runnable.class); if (runnable != null) { runnable.run(); } return null; }).when(am).notifyKeyguardFlagsChanged(any()); } sWm = WindowManagerService.main(context, mock(InputManagerService.class), true, false, false, new TestWindowManagerPolicy()); } Loading services/tests/servicestests/src/com/android/server/wm/UnknownAppVisibilityControllerTest.java +23 −48 Original line number Diff line number Diff line Loading @@ -17,25 +17,14 @@ package com.android.server.wm; import static junit.framework.Assert.assertTrue; import static org.mockito.Mockito.any; import static org.mockito.Mockito.doAnswer; import android.app.ActivityManagerInternal; import android.content.Context; import android.platform.test.annotations.Presubmit; import android.support.test.InstrumentationRegistry; import android.support.test.filters.SmallTest; import android.support.test.runner.AndroidJUnit4; import com.android.server.LocalServices; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.mockito.invocation.InvocationOnMock; /** * Test class for {@link AppTransition}. Loading @@ -52,64 +41,50 @@ public class UnknownAppVisibilityControllerTest extends WindowTestsBase { @Before public void setUp() throws Exception { super.setUp(); final Context context = InstrumentationRegistry.getTargetContext(); doAnswer((InvocationOnMock invocationOnMock) -> { invocationOnMock.getArgumentAt(0, Runnable.class).run(); return null; }).when(sMockAm).notifyKeyguardFlagsChanged(any()); mWm = TestWindowManagerPolicy.getWindowManagerService(context); } @After public void tearDown() throws Exception { LocalServices.removeServiceForTest(ActivityManagerInternal.class); sWm.mUnknownAppVisibilityController.clear(); } @Test public void testFlow() throws Exception { AppWindowToken token = createAppToken(); mWm.mUnknownAppVisibilityController.notifyLaunched(token); mWm.mUnknownAppVisibilityController.notifyAppResumedFinished(token); mWm.mUnknownAppVisibilityController.notifyRelayouted(token); final AppWindowToken token = new TestAppWindowToken(sDisplayContent); sWm.mUnknownAppVisibilityController.notifyLaunched(token); sWm.mUnknownAppVisibilityController.notifyAppResumedFinished(token); sWm.mUnknownAppVisibilityController.notifyRelayouted(token); // Make sure our handler processed the message. Thread.sleep(100); assertTrue(mWm.mUnknownAppVisibilityController.allResolved()); assertTrue(sWm.mUnknownAppVisibilityController.allResolved()); } @Test public void testMultiple() throws Exception { AppWindowToken token1 = createAppToken(); AppWindowToken token2 = createAppToken(); mWm.mUnknownAppVisibilityController.notifyLaunched(token1); mWm.mUnknownAppVisibilityController.notifyAppResumedFinished(token1); mWm.mUnknownAppVisibilityController.notifyLaunched(token2); mWm.mUnknownAppVisibilityController.notifyRelayouted(token1); mWm.mUnknownAppVisibilityController.notifyAppResumedFinished(token2); mWm.mUnknownAppVisibilityController.notifyRelayouted(token2); final AppWindowToken token1 = new TestAppWindowToken(sDisplayContent); final AppWindowToken token2 = new TestAppWindowToken(sDisplayContent); sWm.mUnknownAppVisibilityController.notifyLaunched(token1); sWm.mUnknownAppVisibilityController.notifyAppResumedFinished(token1); sWm.mUnknownAppVisibilityController.notifyLaunched(token2); sWm.mUnknownAppVisibilityController.notifyRelayouted(token1); sWm.mUnknownAppVisibilityController.notifyAppResumedFinished(token2); sWm.mUnknownAppVisibilityController.notifyRelayouted(token2); // Make sure our handler processed the message. Thread.sleep(100); assertTrue(mWm.mUnknownAppVisibilityController.allResolved()); assertTrue(sWm.mUnknownAppVisibilityController.allResolved()); } @Test public void testClear() throws Exception { AppWindowToken token = createAppToken(); mWm.mUnknownAppVisibilityController.notifyLaunched(token); mWm.mUnknownAppVisibilityController.clear();; assertTrue(mWm.mUnknownAppVisibilityController.allResolved()); final AppWindowToken token = new TestAppWindowToken(sDisplayContent); sWm.mUnknownAppVisibilityController.notifyLaunched(token); sWm.mUnknownAppVisibilityController.clear();; assertTrue(sWm.mUnknownAppVisibilityController.allResolved()); } @Test public void testAppRemoved() throws Exception { AppWindowToken token = createAppToken(); mWm.mUnknownAppVisibilityController.notifyLaunched(token); mWm.mUnknownAppVisibilityController.appRemoved(token); assertTrue(mWm.mUnknownAppVisibilityController.allResolved()); } private AppWindowToken createAppToken() { return new AppWindowToken(mWm, null, false, mWm.getDefaultDisplayContentLocked()); final AppWindowToken token = new TestAppWindowToken(sDisplayContent); sWm.mUnknownAppVisibilityController.notifyLaunched(token); sWm.mUnknownAppVisibilityController.appRemoved(token); assertTrue(sWm.mUnknownAppVisibilityController.allResolved()); } } Loading
services/core/java/com/android/server/wm/AppWindowToken.java +3 −3 Original line number Diff line number Diff line Loading @@ -173,10 +173,9 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree boolean showForAllUsers, int targetSdk, int orientation, int rotationAnimationHint, int configChanges, boolean launchTaskBehind, boolean alwaysFocusable, AppWindowContainerController controller) { this(service, token, voiceInteraction, dc); this(service, token, voiceInteraction, dc, fullscreen); setController(controller); mInputDispatchingTimeoutNanos = inputDispatchingTimeoutNanos; mFillsParent = fullscreen; mShowForAllUsers = showForAllUsers; mTargetSdk = targetSdk; mOrientation = orientation; Loading @@ -191,11 +190,12 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree } AppWindowToken(WindowManagerService service, IApplicationToken token, boolean voiceInteraction, DisplayContent dc) { DisplayContent dc, boolean fillsParent) { super(service, token != null ? token.asBinder() : null, TYPE_APPLICATION, true, dc, false /* ownerCanManageAppTokens */); appToken = token; mVoiceInteraction = voiceInteraction; mFillsParent = fillsParent; mInputApplicationHandle = new InputApplicationHandle(this); mAppAnimator = new AppWindowAnimator(this, service); } Loading
services/tests/servicestests/src/com/android/server/wm/AppWindowTokenTests.java +5 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.server.wm; import org.junit.Test; import org.junit.Ignore; import org.junit.runner.RunWith; import android.platform.test.annotations.Presubmit; Loading Loading @@ -70,6 +71,7 @@ public class AppWindowTokenTests extends WindowTestsBase { // The base application window should be below all other windows. assertEquals(baseWin, token.getFirstChild()); token.removeImmediately(); } @Test Loading @@ -86,6 +88,7 @@ public class AppWindowTokenTests extends WindowTestsBase { assertEquals(window1, token.findMainWindow()); final WindowState window2 = createWindow(null, TYPE_APPLICATION_STARTING, token, "window2"); assertEquals(window2, token.findMainWindow()); token.removeImmediately(); } @Test Loading Loading @@ -123,6 +126,8 @@ public class AppWindowTokenTests extends WindowTestsBase { } @Test @Ignore // TODO(b/35034729): Need to fix before re-enabling public void testLandscapeSeascapeRotationByPolicy() throws Exception { // Some plumbing to get the service ready for rotation updates. sWm.mDisplayReady = true; Loading
services/tests/servicestests/src/com/android/server/wm/TaskPositionerTests.java +9 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.server.wm; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; Loading Loading @@ -77,6 +78,7 @@ public class TaskPositionerTests extends WindowTestsBase { * as does some basic tests (e.g. dragging in Y only will keep X stable). */ @Test @Ignore public void testBasicFreeWindowResizing() throws Exception { final Rect r = new Rect(100, 220, 700, 520); final int midY = (r.top + r.bottom) / 2; Loading Loading @@ -137,6 +139,7 @@ public class TaskPositionerTests extends WindowTestsBase { * This tests that by dragging any edge, the fixed / opposite edge(s) remains anchored. */ @Test @Ignore public void testFreeWindowResizingTestAllEdges() throws Exception { final Rect r = new Rect(100, 220, 700, 520); final int midX = (r.left + r.right) / 2; Loading Loading @@ -221,6 +224,7 @@ public class TaskPositionerTests extends WindowTestsBase { * right things upon resizing when dragged from the top left corner. */ @Test @Ignore public void testLandscapePreservedWindowResizingDragTopLeft() throws Exception { final Rect r = new Rect(100, 220, 700, 520); Loading Loading @@ -258,6 +262,7 @@ public class TaskPositionerTests extends WindowTestsBase { * right things upon resizing when dragged from the left corner. */ @Test @Ignore public void testLandscapePreservedWindowResizingDragLeft() throws Exception { final Rect r = new Rect(100, 220, 700, 520); final int midY = (r.top + r.bottom) / 2; Loading Loading @@ -298,6 +303,7 @@ public class TaskPositionerTests extends WindowTestsBase { * right things upon resizing when dragged from the top corner. */ @Test @Ignore public void testLandscapePreservedWindowResizingDragTop() throws Exception { final Rect r = new Rect(100, 220, 700, 520); final int midX = (r.left + r.right) / 2; Loading Loading @@ -334,6 +340,7 @@ public class TaskPositionerTests extends WindowTestsBase { * right things upon resizing when dragged from the top left corner. */ @Test @Ignore public void testPortraitPreservedWindowResizingDragTopLeft() throws Exception { final Rect r = new Rect(330, 100, 630, 600); Loading Loading @@ -366,6 +373,7 @@ public class TaskPositionerTests extends WindowTestsBase { * right things upon resizing when dragged from the left corner. */ @Test @Ignore public void testPortraitPreservedWindowResizingDragLeft() throws Exception { final Rect r = new Rect(330, 100, 630, 600); final int midY = (r.top + r.bottom) / 2; Loading Loading @@ -408,6 +416,7 @@ public class TaskPositionerTests extends WindowTestsBase { * right things upon resizing when dragged from the top corner. */ @Test @Ignore public void testPortraitPreservedWindowResizingDragTop() throws Exception { final Rect r = new Rect(330, 100, 630, 600); final int midX = (r.left + r.right) / 2; Loading
services/tests/servicestests/src/com/android/server/wm/TestWindowManagerPolicy.java +17 −0 Original line number Diff line number Diff line Loading @@ -18,8 +18,12 @@ package com.android.server.wm; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.any; import static org.mockito.Mockito.doAnswer; import org.mockito.invocation.InvocationOnMock; import android.annotation.Nullable; import android.app.ActivityManagerInternal; import android.content.Context; import android.content.res.CompatibilityInfo; import android.content.res.Configuration; Loading Loading @@ -64,6 +68,19 @@ class TestWindowManagerPolicy implements WindowManagerPolicy { LocalServices.addService(PowerManagerInternal.class, mock(PowerManagerInternal.class)); } if (LocalServices.getService(ActivityManagerInternal.class) == null) { LocalServices.addService(ActivityManagerInternal.class, mock(ActivityManagerInternal.class)); final ActivityManagerInternal am = LocalServices.getService(ActivityManagerInternal.class); doAnswer((InvocationOnMock invocationOnMock) -> { final Runnable runnable = invocationOnMock.getArgumentAt(0, Runnable.class); if (runnable != null) { runnable.run(); } return null; }).when(am).notifyKeyguardFlagsChanged(any()); } sWm = WindowManagerService.main(context, mock(InputManagerService.class), true, false, false, new TestWindowManagerPolicy()); } Loading
services/tests/servicestests/src/com/android/server/wm/UnknownAppVisibilityControllerTest.java +23 −48 Original line number Diff line number Diff line Loading @@ -17,25 +17,14 @@ package com.android.server.wm; import static junit.framework.Assert.assertTrue; import static org.mockito.Mockito.any; import static org.mockito.Mockito.doAnswer; import android.app.ActivityManagerInternal; import android.content.Context; import android.platform.test.annotations.Presubmit; import android.support.test.InstrumentationRegistry; import android.support.test.filters.SmallTest; import android.support.test.runner.AndroidJUnit4; import com.android.server.LocalServices; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.mockito.invocation.InvocationOnMock; /** * Test class for {@link AppTransition}. Loading @@ -52,64 +41,50 @@ public class UnknownAppVisibilityControllerTest extends WindowTestsBase { @Before public void setUp() throws Exception { super.setUp(); final Context context = InstrumentationRegistry.getTargetContext(); doAnswer((InvocationOnMock invocationOnMock) -> { invocationOnMock.getArgumentAt(0, Runnable.class).run(); return null; }).when(sMockAm).notifyKeyguardFlagsChanged(any()); mWm = TestWindowManagerPolicy.getWindowManagerService(context); } @After public void tearDown() throws Exception { LocalServices.removeServiceForTest(ActivityManagerInternal.class); sWm.mUnknownAppVisibilityController.clear(); } @Test public void testFlow() throws Exception { AppWindowToken token = createAppToken(); mWm.mUnknownAppVisibilityController.notifyLaunched(token); mWm.mUnknownAppVisibilityController.notifyAppResumedFinished(token); mWm.mUnknownAppVisibilityController.notifyRelayouted(token); final AppWindowToken token = new TestAppWindowToken(sDisplayContent); sWm.mUnknownAppVisibilityController.notifyLaunched(token); sWm.mUnknownAppVisibilityController.notifyAppResumedFinished(token); sWm.mUnknownAppVisibilityController.notifyRelayouted(token); // Make sure our handler processed the message. Thread.sleep(100); assertTrue(mWm.mUnknownAppVisibilityController.allResolved()); assertTrue(sWm.mUnknownAppVisibilityController.allResolved()); } @Test public void testMultiple() throws Exception { AppWindowToken token1 = createAppToken(); AppWindowToken token2 = createAppToken(); mWm.mUnknownAppVisibilityController.notifyLaunched(token1); mWm.mUnknownAppVisibilityController.notifyAppResumedFinished(token1); mWm.mUnknownAppVisibilityController.notifyLaunched(token2); mWm.mUnknownAppVisibilityController.notifyRelayouted(token1); mWm.mUnknownAppVisibilityController.notifyAppResumedFinished(token2); mWm.mUnknownAppVisibilityController.notifyRelayouted(token2); final AppWindowToken token1 = new TestAppWindowToken(sDisplayContent); final AppWindowToken token2 = new TestAppWindowToken(sDisplayContent); sWm.mUnknownAppVisibilityController.notifyLaunched(token1); sWm.mUnknownAppVisibilityController.notifyAppResumedFinished(token1); sWm.mUnknownAppVisibilityController.notifyLaunched(token2); sWm.mUnknownAppVisibilityController.notifyRelayouted(token1); sWm.mUnknownAppVisibilityController.notifyAppResumedFinished(token2); sWm.mUnknownAppVisibilityController.notifyRelayouted(token2); // Make sure our handler processed the message. Thread.sleep(100); assertTrue(mWm.mUnknownAppVisibilityController.allResolved()); assertTrue(sWm.mUnknownAppVisibilityController.allResolved()); } @Test public void testClear() throws Exception { AppWindowToken token = createAppToken(); mWm.mUnknownAppVisibilityController.notifyLaunched(token); mWm.mUnknownAppVisibilityController.clear();; assertTrue(mWm.mUnknownAppVisibilityController.allResolved()); final AppWindowToken token = new TestAppWindowToken(sDisplayContent); sWm.mUnknownAppVisibilityController.notifyLaunched(token); sWm.mUnknownAppVisibilityController.clear();; assertTrue(sWm.mUnknownAppVisibilityController.allResolved()); } @Test public void testAppRemoved() throws Exception { AppWindowToken token = createAppToken(); mWm.mUnknownAppVisibilityController.notifyLaunched(token); mWm.mUnknownAppVisibilityController.appRemoved(token); assertTrue(mWm.mUnknownAppVisibilityController.allResolved()); } private AppWindowToken createAppToken() { return new AppWindowToken(mWm, null, false, mWm.getDefaultDisplayContentLocked()); final AppWindowToken token = new TestAppWindowToken(sDisplayContent); sWm.mUnknownAppVisibilityController.notifyLaunched(token); sWm.mUnknownAppVisibilityController.appRemoved(token); assertTrue(sWm.mUnknownAppVisibilityController.allResolved()); } }