fix:上位机

1.对获取到字符串进行处理,截取json部分
2.注册设备的时候,增加wdaUrl的属性
3.架构属性作为配置
master
李杰应 2024-08-02 16:02:21 +08:00
parent 696d51ea04
commit 1363de0a83
3 changed files with 25 additions and 3 deletions

View File

@ -431,6 +431,9 @@ public class PyMobileDevice extends Python3 {
String jsonText = builder.toString();
HashMap<String, AppleApplicationInfo> applicationInfos = new HashMap<>();
try {
if (null != jsonText && !jsonText.startsWith("{")) {
jsonText = jsonText.substring(jsonText.indexOf("{"));
}
applicationInfos = gson.fromJson(jsonText, new TypeToken<HashMap<String, AppleApplicationInfo>>() {
}.getType());
} catch (JsonSyntaxException e) {
@ -602,6 +605,9 @@ public class PyMobileDevice extends Python3 {
}
String jsonText = outputReceiver.getHoleOutput(false);
try {
if (null != jsonText && !jsonText.startsWith("{")) {
jsonText = jsonText.substring(jsonText.indexOf("{"));
}
return gson.fromJson(jsonText, DeviceBaseInfo.class);
} catch (JsonSyntaxException e) {
logger.error("读取设备基本信息时发生json解析错误\n" + jsonText, e);
@ -630,6 +636,9 @@ public class PyMobileDevice extends Python3 {
return;
}
String jsonText = line.substring(startIndex + 5);
if (null != jsonText && !jsonText.startsWith("{")) {
jsonText = jsonText.substring(jsonText.indexOf("{"));
}
if (jsonText.startsWith("{") && jsonText.endsWith("}")) {
try {
DeveloperDvtGraphics data = gson.fromJson(jsonText, DeveloperDvtGraphics.class);
@ -691,6 +700,9 @@ public class PyMobileDevice extends Python3 {
// System.out.println("jsonText = \n" + jsonText);
BatteryDetail batteryDetail;
try {
if (null != jsonText && !jsonText.startsWith("{")) {
jsonText = jsonText.substring(jsonText.indexOf("{"));
}
batteryDetail = gson.fromJson(jsonText, BatteryDetail.class);
} catch (JsonSyntaxException e) {
logger.error("反序列化设备电池信息时发生json格式错误", e);
@ -788,6 +800,9 @@ public class PyMobileDevice extends Python3 {
if (index > 0) {
String jsonText = line.substring(index + 5);
try {
if (null != jsonText && !jsonText.startsWith("{")) {
jsonText = jsonText.substring(jsonText.indexOf("{"));
}
BatteryBaseInfo batteryBaseInfo = gson.fromJson(jsonText, BatteryBaseInfo.class);
callback.onBattery(batteryBaseInfo);
} catch (JsonSyntaxException e) {
@ -820,6 +835,9 @@ public class PyMobileDevice extends Python3 {
}
String jsonText = outputReceiver.getHoleOutput(false);
try {
if (null != jsonText && !jsonText.startsWith("{")) {
jsonText = jsonText.substring(jsonText.indexOf("{"));
}
return gson.fromJson(jsonText, LockdownInfo.class);
} catch (JsonSyntaxException e) {
logger.error("处理lockdown查询结果时发生json反序列化错误", e);

View File

@ -2,6 +2,8 @@ package net.northking.cctp.upperComputer.deviceManager.common;
import net.northking.cctp.upperComputer.deviceManager.utils.OutputLineCallback;
import net.northking.cctp.upperComputer.utils.SpringUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -50,11 +52,12 @@ public class Python3 {
}
}));
String arch = System.getProperty("os.arch");
if (arch.equals("aarch64")) {
// String arch = System.getProperty("os.arch");
String arch = SpringUtils.getProperties("macos.build-wda.arch");
if (StringUtils.isBlank(arch)) {
ARCH = "arm64";
} else {
ARCH = "x86_64";
ARCH = arch;
}
}

View File

@ -229,6 +229,7 @@ public class MacIosDeviceInitThread extends IosDeviceInitThread {
deviceInfo.put("height", realHeight.intValue());
deviceInfo.put("scale", scale);
deviceInfo.put("isHarmony", false);
deviceInfo.put("wdaUrl", "http://" + UpperComputerManager.getInstance().getHost() + ":" + phone.getPort8100());
int rotation = screenInfoData.getOrientation() - 1;
if (rotation < 0) {
logger.debug("无法获取设备【{}】的屏幕方向,默认为0",phone.getUdid());