diff --git a/customize.sh b/customize.sh index dcfdafc..8902b20 100644 --- a/customize.sh +++ b/customize.sh @@ -1,15 +1,16 @@ #!/bin/sh $BOOTMODE || abort "! must be installed in the running system" if [[ -e /proc/config.gz ]]; then - zcat /proc/config.gz | grep -Eq 'CONFIG_USB_(CONFIGFS_)?F_HID=[my]' || abort "! kernel does not have the required modules" + zcat /proc/config.gz | grep -Eq 'CONFIG_USB_(CONFIGFS_)?F_HID=[my]' || abort "! kernel does not have the required modules" else - [[ -d /config/usb_gadget ]] || abort "! kernel does not have the required modules" - mkdir /config/usb_gadget/g1 || abort "! kernel does not have the required modules" - mkdir /config/usb_gadget/g1/functions/hid.usb0 || abort "! kernel does not have the required modules" + [[ -d /config/usb_gadget ]] || abort "! kernel does not have the required modules" + mkdir /config/usb_gadget/g1 || abort "! kernel does not have the required modules" + mkdir /config/usb_gadget/g1/functions/hid.usb0 || abort "! kernel does not have the required modules" fi chmod 755 "$MODPATH/system/bin/ghid.sh" sed "s@\[MODDIR\]@$MODPATH@g" "$MODPATH/system/bin/ghid.sh" | sed 's/modules_update/modules/g' >"$TMPDIR/ghid.sh" cp "$TMPDIR/ghid.sh" "$MODPATH/system/bin/ghid.sh" +FILE_CONTEXTS=$(find /system -name plat_file_contexts 2>/dev/null | head -n 1) . "$MODPATH/utils.sh" . "$MODPATH/flash_script.sh" diff --git a/module.prop b/module.prop index 9d95e04..4f36dd6 100644 --- a/module.prop +++ b/module.prop @@ -1,6 +1,6 @@ id=ghid name=ghid -version=0.11 -versionCode=38 +version=0.12.44 +versionCode=44 author=lordwelch description=creates ghid device files in /dev diff --git a/overlay.d/ghid.rc b/overlay.d/ghid.rc index 0839314..9e64190 100644 --- a/overlay.d/ghid.rc +++ b/overlay.d/ghid.rc @@ -1,8 +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=adb && property:sys.usb.configfs=1 exec u:r:magisk:s0 root root -- /system/bin/ghid.sh setup ${sys.usb.config} - start ghid -service ghid /system/bin/ghid.sh setup ${sys.usb.config} - user root - disabled - oneshot +on property:sys.usb.ffs.ready=1 && property:sys.usb.state=adb && property:sys.usb.configfs=1 + exec u:r:magisk:s0 root root -- /system/bin/ghid.sh fix ${sys.usb.config} diff --git a/system/bin/ghid.sh b/system/bin/ghid.sh index 7ea75c5..561de41 100644 --- a/system/bin/ghid.sh +++ b/system/bin/ghid.sh @@ -11,8 +11,8 @@ set -o nohup set +o errexit set +o sh set +o posix -exec >>$moddir/ghid.log -exec 2>>$moddir/ghid.log +exec >>$moddir/oghid.log +exec 2>>$moddir/oghid.log remove_ghid() { echo "disabling ghid" @@ -55,24 +55,44 @@ enable_ghid() { cd /config/usb_gadget/g1/configs/b.1/ /data/adb/magisk/busybox ln -nsf ../../../../usb_gadget/g1/functions/hid.usb0 ./fhid done - # echo none >/config/usb_gadget/g1/UDC - # echo "$controller" >/config/usb_gadget/g1/UDC + echo none >/config/usb_gadget/g1/UDC + echo "$controller" >/config/usb_gadget/g1/UDC } echo success ghid was run with: "$@" -if ! [[ "$1" == "setup" ]]; then - exit 1 -fi -shift +# if ! [[ "$1" == "setup" ]]; then +# exit 1 +# fi +# shift + case "$1" in - ""|"none" ) - remove_ghid + "setup" ) + shift + case "$1" in + ""|"none" ) + remove_ghid + ;; + * ) + enable_ghid + ;; + esac + ;; + "fix" ) + shift + 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* ;; * ) - enable_ghid + shift + exit 0 ;; esac -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*;' & +exit 0