public void removeRemotePackage(String remoteFilePath) throws InstallException { try { executeShellCommand("rm " + remoteFilePath, new NullOutputReceiver(), INSTALL_TIMEOUT); } catch (IOException e) { throw new InstallException(e); } catch (TimeoutException e) { throw new InstallException(e); } catch (AdbCommandRejectedException e) { throw new InstallException(e); } catch (ShellCommandUnresponsiveException e) { throw new InstallException(e); } }
} catch (InstallException e) { logInfo("InstallException while install other apk on device [%s]", serial); e.printStackTrace(System.out); return result.markInstallAsFailed("Unable to install other APK.").addException(e).build(); } catch (InstallException e) { logInfo("InstallException while install test apk on device [%s]", serial); e.printStackTrace(System.out); return result.markInstallAsFailed("Unable to install instrumentation APK.") .addException(e)
/** * Returns true if the installation was canceled by user input. This can typically only * happen in the sync phase. */ @Override public boolean wasCanceled() { Throwable cause = getCause(); return cause instanceof SyncException && ((SyncException)cause).wasCanceled(); } }
/** * Returns true if the installation was canceled by user input. This can typically only * happen in the sync phase. */ @Override public boolean wasCanceled() { Throwable cause = getCause(); return cause instanceof SyncException && ((SyncException)cause).wasCanceled(); } }
@Override public void removeRemotePackage(String remoteFilePath) throws InstallException { try { executeShellCommand(String.format("rm \"%1$s\"", remoteFilePath), new NullOutputReceiver(), INSTALL_TIMEOUT_MINUTES, TimeUnit.MINUTES); } catch (IOException e) { throw new InstallException(e); } catch (TimeoutException e) { throw new InstallException(e); } catch (AdbCommandRejectedException e) { throw new InstallException(e); } catch (ShellCommandUnresponsiveException e) { throw new InstallException(e); } }
} catch (InstallException e) { logInfo("InstallException while install other apk on device [%s]", serial); e.printStackTrace(System.out); return result.markInstallAsFailed("Unable to install other APK.").addException(e).build(); } catch (InstallException e) { logInfo("InstallException while install test apk on device [%s]", serial); e.printStackTrace(System.out); return result.markInstallAsFailed("Unable to install instrumentation APK.") .addException(e)
public String uninstallPackage(String packageName) throws InstallException { try { InstallReceiver receiver = new InstallReceiver(); executeShellCommand("pm uninstall " + packageName, receiver, INSTALL_TIMEOUT); return receiver.getErrorMessage(); } catch (TimeoutException e) { throw new InstallException(e); } catch (AdbCommandRejectedException e) { throw new InstallException(e); } catch (ShellCommandUnresponsiveException e) { throw new InstallException(e); } catch (IOException e) { throw new InstallException(e); } }
@Override public void installPackage(String packageFilePath, boolean reinstall, String... extraArgs) throws InstallException { try { String remoteFilePath = syncPackageToDevice(packageFilePath); installRemotePackage(remoteFilePath, reinstall, extraArgs); removeRemotePackage(remoteFilePath); } catch (IOException e) { throw new InstallException(e); } catch (AdbCommandRejectedException e) { throw new InstallException(e); } catch (TimeoutException e) { throw new InstallException(e); } catch (SyncException e) { throw new InstallException(e); } }
public String installRemotePackage(String remoteFilePath, boolean reinstall) throws InstallException { try { InstallReceiver receiver = new InstallReceiver(); String cmd = String.format(reinstall ? "pm install -r \"%1$s\"" : "pm install \"%1$s\"", remoteFilePath); executeShellCommand(cmd, receiver, INSTALL_TIMEOUT); return receiver.getErrorMessage(); } catch (TimeoutException e) { throw new InstallException(e); } catch (AdbCommandRejectedException e) { throw new InstallException(e); } catch (ShellCommandUnresponsiveException e) { throw new InstallException(e); } catch (IOException e) { throw new InstallException(e); } }
@Override public String uninstallPackage(String packageName) throws InstallException { try { InstallReceiver receiver = new InstallReceiver(); executeShellCommand("pm uninstall " + packageName, receiver, INSTALL_TIMEOUT_MINUTES, TimeUnit.MINUTES); return receiver.getErrorMessage(); } catch (TimeoutException e) { throw new InstallException(e); } catch (AdbCommandRejectedException e) { throw new InstallException(e); } catch (ShellCommandUnresponsiveException e) { throw new InstallException(e); } catch (IOException e) { throw new InstallException(e); } }
public String installPackage(String packageFilePath, boolean reinstall) throws InstallException { try { String remoteFilePath = syncPackageToDevice(packageFilePath); String result = installRemotePackage(remoteFilePath, reinstall); removeRemotePackage(remoteFilePath); return result; } catch (IOException e) { throw new InstallException(e); } catch (AdbCommandRejectedException e) { throw new InstallException(e); } catch (TimeoutException e) { throw new InstallException(e); } catch (SyncException e) { throw new InstallException(e); } }
@Override public void installRemotePackage(String remoteFilePath, boolean reinstall, String... extraArgs) throws InstallException { try { InstallReceiver receiver = new InstallReceiver(); StringBuilder optionString = new StringBuilder(); if (reinstall) { optionString.append("-r "); } if (extraArgs != null) { optionString.append(Joiner.on(' ').join(extraArgs)); } String cmd = String.format("pm install %1$s \"%2$s\"", optionString.toString(), remoteFilePath); executeShellCommand(cmd, receiver, INSTALL_TIMEOUT_MINUTES, TimeUnit.MINUTES); String error = receiver.getErrorMessage(); if (error != null) { throw new InstallException(error); } } catch (TimeoutException e) { throw new InstallException(e); } catch (AdbCommandRejectedException e) { throw new InstallException(e); } catch (ShellCommandUnresponsiveException e) { throw new InstallException(e); } catch (IOException e) { throw new InstallException(e); } }
if (sessionId == null) { Log.d(LOG_TAG, "Failed to establish session, quit installation"); throw new InstallException("Failed to establish session"); String message = String.format("Failed to finalize session : %1$s", errorMessage); Log.e(LOG_TAG, message); throw new InstallException(message); throw new InstallException("Failed to install all "); throw new InstallException(e);
@Override public void installPackages(@NonNull List<File> apks, boolean reinstall, @NonNull List<String> installOptions, long timeout, @NonNull TimeUnit timeoutUnit) throws InstallException { try { SplitApkInstaller.create(this, apks, reinstall, installOptions) .install(timeout, timeoutUnit); } catch (InstallException e) { throw e; } catch (Exception e) { throw new InstallException(e); } }
Joiner.on(',').join(testedApks)); if (testedApks.size() > 1 && device.getApiLevel() < 21) { throw new InstallException("Internal error, file a bug, multi-apk applications" + " require a device with API level 21+");
Joiner.on(',').join(testedApks)); if (testedApks.size() > 1 && device.getApiLevel() < 21) { throw new InstallException( "Internal error, file a bug, multi-apk applications" + " require a device with API level 21+");
Joiner.on(',').join(testedApks)); if (testedApks.size() > 1 && device.getApiLevel() < 21) { throw new InstallException("Internal error, file a bug, multi-apk applications" + " require a device with API level 21+");