Skip to content

Commit

Permalink
优化图片识别后点击屏幕位置的准确
Browse files Browse the repository at this point in the history
  • Loading branch information
forgetrelease committed Jun 7, 2023
1 parent d6db69a commit 38c6df6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
11 changes: 11 additions & 0 deletions src/main/java/org/cloud/sonic/agent/bridge/ios/SibTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,17 @@ public static String getSize(String udId) {
}
return size;
}
public static int getScreenScale(String udId) {
String commandLine = "%s info -d com.apple.mobile.iTunes -u %s";
String re = ProcessCommandTool.getProcessLocalCommandStr(String.format(commandLine, sib, udId));
int size = 2;
try {
JSONObject r = JSON.parseObject(re);
size = r.getInteger("ScreenScaleFactor");
} catch (Throwable ignored) {
}
return size;
}

public static void mount(String udId) {
String commandLine = "%s mount -u %s";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -844,17 +844,9 @@ public void clickByImg(HandleContext handleContext, String des, String pathValue
}
if (findResult != null) {
try {
String[] size = SibTool.getSize(udId).split("x");
WindowSize windowSize = iosDriver.getWindowSize();
int width;
int ori = SibTool.getOrientation(udId);
if (ori == 1 || ori == 2) {
width = windowSize.getWidth();
} else {
width = windowSize.getHeight();
}
iosDriver.tap(findResult.getX() / (Integer.parseInt(size[0]) / width),
findResult.getY() / (Integer.parseInt(size[0]) / width));
double scale = SibTool.getScreenScale(udId);
iosDriver.tap((int) (findResult.getX()*1.0 / scale),
(int) (findResult.getY()*1.0 / scale));
} catch (Exception e) {
log.sendStepLog(StepType.ERROR, "点击" + des + "失败!", "");
handleContext.setE(e);
Expand Down

0 comments on commit 38c6df6

Please sign in to comment.