From b985836432fce4b945d94692e6c6a817aa0f18f7 Mon Sep 17 00:00:00 2001 From: Andrew Hexen Date: Fri, 1 Jul 2022 22:49:12 -0700 Subject: [PATCH] berlna: recovery: add touch script to recovery Signed-off-by: Andrew Hexen Change-Id: I3daf399871b997f18a6d2aa25fac4926c373def3 --- device.mk | 5 +++ recovery/Android.mk | 20 ++++++++++ recovery/bin/load_touch.sh | 60 ++++++++++++++++++++++++++++ recovery/etc/init.recovery.berlna.rc | 39 ++++++++++++++++++ sepolicy/vendor/file_contexts | 3 ++ 5 files changed, 127 insertions(+) create mode 100644 recovery/Android.mk create mode 100644 recovery/bin/load_touch.sh create mode 100644 recovery/etc/init.recovery.berlna.rc diff --git a/device.mk b/device.mk index 92842c5..a8d3848 100644 --- a/device.mk +++ b/device.mk @@ -67,6 +67,11 @@ $(foreach f,$(wildcard $(LOCAL_PATH)/rootdir/etc/init/*.rc),\ $(foreach f,$(wildcard $(LOCAL_PATH)/rootdir/bin/*.sh),\ $(eval PRODUCT_COPY_FILES += $(f):$(TARGET_COPY_OUT_VENDOR)/bin/$(notdir $f))) +# Init (recovery) +PRODUCT_PACKAGES += \ + init.recovery.berlna.rc \ + load_touch.sh + # Lineage Touch PRODUCT_PACKAGES += \ vendor.lineage.touch@1.0-service.berlna diff --git a/recovery/Android.mk b/recovery/Android.mk new file mode 100644 index 0000000..d302fe7 --- /dev/null +++ b/recovery/Android.mk @@ -0,0 +1,20 @@ +LOCAL_PATH := $(call my-dir) + +# Recovery-Stuffs + +include $(CLEAR_VARS) +LOCAL_MODULE := init.recovery.berlna.rc +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE_CLASS := ETC +LOCAL_SRC_FILES := etc/init.recovery.berlna.rc +LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/ +include $(BUILD_PREBUILT) + +include $(CLEAR_VARS) +LOCAL_MODULE := load_touch.sh +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE_CLASS := ETC +LOCAL_SRC_FILES := bin/load_touch.sh +LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/vendor/bin/ +include $(BUILD_PREBUILT) diff --git a/recovery/bin/load_touch.sh b/recovery/bin/load_touch.sh new file mode 100644 index 0000000..1f872db --- /dev/null +++ b/recovery/bin/load_touch.sh @@ -0,0 +1,60 @@ +#!/system/bin/sh + +firmware_path=/vendor/firmware +touch_class_path=/sys/class/touchscreen +touch_path= +firmware_file= + +wait_for_poweron() +{ + local wait_nomore + local readiness + local count + echo "wait until driver reports ..." + wait_nomore=60 + count=0 + while true; do + readiness=$(cat $touch_path/poweron) + if [ "$readiness" == "1" ]; then + echo "ready to flash!!!" + break; + fi + count=$((count+1)) + [ $count -eq $wait_nomore ] && break + sleep 1 + echo "not ready; keep waiting..." + done + if [ $count -eq $wait_nomore ]; then + return 1 + fi + return 0 +} + +load_touch() +{ + panel_supplier="" + panel_supplier=$(cat /sys/class/touchscreen/*/panel_supplier) + echo "panel supplier vendor is: [$panel_supplier]" + cd $firmware_path + case $panel_supplier in + tianma) + firmware_file="novatek_ts-NT36675-21061805-603a-berlna.bin" + ;; + esac + echo "Firmware file for upgrade $firmware_file" + touch_path=/sys/class/touchscreen/$(ls /sys/class/touchscreen/) + wait_for_poweron + wait + echo "forcing firmware upgrade" + echo 1 > $touch_path/forcereflash + wait + echo "sending reflash command" + echo $firmware_file > $touch_path/doreflash + sleep 1.5 + echo "Resetting Touch" + echo 1 > $touch_path/reset +} + +load_touch + +exit 0 diff --git a/recovery/etc/init.recovery.berlna.rc b/recovery/etc/init.recovery.berlna.rc new file mode 100644 index 0000000..01c8f97 --- /dev/null +++ b/recovery/etc/init.recovery.berlna.rc @@ -0,0 +1,39 @@ +# Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of The Linux Foundation nor +# the names of its contributors may be used to endorse or promote +# products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +on boot + start load_touch + +on property:sys.usb.config=fastboot + start load_touch + +service load_touch vendor/bin/load_touch.sh + oneshot + disabled + user root + group root + seclabel u:r:recovery:s0 diff --git a/sepolicy/vendor/file_contexts b/sepolicy/vendor/file_contexts index 2c185ae..e68be5d 100644 --- a/sepolicy/vendor/file_contexts +++ b/sepolicy/vendor/file_contexts @@ -7,3 +7,6 @@ # Fingerprint /(mnt/vendor)/persist/egis(/.*)? u:object_r:fingerprint_vendor_data_file:s0 /sys/devices/soc/0.et320(/.*)? u:object_r:vendor_sysfs_fingerprint:s0 + +# Vendor init scripts +/(vendor|system/vendor)/bin/load_touch\.sh u:object_r:vendor_qti_init_shell_exec:s0