1 of 180

Break On Through To the Other Side

adb_

>

2 of 180

http://eyal.fr

Eyal Lezmy

3 of 180

Join us!

4 of 180

bit.ly/adb-chill

Slides

>

5 of 180

How adb works

Some adb commands

The internals

Dev on the adb project

The Android dev tools

>

>

>

>

>

6 of 180

alias adb=“Android Debug Bridge”

7 of 180

A command line tool

To communicate with Android devices

physical or emulators

8 of 180

Part of the SDK

on the platform-tools directory

2 versions distributed

Stable & Preview channel

9 of 180

How adb

works

10 of 180

adb

daemon

adb

client

adb

server

11 of 180

adb

client

12 of 180

adb

client

13 of 180

adb_

>

adb

client

14 of 180

adb

daemon

15 of 180

adb

daemon

16 of 180

Started at boot

As background process

Executes commands

on the device

adb

daemon

17 of 180

adb

server

18 of 180

adb

daemon

adb

client

adb

server

19 of 180

adb

daemon

adb

client

adb

server

20 of 180

A practical case

21 of 180

adb

client

22 of 180

adb

client

Is there an ADB Server?

23 of 180

adb

client

adb

server

Start adb server

24 of 180

adb

client

adb

server

Port 5037

25 of 180

adb

client

adb

server

Scan for Android devices and emulators

26 of 180

adb

client

adb

server

localhost

5555

5557

5681

27 of 180

adb

client

adb

server

localhost

5555

5557

5681

Is there a device bound here?

28 of 180

adb

client

adb

server

localhost

5555

5557

5681

Is there a device bound here?

29 of 180

adb

client

adb

server

localhost

5555

5557

5681

Is there a device bound here?

30 of 180

adb

client

adb

server

localhost

adb

daemon

5557

Android Studio

Emulator

31 of 180

adb

client

adb

server

localhost

adb

daemon

5557

Android Studio

Emulator

Open a connection to the device

32 of 180

adb

client

adb

server

USB Interface

33 of 180

adb

client

adb

server

USB Interface

/dev/…

adb

daemon

Nexus 6P (USB)

34 of 180

adb

client

adb

server

adb

daemon

Nexus 6P

adb

daemon

Network device

adb

daemon

AS Emulator

35 of 180

adb

client

adb

server

adb

daemon

Nexus 6P

adb

daemon

Network device

adb

daemon

AS Emulator

36 of 180

Some adb commands

37 of 180

adb tcpip 5555

>

Enable wireless debugging

adb connect <device-ip>

>

38 of 180

adb usb

>

Disable wireless debugging

39 of 180

adb tcpip 5555

>

40 of 180

adb tcpip 5555

>

ADB Server asks the Daemon to enable the network connection

“tcpip:5555”

41 of 180

adb tcpip 5555

>

ADB Server asks the Daemon to enable the network connection

The daemon sets a system property

setprop service.adb.tcp.port 5555

42 of 180

adb tcpip 5555

>

ADB Server asks the Daemon to enable the network connection

The daemon sets a system property

ADB Daemon closes itself

exit(1)

43 of 180

adb tcpip 5555

>

ADB Server asks the Daemon to enable the network connection

The daemon sets a system property

ADB Daemon closes itself

The system restarts automatically ADB Daemon

service adbd /sbin/adbd

44 of 180

adb tcpip 5555

>

ADB Server asks the Daemon to enable the network connection

The daemon sets a system property

ADB Daemon closes itself

The system restarts automatically ADB Daemon

The Daemon will read the property at start and will listen to this port

getprop service.adb.tcp.port

45 of 180

adb tcpip 5555

>

setprop service.adb.tcp.port 5555

#

stop adbd

#

start adbd

#

46 of 180

adb tcpip 5555

>

setprop persist.adb.tcp.port 5555

#

stop adbd

#

start adbd

#

Remains after reboot

47 of 180

adb devices -l

>

192.168.63.101:5555 device product:vbox86p model:myGenymotionNexus5 device:vbox86p

F5AZFG013292 device usb:336592896X product:WW_Z00A model:ASUS_Z00AD device:Z00A

