使用wda关闭应用
parent
fe7f1cda9e
commit
6fb1c8765a
|
@ -276,6 +276,23 @@ public final class NKAgent {
|
||||||
return screenShotData;
|
return screenShotData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 杀死app
|
||||||
|
* @param string bundleId
|
||||||
|
* @return 是否成功
|
||||||
|
*/
|
||||||
|
public boolean terminateApp(String string) {
|
||||||
|
if (string.isEmpty()) {
|
||||||
|
throw new IllegalArgumentException("bundleId不能为空");
|
||||||
|
}
|
||||||
|
TextData data = new TextData();
|
||||||
|
data.setText(string);
|
||||||
|
ICommandPacket packet = packetTransfer.syncSend(34, data);
|
||||||
|
if (packet == null) return false;
|
||||||
|
BooleanCommandData bool = new BooleanCommandData();
|
||||||
|
packet.fillICommandData(bool);
|
||||||
|
return bool.isSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean getStatus() {
|
public boolean getStatus() {
|
||||||
|
|
|
@ -15,13 +15,17 @@ public class ScreenShotData implements ICommandData {
|
||||||
@Override
|
@Override
|
||||||
public void buildFromInput(DataInput dataInput) throws IOException {
|
public void buildFromInput(DataInput dataInput) throws IOException {
|
||||||
dataLength = dataInput.readInt();
|
dataLength = dataInput.readInt();
|
||||||
|
if (dataLength > 0) {
|
||||||
data = new byte[dataLength];
|
data = new byte[dataLength];
|
||||||
dataInput.readFully(data);
|
dataInput.readFully(data);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void encodeToOutput(DataOutput dataOutput) throws IOException {
|
public void encodeToOutput(DataOutput dataOutput) throws IOException {
|
||||||
|
if (dataLength > 0) {
|
||||||
dataOutput.writeInt(dataLength);
|
dataOutput.writeInt(dataLength);
|
||||||
dataOutput.write(data);
|
dataOutput.write(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -7,6 +7,8 @@ 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.common.PyMobileDevice;
|
||||||
import net.northking.cctp.upperComputer.deviceManager.screen.IosScreenResponseThread;
|
import net.northking.cctp.upperComputer.deviceManager.screen.IosScreenResponseThread;
|
||||||
|
import net.northking.cctp.upperComputer.deviceManager.thread.IosDeviceInitThread;
|
||||||
|
import net.northking.cctp.upperComputer.driver.ios.NKAgent;
|
||||||
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;
|
||||||
import net.northking.cctp.upperComputer.entity.PhoneEntity;
|
import net.northking.cctp.upperComputer.entity.PhoneEntity;
|
||||||
|
@ -323,8 +325,8 @@ public class IosDebuggerServiceImpl extends AbstractDebuggerService {
|
||||||
public boolean terminateApp(String deviceId, String appPackage) {
|
public boolean terminateApp(String deviceId, String appPackage) {
|
||||||
boolean flag = deviceHandleHelper instanceof MacIosHandleHelper;
|
boolean flag = deviceHandleHelper instanceof MacIosHandleHelper;
|
||||||
if (flag) {
|
if (flag) {
|
||||||
PyMobileDevice.SpecificAppleDeviceInfo specificAppleDeviceInfo = IOSDeviceManager.getInstance().getSpecificAppleDeviceInfo(deviceId);
|
NKAgent nkAgent = getNkAgent(deviceId);
|
||||||
boolean killFlag = PyMobileDevice.getInstance().pkill(specificAppleDeviceInfo, appPackage);
|
boolean killFlag = nkAgent.terminateApp(appPackage);
|
||||||
if (killFlag) {
|
if (killFlag) {
|
||||||
logger.info("设备{},执行关闭应用 {} 命令成功", deviceId, appPackage);
|
logger.info("设备{},执行关闭应用 {} 命令成功", deviceId, appPackage);
|
||||||
} else {
|
} else {
|
||||||
|
@ -382,4 +384,15 @@ public class IosDebuggerServiceImpl extends AbstractDebuggerService {
|
||||||
queryDeviceInfoMap.put(info.getCaseId(), deviceAllInfoThread);
|
queryDeviceInfoMap.put(info.getCaseId(), deviceAllInfoThread);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
private NKAgent getNkAgent(String deviceId) {
|
||||||
|
IosDeviceInitThread iosInitThread = IOSDeviceManager.getInstance().getIosInitThread(deviceId);
|
||||||
|
if (null == iosInitThread || !iosInitThread.isAlive() || iosInitThread.isInterrupted()) {
|
||||||
|
throw new ExecuteException("设备已经掉线,请重新接入设备");
|
||||||
|
}
|
||||||
|
NKAgent nkAgent = iosInitThread.getNkAgent();
|
||||||
|
if (!nkAgent.getStatus()) {
|
||||||
|
throw new ExecuteException("设备Agent还未准备好,稍后再试");
|
||||||
|
}
|
||||||
|
return nkAgent;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue