diff options
| author | 2021-05-13 21:25:05 +0100 | |
|---|---|---|
| committer | 2021-05-14 01:49:19 +0100 | |
| commit | 34827d4c0ec854bee766ec3db2be6e66b34ebb28 (patch) | |
| tree | 4fdd91c94165de6fccdc3ff6e66717331a8d40a7 /java/hiddenapi_modular.go | |
| parent | dfa1083fee4d1bf62c582c4e6ece20343fed6f50 (diff) | |
Use java_sdk_library in bootclasspath_fragment contents as stubs
A java_sdk_library specified in the bootclasspath_fragment contents
must be providing APIs for the bootclasspath_fragment and so must be
treated as if they were specified in the stub_libs. This avoids having
to specify them in both contents and stub_libs.
Bug: 179354495
Test: m nothing
Change-Id: I535065ee1a79b439e2676f35e06a75d4626adcaf
Diffstat (limited to 'java/hiddenapi_modular.go')
| -rw-r--r-- | java/hiddenapi_modular.go | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/java/hiddenapi_modular.go b/java/hiddenapi_modular.go index d1d9a7541..186891556 100644 --- a/java/hiddenapi_modular.go +++ b/java/hiddenapi_modular.go @@ -123,8 +123,21 @@ func hiddenAPIAddStubLibDependencies(ctx android.BottomUpMutatorContext, sdkKind // hiddenAPIGatherStubLibDexJarPaths gathers the paths to the dex jars from the dependencies added // in hiddenAPIAddStubLibDependencies. -func hiddenAPIGatherStubLibDexJarPaths(ctx android.ModuleContext) map[android.SdkKind]android.Paths { +func hiddenAPIGatherStubLibDexJarPaths(ctx android.ModuleContext, contents []android.Module) map[android.SdkKind]android.Paths { m := map[android.SdkKind]android.Paths{} + + // If the contents includes any java_sdk_library modules then add them to the stubs. + for _, module := range contents { + if _, ok := module.(SdkLibraryDependency); ok { + for _, kind := range []android.SdkKind{android.SdkPublic, android.SdkSystem, android.SdkTest} { + dexJar := hiddenAPIRetrieveDexJarBuildPath(ctx, module, kind) + if dexJar != nil { + m[kind] = append(m[kind], dexJar) + } + } + } + } + ctx.VisitDirectDepsIf(isActiveModule, func(module android.Module) { tag := ctx.OtherModuleDependencyTag(module) if hiddenAPIStubsTag, ok := tag.(hiddenAPIStubsDependencyTag); ok { @@ -135,6 +148,12 @@ func hiddenAPIGatherStubLibDexJarPaths(ctx android.ModuleContext) map[android.Sd } } }) + + // Normalize the paths, i.e. remove duplicates and sort. + for k, v := range m { + m[k] = android.SortedUniquePaths(v) + } + return m } |