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

Commit 3e9aa1c7 authored by Issei Suzuki's avatar Issei Suzuki Committed by Android (Google) Code Review
Browse files

Merge "Set insets on the virtual display to avoid IME covering the bubble."

parents 2a464632 a5dbf52d
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -14191,13 +14191,16 @@ package android.graphics {
    field public static final int YV12 = 842094169; // 0x32315659
  }
  public final class Insets {
  public final class Insets implements android.os.Parcelable {
    method @NonNull public static android.graphics.Insets add(@NonNull android.graphics.Insets, @NonNull android.graphics.Insets);
    method public int describeContents();
    method @NonNull public static android.graphics.Insets max(@NonNull android.graphics.Insets, @NonNull android.graphics.Insets);
    method @NonNull public static android.graphics.Insets min(@NonNull android.graphics.Insets, @NonNull android.graphics.Insets);
    method @NonNull public static android.graphics.Insets of(int, int, int, int);
    method @NonNull public static android.graphics.Insets of(@Nullable android.graphics.Rect);
    method @NonNull public static android.graphics.Insets subtract(@NonNull android.graphics.Insets, @NonNull android.graphics.Insets);
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.graphics.Insets> CREATOR;
    field public static final android.graphics.Insets NONE;
    field public final int bottom;
    field public final int left;
+23 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.app.ActivityManager.StackInfo;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.graphics.Insets;
import android.hardware.display.DisplayManager;
import android.hardware.display.VirtualDisplay;
import android.os.RemoteException;
@@ -84,6 +85,8 @@ public class ActivityView extends ViewGroup {
    /** The ActivityView is only allowed to contain one task. */
    private final boolean mSingleTaskInstance;

    private Insets mForwardedInsets;

    @UnsupportedAppUsage
    public ActivityView(Context context) {
        this(context, null /* attrs */);
@@ -369,11 +372,13 @@ public class ActivityView extends ViewGroup {
                .build();

        try {
            // TODO: Find a way to consolidate these calls to the server.
            wm.reparentDisplayContent(displayId, mRootSurfaceControl);
            wm.dontOverrideDisplayInfo(displayId);
            if (mSingleTaskInstance) {
                mActivityTaskManager.setDisplayToSingleTaskInstance(displayId);
            }
            wm.setForwardedInsets(displayId, mForwardedInsets);
        } catch (RemoteException e) {
            e.rethrowAsRuntimeException();
        }
@@ -453,6 +458,24 @@ public class ActivityView extends ViewGroup {
        }
    }

    /**
     * Set forwarded insets on the virtual display.
     *
     * @see IWindowManager#setForwardedInsets
     */
    public void setForwardedInsets(Insets insets) {
        mForwardedInsets = insets;
        if (mVirtualDisplay == null) {
            return;
        }
        try {
            final IWindowManager wm = WindowManagerGlobal.getWindowManagerService();
            wm.setForwardedInsets(mVirtualDisplay.getDisplay().getDisplayId(), mForwardedInsets);
        } catch (RemoteException e) {
            e.rethrowAsRuntimeException();
        }
    }

    /**
     * A task change listener that detects background color change of the topmost stack on our
     * virtual display and updates the background of the surface view. This background will be shown
+11 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.content.res.CompatibilityInfo;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.GraphicBuffer;
import android.graphics.Insets;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.Region;
@@ -379,6 +380,16 @@ interface IWindowManager
     */
    void getStableInsets(int displayId, out Rect outInsets);

    /**
     * Set the forwarded insets on the display.
     * <p>
     * This is only used in case a virtual display is displayed on another display that has insets,
     * and the bounds of the virtual display is overlapping with the insets from the host display.
     * In that case, the contents on the virtual display won't be placed over the forwarded insets.
     * Only the owner of the display is permitted to set the forwarded insets on it.
     */
    void setForwardedInsets(int displayId, in Insets insets);

    /**
     * Register shortcut key. Shortcut code is packed as:
     * (MetaState << Integer.SIZE) | KeyCode
+20 −0
Original line number Diff line number Diff line
/* //device/java/android/android/graphics/Insets.aidl
**
** Copyright 2019, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
**     http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/

package android.graphics;

parcelable Insets;
+29 −2
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ package android.graphics;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.os.Parcel;
import android.os.Parcelable;

/**
 * An Insets instance holds four integer offsets which describe changes to the four
@@ -27,7 +29,7 @@ import android.annotation.Nullable;
 * Insets are immutable so may be treated as values.
 *
 */
public final class Insets {
public final class Insets implements Parcelable {
    public static final Insets NONE = new Insets(0, 0, 0, 0);

    public final int left;
@@ -73,7 +75,7 @@ public final class Insets {
    }

    /**
     * Returns a Rect intance with the appropriate values.
     * Returns a Rect instance with the appropriate values.
     *
     * @hide
     */
@@ -168,4 +170,29 @@ public final class Insets {
                ", bottom=" + bottom +
                '}';
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel out, int flags) {
        out.writeInt(left);
        out.writeInt(top);
        out.writeInt(right);
        out.writeInt(bottom);
    }

    public static final Parcelable.Creator<Insets> CREATOR = new Parcelable.Creator<Insets>() {
        @Override
        public Insets createFromParcel(Parcel in) {
            return new Insets(in.readInt(), in.readInt(), in.readInt(), in.readInt());
        }

        @Override
        public Insets[] newArray(int size) {
            return new Insets[size];
        }
    };
}
Loading