SlideShare a Scribd company logo
1 of 34
Download to read offline
Android
ADB
Hello!I am Yossi Gruner
Agenda
▣ what is adb
▣ adb commands
▣ adb scripts
▣ adb files
▣ adb over WiFi
▣ screen capture/record
▣ logcat
▣ shell command
□ am
□ pm
□ dumpsys
□ more…
What is ADB
What is ADB
▣ Android Debug Bridge (adb) is a versatile command
line tool that lets you communicate with an emulator
instance or connected Android-powered device.
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
How it connect
How it connect
ADB Commands
▣ adb devices
□ Print All the connected devices
▣ adb shell
□ run remote shell interactively
▣ adb jdwp
□ list PIDs of processes hosting a JDWP transport
▣ adb install/uninstall
□ un/install the application
▣ adb start-server
□ ensure that there is a server running
▣ adb kill-server
□ kill the server if it is running
Adb scripts
▣ adb wait-for-device
□ block until device is online
▣ adb start-server
□ ensure that there is a server running
▣ adb kill-server
□ kill the server if it is running
▣ adb get-state
□ prints: offline | bootloader | device
▣ adb get-serialno
□ prints: <serial-number>
▣ adb get-devpath
□ prints: <device-path>
Adb scripts
▣ adb status-window
□ continuously print device status for a specified device
▣ adb remount
□ remounts the /system and /vendor (if present) partitions on
the device read-write
▣ adb reboot [bootloader|recovery]
□ reboots the device, optionally into the bootloader or
recovery program
▣ adb reboot-bootloader -
□ reboots the device into the bootloader
▣ adb root
□ restarts the adbd daemon with root permissions
▣ adb usb
□ restarts the adbd daemon listening on USB
Adb - Files
▣ Copy file to device
□ adb push <local> <remote>
▣ Copy file from device
□ adb pull <remote> <local>
adb over WiFi
▣ Android Device
□ adb shell netcfg
 get the android IP address (x.x.x.x)
□ adb shell setprop service.adb.tcp.port 5555
□ adb shell stop adbd && start adbd
▣ PC device
□ adb connect x.x.x.x
□ adb -s x.x.x.x:5555 logcat
□ adb -s x.x.x.x:5555 logcat |grep -vE "/dalvik"
□ adb -s x.x.x.x:5555 shell
BugReport
▣ Command
□ adb shell bugreport > bugreport.txt
□ java -jar chkbugreport.jar bugreport.txt
▣ JAR download
□ https://github.com/sonyxperiadev/ChkBugReport/download
s
ScreenCapture
▣ Command:
□ adb shell screencap -p /sdcard/screen.png
□ adb pull /sdcard/screen.png
□ adb shell rm /sdcard/screen.png
▣ Other way
□ adb shell screencap -p | sed 's/r$//' > screen.png
□ adb shell screencap -p | perl -pe 's/x0Dx0A/x0A/g' >
screen.png
ScreenRecord
▣ Command:
□ adb shell screenrecord /sdcard/recording.mp4
□ adb pull /sdcard/recording.mp4
□ adb shell rm /sdcard/recording.mp4
Adb Key Event
▣ Power Button
□ adb shell input keyevent 26
▣ Unlock screen
□ adb shell input keyevent 82
▣ Volume down
□ adb shell input keyevent 25
▣ List of Keyevent
□ http://developer.android.com/reference/android/view/KeyEv
ent.html
Logcat - Logging
▣ Filter by tagname
□ adb logcat -s TAG_NAME
□ adb logcat -s TAG_NAME_1 TAG_NAME_2
▣ Filter by priority
□ adb logcat "*:PRIORITY"
 V - Verbose (lowest priority)
 D - Debug
 I - Info
 W - Warning
 E - Error
 F - Fatal
 S - Silent (highest priority, on which nothing is ever
printed)
Logcat - Logging
▣ Filter using grep
□ adb logcat | grep "SEARCH_TERM"
□ Example
 adb logcat | grep "Exception"