HT4CNJT00728 device usb:336592896X product:volantis model:Nexus_9 device:flounder

Detailed device list

48 of 180

adb -e shell

>

Filter the type of device

Emulator or network device

adb -d shell

>

USB device

49 of 180

adb -H <ip> -P <port> devices

>

Access a remote ADB Server

50 of 180

adb -H 10.5.0.5 -P 5037 devices

>

51 of 180

adb

client

adb -H 10.5.0.5 -P 5037 devices

>

52 of 180

adb

client

adb

server

5037

adb -H 10.5.0.5 -P 5037 devices

>

Device farm server

10.5.0.5

53 of 180

adb

client

adb

server

Samsung S6

Genymotion Kitkat

Pixel 2 XL

5037

adb -H 10.5.0.5 -P 5037 devices

>

Device farm server

10.5.0.5

54 of 180

adb reverse

>

55 of 180

adb reverse

>

Backend Server

Your app

localhost

localhost

2323

8181

56 of 180

adb reverse tcp:2323 tcp:8181

>

Backend Server

Your app

localhost

localhost

2323

8181

57 of 180

adb reverse tcp:2323 tcp:8181

>

Backend Server

Your app

localhost

localhost

2323

8181

58 of 180

adb reverse

>

SecuredBackend Server

Your app

VPN

59 of 180

adb reverse

>

SecuredBackend Server

Your app

VPN

Proxy

Proxy

Setting

60 of 180

adb shell settings put global http_proxy localhost:3333

>

adb reverse tcp:3333 tcp:3128

>

docker run --name squid \

--publish 127.0.0.1:3128:3128 \

--volume $HOME/squid.conf:/etc/squid3/squid.conf \

--volume /tmp/squid/cache:/var/spool/squid3 \

--volume /tmp/squid/cache:/var/log/squid3 \

sameersbn/squid:3.3.8-12

>

61 of 180

adb

>

62 of 180

adb

>

...

-p <name or path> - simple product name like 'sooner', or a

relative/absolute path to a product out

directory like 'out/target/product/sooner'.

If -p is not specified, the

ANDROID_PRODUCT_OUT environment variable is

used, which must be an absolute path.

63 of 180

adb

>

...

-p <name or path> - simple product name like 'sooner', or a

relative/absolute path to a product out

directory like 'out/target/product/sooner'.

If -p is not specified, the

ANDROID_PRODUCT_OUT environment variable is

used, which must be an absolute path.

Sooner??

64 of 180

65 of 180

Andy Rubin

Holy crap, I guess we’re not going to ship that phone.

66 of 180

The adb internals

67 of 180

adb

daemon

adb

client

adb

server

68 of 180

adb

daemon

adb

client

adb

server

C-S

S-D

69 of 180

Client-Server

70 of 180

adb shell ls

>

71 of 180

adb shell ls

>

adb

client

adb

server

72 of 180

adb shell ls

>

adb

client

adb

server

What’s your protocol version?

73 of 180

adb

client

adb

server

adb shell ls

>

What’s your protocol version?

host:version

74 of 180

adb

client

adb

server

adb shell ls

>

It’s version 36

host:version

OKAY 36

75 of 180

adb

client

adb

server

adb shell ls

>

host:version

OKAY 36

76 of 180

adb

client

adb

server

adb shell ls

>

host:transport-any

I want to talk to any kind of device

77 of 180

adb

client

adb

server

adb shell ls

>

host:transport-any

OKAY

OKAY!

78 of 180

adb

client

adb

server

adb shell ls

>

shell:ls

Please execute the shell service with the parameter “ls”

79 of 180

adb

client

adb

server

adb shell ls

>

shell:ls

“ls output”

cache

charge

config

...

80 of 180

adb

client

adb

server

adb shell ls

>

host:version

OKAY 36

host:transport-any

OKAY

shell:ls

“ls output”

81 of 180

Service

execution

Startup

Device selection

82 of 180

adb devices

>

adb server version (32) doesn't match this client (36); killing…

adb devices

>

adb server is out of date. killing...

83 of 180

adb

>

At device selection

