summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Santos Cordon <santoscordon@google.com> 2017-04-13 16:12:02 -0700
committer Santos Cordon <santoscordon@google.com> 2017-04-27 12:33:52 -0700
commitc09d89c1ec4546cfbc5fe2a5091e8fe62be607cd (patch)
tree1f06537dc46ce573498418680055b9b97d4e6336
parenta35e4e5584e219771d007335eb615b2762bd80ef (diff)
Set sensor-supplied orientation always to portrait in VrMode.
For VrMode, we report the sensor as always being in the device's default orientation so that: 1) The orientation doesn't change as the user moves their head. 2) 2D UI within VR shows 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. Test: Start 2D UI within VR while device is oriented in landscape and ensure that the item is displayed in portrait. Also start 2D UI with custom orientation and ensure it starts in its preferred orientation. Bug: 36516916 Change-Id: I56380b860eec73cf9485185ded811626e40c5c57
-rw-r--r--services/core/java/com/android/server/policy/PhoneWindowManager.java22
1 files changed, 21 insertions, 1 deletions
diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java
index 1d064ded4292..9127d0a3908e 100644
--- a/services/core/java/com/android/server/policy/PhoneWindowManager.java
+++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java
@@ -184,6 +184,7 @@ import android.provider.Settings;
import android.service.dreams.DreamManagerInternal;
import android.service.dreams.DreamService;
import android.service.dreams.IDreamManager;
+import android.service.vr.IPersistentVrStateCallbacks;
import android.speech.RecognizerIntent;
import android.telecom.TelecomManager;
import android.util.DisplayMetrics;
@@ -512,6 +513,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
volatile boolean mGoingToSleep;
volatile boolean mRecentsVisible;
volatile boolean mPictureInPictureVisible;
+ // Written by vr manager thread, only read in this class.
+ volatile private boolean mPersistentVrModeEnabled;
volatile private boolean mDismissImeOnBackKeyPressed;
// Used to hold the last user key used to wake the device. This helps us prevent up events
@@ -1002,6 +1005,14 @@ public class PhoneWindowManager implements WindowManagerPolicy {
}
MyOrientationListener mOrientationListener;
+ final IPersistentVrStateCallbacks mPersistentVrModeListener =
+ new IPersistentVrStateCallbacks.Stub() {
+ @Override
+ public void onPersistentVrStateChanged(boolean enabled) {
+ mPersistentVrModeEnabled = enabled;
+ }
+ };
+
private final StatusBarController mStatusBarController = new StatusBarController();
private final BarController mNavigationBarController = new BarController("NavigationBar",
@@ -6909,7 +6920,13 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|| mAllowAllRotations == 1
|| orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR
|| orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_USER) {
- preferredRotation = sensorRotation;
+ // 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;
} else {
preferredRotation = lastRotation;
}
@@ -7083,6 +7100,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
mKeyguardDelegate.onSystemReady();
mVrManagerInternal = LocalServices.getService(VrManagerInternal.class);
+ if (mVrManagerInternal != null) {
+ mVrManagerInternal.addPersistentVrModeStateListener(mPersistentVrModeListener);
+ }
readCameraLensCoverState();
updateUiMode();