-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
this commit is temporary my future self if you see this, you forgot to re-commit this properly you idiot Change-Id: Ib0c7436e7ef2d3842fbee2711bca5ecdf4cefafc Change-Id: I0217c64c7a01e22c0a5ad1151777c7bc460b7fbe Change-Id: I7bcf6feed4637fa5ed0f03f76cae89a8f0e1ccdb Change-Id: I253faa0c6e2f54dfa7fe6966646d65fd0714a20b Change-Id: I4131c355725dfea25c9823cd999edeb23b813aee
- Loading branch information
Showing
5 changed files
with
142 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,20 @@ | ||
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/halium/usr/share/usbinit/setupusb mtp | ||
echo "mtp" | ||
;; | ||
mtp,adb) | ||
/bin/bash /system/halium/usr/share/usbinit/setupusb mtp_adb | ||
echo "mtp,adb" | ||
;; | ||
*) | ||
echo "off" | ||
;; | ||
esac | ||
end script |
27 changes: 27 additions & 0 deletions
27
rootdir/system/halium/usr/share/upstart/sessions/mtp-server.conf
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,27 @@ | ||
description "MTP protocol server" | ||
|
||
start on :sys:android-usb-connected or android-usb-connected or :sys:android-mtp-on or android-mtp-on or started unity8 | ||
stop on :sys:android-usb-disconnected or android-usb-disconnected or :sys:android-mtp-off or android-mtp-off or desktop-end | ||
|
||
pre-start script | ||
[ "$USER" != "lightdm" ] || { stop; exit 0; } | ||
|
||
test -e /sys/devices/virtual/android_usb/android0/state || { stop; exit 0; } | ||
grep -q DISCONNECTED /sys/devices/virtual/android_usb/android0/state && { stop; exit 0; } | ||
test -e /dev/config/usb_gadget/gadget1/configs/config.1/mtp.gs0 || { stop; exit 0; } | ||
|
||
# Fix for bug LP: #1389223: UnityGreeter isn't available immediately | ||
if ! dbus-send --session --print-reply \ | ||
--dest=com.canonical.UnityGreeter \ | ||
/ org.freedesktop.DBus.Introspectable.Introspect 2>&1 | \ | ||
grep -qc IsActive; then | ||
sleep 10 | ||
fi | ||
end script | ||
|
||
env GOOGLE_LOGTOSTDERR=1 | ||
|
||
respawn | ||
respawn limit unlimited | ||
|
||
exec /usr/bin/mtp-server |
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,86 @@ | ||
CONFIG_DIR=/dev/config | ||
GADGET_DIR=$CONFIG_DIR/usb_gadget | ||
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" | ||
} | ||
|
||
|
||
setup_mtp() { | ||
write $ANDROID_USB/enable 0 | ||
write $ANDROID_USB/android0/iSerial $SERIALNUMBER | ||
write $ANDROID_USB/iManufacturer "Ubuntu Touch Device" | ||
write $ANDROID_USB/idVendor 05C6 | ||
write $ANDROID_USB/idProduct 9039 | ||
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 05C6 | ||
write $ANDROID_USB/idProduct 9039 | ||
write $ANDROID_USB/iManufacturer "Ubuntu Touch Device" | ||
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 "Ubuntu Touch RNDIS" | ||
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 | ||
} | ||
|
||
|
||
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 |