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

Commit 9e2c966d authored by Tiger Huang's avatar Tiger Huang Committed by Android (Google) Code Review
Browse files

Merge "Don't dispatch legacy insets to client"

parents 6993eecd 2bf8c796
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -86,8 +86,6 @@ public class WindowAddRemovePerfTest extends WindowManagerPerfTestBase
        final WindowManager.LayoutParams mLayoutParams = new WindowManager.LayoutParams();
        final InsetsState mRequestedVisibility = new InsetsState();
        final Rect mOutFrame = new Rect();
        final Rect mOutContentInsets = new Rect();
        final Rect mOutStableInsets = new Rect();
        final DisplayCutout.ParcelableWrapper mOutDisplayCutout =
                new DisplayCutout.ParcelableWrapper();
        final InsetsState mOutInsetsState = new InsetsState();
@@ -110,7 +108,6 @@ public class WindowAddRemovePerfTest extends WindowManagerPerfTestBase
                long startTime = SystemClock.elapsedRealtimeNanos();
                session.addToDisplay(this, mLayoutParams, View.VISIBLE,
                        Display.DEFAULT_DISPLAY, mRequestedVisibility, mOutFrame,
                        mOutContentInsets, mOutStableInsets,
                        mOutDisplayCutout, inputChannel, mOutInsetsState, mOutControls);
                final long elapsedTimeNsOfAdd = SystemClock.elapsedRealtimeNanos() - startTime;
                state.addExtraResult("add", elapsedTimeNsOfAdd);
+18 −11
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import android.os.Build.VERSION_CODES;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.DisplayMetrics;
import android.view.InsetsState;
import android.view.MotionEvent;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;
@@ -329,14 +330,6 @@ public class CompatibilityInfo implements Parcelable {
                    CompatibilityInfo.this.applicationInvertedScale);
        }

        /**
         * Translate the screen rect to the application frame.
         */
        @UnsupportedAppUsage
        public void translateRectInScreenToAppWinFrame(Rect rect) {
            rect.scale(applicationInvertedScale);
        }

        /**
         * Translate the region in window to screen.
         */
@@ -389,6 +382,13 @@ public class CompatibilityInfo implements Parcelable {
            params.scale(applicationScale);
        }

        /**
         * Translate a length in application's window to screen.
         */
        public float translateLengthInAppWindowToScreen(float length) {
            return length * applicationScale;
        }

        /**
         * Translate a Rect in application's window to screen.
         */
@@ -405,6 +405,13 @@ public class CompatibilityInfo implements Parcelable {
            rect.scale(applicationInvertedScale);
        }

        /**
         * Translate an InsetsState in screen coordinates into the app window's coordinates.
         */
        public void translateInsetsStateInScreenToAppWindow(InsetsState state) {
            state.scale(applicationInvertedScale);
        }

        /**
         * Translate a Point in screen coordinates into the app window's coordinates.
         */
+24 −23
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import static android.graphics.Matrix.MSCALE_X;
import static android.graphics.Matrix.MSCALE_Y;
import static android.graphics.Matrix.MSKEW_X;
import static android.graphics.Matrix.MSKEW_Y;
import static android.view.View.SYSTEM_UI_FLAG_VISIBLE;

