Include VCN in apex based on the build system flag

This patch includes VCN lib to apex jars when the build system flag
RELEASE_MOVE_VCN_TO_MAINLINE is enabled.

This patch also connects the build system flag to the
soong_config_bool_variable "is_vcn_in_mainline". The
"is_vcn_in_mainline" variable will be used in Android.bp files to
conditionally include VCN in either the Tethering module or
the platform.

Bug: 375213246
Test: flag enabled: VCN libs are in the tethering module
      flag disabled: VCN libs are in the platform
Flag: RELEASE_MOVE_VCN_TO_MAINLINE
Change-Id: I6240c0222fab042a8cf1794632358bf855903bba
diff --git a/core/android_soong_config_vars.mk b/core/android_soong_config_vars.mk
index 7d02df3..d3f49ba 100644
--- a/core/android_soong_config_vars.mk
+++ b/core/android_soong_config_vars.mk
@@ -200,6 +200,9 @@
 $(call soong_config_set,ANDROID,release_package_profiling_module,$(RELEASE_PACKAGE_PROFILING_MODULE))
 $(call soong_config_set,bootclasspath,release_package_profiling_module,$(RELEASE_PACKAGE_PROFILING_MODULE))
 
+# Move VCN from platform to the Tethering module; used by both platform and module
+$(call soong_config_set,ANDROID,is_vcn_in_mainline,$(RELEASE_MOVE_VCN_TO_MAINLINE))
+
 # Add perf-setup build flag to soong
 # Note: BOARD_PERFSETUP_SCRIPT location must be under platform_testing/scripts/perf-setup/.
 ifdef BOARD_PERFSETUP_SCRIPT
diff --git a/target/product/base_system.mk b/target/product/base_system.mk
index 15e6c04..660f27f 100644
--- a/target/product/base_system.mk
+++ b/target/product/base_system.mk
@@ -97,7 +97,6 @@
     enhanced-confirmation.xml \
     ExtShared \
     flags_health_check \
-    framework-connectivity-b \
     framework-graphics \
     framework-location \
     framework-minus-apex \
@@ -349,6 +348,13 @@
         com.android.webview.bootstrap
 endif
 
+# Only add the jar when it is not in the Tethering module. Otherwise,
+# it will be added via com.android.tethering
+ifneq ($(RELEASE_MOVE_VCN_TO_MAINLINE),true)
+    PRODUCT_PACKAGES += \
+        framework-connectivity-b
+endif
+
 ifneq (,$(RELEASE_RANGING_STACK))
     PRODUCT_PACKAGES += \
         com.android.ranging
diff --git a/target/product/default_art_config.mk b/target/product/default_art_config.mk
index 83d9215..d857e04 100644
--- a/target/product/default_art_config.mk
+++ b/target/product/default_art_config.mk
@@ -51,7 +51,6 @@
     framework-minus-apex \
     framework-graphics \
     framework-location \
-    framework-connectivity-b \
     ext \
     telephony-common \
     voip-common \
@@ -121,6 +120,17 @@
     $(call soong_config_set,bootclasspath,release_ranging_stack,true)
 endif
 
+# Check if VCN should be built into the tethering module or not
+ifeq ($(RELEASE_MOVE_VCN_TO_MAINLINE),true)
+    PRODUCT_APEX_BOOT_JARS += \
+        com.android.tethering:framework-connectivity-b \
+
+else
+    PRODUCT_BOOT_JARS += \
+        framework-connectivity-b \
+
+endif
+
 # List of system_server classpath jars delivered via apex.
 # Keep the list sorted by module names and then library names.
 # Note: For modules available in Q, DO NOT add new entries here.
diff --git a/target/product/generic/Android.bp b/target/product/generic/Android.bp
index 59172f0..e4a693e 100644
--- a/target/product/generic/Android.bp
+++ b/target/product/generic/Android.bp
@@ -706,7 +706,6 @@
                 "framework-graphics", // base_system
                 "framework-location", // base_system
                 "framework-minus-apex-install-dependencies", // base_system
-                "framework-connectivity-b", // base_system
                 "framework_compatibility_matrix.device.xml",
                 "generic_system_fonts", // ok
                 "hwservicemanager_compat_symlink_module", // base_system
@@ -735,6 +734,11 @@
                     "com.android.profiling", // base_system (RELEASE_PACKAGE_PROFILING_MODULE)
                 ],
                 default: [],
+            }) + select(release_flag("RELEASE_MOVE_VCN_TO_MAINLINE"), {
+                true: [],
+                default: [
+                    "framework-connectivity-b", // base_system
+                ],
             }) + select(release_flag("RELEASE_AVATAR_PICKER_APP"), {
                 true: [
                     "AvatarPicker", // generic_system (RELEASE_AVATAR_PICKER_APP)