SlideShare a Scribd company logo
1 of 44
Download to read offline
ADB
(Android Debug Bridge):
    How it works?
      2012.2.13 Android Builders Summit

      Tetsuyuki Kobayashi

                                          1
Let's talk about inside of Android.




          http://www.kmckk.co.jp/eng/kzma9/           2
          http://www.kmckk.co.jp/eng/jet_index.html
Who am I?
   20+ years involved in embedded systems
       10 years in real time OS, such as iTRON
       10 years in embedded Java Virtual Machine
       Now GCC, Linux, QEMU, Android, …
   Blogs
       http://d.hatena.ne.jp/embedded/ (Personal)
       http://blog.kmckk.com/ (Corporate)
       http://kobablog.wordpress.com/(English)
   Twitter
       @tetsu_koba
                                                     3
Today's topics

   What is ADB?
   ADB internal
   Command details & Tips
   Advanced Topics




                             4
What is ADB?

   If you are an Android builder, you have used
    ”adb logcat”, ”adb shell”
   Even if you only use DDMS in Eclipse, adb is
    working under the hood.
   Using adb, you can connect emulator or actual
    target device.
   ”adb kill-server”? what does it mean?
How to connect?


Host                                   Target device




   Emulator            Adb clients
                       ”adb shell”


          Adbd
                     How to connect?

         QEMU                                 Adbd




                                                       6
3 elements of ADB

   adb clients
       executable with subcommand
       ”adb shell”, ”adb logcat” : the end point of host side
   adb server
       running on host on back-ground
       act as proxy between adb clients and adbd
   adb daemon (adbd)
       running on target device
       started by init, if die, restarted by init again
                                                                 7
ADB overview


Host                                           Target device


                                               Execute services on
   Emulator                                    new thread/subprocess
                         Adb clients



          Adbd                 TCP port:5037

                   TCP
                         Adb server      USB/TCP        Adbd
         QEMU




                                                                       8
2 roles of ADB

   Providing ”Transport”
       communication path between host and target
        device
       USB or TCP: but clients don't have to aware
   Providing ”Services”
       executing something on the target devices through
        the transport.
                   ”adb shell” for executing command
                   ”adb push/pull” for file transfer

                                                            9
When does adb server start?

   Explicitly, ”adb start-server”
       It starts adb server as back ground process.
   Usually it does automatically on demand. You
    don't have to do ”adb start-server”.
   When you want to restart adb server, do ”adb
    kill-server”
   Actually, adb clients and adb server shares
    same executable
       ”adb start-server” equals ”adb fork-server server &”
                                                           10
Port forwarding

                adb forward tcp:1234 tcp:1234
Host                                  Target device




                          Transport
                                                      client socket
       server socket     USB or TCP                   port 1234
       port 1234




                                                                      11
Port forwarding (cont.)
                        adb forward tcp:1234 tcp:1234
example: connecting to gdbserver in the device from gdb client from host
       Host                                         Target device
                 gdb client
                                connect to
                              localhost:1234



                                        Transport
                                                                     client socket
              server socket           USB or TCP                     port 1234
              port 1234

                                                  listen to
                                               localhost:1234
   Both gdb client and gdbserver                                gdbserver
     do not aware of transport

                                                                                     12
ADB internal

   Source code
   How to get ADB logs
   Sequence chart
   Simple ruby script to connect adb server
   Secure mode
   Switching transport mode



                                               13
Source code

   system/core/adb in Android source tree
       16,000 lines in *.[ch]
   From this directory adb and adbd are built
       Don't confuse.
       common files between adb and adbd
                   adb.c, fdevent.c, transort.c, transport_local.c,
                     tansport_usb.c, service.c, sockets.c, util.c
                    #if ADB_HOST
                        /* code for adb*/
                    #else
                        /* code for adbd */
                    #endif
                                                                       14
Source code(cont.)

   files only for adbd
                backup_service.c, file_sync_service.c,
                  jdwp_service.c, framebuffer_service.c,
                  remount_services.c, usb_linux_clients.c,
                  log_service.c
   files only for adb
                console.c, adb_clients.c, file_sync_client.c,
                  usb_vendors.c,
                  get_my_path_{linux,darwin,windows,freebsd}.c,
                  usb_{linux,macos,libusb,windows}.c
   documents
                OVERVIEW.TXT, SERVICES.TXT, protocol.txt
                                                              15
How to get ADB logs

   For adb clients and adb server, set environment
    variable ADB_TRACE

    $ adb kill-server

    $ ADB_TRACE=all start-server

   For adbd, set system property
    ”persist.adb.trace_mask” in hexadecimal
   # set_property persist.adb.trace_mask 0xfff
   I found some trivial bugs. see below
   http://blog.kmckk.com/archives/4080002.html
                                                  16
   http://blog.kmckk.com/archives/4087230.html
Sequence chart
               Adb client
               “adb shell ls”                    Adb server                    adbd


                                host:version

                                OKAY0004001d
Check version
                            host:transport-any

 Specify the                       OKAY
 destination

                                   shell:ls
                                                              [OPEN]shell:ls
 Command                                                                              subprocess
  to adbd
                                                              [OPEN]shell:ls
                                   OKAY
                                                                                         ls
                                                              [WRITE]len=247
                                                                                      len=247

    stdout                         len=247



                                                                                                   17
Simple ruby script to connect to
             adb server
require 'socket'                        hostname = 'localhost'
                                        port = 5037
def error_exit
  puts "Error"                          s = TCPSocket.open(hostname, port)
  exit 1                                send_to_adb(s, "host:version")
end                                     error_exit if ! check_version(s)
                                        s.close
def send_to_adb(s, msg)
  s.printf("%04x%s",                    s = TCPSocket.open(hostname, port)
msg.length, msg)                        send_to_adb(s, "host:transport-any")
end                                     error_exit if ! check_okay(s)
                                        send_to_adb(s, "shell:ls")
def check_okay(s)                       error_exit if ! check_okay(s)
  (s.read(4) == "OKAY")
end                                     while line = s.gets
                                          puts line.chop
def check_version(s)                    end
  (s.read(12) ==                        s.close
"OKAY0004001d")
end
                                         change ”shell:ls” as you like.      18
http://blog.kmckk.com/archives/4092210.html
Secure mode

   Android smart phone products have adbd.
    Usually it runs on secure mode. (secure = 1)
   if secure == 1, change adbd as SHELL user(=
    not privileged), else it keeps running as root
    user
   In secure mode, all services invoked by adbd
    ran as SHELL user. Some causes ”permission
    denied”.


                                                     19
