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

Commit 20eb3c91 authored by Tiger Huang's avatar Tiger Huang
Browse files

Revert "Introduce updateVisibility and updateLayout"

This reverts commit:
db407ef1, and
d8aa7f78.

Reason for revert:
The surface size would be reduced by mTranslator unexpectedly.

Fix: 233017734
Test: Open a legacy app which has CompatibilityInfo.SCALING_REQUIRED
      and see if the app is cropped.
Change-Id: If830866328a5709cf6856fe840a804b304052003
parent 15751451
Loading
Loading
Loading
Loading
+5 −29
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@ import static android.graphics.Matrix.MSKEW_X;
import static android.graphics.Matrix.MSKEW_Y;
import static android.view.SurfaceControl.METADATA_WINDOW_TYPE;
import static android.view.View.SYSTEM_UI_FLAG_VISIBLE;
import static android.view.ViewRootImpl.LOCAL_LAYOUT;
import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER;

import android.animation.AnimationHandler;
@@ -41,7 +40,6 @@ import android.app.Service;
import android.app.WallpaperColors;
import android.app.WallpaperInfo;
import android.app.WallpaperManager;
import android.app.WindowConfiguration;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.content.Intent;
@@ -260,8 +258,6 @@ public abstract class WallpaperService extends Service {
        private final Point mLastSurfaceSize = new Point();
        private final Matrix mTmpMatrix = new Matrix();
        private final float[] mTmpValues = new float[9];
        private final WindowLayout mWindowLayout = new WindowLayout();
        private final Rect mTempRect = new Rect();

        final WindowManager.LayoutParams mLayout
                = new WindowManager.LayoutParams();
@@ -1100,8 +1096,7 @@ public abstract class WallpaperService extends Service {
                            | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;

                    final Configuration config = mMergedConfiguration.getMergedConfiguration();
                    final WindowConfiguration winConfig = config.windowConfiguration;
                    final Rect maxBounds = winConfig.getMaxBounds();
                    final Rect maxBounds = config.windowConfiguration.getMaxBounds();
                    if (myWidth == ViewGroup.LayoutParams.MATCH_PARENT
                            && myHeight == ViewGroup.LayoutParams.MATCH_PARENT) {
                        mLayout.width = myWidth;
@@ -1158,28 +1153,9 @@ public abstract class WallpaperService extends Service {
                    } else {
                        mLayout.surfaceInsets.set(0, 0, 0, 0);
                    }

                    int relayoutResult = 0;
                    if (LOCAL_LAYOUT) {
                        if (!mSurfaceControl.isValid()) {
                            relayoutResult = mSession.updateVisibility(mWindow, mLayout,
                                    View.VISIBLE, mMergedConfiguration, mSurfaceControl,
                                    mInsetsState, mTempControls);
                        }

                        final Rect displayCutoutSafe = mTempRect;
                        mInsetsState.getDisplayCutoutSafe(displayCutoutSafe);
                        mWindowLayout.computeFrames(mLayout, mInsetsState, displayCutoutSafe,
                                winConfig.getBounds(), winConfig.getWindowingMode(), mWidth,
                                mHeight, mRequestedVisibilities, 1f /* compatScale */, mWinFrames);

                        mSession.updateLayout(mWindow, mLayout, 0 /* flags */, mWinFrames, mWidth,
                                mHeight);
                    } else {
                        relayoutResult = mSession.relayout(mWindow, mLayout, mWidth, mHeight,
                                View.VISIBLE, 0, mWinFrames, mMergedConfiguration,
                                mSurfaceControl, mInsetsState, mTempControls, mSyncSeqIdBundle);
                    }
                    final int relayoutResult = mSession.relayout(mWindow, mLayout, mWidth, mHeight,
                            View.VISIBLE, 0, mWinFrames, mMergedConfiguration, mSurfaceControl,
                            mInsetsState, mTempControls, mSyncSeqIdBundle);

                    final int transformHint = SurfaceControl.rotationToBufferTransform(
                            (mDisplayInstallOrientation + mDisplay.getRotation()) % 4);
@@ -1228,7 +1204,7 @@ public abstract class WallpaperService extends Service {
                            null /* ignoringVisibilityState */, config.isScreenRound(),
                            false /* alwaysConsumeSystemBars */, mLayout.softInputMode,
                            mLayout.flags, SYSTEM_UI_FLAG_VISIBLE, mLayout.type,
                            winConfig.getWindowingMode(), null /* typeSideMap */);
                            config.windowConfiguration.getWindowingMode(), null /* typeSideMap */);

                    if (!fixedSize) {
                        final Rect padding = mIWallpaperEngine.mDisplayPadding;
+0 −35
Original line number Diff line number Diff line
@@ -109,41 +109,6 @@ interface IWindowSession {
            out InsetsState insetsState, out InsetsSourceControl[] activeControls,
            out Bundle bundle);

    /**
     * Changes the view visibility and the attributes of a window. This should only be called when
     * the visibility of the root view is changed. This returns a valid surface if the root view is
     * visible. This also returns the latest information for the caller to compute its window frame.
     *
     * @param window The window being updated.
     * @param attrs If non-null, new attributes to apply to the window.
     * @param viewVisibility Window root view's visibility.
     * @param outMergedConfiguration New config container that holds global, override and merged
     * config for window, if it is now becoming visible and the merged configuration has changed
     * since it was last displayed.
     * @param outSurfaceControl Object in which is placed the new display surface.
     * @param outInsetsState The current insets state in the system.
     * @param outActiveControls The insets source controls for the caller to override the insets
     * state in the system.
     *
     * @return int Result flags: {@link WindowManagerGlobal#RELAYOUT_FIRST_TIME}.
     */
    int updateVisibility(IWindow window, in WindowManager.LayoutParams attrs, int viewVisibility,
            out MergedConfiguration outMergedConfiguration, out SurfaceControl outSurfaceControl,
            out InsetsState outInsetsState, out InsetsSourceControl[] outActiveControls);

    /**
     * Reports the layout results and the attributes of a window to the server.
     *
     * @param window The window being reported.
     * @param attrs If non-null, new attributes to apply to the window.
     * @param flags Request flags: {@link WindowManagerGlobal#RELAYOUT_INSETS_PENDING}.
     * @param clientFrames the window frames computed by the client.
     * @param requestedWidth The width the window wants to be.
     * @param requestedHeight The height the window wants to be.
     */
    oneway void updateLayout(IWindow window, in WindowManager.LayoutParams attrs, int flags,
            in ClientWindowFrames clientFrames, int requestedWidth, int requestedHeight);

    /*
     * Notify the window manager that an application is relaunching and
     * windows should be prepared for replacement.
+22 −60
Original line number Diff line number Diff line
@@ -75,7 +75,6 @@ import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_INSET_PARENT_
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_LAYOUT_SIZE_EXTENDED_BY_CUTOUT;
import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE;
import static android.view.WindowManager.LayoutParams.SOFT_INPUT_MASK_ADJUST;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING;
import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD;
import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR_ADDITIONAL;
import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;
@@ -8009,44 +8008,7 @@ public final class ViewRootImpl implements ViewParent,
        final int requestedWidth = (int) (mView.getMeasuredWidth() * appScale + 0.5f);
        final int requestedHeight = (int) (mView.getMeasuredHeight() * appScale + 0.5f);

        int relayoutResult = 0;
        WindowConfiguration winConfig = getConfiguration().windowConfiguration;
        if (LOCAL_LAYOUT) {
            if (mFirst || viewVisibility != mViewVisibility) {
                relayoutResult = mWindowSession.updateVisibility(mWindow, params, viewVisibility,
                        mPendingMergedConfiguration, mSurfaceControl, mTempInsets, mTempControls);
                if (mTranslator != null) {
                    mTranslator.translateInsetsStateInScreenToAppWindow(mTempInsets);
                    mTranslator.translateSourceControlsInScreenToAppWindow(mTempControls);
                }
                mInsetsController.onStateChanged(mTempInsets);
                mInsetsController.onControlsChanged(mTempControls);

                mPendingAlwaysConsumeSystemBars =
                        (relayoutResult & RELAYOUT_RES_CONSUME_ALWAYS_SYSTEM_BARS) != 0;
            }
            final InsetsState state = mInsetsController.getState();
            final Rect displayCutoutSafe = mTempRect;
            state.getDisplayCutoutSafe(displayCutoutSafe);
            if (mWindowAttributes.type == TYPE_APPLICATION_STARTING) {
                // TODO(b/210378379): Remove the special logic.
                // Letting starting window use the window bounds from the pending config is for the
                // fixed rotation, because the config is not overridden before the starting window
                // is created.
                winConfig = mPendingMergedConfiguration.getMergedConfiguration()
                        .windowConfiguration;
            }
            mWindowLayout.computeFrames(mWindowAttributes, state, displayCutoutSafe,
                    winConfig.getBounds(), winConfig.getWindowingMode(), requestedWidth,
                    requestedHeight, mInsetsController.getRequestedVisibilities(),
                    1f /* compatScale */, mTmpFrames);

            mWindowSession.updateLayout(mWindow, params,
                    insetsPending ? WindowManagerGlobal.RELAYOUT_INSETS_PENDING : 0, mTmpFrames,
                    requestedWidth, requestedHeight);

        } else {
            relayoutResult = mWindowSession.relayout(mWindow, params,
        int relayoutResult = mWindowSession.relayout(mWindow, params,
                requestedWidth, requestedHeight, viewVisibility,
                insetsPending ? WindowManagerGlobal.RELAYOUT_INSETS_PENDING : 0,
                mTmpFrames, mPendingMergedConfiguration, mSurfaceControl, mTempInsets,
@@ -8056,23 +8018,10 @@ public final class ViewRootImpl implements ViewParent,
            mSyncSeqId = maybeSyncSeqId;
        }

            if (mTranslator != null) {
                mTranslator.translateRectInScreenToAppWindow(mTmpFrames.frame);
                mTranslator.translateRectInScreenToAppWindow(mTmpFrames.displayFrame);
                mTranslator.translateRectInScreenToAppWindow(mTmpFrames.attachedFrame);
                mTranslator.translateInsetsStateInScreenToAppWindow(mTempInsets);
                mTranslator.translateSourceControlsInScreenToAppWindow(mTempControls);
            }
            mInsetsController.onStateChanged(mTempInsets);
            mInsetsController.onControlsChanged(mTempControls);

            mPendingAlwaysConsumeSystemBars =
                    (relayoutResult & RELAYOUT_RES_CONSUME_ALWAYS_SYSTEM_BARS) != 0;
        }

        final int transformHint = SurfaceControl.rotationToBufferTransform(
                (mDisplayInstallOrientation + mDisplay.getRotation()) % 4);

        final WindowConfiguration winConfig = getConfiguration().windowConfiguration;
        WindowLayout.computeSurfaceSize(mWindowAttributes, winConfig.getMaxBounds(), requestedWidth,
                requestedHeight, mTmpFrames.frame, mPendingDragResizing, mSurfaceSize);

@@ -8121,10 +8070,23 @@ public final class ViewRootImpl implements ViewParent,
            destroySurface();
        }

        mPendingAlwaysConsumeSystemBars =
                (relayoutResult & RELAYOUT_RES_CONSUME_ALWAYS_SYSTEM_BARS) != 0;

        if (restore) {
            params.restore();
        }

        if (mTranslator != null) {
            mTranslator.translateRectInScreenToAppWindow(mTmpFrames.frame);
            mTranslator.translateRectInScreenToAppWindow(mTmpFrames.displayFrame);
            mTranslator.translateRectInScreenToAppWindow(mTmpFrames.attachedFrame);
            mTranslator.translateInsetsStateInScreenToAppWindow(mTempInsets);
            mTranslator.translateSourceControlsInScreenToAppWindow(mTempControls);
        }
        setFrame(mTmpFrames.frame);
        mInsetsController.onStateChanged(mTempInsets);
        mInsetsController.onControlsChanged(mTempControls);
        return relayoutResult;
    }

