android 5.1 出现有些apk反向问题解决方法

电源键在左边时出现以下问题:
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
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值