Search in sources :

Example 1 with BadgingInfo

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();
    }
}
Also used : Path(java.nio.file.Path) ZipPath(com.android.tools.build.bundletool.model.ZipPath) TempDirectory(com.android.tools.build.bundletool.io.TempDirectory) IncompatibleDeviceException(com.android.tools.build.bundletool.model.exceptions.IncompatibleDeviceException) BadgingInfo(com.android.tools.build.bundletool.device.BadgingInfoParser.BadgingInfo)

Example 2 with BadgingInfo

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));
}
Also used : BadgingInfo(com.android.tools.build.bundletool.device.BadgingInfoParser.BadgingInfo) Test(org.junit.Test)

Aggregations

BadgingInfo (com.android.tools.build.bundletool.device.BadgingInfoParser.BadgingInfo)2 TempDirectory (com.android.tools.build.bundletool.io.TempDirectory)1 ZipPath (com.android.tools.build.bundletool.model.ZipPath)1 IncompatibleDeviceException (com.android.tools.build.bundletool.model.exceptions.IncompatibleDeviceException)1 Path (java.nio.file.Path)1 Test (org.junit.Test)1