use of com.android.tools.build.bundletool.device.BadgingInfoParser.BadgingInfo in project bundletool by google.
the class InstallMultiApksCommand method apksWithPackageName.
private static Optional<PackagePathVersion> apksWithPackageName(Path apksArchivePath, DeviceSpec deviceSpec, Supplier<Aapt2Command> aapt2CommandSupplier) {
try (TempDirectory tempDirectory = new TempDirectory()) {
// Any of the extracted .apk/.apex files will work.
Path extractedFile = ExtractApksCommand.builder().setApksArchivePath(apksArchivePath).setDeviceSpec(deviceSpec).setOutputDirectory(tempDirectory.getPath()).build().execute().get(0);
BadgingInfo badgingInfo = BadgingInfoParser.parse(aapt2CommandSupplier.get().dumpBadging(extractedFile));
return Optional.of(PackagePathVersion.create(apksArchivePath, badgingInfo.getPackageName(), badgingInfo.getVersionCode()));
} catch (IncompatibleDeviceException e) {
logger.warning(String.format("Unable to determine package name of %s, as it is not compatible with the attached" + " device. Skipping.", apksArchivePath));
return Optional.empty();
}
}
use of com.android.tools.build.bundletool.device.BadgingInfoParser.BadgingInfo in project bundletool by google.
the class BadgingInfoParserTest method parse_matchingCase.
@Test
public void parse_matchingCase() {
// GIVEN an input with a package name...
ImmutableList<String> input = ImmutableList.of("package: name='com.google.android.media.swcodec' versionCode='292200000'" + " versionName='' platformBuildVersionName='' platformBuildVersionCode=''" + " compileSdkVersion='29' compileSdkVersionCodename='10'", "application: label='' icon=''", "sdkVersion:'29'", "maxSdkVersion:'29'", "");
// WHEN parsed
BadgingInfo packageName = BadgingInfoParser.parse(input);
// THEN the correct package name is returned.
assertThat(packageName).isEqualTo(BadgingInfo.create("com.google.android.media.swcodec", 292200000));
}
Aggregations