▣ Clearing the logcat buffer
□ adb logcat -c
Logcat - Buffers
▣ radio - adb command “”
□ View the buffer that contains radio/telephony related
messages.
▣ events
□ View the buffer containing events-related messages.
▣ main
□ View the main log buffer (default)
Run Command “logcat -b <buffer>”
Shell Commands
▣ dumpstate
□ Dumps state to a file.
▣ dmesg
□ Prints kernel debugging messages to the screen
▣ start
□ Starts an emulator/device instance.
▣ stop
□ Stops execution of an emulator/device instance.
▣ restart
□ restart an emulator/device instance.
Shell Commands
▣ top
□ Prints all the running tasks on your device
▣ Service
□ Help to communicate with phone services
 service list
 service check <SERVICE_NAME>
 service call <SERVICE_NAME> CODE
Shell Commands - More
▣ More Commands
□ adb shell ls /system/bin
AM - Activity Manager
▣ Start Activity
□ am start <packageName/.ActivityClass>
▣ Start/Stop Service
□ am startservice -n <packageName/.ServiceClass>
□ am stopservice -n <packageName/.ServiceClass>
▣ Send broadcast
□ am broadcast -a <action_name>
▣ Users
□ am switch-user <USER_ID>
□ am start-user <USER_ID>
□ am stop-user <USER_ID>
▣ More Commands
▣ adb shell am
PM - Package Manager
▣ pm list packages
▣ pm list permission-groups
▣ pm list users
▣ pm install
▣ pm create-user
▣ pm remove-user USER_ID
▣ pm get-max-users
▣ More Commands
▣ adb shell pm
Dumpsys
▣ dumpsys
□ will show all system data from the device
▣ you can filter it by adding
□ dumpsys activity
□ dumpsys batterystats
□ dumpsys cpuinfo
□ dumpsys wifi
□ dumpsys meminfo
□ dumpsys package ‘package’
▣ More:
□ adb shell dumpsys -l
Joke commands
▣ adb hell
□ same as ”adb shell” except ”hell” color :)
▣ adb lolcat
□ same as ”adb logcat”
Task #1
1. Open Settings Application
a. main application
2. Open Settings In Inner Activity
a. WifiSettings
Task #2
1. Get System Application to pc
a. Dialer.apk
Task #3
1. Open my Application with intent and extra
a. extra keys
i. string
ii. bool
iii. float
iv. string_array
▣ Download Apk
□ https://goo.gl/IWTGle
▣ Code reference
□ https://github.com/yossigruner/AdbSession
Task #4
1. enable the NFC
2. disable the NFC
Answers
▣ Task #1
□ adb shell am start -S com.android.settings/com.android.settings.Settings
□ adb shell am start -a android.intent.action.MAIN -n
com.android.settings/.wifi.WifiSettings
▣ Task #2
□ adb root
□ adb remount
□ adb pull /system/priv-app/Dialer/Dialer.apk
▣ Task #3
□ adb shell am start -n com.mike.adbsession/com.mike.adbsession.MainActivity --ez
bool false --ef float 1.999 --es string hello --esa string_array hello,world
▣ Task #4
□ enable - service call nfc 6
□ disable - service call nfc 5
References
▣ https://community.woodwing.net/sites/default/files/A
ndroid%20Debug%20Bridge%20%7C%20Android%
20Developers.pdf
▣ https://source.android.com/devices/tech/debug/dum
psys.html
Thanks!Any questions?
yossigruner@gmail.com

More Related Content

What's hot

Manipulating Android tasks and back stack
Manipulating Android tasks and back stackManipulating Android tasks and back stack
Manipulating Android tasks and back stackRan Nachmany
 
Android booting sequece and setup and debugging
Android booting sequece and setup and debuggingAndroid booting sequece and setup and debugging
Android booting sequece and setup and debuggingUtkarsh Mankad
 
Tk2323 lecture 1 introduction to mobile application
Tk2323 lecture 1   introduction to mobile applicationTk2323 lecture 1   introduction to mobile application
Tk2323 lecture 1 introduction to mobile applicationMengChun Lam
 
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.
 
OpenVAS: Vulnerability Assessment Scanner
OpenVAS: Vulnerability Assessment ScannerOpenVAS: Vulnerability Assessment Scanner
OpenVAS: Vulnerability Assessment ScannerChandrak Trivedi
 
Automation With Appium
Automation With AppiumAutomation With Appium
Automation With AppiumKnoldus Inc.
 
Android SDK Tutorial | Edureka
Android SDK Tutorial | EdurekaAndroid SDK Tutorial | Edureka
Android SDK Tutorial | EdurekaEdureka!
 
Introduction to Android ppt
Introduction to Android pptIntroduction to Android ppt
Introduction to Android pptTaha Malampatti
 
Audio in linux embedded
Audio in linux embeddedAudio in linux embedded
Audio in linux embeddedtrx2001
 
Learning AOSP - Android Booting Process
Learning AOSP - Android Booting ProcessLearning AOSP - Android Booting Process
Learning AOSP - Android Booting ProcessNanik Tolaram
 
how to install VMware
how to install VMwarehow to install VMware
how to install VMwarertchandu
 
Mobile Application Development With Android
Mobile Application Development With AndroidMobile Application Development With Android
Mobile Application Development With Androidguest213e237
 

What's hot (20)

Manipulating Android tasks and back stack
Manipulating Android tasks and back stackManipulating Android tasks and back stack
Manipulating Android tasks and back stack
 
Android booting sequece and setup and debugging
Android booting sequece and setup and debuggingAndroid booting sequece and setup and debugging
Android booting sequece and setup and debugging
 
Android JNI
Android JNIAndroid JNI
Android JNI
 
JUnit Presentation
JUnit PresentationJUnit Presentation
JUnit Presentation
 
Tk2323 lecture 1 introduction to mobile application
Tk2323 lecture 1   introduction to mobile applicationTk2323 lecture 1   introduction to mobile application
Tk2323 lecture 1 introduction to mobile application
 
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...
 
OpenVAS: Vulnerability Assessment Scanner
OpenVAS: Vulnerability Assessment ScannerOpenVAS: Vulnerability Assessment Scanner
OpenVAS: Vulnerability Assessment Scanner
 
Android Task Hijacking
Android Task HijackingAndroid Task Hijacking
Android Task Hijacking
 
Automation With Appium
Automation With AppiumAutomation With Appium
Automation With Appium
 
Android - Graphics Animation in Android
Android - Graphics Animation in AndroidAndroid - Graphics Animation in Android
Android - Graphics Animation in Android
 
Android SDK Tutorial | Edureka
Android SDK Tutorial | EdurekaAndroid SDK Tutorial | Edureka
Android SDK Tutorial | Edureka
 
Introduction to Android ppt
Introduction to Android pptIntroduction to Android ppt
Introduction to Android ppt
 
Linux Usb overview
Linux Usb  overviewLinux Usb  overview
Linux Usb overview
 
Audio in linux embedded
Audio in linux embeddedAudio in linux embedded
Audio in linux embedded
 
Learning AOSP - Android Booting Process
Learning AOSP - Android Booting ProcessLearning AOSP - Android Booting Process
Learning AOSP - Android Booting Process
 
how to install VMware
how to install VMwarehow to install VMware
how to install VMware
 
Appium ppt
Appium pptAppium ppt
Appium ppt
 
Mobile Application Development With Android
Mobile Application Development With AndroidMobile Application Development With Android
Mobile Application Development With Android
 
android studio
 android studio android studio
android studio
 
Embedded Android : System Development - Part II (HAL)
Embedded Android : System Development - Part II (HAL)Embedded Android : System Development - Part II (HAL)
Embedded Android : System Development - Part II (HAL)
 

Viewers also liked

Android Logging System
Android Logging SystemAndroid Logging System
Android Logging SystemWilliam Lee
 
Android crash debugging
Android crash debuggingAndroid crash debugging
Android crash debuggingAshish Agrawal
 
android content providers
android content providersandroid content providers
android content providersDeepa Rani
 
Android content providers
Android content providersAndroid content providers
Android content providersKurt Mbanje
 
Android contentprovider
Android contentproviderAndroid contentprovider
Android contentproviderKrazy Koder
 
Content providers in Android
Content providers in AndroidContent providers in Android
Content providers in AndroidAlexey Ustenko
 