How secure mode decided

   Running on emulator → secure = 0
   System property ”ro.secure” == 1 → secure = 1
        if ”ro.debuggable” == 1, you can restart adb
         unsecure by ”adb root”
   All Android phone products are shipped in
    ”ro.secure” = 1, ”ro.debuggable” = 0.
   See adb.c: adb_main
   http://blog.kmckk.com/archives/4099821.html


                                                        20
Switching transport mode
Switching USB mode to TCP mode
$ adb shell netcfg
lo       UP    127.0.0.1       255.0.0.0                       0x00000049
eth0     UP    192.168.1.139   255.255.255.0                   0x00001043
$ adb tcpip 5555
restarting in TCP mode port : 5555
$ adb devices
List of devices attached

$
disconnected from USB. Then restart adb server with specifying target IP address.
$ adb kill-server
$ ADBHOST=192.168.1.139 adb devices
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
List of devices attached
emulator-5554   device

$
                                                                                    21
Switching transport mode (What
        happen inside?)
   See service.c restart_tcp_service
   property_set(”service.adb.tcp.port”, value);
       Note: before Android 4.0, this cause
        ”permission denied” in secure mode and
        ignored silently!
   After that, exit(1);
       init restarts adbd.
       ”service.adb.tcp.port” is checked in adb.c
        adb_main
                                                     22
Patch to enable switching to TCP
  mode in secure Android 2.3
system/core/init/property_service.c
$ diff -u property_service.c.2 property_service.c
--- property_service.c.2    2012-02-07 18:40:34.472414791
+0900
+++ property_service.c 2012-02-07 18:41:24.782801630
+0900
@@ -79,6 +79,7 @@
      { "debug.",           AID_SHELL,     0 },
      { "log.",             AID_SHELL,     0 },
      { "service.adb.root", AID_SHELL,     0 },
+     { "service.adb.tcp.port", AID_SHELL,      0 },
      { "persist.sys.",     AID_SYSTEM,    0 },
      { "persist.service.", AID_SYSTEM,    0 },
      { "persist.security.", AID_SYSTEM,    0 },


   This avoids ”permission denied” when set property ”service.adb.tcp.port”.
   http://blog.kmckk.com/archives/4098873.html
Command details & Tips
   adb logcat
   adb install/uninstall
   adb reboot/reboot-bootloader
   adb emu
   adb backup/restore
   Joke commands
   Add USB vendor ID
   Restriction of server socket of Android emulator
   Similar restriction in server socket created by
    ”adb forward”                                     24
adb logcat

   There is ”log:” subcommand in adb server, but
    ”adb logcat” doesn't use it
   ”adb logcat” executes /system/bin/logcat
    remotely
       Tag filtering is done in target side
       Logging in DDMS filtering in host side
   similar to
    ”adb shell 
    ANDROID_LOG_TAGS=$ANDORID_LOG_TAGS 
    logcat args..”
                                                    25
adb install/uninstall

   adb install
       transfer apk file and then execute
        /system/bin/pm at the device
   adb uninstall
       just execute /system/bin/pm remotely
adb reboot/reboot-bootloader

   fork&exec /system/bin/vdc to unmount
    storage
   wait for the process and then reboot
    by system call
adb emu

   You can send a single command to emulator
    console easily
        send only. can not receive.
        For emulator console,
                    http://developer.android.com/guide/developing/devices/emulator.html

   Simple example. ”adb emu window scale 0.5”
    after starting emulator
   http://blog.kmckk.com/archives/4091258.html



                                                                                           28
adb backup/restore

   New in Android 4.0
   You can backup/restore installed
    applications with their saved status.




                                            29
Joke commands

   adb hell
       same as ”adb shell” except ”hell” color :)
       Just try.
   adb lolcat
       same as ”adb logcat”



                                                 30
Add USB Vendor ID

   When connecting USB device, adb checks USB
    Vendor ID
   Many USB Vendor IDs are hard coded in adb.
    (But not enough)
   To add USB Vendor ID, make
    ”$HOME/.android/adb_usb.ini” and write one ID
    in one line
   See usb_vendors.c

                                                 31
Restriction of server socket of
       Android emulator
Other host                    Host




                                  Emulator
   Adb clients                                                    Adb clients


         TCP port:5037                     Adbd                          TCP port:5037

                                                            TCP
   Adb server                                                     Adb server
                                          QEMU




       All server sockets in Android emulator accepts only from localhost.
       If you feel inconvenient in this restriction, apply the patch in next page.
        http://blog.kmckk.com/archives/3882865.html                                      32
Patch to allow connecting from
   outside (for experiment)
external/qemu
diff --git a/slirp-android/socket.c b/slirp-android/socket.c
index 439590a..ed16d5a 100644
--- a/slirp-android/socket.c
+++ b/slirp-android/socket.c
@@ -650,7 +650,7 @@ solisten(u_int port, u_int32_t laddr, u_int lport, int
flags)
     so->so_laddr_ip   = laddr; /* Ditto */
     so->so_haddr_port = port;

-    s = socket_loopback_server( port, SOCKET_STREAM );
+    s = socket_inaddr_any_server( port, SOCKET_STREAM );
     if (s < 0)
         return NULL;

diff --git a/sockets.c b/sockets.c
index 1063339..55b5d57 100644
--- a/sockets.c
+++ b/sockets.c
@@ -1337,6 +1337,11 @@ socket_in_client( SockAddress*      to, SocketType   type )
     return socket_connect_client( s, to );
 }

+int
+socket_inaddr_any_server( int port, SocketType type )
+{
+    return socket_in_server( INADDR_ANY, port, type );
+}

 int                                                                                 33
 socket_loopback_server( int   port, SocketType   type )
Similar restriction in server
socket created by ”adb forward”

                           adb forward tcp:1234 tcp:1234
Other host     Host                            Target device
                      server socket
                      port 1234


                                       Transport          client socket
      client
                                      USB or TCP          port 1234




                                From localhost only

                                                                          34
Patch to allow connecting from
    outside (for experiment)
system/core
diff --git a/adb/adb.c b/adb/adb.c
index f5e6e0c..1405e1c 100644
--- a/adb/adb.c
+++ b/adb/adb.c
@@ -481,7 +481,8 @@ int local_name_to_fd(const char *name)
      if(!strncmp("tcp:", name, 4)){
            int ret;
            port = atoi(name + 4);
-           ret = socket_loopback_server(port, SOCK_STREAM);
+           ret = socket_inaddr_any_server(port, SOCK_STREAM);
            return ret;
      }
  #ifndef HAVE_WIN32_IPC /* no Unix-domain sockets on Win32 */
