Android13.0 修改屏幕显示方向

Android13默认显示方向是0, 大屏幕产品是固定方向放置的,由于接口走向差异有些屏幕按照0度方向显示是倒的,需要旋转180 可以修改这些默认显示方向

java 复制代码
diff --git a/services/core/java/com/android/server/wm/DisplayRotation.java b/services/core/java/com/android/server/wm/DisplayRotation.java
index c8137925923f..4f5f2323c761 100644
--- a/services/core/java/com/android/server/wm/DisplayRotation.java
+++ b/services/core/java/com/android/server/wm/DisplayRotation.java
@@ -194,7 +194,7 @@ public class DisplayRotation {
     private int mUserRotationMode = WindowManagerPolicy.USER_ROTATION_FREE;
 
     @Surface.Rotation
-    private int mUserRotation = Surface.ROTATION_0;
+    private int mUserRotation = Surface.ROTATION_180;
     private int mBuiltInUserRotation = SystemProperties.getInt("persist.sys.builtinrotation", -1);
 
     private static final int CAMERA_ROTATION_DISABLED = 0;
@@ -282,7 +282,7 @@ public class DisplayRotation {
     @Surface.Rotation
     private int readDefaultDisplayRotation(DisplayAddress displayAddress) {
         if (!(displayAddress instanceof DisplayAddress.Physical)) {
-            return Surface.ROTATION_0;
+            return Surface.ROTATION_180;
         }
         final DisplayAddress.Physical physicalAddress = (DisplayAddress.Physical) displayAddress;
         String syspropValue = SystemProperties.get(
@@ -295,7 +295,7 @@ public class DisplayRotation {
         } else if (syspropValue.equals("ORIENTATION_270")) {
             return Surface.ROTATION_270;
         }
-        return Surface.ROTATION_0;
+        return Surface.ROTATION_180;
     }
 
     private int readRotation(int resID) {
@@ -825,7 +825,7 @@ public class DisplayRotation {
         if (userRotation < Surface.ROTATION_0 || userRotation > Surface.ROTATION_270) {
             Slog.w(TAG, "Trying to restore an invalid user rotation " + userRotation
                     + " for " + mDisplayContent);
-            userRotation = Surface.ROTATION_0;
+            userRotation = Surface.ROTATION_180;
         }
         mUserRotationMode = userRotationMode;
         mUserRotation = userRotation;
@@ -1304,7 +1304,7 @@ public class DisplayRotation {
                 if (preferredRotation >= 0) {
                     return preferredRotation;
                 }
-                return Surface.ROTATION_0;
+                return Surface.ROTATION_180;
         }
     }
 
@@ -1491,7 +1491,7 @@ public class DisplayRotation {
 
             // Configure rotation lock.
             int userRotation = Settings.System.getIntForUser(resolver,
-                    Settings.System.USER_ROTATION, Surface.ROTATION_0,
+                    Settings.System.USER_ROTATION, Surface.ROTATION_180,
                     UserHandle.USER_CURRENT);
 
                        /*if (mBuiltInUserRotation > -1 && mBuiltInUserRotation < 4) {
相关推荐
Jerry说前后端7 分钟前
RecyclerView 性能优化:从原理到实践的深度优化方案
android·前端·性能优化
alexhilton1 小时前
深入浅出着色器:极坐标系与炫酷环形进度条
android·kotlin·android jetpack
一条上岸小咸鱼7 小时前
Kotlin 基本数据类型(一):Numbers
android·前端·kotlin
Huntto7 小时前
最小二乘法计算触摸事件速度
android·最小二乘法·触摸事件·速度估计
一笑的小酒馆7 小时前
Android中使用Compose实现各种样式Dialog
android
红橙Darren8 小时前
手写操作系统 - 编译链接与运行
android·ios·客户端
鹏多多.11 小时前
flutter-使用device_info_plus获取手机设备信息完整指南
android·前端·flutter·ios·数据分析·前端框架
来来走走16 小时前
Flutter开发 网络请求
android·flutter
独行soc1 天前
2025年渗透测试面试题总结-18(题目+回答)
android·python·科技·面试·职场和发展·渗透测试
雨白1 天前
登录和授权:Cookie与Authorization Header机制详解
android