Controlling and monitoring external embedded device using android frameworks ...
Controlling and monitoring external embedded device using android frameworks ...Controlling and monitoring external embedded device using android frameworks ...
Controlling and monitoring external embedded device using android frameworks ...Dhruvilkumar patel
 
Android Overview
Android OverviewAndroid Overview
Android Overviewatomi
 
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
 
Day 15: Content Provider: Using Contacts API
Day 15: Content Provider: Using Contacts APIDay 15: Content Provider: Using Contacts API
Day 15: Content Provider: Using Contacts APIAhsanul Karim
 
Mobile Device Management
Mobile Device ManagementMobile Device Management
Mobile Device ManagementJohn Rhoton
 
Content provider in_android
Content provider in_androidContent provider in_android
Content provider in_androidPRITI TELMORE
 
Leveraging the Android Open Accessory Protocol
Leveraging the Android Open Accessory ProtocolLeveraging the Android Open Accessory Protocol
Leveraging the Android Open Accessory ProtocolGary Bisson
 
Android Architecture
Android ArchitectureAndroid Architecture
Android Architecturedeepakshare
 
Introduction to android
Introduction to androidIntroduction to android
Introduction to androidzeelpatel0504
 

Viewers also liked (20)

Android Debug
Android DebugAndroid Debug
Android Debug
 
Android Logging System
Android Logging SystemAndroid Logging System
Android Logging System
 
Android crash debugging
Android crash debuggingAndroid crash debugging
Android crash debugging
 
android content providers
android content providersandroid content providers
android content providers
 
Android content providers
Android content providersAndroid content providers
Android content providers
 
Android contentprovider
Android contentproviderAndroid contentprovider
Android contentprovider
 
Content providers in Android
Content providers in AndroidContent providers in Android
Content providers in Android
 
Controlling and monitoring external embedded device using android frameworks ...
Controlling and monitoring external embedded device using android frameworks ...Controlling and monitoring external embedded device using android frameworks ...
Controlling and monitoring external embedded device using android frameworks ...
 
Android Overview
Android OverviewAndroid Overview
Android Overview
 
Android Development Tools
Android Development ToolsAndroid Development Tools
Android Development Tools
 
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
 
Day 15: Content Provider: Using Contacts API
Day 15: Content Provider: Using Contacts APIDay 15: Content Provider: Using Contacts API
Day 15: Content Provider: Using Contacts API
 
Mobile Device Management
Mobile Device ManagementMobile Device Management
Mobile Device Management
 
Android ppt
Android pptAndroid ppt
Android ppt
 
Content provider in_android
Content provider in_androidContent provider in_android
Content provider in_android
 
Leveraging the Android Open Accessory Protocol
Leveraging the Android Open Accessory ProtocolLeveraging the Android Open Accessory Protocol
Leveraging the Android Open Accessory Protocol
 
Android Architecture
Android ArchitectureAndroid Architecture
Android Architecture
 
Introduction to android
Introduction to androidIntroduction to android
Introduction to android
 
Gradle
GradleGradle
Gradle
 
Gradle
GradleGradle
Gradle
 

Similar to Android ADB: Debug and Inspect Your Device

Android tools for testers
Android tools for testersAndroid tools for testers
Android tools for testersMaksim Kovalev
 
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...Puppet
 
Challenges of container configuration
Challenges of container configurationChallenges of container configuration
Challenges of container configurationlutter
 
Introduction of unit test on android kernel
Introduction of unit test on android kernelIntroduction of unit test on android kernel
Introduction of unit test on android kernelJohnson Chou
 
Interacting with your app through the command line
Interacting with your app through the command lineInteracting with your app through the command line
Interacting with your app through the command lineRoman Mazur
 
Delivering Go.CD with Terraform and Docker
Delivering Go.CD with Terraform and DockerDelivering Go.CD with Terraform and Docker
Delivering Go.CD with Terraform and DockerJorrit Salverda
 
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis OverviewLeo Lorieri
 
Tip: How to enable wireless debugging with Android?
Tip: How to enable wireless debugging with Android?Tip: How to enable wireless debugging with Android?
Tip: How to enable wireless debugging with Android?Sarath C
 
