initializing tree with aospdtgen just fr skeleton

This commit is contained in:
PROPGSP
2025-06-22 13:42:34 +05:30
commit da7bb29bf7
73 changed files with 14353 additions and 0 deletions

View File

@ -0,0 +1,53 @@
#!/vendor/bin/sh
#
# Copyright (c) 2012, Motorola Mobility LLC, All rights reserved.
#
# The purpose of this script is to annotate panic dumps with useful information
# about the context of the event.
#
export PATH=/vendor/bin:/system/bin:$PATH
annotate()
{
VAL=`$2`
[ "$VAL" ] || return
echo "$1: $VAL" > /sys/fs/pstore/annotate-ramoops
}
case $1 in
build*)
annotate "Build number" "getprop ro.build.display.id"
annotate "Build config" "getprop ro.build.config.version"
annotate "Kernel version" "cat /proc/sys/kernel/osrelease"
;;
baseband*)
annotate "Baseband version" "getprop gsm.version.baseband"
;;
esac
# check for pstore files and copy them to the /data/dontpanic
if [ -e /sys/fs/pstore/console-ramoops ]
then
cp /sys/fs/pstore/console-ramoops /data/vendor/dontpanic/last_kmsg
chown root:log /data/vendor/dontpanic/last_kmsg
chmod 0640 /data/vendor/dontpanic/last_kmsg
if [ -e /sys/fs/pstore/annotate-ramoops ]
then
cat /sys/fs/pstore/annotate-ramoops >> /data/vendor/dontpanic/last_kmsg
fi
fi
if [ -e /sys/fs/pstore/dmesg-ramoops-0 ]
then
cp /sys/fs/pstore/dmesg-ramoops-0 /data/vendor/dontpanic/apanic_console
chown root:log /data/vendor/dontpanic/apanic_console
chmod 0640 /data/vendor/dontpanic/apanic_console
if [ -e /sys/fs/pstore/annotate-ramoops ]
then
cat /sys/fs/pstore/annotate-ramoops >> /data/vendor/dontpanic/apanic_console
fi
rm /sys/fs/pstore/dmesg-ramoops-0
fi
kpgather

View File

@ -0,0 +1,47 @@
#!/vendor/bin/sh
#
# Copyright (c) 2015, Motorola Mobility LLC, All rights reserved.
#
# The purpose of this script is to read panic dumps to /data and dropbox
# for issue report
#
export PATH=/vendor/bin:/system/bin:$PATH
while getopts i op;
do
case $op in
i) ignore_apanic_logs=1;;
esac
done
if [ -z "$ignore_apanic_logs" ]; then
# read log from "kpan" partition to /data/dontpanic
kpreadwrite r
# write panic/wdt report to dropbox
kpgather
else
apanic_logcopy=$(getprop 'ro.vendor.bootreason')
if [ "$apanic_logcopy" == "coldboot" ]; then
return 0
fi
fi
if [ -e /dev/block/bootdevice/by-name/logs ] ; then
BL_logs_parti=/dev/block/bootdevice/by-name/logs
elif [ -e /dev/block/bootdevice/by-name/logfs ] ; then
BL_logs_parti=/dev/block/bootdevice/by-name/logfs
elif [ -e /dev/block/by-name/logs ] ; then
BL_logs_parti=/dev/block/by-name/logs
elif [ -e /dev/block/by-name/logfs ] ; then
BL_logs_parti=/dev/block/by-name/logfs
else
BL_logs_parti=
fi
if [ $BL_logs_parti ]
then
cat $BL_logs_parti > /data/vendor/dontpanic/BL_logs
chown root:log /data/vendor/dontpanic/BL_logs
chmod 0640 /data/vendor/dontpanic/BL_logs
fi

102
rootdir/bin/apanic_mtk.sh Normal file
View File

@ -0,0 +1,102 @@
#!/vendor/bin/sh
#
# Copyright (c) 2019, Motorola Mobility LLC, All rights reserved.
#
# The purpose of this script is to annotate panic dumps with useful information
# about the context of the event.
#
export PATH=/vendor/bin:/system/bin:$PATH
trigger=`getprop ro.vendor.boot.apanic.reason`
trigger_prop=`getprop ro.vendor.boot.apanic.prop`
# script already running by boot reason, exit
if [[ $trigger_prop && $trigger == "boot" ]]; then
exit 0
fi
# run script by db property set and boot reason is not panic
if [[ $trigger_prop && $trigger == "prop" ]]; then
aee_trigger=`getprop vendor.debug.mtk.aeev.db`
kp_type=("KE" "HWT" "HW_Reboot" "ManualMRDump" "HANG")
kp_found=0
# check panic type
if [ ! "$aee_trigger" ]; then
exit 0
fi
for va in ${kp_type[@]}; do
has_str=$(echo $aee_trigger | grep "${va}")
if [[ "$has_str" != "" ]]; then
kp_found=1
break
fi
done
if [ $kp_found == 0 ]; then
exit 0
fi
fi
if [ ! -d /data/vendor/dontpanic ]
then
mkdir /data/vendor/dontpanic
fi
# check for pstore files and copy them to the /data/dontpanic
if [ -e /sys/fs/pstore/console-ramoops* ]
then
cp /sys/fs/pstore/console-ramoops* /data/vendor/dontpanic/last_kmsg
chown root:log /data/vendor/dontpanic/last_kmsg
chmod 0640 /data/vendor/dontpanic/last_kmsg
if [ -e /sys/fs/pstore/annotate-ramoops ]
then
cat /sys/fs/pstore/annotate-ramoops >> /data/vendor/dontpanic/last_kmsg
fi
cat /proc/bootinfo >> /data/vendor/dontpanic/last_kmsg
cat /proc/version >> /data/vendor/dontpanic/last_kmsg
#storage
s_path="/sys/storage/"
storage="STORAGE: Type: "`cat ${s_path}type`", Vendor: "`cat ${s_path}vendor`
storage=$storage", Size: "`cat ${s_path}size`", Model: "`cat ${s_path}model`", FW: "`cat ${s_path}fw`
echo $storage >> /data/vendor/dontpanic/last_kmsg
#ram
r_path="/sys/ram/"
ram="RAM: Vendor: "`cat ${r_path}info`", MR5: "`cat ${r_path}mr5`
ram=$ram", MR6: "`cat ${r_path}mr6`", MR7: "`cat ${r_path}mr7`", MR8: "`cat ${r_path}mr8`
echo $ram >> /data/vendor/dontpanic/last_kmsg
fi
if [ -e /sys/fs/pstore/dmesg-ramoops-0 ]
then
cp /sys/fs/pstore/dmesg-ramoops-0 /data/vendor/dontpanic/apanic_console
chown root:log /data/vendor/dontpanic/apanic_console
chmod 0640 /data/vendor/dontpanic/apanic_console
if [ -e /sys/fs/pstore/annotate-ramoops ]
then
cat /sys/fs/pstore/annotate-ramoops >> /data/vendor/dontpanic/apanic_console
fi
fi
kpgather
if [ -e /dev/block/by-name/logs ] ; then
BL_logs_parti=/dev/block/by-name/logs
elif [ -e /dev/block/by-name/logfs ] ; then
BL_logs_parti=/dev/block/by-name/logfs
else
BL_logs_parti=
fi
if [ $BL_logs_parti ]
then
cat $BL_logs_parti > /data/vendor/dontpanic/BL_logs
chown root:log /data/vendor/dontpanic/BL_logs
chmod 0640 /data/vendor/dontpanic/BL_logs
fi

View File

@ -0,0 +1,12 @@
#!/vendor/bin/sh
#
# Copyright (c) 2016, Motorola Mobility LLC, All rights reserved.
#
# The purpose of this script is to get panic dump from pstore fs, and then
# save to emmc, and then reboot device.
#
export PATH=/vendor/bin:/system/bin:$PATH
# write log from pstore to "kpan" partition
kpreadwrite w

View File

