verified working script. need to investing rc seclabel
This commit is contained in:
parent
71473c6476
commit
458b033a0a
70
bin/ghid.sh
70
bin/ghid.sh
@ -4,45 +4,61 @@ controller=$(getprop sys.usb.controller)
|
|||||||
moddir=${0%bin/*}
|
moddir=${0%bin/*}
|
||||||
selected=standard-keyboard
|
selected=standard-keyboard
|
||||||
remove_ghid() {
|
remove_ghid() {
|
||||||
rm /config/usb_gadget/g1/configs/b.1/fhid
|
echo "disabling ghid" >>$moddir/ghid.log
|
||||||
rmdir /config/usb_gadget/g1/functions/hid.usb0
|
rm /config/usb_gadget/g1/configs/b.1/fhid
|
||||||
echo "$controller" >/config/usb_gadget/g1/UDC
|
rmdir /config/usb_gadget/g1/functions/hid.usb0
|
||||||
|
echo "$controller" >/config/usb_gadget/g1/UDC
|
||||||
}
|
}
|
||||||
|
|
||||||
enable_ghid() {
|
enable_ghid() {
|
||||||
running=true
|
echo "enabling ghid" >>$moddir/ghid.log
|
||||||
. "$moddir/definitions/$selected"
|
running=true
|
||||||
if [ ! -d /config/usb_gadget/g1/functions/hid.usb0 ]; then
|
. "$moddir/definitions/$selected"
|
||||||
mkdir /config/usb_gadget/g1/functions/hid.usb0
|
if [ ! -d /config/usb_gadget/g1/functions/hid.usb0 ]; then
|
||||||
fi
|
mkdir /config/usb_gadget/g1/functions/hid.usb0
|
||||||
current_protocols="$(cat /config/usb_gadget/g1/functions/hid.usb0/protocol)"
|
fi
|
||||||
current_subclasses="$(cat /config/usb_gadget/g1/functions/hid.usb0/subclass)"
|
current_protocols="$(cat /config/usb_gadget/g1/functions/hid.usb0/protocol)"
|
||||||
current_report_lengths="$(cat /config/usb_gadget/g1/functions/hid.usb0/report_length)"
|
current_subclasses="$(cat /config/usb_gadget/g1/functions/hid.usb0/subclass)"
|
||||||
|
current_report_lengths="$(cat /config/usb_gadget/g1/functions/hid.usb0/report_length)"
|
||||||
|
echo "current ghid" >>$moddir/ghid.log
|
||||||
|
echo current_protocols $current_protocols >>$moddir/ghid.log
|
||||||
|
echo current_subclasses $current_subclasses >>$moddir/ghid.log
|
||||||
|
echo current_report_lengths $current_report_lengths >>$moddir/ghid.log
|
||||||
|
|
||||||
if ! { [[ -e /config/usb_gadget/g1/functions/hid.usb0 -a "$current_protocols" == "$protocols" -a "$current_subclasses" == "$subclasses" -a "$current_report_lengths" == "$report_lengths" ]] && diff "$moddir/reports/$report_names" /config/usb_gadget/g1/functions/hid.usb0/report_desc } ; then
|
if [ -e /config/usb_gadget/g1/functions/hid.usb0 -a "$current_protocols" == "$protocols" -a "$current_subclasses" == "$subclasses" -a "$current_report_lengths" == "$report_lengths" ] && diff "$moddir/reports/$report_names" /config/usb_gadget/g1/functions/hid.usb0/report_desc ; then
|
||||||
return 0
|
echo nothing to update >>$moddir/ghid.log
|
||||||
fi
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo new ghid >>$moddir/ghid.log
|
||||||
|
|
||||||
echo $protocols >/config/usb_gadget/g1/functions/hid.usb0/protocol
|
echo $protocols >>$moddir/ghid.log
|
||||||
echo $subclasses >/config/usb_gadget/g1/functions/hid.usb0/subclass
|
echo $subclasses >>$moddir/ghid.log
|
||||||
echo $report_lengths >/config/usb_gadget/g1/functions/hid.usb0/report_length
|
echo $report_lengths >>$moddir/ghid.log
|
||||||
cp $report_names /config/usb_gadget/g1/functions/hid.usb0/report_desc
|
|
||||||
ln -s /config/usb_gadget/g1/functions/hid.usb0 /config/usb_gadget/g1/configs/b.1/fhid
|
rm /config/usb_gadget/g1/configs/b.1/fhid
|
||||||
echo "$controller" >/config/usb_gadget/g1/UDC
|
echo $protocols >/config/usb_gadget/g1/functions/hid.usb0/protocol
|
||||||
|
echo $subclasses >/config/usb_gadget/g1/functions/hid.usb0/subclass
|
||||||
|
echo $report_lengths >/config/usb_gadget/g1/functions/hid.usb0/report_length
|
||||||
|
cp "$moddir/reports/$report_names" /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 none >/config/usb_gadget/g1/UDC
|
||||||
|
echo "$controller" >/config/usb_gadget/g1/UDC
|
||||||
}
|
}
|
||||||
|
|
||||||
|
echo success ghid was run >>$moddir/ghid.log
|
||||||
|
|
||||||
if ! [[ "$1" == "setup" ]]; then
|
if ! [[ "$1" == "setup" ]]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
shift
|
shift
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
""|"none" )
|
""|"none" )
|
||||||
remove_ghid
|
remove_ghid
|
||||||
;;
|
;;
|
||||||
* )
|
* )
|
||||||
enable_ghid
|
enable_ghid
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
125
customize.sh
125
customize.sh
@ -1,2 +1,127 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
chmod 755 $MODPATH/bin/ghid.sh
|
||||||
sed "s@\[MODDIR\]@$MODPATH@g" "$MODPATH/overlay.d/ghid.rc" | sed 's/modules_update/modules/g' >"$TMPDIR/ghid.rc"
|
sed "s@\[MODDIR\]@$MODPATH@g" "$MODPATH/overlay.d/ghid.rc" | sed 's/modules_update/modules/g' >"$TMPDIR/ghid.rc"
|
||||||
cp "$TMPDIR/ghid.rc" "$MODPATH/overlay.d/ghid.rc"
|
cp "$TMPDIR/ghid.rc" "$MODPATH/overlay.d/ghid.rc"
|
||||||
|
|
||||||
|
rpwd="$PWD"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
##########################################################################################
|
||||||
|
# Initialization
|
||||||
|
##########################################################################################
|
||||||
|
cd "$MAGISKBIN"
|
||||||
|
get_flags
|
||||||
|
find_boot_image
|
||||||
|
|
||||||
|
[ -e "$BOOTIMAGE" ] || abort "$BOOTIMAGE does not exist!"
|
||||||
|
|
||||||
|
# Flags
|
||||||
|
[ -z "$KEEPVERITY" ] && KEEPVERITY=false
|
||||||
|
[ -z "$KEEPFORCEENCRYPT" ] && KEEPFORCEENCRYPT=false
|
||||||
|
[ -z "$RECOVERYMODE" ] && RECOVERYMODE=false
|
||||||
|
export KEEPVERITY
|
||||||
|
export KEEPFORCEENCRYPT
|
||||||
|
|
||||||
|
chmod -R 755 .
|
||||||
|
|
||||||
|
eval "$BOOTSIGNER" -verify < "$BOOTIMAGE" && BOOTSIGNED=true
|
||||||
|
"$BOOTSIGNED" && ui_print "- Boot image is signed with AVB 1.0"
|
||||||
|
|
||||||
|
##########################################################################################
|
||||||
|
# Start bootpatch
|
||||||
|
##########################################################################################
|
||||||
|
|
||||||
|
##########################################################################################
|
||||||
|
# Unpack
|
||||||
|
##########################################################################################
|
||||||
|
|
||||||
|
CHROMEOS=false
|
||||||
|
|
||||||
|
ui_print "- Unpacking boot image"
|
||||||
|
./magiskboot unpack "$BOOTIMAGE"
|
||||||
|
|
||||||
|
case $? in
|
||||||
|
1 )
|
||||||
|
abort "! Unsupported/Unknown image format"
|
||||||
|
;;
|
||||||
|
2 )
|
||||||
|
ui_print "- ChromeOS boot image detected"
|
||||||
|
CHROMEOS=true
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
[ -f recovery_dtbo ] && RECOVERYMODE=true
|
||||||
|
|
||||||
|
##########################################################################################
|
||||||
|
# Ramdisk restores
|
||||||
|
##########################################################################################
|
||||||
|
|
||||||
|
# Test patch status and do restore
|
||||||
|
ui_print "- Checking ramdisk status"
|
||||||
|
if [ -e ramdisk.cpio ]; then
|
||||||
|
./magiskboot cpio ramdisk.cpio test
|
||||||
|
STATUS=$?
|
||||||
|
else
|
||||||
|
# Stock A only system-as-root
|
||||||
|
STATUS=0
|
||||||
|
fi
|
||||||
|
case $((STATUS & 3)) in
|
||||||
|
0 ) # Stock boot
|
||||||
|
ui_print "- Stock boot image detected"
|
||||||
|
abort "Magisk not installed????"
|
||||||
|
;;
|
||||||
|
1 ) # Magisk patched
|
||||||
|
ui_print "- Magisk patched boot image detected"
|
||||||
|
;;
|
||||||
|
2 ) # Unsupported
|
||||||
|
ui_print "! Boot image patched by unsupported programs"
|
||||||
|
abort "! Please restore back to stock boot image"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
##########################################################################################
|
||||||
|
# Ramdisk patches
|
||||||
|
##########################################################################################
|
||||||
|
|
||||||
|
ui_print "- Patching ramdisk"
|
||||||
|
ui_print "- Adding overlay.d/ghid.rc"
|
||||||
|
|
||||||
|
./magiskboot cpio ramdisk.cpio \
|
||||||
|
"mkdir 755 overlay.d" \
|
||||||
|
"add 755 overlay.d/ghid.rc $MODPATH/overlay.d/ghid.rc"
|
||||||
|
|
||||||
|
if [ $((STATUS & 4)) -ne 0 ]; then
|
||||||
|
ui_print "- Compressing ramdisk"
|
||||||
|
./magiskboot cpio ramdisk.cpio compress
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -f ramdisk.cpio.orig config
|
||||||
|
|
||||||
|
ui_print "- Repacking boot image"
|
||||||
|
./magiskboot repack "$BOOTIMAGE" || abort "! Unable to repack boot image!"
|
||||||
|
|
||||||
|
# Sign chromeos boot
|
||||||
|
$CHROMEOS && sign_chromeos
|
||||||
|
|
||||||
|
##########################################################################################
|
||||||
|
# End bootpatch
|
||||||
|
##########################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
ui_print "- Flashing new boot image"
|
||||||
|
|
||||||
|
if ! flash_image new-boot.img "$BOOTIMAGE"; then
|
||||||
|
ui_print "- Compressing ramdisk to fit in partition"
|
||||||
|
./magiskboot cpio ramdisk.cpio compress
|
||||||
|
./magiskboot repack "$BOOTIMAGE"
|
||||||
|
flash_image new-boot.img "$BOOTIMAGE" || abort "! Insufficient partition size"
|
||||||
|
fi
|
||||||
|
|
||||||
|
./magiskboot cleanup
|
||||||
|
rm -f new-boot.img
|
||||||
|
|
||||||
|
patch_dtb_partitions
|
||||||
|
run_migrations
|
||||||
|
|
||||||
|
cd "$rpwd"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
id=ghid
|
id=ghid
|
||||||
name=ghid
|
name=ghid
|
||||||
version=0
|
version=0
|
||||||
versionCode=6
|
versionCode=20
|
||||||
author=lordwelch
|
author=lordwelch
|
||||||
description=creates ghid device files in /dev
|
description=creates ghid device files in /dev
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
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 - -- [MODDIR]/bin/ghid.sh setup ${sys.usb.config}
|
exec u:object_r:magisk:s0 root root -- [MODDIR]/bin/ghid.sh setup ${sys.usb.config}
|
||||||
|
@ -1 +0,0 @@
|
|||||||
testing
|
|
Loading…
x
Reference in New Issue
Block a user