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

Commit f6a2ef49 authored by Tiger Huang's avatar Tiger Huang Committed by Automerger Merge Worker
Browse files

Merge "Push drag-resize mode to the client" into tm-dev am: 883190cd

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17222863

Change-Id: I85a22f904328753978c3f497c6da3bdf38a64842
parents 23af10c8 883190cd
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -392,7 +392,7 @@ public abstract class WallpaperService extends Service {
            @Override
            @Override
            public void resized(ClientWindowFrames frames, boolean reportDraw,
            public void resized(ClientWindowFrames frames, boolean reportDraw,
                    MergedConfiguration mergedConfiguration, boolean forceLayout,
                    MergedConfiguration mergedConfiguration, boolean forceLayout,
                    boolean alwaysConsumeSystemBars, int displayId, int syncSeqId) {
                    boolean alwaysConsumeSystemBars, int displayId, int syncSeqId, int resizeMode) {
                Message msg = mCaller.obtainMessageIO(MSG_WINDOW_RESIZED,
                Message msg = mCaller.obtainMessageIO(MSG_WINDOW_RESIZED,
                        reportDraw ? 1 : 0,
                        reportDraw ? 1 : 0,
                        mergedConfiguration);
                        mergedConfiguration);
+1 −1
Original line number Original line Diff line number Diff line
@@ -56,7 +56,7 @@ oneway interface IWindow {
    void resized(in ClientWindowFrames frames, boolean reportDraw,
    void resized(in ClientWindowFrames frames, boolean reportDraw,
            in MergedConfiguration newMergedConfiguration,
            in MergedConfiguration newMergedConfiguration,
            boolean forceLayout, boolean alwaysConsumeSystemBars, int displayId,
            boolean forceLayout, boolean alwaysConsumeSystemBars, int displayId,
            int syncSeqId);
            int syncSeqId, int resizeMode);


    /**
    /**
     * Called when the window insets configuration has changed.
     * Called when the window insets configuration has changed.
+16 −20
Original line number Original line Diff line number Diff line
@@ -53,8 +53,8 @@ import static android.view.ViewRootImplProto.WIDTH;
import static android.view.ViewRootImplProto.WINDOW_ATTRIBUTES;
import static android.view.ViewRootImplProto.WINDOW_ATTRIBUTES;
import static android.view.ViewRootImplProto.WIN_FRAME;
import static android.view.ViewRootImplProto.WIN_FRAME;
import static android.view.ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_REGION;
import static android.view.ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_REGION;
import static android.view.WindowCallbacks.RESIZE_MODE_DOCKED_DIVIDER;
import static android.view.WindowCallbacks.RESIZE_MODE_FREEFORM;
import static android.view.WindowCallbacks.RESIZE_MODE_FREEFORM;
import static android.view.WindowCallbacks.RESIZE_MODE_INVALID;
import static android.view.WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS;
import static android.view.WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS;
import static android.view.WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS;
import static android.view.WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS;
import static android.view.WindowInsetsController.APPEARANCE_LOW_PROFILE_BARS;
import static android.view.WindowInsetsController.APPEARANCE_LOW_PROFILE_BARS;
@@ -85,8 +85,6 @@ import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR_ADDITIONAL
import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;
import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;
import static android.view.WindowManager.LayoutParams.TYPE_TOAST;
import static android.view.WindowManager.LayoutParams.TYPE_TOAST;
import static android.view.WindowManager.LayoutParams.TYPE_VOLUME_OVERLAY;
import static android.view.WindowManager.LayoutParams.TYPE_VOLUME_OVERLAY;
import static android.view.WindowManagerGlobal.RELAYOUT_RES_DRAG_RESIZING_DOCKED;
import static android.view.WindowManagerGlobal.RELAYOUT_RES_DRAG_RESIZING_FREEFORM;
import static android.view.WindowManagerGlobal.RELAYOUT_RES_SURFACE_CHANGED;
import static android.view.WindowManagerGlobal.RELAYOUT_RES_SURFACE_CHANGED;
import static android.view.inputmethod.InputMethodEditorTraceProto.InputMethodClientsTraceProto.ClientSideProto.IME_FOCUS_CONTROLLER;
import static android.view.inputmethod.InputMethodEditorTraceProto.InputMethodClientsTraceProto.ClientSideProto.IME_FOCUS_CONTROLLER;
import static android.view.inputmethod.InputMethodEditorTraceProto.InputMethodClientsTraceProto.ClientSideProto.INSETS_CONTROLLER;
import static android.view.inputmethod.InputMethodEditorTraceProto.InputMethodClientsTraceProto.ClientSideProto.INSETS_CONTROLLER;
@@ -503,9 +501,10 @@ public final class ViewRootImpl implements ViewParent,
    public boolean mIsAnimating;
    public boolean mIsAnimating;


    private boolean mUseMTRenderer;
    private boolean mUseMTRenderer;
    private boolean mPendingDragResizing;
    private boolean mDragResizing;
    private boolean mDragResizing;
    private boolean mInvalidateRootRequested;
    private boolean mInvalidateRootRequested;
    private int mResizeMode;
    private int mResizeMode = RESIZE_MODE_INVALID;
    private int mCanvasOffsetX;
    private int mCanvasOffsetX;
    private int mCanvasOffsetY;
    private int mCanvasOffsetY;
    private boolean mActivityRelaunched;
    private boolean mActivityRelaunched;
@@ -1711,17 +1710,22 @@ public final class ViewRootImpl implements ViewParent,
        final MergedConfiguration mergedConfiguration = (MergedConfiguration) args.arg2;
        final MergedConfiguration mergedConfiguration = (MergedConfiguration) args.arg2;
        final boolean forceNextWindowRelayout = args.argi1 != 0;
        final boolean forceNextWindowRelayout = args.argi1 != 0;
        final int displayId = args.argi3;
        final int displayId = args.argi3;
        final int resizeMode = args.argi5;
        final Rect backdropFrame = frames.backdropFrame;
        final Rect backdropFrame = frames.backdropFrame;


        final boolean frameChanged = !mWinFrame.equals(frames.frame);
        final boolean frameChanged = !mWinFrame.equals(frames.frame);
        final boolean backdropFrameChanged = !mPendingBackDropFrame.equals(backdropFrame);
        final boolean backdropFrameChanged = !mPendingBackDropFrame.equals(backdropFrame);
        final boolean configChanged = !mLastReportedMergedConfiguration.equals(mergedConfiguration);
        final boolean configChanged = !mLastReportedMergedConfiguration.equals(mergedConfiguration);
        final boolean displayChanged = mDisplay.getDisplayId() != displayId;
        final boolean displayChanged = mDisplay.getDisplayId() != displayId;
        final boolean resizeModeChanged = mResizeMode != resizeMode;
        if (msg == MSG_RESIZED && !frameChanged && !backdropFrameChanged && !configChanged
        if (msg == MSG_RESIZED && !frameChanged && !backdropFrameChanged && !configChanged
                && !displayChanged && !forceNextWindowRelayout) {
                && !displayChanged && !resizeModeChanged && !forceNextWindowRelayout) {
            return;
            return;
        }
        }


        mPendingDragResizing = resizeMode != RESIZE_MODE_INVALID;
        mResizeMode = resizeMode;

        if (configChanged) {
        if (configChanged) {
            // If configuration changed - notify about that and, maybe, about move to display.
            // If configuration changed - notify about that and, maybe, about move to display.
            performConfigurationChange(mergedConfiguration, false /* force */,
            performConfigurationChange(mergedConfiguration, false /* force */,
@@ -2920,11 +2924,7 @@ public final class ViewRootImpl implements ViewParent,
                    mViewFrameInfo.flags |= FrameInfo.FLAG_WINDOW_VISIBILITY_CHANGED;
                    mViewFrameInfo.flags |= FrameInfo.FLAG_WINDOW_VISIBILITY_CHANGED;
                }
                }
                relayoutResult = relayoutWindow(params, viewVisibility, insetsPending);
                relayoutResult = relayoutWindow(params, viewVisibility, insetsPending);
                final boolean freeformResizing = (relayoutResult
                final boolean dragResizing = mPendingDragResizing;
                        & RELAYOUT_RES_DRAG_RESIZING_FREEFORM) != 0;
                final boolean dockedResizing = (relayoutResult
                        & RELAYOUT_RES_DRAG_RESIZING_DOCKED) != 0;
                final boolean dragResizing = freeformResizing || dockedResizing;
                if (mSyncSeqId > mLastSyncSeqId) {
                if (mSyncSeqId > mLastSyncSeqId) {
                    mLastSyncSeqId = mSyncSeqId;
                    mLastSyncSeqId = mSyncSeqId;
                    if (DEBUG_BLAST) {
                    if (DEBUG_BLAST) {
@@ -3065,9 +3065,6 @@ public final class ViewRootImpl implements ViewParent,


                if (mDragResizing != dragResizing) {
                if (mDragResizing != dragResizing) {
                    if (dragResizing) {
                    if (dragResizing) {
                        mResizeMode = freeformResizing
                                ? RESIZE_MODE_FREEFORM
                                : RESIZE_MODE_DOCKED_DIVIDER;
                        final boolean backdropSizeMatchesFrame =
                        final boolean backdropSizeMatchesFrame =
                                mWinFrame.width() == mPendingBackDropFrame.width()
                                mWinFrame.width() == mPendingBackDropFrame.width()
                                        && mWinFrame.height() == mPendingBackDropFrame.height();
                                        && mWinFrame.height() == mPendingBackDropFrame.height();
@@ -7982,10 +7979,8 @@ public final class ViewRootImpl implements ViewParent,
                (mDisplayInstallOrientation + mDisplay.getRotation()) % 4);
                (mDisplayInstallOrientation + mDisplay.getRotation()) % 4);


        final WindowConfiguration winConfig = getConfiguration().windowConfiguration;
        final WindowConfiguration winConfig = getConfiguration().windowConfiguration;
        final boolean dragResizing = (relayoutResult
                & (RELAYOUT_RES_DRAG_RESIZING_DOCKED | RELAYOUT_RES_DRAG_RESIZING_FREEFORM)) != 0;
        WindowLayout.computeSurfaceSize(mWindowAttributes, winConfig.getMaxBounds(), requestedWidth,
        WindowLayout.computeSurfaceSize(mWindowAttributes, winConfig.getMaxBounds(), requestedWidth,
                requestedHeight, mTmpFrames.frame, dragResizing, mSurfaceSize);
                requestedHeight, mTmpFrames.frame, mPendingDragResizing, mSurfaceSize);


        final boolean transformHintChanged = transformHint != mLastTransformHint;
        final boolean transformHintChanged = transformHint != mLastTransformHint;
        final boolean sizeChanged = !mLastSurfaceSize.equals(mSurfaceSize);
        final boolean sizeChanged = !mLastSurfaceSize.equals(mSurfaceSize);
@@ -8476,7 +8471,7 @@ public final class ViewRootImpl implements ViewParent,
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
    private void dispatchResized(ClientWindowFrames frames, boolean reportDraw,
    private void dispatchResized(ClientWindowFrames frames, boolean reportDraw,
            MergedConfiguration mergedConfiguration, boolean forceLayout,
            MergedConfiguration mergedConfiguration, boolean forceLayout,
                                 boolean alwaysConsumeSystemBars, int displayId, int seqId) {
            boolean alwaysConsumeSystemBars, int displayId, int seqId, int resizeMode) {
        final Rect frame = frames.frame;
        final Rect frame = frames.frame;
        final Rect backDropFrame = frames.backdropFrame;
        final Rect backDropFrame = frames.backdropFrame;
        if (DEBUG_LAYOUT) Log.v(mTag, "Resizing " + this + ": frame=" + frame.toShortString()
        if (DEBUG_LAYOUT) Log.v(mTag, "Resizing " + this + ": frame=" + frame.toShortString()
@@ -8508,6 +8503,7 @@ public final class ViewRootImpl implements ViewParent,
        args.argi2 = alwaysConsumeSystemBars ? 1 : 0;
        args.argi2 = alwaysConsumeSystemBars ? 1 : 0;
        args.argi3 = displayId;
        args.argi3 = displayId;
        args.argi4 = seqId;
        args.argi4 = seqId;
        args.argi5 = resizeMode;
        msg.obj = args;
        msg.obj = args;
        mHandler.sendMessage(msg);
        mHandler.sendMessage(msg);
    }
    }
@@ -9897,11 +9893,11 @@ public final class ViewRootImpl implements ViewParent,
        @Override
        @Override
        public void resized(ClientWindowFrames frames, boolean reportDraw,
        public void resized(ClientWindowFrames frames, boolean reportDraw,
                MergedConfiguration mergedConfiguration, boolean forceLayout,
                MergedConfiguration mergedConfiguration, boolean forceLayout,
                boolean alwaysConsumeSystemBars, int displayId, int seqId) {
                boolean alwaysConsumeSystemBars, int displayId, int seqId, int resizeMode) {
            final ViewRootImpl viewAncestor = mViewAncestor.get();
            final ViewRootImpl viewAncestor = mViewAncestor.get();
            if (viewAncestor != null) {
            if (viewAncestor != null) {
                viewAncestor.dispatchResized(frames, reportDraw, mergedConfiguration, forceLayout,
                viewAncestor.dispatchResized(frames, reportDraw, mergedConfiguration, forceLayout,
                        alwaysConsumeSystemBars, displayId, seqId);
                        alwaysConsumeSystemBars, displayId, seqId, resizeMode);
            }
            }
        }
        }


+15 −3
Original line number Original line Diff line number Diff line
@@ -28,9 +28,21 @@ import android.graphics.Rect;
 */
 */
public interface WindowCallbacks {
public interface WindowCallbacks {


    public static final int RESIZE_MODE_INVALID = -1;
    int RESIZE_MODE_INVALID = -1;
    public static final int RESIZE_MODE_FREEFORM = 0;

    public static final int RESIZE_MODE_DOCKED_DIVIDER = 1;
    /**
     * The window is being resized by dragging one of the window corners,
     * in this case the surface would be fullscreen-sized. The client should
     * render to the actual frame location (instead of (0,curScrollY)).
     */
    int RESIZE_MODE_FREEFORM = 0;

    /**
     * The window is being resized by dragging on the docked divider. The client should render
     * at (0, 0) and extend its background to the background frame passed into
     * {@link IWindow#resized}.
     */
    int RESIZE_MODE_DOCKED_DIVIDER = 1;


    /**
    /**
     * Called by the system when the window got changed by the user, before the layouter got called.
     * Called by the system when the window got changed by the user, before the layouter got called.
+2 −16
Original line number Original line Diff line number Diff line
@@ -70,31 +70,17 @@ public final class WindowManagerGlobal {
     */
     */
    public static final int RELAYOUT_RES_SURFACE_CHANGED = 1 << 1;
    public static final int RELAYOUT_RES_SURFACE_CHANGED = 1 << 1;


    /**
     * The window is being resized by dragging on the docked divider. The client should render
     * at (0, 0) and extend its background to the background frame passed into
     * {@link IWindow#resized}.
     */
    public static final int RELAYOUT_RES_DRAG_RESIZING_DOCKED = 1 << 2;

    /**
     * The window is being resized by dragging one of the window corners,
     * in this case the surface would be fullscreen-sized. The client should
     * render to the actual frame location (instead of (0,curScrollY)).
     */
    public static final int RELAYOUT_RES_DRAG_RESIZING_FREEFORM = 1 << 3;

    /**
    /**
     * The window manager has changed the size of the surface from the last call.
     * The window manager has changed the size of the surface from the last call.
     */
     */
    public static final int RELAYOUT_RES_SURFACE_RESIZED = 1 << 4;
    public static final int RELAYOUT_RES_SURFACE_RESIZED = 1 << 2;


    /**
    /**
     * In multi-window we force show the system bars. Because we don't want that the surface size
     * In multi-window we force show the system bars. Because we don't want that the surface size
     * changes in this mode, we instead have a flag whether the system bar sizes should always be
     * changes in this mode, we instead have a flag whether the system bar sizes should always be
     * consumed, so the app is treated like there is no virtual system bars at all.
     * consumed, so the app is treated like there is no virtual system bars at all.
     */
     */
    public static final int RELAYOUT_RES_CONSUME_ALWAYS_SYSTEM_BARS = 1 << 5;
    public static final int RELAYOUT_RES_CONSUME_ALWAYS_SYSTEM_BARS = 1 << 3;


    /**
    /**
     * Flag for relayout: the client will be later giving
     * Flag for relayout: the client will be later giving
Loading