summaryrefslogtreecommitdiff
path: root/java/hiddenapi.go
diff options
context:
space:
mode:
Diffstat (limited to 'java/hiddenapi.go')
-rw-r--r--java/hiddenapi.go106
1 files changed, 33 insertions, 73 deletions
diff --git a/java/hiddenapi.go b/java/hiddenapi.go
index 2f73262fb..2c0655f93 100644
--- a/java/hiddenapi.go
+++ b/java/hiddenapi.go
@@ -56,35 +56,6 @@ type hiddenAPI struct {
// this file so using the encoded dex jar here would result in a cycle in the ninja rules.
bootDexJarPath android.Path
- // The path to the CSV file that contains mappings from Java signature to various flags derived
- // from annotations in the source, e.g. whether it is public or the sdk version above which it
- // can no longer be used.
- //
- // It is created by the Class2NonSdkList tool which processes the .class files in the class
- // implementation jar looking for UnsupportedAppUsage and CovariantReturnType annotations. The
- // tool also consumes the hiddenAPISingletonPathsStruct.stubFlags file in order to perform
- // consistency checks on the information in the annotations and to filter out bridge methods
- // that are already part of the public API.
- flagsCSVPath android.Path
-
- // The path to the CSV file that contains mappings from Java signature to the value of properties
- // specified on UnsupportedAppUsage annotations in the source.
- //
- // Like the flagsCSVPath file this is also created by the Class2NonSdkList in the same way.
- // Although the two files could potentially be created in a single invocation of the
- // Class2NonSdkList at the moment they are created using their own invocation, with the behavior
- // being determined by the property that is used.
- metadataCSVPath android.Path
-
- // The path to the CSV file that contains mappings from Java signature to source location
- // information.
- //
- // It is created by the merge_csv tool which processes the class implementation jar, extracting
- // all the files ending in .uau (which are CSV files) and merges them together. The .uau files are
- // created by the unsupported app usage annotation processor during compilation of the class
- // implementation jar.
- indexCSVPath android.Path
-
// The paths to the classes jars that contain classes and class members annotated with
// the UnsupportedAppUsage annotation that need to be extracted as part of the hidden API
// processing.
@@ -182,25 +153,14 @@ func isModuleInBootClassPath(ctx android.BaseModuleContext, module android.Modul
return active
}
-// hiddenAPIExtractAndEncode is called by any module that could contribute to the hiddenapi
-// processing.
+// hiddenAPIEncodeDex is called by any module that needs to encode dex files.
//
// It ignores any module that has not had initHiddenApi() called on it and which is not in the boot
-// jar list.
+// jar list. In that case it simply returns the supplied dex jar path.
//
-// Otherwise, it generates ninja rules to do the following:
-// 1. Extract information needed for hiddenapi processing from the module and output it into CSV
-// files.
-// 2. Conditionally adds the supplied dex file to the list of files used to generate the
-// hiddenAPISingletonPathsStruct.stubsFlag file.
-// 3. Conditionally creates a copy of the supplied dex file into which it has encoded the hiddenapi
-// flags and returns this instead of the supplied dex jar, otherwise simply returns the supplied
-// dex jar.
-func (h *hiddenAPI) hiddenAPIExtractAndEncode(ctx android.ModuleContext, dexJar android.OutputPath,
- implementationJar android.Path, uncompressDex bool) android.OutputPath {
-
- // Call before checking if this is active as it will update the hiddenAPI structure.
- h.hiddenAPIExtractInformation(ctx, dexJar, implementationJar)
+// Otherwise, it creates a copy of the supplied dex file into which it has encoded the hiddenapi
+// flags and returns this instead of the supplied dex jar.
+func (h *hiddenAPI) hiddenAPIEncodeDex(ctx android.ModuleContext, dexJar android.OutputPath, uncompressDex bool) android.OutputPath {
if !h.active {
return dexJar
@@ -217,12 +177,12 @@ func (h *hiddenAPI) hiddenAPIExtractAndEncode(ctx android.ModuleContext, dexJar
return dexJar
}
-// hiddenAPIExtractInformation generates ninja rules to extract the information from the classes
+// hiddenAPIUpdatePaths generates ninja rules to extract the information from the classes
// jar, and outputs it to the appropriate module specific CSV file.
//
// It also makes the dex jar available for use when generating the
// hiddenAPISingletonPathsStruct.stubFlags.
-func (h *hiddenAPI) hiddenAPIExtractInformation(ctx android.ModuleContext, dexJar, classesJar android.Path) {
+func (h *hiddenAPI) hiddenAPIUpdatePaths(ctx android.ModuleContext, dexJar, classesJar android.Path) {
// Save the classes jars even if this is not active as they may be used by modular hidden API
// processing.
@@ -236,35 +196,20 @@ func (h *hiddenAPI) hiddenAPIExtractInformation(ctx android.ModuleContext, dexJa
// Save the unencoded dex jar so it can be used when generating the
// hiddenAPISingletonPathsStruct.stubFlags file.
h.bootDexJarPath = dexJar
-
- if !h.active {
- return
- }
-
- // More than one library with the same classes may need to be encoded but only one should be
- // used as a source of information for hidden API processing otherwise it will result in
- // duplicate entries in the files.
- if !h.primary {
- return
- }
-
- stubFlagsCSV := hiddenAPISingletonPaths(ctx).stubFlags
-
- flagsCSV := android.PathForModuleOut(ctx, "hiddenapi", "flags.csv")
- h.flagsCSVPath = flagsCSV
- buildRuleToGenerateAnnotationFlags(ctx, "hiddenapi flags", classesJars, stubFlagsCSV, flagsCSV)
-
- metadataCSV := android.PathForModuleOut(ctx, "hiddenapi", "metadata.csv")
- h.metadataCSVPath = metadataCSV
- buildRuleToGenerateMetadata(ctx, "hiddenapi metadata", classesJars, stubFlagsCSV, metadataCSV)
-
- indexCSV := android.PathForModuleOut(ctx, "hiddenapi", "index.csv")
- h.indexCSVPath = indexCSV
- buildRuleToGenerateIndex(ctx, "Merged Hidden API index", classesJars, indexCSV)
}
// buildRuleToGenerateAnnotationFlags builds a ninja rule to generate the annotation-flags.csv file
// from the classes jars and stub-flags.csv files.
+//
+// The annotation-flags.csv file contains mappings from Java signature to various flags derived from
+// annotations in the source, e.g. whether it is public or the sdk version above which it can no
+// longer be used.
+//
+// It is created by the Class2NonSdkList tool which processes the .class files in the class
+// implementation jar looking for UnsupportedAppUsage and CovariantReturnType annotations. The
+// tool also consumes the hiddenAPISingletonPathsStruct.stubFlags file in order to perform
+// consistency checks on the information in the annotations and to filter out bridge methods
+// that are already part of the public API.
func buildRuleToGenerateAnnotationFlags(ctx android.ModuleContext, desc string, classesJars android.Paths, stubFlagsCSV android.Path, outputPath android.WritablePath) {
ctx.Build(pctx, android.BuildParams{
Rule: hiddenAPIGenerateCSVRule,
@@ -281,6 +226,14 @@ func buildRuleToGenerateAnnotationFlags(ctx android.ModuleContext, desc string,
// buildRuleToGenerateMetadata builds a ninja rule to generate the metadata.csv file from
// the classes jars and stub-flags.csv files.
+//
+// The metadata.csv file contains mappings from Java signature to the value of properties specified
+// on UnsupportedAppUsage annotations in the source.
+//
+// Like the annotation-flags.csv file this is also created by the Class2NonSdkList in the same way.
+// Although the two files could potentially be created in a single invocation of the
+// Class2NonSdkList at the moment they are created using their own invocation, with the behavior
+// being determined by the property that is used.
func buildRuleToGenerateMetadata(ctx android.ModuleContext, desc string, classesJars android.Paths, stubFlagsCSV android.Path, metadataCSV android.WritablePath) {
ctx.Build(pctx, android.BuildParams{
Rule: hiddenAPIGenerateCSVRule,
@@ -295,8 +248,15 @@ func buildRuleToGenerateMetadata(ctx android.ModuleContext, desc string, classes
})
}
-// buildRuleToGenerateMetadata builds a ninja rule to generate the index.csv file from the classes
+// buildRuleToGenerateIndex builds a ninja rule to generate the index.csv file from the classes
// jars.
+//
+// The index.csv file contains mappings from Java signature to source location information.
+//
+// It is created by the merge_csv tool which processes the class implementation jar, extracting
+// all the files ending in .uau (which are CSV files) and merges them together. The .uau files are
+// created by the unsupported app usage annotation processor during compilation of the class
+// implementation jar.
func buildRuleToGenerateIndex(ctx android.ModuleContext, desc string, classesJars android.Paths, indexCSV android.WritablePath) {
rule := android.NewRuleBuilder(pctx, ctx)
rule.Command().