From 53b297734ed84b86746abebbc7efa1509461c5da Mon Sep 17 00:00:00 2001 From: Anand S Date: Sat, 10 May 2025 17:22:13 +0530 Subject: [PATCH] rhodep: init: Selectively update from stock Change-Id: I34880cc66f5732d5031ae03c14487b0e580a8c31 --- device.mk | 3 +- init/Android.bp | 6 ++ init/init.mmi.overlay.rc | 143 +++++++++------------------ init/init.oem.fingerprint2.sh | 179 ++++++++++++++++++++++++++++++++++ 4 files changed, 235 insertions(+), 96 deletions(-) create mode 100755 init/init.oem.fingerprint2.sh diff --git a/device.mk b/device.mk index d702f83..4b7161b 100644 --- a/device.mk +++ b/device.mk @@ -46,7 +46,8 @@ PRODUCT_PACKAGES += \ # Init PRODUCT_PACKAGES += \ - init.mmi.overlay.rc + init.mmi.overlay.rc \ + init.oem.fingerprint2.sh # NFC PRODUCT_PACKAGES += \ diff --git a/init/Android.bp b/init/Android.bp index 1f12d95..97e8357 100644 --- a/init/Android.bp +++ b/init/Android.bp @@ -9,3 +9,9 @@ prebuilt_etc { sub_dir: "init/hw", vendor: true, } + +sh_binary { + name: "init.oem.fingerprint2.sh", + src: "init.oem.fingerprint2.sh", + vendor: true, +} diff --git a/init/init.mmi.overlay.rc b/init/init.mmi.overlay.rc index 5a98f42..4acd0aa 100644 --- a/init/init.mmi.overlay.rc +++ b/init/init.mmi.overlay.rc @@ -6,107 +6,66 @@ on post-fs chown system system /sys/devices/platform/soc/4a80000.spi/spi_master/spi0/spi0.0/touchscreen/primary/double_tap_enabled chown system system /sys/devices/platform/soc/4a80000.spi/spi_master/spi0/spi0.0/touchscreen/primary/double_tap_pressed +#fps dual sensor +service chipone_ident /vendor/bin/hw/chipone_ident + class late_start + user system + group system + oneshot + disabled + +service vendor.ident-fps-overlay-sh /vendor/bin/init.oem.fingerprint.overlay.sh + class core + user root + group drmrpc system + oneshot + disabled + on post-fs-data - + exec_start vendor.ident-fps-overlay-sh + chown system system /dev/fpsensor + chmod 0660 /dev/fpsensor chown system system /sys/devices/platform/soc/soc:fm_wcn39x0/elna_en - # touch api - chown system system /sys/class/touchscreen/primary/interpolation - chmod 0660 /sys/class/touchscreen/primary/interpolation - chown system system /sys/class/touchscreen/primary/first_filter - chmod 0660 /sys/class/touchscreen/primary/first_filter - chown system system /sys/class/touchscreen/primary/edge - chmod 0660 /sys/class/touchscreen/primary/edge - # change permission for stylus - chown system system /sys/class/touchscreen/primary/palm_settings - # Change ownership and permission for bq25960-standalone factory testing - chown system system /sys/class/power_supply/bq25960-standalone/voltage_now - chown system system /sys/bus/iio/devices/iio:device6/in_index_bq25980_cp_enabled_input - chmod 0644 /sys/class/power_supply/bq25960-standalone/voltage_now - chmod 0664 /sys/bus/iio/devices/iio:device6/in_index_bq25980_cp_enabled_input + # Change ownership and permission for cp-standalone factory testing + chown system system /sys/class/power_supply/cp-standalone/voltage_now + chown system system /sys/bus/iio/devices/iio:device5/in_index_sc8549_cp_enable_input + chmod 0644 /sys/class/power_supply/cp-standalone/voltage_now + chmod 0664 /sys/bus/iio/devices/iio:device5/in_index_sc8549_cp_enable_input - # Add for Egis Fod fingerprint - mkdir /data/vendor/egis 0770 system system - mkdir /mnt/vendor/persist/egis 0770 system system - mkdir /data/vendor/tzstorage/egis 0770 system system - mkdir /data/vendor/egis/cqa 0770 system system - - # Add for after-sale ois gyro cal - mkdir /mnt/vendor/persist/camera/gyro_compat 0770 vendor_tcmd camera - - # Add for OIS hall test result - mkdir /mnt/vendor/persist/camera/ois_hall 0770 vendor_tcmd camera - - # Add for fod fps calibration - chown system system /sys/class/backlight/panel0-backlight/brightness - chown system system /sys/class/drm/card0-DSI-1/panelName - chown system system /sys/class/drm/card0-DSI-1/panelId - chown system system /d/dri/0/debug/motUtil - chmod 0666 /d/dri/0/debug/motUtil; - chmod 0666 /sys/class/backlight/panel0-backlight/brightness - chmod 0666 /sys/class/drm/card0-DSI-1/panelName - chmod 0666 /sys/class/drm/card0-DSI-1/panelId - - #bluetooth sar - write /data/vendor/radio/bluetooth_sar disable - chmod 0644 /data/vendor/radio/bluetooth_sar - chown radio /data/vendor/radio/bluetooth_sar - -on early-init - exec u:r:vendor_modprobe:s0 -- /vendor/bin/modprobe -r -d /vendor/lib/modules/${ro.vendor.mot.gki.path} zram - -on boot - # vibrator hal need to access this sysfs node for AF noise issue - chown system system /sys/devices/platform/soc/soc:mot,cam-actuator/onekey_actuator - chmod 0660 /sys/devices/platform/soc/soc:mot,cam-actuator/onekey_actuator - # change permission for capsensor - chown system system /sys/class/capsense/reset - chown system system /sys/class/capsense/int_state - chown radio system /sys/class/capsense/reg - chown radio system /sys/class/capsense/fw_download_status - chown system system /sys/class/capsense/mode - chmod 0660 /sys/class/capsense/reset - chmod 0660 /sys/class/capsense/int_state - chmod 0660 /sys/class/capsense/reg - chmod 0660 /sys/class/capsense/fw_download_status - # touch - chown system system /sys/class/touchscreen/primary/interpolation - chmod 0660 /sys/class/touchscreen/primary/interpolation - chown system system /sys/class/touchscreen/primary/sample - chmod 0660 /sys/class/touchscreen/primary/sample - chown system system /sys/class/touchscreen/primary/edge - chmod 0660 /sys/class/touchscreen/primary/edge - chown system system /sys/class/touchscreen/primary/gesture - chmod 0660 /sys/class/touchscreen/primary/gesture - chmod 0660 /sys/class/capsense/mode - chmod 0666 /dev/gtp_tools + chown vendor_pwric vendor_pwric /sys/class/power_supply/cp-standalone/force_chg_auto_enable on fs - insmod /vendor/lib/modules/${ro.vendor.mot.gki.path}/rbs_fod_mmi.ko + insmod /vendor/lib/modules/${ro.vendor.mot.gki.path}/goodix_brl_mmi.ko + insmod /vendor/lib/modules/${ro.vendor.mot.gki.path}/mmi_charger.ko + insmod /vendor/lib/modules/${ro.vendor.mot.gki.path}/bq2597x_mmi_iio.ko + insmod /vendor/lib/modules/${ro.vendor.mot.gki.path}/mmi_discrete_charger_class.ko + insmod /vendor/lib/modules/${ro.vendor.mot.gki.path}/sgm4154x_charger.ko + insmod /vendor/lib/modules/${ro.vendor.mot.gki.path}/bq2589x_charger.ko + insmod /vendor/lib/modules/${ro.vendor.mot.gki.path}/mmi_discrete_charger.ko + insmod /vendor/lib/modules/${ro.vendor.mot.gki.path}/qpnp_adaptive_charge.ko + insmod /vendor/lib/modules/${ro.vendor.mot.gki.path}/tcpc_class.ko + insmod /vendor/lib/modules/${ro.vendor.mot.gki.path}/tcpc_rt1711h.ko + insmod /vendor/lib/modules/${ro.vendor.mot.gki.path}/tcpc_sgm7220.ko + insmod /vendor/lib/modules/${ro.vendor.mot.gki.path}/rt_pd_manager.ko + insmod /vendor/lib/modules/${ro.vendor.mot.gki.path}/mmi_discrete_turbo_charger.ko on boot && property:ro.vendor.mot.gki.path=5.4-gki insmod /vendor/lib/modules/${ro.vendor.mot.gki.path}/nfc_i2c.ko -on late-init - insmod /vendor/lib/modules/${ro.vendor.mot.gki.path}/qpnp_adaptive_charge.ko - insmod /vendor/lib/modules/${ro.vendor.mot.gki.path}/mmi-smbcharger-iio.ko - insmod /vendor/lib/modules/${ro.vendor.mot.gki.path}/mmi_parallel_charger_iio.ko - -on early-boot - # Add for egis fingerprint - chown system system /dev/esfp0 - chmod 0664 /dev/esfp0 - - chown system camera /dev/cci_intf - chmod 0660 /dev/cci_intf - on charger + insmod /vendor/lib/modules/${ro.vendor.mot.gki.path}/mmi_charger.ko + insmod /vendor/lib/modules/${ro.vendor.mot.gki.path}/bq2597x_mmi_iio.ko + insmod /vendor/lib/modules/${ro.vendor.mot.gki.path}/mmi_discrete_charger_class.ko + insmod /vendor/lib/modules/${ro.vendor.mot.gki.path}/sgm4154x_charger.ko + insmod /vendor/lib/modules/${ro.vendor.mot.gki.path}/bq2589x_charger.ko + insmod /vendor/lib/modules/${ro.vendor.mot.gki.path}/mmi_discrete_charger.ko insmod /vendor/lib/modules/${ro.vendor.mot.gki.path}/qpnp_adaptive_charge.ko - insmod /vendor/lib/modules/${ro.vendor.mot.gki.path}/mmi-smbcharger-iio.ko - insmod /vendor/lib/modules/${ro.vendor.mot.gki.path}/mmi_parallel_charger_iio.ko - -on post-fs-data && property:ro.boot.mode=charger - setprop persist.vendor.hvdcp_opti.start 1 + insmod /vendor/lib/modules/${ro.vendor.mot.gki.path}/tcpc_class.ko + insmod /vendor/lib/modules/${ro.vendor.mot.gki.path}/tcpc_rt1711h.ko + insmod /vendor/lib/modules/${ro.vendor.mot.gki.path}/tcpc_sgm7220.ko + insmod /vendor/lib/modules/${ro.vendor.mot.gki.path}/rt_pd_manager.ko + insmod /vendor/lib/modules/${ro.vendor.mot.gki.path}/mmi_discrete_turbo_charger.ko service capsense_reset /vendor/bin/capsense_reset class core @@ -114,11 +73,5 @@ service capsense_reset /vendor/bin/capsense_reset group system input disabled -on property:vendor.bluetooth.sar_state=connect - write /data/vendor/radio/bluetooth_sar connect - -on property:vendor.bluetooth.sar_state=disconnect - write /data/vendor/radio/bluetooth_sar disconnect - on property:sys.boot_completed=1 start capsense_reset diff --git a/init/init.oem.fingerprint2.sh b/init/init.oem.fingerprint2.sh new file mode 100755 index 0000000..4fdc943 --- /dev/null +++ b/init/init.oem.fingerprint2.sh @@ -0,0 +1,179 @@ +#!/vendor/bin/sh +# +# Start indicated fingerprint HAL service +# +# Copyright (c) 2019 Lenovo +# All rights reserved. +# +# April 15, 2019 chengql2@lenovo.com Initial version +# December 2, 2019 chengql2 Store fps_id into persist fs +# November 19, 2020 zengzm refactor the code, support more than 3 fingerprint sensors; support config. + +# get the filename, contains the file postfix +script_name=${0##*/} +# remove the file postfix +script_name=${script_name%.*} +function log { + echo "$script_name: $*" > /dev/kmsg +} + +PROP_GKI_PATH=ro.vendor.mot.gki.path +GKI_PATH=$(getprop $PROP_GKI_PATH) + +# for new projects, only need to config varible vendor_list,kernel_so_list,kernel_so_name_list,hal_list +# vendor_list: the array contains the sensor name, it will be used for system properties. +# kernel_so_list: the array contains the kernel so's absolute path. It will be used at insmod. +# kernel_so_name_list: the array contains the kernel so's name. It will be used at rmmod. +# hal_list: the array contains the hal service name. +# +# note: all arrays should have the same size. +vendor_list=('egis' 'focal') +kernel_so_list=("/vendor/lib/modules/$GKI_PATH/rbs_fps_mmi.ko" "/vendor/lib/modules/$GKI_PATH/focal_fps_mmi.ko") +kernel_so_name_list=("rbs_fps_mmi.ko" "focal_fps_mmi.ko") +hal_list=('ets_hal' 'focal_hal') +last_vendor_index=`expr ${#vendor_list[@]} - 1` +vendor_list_size=${#vendor_list[@]} + +if [ $vendor_list_size != ${#kernel_so_list[@]} ]; then + log "error, vendor_list.size is not equal to kernel_so_list" + return 255 +fi + +if [ $vendor_list_size != ${#kernel_so_name_list[@]} ]; then + log "error, vendor_list.size is not equal to kernel_so_name_list" + return 255 +fi + +if [ $vendor_list_size != ${#hal_list[@]} ]; then + log "error, vendor_list.size is not equal to hal_list" + return 255 +fi + +# At the current boot, what is the fingerprint sensor +persist_fps_id=/mnt/vendor/persist/fps/vendor_id + +# what is the fingerprint sensor successfully installed before. +persist_fps_id2=/mnt/vendor/persist/fps/last_vendor_id + +FPS_VENDOR_NONE=none +MAX_TIMES=20 + +# this property store FPS_STATUS_NONE or FPS_STATUS_OK +# after start fingerprint hal service, the hal service will set this property. +prop_fps_status=vendor.hw.fingerprint.status + +# use this to trigger init.mmi.rc +prop_fps_ident=vendor.hw.fps.ident + +# if $prop_fps_status=$FPS_STATUS_OK, then will set prop_persist_fps to the specific vendor name. +prop_persist_fps=persist.vendor.hardware.fingerprint + +FPS_STATUS_NONE=none +FPS_STATUS_OK=ok + +function find_vendor_index() { + # param1: the specific vendor name + # return: the vendor index in vendor_list. the valid index is from 0; if not found,return 255 + for temp_vendor_index in $(seq 0 $last_vendor_index) + do + if [ "${vendor_list[temp_vendor_index]}" = "$1" ]; then + return $temp_vendor_index + fi + done + return 255 +} + +function start_hal_service(){ + # param1: the vendor index + # return: 0 means success, will setprop $prop_persist_fps + setprop $prop_fps_status $FPS_STATUS_NONE + setprop $prop_fps_ident $FPS_STATUS_NONE + + insmod ${kernel_so_list[$1]} + log "${kernel_so_list[$1]} insmod" + sleep 1 + setprop $prop_fps_ident ${vendor_list[$1]} + + log "start ${hal_list[$1]}" + start ${hal_list[$1]} + + for ii in $(seq 1 $MAX_TIMES) + do + sleep 0.1 + fps_status=$(getprop $prop_fps_status) + # log "check fps vendor status: $fps_status" + if [ $fps_status != $FPS_STATUS_NONE ]; then + break + fi + done + + log "fingerprint HAL status: $fps_status" + if [ $fps_status == $FPS_STATUS_OK ]; then + log "start ${hal_list[$1]} hal success" + setprop $prop_persist_fps ${vendor_list[$1]} + return 0 + fi + + log "start ${hal_list[$1]} hal failed, remove kernel so: ${kernel_so_name_list[$1]} " + setprop ctl.stop ${hal_list[$1]} + rmmod ${kernel_so_name_list[$1]} + sleep 0.1 + # if failed,return 255 + return 255 +} + +# set last fingerprint sensor +fps_vendor=$(cat $persist_fps_id) +if [ -n "$fps_vendor" ] && [ "$fps_vendor" != $FPS_STATUS_NONE ]; then + echo $fps_vendor > $persist_fps_id2 +fi + +# get the identified fingerprint sensor +fps_vendor2=$(cat $persist_fps_id2) +if [ -z $fps_vendor2 ]; then + fps_vendor2=$FPS_VENDOR_NONE +fi +log "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 (current): $fps_vendor" + +vendor_index=255 +# try to start the most recent success launched sensor. +if [ $fps_vendor != $FPS_STATUS_NONE ]; then + find_vendor_index $fps_vendor + vendor_index=$? + if [ $vendor_index != 255 ]; then + log "start $fps_vendor hal service" + start_hal_service $vendor_index + if [ $? != 255 ]; then + return 0 + fi + fi +fi + +# try all the fingerprint sensors +for temp_vendor_index in $(seq 0 $last_vendor_index) +do + if [ $temp_vendor_index == $vendor_index ]; then + continue + fi + + if [ ! -e ${kernel_so_list[$temp_vendor_index]} ]; then + log "does not exist ${kernel_so_list[$temp_vendor_index]},ignore this fingerprint sensor" + continue + fi + + start_hal_service $temp_vendor_index + if [ $? != 255 ]; then + echo ${vendor_list[$temp_vendor_index]} > $persist_fps_id + return 0 + fi +done + +log "error, no fingerprint sensor found" +setprop $prop_persist_fps $FPS_VENDOR_NONE +echo $FPS_VENDOR_NONE > $persist_fps_id