android11-修改屏幕显示方向和触摸方向

方向定义

参数0表示12点钟方向显示
参数90表示3点钟方向显示
参数180表示6点钟方向显示
参数270表示9点钟方向显示

修改显示方向

/android11/device/rockchip/rk356x/BoardConfig.mk
diff --git a/device/rockchip/rk356x/BoardConfig.mk b/device/rockchip/rk356x/BoardConfig.mk
index e2773c1369..68dcf6222d 100644
--- a/device/rockchip/rk356x/BoardConfig.mk
+++ b/device/rockchip/rk356x/BoardConfig.mk
@@ -26,7 +26,7 @@ PRODUCT_KERNEL_DTS ?= rk3568-evb1-ddr4-v10
 PRODUCT_KERNEL_CONFIG ?= rockchip_defconfig
 
 # BOARD_AVB_ENABLE := true
-SF_PRIMARY_DISPLAY_ORIENTATION := 0
+SF_PRIMARY_DISPLAY_ORIENTATION := 90

修改触摸方向

/android11/build/make/tools/buildinfo.sh
diff --git a/build/make/tools/buildinfo.sh b/build/make/tools/buildinfo.sh
index 9bee115484..55d80d705b 100755
--- a/build/make/tools/buildinfo.sh
+++ b/build/make/tools/buildinfo.sh
@@ -54,3 +54,4 @@ if [ -n "$BUILD_THUMBPRINT" ] ; then
 fi
 
 echo "# end build properties"
+echo "persist.sys.touch.rotation=90"
/android11/frameworks/native/services/inputflinger/reader/mapper/TouchInputMapper.cpp
diff --git a/frameworks/native/services/inputflinger/reader/mapper/TouchInputMapper.cpp b/framewo
rks/native/services/inputflinger/reader/mapper/TouchInputMapper.cpp
index 99a572a5fd..5af877855f 100644
--- a/frameworks/native/services/inputflinger/reader/mapper/TouchInputMapper.cpp
+++ b/frameworks/native/services/inputflinger/reader/mapper/TouchInputMapper.cpp
@@ -22,6 +22,7 @@
 #include "CursorScrollAccumulator.h"
 #include "TouchButtonAccumulator.h"
 #include "TouchCursorInputMapperCommon.h"
+#include 
 
 namespace android {
 
@@ -674,6 +675,26 @@ void TouchInputMapper::configureSurface(nsecs_t when, bool* outResetNeeded) {
             int32_t naturalPhysicalWidth, naturalPhysicalHeight;
             int32_t naturalPhysicalLeft, naturalPhysicalTop;
             int32_t naturalDeviceWidth, naturalDeviceHeight;
+           char value[PROPERTY_VALUE_MAX];
+           int orientation = 0;
+           property_get("persist.sys.touch.rotation", value, "90");
+            switch(atoi(value)){
+                case 90:
+                    orientation = DISPLAY_ORIENTATION_90;
+                    break;
+                case 180:
+                    orientation = DISPLAY_ORIENTATION_180;
+                    break;
+                case 270:
+                    orientation = DISPLAY_ORIENTATION_270;
+                    break;
+                case 0:
+                default:
+                    orientation = DISPLAY_ORIENTATION_0;
+                    break;
+            }
+            mViewport.orientation = (mViewport.orientation + orientation) % 4;
+
             switch (mViewport.orientation) {

你可能感兴趣的:(Android,android)