Use WindowConfiguration to match DeviceProfile in IDP.getDeviceProfile
- Also fix WindowBounds.isLandscape to use full display bounds to determine isLandscape, otherwise both orientation will be treated as isLandscape when using availableSize
Bug: 309801705
Test: manual and presubmit
Flag: NONE
Change-Id: Ic7f4235e620d4760a9af356f23066fe5b23304e6
diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java
index 75f4bb2..e5a6b2b 100644
--- a/src/com/android/launcher3/InvariantDeviceProfile.java
+++ b/src/com/android/launcher3/InvariantDeviceProfile.java
@@ -27,12 +27,12 @@
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 DeviceProfile getDeviceProfile(Context context) {
- Resources res = context.getResources();
- Configuration config = context.getResources().getConfiguration();
+ WindowManagerProxy windowManagerProxy = WindowManagerProxy.INSTANCE.get(context);
+ Rect bounds = windowManagerProxy.getCurrentBounds(context);
+ int rotation = windowManagerProxy.getRotation(context);
- float screenWidth = config.screenWidthDp * res.getDisplayMetrics().density;
- float screenHeight = config.screenHeightDp * res.getDisplayMetrics().density;
- int rotation = WindowManagerProxy.INSTANCE.get(context).getRotation(context);
-
- return getBestMatch(screenWidth, screenHeight, rotation);
+ return getBestMatch(bounds.width(), bounds.height(), rotation);
}
/**