Add property Exportable to aconfig_declarations

Only when aconfig_declarations explicitly set this property true,
its flags will be repackaged.

If a java_aconfig_library has mode "exported", its corresponding
aconfig_declarations must have exportable prop set to true.

Test: Added unit tests and CI

Bug: 310504781

Ignore-AOSP-First: this change will be cherry picked to aosp
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:e4527f3010b3fd6f33948a15a9b4fdc944da34f0)
Merged-In: Ie9526e3755a6e7d142b377d5dd85a1bc60ffabc5
Change-Id: Ie9526e3755a6e7d142b377d5dd85a1bc60ffabc5
diff --git a/aconfig/codegen/java_aconfig_library.go b/aconfig/codegen/java_aconfig_library.go
index 4b8d346..d4c6da5 100644
--- a/aconfig/codegen/java_aconfig_library.go
+++ b/aconfig/codegen/java_aconfig_library.go
@@ -91,6 +91,12 @@
 	if !isModeSupported(mode) {
 		ctx.PropertyErrorf("mode", "%q is not a supported mode", mode)
 	}
+	// TODO: uncomment this part after internal clean up
+	//if mode == "exported" && !declarations.Exportable {
+	//	// if mode is exported, the corresponding aconfig_declaration must mark its
+	//	// exportable property true
+	//	ctx.PropertyErrorf("mode", "exported mode requires its aconfig_declaration has exportable prop true")
+	//}
 
 	ctx.Build(pctx, android.BuildParams{
 		Rule:        javaRule,
@@ -102,12 +108,15 @@
 		},
 	})
 
-	// Mark our generated code as possibly needing jarjar repackaging
-	// TODO: Maybe control this with a property?
-	module.AddJarJarRenameRule(declarations.Package+".Flags", "")
-	module.AddJarJarRenameRule(declarations.Package+".FeatureFlags", "")
-	module.AddJarJarRenameRule(declarations.Package+".FeatureFlagsImpl", "")
-	module.AddJarJarRenameRule(declarations.Package+".FakeFeatureFlagsImpl", "")
+	if declarations.Exportable {
+		// Mark our generated code as possibly needing jarjar repackaging
+		// The repackaging only happens when the corresponding aconfig_declaration
+		// has property exportable true
+		module.AddJarJarRenameRule(declarations.Package+".Flags", "")
+		module.AddJarJarRenameRule(declarations.Package+".FeatureFlags", "")
+		module.AddJarJarRenameRule(declarations.Package+".FeatureFlagsImpl", "")
+		module.AddJarJarRenameRule(declarations.Package+".FakeFeatureFlagsImpl", "")
+	}
 
 	return srcJarPath
 }