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

Commit 648e5881 authored by Jorim Jaggi's avatar Jorim Jaggi
Browse files

Handle adjustResize flag properly on client

Test:
adb shell setprop persist.wm.new_insets 1
adb shell setprop persist.pre_render_ime_views 0

Test: Open IME with app that doesn't have adjustResize set
Test: InsetsStateTest
Bug: 111084606
Change-Id: I1268101d851ddc8fee7896a1a8316eedf0c8de95
parent a6f35616
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import android.util.SparseSetArray;
import android.view.InsetsState.InsetSide;
import android.view.SyncRtSurfaceTransactionApplier.SurfaceParams;
import android.view.WindowInsets.Type.InsetType;
import android.view.WindowManager.LayoutParams;

import com.android.internal.annotations.VisibleForTesting;

@@ -165,7 +166,8 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll
            @Nullable @InsetSide SparseIntArray typeSideMap) {
        return state.calculateInsets(frame, false /* isScreenRound */,
                false /* alwaysConsumerNavBar */, null /* displayCutout */,
                null /* legacyContentInsets */, null /* legacyStableInsets */, typeSideMap)
                null /* legacyContentInsets */, null /* legacyStableInsets */,
                LayoutParams.SOFT_INPUT_ADJUST_RESIZE /* legacySoftInputMode*/, typeSideMap)
               .getInsets(mTypes);
    }

+6 −3
Original line number Diff line number Diff line
@@ -112,6 +112,8 @@ public class InsetsController implements WindowInsetsController {

    private int mPendingTypesToShow;

    private int mLastLegacySoftInputMode;

    public InsetsController(ViewRootImpl viewRoot) {
        mViewRoot = viewRoot;
        mAnimCallback = () -> {
@@ -126,7 +128,7 @@ public class InsetsController implements WindowInsetsController {
            }
            WindowInsets insets = state.calculateInsets(mFrame, mLastInsets.isRound(),
                    mLastInsets.shouldAlwaysConsumeNavBar(), mLastInsets.getDisplayCutout(),
                    mLastLegacyContentInsets, mLastLegacyStableInsets,
                    mLastLegacyContentInsets, mLastLegacyStableInsets, mLastLegacySoftInputMode,
                    null /* typeSideMap */);
            mViewRoot.mView.dispatchWindowInsetsAnimationProgress(insets);
        };
@@ -164,11 +166,12 @@ public class InsetsController implements WindowInsetsController {
    @VisibleForTesting
    public WindowInsets calculateInsets(boolean isScreenRound,
            boolean alwaysConsumeNavBar, DisplayCutout cutout, Rect legacyContentInsets,
            Rect legacyStableInsets) {
            Rect legacyStableInsets, int legacySoftInputMode) {
        mLastLegacyContentInsets.set(legacyContentInsets);
        mLastLegacyStableInsets.set(legacyStableInsets);
        mLastLegacySoftInputMode = legacySoftInputMode;
        mLastInsets = mState.calculateInsets(mFrame, isScreenRound, alwaysConsumeNavBar, cutout,
                legacyContentInsets, legacyStableInsets,
                legacyContentInsets, legacyStableInsets, legacySoftInputMode,
                null /* typeSideMap */);
        return mLastInsets;
    }
+9 −3
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package android.view;
import static android.view.ViewRootImpl.NEW_INSETS_MODE_FULL;
import static android.view.ViewRootImpl.NEW_INSETS_MODE_IME;
import static android.view.ViewRootImpl.NEW_INSETS_MODE_NONE;
import static android.view.WindowInsets.Type.IME;
import static android.view.WindowInsets.Type.SIZE;
import static android.view.WindowInsets.Type.indexOf;

@@ -34,6 +35,7 @@ import android.util.SparseArray;
import android.util.SparseIntArray;
import android.view.WindowInsets.Type;
import android.view.WindowInsets.Type.InsetType;
import android.view.WindowManager.LayoutParams;

import java.io.PrintWriter;
import java.lang.annotation.Retention;
@@ -130,7 +132,7 @@ public class InsetsState implements Parcelable {
    public WindowInsets calculateInsets(Rect frame, boolean isScreenRound,
            boolean alwaysConsumeNavBar, DisplayCutout cutout,
            @Nullable Rect legacyContentInsets, @Nullable Rect legacyStableInsets,
            @Nullable @InsetSide SparseIntArray typeSideMap) {
            int legacySoftInputMode, @Nullable @InsetSide SparseIntArray typeSideMap) {
        Insets[] typeInsetsMap = new Insets[Type.SIZE];
        Insets[] typeMaxInsetsMap = new Insets[Type.SIZE];
        boolean[] typeVisibilityMap = new boolean[SIZE];
@@ -146,8 +148,12 @@ public class InsetsState implements Parcelable {
            if (source == null) {
                continue;
            }
            if (ViewRootImpl.sNewInsetsMode != NEW_INSETS_MODE_FULL
                    && (type == TYPE_TOP_BAR || type == TYPE_NAVIGATION_BAR)) {

            boolean skipSystemBars = ViewRootImpl.sNewInsetsMode != NEW_INSETS_MODE_FULL
                    && (type == TYPE_TOP_BAR || type == TYPE_NAVIGATION_BAR);
            boolean skipIme = source.getType() == TYPE_IME
                    && (legacySoftInputMode & LayoutParams.SOFT_INPUT_ADJUST_RESIZE) == 0;
            if (skipSystemBars || skipIme) {
                typeVisibilityMap[indexOf(toPublicType(type))] = source.isVisible();
                continue;
            }
+1 −1
Original line number Diff line number Diff line
@@ -1886,7 +1886,7 @@ public final class ViewRootImpl implements ViewParent,
                mLastWindowInsets = mInsetsController.calculateInsets(
                        mContext.getResources().getConfiguration().isScreenRound(),
                        mAttachInfo.mAlwaysConsumeNavBar, displayCutout,
                        contentInsets, stableInsets);
                        contentInsets, stableInsets, mWindowAttributes.softInputMode);
            } else {
                mLastWindowInsets = new WindowInsets(contentInsets, stableInsets,
                        mContext.getResources().getConfiguration().isScreenRound(),
+2 −1
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package android.view;
import static android.view.ImeInsetsSourceConsumer.areEditorsSimilar;
import static android.view.InsetsState.TYPE_IME;

import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;

@@ -73,7 +74,7 @@ public class ImeInsetsSourceConsumerTest {
                    false,
                    new DisplayCutout(
                            Insets.of(10, 10, 10, 10), rect, rect, rect, rect),
                    rect, rect);
                    rect, rect, SOFT_INPUT_ADJUST_RESIZE);
            mImeConsumer = new ImeInsetsSourceConsumer(
                    new InsetsState(), Transaction::new, mController);
        });
Loading