Java Code Examples for com.android.ddmlib.IDevice#getSerialNumber()
The following examples show how to use
com.android.ddmlib.IDevice#getSerialNumber() .
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: LogDevicesComboBoxSupport.java From NBANDROID-V2 with Apache License 2.0 | 6 votes |
/** * Add a new device to the data model, or replace any existing. */ private void add(IDevice device) { String serial = device.getSerialNumber(); do { // for emulators use their virtual device name as label String deviceAvdName = device.getAvdName(); if (deviceAvdName != null) { deviceLabels.put(serial, deviceAvdName + " [" + serial + "]"); break; } // for real devices use their model name (something like '<vendor> <device>') String deviceModelName = device.getProperty("ro.product.model"); if (deviceModelName != null) { deviceLabels.put(serial, deviceModelName + " [" + serial + "]"); break; } } while (false); // finally, add the serial. add(serial); }
Example 2
Source File: MyDeviceChooser.java From ADB-Duang with MIT License | 6 votes |
@Override @Nullable public Object getValueAt(int rowIndex, int columnIndex) { if (rowIndex >= myDevices.length) { return null; } IDevice device = myDevices[rowIndex]; switch (columnIndex) { case DEVICE_NAME_COLUMN_INDEX: return device; case SERIAL_COLUMN_INDEX: return device.getSerialNumber(); case DEVICE_STATE_COLUMN_INDEX: return getDeviceState(device); // case COMPATIBILITY_COLUMN_INDEX: // return new CanRunOnDeviceCompat(myMinSdkVersion, myProjectTarget, myRequiredHardwareFeatures, device).get(); } return null; }
Example 3
Source File: MyDeviceChooser.java From ADBWIFI with Apache License 2.0 | 6 votes |
@Override @Nullable public Object getValueAt(int rowIndex, int columnIndex) { if (rowIndex >= myDevices.length) { return null; } IDevice device = myDevices[rowIndex]; switch (columnIndex) { case DEVICE_NAME_COLUMN_INDEX: return device; case SERIAL_COLUMN_INDEX: return device.getSerialNumber(); case DEVICE_STATE_COLUMN_INDEX: return getDeviceState(device); case COMPATIBILITY_COLUMN_INDEX: return new CanRunOnDeviceCompat(myMinSdkVersion, myProjectTarget, myRequiredHardwareFeatures, device).get(); } return null; }
Example 4
Source File: DeviceConnectHelper.java From Android-Monkey-Adapter with Apache License 2.0 | 6 votes |
public IDevice waitForDeviceConnected(final String serialNumber, final long timeout) throws InterruptedException { id = serialNumber; Console.printLogMessage(serialNumber, "waitForDeviceConnected(" + serialNumber + " to be connected start"); IDevice [] devices = AndroidDebugBridge.getBridge().getDevices(); if (devices != null) { for (IDevice device : devices) { if (device.getSerialNumber() == serialNumber) { Console.printLogMessage("", device.getSerialNumber()); return device; } } } AndroidDebugBridge.addDebugBridgeChangeListener(DeviceConnectHelper.this); AndroidDebugBridge.addDeviceChangeListener(DeviceConnectHelper.this); synchronized (this) { while (getConnecedDevice(serialNumber) == null) { Console.printLogMessage("", "wait"); wait(60000); } } Console.printLogMessage(serialNumber, "waitForDeviceConnected(" + serialNumber + " to be connected end"); return getConnecedDevice(serialNumber); }
Example 5
Source File: MobileChangeHandler.java From agent with MIT License | 5 votes |
protected void mobileConnected(IDevice iDevice) { String mobileId = iDevice.getSerialNumber(); Device device = DeviceHolder.get(mobileId); if (device == null) { log.info("[{}]首次接入agent", mobileId); Mobile mobile = ServerClient.getInstance().getMobileById(mobileId); log.info("[{}]启动appium server...", mobileId); AppiumServer appiumServer = new AppiumServer(); appiumServer.start(); log.info("[{}]启动appium server完成, url: {}", mobileId, appiumServer.getUrl()); if (mobile == null) { try { log.info("[{}]首次接入server,开始初始化...", mobileId); device = initMobile(iDevice, appiumServer); } catch (Exception e) { log.info("[{}]停止appium server", mobileId); appiumServer.stop(); throw new RuntimeException(String.format("[%s]初始化失败", mobileId), e); } } else { log.info("[{}]已接入过server", mobileId); device = newMobile(iDevice, mobile, appiumServer); } beforePutDeviceToHolder(device); DeviceHolder.put(mobileId, device); } else { log.info("[{}]重新接入agent", mobileId); reconnectToAgent(device, iDevice); } device.onlineToServer(); log.info("[{}]MobileConnected处理完成", mobileId); }
Example 6
Source File: Application.java From CXTouch with GNU General Public License v3.0 | 5 votes |
public synchronized void addDevice(IDevice device) { try { doAddDevice(device, true); } catch (Exception ex) { logger.error("Loading device(" + device.getSerialNumber() + ") failed: " + ex.getMessage(), ex); if (AdbUtil.isWirelessDevice(device)) { String wirelessWeak = stringMgr.getString("wireless.signal.weak") + device.getSerialNumber(); GUIUtil.showErrorMessageDialog(wirelessWeak); } } }
Example 7
Source File: MonkeyTestDevice.java From Android-Monkey-Adapter with Apache License 2.0 | 5 votes |
public MonkeyTestDevice(IDevice device) { if (device == null) { throw new IllegalArgumentException( "MonkeyTestDevice(IDevice device), device should not be null."); } mDevice = device; String serialno = device.getSerialNumber(); if (serialno == null || serialno.isEmpty() || serialno.contains("?")) { throw new IllegalArgumentException( "MonkeyTestDevice(IDevice device), device should not have a illegal serial number, like null, empty or ??????"); } mSerialNumber = serialno; }
Example 8
Source File: Minitouch.java From agent with MIT License | 4 votes |
public Minitouch(IDevice iDevice) { this.iDevice = iDevice; mobileId = iDevice.getSerialNumber(); }
Example 9
Source File: Scrcpy.java From agent with MIT License | 4 votes |
public Scrcpy(IDevice iDevice) { this.iDevice = iDevice; mobileId = iDevice.getSerialNumber(); }
Example 10
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; }