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

Commit 912782ea authored by Garfield Tan's avatar Garfield Tan
Browse files

Remove DecorCaptionView and CAPTION_ON_SHELL flag

The legacy caption on the client side is replaced by the caption in WM
shell. A lot of development has been made on top of the shell caption
that the legacy caption is way too stale from desktop mode's
perspective.

In the process of removing code, I found there is a public API
Window#setDecorCaptionShade that became useless after moving captions to
WM shell. We should consider if rewiring is necessary based on UX input
and the API usage among apps.

The removal of CAPTION_ON_SHELL should result in the flag being on
permanently.

Bug: 333724879
Bug: 328668781
Test: Launch an app in CF PC and the caption looks OK.
Test: atest InsetsControllerTest
Test: WmTests in presubmit tests.
Test: FrameworksCoreTests in presubmit tests.
Test: WM related CTS tests in presubmit tests.
Test: atest WindowDecorationTests
Flag: NA
Change-Id: If8ac1cc9e8a81f63f9960768aea8d2016a67c4f9
parent 2487facc
Loading
Loading
Loading
Loading
+2 −46
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import static android.view.InsetsControllerProto.CONTROL;
import static android.view.InsetsControllerProto.STATE;
import static android.view.InsetsSource.ID_IME;
import static android.view.InsetsSource.ID_IME_CAPTION_BAR;
import static android.view.ViewRootImpl.CAPTION_ON_SHELL;
import static android.view.WindowInsets.Type.FIRST;
import static android.view.WindowInsets.Type.LAST;
import static android.view.WindowInsets.Type.all;
@@ -685,9 +684,6 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation

                @Override
                public void onIdNotFoundInState2(int index1, InsetsSource source1) {
                    if (!CAPTION_ON_SHELL && source1.getType() == captionBar()) {
                        return;
                    }
                    if (source1.getId() == ID_IME_CAPTION_BAR) {
                        return;
                    }
@@ -848,15 +844,8 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
    }

    public boolean onStateChanged(InsetsState state) {
        boolean stateChanged = false;
        if (!CAPTION_ON_SHELL) {
            stateChanged = !mState.equals(state, true /* excludesCaptionBar */,
                    false /* excludesInvisibleIme */)
                    || captionInsetsUnchanged();
        } else {
            stateChanged = !mState.equals(state, false /* excludesCaptionBar */,
        boolean stateChanged = !mState.equals(state, false /* excludesCaptionBar */,
                false /* excludesInvisibleIme */);
        }
        if (!stateChanged && mLastDispatchedState.equals(state)) {
            return false;
        }
@@ -924,21 +913,6 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
        }
    }

    private boolean captionInsetsUnchanged() {
        if (CAPTION_ON_SHELL) {
            return false;
        }
        final InsetsSource source = mState.peekSource(ID_CAPTION_BAR);
        if (source == null && mCaptionInsetsHeight == 0) {
            return false;
        }
        if (source != null && mCaptionInsetsHeight == source.getFrame().height()) {
            return false;
        }

        return true;
    }

    /**
     * @see InsetsState#calculateInsets(Rect, InsetsState, boolean, int, int, int, int, int,
     *      android.util.SparseIntArray)
@@ -1888,24 +1862,6 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
        return mAppearanceControlled;
    }

    @Override
    public void setCaptionInsetsHeight(int height) {
        // This method is to be removed once the caption is moved to the shell.
        if (CAPTION_ON_SHELL) {
            return;
        }
        if (mCaptionInsetsHeight != height) {
            mCaptionInsetsHeight = height;
            if (mCaptionInsetsHeight != 0) {
                mState.getOrCreateSource(ID_CAPTION_BAR, captionBar()).setFrame(
                        mFrame.left, mFrame.top, mFrame.right, mFrame.top + mCaptionInsetsHeight);
            } else {
                mState.removeSource(ID_CAPTION_BAR);
            }
            mHost.notifyInsetsChanged();
        }
    }

    @Override
    public void setImeCaptionBarInsetsHeight(int height) {
        if (!ENABLE_HIDE_IME_CAPTION_BAR) {
+0 −9
Original line number Diff line number Diff line
@@ -45,7 +45,6 @@ public class PendingInsetsController implements WindowInsetsController {
    private InsetsController mReplayedInsetsController;
    private ArrayList<OnControllableInsetsChangedListener> mControllableInsetsChangedListeners
            = new ArrayList<>();
    private int mCaptionInsetsHeight = 0;
    private int mImeCaptionBarInsetsHeight = 0;
    private WindowInsetsAnimationControlListener mLoggingListener;
    private @InsetsType int mRequestedVisibleTypes = WindowInsets.Type.defaultVisible();
@@ -98,11 +97,6 @@ public class PendingInsetsController implements WindowInsetsController {
        return mAppearance | (mAppearanceFromResource & ~mAppearanceMask);
    }

    @Override
    public void setCaptionInsetsHeight(int height) {
        mCaptionInsetsHeight = height;
    }

    @Override
    public void setImeCaptionBarInsetsHeight(int height) {
        mImeCaptionBarInsetsHeight = height;
@@ -187,9 +181,6 @@ public class PendingInsetsController implements WindowInsetsController {
            controller.setSystemBarsAppearanceFromResource(
                    mAppearanceFromResource, mAppearanceFromResourceMask);
        }
        if (mCaptionInsetsHeight != 0) {
            controller.setCaptionInsetsHeight(mCaptionInsetsHeight);
        }
        if (mImeCaptionBarInsetsHeight != 0) {
            controller.setImeCaptionBarInsetsHeight(mImeCaptionBarInsetsHeight);
        }
+0 −27
Original line number Diff line number Diff line
@@ -257,7 +257,6 @@ import com.android.internal.inputmethod.ImeTracing;
import com.android.internal.inputmethod.InputMethodDebug;
import com.android.internal.os.IResultReceiver;
import com.android.internal.os.SomeArgs;
import com.android.internal.policy.DecorView;
import com.android.internal.policy.PhoneFallbackEventHandler;
import com.android.internal.view.BaseSurfaceHolder;
import com.android.internal.view.RootViewSurfaceTaker;
@@ -334,13 +333,6 @@ public final class ViewRootImpl implements ViewParent,
     */
    private static final boolean USE_ASYNC_PERFORM_HAPTIC_FEEDBACK = true;
    /**
     * Whether the caption is drawn by the shell.
     * @hide
     */
    public static final boolean CAPTION_ON_SHELL =
            SystemProperties.getBoolean("persist.wm.debug.caption_on_shell", true);
    /**
     * Whether the client (system UI) is handling the transient gesture and the corresponding
     * animation.
@@ -3176,22 +3168,6 @@ public final class ViewRootImpl implements ViewParent,
        Trace.traceEnd(Trace.TRACE_TAG_VIEW);
    }
    private boolean updateCaptionInsets() {
        if (CAPTION_ON_SHELL) {
            return false;
        }
        if (!(mView instanceof DecorView)) return false;
        final int captionInsetsHeight = ((DecorView) mView).getCaptionInsetsHeight();
        final Rect captionFrame = new Rect();
        if (captionInsetsHeight != 0) {
            captionFrame.set(mWinFrame.left, mWinFrame.top, mWinFrame.right,
                            mWinFrame.top + captionInsetsHeight);
        }
        if (mAttachInfo.mCaptionInsets.equals(captionFrame)) return false;
        mAttachInfo.mCaptionInsets.set(captionFrame);
        return true;
    }
    private boolean shouldDispatchCutout() {
        return mWindowAttributes.layoutInDisplayCutoutMode
                        == LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS
@@ -3645,9 +3621,6 @@ public final class ViewRootImpl implements ViewParent,
                    mAttachInfo.mAlwaysConsumeSystemBars = mPendingAlwaysConsumeSystemBars;
                    dispatchApplyInsets = true;
                }
                if (updateCaptionInsets()) {
                    dispatchApplyInsets = true;
                }
                if (dispatchApplyInsets || mLastSystemUiVisibility !=
                        mAttachInfo.mSystemUiVisibility || mApplyInsetsRequested) {
                    mLastSystemUiVisibility = mAttachInfo.mSystemUiVisibility;
+0 −9
Original line number Diff line number Diff line
@@ -283,15 +283,6 @@ public interface WindowInsetsController {
     */
    @Appearance int getSystemBarsAppearance();

    /**
     * Notify the caption insets height change. The information will be used on the client side to,
     * make sure the InsetsState has the correct caption insets.
     *
     * @param height the height of caption bar insets.
     * @hide
     */
    void setCaptionInsetsHeight(int height);

    /**
     * Sets the insets height for the IME caption bar, which corresponds to the
     * "fake" IME navigation bar.
+6 −21
Original line number Diff line number Diff line
@@ -56,7 +56,6 @@ public class BackdropFrameRenderer extends Thread implements Choreographer.Frame
    // during a configuration change.
    private int mLastContentWidth;
    private int mLastContentHeight;
    private int mLastCaptionHeight;
    private int mLastXOffset;
    private int mLastYOffset;

@@ -269,7 +268,7 @@ public class BackdropFrameRenderer extends Thread implements Choreographer.Frame
            final boolean firstCall = mLastContentWidth == 0;
            // The current content buffer is drawn here.
            mLastContentWidth = xSize;
            mLastContentHeight = ySize - mLastCaptionHeight;
            mLastContentHeight = ySize;
            mLastXOffset = xOffset;
            mLastYOffset = yOffset;

@@ -278,12 +277,11 @@ public class BackdropFrameRenderer extends Thread implements Choreographer.Frame
                    mLastXOffset,
                    mLastYOffset,
                    mLastXOffset + mLastContentWidth,
                    mLastYOffset + mLastCaptionHeight + mLastContentHeight);
                    mLastYOffset + mLastContentHeight);

            // If this was the first call and redrawLocked got already called prior
            // to us, we should re-issue a redrawLocked now.
            return firstCall
                    && (mLastCaptionHeight != 0 || !mDecorView.isShowingCaption());
            return firstCall;
        }
    }

@@ -303,22 +301,9 @@ public class BackdropFrameRenderer extends Thread implements Choreographer.Frame
     */
    private void redrawLocked(Rect newBounds, boolean fullscreen) {

        // While a configuration change is taking place the view hierarchy might become
        // inaccessible. For that case we remember the previous metrics to avoid flashes.
        // Note that even when there is no visible caption, the caption child will exist.
        final int captionHeight = mDecorView.getCaptionHeight();

        // The caption height will probably never dynamically change while we are resizing.
        // Once set to something other then 0 it should be kept that way.
        if (captionHeight != 0) {
            // Remember the height of the caption.
            mLastCaptionHeight = captionHeight;
        }

        // Make sure that the other thread has already prepared the render draw calls for the
        // content. If any size is 0, we have to wait for it to be drawn first.
        if ((mLastCaptionHeight == 0 && mDecorView.isShowingCaption()) ||
                mLastContentWidth == 0 || mLastContentHeight == 0) {
        if (mLastContentWidth == 0 || mLastContentHeight == 0) {
            return;
        }

@@ -337,13 +322,13 @@ public class BackdropFrameRenderer extends Thread implements Choreographer.Frame
                ? mUserCaptionBackgroundDrawable : mCaptionBackgroundDrawable;

        if (drawable != null) {
            drawable.setBounds(0, 0, left + width, top + mLastCaptionHeight);
            drawable.setBounds(0, 0, left + width, top);
            drawable.draw(canvas);
        }

        // The backdrop: clear everything with the background. Clipping is done elsewhere.
        if (mResizingBackgroundDrawable != null) {
            mResizingBackgroundDrawable.setBounds(0, mLastCaptionHeight, left + width, top + height);
            mResizingBackgroundDrawable.setBounds(0, 0, left + width, top + height);
            mResizingBackgroundDrawable.draw(canvas);
        }
        mFrameAndBackdropNode.endRecording();
Loading