使用NkAgent启动应用

master
yineng.huang 2024-10-08 15:16:06 +08:00
parent 6fb1c8765a
commit cab4c50752
1 changed files with 11 additions and 3 deletions

View File

@ -80,12 +80,20 @@ public class MacIosHandleHelper extends IosDeviceHandleHelper {
@Override
public boolean activateApp(String deviceId, String appPackage) {
PyMobileDevice.SpecificAppleDeviceInfo specificAppleDeviceInfo = IOSDeviceManager.getInstance().getSpecificAppleDeviceInfo(deviceId);
boolean success = PyMobileDevice.getInstance().launchApp(specificAppleDeviceInfo, appPackage);
logger.debug("设备【{}】启动app【{}】的结果:{}", deviceId, appPackage, success);
NKAgent nkAgent = getNkAgent(deviceId);
String bundleId = nkAgent.activeAppBundleId();
logger.info("设备【{}】的当前启动的应用为【{}】,传过来要启动的应用为【{}】", deviceId, bundleId,appPackage);
if (bundleId.equals(appPackage)) {
logger.info("设备【{}】的应用【{}】已经启动并展示在前台", deviceId, appPackage);
return true;
}
logger.info("设备【{}】的应用【{}】未展示在前台,开始启动", deviceId, appPackage);
boolean success = nkAgent.launchApp(appPackage);
logger.debug("设备【{}】启动app【{}】的结果:{}",deviceId,appPackage,success);
return success;
}
@Override
public File getScreenShotFile(String deviceId, Integer startX, Integer startY, Integer cutWidth, Integer cutHeight, Integer screenWidth, Integer screenHeight) {
if (cutWidth <= 0 || cutHeight <= 0) {