public class AdbHelper extends Object implements AndroidDevicesHelper
| Modifier and Type | Class and Description |
|---|---|
static class |
AdbHelper.CommandFailedException
An exception that indicates that an executed command returned an unsuccessful exit code.
|
AndroidDevicesHelper.AdbDeviceCallable| Modifier and Type | Field and Description |
|---|---|
static Pattern |
PACKAGE_NAME_PATTERN
Pattern that matches safe package names.
|
| Constructor and Description |
|---|
AdbHelper(AdbOptions adbOptions,
TargetDeviceOptions deviceOptions,
ToolchainProvider toolchainProvider,
java.util.function.Supplier<ExecutionContext> contextSupplier,
boolean restartAdbOnFailure,
com.google.common.collect.ImmutableList<String> rapidInstallTypes) |
| Modifier and Type | Method and Description |
|---|---|
void |
adbCall(String description,
AndroidDevicesHelper.AdbDeviceCallable func,
boolean quiet)
Execute an
AdbDeviceCallable for all matching devices. |
void |
close() |
com.google.common.collect.ImmutableList<AndroidDevice> |
getDevices(boolean quiet) |
void |
installApk(SourcePathResolverAdapter pathResolver,
HasInstallableApk hasInstallableApk,
boolean installViaSd,
boolean quiet,
String processName)
Install apk on all matching devices.
|
static void |
setDevicesSupplierForTests(Optional<java.util.function.Supplier<com.google.common.collect.ImmutableList<AndroidDevice>>> devicesSupplierForTests) |
void |
startActivity(SourcePathResolverAdapter pathResolver,
HasInstallableApk hasInstallableApk,
String activity,
boolean waitForDebugger) |
static String |
tryToExtractPackageNameFromManifest(SourcePathResolverAdapter pathResolver,
HasInstallableApk.ApkInfo apkInfo) |
void |
uninstallApp(String packageName,
boolean shouldKeepUserData)
Uninstall apk from all matching devices.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitadbCallOrThrowpublic static final Pattern PACKAGE_NAME_PATTERN
public AdbHelper(AdbOptions adbOptions, TargetDeviceOptions deviceOptions, ToolchainProvider toolchainProvider, java.util.function.Supplier<ExecutionContext> contextSupplier, boolean restartAdbOnFailure, com.google.common.collect.ImmutableList<String> rapidInstallTypes)
public static void setDevicesSupplierForTests(Optional<java.util.function.Supplier<com.google.common.collect.ImmutableList<AndroidDevice>>> devicesSupplierForTests)
public com.google.common.collect.ImmutableList<AndroidDevice> getDevices(boolean quiet)
getDevices in interface AndroidDevicesHelperpublic void adbCall(String description, AndroidDevicesHelper.AdbDeviceCallable func, boolean quiet) throws InterruptedException
AdbDeviceCallable for all matching devices. This functions performs device
filtering based on three possible arguments:
-e (emulator-only) - only emulators are passing the filter -d (device-only) - only real devices are passing the filter -s (serial) - only device/emulator with specific serial number are passing the filter
If more than one device matches the filter this function will fail unless multi-install mode is enabled (-x). This flag is used as a marker that user understands that multiple devices will be used to install the apk if needed.
adbCall in interface AndroidDevicesHelperInterruptedExceptionpublic void installApk(SourcePathResolverAdapter pathResolver, HasInstallableApk hasInstallableApk, boolean installViaSd, boolean quiet, @Nullable String processName) throws InterruptedException
AndroidDevicesHelper-e (emulator-only) - only emulators are passing the filter -d (device-only) - only real devices are passing the filter -s (serial) - only device/emulator with specific serial number are passing the filter
If more than one device matches the filter this function will fail unless multi-install mode is enabled (-x). This flag is used as a marker that user understands that multiple devices will be used to install the apk if needed.
installApk in interface AndroidDevicesHelperInterruptedExceptionpublic void startActivity(SourcePathResolverAdapter pathResolver, HasInstallableApk hasInstallableApk, @Nullable String activity, boolean waitForDebugger) throws IOException
startActivity in interface AndroidDevicesHelperIOExceptionpublic void uninstallApp(String packageName, boolean shouldKeepUserData) throws InterruptedException
uninstallApp in interface AndroidDevicesHelperInterruptedExceptioninstallApk(SourcePathResolverAdapter, HasInstallableApk, boolean, boolean, String)public static String tryToExtractPackageNameFromManifest(SourcePathResolverAdapter pathResolver, HasInstallableApk.ApkInfo apkInfo)
public void close()
close in interface Closeableclose in interface AutoCloseable