com.android.ddmlib.InstallException Java Examples
The following examples show how to use
com.android.ddmlib.InstallException.
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: RealAndroidDeviceTest.java From buck with Apache License 2.0 | 6 votes |
/** Verify that if exception is thrown during installation, installation is marked as failed. */ @Test public void testFailedDeviceInstallWithException() { File apk = new File("/some/file.apk"); TestDevice device = new TestDevice() { @Override public void installPackage(String s, boolean b, String... strings) throws InstallException { throw new InstallException("Failed to install on test device.", null); } }; device.setSerialNumber("serial#1"); device.setName("testDevice"); assertFalse(createAndroidDevice(device).installApkOnDevice(apk, false, false, false)); }
Example #2
Source File: RealAndroidDeviceTest.java From buck with Apache License 2.0 | 6 votes |
/** Verify that if failure reason is returned, installation is marked as failed. */ @Test public void testFailedDeviceInstallWithReason() { File apk = new File("/some/file.apk"); TestDevice device = new TestDevice() { @Override public void installPackage(String s, boolean b, String... strings) throws InstallException { throw new InstallException("[SOME REASON]"); } }; device.setSerialNumber("serial#1"); device.setName("testDevice"); assertFalse(createAndroidDevice(device).installApkOnDevice(apk, false, false, false)); }
Example #3
Source File: InstallApkAction.java From NBANDROID-V2 with Apache License 2.0 | 6 votes |
@Override public void actionPerformed(ActionEvent e) { Runnable runnable = new Runnable() { public void run() { FileObject fo = node.getLookup().lookup(FileObject.class); if (fo != null ) { try { device.installPackage(fo.getPath(), true); } catch (InstallException ex) { String message = ex.getMessage(); NotifyDescriptor nd = new NotifyDescriptor.Message(message, NotifyDescriptor.ERROR_MESSAGE); DialogDisplayer.getDefault().notifyLater(nd); } } } }; RequestProcessor.getDefault().execute(runnable); }
Example #4
Source File: AndroidDevice.java From agent with MIT License | 5 votes |
@Override public void installApp(File appFile) { ScheduledExecutorService scheduleService = handleInstallBtnAsync(); try { // 若使用appium安装,将导致handleInstallBtnAsync无法继续处理安装时的弹窗 // 主要因为appium server无法在安装app时,响应其他请求,所以这里用ddmlib安装 AndroidUtil.installApk(iDevice, appFile.getAbsolutePath()); } catch (InstallException e) { throw new RuntimeException(String.format("[%s]安装app失败", getId()), e); } finally { if (!scheduleService.isShutdown()) { scheduleService.shutdown(); } } }
Example #5
Source File: ScriptService.java From CXTouch with GNU General Public License v3.0 | 5 votes |
@Override public void installScriptService(String deviceId) { DefaultDeviceConnection connection = (DefaultDeviceConnection)application.getDeviceConnection(deviceId); if (connection == null) { throw new IllegalArgumentException("The device doesn't exist: " + deviceId); } try { connection.getDevice().installPackage("res/mediate/CXScript.apk", true); } catch (InstallException e) { throw new RuntimeException(e.getMessage(), e); } }
Example #6
Source File: ControllerInfrastructureService.java From CXTouch with GNU General Public License v3.0 | 5 votes |
@Override public void installMainProcess(IDevice device) { try { device.installPackage("res/mediate/CXTouch.apk", true); } catch (InstallException e) { throw new RuntimeException(e.getMessage(), e); } }
Example #7
Source File: MultiPackagesInstaller.java From bundletool with Apache License 2.0 | 5 votes |
private void removePackageFromDevice(Path remoteApk) { try { device.removeRemotePackage(remoteApk); } catch (InstallException e) { throw CommandExecutionException.builder() .withInternalMessage("Package removal has failed") .withCause(e) .build(); } }
Example #8
Source File: DdmlibDevice.java From bundletool with Apache License 2.0 | 5 votes |
@Override public void installApks(ImmutableList<Path> apks, InstallOptions installOptions) { ImmutableList<File> apkFiles = apks.stream().map(Path::toFile).collect(toImmutableList()); ImmutableList.Builder<String> extraArgs = ImmutableList.builder(); if (installOptions.getAllowDowngrade()) { extraArgs.add("-d"); } if (installOptions.getAllowTestOnly()) { extraArgs.add("-t"); } try { if (getVersion() .isGreaterOrEqualThan(AndroidVersion.ALLOW_SPLIT_APK_INSTALLATION.getApiLevel())) { device.installPackages( apkFiles, installOptions.getAllowReinstall(), extraArgs.build(), installOptions.getTimeout().toMillis(), TimeUnit.MILLISECONDS); } else { device.installPackage( Iterables.getOnlyElement(apkFiles).toString(), installOptions.getAllowReinstall(), extraArgs.build().toArray(new String[0])); } } catch (InstallException e) { throw CommandExecutionException.builder() .withCause(e) .withInternalMessage("Installation of the app failed.") .build(); } }
Example #9
Source File: UninstallAppEvent.java From FuzzDroid with Apache License 2.0 | 5 votes |
@Override public Object onEventReceived(IDevice device) { try { device.uninstallPackage(packageName); } catch (InstallException e) { LoggerHelper.logEvent(MyLevel.EXCEPTION_ANALYSIS, e.getMessage()); e.printStackTrace(); System.exit(-1); } return null; }
Example #10
Source File: RealAndroidDevice.java From buck with Apache License 2.0 | 5 votes |
/** * Uninstalls apk from specific device. Reports success or failure to console. It's currently here * because it's used both by {@link com.facebook.buck.cli.InstallCommand} and {@link * com.facebook.buck.cli.UninstallCommand}. */ @SuppressWarnings("PMD.PrematureDeclaration") public boolean uninstallApkFromDevice(String packageName, boolean keepData) { String name = getNameForDisplay(); PrintStream stdOut = console.getStdOut(); stdOut.printf("Removing apk from %s.\n", name); try { long start = System.currentTimeMillis(); String reason = deviceUninstallPackage(packageName, keepData); long end = System.currentTimeMillis(); if (reason != null) { console.printBuildFailure( String.format("Failed to uninstall apk from %s: %s.", name, reason)); return false; } long delta = end - start; stdOut.printf("Uninstalled apk from %s in %d.%03ds.\n", name, delta / 1000, delta % 1000); return true; } catch (InstallException ex) { console.printBuildFailure(String.format("Failed to uninstall apk from %s.", name)); ex.printStackTrace(console.getStdErr()); return false; } }
Example #11
Source File: RealAndroidDevice.java From buck with Apache License 2.0 | 5 votes |
@Override public boolean installApkOnDevice( File apk, boolean installViaSd, boolean quiet, boolean verifyTempWritable) { String name = getNameForDisplay(); if (verifyTempWritable && !isDeviceTempWritable(name)) { return false; } if (!quiet) { eventBus.post(ConsoleEvent.info("Installing apk on %s.", name)); } try { String reason = null; if (installViaSd) { reason = deviceInstallPackageViaSd(apk.getAbsolutePath()); } else { // Always pass -d if it's supported. The duplication is unfortunate // but there's no easy way to conditionally pass varargs in Java. if (supportsInstallDowngrade()) { device.installPackage(apk.getAbsolutePath(), true, "-d"); } else { device.installPackage(apk.getAbsolutePath(), true); } } if (reason != null) { console.printBuildFailure(String.format("Failed to install apk on %s: %s.", name, reason)); return false; } return true; } catch (InstallException ex) { console.printBuildFailure(String.format("Failed to install apk on %s.", name)); ex.printStackTrace(console.getStdErr()); return false; } }
Example #12
Source File: TestDevice.java From buck with Apache License 2.0 | 4 votes |
@Override public void installPackage(String s, boolean b, String... strings) throws InstallException { throw new UnsupportedOperationException(); }
Example #13
Source File: DelegatingAndroidDevice.java From buck with Apache License 2.0 | 4 votes |
@Override public void uninstallPackage(String packageName) throws InstallException { delegate.uninstallPackage(packageName); }
Example #14
Source File: RealAndroidDevice.java From buck with Apache License 2.0 | 4 votes |
@Override public void uninstallPackage(String packageName) throws InstallException { device.uninstallPackage(packageName); }
Example #15
Source File: ExopackageAgent.java From buck with Apache License 2.0 | 4 votes |
private static void uninstallAgent(BuckEventBus eventBus, AndroidDevice device) throws InstallException { try (SimplePerfEvent.Scope ignored = SimplePerfEvent.scope(eventBus, "uninstall_old_agent")) { device.uninstallPackage(AgentUtil.AGENT_PACKAGE_NAME); } }
Example #16
Source File: DdmlibDevice.java From bundletool with Apache License 2.0 | 4 votes |
@Override public void removeRemotePackage(Path remoteFilePath) throws InstallException { device.removeRemotePackage(remoteFilePath.toString()); }
Example #17
Source File: AndroidDevice.java From agent with MIT License | 4 votes |
@Override public void uninstallApp(String app) throws InstallException { AndroidUtil.uninstallApk(iDevice, app); }
Example #18
Source File: AndroidDevice.java From buck with Apache License 2.0 | votes |
void uninstallPackage(String packageName) throws InstallException;
Example #19
Source File: Device.java From bundletool with Apache License 2.0 | votes |
public abstract void removeRemotePackage(Path remoteFilePath) throws InstallException;