import android.annotation.FloatRange;
import android.annotation.Nullable;
@@ -33,6 +34,7 @@ import android.app.WallpaperManager;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Canvas;
@@ -878,7 +880,6 @@ public abstract class WallpaperService extends Service {

                        if (mSession.addToDisplay(mWindow, mLayout, View.VISIBLE,
                                mDisplay.getDisplayId(), mInsetsState, mWinFrames.frame,
                                mWinFrames.contentInsets, mWinFrames.stableInsets,
                                mWinFrames.displayCutout, inputChannel, mInsetsState,
                                mTempControls) < 0) {
                            Log.w(TAG, "Failed to add window while updating wallpaper surface.");
@@ -914,20 +915,22 @@ public abstract class WallpaperService extends Service {
                    int w = mWinFrames.frame.width();
                    int h = mWinFrames.frame.height();

                    final DisplayCutout rawCutout = mWinFrames.displayCutout.get();
                    final Configuration config = getResources().getConfiguration();
                    final Rect visibleFrame = new Rect(mWinFrames.frame);
                    visibleFrame.intersect(mInsetsState.getDisplayFrame());
                    WindowInsets windowInsets = mInsetsState.calculateInsets(visibleFrame,
                            null /* ignoringVisibilityState */, config.isScreenRound(),
                            false /* alwaysConsumeSystemBars */, rawCutout, mLayout.softInputMode,
                            mLayout.flags, SYSTEM_UI_FLAG_VISIBLE, mLayout.type,
                            config.windowConfiguration.getWindowingMode(), null /* typeSideMap */);

                    if (!fixedSize) {
                        final Rect padding = mIWallpaperEngine.mDisplayPadding;
                        w += padding.left + padding.right;
                        h += padding.top + padding.bottom;
                        mWinFrames.contentInsets.left += padding.left;
                        mWinFrames.contentInsets.top += padding.top;
                        mWinFrames.contentInsets.right += padding.right;
                        mWinFrames.contentInsets.bottom += padding.bottom;
                        mWinFrames.stableInsets.left += padding.left;
                        mWinFrames.stableInsets.top += padding.top;
                        mWinFrames.stableInsets.right += padding.right;
                        mWinFrames.stableInsets.bottom += padding.bottom;
                        mWinFrames.displayCutout.set(mWinFrames.displayCutout.get().inset(
                                -padding.left, -padding.top, -padding.right, -padding.bottom));
                        windowInsets = windowInsets.insetUnchecked(
                                -padding.left, -padding.top, -padding.right, -padding.bottom);
                    } else {
                        w = myWidth;
                        h = myHeight;
@@ -946,9 +949,12 @@ public abstract class WallpaperService extends Service {
                        Log.v(TAG, "Wallpaper size has changed: (" + mCurWidth + ", " + mCurHeight);
                    }

                    final DisplayCutout displayCutout = mWinFrames.displayCutout.get();
                    insetsChanged |= !mDispatchedContentInsets.equals(mWinFrames.contentInsets);
                    insetsChanged |= !mDispatchedStableInsets.equals(mWinFrames.stableInsets);
                    final Rect contentInsets = windowInsets.getSystemWindowInsets().toRect();
                    final Rect stableInsets = windowInsets.getStableInsets().toRect();
                    final DisplayCutout displayCutout = windowInsets.getDisplayCutout() != null
                            ? windowInsets.getDisplayCutout() : rawCutout;
                    insetsChanged |= !mDispatchedContentInsets.equals(contentInsets);
                    insetsChanged |= !mDispatchedStableInsets.equals(stableInsets);
                    insetsChanged |= !mDispatchedDisplayCutout.equals(displayCutout);

                    mSurfaceHolder.setSurfaceFrameSize(w, h);
@@ -1008,18 +1014,13 @@ public abstract class WallpaperService extends Service {
                        }

                        if (insetsChanged) {
                            mDispatchedContentInsets.set(mWinFrames.contentInsets);
                            mDispatchedStableInsets.set(mWinFrames.stableInsets);
                            mDispatchedContentInsets.set(contentInsets);
                            mDispatchedStableInsets.set(stableInsets);
                            mDispatchedDisplayCutout = displayCutout;
                            mFinalStableInsets.set(mDispatchedStableInsets);
                            WindowInsets insets = new WindowInsets(mFinalSystemInsets,
                                    mFinalStableInsets,
                                    getResources().getConfiguration().isScreenRound(), false,
                                    mDispatchedDisplayCutout);
                            if (DEBUG) {
                                Log.v(TAG, "dispatching insets=" + insets);
                                Log.v(TAG, "dispatching insets=" + windowInsets);
                            }
                            onApplyWindowInsets(insets);
                            onApplyWindowInsets(windowInsets);
                        }

                        if (redrawNeeded) {
+0 −1
Original line number Diff line number Diff line
@@ -729,7 +729,6 @@ interface IWindowManager
     * @return {@code true} if system bars are always comsumed.
     */
    boolean getWindowInsets(in WindowManager.LayoutParams attrs, int displayId,
            out Rect outContentInsets, out Rect outStableInsets,
            out DisplayCutout.ParcelableWrapper outDisplayCutout, out InsetsState outInsetsState);

    /**
+7 −9
Original line number Diff line number Diff line
@@ -46,18 +46,16 @@ import java.util.List;
interface IWindowSession {
    int addToDisplay(IWindow window, in WindowManager.LayoutParams attrs,
            in int viewVisibility, in int layerStackId, in InsetsState requestedVisibility,
            out Rect outFrame, out Rect outContentInsets, out Rect outStableInsets,
            out DisplayCutout.ParcelableWrapper displayCutout, out InputChannel outInputChannel,
            out InsetsState insetsState, out InsetsSourceControl[] activeControls);
            out Rect outFrame, out DisplayCutout.ParcelableWrapper displayCutout,
            out InputChannel outInputChannel, out InsetsState insetsState,
            out InsetsSourceControl[] activeControls);
    int addToDisplayAsUser(IWindow window, in WindowManager.LayoutParams attrs,
            in int viewVisibility, in int layerStackId, in int userId,
                in InsetsState requestedVisibility,
                out Rect outFrame, out Rect outContentInsets, out Rect outStableInsets,
            in InsetsState requestedVisibility, out Rect outFrame,
            out DisplayCutout.ParcelableWrapper displayCutout, out InputChannel outInputChannel,
            out InsetsState insetsState, out InsetsSourceControl[] activeControls);
    int addToDisplayWithoutInputChannel(IWindow window, in WindowManager.LayoutParams attrs,
            in int viewVisibility, in int layerStackId, out Rect outContentInsets,
            out Rect outStableInsets, out InsetsState insetsState);
            in int viewVisibility, in int layerStackId, out InsetsState insetsState);
    @UnsupportedAppUsage
    void remove(IWindow window);

Loading