~ycheng-twn/+junk/avila-xenial64

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# adbd - run adb debugging shell
#
# This task enables the adb shell

description     "adbd"

start on local-filesystems
stop on runlevel [06]

normal exit 0 127

respawn

pre-start script
	echo Ubuntu > /sys/class/android_usb/android0/iManufacturer
	echo Aquaris_M10_FHD > /sys/class/android_usb/android0/iProduct
        echo 0123456789ABCDEF > /sys/class/android_usb/android0/iSerial
	echo 1 > /sys/class/android_usb/android0/f_rndis/wceis
	echo Ubuntu > /sys/class/android_usb/android0/f_rndis/manufacturer
	echo 0E8D > /sys/class/android_usb/android0/f_rndis/vendorID

	echo 0 > /sys/class/android_usb/android0/enable
	echo Ubuntu > /sys/class/android_usb/android0/iManufacturer
	echo 2A47 > /sys/class/android_usb/android0/idVendor
	echo 201C > /sys/class/android_usb/android0/idProduct
	echo adb > /sys/class/android_usb/android0/functions
	echo 1 > /sys/class/android_usb/android0/enable

        if [ -d /sys/class/android_usb ]
        then

        if [ -d /sys/class/android_usb/android0/f_ffs ] && \
                [ -n "$(cat /sys/class/android_usb/android0/f_ffs/aliases)" ]
        then
                if ! $(mount|grep -q ^adb)
                then
                        # some devices use the functionfs (i.e. manta)
                        # we need to mount it to keep adb working
                        mkdir -p /dev/usb-ffs/adb
                        chown phablet:phablet -R /dev/usb-ffs
                        mount -o uid=32011,gid=32011 -t functionfs adb /dev/usb-ffs/adb || true
                fi
        fi
        else
        grep -q qemu /proc/cmdline || { stop; exit 0; }
        fi
end script

post-stop script
        unlink /dev/socket/adbd
end script

exec su - -c adbd