獲取設(shè)備的CPU版本和系統(tǒng)版本
CPU版本
adb shell getprop ro.product.cpu.abi | tr -d '\r'
58deMacBook-Pro:minicap wuxian$ adb shell getprop ro.product.cpu.abi | tr -d '\r'
armeabi-v7a
系統(tǒng)版本
adb shell getprop ro.build.version.sdk | tr -d '\r'
58deMacBook-Pro:minicap wuxian$ adb shell getprop ro.build.version.sdk | tr -d '\r'
22
將文件push到手機(jī)
根據(jù)上面獲取的信息,將適合設(shè)備的可執(zhí)行文件和.so文件push到手機(jī)的/data/local/tmp目錄下,如果你不想自己build這些文件可以去STF框架的源碼下找到vendor/minicap文件夾下找到這些文件,我上面的tree信息就是我在stf根目錄vendor/minicap下打印的,所以我們將這兩個(gè)文件導(dǎo)入到我手機(jī)的/data/local/tmp目錄下:
shell@shamu:/data/local/tmp $ ls -l
-rw-rw-r-- shell shell 1053609 2015-08-07 19:19 1.png
-rwxr-xr-x shell shell 1062992 2015-08-03 12:02 busybox
-rwxr-xr-x shell shell 358336 2015-08-03 12:02 busybox1
drwxrwxrwx shell shell 2015-07-21 15:16 dalvik-cache
-rw-r--r-- shell shell 193 2015-08-13 19:44 krperm.txt
-rwxrwxrwx shell shell 370424 2015-08-07 18:16 minicap
-rw-rw-rw- shell shell 13492 2015-08-07 18:26 minicap.so
-rw------- shell shell 11192 2015-08-06 10:46 ui.xml
-rw------- shell shell 2501 2015-08-07 10:36 uidump.xml
啟動(dòng)工具
首先我們測(cè)試一下我們的minicap工具是否可用,命令如下(其中-P后面跟的參數(shù)為你屏幕的尺寸,你可以修改成你自己設(shè)備的尺寸):
adb shell LD_LIBRARY_PATH=/data/local/tmp /data/local/tmp/minicap -P 1440x2560@1440x2560/0 -t
最后輸出OK就表明minicap可用:
58deMacBook-Pro:minicap wuxian$ adb shell LD_LIBRARY_PATH=/data/local/tmp /data/local/tmp/minicap -P 1440x2560@1440x2560/0 -t
PID: 7105
INFO: Using projection 1440x2560@1440x2560/0
INFO: (external/MY_minicap/src/minicap_22.cpp:240) Creating SurfaceComposerClient
INFO: (external/MY_minicap/src/minicap_22.cpp:243) Performing SurfaceComposerClient init check
INFO: (external/MY_minicap/src/minicap_22.cpp:250) Creating virtual display
INFO: (external/MY_minicap/src/minicap_22.cpp:256) Creating buffer queue
INFO: (external/MY_minicap/src/minicap_22.cpp:261) Creating CPU consumer
INFO: (external/MY_minicap/src/minicap_22.cpp:265) Creating frame waiter
INFO: (external/MY_minicap/src/minicap_22.cpp:269) Publishing virtual display
INFO: (jni/minicap/JpgEncoder.cpp:64) Allocating 11061252 bytes for JPG encoder
INFO: (external/MY_minicap/src/minicap_22.cpp:284) Destroying virtual display
OK
然后我們啟動(dòng)minicap工具,命令如下(就比上面的檢測(cè)工具少了個(gè)-t):
adb shell LD_LIBRARY_PATH=/data/local/tmp /data/local/tmp/minicap -P 1440x2560@1440x2560/0
本地端口轉(zhuǎn)發(fā)
上面其實(shí)是啟動(dòng)了一個(gè)socket服務(wù)器,我們需要跟該socket服務(wù)通信,首先我們要將本地的端口映射到minicap工具上,端口自己隨意:
adb forward tcp:1717 localabstract:minicap
獲取信息
然后使用命令nc localhost 1717來(lái)與minicap通信,然后你會(huì)發(fā)現(xiàn)好多亂碼。