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) {
相关推荐
@Adzc9 分钟前
Android 16 省电模式 Tile 点击导致状态栏收起
android
杉氧15 分钟前
打破边界(二):在 React Native 中嵌入原生 UI 组件 (Native UI Components)
android·前端·react native
古法安卓1 小时前
Android-切换白天黑夜内存不足问题排查
android·java·android studio
聚美智数1 小时前
快递拦截-物流在途拦截-在途拦截API接口介绍
android
flower_drop1 小时前
从 QtScrcpy 到 TabQA:如何在浏览器侧边栏搞定 Android 投屏与测试提单?
android
脚踏实地,坚持不懈!3 小时前
Android 系统工程师(性能/功耗/稳定性)岗位问题深度解析:从内核源码到实战排查(完善版)
android·linux·运维·服务器
Kapaseker3 小时前
适配小米“中”折屏,非得买一台吗
android·kotlin
恋猫de小郭3 小时前
Flutter 状态管理基准测评,一个很有趣的观点
android·前端·flutter
可乐鸡翅yeah_3 小时前
App WebView 加载 M3U8 流媒体踩坑,安卓 iOS 混合开发播放异常定位
android·ios·harmonyos·m3u8·m3u8在线播放
木卫四科技3 小时前
从函数劫持到智能体控制平面:Hook 如何从 Linux-Android 演化到 Agent Runtime
android·linux·人工智能·安全