Add system-server sdk type to droidstubs

Needed to generate the system-server api database.

Bug: 193460475
Test: go test
Change-Id: I8c6bb3cc1d16ae128b7bcd2513fce4a83e852a5e
This commit is contained in:
Cole Faust
2022-10-05 12:45:42 -07:00
parent 0342382526
commit 051fa91513
2 changed files with 20 additions and 3 deletions

View File

@@ -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":

View File

@@ -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 {