@ -0,0 +1,408 @@
#!/vendor/bin/sh
#
# Copyright (c) 2013-2016, Motorola LLC All rights reserved.
#
# The purpose of this script is to compile information about the hardware
# versions of various devices on each unit. This is useful when searching
# through reported issues for correlations with certain hardware revisions.
# The information is collected from various locations in proc and sysfs (some
# of which are product-specific) and compiled into small, single-line text
# files in the userdata partition, one for each type of device. The format of
# these lines are as follows:
#
# MOTHREV-vX
# hw_name=XXXXX
# vendor_id=XXXXX
# hw_rev=XXXXX
# date=XXXXX
# lot_code=XXXXX
# fw_rev=XXXXX
# size=XXXXMB
# (components may also add additional fields to the ones above)
#
# The extact format of each field will be device-specific, but should be
# consistent across a particular hardware platform. Note that each revision
# data file is rewritten every time this script is called. This ensures that
# any future format changes to the revision files are picked up.
#
# While the method used to read the information should be consistent on a given
# platform, the specific path to a device's information may vary between
# products. The hardware_revisions.conf file provides a way to adjust those
# paths from the default.
#
export PATH=/vendor/bin:$PATH
scriptname=${0##*/}
notice()
{
echo "$*"
echo "$scriptname: $*" > /dev/kmsg
}
# Output destination and permissions
OUT_PATH=/data/vendor/hardware_revisions
OUT_USR=system
OUT_GRP=system
OUT_PERM=0644
OUT_PATH_PERM=0755
# Default paths to hardware information
PATH_RAM=/sys/ram
PATH_NVM=/sys/block/mmcblk0/device
PATH_STORAGE=/sys/storage
PATH_SDCARD=/sys/block/mmcblk1/device
# PATH_TOUCH_CLASS="/sys/class/touchscreen/"`cd /sys/class/touchscreen && ls */ic_ver | sed 's/ic_ver//g'`
PATH_TOUCH_MMI="/sys/class/touchscreen/"
PATH_TOUCH="/sys/bus/i2c/drivers/"`cd /sys/bus/i2c/drivers && ls */?-*/ic_ver | sed 's/ic_ver//g'`
PATH_TOUCH_SPI="/sys/bus/spi/drivers/"`cd /sys/bus/spi/drivers && ls */*.?/ic_ver | sed 's/ic_ver//g'`
PATH_DISPLAY=/sys/class/graphics/fb0
PATH_DISPLAY_DRM=/sys/class/drm/card0-DSI-1
PATH_DISPLAY_DRM_CLI=/sys/class/drm/card0-DSI-2
PATH_DISPLAY_DEVICETREE=/sys/firmware/devicetree/base/chosen
PATH_PMIC=/sys/hardware_revisions/pmic
# Product-specific overrides
[ -e /vendor/etc/hardware_revisions.conf ] && . /vendor/etc/hardware_revisions.conf
#
# Clear out all revision data in this directory. If in the future we decide
# to remove a component, we want to make sure any old files are not present.
rm /data/vendor/hardware_revisions/*
#
# Append one piece of revision data to a given file. If a value is blank,
# then nothing will be written.
#
# $1 - tag
# $2 - value
# $3 - file to write
write_one_revision_data()
{
if [ -n "${2}" ]; then
VALUE="${2}"
echo "${1}=${VALUE}" >> ${3}
fi
}
#
# Generate the common data contained for
# all hardware peripherals
#
# $1 - file to write to
# $2 - name
# $3 - vendor ID
# $4 - hardware revision
# $5 - date
# $6 - lot code
# $7 - firmware revision
create_common_revision_data()
{
FILE="${1}"
echo "MOTHREV-v2" > ${FILE}
write_one_revision_data "hw_name" "${2}" ${FILE}
write_one_revision_data "vendor_id" "${3}" ${FILE}
write_one_revision_data "hw_rev" "${4}" ${FILE}
write_one_revision_data "date" "${5}" ${FILE}
write_one_revision_data "lot_code" "${6}" ${FILE}
write_one_revision_data "fw_rev" "${7}" ${FILE}
}
create_secondary_revision_data()
{
FILE="${1}"
write_one_revision_data "hw_name_s" "${2}" ${FILE}
write_one_revision_data "vendor_id_s" "${3}" ${FILE}
write_one_revision_data "hw_rev_s" "${4}" ${FILE}
write_one_revision_data "date_s" "${5}" ${FILE}
write_one_revision_data "lot_code_s" "${6}" ${FILE}
write_one_revision_data "fw_rev_s" "${7}" ${FILE}
}
create_multiple_revision_data()
{
local primary=0
if [ $1 -eq $primary ]
then
create_common_revision_data "${FILE}" "${HNAME}" "${VEND}" "${HREV}" "${DATE}" "${LOT_CODE}" "${FREV}"
else
create_secondary_revision_data "${FILE}" "${HNAME}" "${VEND}" "${HREV}" "${DATE}" "${LOT_CODE}" "${FREV}"
fi
}
#
# Applies the appropriate file permissions to the
# hardware revision data file.
#
# $1 - file to write to
apply_revision_data_perms()
{
chown ${OUT_USR}.${OUT_GRP} "${1}"
chmod ${OUT_PERM} "${1}"
}
mkdir -p ${OUT_PATH}
chown ${OUT_USR}.${OUT_GRP} ${OUT_PATH}
chmod ${OUT_PATH_PERM} ${OUT_PATH}
#
# Compile ram
#
FILE="${OUT_PATH}/ram"
HNAME=
VEND=
HREV=
DATE=
FREV=
LOT_CODE=
INFO=
SIZE=
if [ -d "${PATH_RAM}" ] ; then
HNAME=`cat ${PATH_RAM}/type`
VEND=`cat ${PATH_RAM}/info`
VEND="${VEND%%:*:*}"
INFO="$(cat ${PATH_RAM}/mr5),$(cat ${PATH_RAM}/mr6),$(cat ${PATH_RAM}/mr7),\
$(cat ${PATH_RAM}/mr8)"
SIZE=`cat ${PATH_RAM}/size`
fi
create_common_revision_data "${FILE}" "${HNAME}" "${VEND}" "" "" "" ""
write_one_revision_data "config_info" "${INFO}" "${FILE}"
write_one_revision_data "size" "${SIZE}" "${FILE}"
apply_revision_data_perms "${FILE}"
#
# Compile nvm
#
FILE="${OUT_PATH}/nvm"
HNAME=
VEND=
HREV=
DATE=
FREV=
LOT_CODE=
SIZE=
if [ -d "${PATH_NVM}" ] ; then
HNAME=`cat ${PATH_NVM}/type`
if [ -d "${PATH_STORAGE}" ] ; then
VEND=`cat ${PATH_STORAGE}/vendor`
SIZE=$((1024 * `cat ${PATH_STORAGE}/size | sed 's/[^0-9]//g'`))
else
VEND=`cat ${PATH_NVM}/manfid`
SIZE=$((1024 * `getprop ro.boot.storage | sed 's/[^0-9]//g'`))
fi
HREV=`cat ${PATH_NVM}/name`
DATE=`cat ${PATH_NVM}/date`
if [ -e ${PATH_NVM}/device_version -a -e ${PATH_NVM}/firmware_version ] ; then
FREV="$(cat ${PATH_NVM}/device_version),$(cat ${PATH_NVM}/firmware_version)"
else
FREV="$(cat ${PATH_NVM}/hwrev),$(cat ${PATH_NVM}/fwrev)"
fi
LOT_CODE="$(cat ${PATH_NVM}/csd)"
else
if [ -d "${PATH_STORAGE}" ] ; then
HNAME=`cat ${PATH_STORAGE}/type`
VEND=`cat ${PATH_STORAGE}/vendor`
HREV=`cat ${PATH_STORAGE}/model`
FREV=`cat ${PATH_STORAGE}/fw`
SIZE=$((1024 * `cat ${PATH_STORAGE}/size | sed 's/[^0-9]//g'`))
fi
fi
create_common_revision_data "${FILE}" "${HNAME}" "${VEND}" "${HREV}" "${DATE}" "${LOT_CODE}" "${FREV}"
write_one_revision_data "size" "${SIZE}" "${FILE}"
apply_revision_data_perms "${FILE}"
#
# Compile ap
#
FILE="${OUT_PATH}/ap"
HNAME=
VEND=
HREV=
DATE=
FREV=
LOT_CODE=
if [ -e "/proc/cpuinfo" ]; then
PREVIFS="$IFS"
IFS="
"
for CPU in `cat /proc/cpuinfo` ; do
KEY="${CPU%:*}"
VAL="${CPU#*: }"
case "${KEY}" in
Processor*) HNAME="${VAL}" ;;
*implementer*) VEND="${VAL}" ;;
*variant*) HREV="${VAL}" ;;
*part*) HREV="${HREV},${VAL}" ;;
*revision*) HREV="${HREV},${VAL}" ;;
esac
done
IFS="$PREVIFS"
fi
create_common_revision_data "${FILE}" "${HNAME}" "${VEND}" "${HREV}" "" "" ""
apply_revision_data_perms "${FILE}"
#
# copy pmic data
#
FILE="${OUT_PATH}/pmic"
if [ -e "/sys/hardware_revisions/pmic" ]; then
cat /sys/hardware_revisions/pmic > ${FILE}
else
create_common_revision_data "${FILE}" "" "" "" "" "" ""
fi
apply_revision_data_perms "${FILE}"
#
# copy display data
# PATH_DISPLAY_DRM is the sys file path name for DRM display driver
# PATH_DISPLAY is the path name for the old FB driver
#
copy_panel_revision_data()
{
FILE="${OUT_PATH}/display"
HNAME=
VEND=
HREV=
local wait_cnt=0
local has_lid
local lid=1
lid_property=ro.vendor.mot.hw.lid
has_lid=$(getprop $lid_property 2> /dev/null)
notice "has lid = ${has_lid} lid= ${lid}"
while [ "$wait_cnt" -lt 8 ]; do
if [ -e ${PATH_DISPLAY_DRM}/panelName -o -e ${PATH_DISPLAY}/panelName ]; then
if [ -e ${PATH_DISPLAY_DRM}/panelName ] ; then
HNAME=`cat ${PATH_DISPLAY_DRM}/panelName`
VEND=`cat ${PATH_DISPLAY_DRM}/panelSupplier`
HREV=`cat ${PATH_DISPLAY_DRM}/panelVer`
create_multiple_revision_data 0 "${FILE}" "${HNAME}" "${VEND}" "${HREV}" "" "" ""
apply_revision_data_perms "${FILE}"
notice "creat primary panel hwrev"
else
HNAME=`cat ${PATH_DISPLAY}/panel_name`
VEND=`cat ${PATH_DISPLAY}/panel_supplier`
HREV=`cat ${PATH_DISPLAY}/panel_ver`
create_common_revision_data "${FILE}" "${HNAME}" "${VEND}" "${HREV}" "" "" ""
apply_revision_data_perms "${FILE}"
fi
if [ $has_lid -eq $lid ]
then
if [ -e ${PATH_DISPLAY_DRM_CLI}/panelName ] ; then
HNAME=`cat ${PATH_DISPLAY_DRM_CLI}/panelName`
VEND=`cat ${PATH_DISPLAY_DRM_CLI}/panelSupplier`
HREV=`cat ${PATH_DISPLAY_DRM_CLI}/panelVer`
notice "creat CLI hwrev"
create_multiple_revision_data 1 "${FILE}" "${HNAME}" "${VEND}" "${HREV}" "" "" ""
apply_revision_data_perms "${FILE}"
break;
fi
else
break;
fi
fi
sleep 1;
wait_cnt=$((wait_cnt+1))
done
}
copy_panel_revision_data
#
# Compile touchscreen
#
FILE="${OUT_PATH}/touchscreen"
HNAME=
VEND=
HREV=
DATE=
FREV=
LOT_CODE=
# If there is the touchclass path, then access the nodes under the path to get the touch related
# information, otherwise access the path originally defined by the script.
if [ -e "${PATH_TOUCH_MMI}" ]; then
cd ${PATH_TOUCH_MMI}
let index=0
for i in $(ls */ic_ver); do
class_name=`echo $i|sed 's/ic_ver//g'`
PATH_TOUCH_CLASS=${PATH_TOUCH_MMI}${class_name}
if [ -e "${PATH_TOUCH_CLASS}/vendor" ]; then
HNAME=`cat ${PATH_TOUCH_CLASS}/vendor`
ICVER=`cat -e ${PATH_TOUCH_CLASS}/ic_ver`
if [ "$HNAME" ]; then
VEND="${ICVER##*'Product ID: '}"
VEND="${VEND%%\$*}"
FREV="${ICVER##*'Build ID: '}"
FREV="${FREV%%\$*}"
LOT_CODE="${ICVER##*'Config ID: '}"
LOT_CODE="${LOT_CODE%%\$*}"
fi
create_multiple_revision_data "${index}" "${FILE}" "${HNAME}" "${VEND}" "${HREV}" "${DATE}" "${LOT_CODE}" "${FREV}"
#create_common_revision_data "${FILE}" "${HNAME}" "${VEND}" "${HREV}" "${DATE}" "${LOT_CODE}" "${FREV}"
apply_revision_data_perms "${FILE}"
let index++
fi
done
elif [ -e "${PATH_TOUCH_SPI}/name" ]; then
HNAME=`cat ${PATH_TOUCH_SPI}/name`
ICVER=`cat -e ${PATH_TOUCH_SPI}/ic_ver`
case "$HNAME" in
focaltech*)
VEND="${ICVER##*'Product ID: '}"
VEND="${VEND%%\$*}"
FREV="${ICVER##*'Build ID: '}"
FREV="${FREV%%\$*}"
;;
esac
create_common_revision_data "${FILE}" "${HNAME}" "${VEND}" "${HREV}" "${DATE}" "${LOT_CODE}" "${FREV}"
apply_revision_data_perms "${FILE}"
else
if [ -e "${PATH_TOUCH}/name" ]; then
HNAME=`cat ${PATH_TOUCH}/name`
ICVER=`cat -e ${PATH_TOUCH}/ic_ver`
case "${HNAME}" in
melfas*)
VEND="Melfas"
HREV="${ICVER##*'HW Revision:'}"
HREV="${HREV%%\$*}"
FREV="${ICVER##*'Core FW ver:'}"
FREV="${FREV%%\$*}"
;;
cyttsp*)
VEND="${ICVER##*'Custom ID:'}"
VEND="${VEND%%\$*}"
VEND="Cypress,${VEND}"
HREV="${ICVER##*'TTSP Version:'}"
HREV="${HREV%%\$*}"
FREV="${ICVER##*'Application Version:'}"
FREV="${FREV%%\$*}"
;;
atmxt*)
VEND="Atmel"
HREV="${ICVER##*'Family ID:'}"
HREV1="${ICVER##*'Variant ID:'}"
HREV="${HREV%%\$*},${HREV1%%\$*}"
FREV="${ICVER##*'Version:'}"
FREV1="${ICVER##*'Build:'}"
FREV="${FREV%%\$*},${FREV1%%\$*}"
;;
synaptics*)
VEND="${ICVER##*'Product ID: '}"
VEND="${VEND%%\$*}"
FREV="${ICVER##*'Build ID: '}"
FREV="${FREV%%\$*}"
LOT_CODE="${ICVER##*'Config ID: '}"
LOT_CODE="${LOT_CODE%%\$*}"
;;
esac
create_common_revision_data "${FILE}" "${HNAME}" "${VEND}" "${HREV}" "${DATE}" "${LOT_CODE}" "${FREV}"
apply_revision_data_perms "${FILE}"
fi
fi

