1

I've just built and flashed AOSP Automotive on Google Pixel 3 XL using this manual: https://source.android.com/devices/automotive/start/pixelxl

It works fine, but starts in portrait mode by default. For my custom Launcher I need to have it in landscape though.

I tried to change the following settings in core/res/res/values/config.xml

-    <bool name="config_allowAllRotations">false</bool>
+    <bool name="config_allowAllRotations">true</bool>

-    <integer name="config_carDockRotation">-1</integer>
+    <integer name="config_carDockRotation">2</integer>

But it did not take any effect after re-flashing system.img

I also tried to apply the following properties in init.rc without any effect

# screen rotation attempt
setprop ro.sf.hwrotation 0
setprop config.override_forced_orient flase

I am on Android 10, build QQ3A.200705.002.

Any hint would be highly appreciated.. Thanks!

  • This answer from another thread, helped to change the orientation in runtime https://stackoverflow.com/a/41455424/1673740. This was super helpful, however the original question on how to set it by default is still actual. As I understand screen orientation detects from the screen resolution in the device tree. Unfortunately Pixel 3 XL comes with prebuilt qcom kernel and I do not have an access to this part of the code.. – Igor Pchelnikov Jan 18 '21 at 15:58

1 Answers1

0

The fix got merged into AOSP master. There's no need to patch sources anymore, just sync your repository. Then, set def_user_rotation at frameworks/base/packages/SettingsProvider/res/values/defaults.xml as mentioned below and it should work.

Previous answer

There is a pair of config settings for default orientation in frameworks/base/packages/SettingsProvider/res/values/defaults.xml:

  • def_accelerometer_rotation - determines default value of accelerometer_rotation from the other thread (it's set to false by default, so you should be fine)
  • def_user_rotation - should determine default value of user_rotation (so you can set it to value 1-4)

The problem is... the latter doesn't seem to be supported! The good part is AOSP is open source and you can fix it (precisely, fix DatabaseHelper.java). Here is a patch I prepared for you (to apply against frameworks/base):

--- a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
@@ -846,8 +846,8 @@ class DatabaseHelper extends SQLiteOpenHelper {
             try {
                 stmt = db.compileStatement("INSERT INTO system(name,value)"
                         + " VALUES(?,?);");
-                loadBooleanSetting(stmt, Settings.System.USER_ROTATION,
-                        R.integer.def_user_rotation); // should be zero degrees
+                loadIntegerSetting(stmt, Settings.System.USER_ROTATION,
+                        R.integer.def_user_rotation);
                 db.setTransactionSuccessful();
             } finally {
                 db.endTransaction();
@@ -2265,6 +2265,8 @@ class DatabaseHelper extends SQLiteOpenHelper {
             loadBooleanSetting(stmt, Settings.System.ACCELEROMETER_ROTATION,
                     R.bool.def_accelerometer_rotation);
 
+            loadIntegerSetting(stmt, Settings.System.USER_ROTATION, R.integer.def_user_rotation);
+
             loadDefaultHapticSettings(stmt);
 
             loadBooleanSetting(stmt, Settings.System.NOTIFICATION_LIGHT_PULSE,

After building and flashing patched system image (with the patch above and defaults.xml changes), you can verify if the settings got correctly initialized:

  • adb shell settings get system user_rotation (should not be null)
  • adb shell settings get system accelerometer_rotation (should be 0)

Please let me know if it helped with your device - it did with mine. You may also need to set config.override_forced_orient to true, but it wasn't necessary with my Pixel 3a.

twasilczyk
  • 186
  • 4