-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathconnectIP.sh
executable file
·63 lines (48 loc) · 1.86 KB
/
connectIP.sh
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
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
#
# Created by Sujay Davalgi
#
# Configures the selected device and connects the adb over IP
# Using this you can connect to the device over network.
# Machine and phone should be in the same sub-net to connect to the device after enabling the adb over IP
#
# Usage: ./connectIP.sh [<Device Serial>]
# Command line Arguments (Optional):
# $1 - Input the device serial
# If the serial number is not provided, it will display the list of attached devices to pick from
. ./library/mainFunctions.sh
. ./library/textFormatting.sh
. ./library/deviceOperations.sh
. ./library/networkOperations.sh
if [ $# -lt 1 ]; then
getDeviceChoice
else
buildDeviceSnArray
deviceSerial="$1"
fi
displaySelectedDevice $deviceSerial
setPort=5555
if [ $( isAdbDevice $deviceSerial ) == "true" ]; then
#deviceIP=`echo $( getMyIP $deviceSerial )`
deviceIP=`echo $( getDeviceIP $deviceSerial )`
if [ $( isAtHomeDevice $deviceSerial ) == "true" ]; then
#deviceIP="$( adb -s $deviceSerial shell dumpsys activity service BrokerService | grep address: )"
#deviceIP=`echo $deviceIP| cut -d':' -f 2`
#setPort=`adb -s $deviceSerial wait-for-device shell getprop service.adb.tcp.port`
setPort=`adb -s $deviceSerial wait-for-device shell getprop persist.adb.tcp.port`
else
adb -s $deviceSerial wait-for-device tcpip ${setPort}
fi
adb -s $deviceSerial wait-for-device shell stop adbd
adb -s $deviceSerial wait-for-device shell start adbd
echo -e -n " My IP : $deviceIP\n"
echo -e -n " My port: $setPort\n"
adb -s $deviceSerial wait-for-device root
adb -s $deviceSerial wait-for-device shell setprop persist.adb.tcp.port $setPort # you should be root or su before running this
adb -s $deviceSerial wait-for-device connect $deviceIP:$setPort
# To disconnect the IP and use USB
# adb -s $deviceSerial wait-for-device usb
else
echo " Device is not in 'adb' mode"
fi
echo ""