@Override public void installApks(ImmutableList<Path> apks, InstallOptions installOptions) { ImmutableList<File> apkFiles = apks.stream().map(Path::toFile).collect(toImmutableList()); try { if (getVersion() .isGreaterOrEqualThan(AndroidVersion.ALLOW_SPLIT_APK_INSTALLATION.getApiLevel())) { device.installPackages( apkFiles, installOptions.getAllowReinstall(), installOptions.getAllowDowngrade() ? ImmutableList.of("-d") : ImmutableList.of(), installOptions.getTimeout().toMillis(), TimeUnit.MILLISECONDS); } else { device.installPackage( Iterables.getOnlyElement(apkFiles).toString(), installOptions.getAllowReinstall(), installOptions.getAllowDowngrade() ? "-d" : null); } } catch (InstallException e) { throw InstallationException.builder() .withCause(e) .withMessage("Installation of the app failed.") .build(); } } }
private static void validateArguments(@NonNull IDevice device, @NonNull List<File> apks) { if (apks.isEmpty()) { throw new IllegalArgumentException( "List of APKs is empty: the main APK must be specified."); } for (File apk: apks) { if (!apk.isFile()) { throw new IllegalArgumentException("Invalid File: " + apk.getPath()); } } int apiWithSplitApk = AndroidVersion.ALLOW_SPLIT_APK_INSTALLATION.getApiLevel(); if (!device.getVersion().isGreaterOrEqualThan(apiWithSplitApk)) { throw new IllegalArgumentException( "Cannot install split APKs on device with API level < " + apiWithSplitApk); } }
@Override public boolean supportsFeature(@NonNull Feature feature) { switch (feature) { case SCREEN_RECORD: if (!getVersion().isGreaterOrEqualThan(19)) { return false; } if (mHasScreenRecorder == null) { mHasScreenRecorder = hasBinary(SCREEN_RECORDER_DEVICE_PATH); } return mHasScreenRecorder; case PROCSTATS: return getVersion().isGreaterOrEqualThan(19); default: return false; } }
!context.getMainProject().getMinSdkVersion().isGreaterOrEqualThan(21)) { Map<String,FolderConfiguration> folderToConfig = Maps.newHashMap(); Map<FolderConfiguration,File> configToFile = Maps.newHashMap();
!context.getMainProject().getMinSdkVersion().isGreaterOrEqualThan(21)) { Map<String,FolderConfiguration> folderToConfig = Maps.newHashMap(); Map<FolderConfiguration,File> configToFile = Maps.newHashMap();
private SplitApkInstaller(@NonNull IDevice device, @NonNull List<File> apks, @NonNull String options) { mDevice = device; mApks = apks; mOptions = options; // Use "cmd package" when possible to avoid starting up a new VM mPrefix = mDevice.getVersion().isGreaterOrEqualThan( AndroidVersion.BINDER_CMD_AVAILABLE.getApiLevel()) ? "cmd package" : "pm"; }