ALM*_*ALM 3 java multithreading android adb threadpoolexecutor
如何adb shell screenrecord
在Android
设备上运行Java
和结束screenrecording
?
目前我必须指定--time-limit
结束录音。如果我尝试在视频结束之前捕获视频,则会失败。
有没有办法告诉 adb 停止录制?是否存在一种配置线程发送方式CTRL-C
的shell
命令?
这将在无根电话上运行。
代码
videoExecutor.submit(() -> {
//Start recording video
String recordVideo = "screenrecord --time-limit " + testRun.getVideoLength() + " " + "/sdcard/" + logDate + ".mp4";
try {
device.executeShell(recordVideo);
} catch (Exception e1) {
e1.printStackTrace();
}
sleep(testRun.getVideoLength()*ONE_SECOND + TWO_SECONDS); //gotta match the --time-limit above.
RemoteFile remote = new RemoteFile("/sdcard/" + logDate + ".mp4");
File local = new File(videoPath); //Save file to local machine
if(!local.getParentFile().exists()) {
local.getParentFile().mkdirs();
}
try {
//Copy video from phone to computer
try {
device.pull(remote, local);
} catch (Exception e) {
e.printStackTrace();
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
});
Run Code Online (Sandbox Code Playgroud)
无论是发送SIGINT
还是SIGHUP
以screenrecord
过程会导致它停止录制。
我只是在 2 个单独的adb shell
会话中在无根(库存 Android 6.0)手机上尝试了以下操作:
在会话 #1 中:
screenrecord /sdcard/Movies/test.mpg
Run Code Online (Sandbox Code Playgroud)
在第 2 节中:
pkill -INT screenrecord
Run Code Online (Sandbox Code Playgroud)
并screenrecord
发出后捕获停止pkill
命令
归档时间: |
|
查看次数: |
1261 次 |
最近记录: |