Hardware and software Environment

  • Android 7.1.2

Connected devices

The first step is to connect the device, and the rest of the operation is based on this step

The adb connect 192.168.1.100Copy the code

Perform operations on a specific device

The premise here is that multiple devices have been connected. You can use the -s parameter to specify a specific device for subsequent operations

C:\Users\djstava>adb devices
List of devices attached
192.168.1.100:5555  device
8D6TUCDI69D6G6AI        device
Copy the code

Perform operations on a device

adb -s 8D6TUCDI69D6G6AI shell
Copy the code

Adb remote capture

The first step is to take a screenshot, save it in a writable directory on the system, and then use ADB pull to pull it to the local directory

adb shell /system/bin/screencap -p /data/android_traffic_balance_01.png
adb pull /data/android_traffic_balance_01.png .
Copy the code

The adb start-up activity

Direct start

adb shell am start -n com.xugaoxiang/com.xugaoxiang.MainActivity
Copy the code

Specify the intent

adb shell am start -a intent_ACTION -c intent_category -n com.xugaoxiang/com.xugaoxiang.MainActivity
Copy the code

Specify the browser to open a specific page

If multiple browsers exist in the system, you can use a specific browser to open a page

adb shell am start -a android.intent.action.VIEW -d http://google.com
Copy the code

List the package names of all apps

You can also run the grep command to filter packets, and add the -f parameter to obtain the package name and storage path corresponding to apK

adb shell pm list packages
Copy the code

Gets the currently openappThe package name

To know the package name of an app, open the app and run the following command

adb shell dumpsys window | findstr mCurrentFocus
Copy the code

Remount partitions in writable mode

adb root
adb remount
Copy the code

Viewing System Logs

adb shell logcat
Copy the code

Gets the package name and path corresponding to apK

adb shell pm list package -f
Copy the code

Close the selinux

Adb root adb shell setenforce 0 adb root adb shell echo 0 > /sys/fs/selinux/enforceCopy the code

Simulate key value sending

The focus here is on remote controls

Adb shell input keyevent $Copy the code

In this case, the key value is the value of the android layer frameworks in the file/base/core/Java/android/view/KeyEvent. Defined in Java, this part can refer to previous articles android add remote control button

Simulates screen click events

Simulate a click at coordinate (200,200)

adb shell input tap 200 200
Copy the code

Simulates a screen slide event

Simulation sliding from position (200,200) to position (400,400)

adb shell input swipe 200 200 400 400
Copy the code

Viewing System Properties

adb shell getprop
Copy the code

To get a specific property value, follow the property value after the command above

Set a system attribute

adb shell setprop dalvik.vm.heapgrowthlimit 512m
Copy the code