Utilize module lib and test api superset module in hiddenapi
Hiddenapi takes a single widest api scope stub dex jar as an input, as the tool does not support handling duplicate classes passed as inputs. A problem regarding this is that the test and module lib api surfaces do not strictly have a subset/superset relationship, unlike other api surfaces. This has not become a problem for stubs generated from source files as the stubs contain all methods in the source files, but became a problem for stubs genereated from text files as the stubs only contain the methods that are essential for compilation of the stubs and its reverse dependencies, and there were cases where the hiddenapi flags are not properly propagated to the subclasses. To resolve this problem, a java_api_library module that provides the union of the test and the module lib api surfaces was introcudes. Since hiddenapi_modular currently defines the module lib api surface to be a wider api scope over the test api scope, the new module can be passed as input to hiddenapi over the module lib non updatable stub module to resolve the problem. Test: enable hiddenapi for from-text stub build && ENABLE_HIDDENAPI_FLAGS=true m --build-from-text-stub Bug: 191644675 Bug: 275570206 Change-Id: I9a230ec5082c52ed866f29b0748814f2cf10279b
This commit is contained in:
@@ -316,6 +316,60 @@ func TestBootclasspathFragment_StubLibs(t *testing.T) {
|
||||
android.AssertPathsRelativeToTopEquals(t, "widest dex stubs jar", expectedWidestPaths, info.TransitiveStubDexJarsByScope.StubDexJarsForWidestAPIScope())
|
||||
}
|
||||
|
||||
func TestFromTextWidestApiScope(t *testing.T) {
|
||||
result := android.GroupFixturePreparers(
|
||||
prepareForTestWithBootclasspathFragment,
|
||||
PrepareForTestWithJavaSdkLibraryFiles,
|
||||
android.FixtureModifyConfig(func(config android.Config) {
|
||||
config.SetBuildFromTextStub(true)
|
||||
}),
|
||||
FixtureWithLastReleaseApis("mysdklibrary", "android-non-updatable"),
|
||||
FixtureConfigureApexBootJars("someapex:mysdklibrary"),
|
||||
).RunTestWithBp(t, `
|
||||
bootclasspath_fragment {
|
||||
name: "myfragment",
|
||||
contents: ["mysdklibrary"],
|
||||
additional_stubs: [
|
||||
"android-non-updatable",
|
||||
],
|
||||
hidden_api: {
|
||||
split_packages: ["*"],
|
||||
},
|
||||
}
|
||||
java_sdk_library {
|
||||
name: "mysdklibrary",
|
||||
srcs: ["a.java"],
|
||||
shared_library: false,
|
||||
public: {enabled: true},
|
||||
system: {enabled: true},
|
||||
}
|
||||
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,
|
||||
},
|
||||
}
|
||||
`)
|
||||
|
||||
fragment := result.ModuleForTests("myfragment", "android_common")
|
||||
dependencyStubDexFlag := "--dependency-stub-dex=out/soong/.intermediates/default/java/android-non-updatable.stubs.test_module_lib/android_common/dex/android-non-updatable.stubs.test_module_lib.jar"
|
||||
stubFlagsCommand := fragment.Output("modular-hiddenapi/stub-flags.csv").RuleParams.Command
|
||||
android.AssertStringDoesContain(t,
|
||||
"Stub flags generating command does not include the expected dependency stub dex file",
|
||||
stubFlagsCommand, dependencyStubDexFlag)
|
||||
}
|
||||
|
||||
func TestSnapshotWithBootclasspathFragment_HiddenAPI(t *testing.T) {
|
||||
result := android.GroupFixturePreparers(
|
||||
prepareForTestWithBootclasspathFragment,
|
||||
|
Reference in New Issue
Block a user