platform_build_soong/apex/bootclasspath_fragment_test.go

1344 lines
40 KiB
Go
Raw Normal View History

// Copyright (C) 2021 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package apex
import (
"fmt"
"path"
"sort"
"strings"
"testing"
"android/soong/android"
"android/soong/dexpreopt"
"android/soong/java"
Support hidden API processing for modules that use platform APIs Previously, hidden API processing could only be done by those bootclasspath_fragment modules that either did not depend on any other fragments (e.g. art-bootclasspath-fragment) or only depended on APIs provided by other fragments (e.g. i18n-bootclasspath-fragment). That meant that modules like com.android.os.statsd-bootclasspath-fragment that depended on APIs provided by parts of the platform which are not yet part of another bootclasspath_fragment could not perform hidden API processing. This change adds support for a bootclasspath_fragment to specify the additional stubs needed to perform hidden API processing. It adds a new additional_stubs property that can be used to specify the additional stub libraries. Most bootclasspath_fragments that need to use the property will need access to the APIs provided by the android-non-updatable.* libraries. Rather than have each fragment explicitly specify the correct module for each scope it treats "android-non-updatable" as if it was a java_sdk_library that can provide different jars for each scope. Soong will handle mapping that to the correct android-non-updatable.* module. Bug: 179354495 Test: m out/soong/hiddenapi/hiddenapi-flags.csv \ out/soong/hiddenapi/hiddenapi-index.csv \ out/soong/hiddenapi/hiddenapi-stub-flags.txt \ out/soong/hiddenapi/hiddenapi-unsupported.csv - make sure that this change does not change the contents. m TARGET_BUILD_APPS=Calendar nothing Change-Id: Ia8b79830ed0e6d42100de03d76b0c51b7f6c8ade
2021-05-26 11:16:01 +02:00
"github.com/google/blueprint/proptools"
)
// Contains tests for bootclasspath_fragment logic from java/bootclasspath_fragment.go as the ART
// bootclasspath_fragment requires modules from the ART apex.
var prepareForTestWithBootclasspathFragment = android.GroupFixturePreparers(
java.PrepareForTestWithDexpreopt,
PrepareForTestWithApexBuildComponents,
)
// Some additional files needed for the art apex.
var prepareForTestWithArtApex = android.GroupFixturePreparers(
android.FixtureMergeMockFs(android.MockFS{
"com.android.art.avbpubkey": nil,
"com.android.art.pem": nil,
"system/sepolicy/apex/com.android.art-file_contexts": nil,
}),
dexpreopt.FixtureSetBootImageProfiles("art/build/boot/boot-image-profile.txt"),
)
func TestBootclasspathFragments_FragmentDependency(t *testing.T) {
result := android.GroupFixturePreparers(
prepareForTestWithBootclasspathFragment,
// Configure some libraries in the art bootclasspath_fragment and platform_bootclasspath.
java.FixtureConfigureBootJars("com.android.art:baz", "com.android.art:quuz"),
java.FixtureConfigureApexBootJars("someapex:foo", "someapex:bar"),
prepareForTestWithArtApex,
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
variables.BuildFlags = map[string]string{
"RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true",
}
}),
java.PrepareForTestWithJavaSdkLibraryFiles,
java.FixtureWithLastReleaseApis("foo", "baz"),
).RunTestWithBp(t, `
java_sdk_library {
name: "foo",
srcs: ["b.java"],
shared_library: false,
public: {
enabled: true,
},
system: {
enabled: true,
},
}
java_library {
name: "bar",
srcs: ["b.java"],
installable: true,
}
apex {
name: "com.android.art",
key: "com.android.art.key",
bootclasspath_fragments: ["art-bootclasspath-fragment"],
updatable: false,
}
apex_key {
name: "com.android.art.key",
public_key: "com.android.art.avbpubkey",
private_key: "com.android.art.pem",
}
java_sdk_library {
name: "baz",
apex_available: [
"com.android.art",
],
srcs: ["b.java"],
shared_library: false,
public: {
enabled: true,
},
system: {
enabled: true,
},
test: {
enabled: true,
},
}
java_library {
name: "quuz",
apex_available: [
"com.android.art",
],
srcs: ["b.java"],
compile_dex: true,
}
bootclasspath_fragment {
name: "art-bootclasspath-fragment",
image_name: "art",
// Must match the "com.android.art:" entries passed to FixtureConfigureBootJars above.
contents: ["baz", "quuz"],
apex_available: [
"com.android.art",
],
hidden_api: {
split_packages: ["*"],
},
}
bootclasspath_fragment {
name: "other-bootclasspath-fragment",
contents: ["foo", "bar"],
fragments: [
{
apex: "com.android.art",
module: "art-bootclasspath-fragment",
},
],
hidden_api: {
split_packages: ["*"],
},
}
`,
)
checkAPIScopeStubs := func(message string, info java.HiddenAPIInfo, apiScope *java.HiddenAPIScope, expectedPaths ...string) {
t.Helper()
paths := info.TransitiveStubDexJarsByScope.StubDexJarsForScope(apiScope)
android.AssertPathsRelativeToTopEquals(t, fmt.Sprintf("%s %s", message, apiScope), expectedPaths, paths)
}
// Check stub dex paths exported by art.
artFragment := result.Module("art-bootclasspath-fragment", "android_common")
artInfo, _ := android.SingletonModuleProvider(result, artFragment, java.HiddenAPIInfoProvider)
bazPublicStubs := "out/soong/.intermediates/baz.stubs.exportable/android_common/dex/baz.stubs.exportable.jar"
bazSystemStubs := "out/soong/.intermediates/baz.stubs.exportable.system/android_common/dex/baz.stubs.exportable.system.jar"
bazTestStubs := "out/soong/.intermediates/baz.stubs.exportable.test/android_common/dex/baz.stubs.exportable.test.jar"
checkAPIScopeStubs("art", artInfo, java.PublicHiddenAPIScope, bazPublicStubs)
checkAPIScopeStubs("art", artInfo, java.SystemHiddenAPIScope, bazSystemStubs)
checkAPIScopeStubs("art", artInfo, java.TestHiddenAPIScope, bazTestStubs)
checkAPIScopeStubs("art", artInfo, java.CorePlatformHiddenAPIScope)
// Check stub dex paths exported by other.
otherFragment := result.Module("other-bootclasspath-fragment", "android_common")
otherInfo, _ := android.SingletonModuleProvider(result, otherFragment, java.HiddenAPIInfoProvider)
fooPublicStubs := "out/soong/.intermediates/foo.stubs.exportable/android_common/dex/foo.stubs.exportable.jar"
fooSystemStubs := "out/soong/.intermediates/foo.stubs.exportable.system/android_common/dex/foo.stubs.exportable.system.jar"
checkAPIScopeStubs("other", otherInfo, java.PublicHiddenAPIScope, bazPublicStubs, fooPublicStubs)
checkAPIScopeStubs("other", otherInfo, java.SystemHiddenAPIScope, bazSystemStubs, fooSystemStubs)
checkAPIScopeStubs("other", otherInfo, java.TestHiddenAPIScope, bazTestStubs, fooSystemStubs)
checkAPIScopeStubs("other", otherInfo, java.CorePlatformHiddenAPIScope)
}
func TestBootclasspathFragmentInArtApex(t *testing.T) {
commonPreparer := android.GroupFixturePreparers(
prepareForTestWithBootclasspathFragment,
prepareForTestWithArtApex,
android.FixtureWithRootAndroidBp(`
apex {
name: "com.android.art",
key: "com.android.art.key",
bootclasspath_fragments: [
"art-bootclasspath-fragment",
],
// bar (like foo) should be transitively included in this apex because it is part of the
// art-bootclasspath-fragment bootclasspath_fragment.
updatable: false,
}
apex_key {
name: "com.android.art.key",
public_key: "testkey.avbpubkey",
private_key: "testkey.pem",
}
`),
)
contentsInsert := func(contents []string) string {
insert := ""
if contents != nil {
insert = fmt.Sprintf(`contents: ["%s"],`, strings.Join(contents, `", "`))
}
return insert
}
addSource := func(contents ...string) android.FixturePreparer {
text := fmt.Sprintf(`
bootclasspath_fragment {
name: "art-bootclasspath-fragment",
image_name: "art",
%s
apex_available: [
"com.android.art",
],
hidden_api: {
split_packages: ["*"],
},
}
`, contentsInsert(contents))
for _, content := range contents {
text += fmt.Sprintf(`
java_library {
name: "%[1]s",
srcs: ["%[1]s.java"],
installable: true,
apex_available: [
"com.android.art",
],
}
`, content)
}
return android.FixtureAddTextFile("art/build/boot/Android.bp", text)
}
addPrebuilt := func(prefer bool, contents ...string) android.FixturePreparer {
text := fmt.Sprintf(`
prebuilt_apex {
name: "com.android.art",
arch: {
arm64: {
src: "com.android.art-arm64.apex",
},
arm: {
src: "com.android.art-arm.apex",
},
},
exported_bootclasspath_fragments: ["art-bootclasspath-fragment"],
}
prebuilt_bootclasspath_fragment {
name: "art-bootclasspath-fragment",
image_name: "art",
%s
prefer: %t,
apex_available: [
"com.android.art",
],
hidden_api: {
annotation_flags: "hiddenapi/annotation-flags.csv",
metadata: "hiddenapi/metadata.csv",
index: "hiddenapi/index.csv",
stub_flags: "hiddenapi/stub-flags.csv",
all_flags: "hiddenapi/all-flags.csv",
},
}
`, contentsInsert(contents), prefer)
for _, content := range contents {
text += fmt.Sprintf(`
java_import {
name: "%[1]s",
prefer: %[2]t,
jars: ["%[1]s.jar"],
apex_available: [
"com.android.art",
],
compile_dex: true,
}
`, content, prefer)
}
return android.FixtureAddTextFile("prebuilts/module_sdk/art/Android.bp", text)
}
t.Run("boot image files from source", func(t *testing.T) {
result := android.GroupFixturePreparers(
commonPreparer,
// Configure some libraries in the art bootclasspath_fragment that match the source
// bootclasspath_fragment's contents property.
java.FixtureConfigureBootJars("com.android.art:foo", "com.android.art:bar"),
dexpreopt.FixtureSetTestOnlyArtBootImageJars("com.android.art:foo", "com.android.art:bar"),
addSource("foo", "bar"),
java.FixtureSetBootImageInstallDirOnDevice("art", "apex/com.android.art/javalib"),
).RunTest(t)
ensureExactContents(t, result.TestContext, "com.android.art", "android_common_com.android.art", []string{
"etc/boot-image.prof",
"etc/classpaths/bootclasspath.pb",
"javalib/bar.jar",
"javalib/foo.jar",
})
java.CheckModuleDependencies(t, result.TestContext, "com.android.art", "android_common_com.android.art", []string{
`art-bootclasspath-fragment`,
`com.android.art.key`,
Fix the args used to dexpreopt system server jars in prebuilt apexes For prebuilts, java.dexpreopt gets called twice 1. in the context of the top-level prebuilt apex 2. in the context of the java_library shim Only the artifacts of (1) get installed. The artifacts generated by 2) are unused. However the args used to generate the artifacts of (1) are incorrect. It uses moduleName(ctx) to do special-handling of apex system server jars. This special-handling does not happen in (1), so although dexpreopt artficats get generated, they get generated with the wrong args. To fix this, add an additional parameter in java.dexpreopt to pass the libraryName explicitly. Details - Delete moduleName function. This was used to determine the java library name, which is no longer safe - Add a libraryName parameter to java.dexpreopt - Most module types will use j.Name() as libraryName - prebuilt_apex and apex_set will iterate over its `contents` and use each element as libraryName when invoking java.dexpreopt With the correct args passed from (1), we can drop j.dexpreopt from (2) completely. Dropping (2) also breaks profile guided dexpreopt tests. These currently operate on (2). They will be moved to (1) in the next CL of this stack. Test: presubmits Test: lunch cf_x86_64_auto-trunk_staging-userdebug && m nothing (this was a postsubmit failure with aosp/2923733) Test: art_standalone_dexpreopt_tests on next https://android-build.corp.google.com/builds/abtd/run/L86000030001579256 Test: art-gtest on git_master-art-host https://android-build.corp.google.com/builds/abtd/run/L07800030001550262 Bug: 308790457 Bug: 322255144 Change-Id: I8eb604c82f1fa5289d3cd1a20084d56e4d7485e3
2024-01-24 00:56:29 +01:00
`dex2oatd`,
})
// Make sure that the source bootclasspath_fragment copies its dex files to the predefined
// locations for the art image.
Refactor dexpreopt for boot jars to make it flexible to config changes. In the past, dexpreopt for boot jars was very inflexible, and it was incredibly hard to make a change that is as simple as adding a jar to a boot image. Boot image generation was handled by "platform_bootclasspath" and "bootclasspath_fragment" separately. This caused not only code duplication but also the inflexiblity as such a design did not fit today's use cases, where a boot image may take jars from multiple mainline modules and the platform, and a mainline module can contribute to multiple boot images. The design casued a huge maintenance burden as any change to the boot image cost multi-week efforts. In recent years, efforts have been made to improve this a bit by a bit. This change is another step towards making dexpreopt reasonable. After this change, all boot images are generated by "dex_bootjars", which is in build/soong and is therefore available on both the full source tree and the thin manifest (master-art). The change decouples profile generation/extraction from boot image generation. Profiles for mainline modules are still handled by "bootclasspath_fragment" because they need to be packed into APEXes when building mainline modules and extracted from APEXes whem building the system image from prebuilt modules. Boot images are not handled by "bootclasspath_fragment" anymore. Bug: 290583827 Test: m (all existing tests are still passing) Test: Manually checked that the boot images are exactly the same as before. Change-Id: Ib5a5f401bee334ffcab5c26618e0c8888b84575a
2023-07-13 12:03:38 +02:00
module := result.ModuleForTests("dex_bootjars", "android_common")
checkCopiesToPredefinedLocationForArt(t, result.Config, module, "bar", "foo")
})
t.Run("generate boot image profile even if dexpreopt is disabled", func(t *testing.T) {
result := android.GroupFixturePreparers(
commonPreparer,
// Configure some libraries in the art bootclasspath_fragment that match the source
// bootclasspath_fragment's contents property.
java.FixtureConfigureBootJars("com.android.art:foo", "com.android.art:bar"),
addSource("foo", "bar"),
java.FixtureSetBootImageInstallDirOnDevice("art", "system/framework"),
dexpreopt.FixtureDisableDexpreoptBootImages(true),
).RunTest(t)
ensureExactContents(t, result.TestContext, "com.android.art", "android_common_com.android.art", []string{
"etc/boot-image.prof",
"etc/classpaths/bootclasspath.pb",
"javalib/bar.jar",
"javalib/foo.jar",
})
})
t.Run("boot image disable generate profile", func(t *testing.T) {
result := android.GroupFixturePreparers(
commonPreparer,
// Configure some libraries in the art bootclasspath_fragment that match the source
// bootclasspath_fragment's contents property.
java.FixtureConfigureBootJars("com.android.art:foo", "com.android.art:bar"),
addSource("foo", "bar"),
dexpreopt.FixtureDisableGenerateProfile(true),
).RunTest(t)
files := getFiles(t, result.TestContext, "com.android.art", "android_common_com.android.art")
for _, file := range files {
matched, _ := path.Match("etc/boot-image.prof", file.path)
android.AssertBoolEquals(t, "\"etc/boot-image.prof\" should not be in the APEX", matched, false)
}
})
t.Run("boot image files with preferred prebuilt", func(t *testing.T) {
result := android.GroupFixturePreparers(
commonPreparer,
// Configure some libraries in the art bootclasspath_fragment that match the source
// bootclasspath_fragment's contents property.
java.FixtureConfigureBootJars("com.android.art:foo", "com.android.art:bar"),
dexpreopt.FixtureSetTestOnlyArtBootImageJars("com.android.art:foo", "com.android.art:bar"),
addSource("foo", "bar"),
// Make sure that a preferred prebuilt with consistent contents doesn't affect the apex.
addPrebuilt(true, "foo", "bar"),
java.FixtureSetBootImageInstallDirOnDevice("art", "apex/com.android.art/javalib"),
).RunTest(t)
Handle installation rules for co-existing prebuilts Every module belonging to a single mainline module family will be hidden from make, except the one which has been flagged using apex_contributions Details - Introduce a new `source_apex_name` property to prebuilt_apex and override_apex. This property will be used to identify the source equivalent of a prebuilt soong apex module. - Create an N-ary tree from source to prebuilt(s). The tree wil be rooted at the source module. - In a subsequent mutator, visit every node in the tree(s). Query apex_contributions and store the handle of the node which is "active" (if any) - In the same mutator, do another pass over the tree. Invoke `HideFromMake` on every node which is not "active". The two-pass approach is needed PrebuiltSelectionInfoProvider does not know about the inter source-prebuilt dependency, this dependency can only be known by doing a graph walk of the N-ary tree. Some tangential implementation details - Each prebuilt apex has an internal deapxer module that is responsible for generating the deapex ninja rules. The name of this internal module uses the BaseModuleName (without the prebuilt_ prefix). Since we can have multiple prebuilt soong modules in trunk stable, change this to follow the name of the prebuilt module in order to avoid name collisions. Update existing unit tests accordingly Bug: 316179314 Test: go test ./apex -run TestInstallationRulesForMultipleApexPrebuilts Test: m nothing --no-skip-soong-tests Test: presubmits Change-Id: I58aa99d5e6a9859954614e6db9a8e9e2e581642d
2024-01-03 19:57:03 +01:00
ensureExactDeapexedContents(t, result.TestContext, "prebuilt_com.android.art", "android_common", []string{
"etc/boot-image.prof",
"javalib/bar.jar",
"javalib/foo.jar",
})
java.CheckModuleDependencies(t, result.TestContext, "com.android.art", "android_common_com.android.art", []string{
`art-bootclasspath-fragment`,
`com.android.art.key`,
Fix the args used to dexpreopt system server jars in prebuilt apexes For prebuilts, java.dexpreopt gets called twice 1. in the context of the top-level prebuilt apex 2. in the context of the java_library shim Only the artifacts of (1) get installed. The artifacts generated by 2) are unused. However the args used to generate the artifacts of (1) are incorrect. It uses moduleName(ctx) to do special-handling of apex system server jars. This special-handling does not happen in (1), so although dexpreopt artficats get generated, they get generated with the wrong args. To fix this, add an additional parameter in java.dexpreopt to pass the libraryName explicitly. Details - Delete moduleName function. This was used to determine the java library name, which is no longer safe - Add a libraryName parameter to java.dexpreopt - Most module types will use j.Name() as libraryName - prebuilt_apex and apex_set will iterate over its `contents` and use each element as libraryName when invoking java.dexpreopt With the correct args passed from (1), we can drop j.dexpreopt from (2) completely. Dropping (2) also breaks profile guided dexpreopt tests. These currently operate on (2). They will be moved to (1) in the next CL of this stack. Test: presubmits Test: lunch cf_x86_64_auto-trunk_staging-userdebug && m nothing (this was a postsubmit failure with aosp/2923733) Test: art_standalone_dexpreopt_tests on next https://android-build.corp.google.com/builds/abtd/run/L86000030001579256 Test: art-gtest on git_master-art-host https://android-build.corp.google.com/builds/abtd/run/L07800030001550262 Bug: 308790457 Bug: 322255144 Change-Id: I8eb604c82f1fa5289d3cd1a20084d56e4d7485e3
2024-01-24 00:56:29 +01:00
`dex2oatd`,
`prebuilt_com.android.art`,
})
// Make sure that the prebuilt bootclasspath_fragment copies its dex files to the predefined
// locations for the art image.
Refactor dexpreopt for boot jars to make it flexible to config changes. In the past, dexpreopt for boot jars was very inflexible, and it was incredibly hard to make a change that is as simple as adding a jar to a boot image. Boot image generation was handled by "platform_bootclasspath" and "bootclasspath_fragment" separately. This caused not only code duplication but also the inflexiblity as such a design did not fit today's use cases, where a boot image may take jars from multiple mainline modules and the platform, and a mainline module can contribute to multiple boot images. The design casued a huge maintenance burden as any change to the boot image cost multi-week efforts. In recent years, efforts have been made to improve this a bit by a bit. This change is another step towards making dexpreopt reasonable. After this change, all boot images are generated by "dex_bootjars", which is in build/soong and is therefore available on both the full source tree and the thin manifest (master-art). The change decouples profile generation/extraction from boot image generation. Profiles for mainline modules are still handled by "bootclasspath_fragment" because they need to be packed into APEXes when building mainline modules and extracted from APEXes whem building the system image from prebuilt modules. Boot images are not handled by "bootclasspath_fragment" anymore. Bug: 290583827 Test: m (all existing tests are still passing) Test: Manually checked that the boot images are exactly the same as before. Change-Id: Ib5a5f401bee334ffcab5c26618e0c8888b84575a
2023-07-13 12:03:38 +02:00
module := result.ModuleForTests("dex_bootjars", "android_common")
checkCopiesToPredefinedLocationForArt(t, result.Config, module, "bar", "foo")
})
t.Run("source with inconsistency between config and contents", func(t *testing.T) {
android.GroupFixturePreparers(
commonPreparer,
// Create an inconsistency between the ArtApexJars configuration and the art source
// bootclasspath_fragment module's contents property.
java.FixtureConfigureBootJars("com.android.art:foo"),
addSource("foo", "bar"),
).
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(`\QArtApexJars configuration specifies []string{"foo"}, contents property specifies []string{"foo", "bar"}\E`)).
RunTest(t)
})
t.Run("prebuilt with inconsistency between config and contents", func(t *testing.T) {
android.GroupFixturePreparers(
commonPreparer,
// Create an inconsistency between the ArtApexJars configuration and the art
// prebuilt_bootclasspath_fragment module's contents property.
java.FixtureConfigureBootJars("com.android.art:foo"),
addPrebuilt(false, "foo", "bar"),
).
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(`\QArtApexJars configuration specifies []string{"foo"}, contents property specifies []string{"foo", "bar"}\E`)).
RunTest(t)
})
t.Run("preferred prebuilt with inconsistency between config and contents", func(t *testing.T) {
android.GroupFixturePreparers(
commonPreparer,
// Create an inconsistency between the ArtApexJars configuration and the art
// prebuilt_bootclasspath_fragment module's contents property.
java.FixtureConfigureBootJars("com.android.art:foo"),
addPrebuilt(true, "foo", "bar"),
// Source contents property is consistent with the config.
addSource("foo"),
).
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(`\QArtApexJars configuration specifies []string{"foo"}, contents property specifies []string{"foo", "bar"}\E`)).
RunTest(t)
})
t.Run("source preferred and prebuilt with inconsistency between config and contents", func(t *testing.T) {
android.GroupFixturePreparers(
commonPreparer,
// Create an inconsistency between the ArtApexJars configuration and the art
// prebuilt_bootclasspath_fragment module's contents property.
java.FixtureConfigureBootJars("com.android.art:foo"),
addPrebuilt(false, "foo", "bar"),
// Source contents property is consistent with the config.
addSource("foo"),
// This should pass because while the prebuilt is inconsistent with the configuration it is
// not actually used.
).RunTest(t)
})
}
func TestBootclasspathFragmentInPrebuiltArtApex(t *testing.T) {
preparers := android.GroupFixturePreparers(
prepareForTestWithBootclasspathFragment,
prepareForTestWithArtApex,
android.FixtureMergeMockFs(android.MockFS{
"com.android.art-arm64.apex": nil,
"com.android.art-arm.apex": nil,
}),
// Configure some libraries in the art bootclasspath_fragment.
Improve realism of boot jar tests Boot jars, updatable boot jars and art apex jars are part of two separate but related configuration objects, the main Config struct (actually the nested productVariables struct) and the dexpreopt specific GlobalConfig. The fields in both are initialized from the same data in the make config files but handled separately. Previously each test that used one of the configuration objects would generally just initialize the one it used. That would make the test sensitive to the specific configuration object that was used. A refactoring that change the code from using one configuration object to the other would cause the test to fail. Also, some tests would inadvertently create invalid configurations by setting ArtApexJars without also setting BootJars. While the ability to create invalid configurations is useful (and there are some tests that exist to verify the behavior in that case) most tests should not be using them. This change simplifies the configuration of the tests and improves their realism by: 1. Providing a new FixtureConfigureBootJars method that takes a set of boot jars and sets ArtApexJars, and BootJars in the dexpreopt.GlobalConfig and BootJars in the product variables too. 2. Providing a new FixtureConfigureUpdatableBootJars method that takes a set of boot jars and sets UpdatableBootJars in both the dexpreopt.GlobalConfig and productVariables. 3. Migrating existing tests to use these new methods. Some tests still use the dexpreopt.FixtureSet...Jars() methods directly, generally to create invalid configurations. Bug: 177892522 Test: m nothing Change-Id: I4d8f0b9762cfcc7ae6383bef08563d7c3fa13955
2021-04-12 21:02:36 +02:00
java.FixtureConfigureBootJars("com.android.art:foo", "com.android.art:bar"),
dexpreopt.FixtureSetTestOnlyArtBootImageJars("com.android.art:foo", "com.android.art:bar"),
java.FixtureSetBootImageInstallDirOnDevice("art", "apex/com.android.art/javalib"),
)
bp := `
prebuilt_apex {
name: "com.android.art",
arch: {
arm64: {
src: "com.android.art-arm64.apex",
},
arm: {
src: "com.android.art-arm.apex",
},
},
exported_bootclasspath_fragments: ["art-bootclasspath-fragment"],
}
java_import {
name: "foo",
jars: ["foo.jar"],
apex_available: [
"com.android.art",
],
}
java_import {
name: "bar",
jars: ["bar.jar"],
apex_available: [
"com.android.art",
],
}
prebuilt_bootclasspath_fragment {
name: "art-bootclasspath-fragment",
image_name: "art",
// Must match the "com.android.art:" entries passed to FixtureConfigureBootJars above.
contents: ["foo", "bar"],
apex_available: [
"com.android.art",
],
hidden_api: {
annotation_flags: "hiddenapi/annotation-flags.csv",
metadata: "hiddenapi/metadata.csv",
index: "hiddenapi/index.csv",
stub_flags: "hiddenapi/stub-flags.csv",
all_flags: "hiddenapi/all-flags.csv",
},
}
// A prebuilt apex with the same apex_name that shouldn't interfere when it isn't enabled.
prebuilt_apex {
name: "com.mycompany.android.art",
apex_name: "com.android.art",
%s
src: "com.mycompany.android.art.apex",
exported_bootclasspath_fragments: ["art-bootclasspath-fragment"],
}
`
t.Run("disabled alternative APEX", func(t *testing.T) {
result := preparers.RunTestWithBp(t, fmt.Sprintf(bp, "enabled: false,"))
java.CheckModuleDependencies(t, result.TestContext, "com.android.art", "android_common_com.android.art", []string{
Move dexpreopt processing from java_*_import to prebuilt_apex dexpreopt of apex system server from prebuilts involves three soong modules 1. prebuilt_apex / apex_set 2. an internal deapexer module created by the prebuilt apex 3. java_import/java_sdk_library (3) acts as a shim for the deapexer to set the dexjar extracted from the prebuilt apex. This methodolody requires a 1:1 correspondence across the three modules This breaks down when we have multiple versions of the same prebuilt apex in the tree. In preparation for this, move the dexpreopt processing from (3) to (1). Each prebuilt_apex will create the necessary rules for dexpreopting the jars deapexed from itself. In the future, apex_contributions will be used to pick which service-foo.{odex|.vdex} to install depending on which prebuilt apex is selected. Implementation details - Embed dexpreopter in prebuiltApex structs so that this module type can register the dexpreopt rules. Since a single apex can have multiple system server jars, this also requires creating an additional scope in dexpreopt.go to prevent name collisions - Add the dexpreopt modules as required in initApexFilesForAndroidMk - Add the depreopt modules to androidMk in AndroidMkEntries. Drop the equivalent from java_import and java_sdk_library_import Bug: 308790457 Test: existing soong unit tests Test: lunch cf_x86_64_phone-next-userdebug && m out/target/product/vsoc_x86_64/system/apex/com.google.android.adservices.apex Test: Verified that the above command installs /out/target/product/vsoc_x86_64/system/framework/oat/x86_64/apex@com.android.adservices@javalib@service-adservices.jar@classes.{odex|vdex} and the equivalent files of service-sdksandbox Test: presubmits Change-Id: I01cea8956d2857fb864b415e73d3d2686d069b5e
2023-12-06 20:40:24 +01:00
`dex2oatd`,
`prebuilt_art-bootclasspath-fragment`,
Handle installation rules for co-existing prebuilts Every module belonging to a single mainline module family will be hidden from make, except the one which has been flagged using apex_contributions Details - Introduce a new `source_apex_name` property to prebuilt_apex and override_apex. This property will be used to identify the source equivalent of a prebuilt soong apex module. - Create an N-ary tree from source to prebuilt(s). The tree wil be rooted at the source module. - In a subsequent mutator, visit every node in the tree(s). Query apex_contributions and store the handle of the node which is "active" (if any) - In the same mutator, do another pass over the tree. Invoke `HideFromMake` on every node which is not "active". The two-pass approach is needed PrebuiltSelectionInfoProvider does not know about the inter source-prebuilt dependency, this dependency can only be known by doing a graph walk of the N-ary tree. Some tangential implementation details - Each prebuilt apex has an internal deapxer module that is responsible for generating the deapex ninja rules. The name of this internal module uses the BaseModuleName (without the prebuilt_ prefix). Since we can have multiple prebuilt soong modules in trunk stable, change this to follow the name of the prebuilt module in order to avoid name collisions. Update existing unit tests accordingly Bug: 316179314 Test: go test ./apex -run TestInstallationRulesForMultipleApexPrebuilts Test: m nothing --no-skip-soong-tests Test: presubmits Change-Id: I58aa99d5e6a9859954614e6db9a8e9e2e581642d
2024-01-03 19:57:03 +01:00
`prebuilt_com.android.art.apex.selector`,
`prebuilt_com.android.art.deapexer`,
})
java.CheckModuleDependencies(t, result.TestContext, "art-bootclasspath-fragment", "android_common_com.android.art", []string{
`dex2oatd`,
`prebuilt_bar`,
Handle installation rules for co-existing prebuilts Every module belonging to a single mainline module family will be hidden from make, except the one which has been flagged using apex_contributions Details - Introduce a new `source_apex_name` property to prebuilt_apex and override_apex. This property will be used to identify the source equivalent of a prebuilt soong apex module. - Create an N-ary tree from source to prebuilt(s). The tree wil be rooted at the source module. - In a subsequent mutator, visit every node in the tree(s). Query apex_contributions and store the handle of the node which is "active" (if any) - In the same mutator, do another pass over the tree. Invoke `HideFromMake` on every node which is not "active". The two-pass approach is needed PrebuiltSelectionInfoProvider does not know about the inter source-prebuilt dependency, this dependency can only be known by doing a graph walk of the N-ary tree. Some tangential implementation details - Each prebuilt apex has an internal deapxer module that is responsible for generating the deapex ninja rules. The name of this internal module uses the BaseModuleName (without the prebuilt_ prefix). Since we can have multiple prebuilt soong modules in trunk stable, change this to follow the name of the prebuilt module in order to avoid name collisions. Update existing unit tests accordingly Bug: 316179314 Test: go test ./apex -run TestInstallationRulesForMultipleApexPrebuilts Test: m nothing --no-skip-soong-tests Test: presubmits Change-Id: I58aa99d5e6a9859954614e6db9a8e9e2e581642d
2024-01-03 19:57:03 +01:00
`prebuilt_com.android.art.deapexer`,
`prebuilt_foo`,
})
Refactor dexpreopt for boot jars to make it flexible to config changes. In the past, dexpreopt for boot jars was very inflexible, and it was incredibly hard to make a change that is as simple as adding a jar to a boot image. Boot image generation was handled by "platform_bootclasspath" and "bootclasspath_fragment" separately. This caused not only code duplication but also the inflexiblity as such a design did not fit today's use cases, where a boot image may take jars from multiple mainline modules and the platform, and a mainline module can contribute to multiple boot images. The design casued a huge maintenance burden as any change to the boot image cost multi-week efforts. In recent years, efforts have been made to improve this a bit by a bit. This change is another step towards making dexpreopt reasonable. After this change, all boot images are generated by "dex_bootjars", which is in build/soong and is therefore available on both the full source tree and the thin manifest (master-art). The change decouples profile generation/extraction from boot image generation. Profiles for mainline modules are still handled by "bootclasspath_fragment" because they need to be packed into APEXes when building mainline modules and extracted from APEXes whem building the system image from prebuilt modules. Boot images are not handled by "bootclasspath_fragment" anymore. Bug: 290583827 Test: m (all existing tests are still passing) Test: Manually checked that the boot images are exactly the same as before. Change-Id: Ib5a5f401bee334ffcab5c26618e0c8888b84575a
2023-07-13 12:03:38 +02:00
module := result.ModuleForTests("dex_bootjars", "android_common")
checkCopiesToPredefinedLocationForArt(t, result.Config, module, "bar", "foo")
})
t.Run("enabled alternative APEX", func(t *testing.T) {
preparers.ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(
Handle installation rules for co-existing prebuilts Every module belonging to a single mainline module family will be hidden from make, except the one which has been flagged using apex_contributions Details - Introduce a new `source_apex_name` property to prebuilt_apex and override_apex. This property will be used to identify the source equivalent of a prebuilt soong apex module. - Create an N-ary tree from source to prebuilt(s). The tree wil be rooted at the source module. - In a subsequent mutator, visit every node in the tree(s). Query apex_contributions and store the handle of the node which is "active" (if any) - In the same mutator, do another pass over the tree. Invoke `HideFromMake` on every node which is not "active". The two-pass approach is needed PrebuiltSelectionInfoProvider does not know about the inter source-prebuilt dependency, this dependency can only be known by doing a graph walk of the N-ary tree. Some tangential implementation details - Each prebuilt apex has an internal deapxer module that is responsible for generating the deapex ninja rules. The name of this internal module uses the BaseModuleName (without the prebuilt_ prefix). Since we can have multiple prebuilt soong modules in trunk stable, change this to follow the name of the prebuilt module in order to avoid name collisions. Update existing unit tests accordingly Bug: 316179314 Test: go test ./apex -run TestInstallationRulesForMultipleApexPrebuilts Test: m nothing --no-skip-soong-tests Test: presubmits Change-Id: I58aa99d5e6a9859954614e6db9a8e9e2e581642d
2024-01-03 19:57:03 +01:00
"Multiple installable prebuilt APEXes provide ambiguous deapexers: prebuilt_com.android.art and prebuilt_com.mycompany.android.art")).
RunTestWithBp(t, fmt.Sprintf(bp, ""))
})
}
// checkCopiesToPredefinedLocationForArt checks that the supplied modules are copied to the
// predefined locations of boot dex jars used as inputs for the ART boot image.
func checkCopiesToPredefinedLocationForArt(t *testing.T, config android.Config, module android.TestingModule, modules ...string) {
t.Helper()
bootJarLocations := []string{}
for _, output := range module.AllOutputs() {
output = android.StringRelativeToTop(config, output)
if strings.HasPrefix(output, "out/soong/dexpreopt_arm64/dex_artjars_input/") {
bootJarLocations = append(bootJarLocations, output)
}
}
sort.Strings(bootJarLocations)
expected := []string{}
for _, m := range modules {
expected = append(expected, fmt.Sprintf("out/soong/dexpreopt_arm64/dex_artjars_input/%s.jar", m))
}
sort.Strings(expected)
android.AssertArrayString(t, "copies to predefined locations for art", expected, bootJarLocations)
}
func TestBootclasspathFragmentContentsNoName(t *testing.T) {
result := android.GroupFixturePreparers(
prepareForTestWithBootclasspathFragment,
prepareForTestWithMyapex,
// Configure bootclasspath jars to ensure that hidden API encoding is performed on them.
java.FixtureConfigureApexBootJars("myapex:foo", "myapex:bar"),
// Make sure that the frameworks/base/Android.bp file exists as otherwise hidden API encoding
// is disabled.
android.FixtureAddTextFile("frameworks/base/Android.bp", ""),
java.PrepareForTestWithJavaSdkLibraryFiles,
java.FixtureWithLastReleaseApis("foo"),
).RunTestWithBp(t, `
apex {
name: "myapex",
key: "myapex.key",
bootclasspath_fragments: [
"mybootclasspathfragment",
],
updatable: false,
}
apex_key {
name: "myapex.key",
public_key: "testkey.avbpubkey",
private_key: "testkey.pem",
}
java_sdk_library {
name: "foo",
srcs: ["b.java"],
shared_library: false,
public: {enabled: true},
apex_available: [
"myapex",
],
}
java_library {
name: "bar",
srcs: ["b.java"],
installable: true,
apex_available: [
"myapex",
],
}
bootclasspath_fragment {
name: "mybootclasspathfragment",
contents: [
"foo",
"bar",
],
apex_available: [
"myapex",
],
hidden_api: {
split_packages: ["*"],
},
}
`)
ensureExactContents(t, result.TestContext, "myapex", "android_common_myapex", []string{
// This does not include art, oat or vdex files as they are only included for the art boot
// image.
"etc/classpaths/bootclasspath.pb",
"javalib/bar.jar",
"javalib/foo.jar",
})
java.CheckModuleDependencies(t, result.TestContext, "myapex", "android_common_myapex", []string{
Fix the args used to dexpreopt system server jars in prebuilt apexes For prebuilts, java.dexpreopt gets called twice 1. in the context of the top-level prebuilt apex 2. in the context of the java_library shim Only the artifacts of (1) get installed. The artifacts generated by 2) are unused. However the args used to generate the artifacts of (1) are incorrect. It uses moduleName(ctx) to do special-handling of apex system server jars. This special-handling does not happen in (1), so although dexpreopt artficats get generated, they get generated with the wrong args. To fix this, add an additional parameter in java.dexpreopt to pass the libraryName explicitly. Details - Delete moduleName function. This was used to determine the java library name, which is no longer safe - Add a libraryName parameter to java.dexpreopt - Most module types will use j.Name() as libraryName - prebuilt_apex and apex_set will iterate over its `contents` and use each element as libraryName when invoking java.dexpreopt With the correct args passed from (1), we can drop j.dexpreopt from (2) completely. Dropping (2) also breaks profile guided dexpreopt tests. These currently operate on (2). They will be moved to (1) in the next CL of this stack. Test: presubmits Test: lunch cf_x86_64_auto-trunk_staging-userdebug && m nothing (this was a postsubmit failure with aosp/2923733) Test: art_standalone_dexpreopt_tests on next https://android-build.corp.google.com/builds/abtd/run/L86000030001579256 Test: art-gtest on git_master-art-host https://android-build.corp.google.com/builds/abtd/run/L07800030001550262 Bug: 308790457 Bug: 322255144 Change-Id: I8eb604c82f1fa5289d3cd1a20084d56e4d7485e3
2024-01-24 00:56:29 +01:00
`dex2oatd`,
`myapex.key`,
`mybootclasspathfragment`,
})
apex := result.ModuleForTests("myapex", "android_common_myapex")
apexRule := apex.Rule("apexRule")
copyCommands := apexRule.Args["copy_commands"]
// Make sure that the fragment provides the hidden API encoded dex jars to the APEX.
fragment := result.Module("mybootclasspathfragment", "android_common_apex10000")
info, _ := android.SingletonModuleProvider(result, fragment, java.BootclasspathFragmentApexContentInfoProvider)
checkFragmentExportedDexJar := func(name string, expectedDexJar string) {
module := result.Module(name, "android_common_apex10000")
dexJar, err := info.DexBootJarPathForContentModule(module)
if err != nil {
t.Error(err)
}
android.AssertPathRelativeToTopEquals(t, name+" dex", expectedDexJar, dexJar)
expectedCopyCommand := fmt.Sprintf("&& cp -f %s out/soong/.intermediates/myapex/android_common_myapex/image.apex/javalib/%s.jar", expectedDexJar, name)
android.AssertStringDoesContain(t, name+" apex copy command", copyCommands, expectedCopyCommand)
}
checkFragmentExportedDexJar("foo", "out/soong/.intermediates/mybootclasspathfragment/android_common_apex10000/hiddenapi-modular/encoded/foo.jar")
checkFragmentExportedDexJar("bar", "out/soong/.intermediates/mybootclasspathfragment/android_common_apex10000/hiddenapi-modular/encoded/bar.jar")
}
func getDexJarPath(result *android.TestResult, name string) string {
module := result.Module(name, "android_common")
return module.(java.UsesLibraryDependency).DexJarBuildPath(moduleErrorfTestCtx{}).Path().RelativeToTop().String()
}
// TestBootclasspathFragment_HiddenAPIList checks to make sure that the correct parameters are
// passed to the hiddenapi list tool.
func TestBootclasspathFragment_HiddenAPIList(t *testing.T) {
result := android.GroupFixturePreparers(
prepareForTestWithBootclasspathFragment,
prepareForTestWithArtApex,
prepareForTestWithMyapex,
// Configure bootclasspath jars to ensure that hidden API encoding is performed on them.
java.FixtureConfigureBootJars("com.android.art:baz", "com.android.art:quuz"),
java.FixtureConfigureApexBootJars("myapex:foo", "myapex:bar"),
// Make sure that the frameworks/base/Android.bp file exists as otherwise hidden API encoding
// is disabled.
android.FixtureAddTextFile("frameworks/base/Android.bp", ""),
java.PrepareForTestWithJavaSdkLibraryFiles,
java.FixtureWithLastReleaseApis("foo", "quuz"),
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
variables.BuildFlags = map[string]string{
"RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true",
}
}),
).RunTestWithBp(t, `
apex {
name: "com.android.art",
key: "com.android.art.key",
bootclasspath_fragments: ["art-bootclasspath-fragment"],
updatable: false,
}
apex_key {
name: "com.android.art.key",
public_key: "com.android.art.avbpubkey",
private_key: "com.android.art.pem",
}
java_library {
name: "baz",
apex_available: [
"com.android.art",
],
srcs: ["b.java"],
compile_dex: true,
}
java_sdk_library {
name: "quuz",
apex_available: [
"com.android.art",
],
srcs: ["b.java"],
compile_dex: true,
public: {enabled: true},
system: {enabled: true},
test: {enabled: true},
module_lib: {enabled: true},
}
bootclasspath_fragment {
name: "art-bootclasspath-fragment",
image_name: "art",
// Must match the "com.android.art:" entries passed to FixtureConfigureBootJars above.
contents: ["baz", "quuz"],
apex_available: [
"com.android.art",
],
hidden_api: {
split_packages: ["*"],
},
}
apex {
name: "myapex",
key: "myapex.key",
bootclasspath_fragments: [
"mybootclasspathfragment",
],
updatable: false,
}
apex_key {
name: "myapex.key",
public_key: "testkey.avbpubkey",
private_key: "testkey.pem",
}
java_sdk_library {
name: "foo",
srcs: ["b.java"],
shared_library: false,
public: {enabled: true},
apex_available: [
"myapex",
],
}
java_library {
name: "bar",
srcs: ["b.java"],
installable: true,
apex_available: [
"myapex",
],
}
bootclasspath_fragment {
name: "mybootclasspathfragment",
contents: [
"foo",
"bar",
],
apex_available: [
"myapex",
],
fragments: [
{
apex: "com.android.art",
module: "art-bootclasspath-fragment",
},
],
hidden_api: {
split_packages: ["*"],
},
}
`)
java.CheckModuleDependencies(t, result.TestContext, "mybootclasspathfragment", "android_common_apex10000", []string{
"art-bootclasspath-fragment",
"bar",
"dex2oatd",
"foo",
})
fooStubs := getDexJarPath(result, "foo.stubs.exportable")
quuzPublicStubs := getDexJarPath(result, "quuz.stubs.exportable")
quuzSystemStubs := getDexJarPath(result, "quuz.stubs.exportable.system")
quuzTestStubs := getDexJarPath(result, "quuz.stubs.exportable.test")
quuzModuleLibStubs := getDexJarPath(result, "quuz.stubs.exportable.module_lib")
// Make sure that the fragment uses the quuz stub dex jars when generating the hidden API flags.
fragment := result.ModuleForTests("mybootclasspathfragment", "android_common_apex10000")
rule := fragment.Rule("modularHiddenAPIStubFlagsFile")
command := rule.RuleParams.Command
android.AssertStringDoesContain(t, "check correct rule", command, "hiddenapi list")
// Make sure that the quuz stubs are available for resolving references from the implementation
// boot dex jars provided by this module.
android.AssertStringDoesContain(t, "quuz widest", command, "--dependency-stub-dex="+quuzModuleLibStubs)
// Make sure that the quuz stubs are available for resolving references from the different API
// stubs provided by this module.
android.AssertStringDoesContain(t, "public", command, "--public-stub-classpath="+quuzPublicStubs+":"+fooStubs)
android.AssertStringDoesContain(t, "system", command, "--system-stub-classpath="+quuzSystemStubs+":"+fooStubs)
android.AssertStringDoesContain(t, "test", command, "--test-stub-classpath="+quuzTestStubs+":"+fooStubs)
}
Support hidden API processing for modules that use platform APIs Previously, hidden API processing could only be done by those bootclasspath_fragment modules that either did not depend on any other fragments (e.g. art-bootclasspath-fragment) or only depended on APIs provided by other fragments (e.g. i18n-bootclasspath-fragment). That meant that modules like com.android.os.statsd-bootclasspath-fragment that depended on APIs provided by parts of the platform which are not yet part of another bootclasspath_fragment could not perform hidden API processing. This change adds support for a bootclasspath_fragment to specify the additional stubs needed to perform hidden API processing. It adds a new additional_stubs property that can be used to specify the additional stub libraries. Most bootclasspath_fragments that need to use the property will need access to the APIs provided by the android-non-updatable.* libraries. Rather than have each fragment explicitly specify the correct module for each scope it treats "android-non-updatable" as if it was a java_sdk_library that can provide different jars for each scope. Soong will handle mapping that to the correct android-non-updatable.* module. Bug: 179354495 Test: m out/soong/hiddenapi/hiddenapi-flags.csv \ out/soong/hiddenapi/hiddenapi-index.csv \ out/soong/hiddenapi/hiddenapi-stub-flags.txt \ out/soong/hiddenapi/hiddenapi-unsupported.csv - make sure that this change does not change the contents. m TARGET_BUILD_APPS=Calendar nothing Change-Id: Ia8b79830ed0e6d42100de03d76b0c51b7f6c8ade
2021-05-26 11:16:01 +02:00
// TestBootclasspathFragment_AndroidNonUpdatable checks to make sure that setting
// additional_stubs: ["android-non-updatable"] causes the source android-non-updatable modules to be
// added to the hiddenapi list tool.
func TestBootclasspathFragment_AndroidNonUpdatable_FromSource(t *testing.T) {
Support hidden API processing for modules that use platform APIs Previously, hidden API processing could only be done by those bootclasspath_fragment modules that either did not depend on any other fragments (e.g. art-bootclasspath-fragment) or only depended on APIs provided by other fragments (e.g. i18n-bootclasspath-fragment). That meant that modules like com.android.os.statsd-bootclasspath-fragment that depended on APIs provided by parts of the platform which are not yet part of another bootclasspath_fragment could not perform hidden API processing. This change adds support for a bootclasspath_fragment to specify the additional stubs needed to perform hidden API processing. It adds a new additional_stubs property that can be used to specify the additional stub libraries. Most bootclasspath_fragments that need to use the property will need access to the APIs provided by the android-non-updatable.* libraries. Rather than have each fragment explicitly specify the correct module for each scope it treats "android-non-updatable" as if it was a java_sdk_library that can provide different jars for each scope. Soong will handle mapping that to the correct android-non-updatable.* module. Bug: 179354495 Test: m out/soong/hiddenapi/hiddenapi-flags.csv \ out/soong/hiddenapi/hiddenapi-index.csv \ out/soong/hiddenapi/hiddenapi-stub-flags.txt \ out/soong/hiddenapi/hiddenapi-unsupported.csv - make sure that this change does not change the contents. m TARGET_BUILD_APPS=Calendar nothing Change-Id: Ia8b79830ed0e6d42100de03d76b0c51b7f6c8ade
2021-05-26 11:16:01 +02:00
result := android.GroupFixturePreparers(
prepareForTestWithBootclasspathFragment,
prepareForTestWithArtApex,
prepareForTestWithMyapex,
// Configure bootclasspath jars to ensure that hidden API encoding is performed on them.
java.FixtureConfigureBootJars("com.android.art:baz", "com.android.art:quuz"),
java.FixtureConfigureApexBootJars("myapex:foo", "myapex:bar"),
Support hidden API processing for modules that use platform APIs Previously, hidden API processing could only be done by those bootclasspath_fragment modules that either did not depend on any other fragments (e.g. art-bootclasspath-fragment) or only depended on APIs provided by other fragments (e.g. i18n-bootclasspath-fragment). That meant that modules like com.android.os.statsd-bootclasspath-fragment that depended on APIs provided by parts of the platform which are not yet part of another bootclasspath_fragment could not perform hidden API processing. This change adds support for a bootclasspath_fragment to specify the additional stubs needed to perform hidden API processing. It adds a new additional_stubs property that can be used to specify the additional stub libraries. Most bootclasspath_fragments that need to use the property will need access to the APIs provided by the android-non-updatable.* libraries. Rather than have each fragment explicitly specify the correct module for each scope it treats "android-non-updatable" as if it was a java_sdk_library that can provide different jars for each scope. Soong will handle mapping that to the correct android-non-updatable.* module. Bug: 179354495 Test: m out/soong/hiddenapi/hiddenapi-flags.csv \ out/soong/hiddenapi/hiddenapi-index.csv \ out/soong/hiddenapi/hiddenapi-stub-flags.txt \ out/soong/hiddenapi/hiddenapi-unsupported.csv - make sure that this change does not change the contents. m TARGET_BUILD_APPS=Calendar nothing Change-Id: Ia8b79830ed0e6d42100de03d76b0c51b7f6c8ade
2021-05-26 11:16:01 +02:00
// Make sure that the frameworks/base/Android.bp file exists as otherwise hidden API encoding
// is disabled.
android.FixtureAddTextFile("frameworks/base/Android.bp", ""),
android.FixtureModifyConfig(func(config android.Config) {
config.SetBuildFromTextStub(false)
}),
Support hidden API processing for modules that use platform APIs Previously, hidden API processing could only be done by those bootclasspath_fragment modules that either did not depend on any other fragments (e.g. art-bootclasspath-fragment) or only depended on APIs provided by other fragments (e.g. i18n-bootclasspath-fragment). That meant that modules like com.android.os.statsd-bootclasspath-fragment that depended on APIs provided by parts of the platform which are not yet part of another bootclasspath_fragment could not perform hidden API processing. This change adds support for a bootclasspath_fragment to specify the additional stubs needed to perform hidden API processing. It adds a new additional_stubs property that can be used to specify the additional stub libraries. Most bootclasspath_fragments that need to use the property will need access to the APIs provided by the android-non-updatable.* libraries. Rather than have each fragment explicitly specify the correct module for each scope it treats "android-non-updatable" as if it was a java_sdk_library that can provide different jars for each scope. Soong will handle mapping that to the correct android-non-updatable.* module. Bug: 179354495 Test: m out/soong/hiddenapi/hiddenapi-flags.csv \ out/soong/hiddenapi/hiddenapi-index.csv \ out/soong/hiddenapi/hiddenapi-stub-flags.txt \ out/soong/hiddenapi/hiddenapi-unsupported.csv - make sure that this change does not change the contents. m TARGET_BUILD_APPS=Calendar nothing Change-Id: Ia8b79830ed0e6d42100de03d76b0c51b7f6c8ade
2021-05-26 11:16:01 +02:00
java.PrepareForTestWithJavaSdkLibraryFiles,
java.FixtureWithLastReleaseApis("foo", "android-non-updatable"),
).RunTestWithBp(t, `
java_sdk_library {
name: "android-non-updatable",
srcs: ["b.java"],
compile_dex: true,
public: {
enabled: true,
},
system: {
enabled: true,
},
test: {
enabled: true,
},
module_lib: {
enabled: true,
},
}
apex {
name: "com.android.art",
key: "com.android.art.key",
bootclasspath_fragments: ["art-bootclasspath-fragment"],
updatable: false,
}
apex_key {
name: "com.android.art.key",
public_key: "com.android.art.avbpubkey",
private_key: "com.android.art.pem",
}
java_library {
name: "baz",
apex_available: [
"com.android.art",
],
srcs: ["b.java"],
compile_dex: true,
}
java_library {
name: "quuz",
apex_available: [
"com.android.art",
],
srcs: ["b.java"],
compile_dex: true,
}
bootclasspath_fragment {
name: "art-bootclasspath-fragment",
image_name: "art",
// Must match the "com.android.art:" entries passed to FixtureConfigureBootJars above.
contents: ["baz", "quuz"],
apex_available: [
"com.android.art",
],
hidden_api: {
split_packages: ["*"],
},
Support hidden API processing for modules that use platform APIs Previously, hidden API processing could only be done by those bootclasspath_fragment modules that either did not depend on any other fragments (e.g. art-bootclasspath-fragment) or only depended on APIs provided by other fragments (e.g. i18n-bootclasspath-fragment). That meant that modules like com.android.os.statsd-bootclasspath-fragment that depended on APIs provided by parts of the platform which are not yet part of another bootclasspath_fragment could not perform hidden API processing. This change adds support for a bootclasspath_fragment to specify the additional stubs needed to perform hidden API processing. It adds a new additional_stubs property that can be used to specify the additional stub libraries. Most bootclasspath_fragments that need to use the property will need access to the APIs provided by the android-non-updatable.* libraries. Rather than have each fragment explicitly specify the correct module for each scope it treats "android-non-updatable" as if it was a java_sdk_library that can provide different jars for each scope. Soong will handle mapping that to the correct android-non-updatable.* module. Bug: 179354495 Test: m out/soong/hiddenapi/hiddenapi-flags.csv \ out/soong/hiddenapi/hiddenapi-index.csv \ out/soong/hiddenapi/hiddenapi-stub-flags.txt \ out/soong/hiddenapi/hiddenapi-unsupported.csv - make sure that this change does not change the contents. m TARGET_BUILD_APPS=Calendar nothing Change-Id: Ia8b79830ed0e6d42100de03d76b0c51b7f6c8ade
2021-05-26 11:16:01 +02:00
}
apex {
name: "myapex",
key: "myapex.key",
bootclasspath_fragments: [
"mybootclasspathfragment",
],
updatable: false,
}
apex_key {
name: "myapex.key",
public_key: "testkey.avbpubkey",
private_key: "testkey.pem",
}
java_sdk_library {
name: "foo",
srcs: ["b.java"],
shared_library: false,
public: {enabled: true},
apex_available: [
"myapex",
],
}
java_library {
name: "bar",
srcs: ["b.java"],
installable: true,
apex_available: [
"myapex",
],
}
bootclasspath_fragment {
name: "mybootclasspathfragment",
contents: [
"foo",
"bar",
],
apex_available: [
"myapex",
],
additional_stubs: ["android-non-updatable"],
fragments: [
{
apex: "com.android.art",
module: "art-bootclasspath-fragment",
},
],
hidden_api: {
split_packages: ["*"],
},
Support hidden API processing for modules that use platform APIs Previously, hidden API processing could only be done by those bootclasspath_fragment modules that either did not depend on any other fragments (e.g. art-bootclasspath-fragment) or only depended on APIs provided by other fragments (e.g. i18n-bootclasspath-fragment). That meant that modules like com.android.os.statsd-bootclasspath-fragment that depended on APIs provided by parts of the platform which are not yet part of another bootclasspath_fragment could not perform hidden API processing. This change adds support for a bootclasspath_fragment to specify the additional stubs needed to perform hidden API processing. It adds a new additional_stubs property that can be used to specify the additional stub libraries. Most bootclasspath_fragments that need to use the property will need access to the APIs provided by the android-non-updatable.* libraries. Rather than have each fragment explicitly specify the correct module for each scope it treats "android-non-updatable" as if it was a java_sdk_library that can provide different jars for each scope. Soong will handle mapping that to the correct android-non-updatable.* module. Bug: 179354495 Test: m out/soong/hiddenapi/hiddenapi-flags.csv \ out/soong/hiddenapi/hiddenapi-index.csv \ out/soong/hiddenapi/hiddenapi-stub-flags.txt \ out/soong/hiddenapi/hiddenapi-unsupported.csv - make sure that this change does not change the contents. m TARGET_BUILD_APPS=Calendar nothing Change-Id: Ia8b79830ed0e6d42100de03d76b0c51b7f6c8ade
2021-05-26 11:16:01 +02:00
}
`)
java.CheckModuleDependencies(t, result.TestContext, "mybootclasspathfragment", "android_common_apex10000", []string{
"android-non-updatable.stubs",
"android-non-updatable.stubs.module_lib",
"android-non-updatable.stubs.system",
"android-non-updatable.stubs.test",
"art-bootclasspath-fragment",
"bar",
"dex2oatd",
"foo",
})
nonUpdatablePublicStubs := getDexJarPath(result, "android-non-updatable.stubs")
nonUpdatableSystemStubs := getDexJarPath(result, "android-non-updatable.stubs.system")
nonUpdatableTestStubs := getDexJarPath(result, "android-non-updatable.stubs.test")
nonUpdatableModuleLibStubs := getDexJarPath(result, "android-non-updatable.stubs.module_lib")
// Make sure that the fragment uses the android-non-updatable modules when generating the hidden
// API flags.
fragment := result.ModuleForTests("mybootclasspathfragment", "android_common_apex10000")
rule := fragment.Rule("modularHiddenAPIStubFlagsFile")
command := rule.RuleParams.Command
android.AssertStringDoesContain(t, "check correct rule", command, "hiddenapi list")
// Make sure that the module_lib non-updatable stubs are available for resolving references from
// the implementation boot dex jars provided by this module.
android.AssertStringDoesContain(t, "android-non-updatable widest", command, "--dependency-stub-dex="+nonUpdatableModuleLibStubs)
// Make sure that the appropriate non-updatable stubs are available for resolving references from
// the different API stubs provided by this module.
android.AssertStringDoesContain(t, "public", command, "--public-stub-classpath="+nonUpdatablePublicStubs)
android.AssertStringDoesContain(t, "system", command, "--system-stub-classpath="+nonUpdatableSystemStubs)
android.AssertStringDoesContain(t, "test", command, "--test-stub-classpath="+nonUpdatableTestStubs)
}
func TestBootclasspathFragment_AndroidNonUpdatable_FromText(t *testing.T) {
result := android.GroupFixturePreparers(
prepareForTestWithBootclasspathFragment,
prepareForTestWithArtApex,
prepareForTestWithMyapex,
// Configure bootclasspath jars to ensure that hidden API encoding is performed on them.
java.FixtureConfigureBootJars("com.android.art:baz", "com.android.art:quuz"),
java.FixtureConfigureApexBootJars("myapex:foo", "myapex:bar"),
// Make sure that the frameworks/base/Android.bp file exists as otherwise hidden API encoding
// is disabled.
android.FixtureAddTextFile("frameworks/base/Android.bp", ""),
android.FixtureModifyConfig(func(config android.Config) {
config.SetBuildFromTextStub(true)
}),
java.PrepareForTestWithJavaSdkLibraryFiles,
java.FixtureWithLastReleaseApis("foo", "android-non-updatable"),
).RunTestWithBp(t, `
java_sdk_library {
name: "android-non-updatable",
srcs: ["b.java"],
compile_dex: true,
public: {
enabled: true,
},
system: {
enabled: true,
},
test: {
enabled: true,
},
module_lib: {
enabled: true,
},
}
apex {
name: "com.android.art",
key: "com.android.art.key",
bootclasspath_fragments: ["art-bootclasspath-fragment"],
updatable: false,
}
apex_key {
name: "com.android.art.key",
public_key: "com.android.art.avbpubkey",
private_key: "com.android.art.pem",
}
java_library {
name: "baz",
apex_available: [
"com.android.art",
],
srcs: ["b.java"],
compile_dex: true,
}
java_library {
name: "quuz",
apex_available: [
"com.android.art",
],
srcs: ["b.java"],
compile_dex: true,
}
bootclasspath_fragment {
name: "art-bootclasspath-fragment",
image_name: "art",
// Must match the "com.android.art:" entries passed to FixtureConfigureBootJars above.
contents: ["baz", "quuz"],
apex_available: [
"com.android.art",
],
hidden_api: {
split_packages: ["*"],
},
}
apex {
name: "myapex",
key: "myapex.key",
bootclasspath_fragments: [
"mybootclasspathfragment",
],
updatable: false,
}
apex_key {
name: "myapex.key",
public_key: "testkey.avbpubkey",
private_key: "testkey.pem",
}
java_sdk_library {
name: "foo",
srcs: ["b.java"],
shared_library: false,
public: {enabled: true},
apex_available: [
"myapex",
],
}
java_library {
name: "bar",
srcs: ["b.java"],
installable: true,
apex_available: [
"myapex",
],
}
bootclasspath_fragment {
name: "mybootclasspathfragment",
contents: [
"foo",
"bar",
],
apex_available: [
"myapex",
],
additional_stubs: ["android-non-updatable"],
fragments: [
{
apex: "com.android.art",
module: "art-bootclasspath-fragment",
},
],
hidden_api: {
split_packages: ["*"],
},
}
`)
java.CheckModuleDependencies(t, result.TestContext, "mybootclasspathfragment", "android_common_apex10000", []string{
"android-non-updatable.stubs",
"android-non-updatable.stubs.system",
"android-non-updatable.stubs.test",
"android-non-updatable.stubs.test_module_lib",
"art-bootclasspath-fragment",
"bar",
"dex2oatd",
"foo",
})
nonUpdatableTestModuleLibStubs := getDexJarPath(result, "android-non-updatable.stubs.test_module_lib")
// Make sure that the fragment uses the android-non-updatable modules when generating the hidden
// API flags.
fragment := result.ModuleForTests("mybootclasspathfragment", "android_common_apex10000")
rule := fragment.Rule("modularHiddenAPIStubFlagsFile")
command := rule.RuleParams.Command
android.AssertStringDoesContain(t, "check correct rule", command, "hiddenapi list")
// Make sure that the test_module_lib non-updatable stubs are available for resolving references from
// the implementation boot dex jars provided by this module.
android.AssertStringDoesContain(t, "android-non-updatable widest", command, "--dependency-stub-dex="+nonUpdatableTestModuleLibStubs)
}
Support hidden API processing for modules that use platform APIs Previously, hidden API processing could only be done by those bootclasspath_fragment modules that either did not depend on any other fragments (e.g. art-bootclasspath-fragment) or only depended on APIs provided by other fragments (e.g. i18n-bootclasspath-fragment). That meant that modules like com.android.os.statsd-bootclasspath-fragment that depended on APIs provided by parts of the platform which are not yet part of another bootclasspath_fragment could not perform hidden API processing. This change adds support for a bootclasspath_fragment to specify the additional stubs needed to perform hidden API processing. It adds a new additional_stubs property that can be used to specify the additional stub libraries. Most bootclasspath_fragments that need to use the property will need access to the APIs provided by the android-non-updatable.* libraries. Rather than have each fragment explicitly specify the correct module for each scope it treats "android-non-updatable" as if it was a java_sdk_library that can provide different jars for each scope. Soong will handle mapping that to the correct android-non-updatable.* module. Bug: 179354495 Test: m out/soong/hiddenapi/hiddenapi-flags.csv \ out/soong/hiddenapi/hiddenapi-index.csv \ out/soong/hiddenapi/hiddenapi-stub-flags.txt \ out/soong/hiddenapi/hiddenapi-unsupported.csv - make sure that this change does not change the contents. m TARGET_BUILD_APPS=Calendar nothing Change-Id: Ia8b79830ed0e6d42100de03d76b0c51b7f6c8ade
2021-05-26 11:16:01 +02:00
// TestBootclasspathFragment_AndroidNonUpdatable_AlwaysUsePrebuiltSdks checks to make sure that
// setting additional_stubs: ["android-non-updatable"] causes the prebuilt android-non-updatable
// modules to be added to the hiddenapi list tool.
func TestBootclasspathFragment_AndroidNonUpdatable_AlwaysUsePrebuiltSdks(t *testing.T) {
result := android.GroupFixturePreparers(
prepareForTestWithBootclasspathFragment,
java.PrepareForTestWithDexpreopt,
Support hidden API processing for modules that use platform APIs Previously, hidden API processing could only be done by those bootclasspath_fragment modules that either did not depend on any other fragments (e.g. art-bootclasspath-fragment) or only depended on APIs provided by other fragments (e.g. i18n-bootclasspath-fragment). That meant that modules like com.android.os.statsd-bootclasspath-fragment that depended on APIs provided by parts of the platform which are not yet part of another bootclasspath_fragment could not perform hidden API processing. This change adds support for a bootclasspath_fragment to specify the additional stubs needed to perform hidden API processing. It adds a new additional_stubs property that can be used to specify the additional stub libraries. Most bootclasspath_fragments that need to use the property will need access to the APIs provided by the android-non-updatable.* libraries. Rather than have each fragment explicitly specify the correct module for each scope it treats "android-non-updatable" as if it was a java_sdk_library that can provide different jars for each scope. Soong will handle mapping that to the correct android-non-updatable.* module. Bug: 179354495 Test: m out/soong/hiddenapi/hiddenapi-flags.csv \ out/soong/hiddenapi/hiddenapi-index.csv \ out/soong/hiddenapi/hiddenapi-stub-flags.txt \ out/soong/hiddenapi/hiddenapi-unsupported.csv - make sure that this change does not change the contents. m TARGET_BUILD_APPS=Calendar nothing Change-Id: Ia8b79830ed0e6d42100de03d76b0c51b7f6c8ade
2021-05-26 11:16:01 +02:00
prepareForTestWithArtApex,
prepareForTestWithMyapex,
// Configure bootclasspath jars to ensure that hidden API encoding is performed on them.
java.FixtureConfigureBootJars("com.android.art:baz", "com.android.art:quuz"),
java.FixtureConfigureApexBootJars("myapex:foo", "myapex:bar"),
Support hidden API processing for modules that use platform APIs Previously, hidden API processing could only be done by those bootclasspath_fragment modules that either did not depend on any other fragments (e.g. art-bootclasspath-fragment) or only depended on APIs provided by other fragments (e.g. i18n-bootclasspath-fragment). That meant that modules like com.android.os.statsd-bootclasspath-fragment that depended on APIs provided by parts of the platform which are not yet part of another bootclasspath_fragment could not perform hidden API processing. This change adds support for a bootclasspath_fragment to specify the additional stubs needed to perform hidden API processing. It adds a new additional_stubs property that can be used to specify the additional stub libraries. Most bootclasspath_fragments that need to use the property will need access to the APIs provided by the android-non-updatable.* libraries. Rather than have each fragment explicitly specify the correct module for each scope it treats "android-non-updatable" as if it was a java_sdk_library that can provide different jars for each scope. Soong will handle mapping that to the correct android-non-updatable.* module. Bug: 179354495 Test: m out/soong/hiddenapi/hiddenapi-flags.csv \ out/soong/hiddenapi/hiddenapi-index.csv \ out/soong/hiddenapi/hiddenapi-stub-flags.txt \ out/soong/hiddenapi/hiddenapi-unsupported.csv - make sure that this change does not change the contents. m TARGET_BUILD_APPS=Calendar nothing Change-Id: Ia8b79830ed0e6d42100de03d76b0c51b7f6c8ade
2021-05-26 11:16:01 +02:00
// Make sure that the frameworks/base/Android.bp file exists as otherwise hidden API encoding
// is disabled.
android.FixtureAddTextFile("frameworks/base/Android.bp", ""),
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
variables.Always_use_prebuilt_sdks = proptools.BoolPtr(true)
}),
java.PrepareForTestWithJavaSdkLibraryFiles,
java.FixtureWithPrebuiltApis(map[string][]string{
"current": {"android-non-updatable"},
"30": {"foo"},
}),
).RunTestWithBp(t, `
apex {
name: "com.android.art",
key: "com.android.art.key",
bootclasspath_fragments: ["art-bootclasspath-fragment"],
updatable: false,
}
apex_key {
name: "com.android.art.key",
public_key: "com.android.art.avbpubkey",
private_key: "com.android.art.pem",
}
java_library {
name: "baz",
apex_available: [
"com.android.art",
],
srcs: ["b.java"],
compile_dex: true,
}
java_library {
name: "quuz",
apex_available: [
"com.android.art",
],
srcs: ["b.java"],
compile_dex: true,
}
bootclasspath_fragment {
name: "art-bootclasspath-fragment",
image_name: "art",
// Must match the "com.android.art:" entries passed to FixtureConfigureBootJars above.
contents: ["baz", "quuz"],
apex_available: [
"com.android.art",
],
hidden_api: {
split_packages: ["*"],
},
Support hidden API processing for modules that use platform APIs Previously, hidden API processing could only be done by those bootclasspath_fragment modules that either did not depend on any other fragments (e.g. art-bootclasspath-fragment) or only depended on APIs provided by other fragments (e.g. i18n-bootclasspath-fragment). That meant that modules like com.android.os.statsd-bootclasspath-fragment that depended on APIs provided by parts of the platform which are not yet part of another bootclasspath_fragment could not perform hidden API processing. This change adds support for a bootclasspath_fragment to specify the additional stubs needed to perform hidden API processing. It adds a new additional_stubs property that can be used to specify the additional stub libraries. Most bootclasspath_fragments that need to use the property will need access to the APIs provided by the android-non-updatable.* libraries. Rather than have each fragment explicitly specify the correct module for each scope it treats "android-non-updatable" as if it was a java_sdk_library that can provide different jars for each scope. Soong will handle mapping that to the correct android-non-updatable.* module. Bug: 179354495 Test: m out/soong/hiddenapi/hiddenapi-flags.csv \ out/soong/hiddenapi/hiddenapi-index.csv \ out/soong/hiddenapi/hiddenapi-stub-flags.txt \ out/soong/hiddenapi/hiddenapi-unsupported.csv - make sure that this change does not change the contents. m TARGET_BUILD_APPS=Calendar nothing Change-Id: Ia8b79830ed0e6d42100de03d76b0c51b7f6c8ade
2021-05-26 11:16:01 +02:00
}
apex {
name: "myapex",
key: "myapex.key",
bootclasspath_fragments: [
"mybootclasspathfragment",
],
updatable: false,
}
apex_key {
name: "myapex.key",
public_key: "testkey.avbpubkey",
private_key: "testkey.pem",
}
java_sdk_library {
name: "foo",
srcs: ["b.java"],
shared_library: false,
public: {enabled: true},
apex_available: [
"myapex",
],
}
java_library {
name: "bar",
srcs: ["b.java"],
installable: true,
apex_available: [
"myapex",
],
}
bootclasspath_fragment {
name: "mybootclasspathfragment",
contents: [
"foo",
"bar",
],
apex_available: [
"myapex",
],
additional_stubs: ["android-non-updatable"],
fragments: [
{
apex: "com.android.art",
module: "art-bootclasspath-fragment",
},
],
hidden_api: {
split_packages: ["*"],
},
Support hidden API processing for modules that use platform APIs Previously, hidden API processing could only be done by those bootclasspath_fragment modules that either did not depend on any other fragments (e.g. art-bootclasspath-fragment) or only depended on APIs provided by other fragments (e.g. i18n-bootclasspath-fragment). That meant that modules like com.android.os.statsd-bootclasspath-fragment that depended on APIs provided by parts of the platform which are not yet part of another bootclasspath_fragment could not perform hidden API processing. This change adds support for a bootclasspath_fragment to specify the additional stubs needed to perform hidden API processing. It adds a new additional_stubs property that can be used to specify the additional stub libraries. Most bootclasspath_fragments that need to use the property will need access to the APIs provided by the android-non-updatable.* libraries. Rather than have each fragment explicitly specify the correct module for each scope it treats "android-non-updatable" as if it was a java_sdk_library that can provide different jars for each scope. Soong will handle mapping that to the correct android-non-updatable.* module. Bug: 179354495 Test: m out/soong/hiddenapi/hiddenapi-flags.csv \ out/soong/hiddenapi/hiddenapi-index.csv \ out/soong/hiddenapi/hiddenapi-stub-flags.txt \ out/soong/hiddenapi/hiddenapi-unsupported.csv - make sure that this change does not change the contents. m TARGET_BUILD_APPS=Calendar nothing Change-Id: Ia8b79830ed0e6d42100de03d76b0c51b7f6c8ade
2021-05-26 11:16:01 +02:00
}
`)
java.CheckModuleDependencies(t, result.TestContext, "mybootclasspathfragment", "android_common_apex10000", []string{
"art-bootclasspath-fragment",
"bar",
"dex2oatd",
"foo",
"prebuilt_sdk_module-lib_current_android-non-updatable",
"prebuilt_sdk_public_current_android-non-updatable",
"prebuilt_sdk_system_current_android-non-updatable",
"prebuilt_sdk_test_current_android-non-updatable",
})
nonUpdatablePublicStubs := getDexJarPath(result, "sdk_public_current_android-non-updatable")
nonUpdatableSystemStubs := getDexJarPath(result, "sdk_system_current_android-non-updatable")
nonUpdatableTestStubs := getDexJarPath(result, "sdk_test_current_android-non-updatable")
nonUpdatableModuleLibStubs := getDexJarPath(result, "sdk_module-lib_current_android-non-updatable")
// Make sure that the fragment uses the android-non-updatable modules when generating the hidden
// API flags.
fragment := result.ModuleForTests("mybootclasspathfragment", "android_common_apex10000")
rule := fragment.Rule("modularHiddenAPIStubFlagsFile")
command := rule.RuleParams.Command
android.AssertStringDoesContain(t, "check correct rule", command, "hiddenapi list")
// Make sure that the module_lib non-updatable stubs are available for resolving references from
// the implementation boot dex jars provided by this module.
android.AssertStringDoesContain(t, "android-non-updatable widest", command, "--dependency-stub-dex="+nonUpdatableModuleLibStubs)
// Make sure that the appropriate non-updatable stubs are available for resolving references from
// the different API stubs provided by this module.
android.AssertStringDoesContain(t, "public", command, "--public-stub-classpath="+nonUpdatablePublicStubs)
android.AssertStringDoesContain(t, "system", command, "--system-stub-classpath="+nonUpdatableSystemStubs)
android.AssertStringDoesContain(t, "test", command, "--test-stub-classpath="+nonUpdatableTestStubs)
}
// TODO(b/177892522) - add test for host apex.