-
-
Save barsikus007/2e44999712cdb074a1c9a9803cad7b8f to your computer and use it in GitHub Desktop.
#!/bin/sh | |
# run while loop for boot_completed status & sleep 10 needed for magisk service.d | |
while [ "$(getprop sys.boot_completed | tr -d '\r')" != "1" ]; do sleep 1; done | |
sleep 10 | |
get_fn_type() { | |
# get currently active function name | |
if ls /config/usb_gadget/g1/configs/b.1/function* > /dev/null 2>&1 | |
then | |
echo "function" | |
else | |
echo "f" | |
fi | |
} | |
fn_type=$(get_fn_type) | |
get_chkfn() { | |
# get currently active function name | |
ls -al /config/usb_gadget/g1/configs/b.1/ | grep -Eo "$fn_type[0-9]+[[:space:]].*" | awk '{print $3}' | cut -d/ -f8 | |
} | |
get_last_fn() { | |
# get currently free function number | |
num=$(ls -al /config/usb_gadget/g1/configs/b.1/ | grep -Eo "$fn_type[0-9]+[[:space:]]" | tail -1 | cut -dn -f 3) | |
echo "$fn_type"$((num+1)) | |
} | |
is_mass_storage_present() { | |
# returns 1 if mass_storage.0 is present | |
ls -al /config/usb_gadget/g1/configs/b.1/ | grep -Eo "mass_storage.0" | wc -l | |
} | |
get_mass_storage_path() { | |
# get path to mass_storage.0 | |
ls -al /config/usb_gadget/g1/configs/b.1/ | grep -Eo "$fn_type[0-9]+[[:space:]].*mass_storage.0" | cut -d' ' -f1 | |
} | |
# save currently active function name | |
if [ "$fn_type" = "f" ]; then | |
get_chkfn > /data/adb/.fixdd | |
fi | |
# loop | |
# run every 0.5 seconds | |
while true | |
do | |
# check the app is active | |
chkapp="$(pgrep -f drivedroid | wc -l)" | |
# check if mass storage is active function | |
mass_storage_active=$(is_mass_storage_present) | |
if [ "$chkapp" -eq "1" ] && [ "$mass_storage_active" -eq "0" ]; then | |
# add mass_storage.0 to currently active functions | |
if [ "$fn_type" = "f" ]; then | |
setprop sys.usb.config cdrom | |
setprop sys.usb.configfs 1 | |
rm /config/usb_gadget/g1/configs/b.1/f* | |
fi | |
mkdir -p /config/usb_gadget/g1/functions/mass_storage.0/lun.0/ | |
ln -s /config/usb_gadget/g1/functions/mass_storage.0 "/config/usb_gadget/g1/configs/b.1/$(get_last_fn)" | |
if [ "$fn_type" = "f" ]; then | |
getprop sys.usb.controller > /config/usb_gadget/g1/UDC | |
setprop sys.usb.state cdrom | |
fi | |
elif [ "$chkapp" -eq "0" ] && [ "$mass_storage_active" -eq "1" ]; then | |
# remove mass_storage.0 function | |
rm "/config/usb_gadget/g1/configs/b.1/$(get_mass_storage_path)" | |
# it seems, than pixel 7 doesn't use sys.usb.config at all | |
if [ "$fn_type" = "f" ]; then | |
# reload of configfs to fix samsung android auto | |
setprop sys.usb.configfs 0 | |
setprop sys.usb.configfs 1 | |
# load previous active function | |
chkfrstfn="$(cat /data/adb/.fixdd)" | |
ln -s /config/usb_gadget/g1/functions/"$chkfrstfn" /config/usb_gadget/g1/configs/b.1/f1 | |
ls /sys/class/udc/ | grep -Eo ".*\.dwc3" > /config/usb_gadget/g1/UDC | |
if [ "$chkfrstfn" = "ffs.adb" ]; then | |
setprop sys.usb.config adb | |
elif [ "$chkfrstfn" = "ffs.mtp" ]; then | |
setprop sys.usb.config mtp | |
elif [ "$chkfrstfn" = "mtp.gs0" ]; then | |
setprop sys.usb.config mtp | |
fi | |
fi | |
fi | |
sleep 0.5 | |
done |
@Ashwinlapmobtech, you can try to remove this folder (if mass_storage.0 exists)
add this to 64th line
rm /config/usb_gadget/g1/functions/mass_storage.usb0
While using ykue
@Ashwinlapmobtech, you can try to remove this folder (if mass_storage.0 exists) add this to 64th line
rm /config/usb_gadget/g1/functions/mass_storage.usb0
While executing your code the mass. storage.0 folder will be automatically created right bro?
So there is no use of folder mass. storage.usb.0
And it will not cause any impact by deleting that folder. .
Am i right bro...?
AFAIR, this folders created dynamicaly on every boot, but I am not sure
@barsikus007, Hey, could you give me a quick rundown of how to install this? you have multiple commands for this. I assume the most recent one is accurate?
@barsikus007, Hey, could you give me a quick rundown of how to install this? you have multiple commands for this. I assume the most recent one is accurate?
I prefer to use this magisk module
https://github.com/overzero-git/DriveDroid-fix-Magisk-module
Thanks man, I'll try it tonight
Hi i am having poco f3 gt
And that also have folder required for drivedroid
But its name is mass_storage.usb0
But for drivedroid it should be mass_storage.0 should be the folder name
So only it recognises
But as its usb.0 its not recognised by drivedroid
And even if i use your code.. i think both maas storage.0 and
Mass storage usb.0 gets activated while plugging in cable so as a result showing usb descriptor failed in windows...
Thatt caise me so much trouble bro...
If possible please guide me to change that folder name or what to do to solve this issue accordingly bro...
Tq bro..