Introduce a system feature annotation processor
Add a system feature annotation processor that can be used to compute
various useful properties for system features, putting them in a single
SystemFeaturesMetadata class. To start, generate the number of system
features in PackageManager as annotated with
@SdkConstant(SdkConstantType.FEATURE).
A follow-up change will add this processor as a plugin to the framework,
using the feature count as a size hint for the system feature IPC cache.
A separate follow-up will augment the codegen such that we can compute a
"perfect" indexing of SDK system features to indices. This can then be
used to optimize system feature queries without paying a (relatively)
high per-process memory cost for a runtime, string-based hash.
Bug: 203143243
Test: atest systemfeatures-gen-tests
Change-Id: I70f0f148cd644e3f38648f023df13624004766f0
diff --git a/tools/systemfeatures/Android.bp b/tools/systemfeatures/Android.bp
index e6d0a3d..2ebede3 100644
--- a/tools/systemfeatures/Android.bp
+++ b/tools/systemfeatures/Android.bp
@@ -13,6 +13,7 @@
srcs: [
"src/**/*.java",
"src/**/*.kt",
+ ":framework-metalava-annotations",
],
static_libs: [
"guava",
@@ -26,6 +27,12 @@
static_libs: ["systemfeatures-gen-lib"],
}
+java_plugin {
+ name: "systemfeatures-metadata-processor",
+ processor_class: "com.android.systemfeatures.SystemFeaturesMetadataProcessor",
+ static_libs: ["systemfeatures-gen-lib"],
+}
+
genrule {
name: "systemfeatures-gen-tests-srcs",
cmd: "$(location systemfeatures-gen-tool) com.android.systemfeatures.RwNoFeatures --readonly=false > $(location RwNoFeatures.java) && " +
@@ -61,6 +68,7 @@
"systemfeatures-gen-lib",
"truth",
],
+ plugins: ["systemfeatures-metadata-processor"],
}
// Rename the goldens as they may be copied into the source tree, and we don't