嵌入式爱好者

8mp Android11 旋转屏幕的方法

2023-3-10 08:55| 发布者: wjy| 查看: 357| 评论: 1

类目: 知识库  >  i.MX8MP系列产品     文档编号: 948

1. 使用persist.vendor.orientation属性来控制屏幕的显示方向,取值0 90 180 270

vi frameworks/native/services/su**ceflinger/Su**ceFlinger.cpp

processDisplayHotplugEventsLocked里面修改

@@ -2436,6 +2436,28 @@ void Su**ceFlinger::processDisplayHotplugEventsLocked() {

             continue;

         }

+       /* Rotate desktop */

+       char rotationvalue[PROPERTY_VALUE_MAX] = "";;

+       property_get("persist.vendor.orientation", rotationvalue, "-1");

+       int rotation = atoi(rotationvalue);

+       ALOGI("Primary Display Orientation is set to rotation %2d.", rotation);

+       switch (rotation) {

+               case 0:

+                       internalDisplayOrientation = ui::ROTATION_0;

+                       break;

+               case 90:

+                       internalDisplayOrientation = ui::ROTATION_90;

+                       break;

+               case 180:

+                       internalDisplayOrientation = ui::ROTATION_180;

+                       break;

+               case 270:

+                       internalDisplayOrientation = ui::ROTATION_270;

+                       break;

+               default:

+                       break;

+       }

+

         const DisplayId displayId = info->id;

         const auto it = mPhysicalDisplayTokens.find(displayId);

 

2. 在环境变量中添加相关配置。

vi device/nxp/imx8m/evk_8mp/system.prop

@@ -1,3 +1,4 @@

 persist.sys.timezone=Asia/Shanghai

 persist.sys.language=zh

 persist.sys.country=CN

+persist.vendor.orientation=90

 

旋转90度此处就写90180度就写180270度就写270即可。

 

3. 若遇到属性设置值失败问题:

vi device/nxp/imx8m/sepolicy/property_contexts

@@ -1,3 +1,4 @@

+persist.vendor.orientation     u:object_r:debug_prop:s0

 vendor.wc_transport.                u:object_r:vendor_wc_prop:s0

 persist.vendor.usb.config           u:object_r:vendor_usb_config_prop:s0

 vendor.usb.config                   u:object_r:vendor_usb_config_prop:s0


已解决

未解决

只是看看
发表评论

最新评论

引用 wjy 2023-3-10 09:01
注意:文中步骤一里的“**”,实际为“r f a”(中间无空格),因论坛原因被屏蔽。修改的文件名称为:Su r f a ceFlinger.cpp

查看全部评论(1)

QQ|小黑屋| 飞凌嵌入式 ( 冀ICP备12004394号-1 )

GMT+8, 2024-12-22 14:28

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

返回顶部