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

Commit 60c66780 authored by Evan Rosky's avatar Evan Rosky
Browse files

Use inputtarget to check for insets controller

Was using just the window target, but we need to actually use
the inputmethodinputtarget since that has an activity that can
actually be checked for split-screen mode.

Additionally, we need to force-update the Wm configuration
because we skip doing so when divider is "hidden" by keyguard.

Bug: 159457357
Test: open split with pip running. Open keyboard in secondary,
      lock screen, then unlock.
Change-Id: Idbc0c3b90c18a55cc664c6958546994cbb8549ee
parent 4f5495ea
Loading
Loading
Loading
Loading
+5 −3
Original line number Original line Diff line number Diff line
@@ -193,10 +193,11 @@ public class Divider extends SystemUI implements DividerView.DividerCallbacks,


            @Override
            @Override
            public void onKeyguardShowingChanged() {
            public void onKeyguardShowingChanged() {
                if (!isDividerVisible() || mView == null) {
                if (!isSplitActive() || mView == null) {
                    return;
                    return;
                }
                }
                mView.setHidden(mKeyguardStateController.isShowing());
                mView.setHidden(mKeyguardStateController.isShowing());
                mImePositionProcessor.updateAdjustForIme();
            }
            }


            @Override
            @Override
@@ -285,8 +286,9 @@ public class Divider extends SystemUI implements DividerView.DividerCallbacks,
     * while this only cares if some things are (eg. while entering/exiting as well).
     * while this only cares if some things are (eg. while entering/exiting as well).
     */
     */
    private boolean isSplitActive() {
    private boolean isSplitActive() {
        return mSplits.mPrimary.topActivityType != ACTIVITY_TYPE_UNDEFINED
        return mSplits.mPrimary != null && mSplits.mSecondary != null
                || mSplits.mSecondary.topActivityType != ACTIVITY_TYPE_UNDEFINED;
                && (mSplits.mPrimary.topActivityType != ACTIVITY_TYPE_UNDEFINED
                        || mSplits.mSecondary.topActivityType != ACTIVITY_TYPE_UNDEFINED);
    }
    }


    private void addDivider(Configuration configuration) {
    private void addDivider(Configuration configuration) {
+13 −1
Original line number Original line Diff line number Diff line
@@ -91,6 +91,7 @@ class DividerImeController implements DisplayImeController.ImePositionProcessor


    private boolean mPaused = true;
    private boolean mPaused = true;
    private boolean mPausedTargetAdjusted = false;
    private boolean mPausedTargetAdjusted = false;
    private boolean mAdjustedWhileHidden = false;


    DividerImeController(SplitScreenTaskOrganizer splits, TransactionPool pool, Handler handler) {
    DividerImeController(SplitScreenTaskOrganizer splits, TransactionPool pool, Handler handler) {
        mSplits = splits;
        mSplits = splits;
@@ -170,11 +171,17 @@ class DividerImeController implements DisplayImeController.ImePositionProcessor
            // If split is hidden, we don't want to trigger any relayouts that would cause the
            // If split is hidden, we don't want to trigger any relayouts that would cause the
            // divider to show again.
            // divider to show again.
            updateImeAdjustState();
            updateImeAdjustState();
        } else {
            mAdjustedWhileHidden = true;
        }
        }
    }
    }


    private void updateImeAdjustState() {
    private void updateImeAdjustState() {
        if (mAdjusted != mTargetAdjusted) {
        updateImeAdjustState(false /* force */);
    }

    private void updateImeAdjustState(boolean force) {
        if (mAdjusted != mTargetAdjusted || force) {
            // Reposition the server's secondary split position so that it evaluates
            // Reposition the server's secondary split position so that it evaluates
            // insets properly.
            // insets properly.
            WindowContainerTransaction wct = new WindowContainerTransaction();
            WindowContainerTransaction wct = new WindowContainerTransaction();
@@ -231,6 +238,11 @@ class DividerImeController implements DisplayImeController.ImePositionProcessor
        mSplits.mDivider.setAdjustedForIme(mTargetShown && !mPaused);
        mSplits.mDivider.setAdjustedForIme(mTargetShown && !mPaused);
    }
    }


    public void updateAdjustForIme() {
        updateImeAdjustState(mAdjustedWhileHidden);
        mAdjustedWhileHidden = false;
    }

    @Override
    @Override
    public void onImePositionChanged(int displayId, int imeTop,
    public void onImePositionChanged(int displayId, int imeTop,
            SurfaceControl.Transaction t) {
            SurfaceControl.Transaction t) {
+4 −3
Original line number Original line Diff line number Diff line
@@ -271,10 +271,8 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged
            if (imeSource == null || mImeSourceControl == null) {
            if (imeSource == null || mImeSourceControl == null) {
                return;
                return;
            }
            }
            // Set frame, but only if the new frame isn't empty -- this maintains continuity
            final Rect newFrame = imeSource.getFrame();
            final Rect newFrame = imeSource.getFrame();
            mImeFrame.set(newFrame);
            final boolean isFloating = newFrame.height() == 0 && show;
            final boolean isFloating = newFrame.height() == 0;
            if (isFloating) {
            if (isFloating) {
                // This is likely a "floating" or "expanded" IME, so to get animations, just
                // This is likely a "floating" or "expanded" IME, so to get animations, just
                // pretend the ime has some size just below the screen.
                // pretend the ime has some size just below the screen.
@@ -283,6 +281,9 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged
                        mSystemWindows.mDisplayController.getDisplayLayout(mDisplayId).density()
                        mSystemWindows.mDisplayController.getDisplayLayout(mDisplayId).density()
                                * FLOATING_IME_BOTTOM_INSET);
                                * FLOATING_IME_BOTTOM_INSET);
                mImeFrame.bottom -= floatingInset;
                mImeFrame.bottom -= floatingInset;
            } else if (newFrame.height() != 0) {
                // Don't set a new frame if it's empty and hiding -- this maintains continuity
                mImeFrame.set(newFrame);
            }
            }
            if (DEBUG) {
            if (DEBUG) {
                Slog.d(TAG, "Run startAnim  show:" + show + "  was:"
                Slog.d(TAG, "Run startAnim  show:" + show + "  was:"
+3 −2
Original line number Original line Diff line number Diff line
@@ -3506,12 +3506,13 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
    }
    }


    private boolean isImeControlledByApp() {
    private boolean isImeControlledByApp() {
        return mInputMethodTarget != null && !WindowConfiguration.isSplitScreenWindowingMode(
        return mInputMethodInputTarget != null && !WindowConfiguration.isSplitScreenWindowingMode(
                mInputMethodTarget.getWindowingMode());
                        mInputMethodInputTarget.getWindowingMode());
    }
    }


    boolean isImeAttachedToApp() {
    boolean isImeAttachedToApp() {
        return isImeControlledByApp()
        return isImeControlledByApp()
                && mInputMethodTarget != null
                && mInputMethodTarget.mActivityRecord != null
                && mInputMethodTarget.mActivityRecord != null
                && mInputMethodTarget.getWindowingMode() == WINDOWING_MODE_FULLSCREEN
                && mInputMethodTarget.getWindowingMode() == WINDOWING_MODE_FULLSCREEN
                // An activity with override bounds should be letterboxed inside its parent bounds,
                // An activity with override bounds should be letterboxed inside its parent bounds,
+1 −0
Original line number Original line Diff line number Diff line
@@ -858,6 +858,7 @@ public class DisplayContentTests extends WindowTestsBase {
    public void testComputeImeParent_app() throws Exception {
    public void testComputeImeParent_app() throws Exception {
        final DisplayContent dc = createNewDisplay();
        final DisplayContent dc = createNewDisplay();
        dc.mInputMethodTarget = createWindow(null, TYPE_BASE_APPLICATION, "app");
        dc.mInputMethodTarget = createWindow(null, TYPE_BASE_APPLICATION, "app");
        dc.mInputMethodInputTarget = dc.mInputMethodTarget;
        assertEquals(dc.mInputMethodTarget.mActivityRecord.getSurfaceControl(),
        assertEquals(dc.mInputMethodTarget.mActivityRecord.getSurfaceControl(),
                dc.computeImeParent());
                dc.computeImeParent());
    }
    }
Loading