#AdbCommand Collection of various practical commands of Adb
If you connect multiple devices, use adb -s to operate. Use findstr under windows, and grep under linux and mac.
Connect to ADB via wireless:
- Plug in the phone and enter the command: adb tcpip 5555
- Enter the connection command: adb connect 172.16.7.204:5555
Execute shell commands as root:
- Execute adb root first
When Read-only file system
is executed as readable and writable:
- adb remount
If the result is too long, it can be saved to a file, such as:
>
New or overwrite file save:adb shell pm list packages > installed_package.txt
>>
appends the result to the file:adb shell pm list packages >> installed_package.txt
adb kill-server
adb start-server
adb devices
adb shell ifconfig wlan0
adb push /Users/caochang/apk/BBox.apk /sdcard/xbd/BBox.apk
adb pull /sdcard/xbd/BBox.apk /Users/caochang/apk/BBox.apk
adb shell getprop > info.txt
adb shell dumpsys iphonesubinfo
adb shell getprop ro.product.brand
adb shell getprop ro.product.model
adb shell getprop ro.build.version.sdk
adb shell getprop ro.build.version.release
adb shell wm size
adb shell wm size 1080*1920
adb shell wm density
adb shell wm density 480
adb shell getprop ro.product.cpu.abilist (after Android5.0 system) adb shell getprop ro.product.cpu.abi (before Android5.0 system)
adb shell cat /sys/class/net/eth0/address (network card one) adb shell cat /sys/class/net/wlan0/address (wireless network card)
adb shell settings get secure android_id adb shell content query --uri content://settings/secure/android_id --projection value
adb shell system /etc/media_codecs.xml adb shell cat /etc/media_codecs.xml | grep -i "hevc" (check if h265 is supported)
adb shell settings get system screen_off_timeout
adb shell settings put system screen_off_timeout 60000
adb shell settings get secure sms_default_application
adb shell settings put secure sms_default_application com.carlos.sms
adb shell "dumpsys window policy | grep mScreenOnFully"
adb shell dumpsys power | findstr "Display Power:state="
adb shell cat /system/build.prop
heapgrowthlimit
: Common application memory limit, corresponding to the value obtained by the ActivityManager.getMemoryClass()
method
heapsize
: After largeHeap=true
is set in manifest
, the maximum memory value that can be used, corresponding to the value obtained by ActivityManager.getLargeMemoryClass()
method
adb shell getprop persist.sys.dalvik.vm.lib If the value is libdvm.so, it is dalvik, and libart.so is art
Under the Android4.4 directory, the relevant path data/data/com.android.providers.settings/databases/settings.db
, you can open the database to view
Under the Android7.x directory, the relevant path data/system/users/0
, settings_secure.xml
, settings_system.xml
, settings_global.xml
files under the path
get value
adb shell settings get system [key]
adb shell settings get global [key]
adb shell settings get secure [key]
Settings
adb shell settings put secure [key] [value]
...
For example, get the default duration (in milliseconds) before the defined press turns into a long press: adb shell settings get secure long_press_timeout
adb shell am start
-W: wait for launch to complete
-S: force stop the target app before starting the activity
Example adb shell am start -W com.UCMobile/com.uc.browser.InnerUCMobile
Filterable startup log for displayed
output in AS
adb shell dumpsys cpuinfo | find "com.sec.android.app.launcher"
adb shell "dumpsys meminfo | grep com.carlos.bbox
adb shell "ps | grep com.aspire.agent" The value of the second column of the result is pid
adb shell cat /proc/6094/status
adb shell "cat /proc/uid_stat/10189/tcp_snd"
adb shell "cat /proc/uid_stat/11110/tcp_rcv"
adb shell dumpsys dropbox --print >>crashlog_$(date +%Y%m%d%H%M).txt
adb shell cat /proc/meminfo
adb shell kill -9 6094
adb shell pm list packages [-com.carlos.bbox]
adb shell pm clear com.carlos.bbox
adb uninstall com.carlos.bbox
adb shell pm uninstall -k --user 0 com.carlos.test
adb install (-r force installation) /Users/caochang/apk/BBox.apk
adb shell pm install (-r) /sdcard/xbd/BBox.apk
adb install-multiple -r /Users/caochang/apk/BBox.apk
adb shell am broadcast -a com.carlos.bbox -e port 8888
adb shell am startservice com.carlos.bbox/com.carlos.bbox.MyService
adb shell am start -n com.carlos.bbox/.MainActivity Start with parameters:
-a action; the action corresponding to the activity;
--es key stringValue; pass String parameter;
--ez key booleanValue; pass Boolean parameter;
--ei key intValue; pass int parameter;
--el key longValue; pass long parameter;
--ef key floatValue; pass float parameter;
adb shell am froce-stop com.carlos.bbox
- Commands below 8.0 adb shell dumpsys activity | grep "mFocusedActivity"
- Commands above 8.0 adb shell dumpsys activity | grep "mResumedActivity"
adb shell dumpsys window | grep mCurrentFocus
adb shell dumpsys activity top
adb sehll pm list packages | grep "com.carlos.test"