android8.1第三方应用转换为横屏

 PS:有些第三方的app应用自身定义了竖屏显示,并且优先级更高,安装到系统里面就会默认为是竖屏显示,看着极为不舒服,第三方app也不愿意修改app的android:screenOrientation属性,那么只能系统来修改此问题。以下是修改处:

1、首先在PhoneWindowManager.java中的rotationForOrientationLw方法中如下修改:

diff --git a/base/services/core/java/com/android/server/policy/PhoneWindowManager.java b/base/services/core/java/com/android/server/policy/PhoneWindowManager.java
index b1f4f3b..81f5509 100755
--- a/base/services/core/java/com/android/server/policy/PhoneWindowManager.java
+++ b/base/services/core/java/com/android/server/policy/PhoneWindowManager.java
@@ -292,9 +292,9 @@ import android.app.PendingIntent;
 public class PhoneWindowManager implements WindowManagerPolicy {
     static final String TAG = "PhoneWindowManager";
     /// M: runtime switch debug flags @{
-    static boolean DEBUG = false;
+    static boolean DEBUG = true;
     static boolean localLOGV = false;
-    static boolean DEBUG_INPUT = false;
+    static boolean DEBUG_INPUT = true;
     static boolean DEBUG_KEYGUARD = false;
     static boolean DEBUG_LAYOUT = false;
     static boolean DEBUG_SPLASH_SCREEN = false;
@@ -8153,7 +8153,7 @@ eaHandler.sendEmptyMessageDelayed(MSG_VOLUME_DOWN_KEY_OK, 3000);
                         );
         }
 
-        if (mForceDefaultOrientation) {
+        if (true/*mForceDefaultOrientation*/) {
             return Surface.ROTATION_0;
         }
 

2、在窗口显示DisplayContent.java中的updateRotationUnchecked方法中修改如下

diff --git a/base/services/core/java/com/android/server/wm/DisplayContent.java b/base/services/core/java/com/android/server/wm/DisplayContent.java
old mode 100644
new mode 100755
index 6b9f020..6e19caf
--- a/base/services/core/java/com/android/server/wm/DisplayContent.java
+++ b/base/services/core/java/com/android/server/wm/DisplayContent.java
@@ -921,6 +921,9 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
      * {@link WindowManagerService#sendNewConfiguration(int)} TO UNFREEZE THE SCREEN.
      */
     boolean updateRotationUnchecked(boolean inTransaction) {
+        if (true) {
+            return true;
+        }
         if (mService.mDeferredRotationPauseCount > 0) {
             // Rotation updates have been paused temporarily.  Defer the update until
             // updates have been resumed.

猜你喜欢

转载自blog.csdn.net/lwz622/article/details/125768541