Construction and basic use of MONKEY environment

Install the night God simulator and turn it on

Open cmd in the Nox\bin directory

To connect the mobile phone to the computer through USB, you need to enter the developer mode and turn on USB debugging

About mobile phone - "click version number about 5-7 times

Display device to indicate normal connection, display offline device connection is not successful, Apple phone can only connect through Xcode.

adb devices  #View phones connected to this computer

adb #Help document

adb -e shell wm size 
# -e connect the currently unique simulator - d connect the currently unique connected mobile phone to return the resolution of the simulator


adb -s 127.0.0.1:62001 shell wm size #Multiple devices use - s and specify a name 


adb root #To run the simulator with root permission, the root mobile phone needs to root itself

adb -P 8888 start-server #Use the specified port number to run the adb default port number 5037

adb shell pm list packages #Show installed package name
adb shell pm list packages -f #Displays the package name and APK of the installation and its path
adb shell pm list packages -d #Show apps that have been disabled
adb shell pm list packages -e #Show enabled apps
adb shell pm list packages -s #Application of display system
adb shell pm list packages -3 #Show third party apps
adb shell pm list packages news #View and find apps containing news

adb install ‪C:\Users\admin\Desktop\psiphon3.apk #Install the APK on the computer to the system by default
adb install -r ‪C:\Users\admin\Desktop\psiphon3.apk # -r overlay installation
adb install -s ‪C:\Users\admin\Desktop\psiphon3.apk # -s installed in SDcard
adb install -d ‪C:\Users\admin\Desktop\psiphon3.apk # -d allow degraded installation

adb shell pm uninstall -k com.tencent.mm #Unloading application

adb shell pm clear com.tencent.news #Clear cache

adb push C:\Users\admin\Desktop\1.jpg /sdcard/ #Transfer the drawing library into the sdcard directory 
adb push C:\Users\admin\Desktop\1.jpg /sdcard/2.jpg #Transfer the drawing library into the sdcard directory and rename it
adb pull /sdcard/2.jpg C:\Users\admin\Desktop\3.jpg #Download the file locally and rename it

adb shell input keyevent 3  
#Enter keyboard event 3 for keycode corresponding to home key 4 return key 5 dialer 24 increase volume 25 decrease volume    
26 Power key 27 photo taking 64 open system browser 82 menu key 122 move cursor to the beginning of line/Screen head 123 move cursor to end of line/Interface tail
187 Open work task view 207 contact 220 decrease brightness 221 increase brightness

adb shell input text 123abc #Input field 123abc does not support Chinese

adb shell getprop ro.product.model #Get phone model

adb shell dumpsys battery #View battery properties

adb shell wm density #View DPI (pixel density)

adb shell dumpsys window displays #Display screen information

adb shell settings get secure android_id #Get the ID of the machine (device ID)

adb shell dumpsys iphonesubinfo #Get the IMER Code mobile phone call*#06#

adb shell getprop ro.build.version.release #Get Android version

adb shell cat /proc/cpuinfo #Get CPU Information

adb shell screencap -p /sdcard/sc.png #Screenshot and save

adb logcat #Get log log level V D I W E F S
adb logcat *:W #Get W permission log
adb logcat -c #Use before every record before clearing previous logs
adb logcat >log.txt #Write log to file in real time and save file in current directory
ctrl+c #Termination order
adb shell dmesg #Kernel logs are generally not used

monkey is Android's own tool. Using pseudo-random event flow, the seed value will be generated each time you run it. Using the seed value, you can reproduce the previous operations.

adb shell #Enter linux command line mode
monkey 100 #Send 100 random commands instantly

The stability test uses monkey. 30000 commands are used to start. In general, the monkey test is not carried out in the shell. The phone will not write to the log without root permission.

adb shell monkey 100 #Basic command run 100 basic commands
adb shell monkey -v 100 >mongkey.log #Specify the level of the log and save the log to monkey.log
adb shell monkey -p com.tencent.news -v 100 >mongkey.log #Specifies that the command is executed in an application
adb shell monkey -p com.tencent.news --throttle 300 -v 100 >mongkey.log # Event interval 300 ms
adb shell monkey -p com.tencent.news --throttle 300 -v -v 100 >mongkey.log # Second log level
adb shell monkey -p com.tencent.news --throttle 300 -v -v -v 100 >mongkey.log 
# The third log level the higher the log level the more detailed the log ctrl+c cannot stop the monkey command

adb shell monkey -p com.tencent.news --throttle 300 --pct-touch 10 -v -v -v 100 >mongkey.log 
 # Set 10% command to touch event anyevent random event motion sliding trackball trackball nav navigation

adb shell monkey -p com.tencent.news --throttle 300 --ingnore-crashes --ignore-timeouts --pct-touch 10 -v -v -v 100 >mongkey.log 
 # Ignore crashes and timeouts when running commands

adb shell monkey -p com.tencent.news -s 1554836532341 --throttle 300 --pct-touch 10 -v -v -v 100 >mongkey.log 
 # Use the seed value to reproduce the previous command

ps |grep monkey
kill Process number  #Kill monkey in the shell

adb shell ps |findstr monkey
adb shell kill Process number #Kill monkey in cmd 

Tags: shell Mobile simulator Android

Posted on Sat, 09 Nov 2019 11:28:18 -0500 by gijs25