Implementation principle
Hierarchy Viewer: Get the current mobile phone real-time UI information, convenient for mobile phone automation testing;
The subprocess in Python. Popen (): Call system command;
Uiautomator tool: Get interface control information;
ADB command: To operate the mobile phone;
Test environment
1. Hierarchyviewer will map the next Android device's 4939 port to the 4939 port of the PC
ADB devices View mobile device number
Adb-s Mobile device number forward tcp:4939 tcp:4939
2, determine whether the phone has opened the view server, if not turned on the open
Adb-s Mobile device Number Shell service Call window 3
View by return value
"Result:parcel (00000000 00000000 ' ... ')--not open
"Result:parcel (00000000 00000001 ' ... ')--open
Open View Server
Adb-s Mobile device Number Shell Service Call window 1 i32 4939
Close View server
Adb-s Mobile device Number Shell service Call window 2 i32 4939
Note: Only the emulator or root phone can open the view service, the actual operation of the root phone to open the view service is not the command to complete, so first use the simulator to test
About the real-machine open reference the following link: brush into a brick machine is not responsible
Http://maider.blog.sohu.com/255448342.html
How to turn on Viewserver on the root phone so that hierachyviewer can connect