OWF12/PAUG Conf Days Android tools for developpeurs, paul marois, design and ...
OWF12/PAUG Conf Days Android tools for developpeurs, paul marois, design and ...OWF12/PAUG Conf Days Android tools for developpeurs, paul marois, design and ...
OWF12/PAUG Conf Days Android tools for developpeurs, paul marois, design and ...Paris Open Source Summit
 
Oracle goldengate and RAC12c
Oracle goldengate and RAC12cOracle goldengate and RAC12c
Oracle goldengate and RAC12cSiraj Ahmed
 
Study on Android Emulator
Study on Android EmulatorStudy on Android Emulator
Study on Android EmulatorSamael Wang
 
DCEU 18: Tips and Tricks of the Docker Captains
DCEU 18: Tips and Tricks of the Docker CaptainsDCEU 18: Tips and Tricks of the Docker Captains
DCEU 18: Tips and Tricks of the Docker CaptainsDocker, Inc.
 
Hands on Virtualization with Ganeti
Hands on Virtualization with GanetiHands on Virtualization with Ganeti
Hands on Virtualization with GanetiOSCON Byrum
 
Drone CI/CD 自動化測試及部署
Drone CI/CD 自動化測試及部署Drone CI/CD 自動化測試及部署
Drone CI/CD 自動化測試及部署Bo-Yi Wu
 
Adrian Mouat - Docker Tips and Tricks
 Adrian Mouat - Docker Tips and Tricks Adrian Mouat - Docker Tips and Tricks
Adrian Mouat - Docker Tips and TricksKevin Cross
 

Similar to Android ADB: Debug and Inspect Your Device (20)

Android tools for testers
Android tools for testersAndroid tools for testers
Android tools for testers
 
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...
 
Challenges of container configuration
Challenges of container configurationChallenges of container configuration
Challenges of container configuration
 
Adb instructions
Adb instructionsAdb instructions
Adb instructions
 
Introduction of unit test on android kernel
Introduction of unit test on android kernelIntroduction of unit test on android kernel
Introduction of unit test on android kernel
 
Interacting with your app through the command line
Interacting with your app through the command lineInteracting with your app through the command line
Interacting with your app through the command line
 
Android in ubuntu
Android in ubuntuAndroid in ubuntu
Android in ubuntu
 
Delivering Go.CD with Terraform and Docker
Delivering Go.CD with Terraform and DockerDelivering Go.CD with Terraform and Docker
Delivering Go.CD with Terraform and Docker
 
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
 
Tip: How to enable wireless debugging with Android?
Tip: How to enable wireless debugging with Android?Tip: How to enable wireless debugging with Android?
Tip: How to enable wireless debugging with Android?
 
Greach 2016 dockerize your grails
Greach 2016   dockerize your grailsGreach 2016   dockerize your grails
Greach 2016 dockerize your grails
 
OWF12/PAUG Conf Days Android tools for developpeurs, paul marois, design and ...
OWF12/PAUG Conf Days Android tools for developpeurs, paul marois, design and ...OWF12/PAUG Conf Days Android tools for developpeurs, paul marois, design and ...
OWF12/PAUG Conf Days Android tools for developpeurs, paul marois, design and ...
 
Oracle goldengate and RAC12c
Oracle goldengate and RAC12cOracle goldengate and RAC12c
Oracle goldengate and RAC12c
 
CI-CD WITH GITLAB WORKFLOW
CI-CD WITH GITLAB WORKFLOWCI-CD WITH GITLAB WORKFLOW
CI-CD WITH GITLAB WORKFLOW
 
Study on Android Emulator
Study on Android EmulatorStudy on Android Emulator
Study on Android Emulator
 
FreeBSD: Dev to Prod
FreeBSD: Dev to ProdFreeBSD: Dev to Prod
FreeBSD: Dev to Prod
 
DCEU 18: Tips and Tricks of the Docker Captains
DCEU 18: Tips and Tricks of the Docker CaptainsDCEU 18: Tips and Tricks of the Docker Captains
DCEU 18: Tips and Tricks of the Docker Captains
 
