-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change-Id: I40b1821b988e3620189de8bf09d8fa7fb653e1ef
- Loading branch information
Showing
4 changed files
with
124 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
start on (android-container persist.sys.usb.config=* or android) and started lightdm | ||
|
||
task | ||
|
||
script | ||
VAL=$(getprop persist.sys.usb.config) | ||
case ${VAL} in | ||
mtp) | ||
/bin/bash /system/bin/setupusb mtp | ||
echo "mtp" | ||
;; | ||
adb,mtp) | ||
/bin/bash /system/bin/setupusb mtp_adb | ||
echo "adb,mtp" | ||
;; | ||
*) | ||
echo "off" | ||
;; | ||
esac | ||
end script | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
SERIALNUMBER=`getprop ro.serialno` | ||
MANUFACTURER=`getprop ro.product.manufacturer` | ||
PRODUCT=`getprop ro.product.model` | ||
PRODUCT_ID_SUFFIX=`getprop ro.usb.pid_suffix` | ||
CONTROLLER=`getprop sys.usb.controller` | ||
ANDROID_USB=/sys/class/android_usb/android0 | ||
|
||
write() { | ||
if [ ! -e "$1" ]; then | ||
return | ||
fi | ||
echo -n "$2" >"$1" | ||
} | ||
|
||
symlink() { | ||
ln -s "$1" "$2" | ||
} | ||
|
||
setup_mtp() { | ||
write $ANDROID_USB/enable 0 | ||
write $ANDROID_USB/android0/iSerial $SERIALNUMBER | ||
write $ANDROID_USB/idVendor 05C6 | ||
write $ANDROID_USB/idProduct F003 | ||
write $ANDROID_USB/functions mtp | ||
write $ANDROID_USB/enable 1 | ||
setprop sys.usb.state mtp | ||
} | ||
|
||
setup_adb() { | ||
setprop sys.usb.config adb | ||
} | ||
|
||
setup_mtp_adb() { | ||
write $ANDROID_USB/enable 0 | ||
write $ANDROID_USB/functions "" | ||
write $ANDROID_USB/enable 1 | ||
sleep 10 # 0.5 delay to attempt to remove rndis function | ||
write $ANDROID_USB/enable 0 | ||
write $ANDROID_USB/idVendor 1004 | ||
write $ANDROID_USB/idProduct 62CE | ||
write $ANDROID_USB/iManufacturer "Mer Boat Loader" | ||
write $ANDROID_USB/iProduct "$PRODUCT" | ||
write $ANDROID_USB/iSerial "$SERIALNUMBER" | ||
write $ANDROID_USB/functions mtp,adb:mtp,acm,diag,adb | ||
write $ANDROID_USB/enable 1 | ||
# setprop sys.usb.state mtp,adb | ||
} | ||
|
||
setup_rndis() { | ||
write $ANDROID_USB/enable 0 | ||
write $ANDROID_USB/functions "" | ||
write $ANDROID_USB/enable 1 | ||
sleep 10 # 0.5 delay to attempt to remove rndis function | ||
write $ANDROID_USB/enable 0 | ||
write $ANDROID_USB/idVendor 1004 | ||
write $ANDROID_USB/idProduct 62CE | ||
write $ANDROID_USB/iManufacturer "Mer Boat Loader" | ||
write $ANDROID_USB/iProduct "$PRODUCT" | ||
write $ANDROID_USB/iSerial "$SERIALNUMBER" | ||
write $ANDROID_USB/functions rndis | ||
write $ANDROID_USB/enable 1 | ||
# setprop sys.usb.state rndis | ||
} | ||
|
||
reset_usb() { | ||
write $ANDROID_USB/enable 0 | ||
write $ANDROID_USB/functions "" | ||
write $ANDROID_USB/enable 1 | ||
} | ||
|
||
setup_boot() { | ||
if [ -e /dev/.usb_setup_done ]; then | ||
echo "Boot setup done" | ||
return | ||
fi | ||
|
||
touch /dev/.usb_setup_done | ||
} | ||
|
||
setup_boot | ||
|
||
if [ "$1" == "rndis" ]; then | ||
setup_rndis | ||
elif [ "$1" == "mtp" ]; then | ||
setup_mtp | ||
elif [ "$1" == "adb" ]; then | ||
setup_adb | ||
elif [ "$1" == "mtp_adb" ]; then | ||
setup_mtp_adb | ||
elif [ "$1" == "reset" ]; then | ||
reset_usb | ||
else | ||
echo "No configuration selected." | ||
fi | ||
|
||
exit 0 | ||
|