Loading java/base.go +5 −3 Original line number Diff line number Diff line Loading @@ -1223,9 +1223,11 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) { return } // Hidden API CSV generation and dex encoding dexOutputFile = j.hiddenAPIExtractAndEncode(ctx, dexOutputFile, j.implementationJarFile, proptools.Bool(j.dexProperties.Uncompress_dex)) // Update hidden API paths. j.hiddenAPIUpdatePaths(ctx, dexOutputFile, j.implementationJarFile) // Encode hidden API flags in dex file. dexOutputFile = j.hiddenAPIEncodeDex(ctx, dexOutputFile, proptools.Bool(j.dexProperties.Uncompress_dex)) // merge dex jar with resources if necessary if j.resourceJar != nil { Loading java/hiddenapi.go +33 −73 Original line number Diff line number Diff line Loading @@ -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. Loading Loading @@ -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 Loading @@ -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. Loading @@ -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, Loading @@ -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, Loading @@ -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(). Loading java/java.go +6 −4 Original line number Diff line number Diff line Loading @@ -1315,7 +1315,7 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) { di := ctx.OtherModuleProvider(deapexerModule, android.DeapexerProvider).(android.DeapexerInfo) if dexOutputPath := di.PrebuiltExportPath(j.BaseModuleName(), ".dexjar"); dexOutputPath != nil { j.dexJarFile = dexOutputPath j.hiddenAPIExtractInformation(ctx, dexOutputPath, outputFile) j.hiddenAPIUpdatePaths(ctx, dexOutputPath, outputFile) } else { // This should never happen as a variant for a prebuilt_apex is only created if the // prebuilt_apex has been configured to export the java library dex file. Loading Loading @@ -1346,9 +1346,11 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) { return } // Hidden API CSV generation and dex encoding dexOutputFile = j.hiddenAPIExtractAndEncode(ctx, dexOutputFile, outputFile, proptools.Bool(j.dexProperties.Uncompress_dex)) // Update hidden API paths. j.hiddenAPIUpdatePaths(ctx, dexOutputFile, outputFile) // Encode hidden API flags in dex file. dexOutputFile = j.hiddenAPIEncodeDex(ctx, dexOutputFile, proptools.Bool(j.dexProperties.Uncompress_dex)) j.dexJarFile = dexOutputFile } Loading java/sdk_library.go +1 −1 Original line number Diff line number Diff line Loading @@ -2128,7 +2128,7 @@ func (module *SdkLibraryImport) GenerateAndroidBuildActions(ctx android.ModuleCo if dexOutputPath := di.PrebuiltExportPath(module.BaseModuleName(), ".dexjar"); dexOutputPath != nil { module.dexJarFile = dexOutputPath module.initHiddenAPI(ctx, module.configurationName) module.hiddenAPIExtractInformation(ctx, dexOutputPath, module.findScopePaths(apiScopePublic).stubsImplPath[0]) module.hiddenAPIUpdatePaths(ctx, dexOutputPath, module.findScopePaths(apiScopePublic).stubsImplPath[0]) } else { // This should never happen as a variant for a prebuilt_apex is only created if the // prebuilt_apex has been configured to export the java library dex file. Loading Loading
java/base.go +5 −3 Original line number Diff line number Diff line Loading @@ -1223,9 +1223,11 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) { return } // Hidden API CSV generation and dex encoding dexOutputFile = j.hiddenAPIExtractAndEncode(ctx, dexOutputFile, j.implementationJarFile, proptools.Bool(j.dexProperties.Uncompress_dex)) // Update hidden API paths. j.hiddenAPIUpdatePaths(ctx, dexOutputFile, j.implementationJarFile) // Encode hidden API flags in dex file. dexOutputFile = j.hiddenAPIEncodeDex(ctx, dexOutputFile, proptools.Bool(j.dexProperties.Uncompress_dex)) // merge dex jar with resources if necessary if j.resourceJar != nil { Loading
java/hiddenapi.go +33 −73 Original line number Diff line number Diff line Loading @@ -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. Loading Loading @@ -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 Loading @@ -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. Loading @@ -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, Loading @@ -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, Loading @@ -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(). Loading
java/java.go +6 −4 Original line number Diff line number Diff line Loading @@ -1315,7 +1315,7 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) { di := ctx.OtherModuleProvider(deapexerModule, android.DeapexerProvider).(android.DeapexerInfo) if dexOutputPath := di.PrebuiltExportPath(j.BaseModuleName(), ".dexjar"); dexOutputPath != nil { j.dexJarFile = dexOutputPath j.hiddenAPIExtractInformation(ctx, dexOutputPath, outputFile) j.hiddenAPIUpdatePaths(ctx, dexOutputPath, outputFile) } else { // This should never happen as a variant for a prebuilt_apex is only created if the // prebuilt_apex has been configured to export the java library dex file. Loading Loading @@ -1346,9 +1346,11 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) { return } // Hidden API CSV generation and dex encoding dexOutputFile = j.hiddenAPIExtractAndEncode(ctx, dexOutputFile, outputFile, proptools.Bool(j.dexProperties.Uncompress_dex)) // Update hidden API paths. j.hiddenAPIUpdatePaths(ctx, dexOutputFile, outputFile) // Encode hidden API flags in dex file. dexOutputFile = j.hiddenAPIEncodeDex(ctx, dexOutputFile, proptools.Bool(j.dexProperties.Uncompress_dex)) j.dexJarFile = dexOutputFile } Loading
java/sdk_library.go +1 −1 Original line number Diff line number Diff line Loading @@ -2128,7 +2128,7 @@ func (module *SdkLibraryImport) GenerateAndroidBuildActions(ctx android.ModuleCo if dexOutputPath := di.PrebuiltExportPath(module.BaseModuleName(), ".dexjar"); dexOutputPath != nil { module.dexJarFile = dexOutputPath module.initHiddenAPI(ctx, module.configurationName) module.hiddenAPIExtractInformation(ctx, dexOutputPath, module.findScopePaths(apiScopePublic).stubsImplPath[0]) module.hiddenAPIUpdatePaths(ctx, dexOutputPath, module.findScopePaths(apiScopePublic).stubsImplPath[0]) } else { // This should never happen as a variant for a prebuilt_apex is only created if the // prebuilt_apex has been configured to export the java library dex file. Loading