Snap for 7383558 from 49eddeff2c93a975b3d8b4002b254b81f3f17f92 to r-keystone-qcom-release

Change-Id: I95023bdf6f168566d923e2cc583ebbd9f702f486
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index 7f18e2b..1b77cd2 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -4393,4 +4393,12 @@
 
     <!-- Component names of the services which will keep critical code path warm -->
     <string-array name="config_keep_warming_services" translatable="false" />
+
+    <!-- If true, will enable force landscape mode, it will default landscape and
+         ignore sensor rotation request.-->
+    <bool name="config_supportForceLandscapeMode">false</bool>
+
+    <!-- The number of degrees to rotate the display when the force landscape
+         mode enabled. A value of -1 means no change in orientation by default. -->
+    <integer name="config_forceLandscapeRotation">-1</integer>
 </resources>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 73db4b8..329b9cf 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -4077,4 +4077,7 @@
   <java-symbol type="array" name="config_notificationMsgPkgsAllowedAsConvos" />
 
   <java-symbol type="array" name="config_keep_warming_services" />
+
+  <java-symbol type="bool" name="config_supportForceLandscapeMode" />
+  <java-symbol type="integer" name="config_forceLandscapeRotation" />
 </resources>
diff --git a/services/core/java/com/android/server/wm/DisplayRotation.java b/services/core/java/com/android/server/wm/DisplayRotation.java
index 30306dd..5f0e6bb 100644
--- a/services/core/java/com/android/server/wm/DisplayRotation.java
+++ b/services/core/java/com/android/server/wm/DisplayRotation.java
@@ -99,6 +99,8 @@
     private final int mCarDockRotation;
     private final int mDeskDockRotation;
     private final int mUndockedHdmiRotation;
+    private final int mForceLandscapeRotation;
+    private final boolean mSupportForceLandscapeMode;
     private final RotationAnimationPair mTmpRotationAnim = new RotationAnimationPair();
 
     private OrientationListener mOrientationListener;
@@ -264,6 +266,12 @@
         mCarDockRotation = readRotation(R.integer.config_carDockRotation);
         mDeskDockRotation = readRotation(R.integer.config_deskDockRotation);
         mUndockedHdmiRotation = readRotation(R.integer.config_undockedHdmiRotation);
+        mForceLandscapeRotation = readRotation(R.integer.config_forceLandscapeRotation);
+        mSupportForceLandscapeMode =
+                mContext.getResources().getBoolean(R.bool.config_supportForceLandscapeMode);
+        if (mSupportForceLandscapeMode && mForceLandscapeRotation != -1) {
+            mRotation = mForceLandscapeRotation;
+        }
 
         if (isDefaultDisplay) {
             final Handler uiHandler = UiThread.getHandler();
@@ -1194,6 +1202,8 @@
         } else if (orientation == ActivityInfo.SCREEN_ORIENTATION_LOCKED) {
             // Application just wants to remain locked in the last rotation.
             preferredRotation = lastRotation;
+        } else if (mSupportForceLandscapeMode) {
+            preferredRotation = mForceLandscapeRotation;
         } else if (!mSupportAutoRotation) {
             // If we don't support auto-rotation then bail out here and ignore
             // the sensor and any rotation lock settings.