Hands on Virtualization with Ganeti
Hands on Virtualization with GanetiHands on Virtualization with Ganeti
Hands on Virtualization with Ganeti
 
Drone CI/CD 自動化測試及部署
Drone CI/CD 自動化測試及部署Drone CI/CD 自動化測試及部署
Drone CI/CD 自動化測試及部署
 
Adrian Mouat - Docker Tips and Tricks
 Adrian Mouat - Docker Tips and Tricks Adrian Mouat - Docker Tips and Tricks
Adrian Mouat - Docker Tips and Tricks
 

Android ADB: Debug and Inspect Your Device

  • 3. Agenda ▣ what is adb ▣ adb commands ▣ adb scripts ▣ adb files ▣ adb over WiFi ▣ screen capture/record ▣ logcat ▣ shell command □ am □ pm □ dumpsys □ more…
  • 5. What is ADB ▣ Android Debug Bridge (adb) is a versatile command line tool that lets you communicate with an emulator instance or connected Android-powered device.
  • 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
  • 9. ADB Commands ▣ adb devices □ Print All the connected devices ▣ adb shell □ run remote shell interactively ▣ adb jdwp □ list PIDs of processes hosting a JDWP transport ▣ adb install/uninstall □ un/install the application ▣ adb start-server □ ensure that there is a server running ▣ adb kill-server □ kill the server if it is running
  • 10. Adb scripts ▣ adb wait-for-device □ block until device is online ▣ adb start-server □ ensure that there is a server running ▣ adb kill-server □ kill the server if it is running ▣ adb get-state □ prints: offline | bootloader | device ▣ adb get-serialno □ prints: <serial-number> ▣ adb get-devpath □ prints: <device-path>
  • 11. Adb scripts ▣ adb status-window □ continuously print device status for a specified device ▣ adb remount □ remounts the /system and /vendor (if present) partitions on the device read-write ▣ adb reboot [bootloader|recovery] □ reboots the device, optionally into the bootloader or recovery program ▣ adb reboot-bootloader - □ reboots the device into the bootloader ▣ adb root □ restarts the adbd daemon with root permissions ▣ adb usb □ restarts the adbd daemon listening on USB
  • 12. Adb - Files ▣ Copy file to device □ adb push <local> <remote> ▣ Copy file from device □ adb pull <remote> <local>
  • 13. adb over WiFi ▣ Android Device □ adb shell netcfg  get the android IP address (x.x.x.x) □ adb shell setprop service.adb.tcp.port 5555 □ adb shell stop adbd && start adbd ▣ PC device □ adb connect x.x.x.x □ adb -s x.x.x.x:5555 logcat □ adb -s x.x.x.x:5555 logcat |grep -vE "/dalvik" □ adb -s x.x.x.x:5555 shell
  • 14. BugReport ▣ Command □ adb shell bugreport > bugreport.txt □ java -jar chkbugreport.jar bugreport.txt ▣ JAR download □ https://github.com/sonyxperiadev/ChkBugReport/download s
  • 15. ScreenCapture ▣ Command: □ adb shell screencap -p /sdcard/screen.png □ adb pull /sdcard/screen.png □ adb shell rm /sdcard/screen.png ▣ Other way □ adb shell screencap -p | sed 's/r$//' > screen.png □ adb shell screencap -p | perl -pe 's/x0Dx0A/x0A/g' > screen.png
  • 16. ScreenRecord ▣ Command: □ adb shell screenrecord /sdcard/recording.mp4 □ adb pull /sdcard/recording.mp4 □ adb shell rm /sdcard/recording.mp4
  • 17. Adb Key Event ▣ Power Button □ adb shell input keyevent 26 ▣ Unlock screen □ adb shell input keyevent 82 ▣ Volume down □ adb shell input keyevent 25 ▣ List of Keyevent □ http://developer.android.com/reference/android/view/KeyEv ent.html
  • 18. Logcat - Logging ▣ Filter by tagname □ adb logcat -s TAG_NAME □ adb logcat -s TAG_NAME_1 TAG_NAME_2 ▣ Filter by priority □ adb logcat "*:PRIORITY"  V - Verbose (lowest priority)  D - Debug  I - Info  W - Warning  E - Error  F - Fatal  S - Silent (highest priority, on which nothing is ever printed)
  • 19. Logcat - Logging ▣ Filter using grep □ adb logcat | grep "SEARCH_TERM" □ Example  adb logcat | grep "Exception" ▣ Clearing the logcat buffer □ adb logcat -c
  • 20. Logcat - Buffers ▣ radio - adb command “” □ View the buffer that contains radio/telephony related messages. ▣ events □ View the buffer containing events-related messages. ▣ main □ View the main log buffer (default) Run Command “logcat -b <buffer>”
  • 21. Shell Commands ▣ dumpstate □ Dumps state to a file. ▣ dmesg □ Prints kernel debugging messages to the screen ▣ start □ Starts an emulator/device instance. ▣ stop □ Stops execution of an emulator/device instance. ▣ restart □ restart an emulator/device instance.
  • 22. Shell Commands ▣ top □ Prints all the running tasks on your device ▣ Service □ Help to communicate with phone services  service list  service check <SERVICE_NAME>  service call <SERVICE_NAME> CODE
  • 23. Shell Commands - More ▣ More Commands □ adb shell ls /system/bin
  • 24. AM - Activity Manager ▣ Start Activity □ am start <packageName/.ActivityClass> ▣ Start/Stop Service □ am startservice -n <packageName/.ServiceClass> □ am stopservice -n <packageName/.ServiceClass> ▣ Send broadcast □ am broadcast -a <action_name> ▣ Users □ am switch-user <USER_ID> □ am start-user <USER_ID> □ am stop-user <USER_ID> ▣ More Commands ▣ adb shell am
  • 25. PM - Package Manager ▣ pm list packages ▣ pm list permission-groups ▣ pm list users ▣ pm install ▣ pm create-user ▣ pm remove-user USER_ID ▣ pm get-max-users ▣ More Commands ▣ adb shell pm
  • 26. Dumpsys ▣ dumpsys □ will show all system data from the device ▣ you can filter it by adding □ dumpsys activity □ dumpsys batterystats □ dumpsys cpuinfo □ dumpsys wifi □ dumpsys meminfo □ dumpsys package ‘package’ ▣ More: □ adb shell dumpsys -l
  • 27. Joke commands ▣ adb hell □ same as ”adb shell” except ”hell” color :) ▣ adb lolcat □ same as ”adb logcat”
  • 28. Task #1 1. Open Settings Application a. main application 2. Open Settings In Inner Activity a. WifiSettings
  • 29. Task #2 1. Get System Application to pc a. Dialer.apk
  • 30. Task #3 1. Open my Application with intent and extra a. extra keys i. string ii. bool iii. float iv. string_array ▣ Download Apk □ https://goo.gl/IWTGle ▣ Code reference □ https://github.com/yossigruner/AdbSession
  • 31. Task #4 1. enable the NFC 2. disable the NFC
  • 32. Answers ▣ Task #1 □ adb shell am start -S com.android.settings/com.android.settings.Settings □ adb shell am start -a android.intent.action.MAIN -n com.android.settings/.wifi.WifiSettings ▣ Task #2 □ adb root □ adb remount □ adb pull /system/priv-app/Dialer/Dialer.apk ▣ Task #3 □ adb shell am start -n com.mike.adbsession/com.mike.adbsession.MainActivity --ez bool false --ef float 1.999 --es string hello --esa string_array hello,world ▣ Task #4 □ enable - service call nfc 6 □ disable - service call nfc 5

Editor's Notes

  1. adb shell am start -S com.android.settings/com.android.settings.Settings adb shell am start -a android.intent.action.MAIN -n com.android.settings/.wifi.WifiSettings
  2. adb root adb remount adb pull /system/priv-app/Dialer/Dialer.apk
  3. open application adb shell am start -n com.mike.adbsession/com.mike.adbsession.MainActivity extra: adb shell am start -n com.mike.adbsession/com.mike.adbsession.MainActivity --ez bool false --ef float 1.999 --es string hello --esa string_array hello,world
  4. # Enable NFC service call nfc 6 # Disable NFC service call nfc 5