Advanced Topics

   adb in Android device
   Port adbd to other than Android




                                      36
adb in Android device

   Usually, adb is running on the host side,
    such as Linux, MacOS and Windows
   In Android 4.0 there is /system/bin/adb in
    Android file system
   What for is this?




                                                 37
Connect its own adbd by adb
   Restart adbd in TCP mode
   Then type ”adb devices”
   It can connect its own adbd by local loop back

           Target device

                                 Adb clients            But what is
                                                       the use case?


                                       TCP port:5038

                           TCP
              Adbd               Adb server



         http://blog.kmckk.com/archives/4092970.html                   38
Connect other Android device by
             adb on Android
NexusOne
(Android 2.3.6)                 USB Host
                                (A connector)




 USB device                                            KZM-A9-Dual board
 (micro B connector)                                   (Android 4.0.3)




                   http://blog.kmckk.com/archives/4094716.html
                                                                           39
Connect other Android device by
    adb on Android(cont.)
 At the serial console on KZM-A9-Dual board
     # adb devices
     * daemon not running. starting it now on port 5038 *
     * daemon started successfully *
     List of devices attached
     HT015P803242 device

     #

 It worked!
 You can do ”adb shell”, ”adb logcat”, too.

 Even you can install application from the board
 to NexusOne by ”adb install foo.apk”.
                                                            40
Port adbd to other than Android

   Quick hack!
   Consider dependency for better porting




                     ARM Ubuntu 11.10
                      ARM Ubuntu 11.10
                                         Adbd




                  Kernel with Android patch
                   Kernel with Android patch
                                                41
Quick hack!

   /sbin/adbd is statically linked executable.
   Just copy this file to ARM Ubuntu 11.10 just for
    experiment (using Android patched kernel)
   Somehow, it worked without any recompilation
        sudo chmod 666 /dev/android_adb*
        make symbolic link /bin/sh to /system/bin/sh
        adbd runs in secure mode
        It worked ”adb shell”, ”adb push/pull”
   http://blog.kmckk.com/archives/4093193.html
                                                        42
Consider dependency for better
               porting
   Some service requires other android
    commands
        adb install/uninstall, adb bugreport
        framebuffer service invokes /system/bin/screencap
   Adbd uses Android system properties
        At the binary experiment, all property_get returns
         default values.
                    That's why adbd ran in secure mode.
   Switching adbd mode assumes that init restarts
    adbd process
                                                              43
Q&A




Thank you for listening!
Any comments to blogs are welcome.

                                     44

More Related Content

What's hot

Understanding the Android System Server
Understanding the Android System ServerUnderstanding the Android System Server
Understanding the Android System ServerOpersys inc.
 
Overview of Android binder IPC implementation
Overview of Android binder IPC implementationOverview of Android binder IPC implementation
Overview of Android binder IPC implementationChethan Pchethan
 
Android Open Accessory Protocol - Turn Your Linux machine as ADK
Android Open Accessory Protocol - Turn Your Linux machine as ADKAndroid Open Accessory Protocol - Turn Your Linux machine as ADK
Android Open Accessory Protocol - Turn Your Linux machine as ADKRajesh Sola
 
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)Nanik Tolaram
 
Learning AOSP - Android Booting Process
Learning AOSP - Android Booting ProcessLearning AOSP - Android Booting Process
Learning AOSP - Android Booting ProcessNanik Tolaram
 
Q4.11: Porting Android to new Platforms
Q4.11: Porting Android to new PlatformsQ4.11: Porting Android to new Platforms
Q4.11: Porting Android to new PlatformsLinaro
 
Accessing Hardware on Android
Accessing Hardware on AndroidAccessing Hardware on Android
Accessing Hardware on AndroidGary Bisson
 
Android Security Internals
Android Security InternalsAndroid Security Internals
Android Security InternalsOpersys inc.
 
Android Operating System
Android Operating SystemAndroid Operating System
Android Operating SystemBilal Mirza
 

What's hot (20)

Android Audio System
Android Audio SystemAndroid Audio System
Android Audio System
 
Embedded Android : System Development - Part II (Linux device drivers)
Embedded Android : System Development - Part II (Linux device drivers)Embedded Android : System Development - Part II (Linux device drivers)
Embedded Android : System Development - Part II (Linux device drivers)
 
Understanding the Android System Server
Understanding the Android System ServerUnderstanding the Android System Server
Understanding the Android System Server
 
Overview of Android binder IPC implementation
Overview of Android binder IPC implementationOverview of Android binder IPC implementation
Overview of Android binder IPC implementation
 
Android Open Accessory Protocol - Turn Your Linux machine as ADK
Android Open Accessory Protocol - Turn Your Linux machine as ADKAndroid Open Accessory Protocol - Turn Your Linux machine as ADK
Android Open Accessory Protocol - Turn Your Linux machine as ADK
 
Android Internals
Android InternalsAndroid Internals
Android Internals
 
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
 
Android Binder: Deep Dive
Android Binder: Deep DiveAndroid Binder: Deep Dive
Android Binder: Deep Dive
 
Power Management from Linux Kernel to Android
Power Management from Linux Kernel to AndroidPower Management from Linux Kernel to Android
Power Management from Linux Kernel to Android
 
Learning AOSP - Android Booting Process
Learning AOSP - Android Booting ProcessLearning AOSP - Android Booting Process
Learning AOSP - Android Booting Process
 
Q4.11: Porting Android to new Platforms
Q4.11: Porting Android to new PlatformsQ4.11: Porting Android to new Platforms
Q4.11: Porting Android to new Platforms
 
Embedded Android : System Development - Part I
Embedded Android : System Development - Part IEmbedded Android : System Development - Part I
Embedded Android : System Development - Part I
 
Accessing Hardware on Android
Accessing Hardware on AndroidAccessing Hardware on Android
Accessing Hardware on Android
 
Direct X
Direct XDirect X
Direct X
 
Android Security Internals
Android Security InternalsAndroid Security Internals
Android Security Internals
 
Embedded Android : System Development - Part IV (Android System Services)
Embedded Android : System Development - Part IV (Android System Services)Embedded Android : System Development - Part IV (Android System Services)
Embedded Android : System Development - Part IV (Android System Services)
 
Binder: Android IPC
Binder: Android IPCBinder: Android IPC
Binder: Android IPC
 
Init of Android
Init of AndroidInit of Android
Init of Android
 
Android Operating System
Android Operating SystemAndroid Operating System
Android Operating System
 
Embedded C
Embedded CEmbedded C
Embedded C
 

