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

Commit 7d6f3bab authored by Vladimir Komsiyski's avatar Vladimir Komsiyski Committed by Android (Google) Code Review
Browse files

Merge "SystemApi for specifying insets in LayoutParams" into main

parents 3575d886 d197c078
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -18156,9 +18156,17 @@ package android.view {
    field public static final int DISPLAY_IME_POLICY_LOCAL = 0; // 0x0
  }
  @FlaggedApi("android.companion.virtualdevice.flags.status_bar_and_insets") public static class WindowManager.InsetsParams {
    ctor public WindowManager.InsetsParams(int);
    method @Nullable public android.graphics.Insets getInsetsSize();
    method public int getType();
    method @NonNull public android.view.WindowManager.InsetsParams setInsetsSize(@Nullable android.graphics.Insets);
  }
  public static class WindowManager.LayoutParams extends android.view.ViewGroup.LayoutParams implements android.os.Parcelable {
    method public final long getUserActivityTimeout();
    method public boolean isSystemApplicationOverlay();
    method @FlaggedApi("android.companion.virtualdevice.flags.status_bar_and_insets") public void setInsetsParams(@NonNull java.util.List<android.view.WindowManager.InsetsParams>);
    method @RequiresPermission(android.Manifest.permission.SYSTEM_APPLICATION_OVERLAY) public void setSystemApplicationOverlay(boolean);
    method public final void setUserActivityTimeout(long);
    field @RequiresPermission(android.Manifest.permission.HIDE_NON_SYSTEM_OVERLAY_WINDOWS) public static final int SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS = 524288; // 0x80000
+74 −0
Original line number Diff line number Diff line
@@ -107,6 +107,7 @@ import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.Insets;
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.graphics.Rect;
@@ -4648,6 +4649,30 @@ public interface WindowManager extends ViewManager {
         */
        public InsetsFrameProvider[] providedInsets;

        /**
         * Sets the insets to be provided by the window.
         *
         * @param insetsParams The parameters for the insets to be provided by the window.
         *
         * @hide
         */
        @FlaggedApi(android.companion.virtualdevice.flags.Flags.FLAG_STATUS_BAR_AND_INSETS)
        @SystemApi
        public void setInsetsParams(@NonNull List<InsetsParams> insetsParams) {
            if (insetsParams.isEmpty()) {
                providedInsets = null;
            } else {
                providedInsets = new InsetsFrameProvider[insetsParams.size()];
                for (int i = 0; i < insetsParams.size(); ++i) {
                    final InsetsParams params = insetsParams.get(i);
                    providedInsets[i] =
                            new InsetsFrameProvider(/* owner= */ this, /* index= */ i,
                                    params.getType())
                                    .setInsetsSize(params.getInsetsSize());
                }
            }
        }

        /**
         * Specifies which {@link InsetsType}s should be forcibly shown. The types shown by this
         * method won't affect the app's layout. This field only takes effects if the caller has
@@ -6116,6 +6141,55 @@ public interface WindowManager extends ViewManager {
        }
    }

    /**
     * Specifies the parameters of the insets provided by a window.
     *
     * @see WindowManager.LayoutParams#setInsetsParams(List)
     * @see android.graphics.Insets
     *
     * @hide
     */
    @FlaggedApi(android.companion.virtualdevice.flags.Flags.FLAG_STATUS_BAR_AND_INSETS)
    @SystemApi
    public static class InsetsParams {

        private final @InsetsType int mType;
        private @Nullable Insets mInsets;

        /**
         * Creates an instance of InsetsParams.
         *
         * @param type the type of insets to provide, e.g. {@link WindowInsets.Type#statusBars()}.
         * @see WindowInsets.Type
         */
        public InsetsParams(@InsetsType int type) {
            mType = type;
        }

        /**
         * Sets the size of the provided insets. If {@code null}, then the provided insets will
         * have the same size as the window frame.
         */
        public @NonNull InsetsParams setInsetsSize(@Nullable Insets insets) {
            mInsets = insets;
            return this;
        }

        /**
         * Returns the type of provided insets.
         */
        public @InsetsType int getType() {
            return mType;
        }

        /**
         * Returns the size of the provided insets.
         */
        public @Nullable Insets getInsetsSize() {
            return mInsets;
        }
    }

    /**
     * Holds the WM lock for the specified amount of milliseconds.
     * Intended for use by the tests that need to imitate lock contention.