From b76c7be1dba45983bbeb53721eda17fde6767504 Mon Sep 17 00:00:00 2001 From: dianlujitao Date: Wed, 26 Jan 2022 18:18:28 +0800 Subject: [PATCH] pstar: sepolicy: Rework policies for moto services * Avoid direct access to kmsg for logging purpose. * Load touchscreen driver on early-init for labelling its sysfs nodes. Change-Id: I7bb86c270d81dbd6f4bdc66e78ac77e44b61e708 --- rootdir/bin/init.oem.fingerprint.overlay.sh | 20 ++++++------ rootdir/bin/init.oem.fingerprint2.sh | 34 ++++++++++----------- rootdir/etc/init/hw/init.mmi.overlay.rc | 3 +- 3 files changed, 28 insertions(+), 29 deletions(-) diff --git a/rootdir/bin/init.oem.fingerprint.overlay.sh b/rootdir/bin/init.oem.fingerprint.overlay.sh index 3942b2b..cbcc18f 100755 --- a/rootdir/bin/init.oem.fingerprint.overlay.sh +++ b/rootdir/bin/init.oem.fingerprint.overlay.sh @@ -14,8 +14,8 @@ script_name=${0##*/} script_name=${script_name%.*} -function log { - echo "$script_name: $*" > /dev/kmsg +function notice { + log -t "$scriptname" -i "$*" } persist_fps_id=/mnt/vendor/persist/fps/vendor_id @@ -31,27 +31,27 @@ function ident_fps { log "- install FPC driver" insmod /vendor/lib/modules/fpc1020_mmi.ko sleep 1 - log "- identify FPC sensor" + notice "- identify FPC sensor" setprop $PROP_FPS_IDENT "" start fpc_ident for i in $(seq 1 $MAX_TIMES) do sleep 0.1 ident_status=$(getprop $PROP_FPS_IDENT) - log "-result : $ident_status" + notice "-result : $ident_status" if [ $ident_status == $FPS_VENDOR_FPC ]; then log "ok" echo $FPS_VENDOR_FPC > $persist_fps_id return 0 elif [ $ident_status == $FPS_VENDOR_NONE ]; then - log "fail" - log "- unload FPC driver" + notice "fail" + notice "- unload FPC driver" rmmod fpc1020_mmi break fi done - log "- install Goodix driver" + notice "- install Goodix driver" insmod /vendor/lib/modules/goodix_fod_mmi.ko echo $FPS_VENDOR_GOODIX > $persist_fps_id return 0 @@ -66,16 +66,16 @@ fps_vendor=$(cat $persist_fps_id) if [ -z $fps_vendor ]; then fps_vendor=$FPS_VENDOR_NONE fi -log "FPS vendor: $fps_vendor" +notice "FPS vendor: $fps_vendor" if [ $fps_vendor == $FPS_VENDOR_GOODIX ]; then - log "- install Goodix driver" + notice "- install Goodix driver" insmod /vendor/lib/modules/goodix_fod_mmi.ko return $? fi if [ $fps_vendor == $FPS_VENDOR_FPC ]; then - log "- install FPC driver" + notice "- install FPC driver" insmod /vendor/lib/modules/fpc1020_mmi.ko return $? fi diff --git a/rootdir/bin/init.oem.fingerprint2.sh b/rootdir/bin/init.oem.fingerprint2.sh index c858d42..1491eb5 100755 --- a/rootdir/bin/init.oem.fingerprint2.sh +++ b/rootdir/bin/init.oem.fingerprint2.sh @@ -10,8 +10,8 @@ script_name=${0##*/} script_name=${script_name%.*} -function log { - echo "$script_name: $*" > /dev/kmsg +function notice { + log -t "$scriptname" -i "$*" } persist_fps_id=/mnt/vendor/persist/fps/vendor_id @@ -19,7 +19,7 @@ persist_fps_id2=/mnt/vendor/persist/fps/last_vendor_id MAX_TIMES=100 if [ ! -f $persist_fps_id ]; then - log "warn: no associated persist file found" + notice "warn: no associated persist file found" return -1 fi FPS_VENDOR_NONE=none @@ -36,15 +36,15 @@ fps_vendor2=$(cat $persist_fps_id2) if [ -z $fps_vendor2 ]; then fps_vendor2=$FPS_VENDOR_NONE fi -log "FPS vendor (last): $fps_vendor2" +notice "FPS vendor (last): $fps_vendor2" fps_vendor=$(cat $persist_fps_id) if [ -z $fps_vendor ]; then fps_vendor=$FPS_VENDOR_NONE fi -log "FPS vendor: $fps_vendor" +notice "FPS vendor: $fps_vendor" if [ $fps_vendor == $FPS_STATUS_NONE ]; then - log "warn: boot as the last FPS" + notice "warn: boot as the last FPS" fps=$fps_vendor2 else fps=$fps_vendor @@ -55,35 +55,35 @@ do setprop $prop_fps_status $FPS_STATUS_NONE if [ $fps == $FPS_VENDOR_FPC ]; then - log "start fps_hal" + notice "start fps_hal" start fps_hal else - log "start goodix_hal" + notice "start goodix_hal" start goodix_hal fi -log "wait for HAL finish ..." +notice "wait for HAL finish ..." fps_status=$(getprop $prop_fps_status) for ii in $(seq 1 $MAX_TIMES) do -# log "check fps vendor status: $fps_status" +# notice "check fps vendor status: $fps_status" if [ $fps_status != $FPS_STATUS_NONE ]; then break fi sleep 0.2 fps_status=$(getprop $prop_fps_status) done -log "fingerprint HAL status: $fps_status" +notice "fingerprint HAL status: $fps_status" if [ $fps_status == $FPS_STATUS_OK ]; then - log "HAL success" + notice "HAL success" setprop $prop_persist_fps $fps if [ $fps_vendor2 == $fps ]; then return 0 fi - log "- update FPS vendor (last)" + notice "- update FPS vendor (last)" echo $fps > $persist_fps_id2 - log "- done" + notice "- done" return 0 fi @@ -103,11 +103,11 @@ if [ $fps == $fps_vendor2 ]; then insmod /vendor/lib/modules/fpc1020_mmi.ko fps=$FPS_VENDOR_FPC fi - log "- update FPS vendor" + notice "- update FPS vendor" echo $fps > $persist_fps_id sleep 1 else - log "error: HAL fail unload ko" + notice "error: HAL fail unload ko" if [ $fps == $FPS_VENDOR_FPC ]; then rmmod fpc1020_mmi else @@ -116,7 +116,7 @@ else setprop $prop_persist_fps $FPS_VENDOR_NONE echo $FPS_VENDOR_NONE > $persist_fps_id - log "- done" + notice "- done" return 1 fi diff --git a/rootdir/etc/init/hw/init.mmi.overlay.rc b/rootdir/etc/init/hw/init.mmi.overlay.rc index 916f925..e20ba07 100644 --- a/rootdir/etc/init/hw/init.mmi.overlay.rc +++ b/rootdir/etc/init/hw/init.mmi.overlay.rc @@ -5,6 +5,7 @@ import /vendor/etc/init/hw/init.vendor.st21nfc.rc on early-init setprop ro.vendor.device_edition ${ro.boot.edition} exec u:r:vendor_modprobe:s0 -- /vendor/bin/modprobe -a -d /vendor/lib/modules qpnp-smbcharger-mmi qpnp_adaptive_charge + exec u:r:vendor_modprove:s0 -- /vendor/bin/modprobe -a -d /vendor/lib/modules touchscreen_mmi.ko stmicro_mmi.ko on mmi-priority # Only high priority MMI DLKMs loaded here @@ -30,8 +31,6 @@ on fs insmod /vendor/lib/modules/tzlog_dump.ko insmod /vendor/lib/modules/watchdog_cpu_ctx.ko insmod /vendor/lib/modules/mmi_relay.ko - insmod /vendor/lib/modules/touchscreen_mmi.ko - insmod /vendor/lib/modules/stmicro_mmi.ko insmod /vendor/lib/modules/sx937x_sar.ko insmod /vendor/lib/modules/st21nfc.ko insmod /vendor/lib/modules/stmvl53l1.ko