Merge changes from topic "expose_flagged_api" into main am: af26c102b8 am: ff593197d9 am: daa3a1a2db

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2755310

Change-Id: Iaebf2400acb3ffd5c1781bb8cb47c28c1a180f23
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Jihoon Kang
2023-09-27 20:50:16 +00:00
committed by Automerger Merge Worker
4 changed files with 48 additions and 0 deletions

View File

@@ -2084,3 +2084,11 @@ func (c *deviceConfig) CheckVendorSeappViolations() bool {
func (c *deviceConfig) NextReleaseHideFlaggedApi() bool { func (c *deviceConfig) NextReleaseHideFlaggedApi() bool {
return Bool(c.config.productVariables.NextReleaseHideFlaggedApi) return Bool(c.config.productVariables.NextReleaseHideFlaggedApi)
} }
func (c *deviceConfig) ReleaseExposeFlaggedApi() bool {
return Bool(c.config.productVariables.ReleaseExposeFlaggedApi)
}
func (c *deviceConfig) HideFlaggedApis() bool {
return c.NextReleaseHideFlaggedApi() && !c.ReleaseExposeFlaggedApi()
}

View File

@@ -490,6 +490,8 @@ type ProductVariables struct {
PartitionVarsForBazelMigrationOnlyDoNotUse PartitionVariables `json:",omitempty"` PartitionVarsForBazelMigrationOnlyDoNotUse PartitionVariables `json:",omitempty"`
NextReleaseHideFlaggedApi *bool `json:",omitempty"` NextReleaseHideFlaggedApi *bool `json:",omitempty"`
ReleaseExposeFlaggedApi *bool `json:",omitempty"`
} }
type PartitionVariables struct { type PartitionVariables struct {

View File

@@ -540,6 +540,10 @@ func metalavaCmd(ctx android.ModuleContext, rule *android.RuleBuilder, javaVersi
// See b/285312164 for more information. // See b/285312164 for more information.
cmd.FlagWithArg("--format-defaults ", "overloaded-method-order=source") cmd.FlagWithArg("--format-defaults ", "overloaded-method-order=source")
if ctx.DeviceConfig().HideFlaggedApis() {
cmd.FlagWithArg("--hide-annotation ", "android.annotation.FlaggedApi")
}
return cmd return cmd
} }

View File

@@ -22,6 +22,8 @@ import (
"testing" "testing"
"android/soong/android" "android/soong/android"
"github.com/google/blueprint/proptools"
) )
func TestDroidstubs(t *testing.T) { func TestDroidstubs(t *testing.T) {
@@ -403,3 +405,35 @@ func TestGeneratedApiContributionVisibilityTest(t *testing.T) {
ctx.ModuleForTests("bar", "android_common") ctx.ModuleForTests("bar", "android_common")
} }
func TestDroidstubsHideFlaggedApi(t *testing.T) {
result := android.GroupFixturePreparers(
prepareForJavaTest,
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
variables.NextReleaseHideFlaggedApi = proptools.BoolPtr(true)
variables.ReleaseExposeFlaggedApi = proptools.BoolPtr(false)
}),
android.FixtureMergeMockFs(map[string][]byte{
"a/A.java": nil,
"a/current.txt": nil,
"a/removed.txt": nil,
}),
).RunTestWithBp(t, `
droidstubs {
name: "foo",
srcs: ["a/A.java"],
api_surface: "public",
check_api: {
current: {
api_file: "a/current.txt",
removed_api_file: "a/removed.txt",
}
},
}
`)
m := result.ModuleForTests("foo", "android_common")
manifest := m.Output("metalava.sbox.textproto")
cmdline := String(android.RuleBuilderSboxProtoForTests(t, manifest).Commands[0].Command)
android.AssertStringDoesContain(t, "flagged api hide command not included", cmdline, "--hide-annotation android.annotation.FlaggedApi")
}