host:transport-any

84 of 180

adb

>

adb -s <serial>

>

At device selection

adb -d

>

adb -e

>

host:transport:<serial>

host:transport-any

host:transport-usb

host:transport-local

85 of 180

adb

client

Requests

a service execution

86 of 180

adb

client

adb

server

Requests

a service execution

Executes

host services

87 of 180

adb

daemon

adb

client

adb

server

Requests

a service execution

Executes

host services

Executes

local services

88 of 180

host:version Get the ADB Server version

host:kill Kill the ADB Server

host:devices List the connected devices

host:devices-l List the connected devices with details

host:track-devices Track the list of the connected devices

host:transport* Target a device to interact with

Some host services

89 of 180

shell:<command> Run a shell command

shell: Open an interactive shell session

remount: Remount the filesystem in r-w mode

framebuffer: Get framebuffer snapshots

jdwp:<pid> Connects to the JDWP thread of a process

track-jdwp Track the list of all processes in debug

sync: Specific service used for push & pull

Some local services

90 of 180

Server-Daemon

91 of 180

What the message looks like?

92 of 180

93 of 180

amessage

94 of 180

amessage

data

95 of 180

amessage

data

struct amessage {

unsigned command; /* command identifier constant */

unsigned arg0; /* first argument */

unsigned arg1; /* second argument */

unsigned data_length; /* length of payload (0 is allowed) */

unsigned data_crc32; /* crc32 of data payload */

unsigned magic; /* command ^ 0xffffffff */

};

96 of 180

amessage

data

struct amessage {

unsigned command; /* command identifier constant */

unsigned arg0; /* first argument */

unsigned arg1; /* second argument */

unsigned data_length; /* length of payload (0 is allowed) */

unsigned data_crc32; /* crc32 of data payload */

unsigned magic; /* command ^ 0xffffffff */

};

The verb of the action

97 of 180

amessage

data

struct amessage {

unsigned command; /* command identifier constant */

unsigned arg0; /* first argument */

unsigned arg1; /* second argument */

unsigned data_length; /* length of payload (0 is allowed) */

unsigned data_crc32; /* crc32 of data payload */

unsigned magic; /* command ^ 0xffffffff */

};

The arguments of the action

98 of 180

amessage

data

struct amessage {

unsigned command; /* command identifier constant */

unsigned arg0; /* first argument */

unsigned arg1; /* second argument */

unsigned data_length; /* length of payload (0 is allowed) */

unsigned data_crc32; /* crc32 of data payload */

unsigned magic; /* command ^ 0xffffffff */

};

The size of the data

99 of 180

adb connect <ip:port>

>

100 of 180

adb

daemon

adb

server

adb connect <ip:port>

>

101 of 180

adb

daemon

adb

server

adb connect <ip:port>

>

CNXN, 0x01000000, 256K

102 of 180

adb

daemon

adb

server

adb connect <ip:port>

>

CNXN, 0x01000000, 256K

Command

Arg 1

Arg 2

103 of 180

adb

daemon

adb

server

adb connect <ip:port>

>

CNXN, 0x01000000, 256K

CONNECT command

104 of 180

adb

daemon

adb

server

adb connect <ip:port>

>

CNXN, 0x01000000, 256K

Protocol version

105 of 180

adb

daemon

adb

server

adb connect <ip:port>

>

CNXN, 0x01000000, 256K

Max payload size

106 of 180

adb

daemon

adb

server

adb connect <ip:port>

>

CNXN, 0x01000000, 256K

device::ro.product...

107 of 180

adb

daemon

adb

server

adb connect <ip:port>

>

CNXN, 0x01000000, 256K

device::ro.product...

Command

Arg 1

Arg 2

108 of 180

adb

daemon

adb

server

adb connect <ip:port>

>

CNXN, 0x01000000, 256K

device::ro.product...

Data

109 of 180

adb

daemon

adb

server

adb connect <ip:port>

>

CNXN, 0x01000000, 256K

device::ro.product...

Device identity string

110 of 180

adb shell ls

>

111 of 180

adb

daemon

adb

server

adb shell ls

>

112 of 180

adb

