From 0b5d9692dcb7eda2a2c82a4b09ca19d2d97ee801 Mon Sep 17 00:00:00 2001 From: Santos Cordon Date: Fri, 21 Jul 2017 12:08:53 -0700 Subject: [PATCH] Move VR preference for portrait orientation. This code as written had two problems: 1) It assumed ROTATE_0 was portrait and 2) Only set a preference when an activity was compiled for sensor-based orientations. This change fixes the ROTATE_0 assumption and provides a PORTRAIT preference in VR mode for all activities that aren't explicitly set screenOrientation to "portrait" or "landscape". Bug: 63289312, 62862109 Test: In VR Mode, tested activity preferences of sensor, unspecified, portrait and landscape both on the main display and the virtual display. Change-Id: Ifa04cbcd021e2d744ff70e53cd53359b1ddf5877 --- .../android/server/policy/PhoneWindowManager.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java index 8e2097ae26096..43c3da202e1fa 100644 --- a/services/core/java/com/android/server/policy/PhoneWindowManager.java +++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java @@ -7046,6 +7046,12 @@ public class PhoneWindowManager implements WindowManagerPolicy { // Ignore sensor when demo rotation lock is enabled. // Note that the dock orientation and HDMI rotation lock override this. preferredRotation = mDemoRotation; + } else if (mPersistentVrModeEnabled) { + // While in VR, apps always prefer a portrait rotation. This does not change + // any apps that explicitly set landscape, but does cause sensors be ignored, + // and ignored any orientation lock that the user has set (this conditional + // should remain above the ORIENTATION_LOCKED conditional below). + preferredRotation = mPortraitRotation; } else if (orientation == ActivityInfo.SCREEN_ORIENTATION_LOCKED) { // Application just wants to remain locked in the last rotation. preferredRotation = lastRotation; @@ -7076,13 +7082,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { || mAllowAllRotations == 1 || orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR || orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_USER) { - // In VrMode, we report the sensor as always being in default orientation so: - // 1) The orientation doesn't change as the user moves their head. - // 2) 2D apps within VR show in the device's default orientation. - // This only overwrites the sensor-provided orientation and does not affect any - // explicit orientation preferences specified by any activities. - preferredRotation = - mPersistentVrModeEnabled ? Surface.ROTATION_0 : sensorRotation; + preferredRotation = sensorRotation; } else { preferredRotation = lastRotation; }