Loading quickstep/src/com/android/quickstep/util/SystemWindowManagerProxy.java +7 −0 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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 Loading src/com/android/launcher3/InvariantDeviceProfile.java +5 −8 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); } /** Loading src/com/android/launcher3/util/WindowBounds.java +1 −1 Original line number Diff line number Diff line Loading @@ -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(); } /** Loading src/com/android/launcher3/util/window/WindowManagerProxy.java +14 −0 Original line number Diff line number Diff line Loading @@ -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. Loading tests/src/com/android/launcher3/AbstractDeviceProfileTest.kt +1 −0 Original line number Diff line number Diff line Loading @@ -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( Loading Loading
quickstep/src/com/android/quickstep/util/SystemWindowManagerProxy.java +7 −0 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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 Loading
src/com/android/launcher3/InvariantDeviceProfile.java +5 −8 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); } /** Loading
src/com/android/launcher3/util/WindowBounds.java +1 −1 Original line number Diff line number Diff line Loading @@ -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(); } /** Loading
src/com/android/launcher3/util/window/WindowManagerProxy.java +14 −0 Original line number Diff line number Diff line Loading @@ -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. Loading
tests/src/com/android/launcher3/AbstractDeviceProfileTest.kt +1 −0 Original line number Diff line number Diff line Loading @@ -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( Loading