7

I have my device TI am335xevm running android Jellybean 4.2.2 with Landscape as the default/natural orientation.

How can I change the default/natural orientation of the device to portrait?

Here is what I have tried till now,

1) Added setprop ro.sf.hwrotation 90 to build.prop and it did nothing.

2) changed user_rotation value in /data/data/com.android.providers.settings/databases/settings.db and it changed the orientation of apps only. the orientation of Home screen and launcher are still landscape.

3) Modified PhoneWindowManager.java similar to the one given in link : changing phonewindowmanager to change natural orientation

This option works. But it still shows the bootanimation in landscape and after the animation is finished, the display rotates(with rotate animation) to portrait. How can I avoid this rotation and change the default/natural orientation before boot animation?

Note: I have already overridden the bootanimation with own portrait images so that it will look like portrait.Still the rotation after the bootanimation exit occurs. So what will be a generic solution?

Any advices will be appreciated.

Is it something related to SurfaceFlinger? I would also like to point to this article in android website. pre rotation in hardware composer

(FYI - The question is not regarding app/activity orientation but the device natural orientation when you build Android OS for a custom device)

Rockcollins
  • 418
  • 5
  • 15
  • Change android:screenOrientation="portrait" in the activity tag of AndroidManifest.XML – Zohra Khan Apr 16 '14 at 10:40
  • @ZohraKhan I think there is a confusion. I was not talking about an app. I am talking about the device natural orientation when you build Android OS for a custom device. – Rockcollins Apr 16 '14 at 10:44
  • Maybe try `su setprop ro.sf.hwrotation 90` and then restart your device - `setprop` command by itself does not work without restarting the device. –  Apr 16 '14 at 10:56
  • @CKDPublishing Thanks. I think I have tried setting it this way from the console, and getprop ro.sf.hwrotation gave me 90 as a result. It didn't work when I have given it in build.prop or init..rc when building the os. I will try it once again using android console and then restarting the device and confirm. – Rockcollins Apr 16 '14 at 11:31
  • @CKDPublishing That didn't work. do you think pre rotation mentioned in this link will help? https://source.android.com/devices/graphics.html – Rockcollins Apr 16 '14 at 13:30
  • 2
    Devices have a natural orientation based on how their displays are physically constructed. SurfaceFlinger isn't *choosing* the default orientation, it's *obeying* it. Pre-rotation is a mechanism for handling screen rotation efficiently; it does not define policy. The Display Manager is responsible for dealing with orientation changes, so you'd likely need to modify that to avoid the post-boot-animation rotation. (This also comes up when you boot a portrait device with HDMI attached.) – fadden Apr 16 '14 at 15:01
  • @fadden Thanks for the comment. So we don't have anything to change in the HAL level nor driver level to solve this? Using Display Manager can we set the initial orientation? I am just using the default LCD screen of the device. – Rockcollins Apr 17 '14 at 07:37
  • I know it's been a long time but did you ever manage to find a solution to this? Thanks. – thatbrainiac Dec 18 '19 at 11:37

0 Answers0