daemon

adb

server

adb shell ls

>

OPEN, server-id, 0, shell:ls

113 of 180

adb

daemon

adb

server

adb shell ls

>

OPEN, server-id, 0, shell:ls

Command

Arg1

Arg2

Data

114 of 180

adb

daemon

adb

server

adb shell ls

>

OPEN, server-id, 0, shell:ls

The ADB service to execute

115 of 180

adb

daemon

adb

server

adb shell ls

>

OPEN, server-id, 0, shell:ls

OKAY, daemon-id, server-id

116 of 180

adb

daemon

adb

server

adb shell ls

>

OPEN, server-id, 0, shell:ls

OKAY, daemon-id, server-id

WRITE, daemon-id, server-id

“DATA”

117 of 180

adb

daemon

adb

server

adb shell ls

>

OPEN, server-id, 0, shell:ls

OKAY, daemon-id, server-id

WRITE, daemon-id, server-id

“DATA”

OKAY, server-id, daemon-id

118 of 180

adb

daemon

adb

server

adb shell ls

>

OPEN, server-id, 0, shell:ls

OKAY, daemon-id, server-id

WRITE, daemon-id, server-id

“DATA”

OKAY, server-id, daemon-id

WRITE, daemon-id, server-id

“DATA”

CLOSE, daemon-id, server-id

119 of 180

adb

daemon

adb

server

adb shell ls

>

OPEN, server-id, 0, shell:ls

OKAY, daemon-id, server-id

WRITE, daemon-id, server-id

“DATA”

OKAY, server-id, daemon-id

WRITE, daemon-id, server-id

“DATA”

OKAY, server-id, daemon-id

CLOSE, server-id, daemon-id

CLOSE, daemon-id, server-id

120 of 180

Why ADB is

now faster?

121 of 180

122 of 180

123 of 180

124 of 180

data (256KB)

amessage

Now

125 of 180

data (256KB)

amessage

amessage

data (4KB)

Now

Before

126 of 180

adb

daemon

adb

server

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

127 of 180

adb

daemon

adb

server

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

WRITE, “256KB DATA”

OKAY

OKAY

WRITE, “256KB DATA”

128 of 180

Develop on the ADB project

129 of 180

Configure your environment

Fetch the source code

Make it!

Build your own ADB

130 of 180

repo init \

-u https://android.googlesource.com/platform/manifest \

-b master

repo sync -c --force-sync

source build/envsetup.sh

lunch

make -j24 adb

>

>

>

>

>

131 of 180

adbd

adb

libadb

132 of 180

The client host binary

Bundle in the Android SDK

The one you use everyday

Output path

./out/host/<your-platform>/bin/adb

adb

133 of 180

The device’s daemon binary

Bundle in the Android OS

The one you use everyday

Maybe without noticing

adbd

134 of 180

Adb static library

Contains the common files

libadb

135 of 180

Originally written in

C

136 of 180

Aimed to be written in

C++

137 of 180

Actually written in

C+

138 of 180

Actually written in

C~++

139 of 180

Actually written in

C++--

140 of 180

ADB sources are ubiquitous

141 of 180

ADB sources are ubiquitous

142 of 180

ADB sources are ubiquitous

adb

daemon

adb

client

adb

server

143 of 180

ADB sources are ubiquitous

adb

daemon

adb

client

adb

server

144 of 180

adb

client

adb

server

adb

daemon

Nexus 6P

adb

daemon

Network device

adb

daemon

AS Emulator

adb

client

adb

client

145 of 180

#if ADB_HOST

...

#else // !ADB_HOST

...

#endif // ADB_HOST

146 of 180

#if ADB_HOST

...

#else // !ADB_HOST

...

#endif // ADB_HOST

62 times

147 of 180

#if defined(_WIN32)

...

#endif

148 of 180

#if defined(_WIN32)

...

#endif

51 times

149 of 180

adb kill-server

>

export ADB_TRACE=adb

>

Debug ADB

adb start-server

>

150 of 180

adb devices

>

...

adb I 39295 1708488 adb_client.cpp:135] _adb_connect:host:devices

