SlideShare une entreprise Scribd logo
1  sur  34
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

Contenu connexe

Tendances

Understanding the Android System Server
Understanding the Android System ServerUnderstanding the Android System Server
Understanding the Android System ServerOpersys inc.
 
Android audio system(audioplicy_service)
Android audio system(audioplicy_service)Android audio system(audioplicy_service)
Android audio system(audioplicy_service)fefe7270
 
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
 
Sa1 chapter-5-managing-local-linux-users-and-groups-v2 (4)
Sa1 chapter-5-managing-local-linux-users-and-groups-v2 (4)Sa1 chapter-5-managing-local-linux-users-and-groups-v2 (4)
Sa1 chapter-5-managing-local-linux-users-and-groups-v2 (4)Chinthaka Deshapriya (RHCA)
 
Android studio installation
Android studio installationAndroid studio installation
Android studio installationPoojaBele1
 
Booting Android: bootloaders, fastboot and boot images
Booting Android: bootloaders, fastboot and boot imagesBooting Android: bootloaders, fastboot and boot images
Booting Android: bootloaders, fastboot and boot imagesChris Simmonds
 
Ch 3 Assembler in System programming
Ch 3 Assembler in System programming Ch 3 Assembler in System programming
Ch 3 Assembler in System programming Bhatt Balkrishna
 
Android AIDL Concept
Android AIDL ConceptAndroid AIDL Concept
Android AIDL ConceptCharile Tsai
 
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
 

Tendances (20)

Understanding the Android System Server
Understanding the Android System ServerUnderstanding the Android System Server
Understanding the Android System Server
 
Android audio system(audioplicy_service)
Android audio system(audioplicy_service)Android audio system(audioplicy_service)
Android audio system(audioplicy_service)
 
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)
 
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
 
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)
 
Sa1 chapter-5-managing-local-linux-users-and-groups-v2 (4)
Sa1 chapter-5-managing-local-linux-users-and-groups-v2 (4)Sa1 chapter-5-managing-local-linux-users-and-groups-v2 (4)
Sa1 chapter-5-managing-local-linux-users-and-groups-v2 (4)
 
Hacking Android OS
Hacking Android OSHacking Android OS
Hacking Android OS
 
Linux Device Driver’s
Linux Device Driver’sLinux Device Driver’s
Linux Device Driver’s
 
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)
 
Android studio installation
Android studio installationAndroid studio installation
Android studio installation
 
Android Audio System
Android Audio SystemAndroid Audio System
Android Audio System
 
Aidl service
Aidl serviceAidl service
Aidl service
 
Booting Android: bootloaders, fastboot and boot images
Booting Android: bootloaders, fastboot and boot imagesBooting Android: bootloaders, fastboot and boot images
Booting Android: bootloaders, fastboot and boot images
 
Android Things : Building Embedded Devices
Android Things : Building Embedded DevicesAndroid Things : Building Embedded Devices
Android Things : Building Embedded Devices
 
Ch 3 Assembler in System programming
Ch 3 Assembler in System programming Ch 3 Assembler in System programming
Ch 3 Assembler in System programming
 
Android AIDL Concept
Android AIDL ConceptAndroid AIDL Concept
Android AIDL Concept
 
Deep Dive into the AOSP
Deep Dive into the AOSPDeep Dive into the AOSP
Deep Dive into the AOSP
 
Embedded Android : System Development - Part I
Embedded Android : System Development - Part IEmbedded Android : System Development - Part I
Embedded Android : System Development - Part I
 
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
 
Introduction to Makefile
Introduction to MakefileIntroduction to Makefile
Introduction to Makefile
 

En vedette

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 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
 

En vedette (20)

Android Debug
Android DebugAndroid Debug
Android Debug
 
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 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
 
Android Platform Architecture
Android Platform ArchitectureAndroid Platform Architecture
Android Platform Architecture
 

Similaire à 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
 

Similaire à 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

Notes de l'éditeur

  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