Viewers also liked

Android Logging System
Android Logging SystemAndroid Logging System
Android Logging SystemWilliam Lee
 
Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Using and Customizing the Android Framework / part 4 of Embedded Android Work...Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Using and Customizing the Android Framework / part 4 of Embedded Android Work...Opersys inc.
 
Android crash debugging
Android crash debuggingAndroid crash debugging
Android crash debuggingAshish Agrawal
 
Tricky implementation of Go ARM soft float
Tricky implementation of Go ARM soft floatTricky implementation of Go ARM soft float
Tricky implementation of Go ARM soft floatTetsuyuki Kobayashi
 
Android Development: The Basics
Android Development: The BasicsAndroid Development: The Basics
Android Development: The BasicsMike Desjardins
 
Hierarchy Viewer Internals
Hierarchy Viewer InternalsHierarchy Viewer Internals
Hierarchy Viewer InternalsKyungmin Lee
 
Android Crash analysis and The Dalvik Garbage collector – Tools and Tips
Android Crash analysis and The Dalvik Garbage collector – Tools and TipsAndroid Crash analysis and The Dalvik Garbage collector – Tools and Tips
Android Crash analysis and The Dalvik Garbage collector – Tools and TipsDroidConTLV
 
Using QEMU for cross development
Using QEMU for cross developmentUsing QEMU for cross development
Using QEMU for cross developmentTetsuyuki Kobayashi
 
Asian development bank
Asian development bank Asian development bank
Asian development bank Suneil Kumar
 
Basic of virtual memory of Linux
Basic of virtual memory of LinuxBasic of virtual memory of Linux
Basic of virtual memory of LinuxTetsuyuki Kobayashi
 
Android Overview
Android OverviewAndroid Overview
Android Overviewatomi
 
Asian development bank (ADB) - International Business - Manu Melwin Joy
Asian development bank (ADB) - International Business - Manu Melwin JoyAsian development bank (ADB) - International Business - Manu Melwin Joy
Asian development bank (ADB) - International Business - Manu Melwin Joymanumelwin
 
Functions of ADB
Functions of ADBFunctions of ADB
Functions of ADBVaishakh PV
 
Introduction to android
Introduction to androidIntroduction to android
Introduction to androidzeelpatel0504
 

Viewers also liked (20)

Adb Commands
Adb CommandsAdb Commands
Adb Commands
 
Android Debug
Android DebugAndroid Debug
Android Debug
 
Android Logging System
Android Logging SystemAndroid Logging System
Android Logging System
 
Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Using and Customizing the Android Framework / part 4 of Embedded Android Work...Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Using and Customizing the Android Framework / part 4 of Embedded Android Work...
 
Android crash debugging
Android crash debuggingAndroid crash debugging
Android crash debugging
 
Tricky implementation of Go ARM soft float
Tricky implementation of Go ARM soft floatTricky implementation of Go ARM soft float
Tricky implementation of Go ARM soft float
 
Android Development: The Basics
Android Development: The BasicsAndroid Development: The Basics
Android Development: The Basics
 
Hierarchy Viewer Internals
Hierarchy Viewer InternalsHierarchy Viewer Internals
Hierarchy Viewer Internals
 
Tips of Malloc & Free
Tips of Malloc & FreeTips of Malloc & Free
Tips of Malloc & Free
 
Android Crash analysis and The Dalvik Garbage collector – Tools and Tips
Android Crash analysis and The Dalvik Garbage collector – Tools and TipsAndroid Crash analysis and The Dalvik Garbage collector – Tools and Tips
Android Crash analysis and The Dalvik Garbage collector – Tools and Tips
 
Using QEMU for cross development
Using QEMU for cross developmentUsing QEMU for cross development
Using QEMU for cross development
 
Discover System Facilities inside Your Android Phone
Discover System Facilities inside Your Android Phone Discover System Facilities inside Your Android Phone
Discover System Facilities inside Your Android Phone
 
Logging system of Android
Logging system of AndroidLogging system of Android
Logging system of Android
 
Asian development bank
Asian development bank Asian development bank
Asian development bank
 
Basic of virtual memory of Linux
Basic of virtual memory of LinuxBasic of virtual memory of Linux
Basic of virtual memory of Linux
 
Android Overview
Android OverviewAndroid Overview
Android Overview
 
Asian development bank (ADB) - International Business - Manu Melwin Joy
Asian development bank (ADB) - International Business - Manu Melwin JoyAsian development bank (ADB) - International Business - Manu Melwin Joy
Asian development bank (ADB) - International Business - Manu Melwin Joy
 
Functions of ADB
Functions of ADBFunctions of ADB
Functions of ADB
 
Android ipm 20110409
Android ipm 20110409Android ipm 20110409
Android ipm 20110409
 
Introduction to android
Introduction to androidIntroduction to android
Introduction to android
 

Similar to ADB(Android Debug Bridge): How it works?

Talks on adb - Day 2 (pdf version)
Talks on adb - Day 2 (pdf version)Talks on adb - Day 2 (pdf version)
Talks on adb - Day 2 (pdf version)Kangho Kim
 
drbd9_and_drbdmanage_may_2015
drbd9_and_drbdmanage_may_2015drbd9_and_drbdmanage_may_2015
drbd9_and_drbdmanage_may_2015Alexandre Huynh
 
Cloud Foundry Open Tour China
Cloud Foundry Open Tour ChinaCloud Foundry Open Tour China
Cloud Foundry Open Tour Chinamarklucovsky
 
OSDC 2015: Roland Kammerer | DRBD9: Managing High-Available Storage in Many-N...
OSDC 2015: Roland Kammerer | DRBD9: Managing High-Available Storage in Many-N...OSDC 2015: Roland Kammerer | DRBD9: Managing High-Available Storage in Many-N...
OSDC 2015: Roland Kammerer | DRBD9: Managing High-Available Storage in Many-N...NETWAYS
 
Making kubernetes simple for developers
Making kubernetes simple for developersMaking kubernetes simple for developers
Making kubernetes simple for developersSuraj Deshmukh
 
Cloud Foundry Open Tour China (english)
Cloud Foundry Open Tour China (english)Cloud Foundry Open Tour China (english)
Cloud Foundry Open Tour China (english)marklucovsky
 
Getting Distributed (With Ruby On Rails)
Getting Distributed (With Ruby On Rails)Getting Distributed (With Ruby On Rails)
Getting Distributed (With Ruby On Rails)martinbtt
 
Microservices on Kubernetes - The simple way
Microservices on Kubernetes - The simple wayMicroservices on Kubernetes - The simple way
Microservices on Kubernetes - The simple waySuraj Deshmukh
 
