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

Commit 0e11b2c7 authored by Chavi Weingarten's avatar Chavi Weingarten Committed by Android (Google) Code Review
Browse files

Merge "Update IME SECURE flag if Window updates SECURE flag" into tm-dev

parents f3e8d882 90d0e50b
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -4048,12 +4048,20 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
    @VisibleForTesting
    void setImeInputTarget(InputTarget target) {
        mImeInputTarget = target;
        boolean canScreenshot = mImeInputTarget == null || mImeInputTarget.canScreenshotIme();
        if (mImeWindowsContainer.setCanScreenshot(canScreenshot)) {
        if (refreshImeSecureFlag(getPendingTransaction())) {
            mWmService.requestTraversal();
        }
    }

    /**
     * Re-check the IME target's SECURE flag since it's possible to have changed after the target
     * was set.
     */
    boolean refreshImeSecureFlag(Transaction t) {
        boolean canScreenshot = mImeInputTarget == null || mImeInputTarget.canScreenshotIme();
        return mImeWindowsContainer.setCanScreenshot(t, canScreenshot);
    }

    @VisibleForTesting
    void setImeControlTarget(InsetsControlTarget target) {
        mImeControlTarget = target;
+2 −2
Original line number Diff line number Diff line
@@ -3782,11 +3782,11 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
        return INVALID_WINDOW_TYPE;
    }

    boolean setCanScreenshot(boolean canScreenshot) {
    boolean setCanScreenshot(Transaction t, boolean canScreenshot) {
        if (mSurfaceControl == null) {
            return false;
        }
        getPendingTransaction().setSecure(mSurfaceControl, !canScreenshot);
        t.setSecure(mSurfaceControl, !canScreenshot);
        return true;
    }

+5 −0
Original line number Diff line number Diff line
@@ -217,6 +217,11 @@ class WindowSurfaceController {
        mService.openSurfaceTransaction();
        try {
            getGlobalTransaction().setSecure(mSurfaceControl, isSecure);

            final DisplayContent dc = mAnimator.mWin.mDisplayContent;
            if (dc != null) {
                dc.refreshImeSecureFlag(getGlobalTransaction());
            }
        } finally {
            mService.closeSurfaceTransaction("setSecure");
            if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG, "<<< CLOSE TRANSACTION setSecureLocked");
+14 −0
Original line number Diff line number Diff line
@@ -1201,6 +1201,20 @@ public class DisplayContentTests extends WindowTestsBase {
                dc.computeImeControlTarget());
    }

    @UseTestDisplay(addWindows = W_INPUT_METHOD)
    @Test
    public void testImeSecureFlagGetUpdatedAfterImeInputTarget() {
        // Verify IME window can get up-to-date secure flag update when the IME input target
        // set before setCanScreenshot called.
        final WindowState app = createWindow(null, TYPE_APPLICATION, "app");
        SurfaceControl.Transaction t = mDisplayContent.mInputMethodWindow.getPendingTransaction();
        spyOn(t);
        mDisplayContent.setImeInputTarget(app);
        mDisplayContent.mInputMethodWindow.setCanScreenshot(t, false /* canScreenshot */);

        verify(t).setSecure(eq(mDisplayContent.mInputMethodWindow.mSurfaceControl), eq(true));
    }

    @UseTestDisplay(addWindows = W_ACTIVITY)
    @Test
    public void testComputeImeControlTarget_notMatchParentBounds() throws Exception {