use of com.android.tools.build.bundletool.model.AndroidManifest in project bundletool by google.
the class BuildSdkApksManagerTest method sdkManifestMutation_patchVersionNotSet_defaultPatchVersionAdded.
@Test
public void sdkManifestMutation_patchVersionNotSet_defaultPatchVersionAdded() throws Exception {
SdkBundle sdkBundle = new SdkBundleBuilder().setModule(new BundleModuleBuilder("base").setManifest(androidManifest(PACKAGE_NAME, withSdkLibraryElement("20"))).build()).build();
execute(sdkBundle);
ZipFile apkSetFile = new ZipFile(outputFilePath.toFile());
BuildSdkApksResult result = extractTocFromSdkApkSetFile(apkSetFile, tmpDir);
Variant variant = result.getVariant(0);
ApkDescription apkDescription = variant.getApkSet(0).getApkDescription(0);
File apkFile = extractFromApkSetFile(apkSetFile, apkDescription.getPath(), tmpDir);
AndroidManifest manifest = extractAndroidManifest(apkFile, tmpDir);
assertThat(manifest.getMetadataValue(SDK_PATCH_VERSION_ATTRIBUTE_NAME)).hasValue(DEFAULT_SDK_PATCH_VERSION);
}
use of com.android.tools.build.bundletool.model.AndroidManifest in project bundletool by google.
the class CheckTransparencyCommandTest method bundleMode_verificationFailed_transparencyKeyCertificateNotProvidedByUser.
@Test
public void bundleMode_verificationFailed_transparencyKeyCertificateNotProvidedByUser() throws Exception {
// The public key transparencyKeyCertificate used to create JWS does not match the private key,
// and will result
// in signature verification failure later.
String serializedJws = createJwsToken(CodeTransparency.getDefaultInstance(), CertificateFactory.buildSelfSignedCertificate(kpg.generateKeyPair(), "CN=CheckTransparencyCommandTest_BadCertificate"), transparencyPrivateKey);
AppBundleBuilder appBundle = new AppBundleBuilder().addModule("base", module -> module.setManifest(androidManifest("com.test.app"))).addMetadataFile(BundleMetadata.BUNDLETOOL_NAMESPACE, BundleMetadata.TRANSPARENCY_SIGNED_FILE_NAME, CharSource.wrap(serializedJws).asByteSource(Charset.defaultCharset()));
new AppBundleSerializer().writeToDisk(appBundle.build(), bundlePath);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
CheckTransparencyCommand.builder().setMode(Mode.BUNDLE).setBundlePath(bundlePath).build().checkTransparency(new PrintStream(outputStream));
String output = new String(outputStream.toByteArray(), UTF_8);
assertThat(output).contains("No APK present. APK signature was not checked.");
assertThat(output).contains("Verification failed because code transparency signature is invalid.");
}
use of com.android.tools.build.bundletool.model.AndroidManifest in project bundletool by google.
the class FusingAndroidManifestMergerTest method mergeChildrenMode_onlyOneMetadataPerName.
@Test
public void mergeChildrenMode_onlyOneMetadataPerName() {
SetMultimap<BundleModuleName, AndroidManifest> manifests = createManifests(androidManifest("com.testapp", activityWithIntentFiltersAndMetadata("myActivity", /* intentFilters= */
ImmutableList.of(), /* metadata= */
ImmutableList.of("sharedMeta", "baseMeta"))), androidManifestForFeature("com.testapp.feature1", activityWithIntentFiltersAndMetadata("myActivity", /* intentFilters= */
ImmutableList.of(), /* metadata= */
ImmutableList.of("sharedMeta"))));
AndroidManifest merged = createMerger(Mode.MERGE_CHILDREN).merge(manifests);
AndroidManifest expected = AndroidManifest.create(androidManifest("com.testapp", activityWithIntentFiltersAndMetadata("myActivity", /* intentFilters= */
ImmutableList.of(), /* metadata= */
ImmutableList.of("sharedMeta", "baseMeta"))));
assertThat(merged).isEqualTo(expected);
}
use of com.android.tools.build.bundletool.model.AndroidManifest in project bundletool by google.
the class FusingAndroidManifestMergerTest method mergeChildrenMode_nonIntentFilterOrMetadataElements_notMerged.
@Test
public void mergeChildrenMode_nonIntentFilterOrMetadataElements_notMerged() {
SetMultimap<BundleModuleName, AndroidManifest> manifests = createManifests(androidManifest("com.testapp", withActivity("myActivity", activity -> activity.addChildElement(XmlProtoElementBuilder.create("elementBase")))), androidManifestForFeature("com.testapp.feature1", withActivity("myActivity", activity -> activity.addChildElement(XmlProtoElementBuilder.create("elementFeature")))));
AndroidManifest merged = createMerger(Mode.MERGE_CHILDREN).merge(manifests);
AndroidManifest expected = AndroidManifest.create(androidManifest("com.testapp", withActivity("myActivity", activity -> activity.addChildElement(XmlProtoElementBuilder.create("elementFeature")))));
assertThat(merged).isEqualTo(expected);
}
use of com.android.tools.build.bundletool.model.AndroidManifest in project bundletool by google.
the class FusingAndroidManifestMergerTest method mergeChildrenMode_keepTextNodesInsideElement.
@Test
public void mergeChildrenMode_keepTextNodesInsideElement() {
SetMultimap<BundleModuleName, AndroidManifest> manifests = createManifests(androidManifest("com.testapp", withActivity("myActivity", activity -> activity.addChildElement(XmlProtoElementBuilder.create("meta-data").addAttribute(XmlProtoAttributeBuilder.createAndroidAttribute(NAME_ATTRIBUTE_NAME, NAME_RESOURCE_ID).setValueAsString("meta"))))), androidManifestForFeature("com.testapp.feature1", withActivity("myActivity", activity -> activity.addChildText("text"))));
AndroidManifest merged = createMerger(Mode.MERGE_CHILDREN).merge(manifests);
AndroidManifest expected = AndroidManifest.create(androidManifest("com.testapp", withActivity("myActivity", activity -> activity.addChildText("text").addChildElement(XmlProtoElementBuilder.create("meta-data").addAttribute(XmlProtoAttributeBuilder.createAndroidAttribute(NAME_ATTRIBUTE_NAME, NAME_RESOURCE_ID).setValueAsString("meta"))))));
assertThat(merged).isEqualTo(expected);
}
Aggregations