State of Containers and the Convergence of HPC and BigData
State of Containers and the Convergence of HPC and BigDataState of Containers and the Convergence of HPC and BigData
State of Containers and the Convergence of HPC and BigDatainside-BigData.com
 
DevEx | there’s no place like k3s
DevEx | there’s no place like k3sDevEx | there’s no place like k3s
DevEx | there’s no place like k3sHaggai Philip Zagury
 
Distributed Ruby and Rails
Distributed Ruby and RailsDistributed Ruby and Rails
Distributed Ruby and RailsWen-Tien Chang
 
Scale Out Your Graph Across Servers and Clouds with OrientDB
Scale Out Your Graph Across Servers and Clouds  with OrientDBScale Out Your Graph Across Servers and Clouds  with OrientDB
Scale Out Your Graph Across Servers and Clouds with OrientDBLuca Garulli
 
Writing mruby Debugger
Writing mruby DebuggerWriting mruby Debugger
Writing mruby Debuggeryamanekko
 
AWS Community Day 2022 Dhiraj Mahapatro_AWS Lambda under the hood _ Best Prac...
AWS Community Day 2022 Dhiraj Mahapatro_AWS Lambda under the hood _ Best Prac...AWS Community Day 2022 Dhiraj Mahapatro_AWS Lambda under the hood _ Best Prac...
AWS Community Day 2022 Dhiraj Mahapatro_AWS Lambda under the hood _ Best Prac...AWS Chicago
 
OrientDB & Hazelcast: In-Memory Distributed Graph Database
 OrientDB & Hazelcast: In-Memory Distributed Graph Database OrientDB & Hazelcast: In-Memory Distributed Graph Database
OrientDB & Hazelcast: In-Memory Distributed Graph DatabaseHazelcast
 
DockerCon EU '17 - Dockerizing Aurea
DockerCon EU '17 - Dockerizing AureaDockerCon EU '17 - Dockerizing Aurea
DockerCon EU '17 - Dockerizing AureaŁukasz Piątkowski
 
HKG15-300: Art's Quick Compiler: An unofficial overview
HKG15-300: Art's Quick Compiler: An unofficial overviewHKG15-300: Art's Quick Compiler: An unofficial overview
HKG15-300: Art's Quick Compiler: An unofficial overviewLinaro
 
Drbd9 and drbdmanage_june_2016
Drbd9 and drbdmanage_june_2016Drbd9 and drbdmanage_june_2016
Drbd9 and drbdmanage_june_2016Philipp Reisner
 

Similar to ADB(Android Debug Bridge): How it works? (20)

Talks on adb - Day 2 (pdf version)
Talks on adb - Day 2 (pdf version)Talks on adb - Day 2 (pdf version)
Talks on adb - Day 2 (pdf version)
 
drbd9_and_drbdmanage_may_2015
drbd9_and_drbdmanage_may_2015drbd9_and_drbdmanage_may_2015
drbd9_and_drbdmanage_may_2015
 
Cloud Foundry Open Tour China
Cloud Foundry Open Tour ChinaCloud Foundry Open Tour China
Cloud Foundry Open Tour China
 
OSDC 2015: Roland Kammerer | DRBD9: Managing High-Available Storage in Many-N...
OSDC 2015: Roland Kammerer | DRBD9: Managing High-Available Storage in Many-N...OSDC 2015: Roland Kammerer | DRBD9: Managing High-Available Storage in Many-N...
OSDC 2015: Roland Kammerer | DRBD9: Managing High-Available Storage in Many-N...
 
Making kubernetes simple for developers
Making kubernetes simple for developersMaking kubernetes simple for developers
Making kubernetes simple for developers
 
Cloud Foundry Open Tour China (english)
Cloud Foundry Open Tour China (english)Cloud Foundry Open Tour China (english)
Cloud Foundry Open Tour China (english)
 
Getting Distributed (With Ruby On Rails)
Getting Distributed (With Ruby On Rails)Getting Distributed (With Ruby On Rails)
Getting Distributed (With Ruby On Rails)
 
sdafdsf
sdafdsfsdafdsf
sdafdsf
 
Microservices on Kubernetes - The simple way
Microservices on Kubernetes - The simple wayMicroservices on Kubernetes - The simple way
Microservices on Kubernetes - The simple way
 
State of Containers and the Convergence of HPC and BigData
State of Containers and the Convergence of HPC and BigDataState of Containers and the Convergence of HPC and BigData
State of Containers and the Convergence of HPC and BigData
 
Kubernetes
KubernetesKubernetes
Kubernetes
 
DevEx | there’s no place like k3s
DevEx | there’s no place like k3sDevEx | there’s no place like k3s
DevEx | there’s no place like k3s
 
Distributed Ruby and Rails
Distributed Ruby and RailsDistributed Ruby and Rails
Distributed Ruby and Rails
 
Scale Out Your Graph Across Servers and Clouds with OrientDB
Scale Out Your Graph Across Servers and Clouds  with OrientDBScale Out Your Graph Across Servers and Clouds  with OrientDB
Scale Out Your Graph Across Servers and Clouds with OrientDB
 
Writing mruby Debugger
Writing mruby DebuggerWriting mruby Debugger
Writing mruby Debugger
 
AWS Community Day 2022 Dhiraj Mahapatro_AWS Lambda under the hood _ Best Prac...
AWS Community Day 2022 Dhiraj Mahapatro_AWS Lambda under the hood _ Best Prac...AWS Community Day 2022 Dhiraj Mahapatro_AWS Lambda under the hood _ Best Prac...
AWS Community Day 2022 Dhiraj Mahapatro_AWS Lambda under the hood _ Best Prac...
 
OrientDB & Hazelcast: In-Memory Distributed Graph Database
 OrientDB & Hazelcast: In-Memory Distributed Graph Database OrientDB & Hazelcast: In-Memory Distributed Graph Database
OrientDB & Hazelcast: In-Memory Distributed Graph Database
 
DockerCon EU '17 - Dockerizing Aurea
DockerCon EU '17 - Dockerizing AureaDockerCon EU '17 - Dockerizing Aurea
DockerCon EU '17 - Dockerizing Aurea
 
HKG15-300: Art's Quick Compiler: An unofficial overview
HKG15-300: Art's Quick Compiler: An unofficial overviewHKG15-300: Art's Quick Compiler: An unofficial overview
HKG15-300: Art's Quick Compiler: An unofficial overview
 
Drbd9 and drbdmanage_june_2016
Drbd9 and drbdmanage_june_2016Drbd9 and drbdmanage_june_2016
Drbd9 and drbdmanage_june_2016
 

