RK android13默认横屏

本文介绍了两种让Android系统默认启动为横屏的实现方式。第一种通过修改BoardConfig.mk和设备特定文件设置屏幕旋转参数;第二种涉及SurfaceFlinger.cpp源码修改,动态检测屏幕状态以强制横屏。同时,文中还提及了Recovery界面横屏的配置方法。
ACE-Step

ACE-Step

音乐合成
ACE-Step

ACE-Step是由中国团队阶跃星辰(StepFun)与ACE Studio联手打造的开源音乐生成模型。 它拥有3.5B参数量,支持快速高质量生成、强可控性和易于拓展的特点。 最厉害的是,它可以生成多种语言的歌曲,包括但不限于中文、英文、日文等19种语言

实现 默认横屏有两套方案 :

第一种方式:目录 device/rockchip/rk356x/BoardConfig.mk

SF_PRIMARY_DISPLAY_ORIENTATION := 90

# For Recovery Rotation recovery界面
TARGET_RECOVERY_DEFAULT_ROTATION ?= ROTATION_RIGHT

实际上

build/make/core/Makefile

ifdef TARGET_RECOVERY_DEFAULT_ROTATION
FINAL_VENDOR_DEFAULT_PROPERTIES += \
    ro.minui.default_rotation=$(TARGET_RECOVERY_DEFAULT_ROTATION)
endif

device/rockchip/common/device_xxxx.mk

# For screen hw rotation
ifneq ($(filter 90 180 270, $(strip $(SF_PRIMARY_DISPLAY_ORIENTATION))), )
PRODUCT_DEFAULT_PROPERTY_OVERRIDES += \
    ro.surface_flinger.primary_display_orientation=ORIENTATION_$(SF_PRIMARY_DISPLAY_ORIENTATION)
endif

第二种方式:是基于第一种在代码中实现具体的属性设置

Android系统默认是竖屏显示的,想要完成横屏显示,按以下步骤配置即可实现功能:

目录frameworks/native

diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 7489280328..7362401b7f 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -153,6 +153,7 @@
 #undef NO_THREAD_SAFETY_ANALYSIS
 #define NO_THREAD_SAFETY_ANALYSIS \
     _Pragma("GCC error \"Prefer <ftl/fake_guard.h> or MutexUtils.h helpers.\"")
+#define DP_STATUS "/sys/class/drm/card0-eDP-1/status"
 
 namespace android {
 
@@ -2438,6 +2439,22 @@ bool SurfaceFlinger::isHdrLayer(Layer* layer) const {
 
 ui::Rotation SurfaceFlinger::getPhysicalDisplayOrientation(DisplayId displayId,
                                                            bool isPrimary) const {
+    char dp_statu[128] = { "disconnected"};
+    int fd = open(DP_STATUS, O_RDONLY);
+    if (fd != -1) {
:...skipping...
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 7489280328..7362401b7f 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -153,6 +153,7 @@
 #undef NO_THREAD_SAFETY_ANALYSIS
 #define NO_THREAD_SAFETY_ANALYSIS \
     _Pragma("GCC error \"Prefer <ftl/fake_guard.h> or MutexUtils.h helpers.\"")
+#define DP_STATUS "/sys/class/drm/card0-eDP-1/status"
 
 namespace android {
 
@@ -2438,6 +2439,22 @@ bool SurfaceFlinger::isHdrLayer(Layer* layer) const {
 
 ui::Rotation SurfaceFlinger::getPhysicalDisplayOrientation(DisplayId displayId,
                                                            bool isPrimary) const {
+
+    ALOGD("wancg SurfaceFlinger::getPhysicalDisplayOrientation start");
+    char dp_statu[128] = { "disconnected"};
+    int fd = open(DP_STATUS, O_RDONLY);
+    if (fd != -1) {
+        read(fd, dp_statu, sizeof(dp_statu));
+        close(fd);
+        ALOGW("wancg: read dp status=%s",dp_statu);
+        if ( strncmp(dp_statu,"connected",8) == 0){
+            ALOGD("wancg:force to set rotation 0 SurfaceFlinger::getPhysicalDisplayOrientation");
+            return ui::ROTATION_90;
+        }
+    }else{
+        ALOGE(":fail open %s",DP_STATUS);
+    }
+
     const auto id = PhysicalDisplayId::tryCast(displayId);
     if (!id) {
         return ui::ROTATION_0;

Recovery界面

目录bootable/recovery

diff --git a/recovery_ui/screen_ui.cpp b/recovery_ui/screen_ui.cpp
index 5efaad04..00ee3ee8 100644
--- a/recovery_ui/screen_ui.cpp
+++ b/recovery_ui/screen_ui.cpp
@@ -54,6 +54,7 @@
 #define MIN(a,b)    ((a) < (b) ? (a) : (b))
 #undef ABS
 #define ABS(a)      ((a) >= 0 ? (a) : (-(a)))
+#define DP_STATUS "/sys/class/drm/card0-eDP-1/status"
 enum DirectRenderManager {
     DRM_INNER,
     DRM_OUTER,
@@ -1489,6 +1490,16 @@ int ScreenRecoveryUI::SetSwCallback(int code, int value) {
     rotation_str =
       android::base::GetProperty("ro.minui.default_rotation", "ROTATION_NONE");
   }
+ char dp_statu[128] = { "disconnected"};
+    int fd = open(DP_STATUS, O_RDONLY);
+    if (fd != -1) {
+        read(fd, dp_statu, strlen(dp_statu));
+       close(fd);
+        if ( strncmp(dp_statu,"connected",8) == 0){
+            rotation_str = "ROTATION_RIGHT";
+            
+        }
+    }
 
   if (rotation_str == "ROTATION_RIGHT") {
     gr_rotate(GRRotation::RIGHT);

您可能感兴趣的与本文相关的镜像

ACE-Step

ACE-Step

音乐合成
ACE-Step

ACE-Step是由中国团队阶跃星辰(StepFun)与ACE Studio联手打造的开源音乐生成模型。 它拥有3.5B参数量,支持快速高质量生成、强可控性和易于拓展的特点。 最厉害的是,它可以生成多种语言的歌曲,包括但不限于中文、英文、日文等19种语言

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值