View File

@ -0,0 +1,34 @@
#!/vendor/bin/sh
########################################################
### init.insmod.cfg format: ###
### ----------------------------------------------- ###
### [insmod|setprop|enable/moprobe] [path|prop name] ###
### ... ###
########################################################
if [ $# -eq 1 ]; then
cfg_file=$1
else
exit 1
fi
if [ -f $cfg_file ]; then
while IFS="|" read -r action arg
do
case $action in
"insmod") insmod $arg ;;
"setprop") setprop $arg 1 ;;
"enable") echo 1 > $arg ;;
"modprobe")
case ${arg} in
"-b *" | "-b")
arg="-b $(cat /vendor/lib/modules/modules.load)" ;;
"*" | "")
arg="$(cat /vendor/lib/modules/modules.load)" ;;
esac
modprobe -a -d /vendor/lib/modules $arg ;;
esac
done < $cfg_file
fi

View File

@ -0,0 +1,52 @@
#!/vendor/bin/sh
PATH=/sbin:/vendor/sbin:/vendor/bin:/vendor/xbin
export PATH
scriptname=${0##*/}
notice()
{
echo "$*"
echo "$scriptname: $*" > /dev/kmsg
}
# Check if we are in the first bootup sequence.
hardware_state=$(getprop ro.boot.secure_hardware)
build_tags=$(getprop ro.build.tags)
vendor_build_type=$(getprop ro.vendor.build.type)
backup_state_prop=$(getprop persist.vendor.tl.already_backup)
if [[ "$hardware_state" == "0" ]]; then
notice "Do not need trustlet backup, skip!"
exit 0
fi
# Exclude secure hw with user/userdebug testkey sw
if [[ "$hardware_state" == "1" && "$build_tags" == *"test-keys"* ]]; then
notice "Do not need trustlet backup, skip!"
exit 0
fi
# Exclude secure hw with factory userdebug releasekey sw
if [[ "$hardware_state" == "1" && "$vendor_build_type" == "userdebug" ]]; then
notice "Do not need trustlet backup, skip!"
exit 0
fi
if [[ "$backup_state_prop" == "true" ]]; then
notice "Trustlet already backed up, skip!"
exit 0
fi
# For Trustonic tl and drv backup.
if [ -d /vendor/app/mcRegistry/ ]; then
notice "Detecting trustonic path, syncing up.."
cp -af /vendor/app/mcRegistry/* /mnt/vendor/tzapp/
fi
# TODO: Add more TEE vendor support if required.
setprop persist.vendor.tl.already_backup true
notice "Trustlet backup success!"

View File

@ -0,0 +1,46 @@
#!/vendor/bin/sh
block_by_name=/dev/block/by-name
utags=${block_by_name}/utags
utags_backup=${block_by_name}/utagsBackup
CHMOD_L_FLAG=-L
# Set correct permissions for UTAGS
/vendor/bin/chown -L root:system $utags
/vendor/bin/chown -L root:system $utags_backup
/vendor/bin/chmod ${CHMOD_L_FLAG} 0660 $utags
if [ $? -ne 0 ]; then
CHMOD_L_FLAG=" "
/vendor/bin/chmod ${CHMOD_L_FLAG} 0660 $utags
fi
/vendor/bin/chmod ${CHMOD_L_FLAG} 0660 $utags_backup
# HOB/DHOB
hob=${block_by_name}/hob
dhob=${block_by_name}/dhob
if [ -f $hob ] || [ -L $hob ]; then
/vendor/bin/chown -L radio:radio $hob
/vendor/bin/chown -L radio:radio $dhob
/vendor/bin/chmod ${CHMOD_L_FLAG} 0660 $hob
/vendor/bin/chmod ${CHMOD_L_FLAG} 0660 $dhob
fi
# CLOGO
clogo=${block_by_name}/clogo
if [ -f $clogo ] || [ -L $clogo ]; then
/vendor/bin/chown -L root:vendor_tcmd $clogo
/vendor/bin/chmod ${CHMOD_L_FLAG} 0660 $clogo
fi
#CID
cid=${block_by_name}/cid
/vendor/bin/chown -L root:vendor_tcmd $cid
/vendor/bin/chmod ${CHMOD_L_FLAG} 0660 $cid
#BL logs
logs=${block_by_name}/logs
if [ -f $logs ]; then
/vendor/bin/chown -L root:system $logs
/vendor/bin/chmod ${CHMOD_L_FLAG} 0640 $logs
fi

View File

@ -0,0 +1,190 @@
#!/vendor/bin/sh
PATH=/sbin:/vendor/sbin:/vendor/bin:/vendor/xbin
export PATH
scriptname=${0##*/}
notice()
{
echo "$*"
echo "$scriptname: $*" > /dev/kmsg
}
# reload UTAGS
utag_status=$(cat /proc/config/reload)
if [ "$utag_status" == "2" ]; then
notice "Utags are not ready, reloading"
echo 1 > /proc/config/reload
utag_status=$(cat /proc/config/reload)
[ "$utag_status" != "0" ] && notice "Utags failed to reload"
fi
# Export these for factory validation purposes
iccid=$(cat /proc/config/iccid/ascii 2>/dev/null)
if [ ! -z "$iccid" ]; then
setprop ro.vendor.mot.iccid $iccid
fi
unset iccid
# Get FTI data and catch old units with incorrect/missing UTAG_FTI
pds_fti=/mnt/vendor/persist/factory/fti
if [ -r $pds_fti ]; then
set -A fti $(od -A n -t x1 $pds_fti 2>/dev/null | tr '[A-F]' '[a-f]')
else
notice "Can not read FTI data in persist"
fi
# If UTAG_FTI is readable, compare checksums
# and if they mismatch, assume PDS is valid and overwrite UTAG
utag_fti=/proc/config/fti
if [ -r $utag_fti/ascii ]; then
set -A fti_utag $(cat ${utag_fti}/raw | sed 's/../& /g' | tr '[A-F]' '[a-f]')
# Byte 128 is total cksum, if nothing there, PDS data is invalid/missing
if [ ! -z "${fti[127]}" ]; then
# Make sure fti in UTAG is the same as in persist. Checksum comparison
if [ "${fti[126]}" != "${fti_utag[126]}" -o "${fti[127]}" != "${fti_utag[127]}" ]; then
notice "Copying FTI data from persist"
cat $pds_fti > ${utag_fti}/raw
fi
else
# If PDS data is invalid, take UTAG and hope it is correct
notice "Will use FTI from UTAG"
set -A fti $(od -A n -t x1 ${utag_fti}/ascii 2>/dev/null)
fi
else
notice "Missing FTI UTAG; copying from persist"
echo fti > /proc/config/all/new
cat $pds_fti > ${utag_fti}/raw
fi
# Read HW version from FTI data
hw_v1="\x${fti[35]}"
hw_v2="\x${fti[36]}"
hw_v3="\x${fti[37]}"
if [ "$hw_v3" == "\x30" ]; then
hw_v3=""
fi
hw_v4="\x${fti[38]}"
if [ "$hw_v4" == "\x30" ]; then
hw_v4=""
fi
setprop ro.vendor.hw.boardversion $(printf "$hw_v1$hw_v2$hw_v3$hw_v4")
# Now we have set fti var either from PDS or UTAG
# Get Last Test Station stamp from FTI
# and convert to user-friendly date, US format
# Real offsets for year/month/day are 63/64/65
# If the month/date look reasonable, data is probably OK.
mdate="Unknown"
y=0x${fti[63]}
m=0x${fti[64]}
d=0x${fti[65]}
let year=$y month=$m day=$d
# Invalid data will often have bogus month/date values
if [ $month -le 12 -a $day -le 31 -a $year -ge 12 ]; then
mdate=$month/$day/20$year
else
notice "Corrupt FTI data"
fi
# FEATURE-7596 The utag date is preferred
utag_date=$(cat /proc/config/date/ascii 2>/dev/null)
if [ ! -z "$utag_date" ]; then
# utage date format mm-dd-yyyy
utag_date=(${utag_date//-/ })
m=${utag_date[0]}
d=${utag_date[1]}
y=${utag_date[2]}
let year=$y month=$m day=$d
if [ $month -le 12 -a $month -ge 1 -a $day -le 31 -a $day -ge 1 -a $year -ge 2012 ]; then
mdate=$month/$day/$year
else
notice $month $day $year
notice "Corrupt utag date"
fi
fi
setprop ro.vendor.manufacturedate $mdate
unset fti y m d year month day utag_fti pds_fti fti_utag mdate utag_date
t=$(getprop ro.build.tags)
if [[ "$t" != *release* ]]; then
for p in $(cat /proc/cmdline); do
if [ ${p%%:*} = "@" ]; then
v=${p#@:}; a=${v%=*}; b=${v#*=}
${a%%:*} ${a##*:} $b
fi
done
fi
unset p v a b t
# Cleanup stale/incorrect programmed model value
# Real values will never contain substrings matching "internal" device name
product=$(getprop ro.vendor.hw.device)
model=$(cat /proc/config/model/ascii 2>/dev/null)
if [ $? -eq 0 ]; then
if [ "${model#*_}" == "$product" -o "${model%_*}" == "$product" ]; then
notice "Clearing stale model value"
echo "" > /proc/config/model/raw
fi
fi
unset model product
# Export the RKP csr state which should be done in factory
rkp_complete_file="/mnt/vendor/persist/rkp_complete"
rkp_csr_state="not uploaded"
if [ -f "$rkp_complete_file" ]; then
setprop ro.vendor.mot.hw.rkp_csr_uploaded 1
rkp_csr_state="already uploaded"
else
setprop ro.vendor.mot.hw.rkp_csr_uploaded 0
fi
notice "RKP CSR file on device is: $rkp_csr_state"
unset $rkp_complete_file
unset $rkp_csr_state
get_history_value()
{
local __result=$1
local history_count=0
local value=""
local IFS=','
shift 1
for arg in ${@}; do
value=$value",$arg"
history_count=$(($history_count + 1))
if [ $history_count -eq 3 ]; then
break
fi
done
eval $__result="$value"
debug "value:$value history_count:$history_count"
}
set_boot_bootseq_history()
{
#get current boot sequence
if [ ! -f /proc/bootinfo ]; then
notice "Error:/proc/bootinfo is not ready"
return
fi
boot_seq_line=`grep BOOT_SEQ /proc/bootinfo | sed 's/ //g'`
boot_seq=${boot_seq_line##*:}
notice "BOOT_SEQ is $boot_seq"
setprop ro.vendor.boot_seq $boot_seq
boot_time=`date +%s`
#get previous value of bootseq history
bootseq_history=`getprop persist.vendor.boot.bootseq.history`
notice "booseq_history is $bootseq_history"
get_history_value valid_history_value $bootseq_history
setprop persist.vendor.boot.bootseq.history "$boot_seq.$boot_time$valid_history_value"
new_bootseq_history=`getprop persist.vendor.boot.bootseq.history`
notice "set persist.vendor.boot.bootseq.history $new_bootseq_history"
}
set_boot_bootseq_history

View File

@ -0,0 +1,56 @@
#!/vendor/bin/sh
echo "Retrieve Modem RFS logs"
re='?(-)+([0-9.])'
if ! [[ $2 == $re ]] ; then
echo "error: Not a number" >&2; exit 1
fi
__copy_logs()
{
file1="${1}"
file2="${2}"
if [ ! -f "${file1}" ]; then
echo -e "${file1} invalid"
return
fi
/vendor/bin/chmod 666 "${file1}"
/vendor/bin/cp "${file1}" "${file2}"
/vendor/bin/chmod 640 "${file2}"
}
mdm_rfs_folder=/mnt/vendor/nvdata/md/
mdm_rfs_log0=mot_md_log_0.txt
mdm_rfs_log1=mot_md_log_1.txt
mdm_log_target_folder=/data/vendor/dontpanic
if [ "$1" == "loop" ]; then
loop=1
else
loop=0
fi
while true
do
/vendor/bin/echo "1" > /data/vendor/radio/read_modem_efs
/vendor/bin/sleep 1
/vendor/bin/echo "0" > /data/vendor/radio/read_modem_efs
__copy_logs $mdm_rfs_folder/$mdm_rfs_log0 $mdm_log_target_folder/$mdm_rfs_log0
__copy_logs $mdm_rfs_folder/$mdm_rfs_log1 $mdm_log_target_folder/$mdm_rfs_log1
if [ $loop -eq 1 ]
then
/vendor/bin/sleep $2
else
break
fi
done
exit 0

View File

@ -0,0 +1,10 @@
#!/vendor/bin/sh
# All modules that depend on conditions or need extra parameters
# should go here.
# Handle factory bootmode
bootmode=$(getprop ro.bootmode)
if [ $bootmode = "mot-factory" ]; then
insmod /vendor/lib/modules/moto_f_usbnet.ko
fi

View File

@ -0,0 +1,75 @@
#!/vendor/bin/sh
PATH=/sbin:/vendor/sbin:/vendor/bin:/vendor/xbin
export PATH
scriptname=${0##*/}
debug()
{
echo "$*"
}
notice()
{
echo "$*"
echo "$scriptname: $*" > /dev/kmsg
}
get_history_value()
{
local __result=$1
local history_count=0
local value=""
local IFS=$2
shift 2
for arg in ${@}; do
value=$value"$IFS$arg"
history_count=$(($history_count + 1))
if [ $history_count -eq 3 ]; then
break
fi
done
eval $__result="$value"
debug "value:$value history_count:$history_count"
}
set_reboot_bootseq_history()
{
BOOTSEQ_HISTORY_PROP=persist.vendor.reboot.bootseq.history
#get current boot sequence
if [ ! -f /proc/bootinfo ]; then
notice "Error:/proc/bootinfo is not ready"
return
fi
boot_seq_line=`grep BOOT_SEQ /proc/bootinfo | sed 's/ //g'`
boot_seq=${boot_seq_line##*:}
notice "BOOT_SEQ is $boot_seq"
shutdown_time=`date +%s`
#get previous value of bootseq history
bootseq_history=`getprop $BOOTSEQ_HISTORY_PROP`
debug "booseq_history is $bootseq_history"
get_history_value valid_history_value , $bootseq_history
setprop $BOOTSEQ_HISTORY_PROP "$boot_seq.$shutdown_time$valid_history_value"
new_bootseq_history=`getprop $BOOTSEQ_HISTORY_PROP`
notice "set $BOOTSEQ_HISTORY_PROP $new_bootseq_history"
#update reboot command history
REBOOTCMD_HISTORY_PROP=persist.vendor.reboot.command.history
reboot_cmds=`getprop log.powerctrl.reboot.command`
notice "reboot_cmds is [$reboot_cmds]"
#get previous value of command history
rebootcmd_history=`getprop $REBOOTCMD_HISTORY_PROP`
debug "reboot command history is $rebootcmd_history"
get_history_value valid_cmd_history_value - $rebootcmd_history
setprop $REBOOTCMD_HISTORY_PROP "$boot_seq.$reboot_cmds${valid_cmd_history_value}"
new_bootseq_history=`getprop $REBOOTCMD_HISTORY_PROP`
notice "set $REBOOTCMD_HISTORY_PROP $new_bootseq_history"
}
set_reboot_bootseq_history

View File

@ -0,0 +1,455 @@
#!/vendor/bin/sh
PATH=/sbin:/vendor/sbin:/vendor/bin:/vendor/xbin
export PATH
while getopts ds op;
do
case $op in
d) dbg_on=1;;
s) dump_statistics=1;;
esac
done
shift $(($OPTIND-1))
# Globals
scriptname=${0##*/}
touch_class_path=/sys/class/touchscreen
touch_status_prop=vendor.hw.touch.status
touch_vendor=
touch_path=
panel_path=/sys/class/graphics/fb0
device_property=ro.vendor.hw.device
hwrev_property=ro.vendor.hw.revision
firmware_path=/vendor/firmware
let dec_cfg_id_boot=0
let dec_cfg_id_latest=0
typeset -l product_id
panel_ver=
supplier=
property=
config_id=
build_id=
hwrev_id=
str_cfg_id_new=
str_cfg_id_boot=
str_cfg_id_latest=
build_id_new=
debug()
{
[ $dbg_on ] && echo "Debug: $*"
}
notice()
{
echo "$*"
echo "$scriptname: $*" > /dev/kmsg
}
sanity_check()
{
read_touch_property flashprog || return 1
[[ ( -z "$property" ) || ( "$property" == "1" ) ]] && return 2
read_touch_property productinfo || return 1
[[ ( -z "$property" ) || ( "$property" == "0" ) ]] && return 2
read_touch_property buildid || return 1
config_id=${property#*-}
[[ ( -z "$config_id" ) || ( "$config_id" == "0" ) ]] && return 2
build_id=${property%-*}
[[ ( -z "$build_id" ) || ( "$build_id" == "0" ) ]] && return 2
return 0
}
error_msg()
{
local err_msg
local err_code=$1
case $err_code in
1) err_msg="Error: No response from touch IC";;
2) err_msg="Error: Cannot read property $2";;
3) err_msg="Error: No matching firmware file found";;
4) err_msg="Error: Touch IC is in bootloader mode";;
5) err_msg="Error: Touch provides no reflash interface";;
6) err_msg="Error: Touch driver is not running";;
7) err_msg="Warning: Touch firmware is not the latest";;
8) err_msg="Info: Touch class does not exist";;
9) err_msg="Error: Touch IC is not ready to flash";;
esac
notice "$err_msg"
}
error_and_leave()
{
local err_code=$1
local touch_status="unknown"
error_msg $err_code
case $err_code in
1|4) touch_status="dead";;
5|6|8) touch_status="absent";;
esac
# perform sanity check and declare touch ready if error is not fatal
if [ "$touch_status" == "unknown" ]; then
sanity_check
case "$?" in
0) touch_status="ready";;
2) touch_status="dead";;
1) touch_status="absent";;
esac
fi
# perform recovery if touch is declared dead
if [ "$touch_status" == "dead" ]; then
notice "Touch needs to go through recovery!!!"
reboot_cnt=$(getprop $touch_status_prop 2>/dev/null)
[ -z "$reboot_cnt" ] && reboot_cnt=0
debug "current reboot counter [$reboot_cnt]"
fi
setprop $touch_status_prop $touch_status
notice "property [$touch_status_prop] set to [`getprop $touch_status_prop`]"
if [ "$touch_status" == "dead" ]; then
notice "Touch is not responding; no further action!!!"
#if [ $((reboot_cnt)) -lt 2 ]; then
# notice "Touch is not working; rebooting..."
# debug "sleep 3s to allow touch-dead-sh service to run"
# sleep 3
# [ -z "$dbg_on" ] && setprop sys.powerctl reboot
#else
# notice "Although touch is not working, no more reboots"
#fi
fi
exit $err_code
}
prepend()
{
local list=""
local prefix=$1
shift
for name in $*; do
list="$list$prefix/$name "
done
echo $list
}
dump_statistics()
{
debug "dumping touch statistics"
cat $touch_path/ic_ver
[ -f $touch_path/stats ] && cat $touch_path/stats
return 0
}
wait_for_poweron()
{
local wait_nomore
local readiness
local count
debug "wait until driver reports <ready to flash>..."
wait_nomore=60
count=0
while true; do
readiness=$(cat $touch_path/poweron)
if [ "$readiness" == "1" ]; then
debug "ready to flash!!!"
break;
fi
count=$((count+1))
[ $count -eq $wait_nomore ] && break
sleep 1
debug "not ready; keep waiting..."
done
if [ $count -eq $wait_nomore ]; then
error_msg 9
return 1
fi
return 0
}
setup_permissions()
{
local selinux=$(getprop ro.boot.selinux 2> /dev/null)
local key_path
local key_files
local entry
local product_info
if [ "$selinux" == "permissive" ]; then
debug "loosen permissions to $touch_vendor files"
case $touch_vendor in
synaptics) key_path=$touch_path
key_files=$(prepend f54 `ls $touch_path/f54/ 2>/dev/null`)
key_files=$key_files"reporting query stats";;
focaltech) key_path="/proc/"
key_files="ftxxxx-debug";;
ilitek) key_path="/proc/ilitek"
key_files="ioctl";;
goodix) key_path="/proc/"
key_files="gmnode"
if [ "$touch_product_string" == "GTx5" ]; then
key_path="/dev/"
key_files="gtp_tools"
fi
if [ "$touch_product_string" == "primary" ]; then
product_info=$(cat $touch_class_path/$touch_product_string/productinfo)
debug "$touch_vendor product_info is $product_info"
if [ "$product_info" == "gt9916S" ]; then
key_path="/dev/"
key_files="gtp_tools"
fi
fi
;;
esac
for entry in $key_files; do
chmod 0666 $key_path/$entry
debug "change permissions of $key_path/$entry"
done
fi
# Set permissions to enable factory touch tests
chown root:vendor_tcmd $touch_path/drv_irq
chown root:vendor_tcmd $touch_path/hw_irqstat
chown root:vendor_tcmd $touch_path/reset
# Set permissions to allow Bug2Go access to touch statistics
chown root:log $touch_path/stats
# Erase is optional
[ -f $touch_path/erase_all ] && chown root:vendor_tcmd $touch_path/erase_all
}
read_touch_property()
{
property=""
debug "retrieving property: [$touch_path/$1]"
property=$(cat $touch_path/$1 2> /dev/null)
debug "touch property [$1] is: [$property]"
[ -z "$property" ] && return 1
return 0
}
read_panel_property()
{
property=""
debug "retrieving panel property: [$panel_path/$1]"
property=$(cat $panel_path/$1 2> /dev/null)
debug "panel property [$1] is: [$property]"
[ -z "$property" ] && return 1
return 0
}
find_latest_config_id()
{
local fw_mask=$1
local skip_fields=$2
local dec max z str_hex i
str_cfg_id_latest=""
debug "scanning dir for files matching [$fw_mask]"
let dec=0; max=0;
for file in $(ls $fw_mask 2>/dev/null); do
z=$file
i=0
while [ ! $i -eq $skip_fields ]; do
z=${z#*-}
i=$((i+1))
done
str_hex=${z%%-*};
let dec=0x$str_hex
if [ $dec -gt $max ]; then
let max=$dec; dec_cfg_id_latest=$dec;
str_cfg_id_latest=$str_hex
fi
done
[ -z "$str_cfg_id_latest" ] && return 1
return 0
}
find_best_match()
{
local hw_mask=$1
local panel_supplier=$2
local skip_fields fw_mask
while [ ! -z "$hw_mask" ]; do
if [ "$hw_mask" == "-" ]; then
hw_mask=""
fi
if [ ! -z "$panel_supplier" ]; then
skip_fields=3
fw_mask="$touch_vendor-$panel_supplier-$touch_product_id-*-$product_id$hw_mask.*"
else
skip_fields=2
fw_mask="$touch_vendor-$touch_product_id-*-$product_id$hw_mask.*"
fi
find_latest_config_id "$fw_mask" "$skip_fields" && break
hw_mask=${hw_mask%?}
done
[ -z "$str_cfg_id_latest" ] && return 1
if [ -z "$panel_supplier" ]; then
firmware_file=$(ls $touch_vendor-$touch_product_id-$str_cfg_id_latest-*-$product_id$hw_mask.*)
else
firmware_file=$(ls $touch_vendor-$panel_supplier-$touch_product_id-$str_cfg_id_latest-*-$product_id$hw_mask.*)
fi
notice "Firmware file for upgrade $firmware_file"
return 0
}
query_touch_info()
{
read_touch_property flashprog
bl_mode=$property
debug "bl mode: $bl_mode"
read_touch_property productinfo
touch_product_id=$property
if [ -z "$touch_product_id" ] || [ "$touch_product_id" == "0" ]; then
debug "touch ic reports invalid product id"
error_msg 1
return 1
fi
debug "touch product id: $touch_product_id"
read_touch_property buildid
str_cfg_id_boot=${property#*-}
let dec_cfg_id_boot=0x$str_cfg_id_boot
debug "touch config id: $str_cfg_id_boot"
build_id_boot=${property%-*}
debug "touch build id: $build_id_boot"
return 0
}
query_panel_info()
{
supplier=""
read_touch_property "panel_supplier"
[ -z "$property" ] && read_panel_property "panel_supplier"
supplier=$property
if [ "$supplier" ]; then
read_panel_property "controller_drv_ver"
panel_ver=${property#${property%?}}
debug "panel supplier: $supplier, ver $panel_ver"
else
debug "driver does not report panel supplier"
fi
}
search_firmware_file()
{
local match_not_found
match_not_found=1
if [ "$supplier" ]; then
for pattern in "$supplier$panel_ver" "$supplier"; do
debug "search for best hw revision match with supplier"
find_best_match "-$hwrev_id" "$pattern"
match_not_found=$?
[ "$match_not_found" == "0" ] && break
done
fi
if [ "$match_not_found" != "0" ]; then
debug "search for best hw revision match without supplier"
find_best_match "-$hwrev_id"
if [ "$?" != "0" ]; then
error_msg 3
return 1
fi
fi
return 0
}
run_firmware_upgrade()
{
local recovery
wait_for_poweron
recovery=0
if [ "$bl_mode" == "1" ] || [ "$build_id_boot" == "0" ]; then
recovery=1
notice "Initiating touch firmware recovery"
notice " bl mode = $bl_mode"
notice " build id = $build_id_boot"
fi
if [ $dec_cfg_id_boot -ne $dec_cfg_id_latest ] || [ "$recovery" == "1" ]; then
debug "forcing firmware upgrade"
echo 1 > $touch_path/forcereflash
debug "sending reflash command"
echo $firmware_file > $touch_path/doreflash
read_touch_property flashprog
if [ "$?" != "0" ]; then
error_msg 1
return 1
fi
bl_mode=$property
if [ "$bl_mode" == "1" ]; then
error_msg 4
return 1
fi
read_touch_property buildid
if [ "$?" != "0" ]; then
error_msg 1
return 1
fi
str_cfg_id_new=${property#*-}
build_id_new=${property%-*}
notice "Touch firmware config id at boot time $str_cfg_id_boot"
notice "Touch firmware config id in the file $str_cfg_id_latest"
notice "Touch firmware config id currently programmed $str_cfg_id_new"
[ "$str_cfg_id_latest" != "$str_cfg_id_new" ] && error_msg 7 && return 1
if [ -f $touch_path/f54/force_update ]; then
notice "forcing F54 registers update"
echo 1 > $touch_path/f54/force_update
fi
fi
return 0
}
process_touch_instance()
{
notice "Handling touch ID [$touch_product_string] permissions"
touch_vendor=$(cat $touch_class_path/$touch_product_string/vendor)
debug "touch vendor [$touch_vendor]"
touch_path=/sys$(cat $touch_class_path/$touch_product_string/path)
debug "sysfs touch path: $touch_path"
if [ ! -f $touch_path/doreflash ] ||
[ ! -f $touch_path/poweron ] ||
[ ! -f $touch_path/flashprog ] ||
[ ! -f $touch_path/productinfo ] ||
[ ! -f $touch_path/buildid ]; then
error_msg 5
continue
fi
setup_permissions
if [ $dump_statistics ]; then
dump_statistics
fi
notice "Checking touch ID [$touch_product_string] FW upgrade"
touch_vendor=$(cat $touch_class_path/$touch_product_string/vendor)
debug "touch vendor [$touch_vendor]"
touch_path=/sys$(cat $touch_class_path/$touch_product_string/path)
debug "sysfs touch path: $touch_path"
query_touch_info
query_panel_info
search_firmware_file
[ "$?" == "0" ] && run_firmware_upgrade
notice "Touch firmware is up to date"
setprop $touch_status_prop "ready"
notice "property [$touch_status_prop] set to [`getprop $touch_status_prop`]"
}
# Main starts here
[ -d $touch_class_path ] || error_and_leave 8
debug "sysfs panel path: $panel_path"
product_id=$(getprop $device_property 2> /dev/null)
[ -z "$product_id" ] && error_and_leave 2 $device_property
product_id=${product_id%-*}
product_id=${product_id%_*}
debug "product id: $product_id"
hwrev_id=$(getprop $hwrev_property 2> /dev/null)
[ -z "$hwrev_id" ] && notice "hw revision undefined"
debug "hw revision: $hwrev_id"
cd $firmware_path
# Run asynchronously for each instance
for touch_product_string in $(ls $touch_class_path); do
process_touch_instance &
done
# check if need to reload modules
wait
debug "all background processes completed"
return 0

260
rootdir/bin/init.mmi.usb.sh Normal file
View File

@ -0,0 +1,260 @@
#!/vendor/bin/sh
# Copyright (c) 2012, Code Aurora Forum. 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 Code Aurora Forum, Inc. 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 "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.
#
#
# Allow unique persistent serial numbers for devices connected via usb
# User needs to set unique usb serial number to persist.usb.serialno and
# if persistent serial number is not set then Update USB serial number if
# passed from command line
#
dbg_on=0
debug()
{
echo "${0##*/}: $*"
[ $dbg_on ] && echo "${0##*/}: $*" > /dev/kmsg
}
notice()
{
echo "${0##*/}: $*"
echo "${0##*/}: $*" > /dev/kmsg
}
target=`getprop ro.board.platform`
usb_action=`getprop vendor.usb.mmi-usb-sh.action`
notice "mmi-usb-sh: action = \"$usb_action\""
sys_usb_config=`getprop vendor.usb.config`
bootmode=`getprop ro.bootmode`
#factory cleanup
factory_cfg=`getprop persist.vendor.usb.mot-factory.config`
if [ "$bootmode" == "normal" ]; then
if [[ "$factory_cfg" == *adb* ]]; then
setprop persist.vendor.usb.mot-factory.config NULL
setprop persist.vendor.usb.mot-factory.func NULL
setprop persist.vendor.usb.config NULL
setprop persist.vendor.mot.usb.config NULL
setprop vendor.usb.config none
notice "cleanup factory flg done"
fi
fi
set_usb_secure_mode ()
{
if [ "$#" == "1" ]
then
if [ -f /sys/class/android_usb/android0/secure ]
then
echo "$1" > /sys/class/android_usb/android0/secure
else
setprop vendor.usb.secure_mode $1
fi
notice "mmi-usb-sh: secure mode = $1"
fi
}
tcmd_ctrl_adb ()
{
ctrl_adb=`getprop vendor.tcmd.ctrl_adb`
notice "mmi-usb-sh: vendor.tcmd.ctrl_adb = $ctrl_adb"
case "$ctrl_adb" in
"0")
if [[ "$sys_usb_config" == *adb* ]]
then
# *** ALWAYS expecting adb at the end ***
new_usb_config=${sys_usb_config/,adb/}
notice "mmi-usb-sh: disabling adb ($new_usb_config)"
setprop persist.vendor.usb.config $new_usb_config
setprop vendor.usb.config $new_usb_config
setprop persist.vendor.factory.allow_adb 0
fi
;;
"1")
if [[ "$sys_usb_config" != *adb* ]]
then
# *** ALWAYS expecting adb at the end ***
new_usb_config="$sys_usb_config,adb"
notice "mmi-usb-sh: enabling adb ($new_usb_config)"
setprop persist.vendor.usb.config $new_usb_config
setprop vendor.usb.config $new_usb_config
setprop persist.vendor.factory.allow_adb 1
fi
;;
esac
exit 0
}
case "$usb_action" in
"")
;;
"vendor.tcmd.ctrl_adb")
tcmd_ctrl_adb
;;
esac
case "$target" in
"mt6879")
setprop vendor.usb.controller "11201000.usb0"
setprop vendor.usb.rndis.func.name mtk_rndis.gs4
;;
"mt6789")
setprop vendor.usb.controller "musb-hdrc"
setprop vendor.usb.rndis.func.name mtk_rndis.gs4
;;
"mt6855")
setprop vendor.usb.controller "musb-hdrc"
setprop vendor.usb.rndis.func.name mtk_rndis.gs4
;;
esac
## This is needed to switch to the qcom rndis driver.
diag_extra=`getprop persist.vendor.usb.config.extra`
if [ "$diag_extra" == "" ]; then
setprop persist.vendor.usb.config.extra none
fi
#
# Allow USB enumeration with default PID/VID
#
usb_config=`getprop persist.vendor.usb.config`
mot_usb_config=`getprop persist.vendor.mot.usb.config`
buildtype=`getprop ro.build.type`
securehw=`getprop ro.boot.secure_hardware`
cid=`getprop ro.vendor.boot.cid`
notice "mmi-usb-sh: persist usb configs = \"$usb_config\", \"$mot_usb_config\""
phonelock_type=`getprop persist.sys.phonelock.mode`
usb_restricted=`getprop persist.sys.usb.policylocked`
if [ "$securehw" == "1" ] && [ "$buildtype" == "user" ] && [ "$(($cid))" != 0 ]
then
if [ "$usb_restricted" == "1" ]
then
set_usb_secure_mode 1
else
case "$phonelock_type" in
"1" )
set_usb_secure_mode 1
;;
* )
set_usb_secure_mode 0
;;
esac
fi
fi
case "$bootmode" in
"mot-factory" )
if [ "$usb_config" != "adb" ]
then
setprop persist.vendor.usb.config adb
setprop persist.vendor.usb.mot-factory.config adb
setprop persist.vendor.usb.mot-factory.func adb
fi
;;
"charger" )
;;
* )
if [ "$buildtype" == "user" ] && [ "$phonelock_type" != "1" ] && [ "$usb_restricted" != "1" ]
then
set_usb_secure_mode 1
notice "Disabling enumeration until bootup!"
fi
case "$usb_config" in
"mtp,adb" | "mtp" | "adb")
;;
*)
case "$mot_usb_config" in
"mtp,adb" | "mtp" | "adb")
setprop persist.vendor.usb.config $mot_usb_config
;;
*)
case "$securehw" in
"1" )
setprop persist.vendor.usb.config mtp
;;
*)
setprop persist.vendor.usb.config adb
;;
esac
;;
esac
;;
esac
adb_early=`getprop ro.boot.adb_early`
if [ "$adb_early" == "1" ]; then
set_usb_secure_mode 0
notice "Enabling enumeration after bootup, count = $count !"
new_persist_usb_config=`getprop persist.vendor.usb.config`
if [[ "$new_persist_usb_config" != *adb* ]]; then
setprop persist.vendor.usb.config "adb"
setprop vendor.usb.config "adb"
else
setprop vendor.usb.config $new_persist_usb_config
fi
exit 0
fi
if [ "$buildtype" == "user" ] && [ "$phonelock_type" != "1" ] && [ "$usb_restricted" != "1" ]
then
if [[ "$factory_cfg" == *adb* ]]; then
new_persist_usb_config=`getprop persist.vendor.usb.config`
if [ "$sys_usb_config" != "$new_persist_usb_config" ]; then
setprop vendor.usb.config $new_persist_usb_config
notice "mmi-usb-sh - factory to normal, reset the vendor usb config"
fi
fi
count=0
bootcomplete=`getprop vendor.boot_completed`
notice "mmi-usb-sh - bootcomplete = $booted"
while [ "$bootcomplete" != "1" ]; do
debug "Sleeping till bootup!"
sleep 1
count=$((count+1))
if [ $count -gt 90 ]
then
notice "mmi-usb-sh - Timed out waiting for bootup"
break
fi
bootcomplete=`getprop vendor.boot_completed`
done
set_usb_secure_mode 0
notice "Enabling enumeration after bootup, count = $count !"
exit 0
fi
;;
esac
new_persist_usb_config=`getprop persist.vendor.usb.config`
if [ "$sys_usb_config" != "$new_persist_usb_config" ]; then
setprop vendor.usb.config $new_persist_usb_config
fi

