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

Commit 013af87a authored by Alex Chau's avatar Alex Chau Committed by Android (Google) Code Review
Browse files

Merge "Use WindowConfiguration to match DeviceProfile in IDP.getDeviceProfile" into main

parents 3c08695e c09a98a8
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.quickstep.util;
import static android.view.Display.DEFAULT_DISPLAY;

import android.content.Context;
import android.graphics.Rect;
import android.util.ArrayMap;
import android.view.Surface;
import android.view.WindowManager;
@@ -40,6 +41,12 @@ public class SystemWindowManagerProxy extends WindowManagerProxy {
        super(true);
    }

    @Override
    public Rect getCurrentBounds(Context displayInfoContext) {
        return displayInfoContext.getResources().getConfiguration().windowConfiguration
                .getMaxBounds();
    }

    @Override
    public int getRotation(Context displayInfoContext) {
        return displayInfoContext.getResources().getConfiguration().windowConfiguration
+5 −8
Original line number Diff line number Diff line
@@ -27,12 +27,12 @@ import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;

import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
import android.graphics.Point;
import android.graphics.PointF;
import android.graphics.Rect;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
@@ -700,14 +700,11 @@ public class InvariantDeviceProfile {
    }

    public DeviceProfile getDeviceProfile(Context context) {
        Resources res = context.getResources();
        Configuration config = context.getResources().getConfiguration();

        float screenWidth = config.screenWidthDp * res.getDisplayMetrics().density;
        float screenHeight = config.screenHeightDp * res.getDisplayMetrics().density;
        int rotation = WindowManagerProxy.INSTANCE.get(context).getRotation(context);
        WindowManagerProxy windowManagerProxy = WindowManagerProxy.INSTANCE.get(context);
        Rect bounds = windowManagerProxy.getCurrentBounds(context);
        int rotation = windowManagerProxy.getRotation(context);

        return getBestMatch(screenWidth, screenHeight, rotation);
        return getBestMatch(bounds.width(), bounds.height(), rotation);
    }

    /**
+1 −1
Original line number Diff line number Diff line
@@ -85,7 +85,7 @@ public class WindowBounds {
     * Returns true if the device is in landscape orientation
     */
    public final boolean isLandscape() {
        return availableSize.x > availableSize.y;
        return bounds.width() > bounds.height();
    }

    /**
+14 −0
Original line number Diff line number Diff line
@@ -337,6 +337,20 @@ public class WindowManagerProxy implements ResourceBasedOverride {
        return new CachedDisplayInfo(size, rotation, cutoutRect);
    }

    /**
     * Returns bounds of the display associated with the context, or bounds of DEFAULT_DISPLAY
     * if the context isn't associated with a display.
     */
    public Rect getCurrentBounds(Context displayInfoContext) {
        Resources res = displayInfoContext.getResources();
        Configuration config = res.getConfiguration();

        float screenWidth = config.screenWidthDp * res.getDisplayMetrics().density;
        float screenHeight = config.screenHeightDp * res.getDisplayMetrics().density;

        return new Rect(0, 0, (int) screenWidth, (int) screenHeight);
    }

    /**
     * Returns rotation of the display associated with the context, or rotation of DEFAULT_DISPLAY
     * if the context isn't associated with a display.
+1 −0
Original line number Diff line number Diff line
@@ -273,6 +273,7 @@ abstract class AbstractDeviceProfileTest {
        val realBounds = windowsBounds[rotation]
        whenever(windowManagerProxy.getDisplayInfo(any())).thenReturn(displayInfo)
        whenever(windowManagerProxy.getRealBounds(any(), any())).thenReturn(realBounds)
        whenever(windowManagerProxy.getCurrentBounds(any())).thenReturn(realBounds.bounds)
        whenever(windowManagerProxy.getRotation(any())).thenReturn(rotation)
        whenever(windowManagerProxy.getNavigationMode(any()))
            .thenReturn(