Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 736591ce authored by Gaurav Bhola's avatar Gaurav Bhola Committed by Android (Google) Code Review
Browse files

Merge changes Ifa6896b5,Iccf6de6b into main

* changes:
  Don't attach ime to app if target bounds don't match ime container
  Respect DA policy before trying to start home
parents 8a1c56ac 4df011a9
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -4160,6 +4160,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
                && mImeLayeringTarget != null
                && mImeLayeringTarget.mActivityRecord != null
                && mImeLayeringTarget.getWindowingMode() == WINDOWING_MODE_FULLSCREEN
                && mImeLayeringTarget.getBounds().equals(mImeWindowsContainer.getBounds())
                // IME is attached to app windows that fill display area. This excludes
                // letterboxed windows.
                && mImeLayeringTarget.matchesDisplayAreaBounds();
+5 −1
Original line number Diff line number Diff line
@@ -1693,7 +1693,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
    }

    /**
     * Check if home activity start should be allowed on a display.
     * Check if home activity start should be allowed on a {@link TaskDisplayArea}.
     *
     * @param homeInfo           {@code ActivityInfo} of the home activity that is going to be
     *                           launched.
@@ -1717,6 +1717,10 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
            return false;
        }

        if (taskDisplayArea != null && !taskDisplayArea.canHostHomeTask()) {
            return false;
        }

        final int displayId = taskDisplayArea != null ? taskDisplayArea.getDisplayId()
                : INVALID_DISPLAY;
        if (shouldPlacePrimaryHomeOnDisplay(displayId)) {
+21 −0
Original line number Diff line number Diff line
@@ -1343,6 +1343,27 @@ public class DisplayContentTests extends WindowTestsBase {
        assertEquals(mAppWindow, mDisplayContent.computeImeControlTarget());
    }

    @SetupWindows(addWindows = W_ACTIVITY)
    @Test
    public void testShouldImeAttachedToApp_targetBoundsDifferentFromImeContainer_returnsFalse()
            throws Exception {
        Rect imeContainerBounds = new Rect(0, 0, 100, 100);
        Rect imeTargetBounds = new Rect(0, 0, 100, 200);
        spyOn(mAppWindow);
        spyOn(mAppWindow.mActivityRecord);
        doReturn(imeTargetBounds).when(mAppWindow).getBounds();
        doReturn(true).when(mAppWindow.mActivityRecord).matchParentBounds();
        mDisplayContent.setImeInputTarget(mAppWindow);
        mDisplayContent.setImeLayeringTarget(
                mDisplayContent.getImeInputTarget().getWindowState());
        mDisplayContent.setRemoteInsetsController(createDisplayWindowInsetsController());
        final DisplayArea.Tokens imeContainer = mDisplayContent.getImeContainer();
        spyOn(imeContainer);
        doReturn(imeContainerBounds).when(imeContainer).getBounds();

        assertFalse(mDisplayContent.shouldImeAttachedToApp());
    }

    @Test
    public void testUpdateSystemGestureExclusion() throws Exception {
        final DisplayContent dc = createNewDisplay();
+18 −0
Original line number Diff line number Diff line
@@ -905,6 +905,24 @@ public class RootWindowContainerTests extends WindowTestsBase {
                true /* allowInstrumenting*/));
    }

    /**
     * Tests whether home can be started if it's not allowed by policy.
     */
    @Test
    public void testCanStartHome_returnsFalse_ifDisallowedByPolicy() {
        final ActivityInfo info = new ActivityInfo();
        info.applicationInfo = new ApplicationInfo();
        final WindowProcessController app = mock(WindowProcessController.class);
        doReturn(app).when(mAtm).getProcessController(any(), anyInt());
        doReturn(false).when(app).isInstrumenting();
        final TaskDisplayArea taskDisplayArea = mRootWindowContainer.getDefaultTaskDisplayArea();
        doReturn(false).when(taskDisplayArea).canHostHomeTask();

        assertFalse(mRootWindowContainer.canStartHomeOnDisplayArea(info, taskDisplayArea,
                false /* allowInstrumenting*/));
    }


    /**
     * Tests that secondary home activity should not be resolved if device is still locked.
     */