View File

@ -0,0 +1,178 @@
#!/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=('goodix' 'chipone')
kernel_so_list=("/vendor/lib/modules/$GKI_PATH/goodix_fps_tee.ko" "/vendor/lib/modules/$GKI_PATH/fpsensor_mtk_spi.ko")
kernel_so_name_list=("goodix_fps_tee.ko" "fpsensor_mtk_spi.ko")
hal_list=('goodix_hal' 'chipone_fp_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=30
# 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]}
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

742
rootdir/bin/init.oem.hw.sh Normal file
View File

@ -0,0 +1,742 @@
#!/vendor/bin/sh
BASEDIR=vendor
PATH=/sbin:/$BASEDIR/sbin:/$BASEDIR/bin:/$BASEDIR/xbin
export PATH
while getopts dpfrM op;
do
case $op in
d) dbg_on=1;;
p) populate_only=1;;
f) dead_touch=1;;
r) reset_touch=1;;
M) mount_2nd_stage=1;;
esac
done
shift $(($OPTIND-1))
scriptname=${0##*/}
hw_mp=/proc/hw
config_mp=/proc/config
reboot_utag=$config_mp/.reboot
touch_status_prop=vendor.hw.touch.status
hw_cfg_file=hw_config.xml
vhw_file=/$BASEDIR/etc/vhw.xml
bp_file=/system/build.prop
oem_file=/oem/oem.prop
load_error=3
need_to_reload=2
reload_in_progress=1
reload_done=0
ver_utag=".version"
version_fs="unknown"
xml_version="unknown"
device_params=""
xml_file=""
utag_update_fail="false"
modem_ver_prop=ro.vendor.hw.modem_version
policy_prop=ro.vendor.super_image_policy
super_image_detection()
{
local subsys
local file2mount
local basefile
local version
local extention
local image_dir
local is_super_image
local super_image_prop
local file_mount_prop
local modem_version=$(getprop $modem_ver_prop)
local policy=$(getprop $policy_prop)
debug "'$policy_prop' is '$policy'"
for subsys in modem fsg; do
debug "Processing [${subsys}]..."
is_super_image=""
case ${subsys} in
modem) image_dir=/vendor/firmware_mnt;;
fsg) image_dir=/vendor/fsg;;
esac
[ -f $image_dir/super_modem ] && is_super_image="true"
debug "super image '$is_super_image'"
if [ "$is_super_image" == "true" ]; then
file2mount=""
case ${subsys} in
modem) super_image_prop="ro.vendor.hw.modem_super_image"
file_mount_prop="ro.vendor.hw.modem_mount_file"
basefile="NON-HLOS.bin"
extention=".bin"
[ "$modem_version" ] && file2mount=$(printf "NON-HLOS%sbin" $modem_version)
;;
fsg) super_image_prop="ro.vendor.hw.fsg_super_image"
file_mount_prop="ro.vendor.hw.fsg_mount_file"
basefile="fsg.mbn"
extention=".mbn"
[ "$modem_version" ] && file2mount=$(printf "fsg%smbn" $modem_version)
;;
esac
if [ -z "$file2mount" ]; then
notice "'$modem_ver_prop' not set, but [$subsys] is super image!"
else
# modem_version matches existing file in super image
if [ -f $image_dir/$file2mount ]; then
notice "[$subsys] is super image. '$file2mount' will be mounted"
setprop $file_mount_prop $file2mount
setprop $super_image_prop yes
continue
fi
notice "[$subsys] is super image. '$file2mount' not found"
fi
else
notice "[$subsys] non-super image"
fi
# check super image policy
if [ "$policy" == "enforce" ]; then
notice "[$subsys] strict super image policy! Rebooting to recovery..."
debug "'ro.vendor.hw.super_image_failure' -> 'yes'"
setprop ro.vendor.hw.super_image_failure yes
return
fi
notice "[$subsys] super image policy not enforced"
# proceed with non-super image if policy allows
if [ -z "$is_super_image" ]; then
notice "[$subsys] proceed with non-super image!"
continue
fi
# retrieve default version if available
version=$(cat $image_dir/super_modem)
if [ "$version" ]; then
basefile=$version
notice "default file override '$basefile'"
else
notice "use default file: '$basefile' instead of '$file2mount'"
fi
notice "Searching for '$basefile' in $image_dir..."
debug "checking file '$image_dir/$basefile'"
if [ -f $image_dir/$basefile ]; then
notice "[$subsys] is super image! '$basefile' will be mounted"
debug "'$file_mount_prop' -> '$basefile'"
setprop $file_mount_prop $basefile
debug "'$super_image_prop' -> 'yes'"
setprop $super_image_prop yes
continue
fi
# set to fail
notice "Unable to mount '$basefile'! Rebooting to recovery..."
debug "'ro.vendor.hw.super_image_failure' -> 'yes'"
setprop ro.vendor.hw.super_image_failure yes
return
done
}
set_reboot_counter()
{
local value=$1
local reboot_cnt=0
local reboot_mp=${reboot_utag%.*}
local tag_name=${reboot_utag##*/}
if [ $((value)) -gt 0 ]; then
notice "increase reboot counter"
[ -d $reboot_utag ] && reboot_cnt=$(cat $reboot_utag/ascii)
value=$(($reboot_cnt + 1))
fi
if [ ! -d $reboot_utag ]; then
echo ${reboot_utag##*/} > $reboot_mp/all/new
[ $? != 0 ] && notice "error creating UTAG $tag_name"
fi
echo "$value" > $reboot_utag/ascii
[ $? != 0 ] && notice "error updating UTAG $tag_name"
notice "UTAG $tag_name is [`cat $reboot_utag/ascii`]"
}
set_reboot_counter_property()
{
local reboot_cnt=0
local tag_name=${reboot_utag##*/}
if [ -d $reboot_utag ]; then
reboot_cnt=$(cat $reboot_utag/ascii)
notice "UTAG $tag_name has value [$reboot_cnt]"
else
notice "UTAG $tag_name does not exist"
fi
setprop $touch_status_prop $reboot_cnt
notice "property [$touch_status_prop] is set to [`getprop $touch_status_prop`]"
}
debug()
{
[ $dbg_on ] && echo "Debug: $*"
}
notice()
{
echo "$*"
echo "$scriptname: $*" > /dev/kmsg
}
add_device_params()
{
device_params=$device_params" $@"
debug "add_device_params='$device_params'"
}
drop_device_parameter()
{
device_params=${device_params% *}
debug "drop_device_parameter='$device_params'"
}
set_xml_file()
{
xml_file=$@
debug "working with XML file='$xml_file'"
}
exec_parser()
{
eval motobox expat -u -f $xml_file $device_params "$@" 2>/dev/null
}
reload_utags()
{
local mp=$1
local value
echo "1" > $mp/reload
value=$(cat $mp/reload)
while [ "$value" == "$reload_in_progress" ]; do
notice "waiting for loading to complete"
sleep 1;
value=$(cat $mp/reload)
notice "'$mp' current status [$value]"
done
}
procfs_wait_for_device()
{
local __result=$1
local status
local mpi
local IFS=' '
local device_timeout_count=0
while [ ! -f $hw_mp/reload ] || [ ! -f $config_mp/reload ]; do
notice "waiting for devices"
sleep 1;
if [ "$device_timeout_count" -eq "10" ];then
notice "waiting for devices timeout"
eval $__result=""
return
fi
device_timeout_count=$(($device_timeout_count + 1))
done
for mpi in $hw_mp $config_mp; do
status=$(cat $mpi/reload)
notice "mount point '$mpi' status [$status]"
if [ "$status" == "$need_to_reload" ]; then
notice "force $mpi reloading"
reload_utags $mpi
fi
done
for mpi in $hw_mp $config_mp; do
status=$(cat $mpi/reload)
notice "$mpi reload is [$status]"
device_timeout_count=0
while [ "$status" != "$reload_done" ]; do
notice "waiting for loading $mpi to complete"
sleep 1;
status=$(cat $mpi/reload)
if [ "$device_timeout_count" -eq "10" ]; then
notice "error: waiting for loading $mpi timeout"
break
fi
device_timeout_count=$(($device_timeout_count + 1))
done
done
eval $__result=$status
}
get_attr_data_by_name()
{
local __result=$1
local attr=$2
shift 2
local IFS=' '
eval $__result=""
for arg in ${@}; do
[ "${arg%=*}" == "$attr" ] || continue
debug "attr_data='${arg#*=}'"
eval $__result="${arg#*=}"
break
done
}
get_tag_data()
{
local __name=$1
local __value=$2
shift 2
local dataval
local IFS=' '
eval $__name=""
eval $__value=""
for arg in ${@}; do
case $arg in
string-array | string)
debug "---/ skip keyword: '$arg'"
continue;;
esac
debug "---> arg='$arg'"
if [ "${arg%=*}" == "name" ]; then
eval $__name=${arg#*=}
continue
fi
# eval treats ';' as a separator, thus make it '\;'
dataval=$(echo ${arg#?} | sed 's/;/\\;/g')
debug "<--- dataval='$dataval'"
eval $__value=$dataval
done
}
update_utag()
{
local utag=$1
local payload=$2
local verify
local rc
if [ ! -d $hw_mp/$utag ]; then
notice "creating utag '$utag'"
echo $utag > $hw_mp/all/new
rc=$?
[ "$rc" != "0" ] && notice "'$utag' create dir failed rc=$rc"
fi
debug "writing '$payload' to '$hw_mp/$utag/ascii'"
echo "$payload" > $hw_mp/$utag/ascii
rc=$?
if [ "$rc" != "0" ]; then
utag_update_fail="true"
notice "'$utag' write file failed rc=$rc"
fi
verify=$(cat $hw_mp/$utag/ascii)
debug "read '$verify' from '$hw_mp/$utag/ascii'"
[ "$verify" != "$payload" ] && notice "'$utag' payload validation failed"
}
populate_utags()
{
local selection="$@"
local pline
local ptag
local pvalue
for pline in $(exec_parser $selection); do
get_tag_data ptag pvalue $pline
url_style_off pvalue $pvalue
debug "tag='$ptag' value='$pvalue'"
update_utag $ptag $pvalue
done
}
set_ro_hw_properties_upgrade()
{
local utag_path
local utag_name
local prop_prefix
local utag_value
local verify
for hwtag in $(find $hw_mp -name '.system'); do
debug "path $hwtag has '.system' in its name"
prop_prefix="ro.vendor.hw."
utag_path=${hwtag%/*}
utag_name=${utag_path##*/}
utag_value=$(cat $utag_path/ascii)
setprop $prop_prefix$utag_name "$utag_value"
notice "ro.vendor.hw.$utag_name='$utag_value'"
done
}
set_ro_hw_property()
{
local hwtag=$1
local utag_path
local utag_name
local prop_prefix
local utag_value
local verify
debug "path $hwtag has '.system' in its name"
prop_prefix=$(cat $hwtag/ascii)
verify=${prop_prefix%.}
# esure property ends with '.'
if [ "$prop_prefix" == "$verify" ]; then
prop_prefix="$prop_prefix."
debug "added '.' at the end of [$prop_prefix]"
fi
utag_path=${hwtag%/*}
utag_name=${utag_path##*/}
utag_value=$(cat $utag_path/ascii)
setprop $prop_prefix$utag_name "$utag_value"
notice "$prop_prefix$utag_name='$utag_value'"
}
set_ro_hw_properties()
{
for hwtag in $(find $hw_mp -name '.system'); do
set_ro_hw_property $hwtag &
done
}
set_ro_vendor_incremental()
{
local vendor_incremental="ro.vendor.build.version.incremental"
local vendor_incremental_value
local fetch_prop="ro.build.version.incremental"
local fetch_value=$(getprop $fetch_prop)
[ -z "$fetch_value" ] && prefetch_from_file $fetch_prop vendor_incremental_value
setprop $vendor_incremental "$vendor_incremental_value"
notice "$vendor_incremental='$vendor_incremental_value'"
}
smart_value()
{
local mtag=$1
local __result=$2
local value
eval $__result=""
local tmp=${mtag#?}
# absolute path to the file starts with '/'
if [ "${mtag%$tmp}" == "/" ]; then
value=$(cat $mtag)
# property likely to have '.'
elif [ "$mtag" != "${mtag%.*}" ]; then
value=$(getprop $mtag)
else # tag otherwise
value=$(cat $hw_mp/$mtag/ascii)
fi
eval $__result='$value'
}
url_style_off()
{
local __arg=$1
local value=$2
if [[ $value == *%* ]]; then
value=$(echo ${value//%20/ })
value=$(echo ${value//%28/\(})
value=$(echo ${value//%29/\)})
fi
eval $__arg='$value'
}
match()
{
local mapping
local mline
local mtag
local fs_value
local mvalue
local matched
url_style_off mapping $1
debug "match mapping='$mapping'"
# put '\"' around $mapping to ensure XML
# parser takes it as a single argument
for mline in $(exec_parser \"$mapping\"); do
get_tag_data mtag mvalue $mline
url_style_off mvalue $mvalue
# obtain value based on data source: utag, property or file
smart_value $mtag fs_value
if [ "$fs_value" == "$mvalue" ]; then
matched="true";
else
matched="false";
fi
debug "cmp utag='$mtag' values '$mvalue' & '$fs_value' is \"$matched\""
[ "$matched" == "false" ] && break
done
[ "$matched" == "true" ] && return 0
return 1
}
find_match()
{
local __retval=$1
local tag_name
local fline
local line
local subsection
local matched="false"
eval $__retval=""
for fline in $(exec_parser); do
subsection=${fline%% *}
add_device_params $subsection
for line in $(exec_parser); do
get_attr_data_by_name tag_name "name" $line
debug "tag_name='$tag_name'"
match $tag_name
[ "$?" != "0" ] && continue
eval $__retval=$tag_name
matched="true"
break
done
drop_device_parameter
[ "$matched" == "true" ] && break
done
}
prefetch_from_file()
{
local pname=$1
local __result=$2
local value
local override
eval $__result=""
value=$(cat $bp_file 2>/dev/null | sed '/^$/d' | sed '/^#/d' | sed '/^import/d' | sed -n "/$pname=/p" | sed 's/.*=//')
debug "'$pname' from '$bp_file': '$value'"
if [ -f $oem_file ]; then
override=$(cat $oem_file 2>/dev/null | sed '/^$/d' | sed '/^#/d' | sed '/^import/d' | sed -n "/$pname=/p" | sed 's/.*=//')
[ "$override" ] && value=$override && debug "'$pname' from '$oem_file': '$value'"
fi
eval $__result=$value
}
append_match()
{
local prop_list=$1
local suffix="$2"
local dest_prop
local fetched_prop
local prop_value
local IFS=','
# properties list to put the result of appending hw suffix to
# example: appended="ro.vendor.product.name,ro.vendor.product.device"
for dest_prop in $prop_list; do
fetch_prop=${dest_prop}
# only alter property name that has "vendor" in it
if [ "${fetch_prop//.vendor}" != "$dest_prop" ]; then
fetch_prop=${fetch_prop//.vendor}
prop_value=$(getprop $fetch_prop)
[ -z "$prop_value" ] && prefetch_from_file $fetch_prop prop_value
# finally set destination property to appended value
setprop $dest_prop "$prop_value$suffix"
notice "$dest_prop='$prop_value$suffix'"
fi
done
}
process_mappings()
{
local pname=""
local pexport=""
local pdefault=""
local pappend=""
local putag=""
local subsection
local pline
local matched_val
local whitespace_val
local export_val
local utag_val
for pline in $(exec_parser); do
subsection=${pline%% *}
debug "subsection is '$subsection'"
get_attr_data_by_name pname "name" $pline
get_attr_data_by_name pexport "export" $pline
get_attr_data_by_name pdefault "default" $pline
get_attr_data_by_name pappend "append" $pline
get_attr_data_by_name putag "writeback" $pline
[ "$pname" ] && url_style_off pname $pname && debug "name='$pname'"
[ "$pexport" ] && url_style_off pexport $pexport && debug "export='$pexport'"
[ "$pdefault" ] && url_style_off pdefault $pdefault && debug "default='$pdefault'"
[ "$pappend" ] && url_style_off pappend $pappend && debug "append='$pappend'"
# add 'subsection' to permanent parameters
add_device_params $subsection
# call itself here to handle nonamed subsection, like quirks
[ -z "$pname" ] && [ -z "$pexport" ] && [ -z "$pdefault" ] && [ -z "$pappend" ] && [ -z "$putag" ] && process_mappings && continue
find_match matched_val
[ "$matched_val" ] && url_style_off matched_val $matched_val
# append_match handles OEM overrides, thus has to be called even with empty value
[ "$pappend" ] && append_match $pappend "$matched_val"
if [ "$matched_val" ]; then
if [ "$pexport" ]; then
setprop $pexport "$matched_val"
notice "exporting '$matched_val' into property $pexport"
fi
elif [ "$pexport" -a "$pdefault" ]; then
# if match is not found, proceed with default
setprop $pexport "$pdefault"
notice "defaulting '$pdefault' into property $pexport"
fi
if [ "$putag" ] && [ -d $hw_mp/$putag ]; then
export_val=$(getprop $pexport)
utag_val=$(cat $hw_mp/$putag/ascii)
debug "writeback compare $utag_val,$export_val"
# if property is empty value, clear the utag.
# if property and writeback utag are empty value, don't update utag
if [ "$export_val" -o "$utag_val" != "(null)" ] && [ "$utag_val" != "$export_val" ]; then
update_utag $putag $export_val
notice "writeback '$export_val' into utag $putag"
fi
fi
# remove the last added parameter
drop_device_parameter
done
}
# Main starts here
IFS=$'\n'
if [ ! -z "$mount_2nd_stage" ]; then
notice "Super image detection"
super_image_detection
return 0
fi
if [ ! -z "$reset_touch" ]; then
notice "reset reboot counter"
set_reboot_counter 0
return 0
fi
if [ ! -z "$dead_touch" ]; then
notice "property [$touch_status_prop] set to [dead]"
set_reboot_counter 1
return 0
fi
if [ -f /vendor/lib/modules/utags.ko ]; then
notice "loading utag driver"
insmod /vendor/lib/modules/utags.ko
if [ $? -ne 0 ]; then
gki_modules_full_path=`find /vendor/lib/modules -name "*-gki"`
if [ -n "$gki_modules_full_path" ]; then
gki_modules_path=`basename $gki_modules_full_path`
notice "loading gki utag driver in /vendor/lib/modules/$gki_modules_path"
insmod /vendor/lib/modules/$gki_modules_path/utags.ko
if [ $? -ne 0 ]; then
notice "fail to load /vendor/lib/modules/$gki_modules_path/utags.ko"
setprop ro.vendor.mot.gki.path "."
else
notice "successfully load /vendor/lib/modules/$gki_modules_path/utags.ko"
setprop ro.vendor.mot.gki.path $gki_modules_path
fi
else
notice "fail to load utag driver"
setprop ro.vendor.mot.gki.path "."
fi
else
setprop ro.vendor.mot.gki.path "."
fi
fi
notice "checking integrity"
# check necessary components exist and just proceed
# with RO properties setup otherwise
if [ ! -f /$BASEDIR/bin/expat ] || [ ! -f $vhw_file ]; then
notice "warning: missing expat or xml"
set_ro_hw_properties
return 0
fi
if [ ! -z "$populate_only" ]; then
# special handling for factory UTAGs provisioning
for path in /data/local/tmp /pds/factory; do
[ -f $path/$hw_cfg_file ] && break
done
notice "populating hw config from '$path/$hw_cfg_file'"
set_xml_file $path/$hw_cfg_file
populate_utags hardware
return 0
fi
notice "initializing procfs"
procfs_wait_for_device readiness
if [ "$readiness" != "0" ]; then
notice "no access to hw utags procfs"
return 1
fi
# populate touch status property with reboot counter
set_reboot_counter_property &
# XML parsing starts here
set_xml_file $vhw_file
get_attr_data_by_name boot_device_prop "match" $(exec_parser)
debug "attr='get' value='$boot_device_prop'"
if [ -z $boot_device_prop ]; then
notice "fatal: undefined boot device property"
return 1
fi
# ensure lower case
typeset -l boot_device=$(getprop $boot_device_prop)
# drop suffixes
boot_device=${boot_device%[_-]*}
notice "matching to boot device '$boot_device'"
# add 'validation' to permanent parameters
add_device_params validation
for line in $(exec_parser); do
get_attr_data_by_name product "name" $line
debug "attr='name' value='$product'"
if [ "$product" == "$boot_device" ]; then
get_attr_data_by_name xml_version "version" $line
[ "$xml_version" != "unknown" ] && notice "device '$boot_device' xml version='$xml_version'"
break
fi
done
[ "$xml_version" == "unknown" ] && notice "no match found for device '$boot_device'"
# delete obsolete 'version' utag if exists
[ -d $hw_mp/${ver_utag#?} ] && $(echo ${ver_utag#?} > $hw_mp/all/delete)
# read procfs version
[ -d $hw_mp/$ver_utag ] && version_fs=$(cat $hw_mp/$ver_utag/ascii)
notice "procfs version='$version_fs'"
# add 'device' and '$boot_device' to permanent parameters
add_device_params device $boot_device
[ "$xml_version" == "$version_fs" ] && notice "hw descriptor is up to date"
for section in $(exec_parser); do
debug "section='$section'"
case $section in
mappings)
# add 'mappings' to permanent parameters
add_device_params $section
process_mappings &
;;
*)
[ "$xml_version" == "$version_fs" ] && continue
populate_utags $section;;
esac
done
if [ "$xml_version" != "$version_fs" ]; then
# create version utag if it's missing
[ ! -d $hw_mp/$ver_utag ] && $(echo "$ver_utag" > $hw_mp/all/new)
# update procfs version
[ -d $hw_mp/$ver_utag ] && $(echo "$xml_version" > $hw_mp/$ver_utag/ascii)
fi
set_ro_vendor_incremental &
set_ro_hw_properties
if [ "$utag_update_fail" == "true" ]; then
set_ro_hw_properties_upgrade
fi
wait
notice "script init.oem.hw.sh finish "
return 0

View File

@ -0,0 +1,36 @@
#!/vendor/bin/sh
#
# Copyright (c) 2016, Motorola Mobility LLC, All rights reserved.
#
# The purpose of this script is to annotate panic dumps with useful information
# about the context of the event.
#
export PATH=/vendor/bin:$PATH
annotate()
{
VAL=`$2`
[ "$VAL" ] || return
if [ -e /sys/fs/pstore/annotate-ramoops-0 ] ; then
echo "$1: $VAL" > /sys/fs/pstore/annotate-ramoops-0
fi
if [ -e /proc/driver/mmi_annotate ] ; then
echo "$1: $VAL" > /proc/driver/mmi_annotate
fi
}
case $1 in
build*)
annotate "Boot mode" "getprop ro.boot.mode"
annotate "Console" "getprop ro.boot.console"
annotate "Secure hardware" "getprop ro.boot.secure_hardware"
annotate "Hab cid" "getprop ro.boot.hab.cid"
annotate "VB state" "getprop ro.boot.verifiedbootstate"
annotate "Verity mode" "getprop ro.boot.veritymode"
annotate "HW cid" "getprop ro.boot.cid"
annotate "SW cid" "getprop ro.boot.cid_sw"
annotate "Apdp state" "getprop ro.boot.device_apdp_state"
;;
esac

View File

@ -0,0 +1,69 @@
#!/vendor/bin/sh
# Copyright (c) 2021, Motorola Mobility LLC, All Rights Reserved.
#
# Date Created: 8/30/2021, Set CXP properties according to carrier channel
#
set_properties()
{
# do not set SPB ID for M80 modem
if [ $set_sbp_place ] && [ $set_sbp_place -ge 2 ]; then
sbp=0
fi
setprop ro.vendor.mtk_md_sbp_custom_value $sbp
setprop ro.vendor.operator.optr $1
setprop ro.vendor.operator.spec $2
setprop ro.vendor.operator.seg $3
if [ ! $optr ]; then
setprop persist.vendor.mtk_usp_md_sbp_code $sbp
setprop persist.vendor.operator.optr $1
setprop persist.vendor.operator.spec $2
setprop persist.vendor.operator.seg $3
fi
}
boot_carrier=`getprop ro.boot.carrier`
optr=`getprop persist.vendor.operator.optr`
set_sbp_place=`getprop ro.vendor.ril.set_sbp_place`
case $boot_carrier in
att|attpre )
sbp=7
set_properties OP07 SPEC0407 SEGDEFAULT
;;
cricket )
sbp=145
set_properties OP07 SPEC0407 SEGDEFAULT
;;
tmo|boost|cc|fi|metropcs|tracfone|retus )
sbp=8
set_properties OP08 SPEC0200 SEGDEFAULT
;;
usc )
sbp=236
set_properties OP236 SPEC0200 SEGDEFAULT
;;
vzw|vzwpre|comcast|spectrum )
sbp=12
set_properties OP12 SPEC0200 SEGDEFAULT
;;
ctcn )
sbp=9
setprop ro.vendor.mtk_md_sbp_custom_value 0
set_properties OP09 SPEC0212 SEGC
;;
cmcc )
sbp=1
setprop ro.vendor.mtk_md_sbp_custom_value 1
set_properties OP01 SPEC0200 SEGC
;;
* )
sbp=0
set_properties "" "" ""
;;
esac
return 0