/** Fetch or create a real device that corresponds to a device model. */ static IDevice obtainRealDevice(AndroidDebugBridge adb, String serial) { // Get an existing real device. for (IDevice adbDevice : adb.getDevices()) { if (adbDevice.getSerialNumber().equals(serial)) { return adbDevice; } } throw new IllegalArgumentException("Unknown device serial: " + serial); }
/** * Find all device serials that are plugged in through ADB. * * @param minApiLevel If <code>null</code>, all devices will be returned. Otherwise, only * those device serials that are greater than or equal to the provided * version will be returned. */ public static Set<String> findAllDevices(AndroidDebugBridge adb, Integer minApiLevel) { Set<String> devices = new LinkedHashSet<>(); for (IDevice realDevice : adb.getDevices()) { if (minApiLevel == null) { devices.add(realDevice.getSerialNumber()); } else { DeviceDetails deviceDetails = DeviceDetails.createForDevice(realDevice); int apiLevel = deviceDetails.getApiLevel(); if (apiLevel == DeviceDetails.UNKNOWN_API_LEVEL || apiLevel >= minApiLevel) { devices.add(realDevice.getSerialNumber()); } } } return devices; }
do myEmulator = findExistingEmulator( Arrays.asList( androidDebugBridge.getDevices() ) ); devOnline = ( myEmulator != null ) && ( myEmulator.isOnline() ); if ( devOnline )
/** * Stop the running Android Emulators. * * @throws org.apache.maven.plugin.MojoExecutionException * */ protected void stopAndroidEmulators() throws MojoExecutionException { final AndroidDebugBridge androidDebugBridge = initAndroidDebugBridge(); if ( androidDebugBridge.isConnected() ) { List<IDevice> devices = Arrays.asList( androidDebugBridge.getDevices() ); int numberOfDevices = devices.size(); getLog().info( "Found " + numberOfDevices + " devices connected with the Android Debug Bridge" ); for ( IDevice device : devices ) { if ( device.isEmulator() ) { stopEmulator( device ); } else { getLog().info( "Skipping stop. Not an emulator. " + DeviceHelper.getDescriptiveName( device ) ); } } } }
List<IDevice> devices = Arrays.asList( androidDebugBridge.getDevices() ); int numberOfDevices = devices.size(); getLog().debug( "Found " + numberOfDevices + " devices connected with the Android Debug Bridge" );
if ( androidDebugBridge.isConnected() ) List<IDevice> devices = Arrays.asList( androidDebugBridge.getDevices() ); int numberOfDevices = devices.size(); getLog().info( "Found " + numberOfDevices + " devices connected with the Android Debug Bridge" );
/** * Unlocks the emulator. * @param androidDebugBridge */ void unlockEmulator( AndroidDebugBridge androidDebugBridge ) { if ( emulatorUnlock ) { IDevice myEmulator = findExistingEmulator( Arrays.asList( androidDebugBridge.getDevices() ) ); int devicePort = extractPortFromDevice( myEmulator ); if ( devicePort == -1 ) { getLog().info( "Unable to retrieve port to unlock emulator " + DeviceHelper.getDescriptiveName( myEmulator ) ); } else { getLog().info( "Unlocking emulator " + DeviceHelper.getDescriptiveName( myEmulator ) ); sendEmulatorCommand( devicePort, "event send EV_KEY:KEY_SOFT1:1" ); sendEmulatorCommand( devicePort, "event send EV_KEY:KEY_SOFT1:0" ); sendEmulatorCommand( devicePort, "event send EV_KEY:KEY_SOFT1:1" ); sendEmulatorCommand( devicePort, "event send EV_KEY:KEY_SOFT1:0" ); } } }
List<IDevice> devices = Arrays.asList( androidDebugBridge.getDevices() ); int numberOfDevices = devices.size(); getLog().info( "Found " + numberOfDevices + " devices connected with the Android Debug Bridge" );
@Override public synchronized ImmutableList<Device> getDevicesInternal() { checkState(state.equals(State.INITIALIZED), "Android Debug Bridge is not initialized."); return Arrays.stream(adb.getDevices()).map(DdmlibDevice::new).collect(toImmutableList()); }
public IDevice[] getDevices() { IDevice[] devicelist = null; if (mAndroidDebugBridge != null) { devicelist = mAndroidDebugBridge.getDevices(); } return devicelist; } }
public Collection<IDevice> getDevices() { return Arrays.asList(bridge.getDevices()); }
@Override public boolean hasDevices() { Validate.notNull(delegate, "Android debug bridge must be set. Please call connect() method before execution"); return delegate.getDevices().length != 0; }
@Override public boolean hasDevices() { Validate.notNull(delegate, "Android debug bridge must be set. Please call connect() method before execution"); return delegate.getDevices().length != 0; }
/** Fetch or create a real device that corresponds to a device model. */ static IDevice obtainRealDevice(AndroidDebugBridge adb, String serial) { // Get an existing real device. for (IDevice adbDevice : adb.getDevices()) { if (adbDevice.getSerialNumber().equals(serial)) { return adbDevice; } } throw new IllegalArgumentException("Unknown device serial: " + serial); }
public IDevice[] getDevices() { return getAdb().getDevices(); }
@Override public List<AndroidDevice> getDevices() { Validate.notNull(delegate, "Android debug bridge must be set. Please call connect() method before execution"); IDevice[] idevices = delegate.getDevices(); List<AndroidDevice> devices = new ArrayList<AndroidDevice>(idevices.length); for (IDevice d : idevices) { devices.add(new AndroidDeviceImpl(d)); } return devices; }
@Override public List<AndroidDevice> getDevices() { Validate.stateNotNull(delegate, "Android debug bridge must be set. Please call connect() method before execution"); IDevice[] idevices = delegate.getDevices(); List<AndroidDevice> devices = new ArrayList<AndroidDevice>(idevices.length); for (IDevice d : idevices) { devices.add(new AndroidDeviceImpl(d)); } return devices; }
@Override public List<AndroidDevice> getDevices() { Validate.notNull(delegate, "Android debug bridge must be set. Please call connect() method before execution"); IDevice[] idevices = delegate.getDevices(); List<AndroidDevice> devices = new ArrayList<AndroidDevice>(idevices.length); for (IDevice d : idevices) { devices.add(new AndroidDeviceImpl(d, androidSdk)); } return devices; }
public void reloadDevices() { for (IDevice dev : AndroidDebugBridge.getBridge().getDevices()) { deviceConnected(dev); } }
@TaskAction public void runTask() throws InterruptedException { bridge = ExternalFtcResourcesPlugin.getBridge(); try { waitForAdb(); devices = WrappedDevice.wrapDevices(bridge.getDevices()); getLogger().info("\n" + String.valueOf(devices.length) + " device(s) found:\n"); runOnAllDevices(this::logDevice); runOnAllDevices(device -> { if (resourceNeedsSending(device)) { getLogger().warn(device.getName() + ": Sending resource"); sendResource(device); } else { getLogger().warn(device.getName() + ": Skipping resource"); } }); } catch (TimeoutException e) { getLogger().warn(e.getMessage()); } }