diff options
Diffstat (limited to 'java/hiddenapi_monolithic.go')
-rw-r--r-- | java/hiddenapi_monolithic.go | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/java/hiddenapi_monolithic.go b/java/hiddenapi_monolithic.go index edf42351f..52f0770f3 100644 --- a/java/hiddenapi_monolithic.go +++ b/java/hiddenapi_monolithic.go @@ -43,22 +43,45 @@ type MonolithicHiddenAPIInfo struct { // The paths to the generated all-flags.csv files. AllFlagsPaths android.Paths + + // The classes jars from the libraries on the platform bootclasspath. + ClassesJars android.Paths } // newMonolithicHiddenAPIInfo creates a new MonolithicHiddenAPIInfo from the flagFilesByCategory // plus information provided by each of the fragments. -func newMonolithicHiddenAPIInfo(ctx android.ModuleContext, flagFilesByCategory FlagFilesByCategory, fragments []android.Module) MonolithicHiddenAPIInfo { +func newMonolithicHiddenAPIInfo(ctx android.ModuleContext, flagFilesByCategory FlagFilesByCategory, classpathElements ClasspathElements) MonolithicHiddenAPIInfo { monolithicInfo := MonolithicHiddenAPIInfo{} monolithicInfo.FlagsFilesByCategory = flagFilesByCategory - // Merge all the information from the fragments. The fragments form a DAG so it is possible that - // this will introduce duplicates so they will be resolved after processing all the fragments. - for _, fragment := range fragments { - if ctx.OtherModuleHasProvider(fragment, HiddenAPIInfoProvider) { - info := ctx.OtherModuleProvider(fragment, HiddenAPIInfoProvider).(HiddenAPIInfo) - monolithicInfo.append(&info) + // Merge all the information from the classpathElements. The fragments form a DAG so it is possible that + // this will introduce duplicates so they will be resolved after processing all the classpathElements. + for _, element := range classpathElements { + var classesJars android.Paths + switch e := element.(type) { + case *ClasspathLibraryElement: + classesJars = retrieveClassesJarsFromModule(e.Module()) + + case *ClasspathFragmentElement: + fragment := e.Module() + if ctx.OtherModuleHasProvider(fragment, HiddenAPIInfoProvider) { + info := ctx.OtherModuleProvider(fragment, HiddenAPIInfoProvider).(HiddenAPIInfo) + monolithicInfo.append(&info) + + // If the bootclasspath fragment actually perform hidden API processing itself then use the + // CSV files it provides and do not bother processing the classesJars files. This ensures + // consistent behavior between source and prebuilt as prebuilt modules do not provide + // classesJars. + if info.AllFlagsPath != nil { + continue + } + } + + classesJars = extractClassesJarsFromModules(e.Contents) } + + monolithicInfo.ClassesJars = append(monolithicInfo.ClassesJars, classesJars...) } // Dedup paths. |