RK平台android12 动态调整屏幕方向
介绍
没有gsensor情况下指定默认系统的开机方向,原生的属性值为ro属性,无法动态进行修改,设定后需要重启生效
一.修改方向属性判断
--- a/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
@@ -427,7 +427,7 @@ SurfaceFlinger::SurfaceFlinger(Factory& factory) : SurfaceFlinger(factory, SkipI
}();
useContextPriority = use_context_priority(true);
-
+/*
using Values = SurfaceFlingerProperties::primary_display_orientation_values;
switch (primary_display_orientation(Values::ORIENTATION_0)) {
case Values::ORIENTATION_0:
@@ -442,6 +442,25 @@ SurfaceFlinger::SurfaceFlinger(Factory& factory) : SurfaceFlinger(factory, SkipI
internalDisplayOrientation = ui::ROTATION_270;
break;
}
+*/
+ char value_private[PROPERTY_VALUE_MAX];
+ property_get("persist.surface_flinger.primary_display_orientation", value_private, "0");
+ int temp = atoi(value_private);
+ ALOGD("primary_display_orientation is: %d",temp);
+
+ switch (temp) {
+ case 0:
+ break;
+ case 90:
+ internalDisplayOrientation = ui::ROTATION_90;
+ break;
+ case 180:
+ internalDisplayOrientation = ui::ROTATION_180;
+ break;
+ case 270:
+ internalDisplayOrientation = ui::ROTATION_270;
+ break;
+ }
二.修改data分区加密,导致开机过程中无法读取系统属性
diff --git a/device/rockchip/common/rootdir/init.mount_all_early.rc b/device/rockchip/common/rootdir/init.mount_all_early.rc
index 200d053ebf..6ec6af3d3b 100644
--- a/device/rockchip/common/rootdir/init.mount_all_early.rc
+++ b/device/rockchip/common/rootdir/init.mount_all_early.rc
@@ -4,16 +4,7 @@ on early-fs
start vold
on fs
- mount_all /vendor/etc/fstab.${ro.hardware} --early
+ mount_all /vendor/etc/fstab.${ro.hardware}
on late-fs
# Start services for bootanim
- start servicemanager
- start hwcomposer-2-1
- start gralloc-2-0
- start surfaceflinger
- start bootanim
-
- exec_start wait_for_keymaster
- # Mount RW partitions which need run fsck
- mount_all /vendor/etc/fstab.${ro.hardware} --late
diff --git a/device/rockchip/common/scripts/fstab_tools/fstab.in b/device/rockchip/common/scripts/fstab_tools/fstab.in
index 2ec6c26565..b8cef766e9 100755
--- a/device/rockchip/common/scripts/fstab_tools/fstab.in
+++ b/device/rockchip/common/scripts/fstab_tools/fstab.in
@@ -23,6 +23,6 @@ ${_block_prefix}odm /odm ext4 ro,barrier=1 ${_flags},first_stage_mount
# For sdmmc
/devices/platform/${_sdmmc_device}/mmc_host* auto auto defaults voldmanaged=sdcard1:auto
# Full disk encryption has less effect on rk3326, so default to enable this.
-/dev/block/by-name/userdata /data f2fs noatime,nosuid,nodev,discard,reserve_root=32768,resgid=1065 latemount,wait,check,fileencryption=aes-256-xts:aes-256-cts:v2+inlinecrypt_optimized,keydirectory=/metadata/vold/metadata_encryption,quota,formattable,reservedsize=128M,checkpoint=fs
+/dev/block/by-name/userdata /data f2fs noatime,nosuid,nodev,discard,reserve_root=32768,resgid=1065 latemount,wait,check,keydirectory=/metadata/vold/metadata_encryption,quota,formattable,reservedsize=128M,checkpoint=fs
# for ext4
#/dev/block/by-name/userdata /data ext4 discard,noatime,nosuid,nodev,noauto_da_alloc,data=ordered,user_xattr,barrier=1 latemount,wait,formattable,check,fileencryption=software,quota,reservedsize=128M,checkpoint=block