diff --git a/device.mk b/device.mk index d47cdd51..db1a74b9 100755 --- a/device.mk +++ b/device.mk @@ -562,6 +562,8 @@ PRODUCT_COPY_FILES += \ # Fingerprint HIDL implementation PRODUCT_PACKAGES += \ android.hardware.biometrics.fingerprint@2.1-service.fpc +PRODUCT_COPY_FILES += \ + $(LOCAL_PATH)/init.fingerprint.sh:$(TARGET_COPY_OUT_VENDOR)/bin/init.fingerprint.sh \ PRODUCT_COPY_FILES += \ frameworks/native/data/etc/android.hardware.fingerprint.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.fingerprint.xml diff --git a/init.fingerprint.sh b/init.fingerprint.sh new file mode 100755 index 00000000..413fd9ed --- /dev/null +++ b/init.fingerprint.sh @@ -0,0 +1,48 @@ +#!/vendor/bin/sh +# /vendor/bin/init.fingerprint.sh [max_init_retry_times] + +# fps_hal service prop +fps_svc_prop='init.svc.vendor.fps_hal' +# fps_hal service name +fps_svc_name='vendor.fps_hal' +# fps_hal service init retry count +init_retry_count_prop='vendor.fps.init_retry.count' +# fps_hal service init succeed +init_succeed_prop='vendor.fps.init.succeed' +# Define maximum init retry times as default 10 +max_times=10 + +# Deal with the input parameter +if [ "$#" -ge 1 ]; then + # Check is it positive number or not + # If so, then set maximum times as $1 + # If not, $max_times keeps in default value + if [ "$1" -eq "$1" ] && [ "$1" -gt 0 ]; then + max_times=$1 + echo $max_times + fi +fi + +# fps_hal service init retry count +init_retry_count=0 + +while [ "$init_retry_count" -le "$max_times" ] +do + # debouncing time for init processing + sleep 5 + # Get fps_hal service state and count init retry times + fps_svc_state=$(getprop $fps_svc_prop) + if [ "$fps_svc_state" == "stopped" ]; then + if [ "$init_retry_count" -lt "$max_times" ]; then + init_retry_count=$((init_retry_count+1)) + setprop $init_retry_count_prop $init_retry_count + setprop $init_succeed_prop false + start $fps_svc_name + else + break; + fi + elif [ "$fps_svc_state" == "running" ]; then + setprop $init_succeed_prop true + break + fi +done diff --git a/init.hardware.rc b/init.hardware.rc index 5fd6e009..951b8db5 100644 --- a/init.hardware.rc +++ b/init.hardware.rc @@ -879,3 +879,20 @@ on property:init.svc.bugreport=running on property:init.svc.bugreport=stopped write /d/tracing/instances/pixel-trace/tracing_on 1 + +# init-fingerprint-sh is for stopping fps_hal after init retry fail serval times +# It keeps running until max init retry or fps_hal running successfully +# vendor.fps_hal restarts until max init retry times +# +# /vendor/bin/init.fingerprint.sh [max_init_retry_times] +service init-fingerprint-sh /vendor/bin/init.fingerprint.sh 10 + group root + user root + disabled + oneshot + +on property:sys.boot_completed=1 + start init-fingerprint-sh + +on property:vendor.fps.init.succeed=true && property:init.svc.vendor.fps_hal=stopped + start init-fingerprint-sh diff --git a/sepolicy/vendor/file_contexts b/sepolicy/vendor/file_contexts index 81e2b590..5a1aeed4 100644 --- a/sepolicy/vendor/file_contexts +++ b/sepolicy/vendor/file_contexts @@ -181,6 +181,7 @@ /vendor/bin/init\.radio\.sh u:object_r:init_radio_exec:s0 /vendor/bin/ramoops u:object_r:ramoops_exec:s0 /vendor/bin/init\.ramoops\.sh u:object_r:ramoops_exec:s0 +/vendor/bin/init\.fingerprint\.sh u:object_r:init-fingerprint_exec:s0 /vendor/bin/hw/android\.hardware\.bluetooth@1\.0-service-qti u:object_r:hal_bluetooth_default_exec:s0 /vendor/bin/hw/android\.hardware\.drm@1\.1-service\.widevine u:object_r:hal_drm_widevine_exec:s0 diff --git a/sepolicy/vendor/init-fingerprint.te b/sepolicy/vendor/init-fingerprint.te new file mode 100644 index 00000000..7053f0da --- /dev/null +++ b/sepolicy/vendor/init-fingerprint.te @@ -0,0 +1,10 @@ +type init-fingerprint, domain; +type init-fingerprint_exec, exec_type, vendor_file_type, file_type; + +init_daemon_domain(init-fingerprint) + +allow init-fingerprint vendor_shell_exec:file rx_file_perms; +allow init-fingerprint vendor_toolbox_exec:file rx_file_perms; + +set_prop(init-fingerprint, vendor_fingerprint_prop) +set_prop(init-fingerprint, ctl_start_prop) diff --git a/sepolicy/vendor/property.te b/sepolicy/vendor/property.te index f22f1093..9a978b12 100644 --- a/sepolicy/vendor/property.te +++ b/sepolicy/vendor/property.te @@ -25,3 +25,6 @@ type vendor_usb_config_prop, property_type; type vendor_charge_prop, property_type; type persist_nfc_prop, property_type; type vendor_ramoops_prop, property_type; + +# fingerprint +type vendor_fingerprint_prop, property_type; diff --git a/sepolicy/vendor/property_contexts b/sepolicy/vendor/property_contexts index d8a80683..9d4597da 100644 --- a/sepolicy/vendor/property_contexts +++ b/sepolicy/vendor/property_contexts @@ -212,3 +212,7 @@ persist.nfc. u:object_r:persist_nfc_prop:s0 # ramoops vendor.ramoops. u:object_r:vendor_ramoops_prop:s0 + +# fingerprint +vendor.fps.init.succeed u:object_r:vendor_fingerprint_prop:s0 +vendor.fps.init_retry.count u:object_r:vendor_fingerprint_prop:s0