More from Tetsuyuki Kobayashi

Try new transport protocol SRT (ver. 2)
Try new transport protocol SRT  (ver. 2)Try new transport protocol SRT  (ver. 2)
Try new transport protocol SRT (ver. 2)Tetsuyuki Kobayashi
 
Raspberry Pi Zero とカメラモジュールで作るライブ配信実験機
Raspberry Pi Zero とカメラモジュールで作るライブ配信実験機Raspberry Pi Zero とカメラモジュールで作るライブ配信実験機
Raspberry Pi Zero とカメラモジュールで作るライブ配信実験機Tetsuyuki Kobayashi
 
WebOS Open Source Edition を試してみた
WebOS Open Source Edition を試してみたWebOS Open Source Edition を試してみた
WebOS Open Source Edition を試してみたTetsuyuki Kobayashi
 
Linuxのユーザーランドをinitから全てまるごとgolangで書く
Linuxのユーザーランドをinitから全てまるごとgolangで書くLinuxのユーザーランドをinitから全てまるごとgolangで書く
Linuxのユーザーランドをinitから全てまるごとgolangで書くTetsuyuki Kobayashi
 
組み込みLinuxでのGolangのススメ(Go con版)
組み込みLinuxでのGolangのススメ(Go con版)組み込みLinuxでのGolangのススメ(Go con版)
組み込みLinuxでのGolangのススメ(Go con版)Tetsuyuki Kobayashi
 
組み込みLinuxでのGolangのススメ
組み込みLinuxでのGolangのススメ組み込みLinuxでのGolangのススメ
組み込みLinuxでのGolangのススメTetsuyuki Kobayashi
 
Simple and efficient way to get the last log using MMAP
Simple and efficient way to get the last log using MMAPSimple and efficient way to get the last log using MMAP
Simple and efficient way to get the last log using MMAPTetsuyuki Kobayashi
 
Inter-process communication of Android
Inter-process communication of AndroidInter-process communication of Android
Inter-process communication of AndroidTetsuyuki Kobayashi
 
Android is NOT just 'Java on Linux'
Android is NOT just 'Java on Linux'Android is NOT just 'Java on Linux'
Android is NOT just 'Java on Linux'Tetsuyuki Kobayashi
 
Reusing your existing software on Android
Reusing your existing software on AndroidReusing your existing software on Android
Reusing your existing software on AndroidTetsuyuki Kobayashi
 

More from Tetsuyuki Kobayashi (20)

some topic of ffmpeg
some topic of ffmpeg some topic of ffmpeg
some topic of ffmpeg
 
New VIdeo CODEC AV1
New VIdeo CODEC AV1 New VIdeo CODEC AV1
New VIdeo CODEC AV1
 
Try new transport protocol SRT (ver. 2)
Try new transport protocol SRT  (ver. 2)Try new transport protocol SRT  (ver. 2)
Try new transport protocol SRT (ver. 2)
 
Try new transport protocol SRT
Try new transport protocol SRTTry new transport protocol SRT
Try new transport protocol SRT
 
Raspberry Pi Zero とカメラモジュールで作るライブ配信実験機
Raspberry Pi Zero とカメラモジュールで作るライブ配信実験機Raspberry Pi Zero とカメラモジュールで作るライブ配信実験機
Raspberry Pi Zero とカメラモジュールで作るライブ配信実験機
 
WebOS Open Source Edition を試してみた
WebOS Open Source Edition を試してみたWebOS Open Source Edition を試してみた
WebOS Open Source Edition を試してみた
 
Linuxのユーザーランドをinitから全てまるごとgolangで書く
Linuxのユーザーランドをinitから全てまるごとgolangで書くLinuxのユーザーランドをinitから全てまるごとgolangで書く
Linuxのユーザーランドをinitから全てまるごとgolangで書く
 
組み込みLinuxでのGolangのススメ(Go con版)
組み込みLinuxでのGolangのススメ(Go con版)組み込みLinuxでのGolangのススメ(Go con版)
組み込みLinuxでのGolangのススメ(Go con版)
 
組み込みLinuxでのGolangのススメ
組み込みLinuxでのGolangのススメ組み込みLinuxでのGolangのススメ
組み込みLinuxでのGolangのススメ
 
ARM 64bit has come!
ARM 64bit has come!ARM 64bit has come!
ARM 64bit has come!
 
Virtual memory 20070222-en
Virtual memory 20070222-enVirtual memory 20070222-en
Virtual memory 20070222-en
 
Simple and efficient way to get the last log using MMAP
Simple and efficient way to get the last log using MMAPSimple and efficient way to get the last log using MMAP
Simple and efficient way to get the last log using MMAP
 
Patch101
Patch101Patch101
Patch101
 
Tweaking Google TV emulator
Tweaking Google TV emulatorTweaking Google TV emulator
Tweaking Google TV emulator
 
Inter-process communication of Android
Inter-process communication of AndroidInter-process communication of Android
Inter-process communication of Android
 
Android is NOT just 'Java on Linux'
Android is NOT just 'Java on Linux'Android is NOT just 'Java on Linux'
Android is NOT just 'Java on Linux'
 
Android On Ubuntu for developer
Android On Ubuntu for developerAndroid On Ubuntu for developer
Android On Ubuntu for developer
 
Reusing your existing software on Android
Reusing your existing software on AndroidReusing your existing software on Android
Reusing your existing software on Android
 
Logging system of Android
Logging system of AndroidLogging system of Android
Logging system of Android
 
Froyo DalvikVM JIT
Froyo DalvikVM JITFroyo DalvikVM JIT
Froyo DalvikVM JIT
 

Recently uploaded

Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 

Recently uploaded (20)

Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 

