parent
e87632e127
commit
1608e29d27
|
@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import io.appium.java_client.AppiumDriver;
|
import io.appium.java_client.AppiumDriver;
|
||||||
import net.northking.cctp.upperComputer.config.MobileProperty;
|
import net.northking.cctp.upperComputer.config.MobileProperty;
|
||||||
|
import net.northking.cctp.upperComputer.deviceManager.common.PyMobileDevice;
|
||||||
import net.northking.cctp.upperComputer.deviceManager.screen.IosScreenResponseThread;
|
import net.northking.cctp.upperComputer.deviceManager.screen.IosScreenResponseThread;
|
||||||
import net.northking.cctp.upperComputer.entity.Attachment;
|
import net.northking.cctp.upperComputer.entity.Attachment;
|
||||||
import net.northking.cctp.upperComputer.entity.DebuggerDeviceInfo;
|
import net.northking.cctp.upperComputer.entity.DebuggerDeviceInfo;
|
||||||
|
@ -18,6 +19,7 @@ import net.northking.cctp.upperComputer.service.thread.IOSDeviceInfoByPackageThr
|
||||||
import net.northking.cctp.upperComputer.deviceManager.IOSDeviceManager;
|
import net.northking.cctp.upperComputer.deviceManager.IOSDeviceManager;
|
||||||
import net.northking.cctp.upperComputer.utils.HttpUtils;
|
import net.northking.cctp.upperComputer.utils.HttpUtils;
|
||||||
import net.northking.cctp.upperComputer.utils.ScreenShotUtils;
|
import net.northking.cctp.upperComputer.utils.ScreenShotUtils;
|
||||||
|
import net.northking.cctp.upperComputer.utils.ios.MacIosHandleHelper;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.openqa.selenium.WebElement;
|
import org.openqa.selenium.WebElement;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -319,28 +321,40 @@ public class IosDebuggerServiceImpl extends AbstractDebuggerService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean terminateApp(String deviceId, String appPackage) {
|
public boolean terminateApp(String deviceId, String appPackage) {
|
||||||
String[] cmd = {"tidevice", "-u", deviceId, "kill", appPackage};
|
boolean flag = deviceHandleHelper instanceof MacIosHandleHelper;
|
||||||
ProcessBuilder builder = new ProcessBuilder(Arrays.asList(cmd)).redirectErrorStream(true);
|
if (flag) {
|
||||||
Process process = null;
|
PyMobileDevice.SpecificAppleDeviceInfo specificAppleDeviceInfo = IOSDeviceManager.getInstance().getSpecificAppleDeviceInfo(deviceId);
|
||||||
try {
|
boolean killFlag = PyMobileDevice.getInstance().pkill(specificAppleDeviceInfo, appPackage);
|
||||||
process = builder.start();
|
if (killFlag) {
|
||||||
BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
logger.info("设备{},执行关闭应用 {} 命令成功", deviceId, appPackage);
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
|
||||||
String line = null;
|
|
||||||
while ((line = in.readLine()) != null) {
|
|
||||||
stringBuilder.append(line);
|
|
||||||
}
|
|
||||||
String result = stringBuilder.toString();
|
|
||||||
if (result.trim().startsWith("Kill pid:")) {
|
|
||||||
logger.debug("手机【{}】应用【{}】已关闭,关闭消息:{}", deviceId, appPackage, result);
|
|
||||||
return true;
|
|
||||||
} else {
|
} else {
|
||||||
logger.debug("手机【{}】应用【{}】关闭失败,关闭消息:{}", deviceId, appPackage, result);
|
logger.info("设备{},执行关闭应用 {} 命令失败", deviceId, appPackage);
|
||||||
|
}
|
||||||
|
return killFlag;
|
||||||
|
} else {
|
||||||
|
String[] cmd = {"tidevice", "-u", deviceId, "kill", appPackage};
|
||||||
|
ProcessBuilder builder = new ProcessBuilder(Arrays.asList(cmd)).redirectErrorStream(true);
|
||||||
|
Process process = null;
|
||||||
|
try {
|
||||||
|
process = builder.start();
|
||||||
|
BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||||
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
String line = null;
|
||||||
|
while ((line = in.readLine()) != null) {
|
||||||
|
stringBuilder.append(line);
|
||||||
|
}
|
||||||
|
String result = stringBuilder.toString();
|
||||||
|
if (result.trim().startsWith("Kill pid:")) {
|
||||||
|
logger.debug("手机【{}】应用【{}】已关闭,关闭消息:{}", deviceId, appPackage, result);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
logger.debug("手机【{}】应用【{}】关闭失败,关闭消息:{}", deviceId, appPackage, result);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
logger.error("手机【{}】应用【{}】关闭出现问题",deviceId,appPackage,e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
|
||||||
logger.error("手机【{}】应用【{}】关闭出现问题",deviceId,appPackage,e);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue