Test commonly used adb commands

[adb] concept:

adb common commands:

1. Check whether the device is connected (adb devices):

C:\Users\yx>adb devices
List of devices attached
9f6777a8        device

2. View the static IP of the device (adb shell ifconfig wlan0):

C:\Users\yx>adb shell ifconfig wlan0
wlan0     Link encap:UNSPEC    Driver icnss
          inet addr:192.168.100.55  Bcast:192.168.100.255  Mask:255.255.255.0
          inet6 addr: fe80::9aa3:f1a:5911:28a9/64 Scope: Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:30040927 errors:0 dropped:0 overruns:0 frame:0
          TX packets:26075649 errors:0 dropped:298 overruns:0 carrier:0
          collisions:0 txqueuelen:3000
          RX bytes:33627422829 TX bytes:9685494713

3. Install the APP on the phone (adb install ***.apk):

C:\Users\yx>adb install C:\Users\yx\Desktop\base.apk
4630 KB/s (23837534 bytes in 5.026s)
Success

4. View all third-party installation packages installed in the phone (adb shell pm list package -3):

Note: The concept of third-party installation package:
(1) For the installation package that cannot be downloaded directly in WeChat, you need to use the “open in browser” with the three dots in the upper right corner. This browser is a third-party application
(2), browser You can download software, WeChat itself does not have this function.
(3) Third-party software is related software developed by other organizations and individuals that are not the software compiler. (Approximately equal to software that is not in the app store???)

C:\Users\niuyx>adb shell pm list package -3
package:com.miui.screenrecorder
package:com.fanweilin.coordinatemap
package:com.jianju.runtime

5. Uninstall an APP (adb uninstall APP package name):

The package name is the real package name of the APP and the mobile phone, not the name of the APP directly seen on the interface.

C:\Users\yx>adb uninstall com.jianju.runtime
Success

6. View the APP path (adb shell pm path APP package name):

C:\Users\adbyx>adb shell pm path com.jianju.runtime
package: /data/ app/~~EDWKajekTRvQZhtZQEoV_Q== /com.jianju.runtime--JA2FOtP-WNXAb41oBkMVA==/ base.apk

7. Enter the mobile phone shell environment (adb shell):

C:\Users\yx>adb shell
picasso:/ $ ls
ls
acct             init.miui.cust.rc                  oem

8. View the phone log (adb logcat -t 10):

C:\Users\yx>adb logcat -t 10
--------- beginning of main
06-01 15:07:11.224 31527 31527 D VFUtils : scaleWght : 330
06-01 15:07:11.593  1744  3638 I MiuiNetworkPolicy: bandwidth: 2 KB/s, Max bandwidth: 1279 KB/s
06-01 15:07:12.122   954  1681 E SDM     : DRMCrtc::Perform: CRTC 109: Set mode 1080x2400x120x133647vid
06-01 15:07:12.123   954  1681 E SDM     : DRMCrtc::Perform: CRTC 109: Set mode 1080x2400x120x133647vid
06-01 15:07:12.124   954  1681 I SDM     : StrategyImpl::SetIdleTimeoutMs: Idle timeout: active = 1100, inactive = 520
06-01 15:07:13.232   954  1681 E SDM     : DRMCrtc::Perform: CRTC 109: Set mode 1080x2400x50x133647vid
06-01 15:07:13.236   954  1681 E SDM     : DRMCrtc::Perform: CRTC 109: Set mode 1080x2400x50x133647vid
06-01 15:07:13.237   954  1681 I SDM     : StrategyImpl::SetIdleTimeoutMs: Idle timeout: active = 1100, inactive = 520
06-01 15:07:13.444   954  1681 E SDM     : DRMCrtc::Perform: CRTC 109: Set mode 1080x2400x50x133647vid
06-01 15:07:13.445   954  1681 E SDM     : DRMCrtc::Perform: CRTC 109: Set mode 1080x2400x50x133647vid

9. View the current running APP package name on the phone (adb shell dumpsys window | findstr mCurrentFocus):

Where com.xxx.xxx is the package name

C:\Users\niuyx>adb shell dumpsys window | findstr mCurrentFocus
  mCurrentFocus=Window{b7f518a u0 com.jianju.runtime/com.jianju.runtime.MainActivity}

10. Grab the specified APP log (adb logcat | find “com.jianju.runtime”):

find can filter the package name
ctrl+c to end the capture

C:\Users\yx>adb logcat | find "com.jianju.runtime"

11. Grab the specified APP log and save it in the specified location of the computer (adb logcat | find “com.jianju.runtime” >D:/1/1.txt):

C:\Users\niuyx>adb logcat | find "com.jianju.runtime" >D:/1/1.txt

12. Close the APP

adb shell am force-stop com.jianju.runtime

13. Start the APP (adb shell am start com.xxx.xxx/com.xxx.xxx.LoginActivity)

(1) First find the entry of the APP
adb shell dumpsys package com.jianju.runtime | findstr / |findstr filter
(2) Start the APP
adb shell am start com.jianju.runtime/com.jianju.runtime.LoginActivity

C:\Users\niuyx>adb shell dumpsys package com.jianju.runtime | findstr \/ |findstr filter
        2ede301 com.jianju.runtime/.LoginActivity filter e3a25a6

C:\Users\niuyx>adb shell am start com.jianju.runtime/com.jianju.runtime.LoginActivity
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.jianju.runtime/.LoginActivity }

14. Transfer files from the computer to the mobile phone

adb push 1.txt /sdcard/
(file name phone storage path)

15. Transfer from the mobile phone to the computer

(1) Enter the path of the file to be stored on the command line (or enter the command window if cmd is in the specified position);
(2) adb push file name/sdcard/ (mobile phone storage path)

C:\Users\yx>adb push 1.txt /sdcard/
5640 KB/s (218902 bytes in 0.037s)

Leave a Comment

Your email address will not be published. Required fields are marked *