ADB(Android Debug Bridge): How it works?

  • 1. ADB (Android Debug Bridge): How it works? 2012.2.13 Android Builders Summit Tetsuyuki Kobayashi 1
  • 2. Let's talk about inside of Android. http://www.kmckk.co.jp/eng/kzma9/ 2 http://www.kmckk.co.jp/eng/jet_index.html
  • 3. Who am I?  20+ years involved in embedded systems  10 years in real time OS, such as iTRON  10 years in embedded Java Virtual Machine  Now GCC, Linux, QEMU, Android, …  Blogs  http://d.hatena.ne.jp/embedded/ (Personal)  http://blog.kmckk.com/ (Corporate)  http://kobablog.wordpress.com/(English)  Twitter  @tetsu_koba 3
  • 4. Today's topics  What is ADB?  ADB internal  Command details & Tips  Advanced Topics 4
  • 5. What is ADB?  If you are an Android builder, you have used ”adb logcat”, ”adb shell”  Even if you only use DDMS in Eclipse, adb is working under the hood.  Using adb, you can connect emulator or actual target device.  ”adb kill-server”? what does it mean?
  • 6. How to connect? Host Target device Emulator Adb clients ”adb shell” Adbd How to connect? QEMU Adbd 6
  • 7. 3 elements of ADB  adb clients  executable with subcommand  ”adb shell”, ”adb logcat” : the end point of host side  adb server  running on host on back-ground  act as proxy between adb clients and adbd  adb daemon (adbd)  running on target device  started by init, if die, restarted by init again 7
  • 8. ADB overview Host Target device Execute services on Emulator new thread/subprocess Adb clients Adbd TCP port:5037 TCP Adb server USB/TCP Adbd QEMU 8
  • 9. 2 roles of ADB  Providing ”Transport”  communication path between host and target device  USB or TCP: but clients don't have to aware  Providing ”Services”  executing something on the target devices through the transport.  ”adb shell” for executing command  ”adb push/pull” for file transfer 9
  • 10. When does adb server start?  Explicitly, ”adb start-server”  It starts adb server as back ground process.  Usually it does automatically on demand. You don't have to do ”adb start-server”.  When you want to restart adb server, do ”adb kill-server”  Actually, adb clients and adb server shares same executable  ”adb start-server” equals ”adb fork-server server &” 10
  • 11. Port forwarding adb forward tcp:1234 tcp:1234 Host Target device Transport client socket server socket USB or TCP port 1234 port 1234 11
  • 12. Port forwarding (cont.) adb forward tcp:1234 tcp:1234 example: connecting to gdbserver in the device from gdb client from host Host Target device gdb client connect to localhost:1234 Transport client socket server socket USB or TCP port 1234 port 1234 listen to localhost:1234 Both gdb client and gdbserver gdbserver do not aware of transport 12
  • 13. ADB internal  Source code  How to get ADB logs  Sequence chart  Simple ruby script to connect adb server  Secure mode  Switching transport mode 13
  • 14. Source code  system/core/adb in Android source tree  16,000 lines in *.[ch]  From this directory adb and adbd are built  Don't confuse.  common files between adb and adbd  adb.c, fdevent.c, transort.c, transport_local.c, tansport_usb.c, service.c, sockets.c, util.c #if ADB_HOST /* code for adb*/ #else /* code for adbd */ #endif 14
  • 15. Source code(cont.)  files only for adbd  backup_service.c, file_sync_service.c, jdwp_service.c, framebuffer_service.c, remount_services.c, usb_linux_clients.c, log_service.c  files only for adb  console.c, adb_clients.c, file_sync_client.c, usb_vendors.c, get_my_path_{linux,darwin,windows,freebsd}.c, usb_{linux,macos,libusb,windows}.c  documents  OVERVIEW.TXT, SERVICES.TXT, protocol.txt 15
  • 16. How to get ADB logs  For adb clients and adb server, set environment variable ADB_TRACE  $ adb kill-server  $ ADB_TRACE=all start-server  For adbd, set system property ”persist.adb.trace_mask” in hexadecimal  # set_property persist.adb.trace_mask 0xfff  I found some trivial bugs. see below  http://blog.kmckk.com/archives/4080002.html 16  http://blog.kmckk.com/archives/4087230.html
  • 17. Sequence chart Adb client “adb shell ls” Adb server adbd host:version OKAY0004001d Check version host:transport-any Specify the OKAY destination shell:ls [OPEN]shell:ls Command subprocess to adbd [OPEN]shell:ls OKAY ls [WRITE]len=247 len=247 stdout len=247 17
  • 18. Simple ruby script to connect to adb server require 'socket' hostname = 'localhost' port = 5037 def error_exit puts "Error" s = TCPSocket.open(hostname, port) exit 1 send_to_adb(s, "host:version") end error_exit if ! check_version(s) s.close def send_to_adb(s, msg) s.printf("%04x%s", s = TCPSocket.open(hostname, port) msg.length, msg) send_to_adb(s, "host:transport-any") end error_exit if ! check_okay(s) send_to_adb(s, "shell:ls") def check_okay(s) error_exit if ! check_okay(s) (s.read(4) == "OKAY") end while line = s.gets puts line.chop def check_version(s) end (s.read(12) == s.close "OKAY0004001d") end change ”shell:ls” as you like. 18 http://blog.kmckk.com/archives/4092210.html
  • 19. Secure mode  Android smart phone products have adbd. Usually it runs on secure mode. (secure = 1)  if secure == 1, change adbd as SHELL user(= not privileged), else it keeps running as root user  In secure mode, all services invoked by adbd ran as SHELL user. Some causes ”permission denied”. 19
  • 20. How secure mode decided  Running on emulator → secure = 0  System property ”ro.secure” == 1 → secure = 1  if ”ro.debuggable” == 1, you can restart adb unsecure by ”adb root”  All Android phone products are shipped in ”ro.secure” = 1, ”ro.debuggable” = 0.  See adb.c: adb_main  http://blog.kmckk.com/archives/4099821.html 20
  • 21. Switching transport mode Switching USB mode to TCP mode $ adb shell netcfg lo UP 127.0.0.1 255.0.0.0 0x00000049 eth0 UP 192.168.1.139 255.255.255.0 0x00001043 $ adb tcpip 5555 restarting in TCP mode port : 5555 $ adb devices List of devices attached $ disconnected from USB. Then restart adb server with specifying target IP address. $ adb kill-server $ ADBHOST=192.168.1.139 adb devices * daemon not running. starting it now on port 5037 * * daemon started successfully * List of devices attached emulator-5554 device $ 21
  • 22. Switching transport mode (What happen inside?)  See service.c restart_tcp_service  property_set(”service.adb.tcp.port”, value);  Note: before Android 4.0, this cause ”permission denied” in secure mode and ignored silently!  After that, exit(1);  init restarts adbd.  ”service.adb.tcp.port” is checked in adb.c adb_main 22
  • 23. Patch to enable switching to TCP mode in secure Android 2.3 system/core/init/property_service.c $ diff -u property_service.c.2 property_service.c --- property_service.c.2 2012-02-07 18:40:34.472414791 +0900 +++ property_service.c 2012-02-07 18:41:24.782801630 +0900 @@ -79,6 +79,7 @@ { "debug.", AID_SHELL, 0 }, { "log.", AID_SHELL, 0 }, { "service.adb.root", AID_SHELL, 0 }, + { "service.adb.tcp.port", AID_SHELL, 0 }, { "persist.sys.", AID_SYSTEM, 0 }, { "persist.service.", AID_SYSTEM, 0 }, { "persist.security.", AID_SYSTEM, 0 }, This avoids ”permission denied” when set property ”service.adb.tcp.port”. http://blog.kmckk.com/archives/4098873.html
  • 24. Command details & Tips  adb logcat  adb install/uninstall  adb reboot/reboot-bootloader  adb emu  adb backup/restore  Joke commands  Add USB vendor ID  Restriction of server socket of Android emulator  Similar restriction in server socket created by ”adb forward” 24
  • 25. adb logcat  There is ”log:” subcommand in adb server, but ”adb logcat” doesn't use it  ”adb logcat” executes /system/bin/logcat remotely  Tag filtering is done in target side  Logging in DDMS filtering in host side  similar to ”adb shell ANDROID_LOG_TAGS=$ANDORID_LOG_TAGS logcat args..” 25
  • 26. adb install/uninstall  adb install  transfer apk file and then execute /system/bin/pm at the device  adb uninstall  just execute /system/bin/pm remotely
  • 27. adb reboot/reboot-bootloader  fork&exec /system/bin/vdc to unmount storage  wait for the process and then reboot by system call
  • 28. adb emu  You can send a single command to emulator console easily  send only. can not receive.  For emulator console,  http://developer.android.com/guide/developing/devices/emulator.html  Simple example. ”adb emu window scale 0.5” after starting emulator  http://blog.kmckk.com/archives/4091258.html 28
  • 29. adb backup/restore  New in Android 4.0  You can backup/restore installed applications with their saved status. 29
  • 30. Joke commands  adb hell  same as ”adb shell” except ”hell” color :)  Just try.  adb lolcat  same as ”adb logcat” 30
  • 31. Add USB Vendor ID  When connecting USB device, adb checks USB Vendor ID  Many USB Vendor IDs are hard coded in adb. (But not enough)  To add USB Vendor ID, make ”$HOME/.android/adb_usb.ini” and write one ID in one line  See usb_vendors.c 31
  • 32. Restriction of server socket of Android emulator Other host Host Emulator Adb clients Adb clients TCP port:5037 Adbd TCP port:5037 TCP Adb server Adb server QEMU All server sockets in Android emulator accepts only from localhost. If you feel inconvenient in this restriction, apply the patch in next page. http://blog.kmckk.com/archives/3882865.html 32
  • 33. Patch to allow connecting from outside (for experiment) external/qemu diff --git a/slirp-android/socket.c b/slirp-android/socket.c index 439590a..ed16d5a 100644 --- a/slirp-android/socket.c +++ b/slirp-android/socket.c @@ -650,7 +650,7 @@ solisten(u_int port, u_int32_t laddr, u_int lport, int flags) so->so_laddr_ip = laddr; /* Ditto */ so->so_haddr_port = port; - s = socket_loopback_server( port, SOCKET_STREAM ); + s = socket_inaddr_any_server( port, SOCKET_STREAM ); if (s < 0) return NULL; diff --git a/sockets.c b/sockets.c index 1063339..55b5d57 100644 --- a/sockets.c +++ b/sockets.c @@ -1337,6 +1337,11 @@ socket_in_client( SockAddress* to, SocketType type ) return socket_connect_client( s, to ); } +int +socket_inaddr_any_server( int port, SocketType type ) +{ + return socket_in_server( INADDR_ANY, port, type ); +} int 33 socket_loopback_server( int port, SocketType type )
  • 34. Similar restriction in server socket created by ”adb forward” adb forward tcp:1234 tcp:1234 Other host Host Target device server socket port 1234 Transport client socket client USB or TCP port 1234 From localhost only 34
  • 35. Patch to allow connecting from outside (for experiment) system/core diff --git a/adb/adb.c b/adb/adb.c index f5e6e0c..1405e1c 100644 --- a/adb/adb.c +++ b/adb/adb.c @@ -481,7 +481,8 @@ int local_name_to_fd(const char *name) if(!strncmp("tcp:", name, 4)){ int ret; port = atoi(name + 4); - ret = socket_loopback_server(port, SOCK_STREAM); + ret = socket_inaddr_any_server(port, SOCK_STREAM); return ret; } #ifndef HAVE_WIN32_IPC /* no Unix-domain sockets on Win32 */
  • 36. Advanced Topics  adb in Android device  Port adbd to other than Android 36
  • 37. adb in Android device  Usually, adb is running on the host side, such as Linux, MacOS and Windows  In Android 4.0 there is /system/bin/adb in Android file system  What for is this? 37
  • 38. Connect its own adbd by adb  Restart adbd in TCP mode  Then type ”adb devices”  It can connect its own adbd by local loop back Target device Adb clients But what is the use case? TCP port:5038 TCP Adbd Adb server http://blog.kmckk.com/archives/4092970.html 38
  • 39. Connect other Android device by adb on Android NexusOne (Android 2.3.6) USB Host (A connector) USB device KZM-A9-Dual board (micro B connector) (Android 4.0.3) http://blog.kmckk.com/archives/4094716.html 39
  • 40. Connect other Android device by adb on Android(cont.) At the serial console on KZM-A9-Dual board # adb devices * daemon not running. starting it now on port 5038 * * daemon started successfully * List of devices attached HT015P803242 device # It worked! You can do ”adb shell”, ”adb logcat”, too. Even you can install application from the board to NexusOne by ”adb install foo.apk”. 40
  • 41. Port adbd to other than Android  Quick hack!  Consider dependency for better porting ARM Ubuntu 11.10 ARM Ubuntu 11.10 Adbd Kernel with Android patch Kernel with Android patch 41
  • 42. Quick hack!  /sbin/adbd is statically linked executable.  Just copy this file to ARM Ubuntu 11.10 just for experiment (using Android patched kernel)  Somehow, it worked without any recompilation  sudo chmod 666 /dev/android_adb*  make symbolic link /bin/sh to /system/bin/sh  adbd runs in secure mode  It worked ”adb shell”, ”adb push/pull”  http://blog.kmckk.com/archives/4093193.html 42
  • 43. Consider dependency for better porting  Some service requires other android commands  adb install/uninstall, adb bugreport  framebuffer service invokes /system/bin/screencap  Adbd uses Android system properties  At the binary experiment, all property_get returns default values.  That's why adbd ran in secure mode.  Switching adbd mode assumes that init restarts adbd process 43
  • 44. Q&A Thank you for listening! Any comments to blogs are welcome. 44