From ba78cb4529f1f883b5687c6ae453b0d8680c3cdd Mon Sep 17 00:00:00 2001 From: Mady Mellor Date: Tue, 15 Feb 2022 16:47:57 -0800 Subject: [PATCH] Don't use rotation to determine orientation Looking more closely at documentation, rotation doesn't work as I originally thought. ROTATION_0 is a device's *natural* resting state which is portrait on phones but can differ for tablets or foldables. The fix for this is to use the config value. Test: manual - check that bubbles layout correctly on large tablet Bug: 217211205 Change-Id: I3efc296d69d045be431b176f7acc71952b3f7bab --- .../com/android/wm/shell/bubbles/BubbleController.java | 1 - .../com/android/wm/shell/bubbles/BubblePositioner.java | 8 +++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java index 6ed1ba9f561fe..d18adb93350ca 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java @@ -423,7 +423,6 @@ public class BubbleController { WindowContainerTransaction t) { // This is triggered right before the rotation is applied if (fromRotation != toRotation) { - mBubblePositioner.setRotation(toRotation); if (mStackView != null) { // Layout listener set on stackView will update the positioner // once the rotation is applied diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubblePositioner.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubblePositioner.java index 127d5a8a9966e..75b19fb03e730 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubblePositioner.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubblePositioner.java @@ -20,6 +20,7 @@ import static java.lang.annotation.RetentionPolicy.SOURCE; import android.annotation.IntDef; import android.content.Context; +import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.Insets; import android.graphics.PointF; @@ -112,10 +113,6 @@ public class BubblePositioner { update(); } - public void setRotation(int rotation) { - mRotation = rotation; - } - /** * Available space and inset information. Call this when config changes * occur or when added to a window. @@ -273,7 +270,8 @@ public class BubblePositioner { /** @return whether the device is in landscape orientation. */ public boolean isLandscape() { - return mRotation == Surface.ROTATION_90 || mRotation == Surface.ROTATION_270; + return mContext.getResources().getConfiguration().orientation + == Configuration.ORIENTATION_LANDSCAPE; } /** @return whether the screen is considered large. */