Skip to content

Commit 2294e0d

Browse files
author
朱辉\harry
committed
修复index.html预览屏幕截图失败的问题。 修复截图的目标大小。TODO: 安卓手表测试文件传输时间过长导致Timeout异常,需要自己重写
1 parent f97b33c commit 2294e0d

3 files changed

Lines changed: 14 additions & 4 deletions

File tree

‎src/main/java/com/yeetor/adb/AdbServer.java‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,16 @@ public static String executeShellCommand(IDevice device, String command) {
126126
return output.getOutput();
127127
}
128128

129+
/**
130+
* TODO: 添加自定义adb命令,原因是安卓手表的传输速度太慢,导致adb push超时错误
131+
* @param device
132+
* @param command
133+
* @return
134+
*/
135+
public static String executeCommand(IDevice device, String command) {
136+
return "";
137+
}
138+
129139
private ListenableFuture<List<AdbForward>> executeGetForwardList() {
130140
final File adbFile = new File(AdbServer.server().adbPath);
131141
final SettableFuture future = SettableFuture.create();

‎src/main/java/com/yeetor/androidcontrol/server/LocalServer.java‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,12 +217,11 @@ void sendShot(ChannelHandlerContext ctx, Command command) {
217217
DefaultFullHttpResponse onHttp(FullHttpRequest req) {
218218
String uri = req.uri();
219219
String uriPath = uri.substring(uri.indexOf("/") + 1);
220-
System.out.println("http://" + uriPath);
221220
if (uriPath.startsWith("shot")) {
222221
// 获取serialNumber
223-
String[] s = uri.split("/");
222+
String[] s = uriPath.split("/");
224223
if (s.length == 2) {
225-
return new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK, Unpooled.copiedBuffer(new Minicap(s[2]).takeScreenShot()));
224+
return new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK, Unpooled.copiedBuffer(new Minicap(s[1]).takeScreenShot()));
226225
} else {
227226
return new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.NOT_FOUND);
228227
}

‎src/main/java/com/yeetor/minicap/Minicap.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,8 @@ private void removeForward(AdbForward forward) {
180180
* @return
181181
*/
182182
public byte[] takeScreenShot() {
183-
String command = getMinicapCommand(deviceSize.w, deviceSize.h, 1080, 1920, 0, false, "minicap", new String[] {"-s -b"});
183+
String command = getMinicapCommand(deviceSize.w, deviceSize.h, deviceSize.w, deviceSize.h, 0, false, "minicap", new String[] {"-s -b"});
184+
System.out.println("takeScreenShot:" + command);
184185
BinaryOutputReceiver receiver = new BinaryOutputReceiver();
185186
try {
186187
device.executeShellCommand(command, receiver, 0);

0 commit comments

Comments
 (0)