电源键在左边时出现以下问题:
1.系统默认横屏时,在横屏时使用固定为竖屏的app时,出现app旋转180°;
2.系统默认竖屏时,在竖屏时使用固定为横屏的app时,出现app旋转180°。
以下是解决上面方法:
1.先在frameworks/base/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java中根据以下修改:
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
old mode 100644
new mode 100755
index 4be85ef..f25d53a
--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -1519,11 +1548,22 @@ public class PhoneWindowManager implements WindowManagerPolicy {
mLandscapeRotation = Surface.ROTATION_0;
mSeascapeRotation = Surface.ROTATION_180;
if (res.getBoolean(com.android.internal.R.bool.config_reverseDefaultRotation)) {
- mPortraitRotation = Surface.ROTATION_90;
- mUpsideDownRotation = Surface.ROTATION_270;
+ if (android.os.SystemProperties.get("ro.inet.app_reverse_portrait", "false").equals("true")) {
+ mPortraitRotation = Surface.ROTATION_270;
+ mUpsideDownRotation = Surface.ROTATION_90;
+ } else {
+ mPortraitRotation = Surface.ROTATION_90;
+ mUpsideDownRotation = Surface.ROTATION_270;
+ }
+
} else {
- mPortraitRotation = Surface.ROTATION_270;
- mUpsideDownRotation = Surface.ROTATION_90;
+ if (android.os.SystemProperties.get("ro.inet.app_reverse_portrait", "false").equals("true")) {
+ mPortraitRotation = Surface.ROTATION_90;
+ mUpsideDownRotation = Surface.ROTATION_270;
+ } else {
+ mPortraitRotation = Surface.ROTATION_270;
+ mUpsideDownRotation = Surface.ROTATION_90;
+ }
}
} else {
shortSize = width;
@@ -1531,11 +1571,21 @@ public class PhoneWindowManager implements WindowManagerPolicy {
mPortraitRotation = Surface.ROTATION_0;
mUpsideDownRotation = Surface.ROTATION_180;
if (res.getBoolean(com.android.internal.R.bool.config_reverseDefaultRotation)) {
- mLandscapeRotation = Surface.ROTATION_270;
- mSeascapeRotation = Surface.ROTATION_90;
+ if (android.os.SystemProperties.get("ro.inet.app_reverse_landscape", "false").equals("true")) {
+ mLandscapeRotation = Surface.ROTATION_90;
+ mSeascapeRotation = Surface.ROTATION_270;
+ } else {
+ mLandscapeRotation = Surface.ROTATION_270;
+ mSeascapeRotation = Surface.ROTATION_90;
+ }
} else {
- mLandscapeRotation = Surface.ROTATION_90;
- mSeascapeRotation = Surface.ROTATION_270;
+ if (android.os.SystemProperties.get("ro.inet.app_reverse_landscape", "false").equals("true")) {
+ mLandscapeRotation = Surface.ROTATION_270;
+ mSeascapeRotation = Surface.ROTATION_90;
+ } else {
+ mLandscapeRotation = Surface.ROTATION_90;
+ mSeascapeRotation = Surface.ROTATION_270;
+ }
}
}
@@ -5737,6 +5787,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
if (isAnyPortrait(preferredRotation)) {
return preferredRotation;
}
+
+ if (isAnyPortrait(lastRotation) && android.os.SystemProperties.get("ro.inet.app_reverse_portrait", "false").equals("true")) {
+ return lastRotation;
+ }
+
return mPortraitRotation;
case ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE:
@@ -5744,6 +5799,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
if (isLandscapeOrSeascape(preferredRotation)) {
return preferredRotation;
}
+
+ if (isLandscapeOrSeascape(lastRotation) && android.os.SystemProperties.get("ro.inet.app_reverse_landscape", "false").equals("true")) {
+ return lastRotation;
+ }
+
return mLandscapeRotation;
case ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT:
@@ -5751,6 +5811,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
if (isAnyPortrait(preferredRotation)) {
return preferredRotation;
}
+
+ if (isAnyPortrait(lastRotation) && android.os.SystemProperties.get("ro.inet.app_reverse_portrait", "false").equals("true")) {
+ return lastRotation;
+ }
+
return mUpsideDownRotation;
case ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE:
@@ -5758,6 +5823,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
if (isLandscapeOrSeascape(preferredRotation)) {
return preferredRotation;
}
+
+ if (isLandscapeOrSeascape(lastRotation) && android.os.SystemProperties.get("ro.inet.app_reverse_landscape", "false").equals("true")) {
+ return lastRotation;
+ }
+
return mSeascapeRotation;
case ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE:
2.在build.prop中根据添加修改:
(1)系统默认横屏时,固定为竖屏的apk反向,添加:
ro.inet.app_reverse_portrait=true
(2)系统默认竖屏时,固定为横屏的apk反向,添加
ro.inet.app_reverse_landscape=true