Hi YiFei,
The ro.sf.hwrotation is not available under iMX.6 4.2.2 BSP.
However, I have added a patch for the same for our custom device. Hope it will help you.
My primary usage was to get the device rotated in 270 and this patch may not work for 90. So, you may need to tweak a little in WindowManagerService.java.
Note:
1. Make sure that you set the ro.sf.hwrotation in init.rc and build the image.
2. This is still not the full-fledged hwrotation support becasue I still cannot get the rotated bootanimation. For that I may need to tweak the surfaceflinger.
Please see the below patch for details:
------------------------------------------------------------
Index: base/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
===================================================================
--- base/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java (revision 4346)
+++ base/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java (revision 4554)
@@ -4027,7 +4027,15 @@
} else {
// No overriding preference.
// We will do exactly what the application asked us to do.
- preferredRotation = -1;
+ if ((SystemProperties.getInt("ro.sf.hwrotation", 0) == 270 ||
+ SystemProperties.getInt("ro.sf.hwrotation", 0) == 90)){
+
+ //Overrriding any preferred orientations as per the device settings
+ //Set preferred orientation as portrait unless application wants to override it
+ preferredRotation = mPortraitRotation;
+ } else {
+ preferredRotation = -1;
+ }
}
switch (orientation) {
Index: base/services/java/com/android/server/wm/WindowManagerService.java
===================================================================
--- base/services/java/com/android/server/wm/WindowManagerService.java (revision 4346)
+++ base/services/java/com/android/server/wm/WindowManagerService.java (revision 4554)
@@ -818,6 +818,12 @@
mActivityManager = ActivityManagerNative.getDefault();
mBatteryStats = BatteryStatsService.getService();
+ // Change the default boot time orientation as per device settings
+ if ((SystemProperties.getInt("ro.sf.hwrotation", 0) == 270 ||
+ SystemProperties.getInt("ro.sf.hwrotation", 0) == 90)) {
+ mRotation = 3;
+ }
+
// Get persisted window scale setting
mWindowAnimationScale = Settings.Global.getFloat(context.getContentResolver(),
Settings.Global.WINDOW_ANIMATION_SCALE, mWindowAnimationScale);
-----------------------------------------------------------------------
Thanks,
-Ninad.