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

Commit f96c90ac authored by Jorim Jaggi's avatar Jorim Jaggi
Browse files

A brave new world for window insets (1/n)

This CL starts a journey to discover a brave new inset world. The
path to get us there may be rocky, but it's going to be rocky.

One of the main pledges of the new API is that an app can retrieve
what is causing a certain inset easily. For that, we need to
dispatch metadata who is causing what inset, such that we can query
it from the client side.

Furthermore, the client will be able to manipulate insets directly,
but also listen to animation changes. We don't want to go through
window manager for that, thus, there needs to be a local codepath
from (global window state -> WindowInsets).

Because we have these two requirements, we dispatch the relevant
global window state for insets, represented by InsetsState, and
dispatch it to the client. On the client side we take the frame
and the InsetsState and generate WindowInsets out of it.

Bug: 118118435
Test: InsetsSourceTest, InsetsStateTest, InsetsSourceProviderTest,
InsetsStateControllerTest
Change-Id: I2bfe9dda376512916261823fc2ee35cbedeb6731
parent e30fc89f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -13940,6 +13940,7 @@ package android.graphics {
  }
  public final class Insets {
    method public static android.graphics.Insets add(android.graphics.Insets, android.graphics.Insets);
    method public static android.graphics.Insets of(int, int, int, int);
    method public static android.graphics.Insets of(android.graphics.Rect);
    field public static final android.graphics.Insets NONE;
+0 −1
Original line number Diff line number Diff line
@@ -1461,7 +1461,6 @@ Landroid/view/IWindowManager;->setShelfHeight(ZI)V
Landroid/view/IWindowManager;->setStrictModeVisualIndicatorPreference(Ljava/lang/String;)V
Landroid/view/IWindowManager;->showStrictModeViolation(Z)V
Landroid/view/IWindowManager;->thawRotation()V
Landroid/view/IWindowSession$Stub$Proxy;->relayout(Landroid/view/IWindow;ILandroid/view/WindowManager$LayoutParams;IIIIJLandroid/graphics/Rect;Landroid/graphics/Rect;Landroid/graphics/Rect;Landroid/graphics/Rect;Landroid/graphics/Rect;Landroid/graphics/Rect;Landroid/graphics/Rect;Landroid/view/DisplayCutout$ParcelableWrapper;Landroid/util/MergedConfiguration;Landroid/view/Surface;)I
Landroid/view/IWindowSession$Stub;->asInterface(Landroid/os/IBinder;)Landroid/view/IWindowSession;
Landroid/view/IWindowSession;->finishDrawing(Landroid/view/IWindow;)V
Landroid/view/IWindowSession;->getInTouchMode()Z
+7 −2
Original line number Diff line number Diff line
@@ -56,6 +56,7 @@ import android.view.SurfaceHolder;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowInsets;
import android.view.InsetsState;
import android.view.WindowManager;
import android.view.WindowManagerGlobal;

@@ -184,6 +185,7 @@ public abstract class WallpaperService extends Service {
        final DisplayCutout.ParcelableWrapper mDisplayCutout =
                new DisplayCutout.ParcelableWrapper();
        DisplayCutout mDispatchedDisplayCutout = DisplayCutout.NO_CUTOUT;
        final InsetsState mInsetsState = new InsetsState();
        final MergedConfiguration mMergedConfiguration = new MergedConfiguration();

        final WindowManager.LayoutParams mLayout
@@ -803,9 +805,11 @@ public abstract class WallpaperService extends Service {
                        mLayout.windowAnimations =
                                com.android.internal.R.style.Animation_Wallpaper;
                        mInputChannel = new InputChannel();

                        if (mSession.addToDisplay(mWindow, mWindow.mSeq, mLayout, View.VISIBLE,
                                mDisplay.getDisplayId(), mWinFrame, mContentInsets, mStableInsets,
                                mOutsets, mDisplayCutout, mInputChannel) < 0) {
                                mOutsets, mDisplayCutout, mInputChannel,
                                mInsetsState) < 0) {
                            Log.w(TAG, "Failed to add window while updating wallpaper surface.");
                            return;
                        }
@@ -831,7 +835,8 @@ public abstract class WallpaperService extends Service {
                        mWindow, mWindow.mSeq, mLayout, mWidth, mHeight,
                            View.VISIBLE, 0, -1, mWinFrame, mOverscanInsets, mContentInsets,
                            mVisibleInsets, mStableInsets, mOutsets, mBackdropFrame,
                            mDisplayCutout, mMergedConfiguration, mSurfaceHolder.mSurface);
                            mDisplayCutout, mMergedConfiguration, mSurfaceHolder.mSurface,
                            mInsetsState);

                    if (DEBUG) Log.v(TAG, "New surface: " + mSurfaceHolder.mSurface
                            + ", frame=" + mWinFrame);
+7 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.view.DragEvent;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.DisplayCutout;
import android.view.InsetsState;

import com.android.internal.os.IResultReceiver;
import android.util.MergedConfiguration;
@@ -53,6 +54,12 @@ oneway interface IWindow {
            in MergedConfiguration newMergedConfiguration, in Rect backDropFrame,
            boolean forceLayout, boolean alwaysConsumeNavBar, int displayId,
            in DisplayCutout.ParcelableWrapper displayCutout);

    /**
     * Called when the window insets configuration has changed.
     */
    void insetsChanged(in InsetsState insetsState);

    void moved(int newX, int newY);
    void dispatchAppVisibility(boolean visible);
    void dispatchGetNewSurface();
+7 −3
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import android.view.IWindow;
import android.view.IWindowId;
import android.view.MotionEvent;
import android.view.WindowManager;
import android.view.InsetsState;
import android.view.Surface;
import android.view.SurfaceControl;

@@ -40,10 +41,11 @@ interface IWindowSession {
    int addToDisplay(IWindow window, int seq, in WindowManager.LayoutParams attrs,
            in int viewVisibility, in int layerStackId, out Rect outFrame,
            out Rect outContentInsets, out Rect outStableInsets, out Rect outOutsets,
            out DisplayCutout.ParcelableWrapper displayCutout, out InputChannel outInputChannel);
            out DisplayCutout.ParcelableWrapper displayCutout, out InputChannel outInputChannel,
            out InsetsState insetsState);
    int addToDisplayWithoutInputChannel(IWindow window, int seq, in WindowManager.LayoutParams attrs,
            in int viewVisibility, in int layerStackId, out Rect outContentInsets,
            out Rect outStableInsets);
            out Rect outStableInsets, out InsetsState insetsState);
    void remove(IWindow window);

    /**
@@ -86,6 +88,7 @@ interface IWindowSession {
     * config for window, if it is now becoming visible and the merged configuration has changed
     * since it was last displayed.
     * @param outSurface Object in which is placed the new display surface.
     * @param insetsState The current insets state in the system.
     *
     * @return int Result flags: {@link WindowManagerGlobal#RELAYOUT_SHOW_FOCUS},
     * {@link WindowManagerGlobal#RELAYOUT_FIRST_TIME}.
@@ -96,7 +99,8 @@ interface IWindowSession {
            out Rect outContentInsets, out Rect outVisibleInsets, out Rect outStableInsets,
            out Rect outOutsets, out Rect outBackdropFrame,
            out DisplayCutout.ParcelableWrapper displayCutout,
            out MergedConfiguration outMergedConfiguration, out Surface outSurface);
            out MergedConfiguration outMergedConfiguration, out Surface outSurface,
            out InsetsState insetsState);

    /*
     * Notify the window manager that an application is relaunching and
Loading