adb I 39295 1708488 adb_io.cpp:99] writex: fd=3 len=16 30303063686f73743a64657669636573 000chost:devices

...

ADB Client logs

tail -f /tmp/adb.log Linux

tail -f $TMPDIR/adb.*.log Mac

ADB Server logs

>

>

151 of 180

ADB &

The Android Dev Tools

152 of 180

Android Studio

153 of 180

repo init \

-u https://android.googlesource.com/platform/manifest \

-b studio-master-dev

repo sync -c --force-sync

cd ./tools/idea

>

>

>

Get the source code

154 of 180

Android Studio

does not use

adb

155 of 180

Android Studio

does not use

adb

…almost

156 of 180

Android Studio

uses

ddmlib

157 of 180

A Java library

Behaves as an ADB Client

Part of the AOSP

tools/base/ddmlib

ddmlib

158 of 180

ddmlib

does not use

adb

159 of 180

ddmlib

does not use

adb

…almost

160 of 180

ddmlib

adb

server

adb

daemon

Nexus 6P

adb

daemon

Network device

adb

daemon

AS Emulator

5037

161 of 180

What’s the difference between ddmlib and adb binary?

162 of 180

What’s the difference between ddmlib and adb binary?

one of

s

163 of 180

What’s the difference between ddmlib and adb binary?

one of

s

The backward compatibility

164 of 180

adb binary

ddmlib

Latest version only

From ADB 1.0.20

165 of 180

adb binary

ddmlib

Latest version only

From ADB 1.0.20

(October 2008)

166 of 180

Maintained by Google

Open source

Many thousands of daily users

Still need the adb binary

ddmlib as library

167 of 180

Maintained by Google

Open source

Many thousands of daily users

Still need the adb binary

Possibly a good tool for your project

ddmlib as library

168 of 180

repositories {

google()

}

dependencies {

implementation 'com.android.tools.ddms:ddmlib:26.1.0'

}

169 of 180

The Android Gradle Plugin

170 of 180

repo init \

-u https://android.googlesource.com/platform/manifest \

-b gradle_3.0.0

repo sync -c --force-sync

cd ./tools/base/build-system/

>

>

>

Get the source code

171 of 180

The Android Gradle Plugin

uses

ddmlib

172 of 180

The Android Gradle Plugin

uses

ddmlib

Like Android Studio

173 of 180

The Android Gradle Plugin

uses

ddmlib

How does

?

174 of 180

When there is an interaction with a device

Install an APK

Launch instrumented tests

Get devices information

175 of 180

Manages the list of connected devices

Interacts with the device through ddmlib

DeviceProvider

ConnectedDevice

176 of 180

gradlew <yourTask> --debug

>

Make ddmlib verbose from the build.gradle

import com.android.ddmlib.DdmPreferences

DdmPreferences.setLogLevel("verbose")

177 of 180

Make ddmlib verbose from the build.gradle

V/ddms: execute: running pm install-create -r -S 945819

V/ddms: execute: running pm install-write -S 945819 26732 0_binocle-flavor1-debug -

V/ddms: execute: running pm install-commit 1802739235

V/ddms: execute: running am instrument -w -r com.genymotion.binocle.test/android.test.InstrumentationTestRunner

V/InstrumentationResultParser: INSTRUMENTATION_STATUS: numtests=5

V/InstrumentationResultParser: INSTRUMENTATION_STATUS: stream=

V/InstrumentationResultParser: com.genymotion.binocle.test.TestBattery:

V/InstrumentationResultParser: INSTRUMENTATION_STATUS: id=InstrumentationTestRunner

V/InstrumentationResultParser: INSTRUMENTATION_STATUS: test=testBatteryWarning

178 of 180

Inject ADB options from the build.gradle

for all the tasks

android.adbOptions {

timeOutInMs 5000 // 5 seconds

installOptions “-g”

}

179 of 180

Inject ADB options from the build.gradle

for a single task

android.testVariants.all { variant ->

variant.connectedInstrumentTest.installOptions = ["-g"]

}

180 of 180

http://eyal.fr

bit.ly/adb-chill

Thank you!

Slides

>

>