Attempt to fix instability with hid and configfs
I may just need a new cord Add test for rc file Add more logging Exec the script and stat the service to run the script Run the permission changes in a background subshell
This commit is contained in:
parent
138fd917c6
commit
dd1446f30e
@ -85,6 +85,9 @@ rpwd="$PWD"
|
|||||||
##########################################################################################
|
##########################################################################################
|
||||||
|
|
||||||
ui_print "- Patching ramdisk"
|
ui_print "- Patching ramdisk"
|
||||||
|
./magiskboot cpio ramdisk.cpio extract /overlay.d/ghid.rc ghid.rc
|
||||||
|
if ! diff $MODPATH/overlay.d/ghid.rc ghid.rc; then
|
||||||
|
rm ghid.rc
|
||||||
ui_print "- Adding overlay.d/ghid.rc"
|
ui_print "- Adding overlay.d/ghid.rc"
|
||||||
|
|
||||||
./magiskboot cpio ramdisk.cpio \
|
./magiskboot cpio ramdisk.cpio \
|
||||||
@ -117,6 +120,10 @@ rpwd="$PWD"
|
|||||||
./magiskboot repack "$BOOTIMAGE"
|
./magiskboot repack "$BOOTIMAGE"
|
||||||
flash_image new-boot.img "$BOOTIMAGE" || abort "! Insufficient partition size"
|
flash_image new-boot.img "$BOOTIMAGE" || abort "! Insufficient partition size"
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
rm ghid.rc
|
||||||
|
ui_print "- overlay.d/ghid.rc already added"
|
||||||
|
fi
|
||||||
|
|
||||||
./magiskboot cleanup
|
./magiskboot cleanup
|
||||||
rm -f new-boot.img
|
rm -f new-boot.img
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
id=ghid
|
id=ghid
|
||||||
name=ghid
|
name=ghid
|
||||||
version=0
|
version=0.9
|
||||||
versionCode=26
|
versionCode=30
|
||||||
author=lordwelch
|
author=lordwelch
|
||||||
description=creates ghid device files in /dev
|
description=creates ghid device files in /dev
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
on property:sys.usb.ffs.ready=1 && property:sys.usb.config=* && property:sys.usb.configfs=1
|
on property:sys.usb.ffs.ready=1 && property:sys.usb.config=* && property:sys.usb.configfs=1
|
||||||
|
exec u:r:magisk:s0 root root -- /system/bin/ghid.sh setup ${sys.usb.config}
|
||||||
start ghid
|
start ghid
|
||||||
|
|
||||||
service ghid /system/bin/ghid.sh setup ${sys.usb.config}
|
service ghid /system/bin/ghid.sh setup ${sys.usb.config}
|
||||||
|
@ -3,15 +3,25 @@
|
|||||||
controller=$(getprop sys.usb.controller)
|
controller=$(getprop sys.usb.controller)
|
||||||
moddir=[MODDIR]
|
moddir=[MODDIR]
|
||||||
selected=keyboard-standard
|
selected=keyboard-standard
|
||||||
|
exec >>$moddir/ghid.log
|
||||||
|
exec 2>>$moddir/ghid.log
|
||||||
|
set -o xtrace
|
||||||
|
set -o nohup
|
||||||
|
set +o errexit
|
||||||
|
set +o sh
|
||||||
|
set +o posix
|
||||||
|
exec >>$moddir/ghid.log
|
||||||
|
exec 2>>$moddir/ghid.log
|
||||||
|
|
||||||
remove_ghid() {
|
remove_ghid() {
|
||||||
echo "disabling ghid" >>$moddir/ghid.log
|
echo "disabling ghid"
|
||||||
rm /config/usb_gadget/g1/configs/b.1/fhid
|
rm /config/usb_gadget/g1/configs/b.1/fhid
|
||||||
rmdir /config/usb_gadget/g1/functions/hid.usb0
|
rmdir /config/usb_gadget/g1/functions/hid.usb0
|
||||||
}
|
}
|
||||||
|
|
||||||
enable_ghid() {
|
enable_ghid() {
|
||||||
for f in $selected; do
|
for f in $selected; do
|
||||||
echo "enabling ghid" >>$moddir/ghid.log
|
echo "enabling ghid"
|
||||||
running=true
|
running=true
|
||||||
. "$moddir/definitions/$f"
|
. "$moddir/definitions/$f"
|
||||||
if [ ! -d /config/usb_gadget/g1/functions/hid.usb0 ]; then
|
if [ ! -d /config/usb_gadget/g1/functions/hid.usb0 ]; then
|
||||||
@ -20,21 +30,21 @@ enable_ghid() {
|
|||||||
current_protocol="$(cat /config/usb_gadget/g1/functions/hid.usb0/protocol)"
|
current_protocol="$(cat /config/usb_gadget/g1/functions/hid.usb0/protocol)"
|
||||||
current_subclass="$(cat /config/usb_gadget/g1/functions/hid.usb0/subclass)"
|
current_subclass="$(cat /config/usb_gadget/g1/functions/hid.usb0/subclass)"
|
||||||
current_report_length="$(cat /config/usb_gadget/g1/functions/hid.usb0/report_length)"
|
current_report_length="$(cat /config/usb_gadget/g1/functions/hid.usb0/report_length)"
|
||||||
echo "current ghid" >>$moddir/ghid.log
|
echo "current ghid"
|
||||||
echo current_protocol $current_protocol >>$moddir/ghid.log
|
echo current_protocol $current_protocol
|
||||||
echo current_subclass $current_subclass >>$moddir/ghid.log
|
echo current_subclass $current_subclass
|
||||||
echo current_report_length $current_report_length >>$moddir/ghid.log
|
echo current_report_length $current_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
|
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 >>$moddir/ghid.log
|
echo nothing to update
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo new ghid >>$moddir/ghid.log
|
echo new ghid
|
||||||
|
|
||||||
echo $protocol >>$moddir/ghid.log
|
echo $protocol
|
||||||
echo $subclass >>$moddir/ghid.log
|
echo $subclass
|
||||||
echo $report_length >>$moddir/ghid.log
|
echo $report_length
|
||||||
|
|
||||||
rm /config/usb_gadget/g1/configs/b.1/fhid
|
rm /config/usb_gadget/g1/configs/b.1/fhid
|
||||||
echo $protocol >/config/usb_gadget/g1/functions/hid.usb0/protocol
|
echo $protocol >/config/usb_gadget/g1/functions/hid.usb0/protocol
|
||||||
@ -44,12 +54,12 @@ enable_ghid() {
|
|||||||
cd /config/usb_gadget/g1/configs/b.1/
|
cd /config/usb_gadget/g1/configs/b.1/
|
||||||
/data/adb/magisk/busybox ln -nsf ../../../../usb_gadget/g1/functions/hid.usb0 ./fhid
|
/data/adb/magisk/busybox ln -nsf ../../../../usb_gadget/g1/functions/hid.usb0 ./fhid
|
||||||
done
|
done
|
||||||
echo none >/config/usb_gadget/g1/UDC
|
# echo none >/config/usb_gadget/g1/UDC
|
||||||
echo "$controller" >/config/usb_gadget/g1/UDC
|
# echo "$controller" >/config/usb_gadget/g1/UDC
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
echo success ghid was run >>$moddir/ghid.log
|
echo success ghid was run with: "$@"
|
||||||
|
|
||||||
if ! [[ "$1" == "setup" ]]; then
|
if ! [[ "$1" == "setup" ]]; then
|
||||||
exit 1
|
exit 1
|
||||||
@ -64,8 +74,4 @@ case "$1" in
|
|||||||
enable_ghid
|
enable_ghid
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
chcon u:object_r:null_device:s0 /dev/hidg*
|
sh <<<'chcon u:object_r:null_device:s0 /dev/hidg*;chmod 666 /dev/hidg*;sleep 5;chcon u:object_r:null_device:s0 /dev/hidg*;chmod 666 /dev/hidg*;ls -alZ /dev/hidg*;' &
|
||||||
chmod 666 /dev/hidg*
|
|
||||||
sleep 1
|
|
||||||
chcon u:object_r:null_device:s0 /dev/hidg*
|
|
||||||
chmod 666 /dev/hidg*
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user