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度此处就写90,180度就写180,270度就写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 |
|小黑屋| 飞凌嵌入式 ( 冀ICP备12004394号-1 )
GMT+8, 2024-12-22 14:28
Powered by Discuz! X3.4
© 2001-2013 Comsenz Inc.