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

Commit 5948d5c2 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes from topic "max_bounds"

* changes:
  Verify DisplayArea bounds in WindowMetricsTests
  Add DisplayArea support for WM#getMaximumWindowMetrics
parents 23ef82f4 5a24a59d
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -553,11 +553,13 @@ package android.app {
    method public int getActivityType();
    method public android.graphics.Rect getAppBounds();
    method public android.graphics.Rect getBounds();
    method @NonNull public android.graphics.Rect getMaxBounds();
    method public int getRotation();
    method public int getWindowingMode();
    method public void setActivityType(int);
    method public void setAppBounds(android.graphics.Rect);
    method public void setBounds(android.graphics.Rect);
    method public void setMaxBounds(@Nullable android.graphics.Rect);
    method public void setRotation(int);
    method public void setTo(android.app.WindowConfiguration);
    method public void setWindowingMode(int);
+2 −5
Original line number Diff line number Diff line
@@ -310,7 +310,6 @@ public class WindowConfiguration implements Parcelable, Comparable<WindowConfigu
     * Sets the maximum bounds to the provided {@link Rect}.
     * @param rect the new bounds value.
     * @see #getMaxBounds()
     * @hide
     */
    public void setMaxBounds(@Nullable Rect rect) {
        if (rect == null) {
@@ -364,10 +363,8 @@ public class WindowConfiguration implements Parcelable, Comparable<WindowConfigu
        return mBounds;
    }

    /**
     * @see #setMaxBounds(Rect)
     * @hide
     */
    /** @see #setMaxBounds(Rect) */
    @NonNull
    public Rect getMaxBounds() {
        return mMaxBounds;
    }
+12 −1
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.annotation.SuppressLint;
import android.annotation.TestApi;
import android.app.KeyguardManager;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.content.res.CompatibilityInfo;
import android.content.res.Configuration;
import android.content.res.Resources;
@@ -1157,9 +1158,19 @@ public final class Display {
     * </p><p>
     * The real size may be smaller than the physical size of the screen when the
     * window manager is emulating a smaller display (using adb shell wm size).
     * </p>
     * </p><p>
     * In general, {@link #getRealSize(Point)} and {@link WindowManager#getMaximumWindowMetrics()}
     * report the same bounds except that certain areas of the display may not be available to
     * windows created in the {@link WindowManager}'s {@link Context}.
     *
     * For example, imagine a device which has a multi-task mode that limits windows to half of the
     * screen. In this case, {@link WindowManager#getMaximumWindowMetrics()} reports the
     * bounds of the screen half where the window is located, while {@link #getRealSize(Point)}
     * still reports the bounds of the whole display.
     *
     * @param outSize Set to the real size of the display.
     *
     * @see WindowManager#getMaximumWindowMetrics()
     */
    public void getRealSize(Point outSize) {
        synchronized (this) {
+11 −1
Original line number Diff line number Diff line
@@ -72,6 +72,7 @@ import android.compat.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.Region;
import android.os.IBinder;
@@ -473,9 +474,18 @@ public interface WindowManager extends ViewManager {
     *
     * Note that this might still be smaller than the size of the physical display if certain areas
     * of the display are not available to windows created in this {@link Context}.
     * <p>
     * For example, given that there's a device which have a multi-task mode to limit activities
     * to a half screen. In this case, {@link #getMaximumWindowMetrics()} reports the bounds of
     * the half screen which the activity is located, while {@link Display#getRealSize(Point)} still
     * reports the bounds of the whole physical display.
     *
     * @see #getMaximumWindowMetrics()
     * Despite this, {@link #getMaximumWindowMetrics()} and {@link Display#getRealSize(Point)}
     * reports the same bounds in general.
     *
     * @see #getCurrentWindowMetrics()
     * @see WindowMetrics
     * @see Display#getRealSize(Point)
     */
    default @NonNull WindowMetrics getMaximumWindowMetrics() {
        throw new UnsupportedOperationException();
+7 −9
Original line number Diff line number Diff line
@@ -29,7 +29,6 @@ import android.app.ResourcesManager;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.graphics.Insets;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.Region;
import android.os.Bundle;
@@ -233,17 +232,16 @@ public final class WindowManagerImpl implements WindowManager {

    @Override
    public WindowMetrics getMaximumWindowMetrics() {
        final Rect maxBounds = getMaximumBounds();
        final Context context = mParentWindow != null ? mParentWindow.getContext() : mContext;
        final Rect maxBounds = getMaximumBounds(context);

        return new WindowMetrics(maxBounds, computeWindowInsets(maxBounds));
    }

    private Rect getMaximumBounds() {
        // TODO(b/128338354): Current maximum bound is display size, but it should be displayArea
        //  bound after displayArea feature is finished.
        final Display display = mContext.getDisplayNoVerify();
        final Point displaySize = new Point();
        display.getRealSize(displaySize);
        return new Rect(0, 0, displaySize.x, displaySize.y);
    private static Rect getMaximumBounds(Context context) {
        synchronized (ResourcesManager.getInstance()) {
            return context.getResources().getConfiguration().windowConfiguration.getMaxBounds();
        }
    }

    // TODO(b/150095967): Set window type to LayoutParams
Loading