+0 −15
Original line number Diff line number Diff line
@@ -337,21 +337,6 @@ public class WindowlessWindowManager implements IWindowSession {
        return 0;
    }

    @Override
    public int updateVisibility(IWindow window, WindowManager.LayoutParams inAttrs,
            int viewVisibility, MergedConfiguration outMergedConfiguration,
            SurfaceControl outSurfaceControl, InsetsState outInsetsState,
            InsetsSourceControl[] outActiveControls) {
        // TODO(b/161810301): Finish the implementation.
        return 0;
    }

    @Override
    public void updateLayout(IWindow window, WindowManager.LayoutParams inAttrs, int flags,
            ClientWindowFrames clientWindowFrames, int requestedWidth, int requestedHeight) {
        // TODO(b/161810301): Finish the implementation.
    }

    @Override
    public void prepareToReplaceWindows(android.os.IBinder appToken, boolean childrenOnly) {
    }
+3 −25
Original line number Diff line number Diff line
@@ -20,10 +20,8 @@ import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME;
import static android.graphics.Color.WHITE;
import static android.graphics.Color.alpha;
import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER;
import static android.view.ViewRootImpl.LOCAL_LAYOUT;
import static android.view.WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS;
import static android.view.WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS;
import static android.view.WindowLayout.UNSPECIFIED_LENGTH;
import static android.view.WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
import static android.view.WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED;
import static android.view.WindowManager.LayoutParams.FLAG_IGNORE_CHEEK_PRESSES;
@@ -53,7 +51,6 @@ import android.annotation.Nullable;
import android.app.ActivityManager;
import android.app.ActivityManager.TaskDescription;
import android.app.ActivityThread;
import android.app.WindowConfiguration;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
@@ -80,7 +77,6 @@ import android.view.SurfaceSession;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowInsets;
import android.view.WindowLayout;
import android.view.WindowManager;
import android.view.WindowManagerGlobal;
import android.window.ClientWindowFrames;
@@ -212,8 +208,6 @@ public class TaskSnapshotWindow {
        final IWindowSession session = WindowManagerGlobal.getWindowSession();
        final SurfaceControl surfaceControl = new SurfaceControl();
        final ClientWindowFrames tmpFrames = new ClientWindowFrames();
        final WindowLayout windowLayout = new WindowLayout();
        final Rect displayCutoutSafe = new Rect();

        final InsetsSourceControl[] tmpControls = new InsetsSourceControl[0];
        final MergedConfiguration tmpMergedConfiguration = new MergedConfiguration();
@@ -251,25 +245,9 @@ public class TaskSnapshotWindow {
        window.setOuter(snapshotSurface);
        try {
            Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "TaskSnapshot#relayout");
            if (LOCAL_LAYOUT) {
                if (!surfaceControl.isValid()) {
                    session.updateVisibility(window, layoutParams, View.VISIBLE,
                            tmpMergedConfiguration, surfaceControl, tmpInsetsState, tmpControls);
                }
                tmpInsetsState.getDisplayCutoutSafe(displayCutoutSafe);
                final WindowConfiguration winConfig =
                        tmpMergedConfiguration.getMergedConfiguration().windowConfiguration;
                windowLayout.computeFrames(layoutParams, tmpInsetsState, displayCutoutSafe,
                        winConfig.getBounds(), winConfig.getWindowingMode(), UNSPECIFIED_LENGTH,
                        UNSPECIFIED_LENGTH, info.requestedVisibilities, 1f /* compatScale */,
                        tmpFrames);
                session.updateLayout(window, layoutParams, 0 /* flags */, tmpFrames,
                        UNSPECIFIED_LENGTH, UNSPECIFIED_LENGTH);
            } else {
            session.relayout(window, layoutParams, -1, -1, View.VISIBLE, 0,
                    tmpFrames, tmpMergedConfiguration, surfaceControl, tmpInsetsState,
                    tmpControls, new Bundle());
            }
            Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
        } catch (RemoteException e) {
            snapshotSurface.clearWindowSynced();
Loading