Add permission handling with ueventd Add selinux context to system_ext/etc/selinux/system_ext_file_contexts Remove init changes and boot image patching Only initialize the keyboard once on boot with a non-standard name Standard names are f[1-9] we use fhid
70 lines
2.0 KiB
Bash
70 lines
2.0 KiB
Bash
#!/system/bin/sh
|
|
# $1 setup
|
|
controller=$(getprop sys.usb.controller)
|
|
moddir=[MODDIR]
|
|
|
|
exec >>$moddir/ghid.log
|
|
exec 2>>$moddir/ghid.log
|
|
date
|
|
set -o xtrace
|
|
set -o nohup
|
|
set +o errexit
|
|
set +o sh
|
|
set +o posix
|
|
exec >>$moddir/oghid.log
|
|
exec 2>>$moddir/oghid.log
|
|
|
|
remove_ghid() {
|
|
echo "disabling ghid"
|
|
rm /config/usb_gadget/g1/configs/b.1/fhid
|
|
rmdir /config/usb_gadget/g1/functions/hid.usb0
|
|
}
|
|
|
|
enable_ghid() {
|
|
. "$moddir/definitions/keyboard-standard"
|
|
if [ ! -d /config/usb_gadget/g1/functions/hid.usb0 ]; then
|
|
mkdir /config/usb_gadget/g1/functions/hid.usb0
|
|
fi
|
|
current_protocol="$(cat /config/usb_gadget/g1/functions/hid.usb0/protocol)"
|
|
current_subclass="$(cat /config/usb_gadget/g1/functions/hid.usb0/subclass)"
|
|
current_report_length="$(cat /config/usb_gadget/g1/functions/hid.usb0/report_length)"
|
|
|
|
if [ -e /config/usb_gadget/g1/functions/hid.usb0 -a "$current_protocol" == "$protocol" -a "$current_subclass" == "$subclass" -a "$current_report_length" == "$report_length" ] && diff "$moddir/reports/$report_name" /config/usb_gadget/g1/functions/hid.usb0/report_desc; then
|
|
echo nothing to update
|
|
cd /config/usb_gadget/g1/configs/b.1/
|
|
/data/adb/magisk/busybox ln -nsf ../../../../usb_gadget/g1/functions/hid.usb0 ./fhid
|
|
return 0
|
|
fi
|
|
|
|
echo new ghid
|
|
|
|
echo protocol: $protocol
|
|
echo subclass: $subclass
|
|
echo report_length: $report_length
|
|
|
|
echo $protocol >/config/usb_gadget/g1/functions/hid.usb0/protocol
|
|
echo $subclass >/config/usb_gadget/g1/functions/hid.usb0/subclass
|
|
echo $report_length >/config/usb_gadget/g1/functions/hid.usb0/report_length
|
|
cat "$moddir/reports/$report_name" >/config/usb_gadget/g1/functions/hid.usb0/report_desc
|
|
|
|
cd /config/usb_gadget/g1/configs/b.1/
|
|
/data/adb/magisk/busybox ln -nsf ../../../../usb_gadget/g1/functions/hid.usb0 ./fhid
|
|
}
|
|
|
|
echo success ghid was run with: "$@"
|
|
|
|
case "$1" in
|
|
"init")
|
|
enable_ghid
|
|
;;
|
|
"remove")
|
|
remove_ghid
|
|
;;
|
|
*)
|
|
shift
|
|
exit 0
|
|
;;
|
|
esac
|
|
|
|
restorecon /dev/hidg*
|