Ignore some properties for T and above.

As requested by reminv@, their team wants the source code in
sc-mainline-prod to be strictly the same as the code in AOSP. Therefore,
we need to ignore `standalone_contents` in the
`systemserverclasspath_fragment` module and
`systemserverclasspath_fragments` in the `sdk` module in order to merge
aosp/1925682 into sc-mainline-prod.

- `standalone_contents` in the `systemserverclasspath_fragment` module
  does nothing but adds its contents as dependencies of the APEX.
- `systemserverclasspath_fragments` in the `sdk` module does nothing.

Bug: 203198541
Test: TARGET_BUILD_APPS=com.android.tethering vendor/google/build/mainline_modules_bundles.sh
Change-Id: I56ca22aa91a807cd113dfda2fabaeb49ecabe289
Merged-In: I09a6fd1d3db85c194330da9b751702a9bf069e26
diff --git a/java/systemserver_classpath_fragment.go b/java/systemserver_classpath_fragment.go
index 10dbd01..be28fe9 100644
--- a/java/systemserver_classpath_fragment.go
+++ b/java/systemserver_classpath_fragment.go
@@ -72,10 +72,15 @@
 }
 
 type systemServerClasspathFragmentProperties struct {
-	// The contents of this systemserverclasspath_fragment, could be either java_library, or java_sdk_library.
+	// List of system_server classpath jars, could be either java_library, or java_sdk_library.
 	//
 	// The order of this list matters as it is the order that is used in the SYSTEMSERVERCLASSPATH.
 	Contents []string
+
+	// List of jars that system_server loads dynamically using separate classloaders.
+	//
+	// The order does not matter.
+	Standalone_contents []string
 }
 
 func systemServerClasspathFactory() android.Module {
@@ -88,8 +93,12 @@
 }
 
 func (s *SystemServerClasspathModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
-	if len(s.properties.Contents) == 0 {
-		ctx.PropertyErrorf("contents", "empty contents are not allowed")
+	if len(s.properties.Contents) == 0 && len(s.properties.Standalone_contents) == 0 {
+		ctx.PropertyErrorf("contents", "Either contents or standalone_contents needs to be non-empty")
+	}
+
+	if s.ShouldIgnore() {
+		return
 	}
 
 	configuredJars := s.configuredJars(ctx)
@@ -128,8 +137,17 @@
 
 func (s *SystemServerClasspathModule) ComponentDepsMutator(ctx android.BottomUpMutatorContext) {
 	module := ctx.Module()
+	var deps []string
+	deps = append(deps, s.properties.Contents...)
+	deps = append(deps, s.properties.Standalone_contents...)
 
-	for _, name := range s.properties.Contents {
+	for _, name := range deps {
 		ctx.AddDependency(module, systemServerClasspathFragmentContentDepTag, name)
 	}
 }
+
+func (s *SystemServerClasspathModule) ShouldIgnore() bool {
+	// Ignore this `systemserverclasspath_fragment` if it only contains `standalone_contents` because
+	// it is for T and above.
+	return len(s.properties.Contents) == 0
+}