try { executeShellCommand("am get-config", receiver, 5, TimeUnit.SECONDS); return DeviceConfig.Builder.parse(output); } catch (Exception e) { throw new DeviceException(e); }
public static Response send(Sale sale) throws DeviceException { try( Socket socket = new Socket(addr, 9999); DataInputStream is = new DataInputStream(socket.getInputStream()); DataOutputStream os = new DataOutputStream(socket.getOutputStream()); ) { StringWriter writer = new StringWriter(); Marshaller marshaller = JAXBContext.newInstance(Sale.class).createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); marshaller.marshal(sale, writer); os.writeUTF(writer.toString()); Unmarshaller unmarshaller = JAXBContext.newInstance(Response.class).createUnmarshaller(); Response response = (Response)unmarshaller.unmarshal(new StringReader(is.readUTF())); return response; } catch(IOException | JAXBException e) { e.printStackTrace(); } throw new DeviceException(); }
@Override public void installPackage(@NonNull File apkFile, @NonNull Collection<String> options, int timeout, ILogger logger) throws DeviceException { try { iDevice.installPackage(apkFile.getAbsolutePath(), true /*reinstall*/, options.isEmpty() ? null : options.toArray(new String[options.size()])); } catch (Exception e) { logger.error(e, "Unable to install " + apkFile.getAbsolutePath()); throw new DeviceException(e); } }
@Override public void installPackage(@NonNull File apkFile, @NonNull Collection<String> options, int timeout, ILogger logger) throws DeviceException { try { iDevice.installPackage(apkFile.getAbsolutePath(), true /*reinstall*/, options.isEmpty() ? null : options.toArray(new String[options.size()])); } catch (Exception e) { logger.error(e, "Unable to install " + apkFile.getAbsolutePath()); throw new DeviceException(e); } }
@Override public void installPackages(@NonNull List<File> splitApkFiles, @NonNull Collection<String> options, int timeoutInMs, ILogger logger) throws DeviceException { try { iDevice.installPackages(splitApkFiles, true /*reinstall*/, ImmutableList.copyOf(options), timeoutInMs, TimeUnit.MILLISECONDS); } catch (Exception e) { List<String> apkFileNames = Lists.transform( splitApkFiles, input -> input != null ? input.getAbsolutePath() : null); logger.error(e, "Unable to install " + Joiner.on(',').join(apkFileNames)); throw new DeviceException(e); } }
@Override public void installPackages(@NonNull List<File> splitApkFiles, @NonNull Collection<String> options, int timeoutInMs, ILogger logger) throws DeviceException { List<String> apkFileNames = Lists.transform(splitApkFiles, new Function<File, String>() { @Override public String apply(@Nullable File input) { return input != null ? input.getAbsolutePath() : null; } }); try { iDevice.installPackages(apkFileNames, timeoutInMs, true /*reinstall*/, options.isEmpty() ? null : options.toArray(new String[options.size()])); } catch (Exception e) { logger.error(e, "Unable to install " + Joiner.on(',').join(apkFileNames)); throw new DeviceException(e); } }
@Override public void uninstallPackage(@NonNull String packageName, int timeout, ILogger logger) throws DeviceException { try { iDevice.uninstallPackage(packageName); } catch (Exception e) { logger.error(e, "Unable to uninstall " + packageName); throw new DeviceException(e); } }
@NonNull @Override public DeviceConfig getDeviceConfig() throws DeviceException { final List<String> output = new ArrayList<String>(); final MultiLineReceiver receiver = new MultiLineReceiver() { @Override public void processNewLines(String[] lines) { output.addAll(Arrays.asList(lines)); } @Override public boolean isCancelled() { return false; } }; try { executeShellCommand("am get-config", receiver, mTimeout, mTimeUnit); return DeviceConfig.Builder.parse(output); } catch (Exception e) { throw new DeviceException(e); } } }
@Override public void uninstallPackage(@NonNull String packageName, int timeout, ILogger logger) throws DeviceException { try { iDevice.uninstallPackage(packageName); } catch (Exception e) { logger.error(e, "Unable to uninstall " + packageName); throw new DeviceException(e); } }
@NonNull @Override public DeviceConfig getDeviceConfig() throws DeviceException { final List<String> output = new ArrayList<String>(); final MultiLineReceiver receiver = new MultiLineReceiver() { @Override public void processNewLines(String[] lines) { output.addAll(Arrays.asList(lines)); } @Override public boolean isCancelled() { return false; } }; try { executeShellCommand("am get-config", receiver, 5, TimeUnit.SECONDS); return DeviceConfig.Builder.parse(output); } catch (Exception e) { throw new DeviceException(e); } } }
throw new DeviceException("Could not create ADB Bridge. " + "ADB location: " + adbLocation.getAbsolutePath()); Thread.sleep(sleepTime); } catch (InterruptedException e) { throw new DeviceException(e); throw new DeviceException("Timeout getting device list."); throw new DeviceException("No connected devices!"); throw new DeviceException(String.format( "Connected device with serial%s '%s' not found!", serials.size() == 1 ? "" : "s", throw new DeviceException(String.format( "Connected device with serial $1%s is not online.", androidSerialsEnv)); } else { throw new DeviceException("No online devices found.");
Thread.sleep(sleepTime); } catch (InterruptedException e) { throw new DeviceException(e); throw new DeviceException("Timeout getting device list."); throw new DeviceException("No connected devices!"); throw new DeviceException(String.format( "Connected device with serial %s not found!", androidSerial)); throw new DeviceException(String.format( "Connected device with serial $1%s is not online.", androidSerial)); } else { throw new DeviceException("No online devices found.");