Java Code Examples for com.android.ddmlib.IDevice#isEmulator()
The following examples show how to use
com.android.ddmlib.IDevice#isEmulator() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FrameworkEventManager.java From FuzzDroid with Apache License 2.0 | 5 votes |
private IDevice getDevice(String devicePort) { for (IDevice iDev : adb.getDevices()) { if (iDev.isEmulator() && iDev.getSerialNumber().contains(devicePort)) { LoggerHelper.logEvent(MyLevel.RUNTIME, "Successfully connected to emulator: " + iDev.getAvdName()); return iDev; } } return null; }
Example 2
Source File: LogSourcePanel.java From logviewer with Apache License 2.0 | 5 votes |
static void renderDeviceName(@NotNull IDevice d, @NotNull ColoredTextContainer component) { //component.setIcon(d.isEmulator() ? AndroidIcons.Ddms.Emulator2 : AndroidIcons.Ddms.RealDevice); String name; if (d.isEmulator()) { String avdName = d.getAvdName(); if (avdName == null) { avdName = "unknown"; } name = String.format(" %1$s %2$s ", "Emulator", avdName); } else { name = String.format(" %1$s ", DevicePropertyUtil.getModel(d, "")); } component.append(d.getSerialNumber(), SimpleTextAttributes.GRAYED_BOLD_ATTRIBUTES); component.append(name, SimpleTextAttributes.REGULAR_ATTRIBUTES); IDevice.DeviceState deviceState = d.getState(); if (deviceState != IDevice.DeviceState.ONLINE) { String state = String.format("[%1$s] ", d.getState()); component.append(state, SimpleTextAttributes.GRAYED_BOLD_ATTRIBUTES); } if (deviceState != IDevice.DeviceState.DISCONNECTED && deviceState != IDevice.DeviceState.OFFLINE) { component.append(DevicePropertyUtil.getBuild(d), SimpleTextAttributes.GRAY_ATTRIBUTES); } }
Example 3
Source File: AdbUtils.java From NBANDROID-V2 with Apache License 2.0 | 5 votes |
public static Map<String,IDevice> getRunningEmulators(){ Map<String,IDevice> tmp = new HashMap<>(); AndroidDebugBridge debugBridge = AndroidSdkProvider.getAdb(); if(debugBridge!=null){ for (IDevice device : debugBridge.getDevices()) { if(device.isEmulator() && device.isOnline()){ tmp.put(device.getAvdName(), device); } } } return tmp; }
Example 4
Source File: InstallApkAction.java From NBANDROID-V2 with Apache License 2.0 | 5 votes |
public MenuItemWithDevice(IDevice device,Node node) throws HeadlessException { this.device = device; this.node=node; setText(getHtmlDisplayName()); if (!device.isEmulator()) { setIcon(SelectDeviceAction.PHONE_CENTER_ICON); }else{ setIcon(SelectDeviceAction.EMULATOR_ICON); } addActionListener(this); }
Example 5
Source File: DeviceUiChooser.java From NBANDROID-V2 with Apache License 2.0 | 5 votes |
private void setupDevicesTable() { DefaultTableModel tableModel = (DefaultTableModel) devicesTable.getModel(); tableModel.setRowCount(0); for (IDevice device : devices) { String name; String target; if (device.isEmulator()) { name = device.getAvdName(); AvdInfo info = avdManager.getAvd(device.getAvdName(), true /*validAvdOnly*/); target = info == null ? "?" : device.getAvdName(); } else { name = "N/A"; String deviceBuild = device.getProperty(IDevice.PROP_BUILD_VERSION); target = deviceBuild == null ? "unknown" : deviceBuild; } String state; if (DeviceState.BOOTLOADER.equals(device.getState())) { state = "bootloader"; } else if (DeviceState.OFFLINE.equals(device.getState())) { state = "offline"; } else if (DeviceState.ONLINE.equals(device.getState())) { state = "online"; } else { state = "unknown"; } tableModel.addRow(new Object[]{ // TODO nulls? device.getSerialNumber(), name, target, Boolean.valueOf("1".equals(device.getProperty(IDevice.PROP_DEBUGGABLE))), state }); } devicesTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { DeviceUiChooser.this.updateState(); } }); }
Example 6
Source File: DefaultIosDeviceChangeListener.java From agent with MIT License | 4 votes |
@Override protected MobileDevice initMobile(IDevice iDevice, AppiumServer appiumServer) throws Exception { String mobileId = iDevice.getSerialNumber(); boolean isRealDevice = !iDevice.isEmulator(); Mobile mobile = new Mobile(); mobile.setPlatform(MobileDevice.PLATFORM_IOS); mobile.setCreateTime(new Date()); mobile.setId(mobileId); mobile.setName(IosUtil.getDeviceName(mobileId, isRealDevice)); mobile.setEmulator(isRealDevice ? Mobile.REAL_MOBILE : Mobile.EMULATOR); if (isRealDevice) { mobile.setSystemVersion(IosUtil.getRealDeviceSystemVersion(mobileId)); } IosDevice iosDevice = new IosDevice(mobile, appiumServer); log.info("[{}]开始初始化appium", mobileId); RemoteWebDriver driver = iosDevice.freshDriver(null, true); log.info("[{}]初始化appium完成", mobileId); if (!isRealDevice) { try { AppiumDriver appiumDriver = (AppiumDriver) driver; String sdkVersion = (String) appiumDriver.getSessionDetail("sdkVersion"); mobile.setSystemVersion(sdkVersion); } catch (Exception e) { log.warn("[{}]获取sdkVersion失败", mobileId, e); } } // 有时window获取的宽高可能为0 while (true) { Dimension window = driver.manage().window().getSize(); int width = window.getWidth(); int height = window.getHeight(); if (width > 0 && height > 0) { mobile.setScreenWidth(width); mobile.setScreenHeight(height); break; } else { log.warn("[{}]未获取到正确的屏幕宽高: {}", mobileId, window); } } // 截图并上传到服务器 UploadFile uploadFile = iosDevice.screenshotThenUploadToServer(); mobile.setImgPath(uploadFile.getFilePath()); driver.quit(); return iosDevice; }