From 051fa915137524c80128786c77149b0160836ed8 Mon Sep 17 00:00:00 2001 From: Cole Faust Date: Wed, 5 Oct 2022 12:45:42 -0700 Subject: [PATCH] Add system-server sdk type to droidstubs Needed to generate the system-server api database. Bug: 193460475 Test: go test Change-Id: I8c6bb3cc1d16ae128b7bcd2513fce4a83e852a5e --- java/droidstubs.go | 6 ++++-- java/droidstubs_test.go | 17 ++++++++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/java/droidstubs.go b/java/droidstubs.go index d9efb408f..5777b185c 100644 --- a/java/droidstubs.go +++ b/java/droidstubs.go @@ -28,7 +28,7 @@ import ( ) // The values allowed for Droidstubs' Api_levels_sdk_type -var allowedApiLevelSdkTypes = []string{"public", "system", "module-lib"} +var allowedApiLevelSdkTypes = []string{"public", "system", "module-lib", "system-server"} func init() { RegisterStubsBuildComponents(android.InitRegistrationContext) @@ -134,7 +134,7 @@ type DroidstubsProperties struct { // the dirs which Metalava extracts API levels annotations from. Api_levels_annotations_dirs []string - // the sdk kind which Metalava extracts API levels annotations from. Supports 'public', 'system' and 'module-lib' for now; defaults to public. + // the sdk kind which Metalava extracts API levels annotations from. Supports 'public', 'system', 'module-lib' and 'system-server'; defaults to public. Api_levels_sdk_type *string // the filename which Metalava extracts API levels annotations from. Defaults to android.jar. @@ -445,6 +445,8 @@ func (d *Droidstubs) apiLevelsGenerationFlags(ctx android.ModuleContext, cmd *an // for older releases. Similarly, module-lib falls back to system API. var sdkDirs []string switch proptools.StringDefault(d.properties.Api_levels_sdk_type, "public") { + case "system-server": + sdkDirs = []string{"system-server", "module-lib", "system", "public"} case "module-lib": sdkDirs = []string{"module-lib", "system", "public"} case "system": diff --git a/java/droidstubs_test.go b/java/droidstubs_test.go index 24436921c..25f8c8667 100644 --- a/java/droidstubs_test.go +++ b/java/droidstubs_test.go @@ -122,7 +122,7 @@ func getAndroidJarPatternsForDroidstubs(t *testing.T, sdkType string) []string { "some-other-exported-dir", ], api_levels_annotations_enabled: true, - api_levels_sdk_type: "%s", + api_levels_sdk_type: "%s", } `, sdkType), map[string][]byte{ @@ -169,6 +169,21 @@ func TestModuleLibDroidstubs(t *testing.T) { }, patterns) } +func TestSystemServerDroidstubs(t *testing.T) { + patterns := getAndroidJarPatternsForDroidstubs(t, "system-server") + + android.AssertArrayString(t, "order of patterns", []string{ + "--android-jar-pattern somedir/%/system-server/android.jar", + "--android-jar-pattern someotherdir/%/system-server/android.jar", + "--android-jar-pattern somedir/%/module-lib/android.jar", + "--android-jar-pattern someotherdir/%/module-lib/android.jar", + "--android-jar-pattern somedir/%/system/android.jar", + "--android-jar-pattern someotherdir/%/system/android.jar", + "--android-jar-pattern somedir/%/public/android.jar", + "--android-jar-pattern someotherdir/%/public/android.jar", + }, patterns) +} + func TestDroidstubsSandbox(t *testing.T) { ctx, _ := testJavaWithFS(t, ` genrule {