Split PRODUCT_AFDO_PROFILES into two variables

Currently, PRODUCT_AFDO_PROFILES is generally applied to all products and is not semantically treated as a product config varilable.

Splitting this allows us:
1. Explicitly tell that PRODUCT_AFDO_PROFILES takes precedence over product-agnostic profiles in AFDO_PROFILES
2. Add PRODUCT_AFDO_PROFILES to _product_vars_list

Test: Define PRODUCT_AFDO_PROFILES in a product config and make sure it appears first in the soong var AfdoProfiles
Bug: 277215393
Change-Id: I284f6308d456994bb72129cb0d7be7cd091993ae
Merged-In: I284f6308d456994bb72129cb0d7be7cd091993ae
diff --git a/core/product.mk b/core/product.mk
index ed10604..1789561 100644
--- a/core/product.mk
+++ b/core/product.mk
@@ -395,6 +395,8 @@
 #   supports it
 _product_single_value_vars += PRODUCT_ENABLE_UFFD_GC
 
+_product_list_vars += PRODUCT_AFDO_PROFILES
+
 .KATI_READONLY := _product_single_value_vars _product_list_vars
 _product_var_list :=$= $(_product_single_value_vars) $(_product_list_vars)
 
diff --git a/core/soong_config.mk b/core/soong_config.mk
index a3961f9..346edcf 100644
--- a/core/soong_config.mk
+++ b/core/soong_config.mk
@@ -12,7 +12,15 @@
 include $(BUILD_SYSTEM)/art_config.mk
 include $(BUILD_SYSTEM)/dex_preopt_config.mk
 
+ifndef AFDO_PROFILES
+# Set AFDO_PROFILES
 -include vendor/google_data/pgo_profile/sampling/afdo_profiles.mk
+else
+$(error AFDO_PROFILES can only be set from soong_config.mk. For product-specific fdo_profiles, please use PRODUCT_AFDO_PROFILES)
+endif
+
+# PRODUCT_AFDO_PROFILES takes precedence over product-agnostic profiles in AFDO_PROFILES
+ALL_AFDO_PROFILES := $(PRODUCT_AFDO_PROFILES) $(AFDO_PROFILES)
 
 ifeq ($(WRITE_SOONG_VARIABLES),true)
 
@@ -311,7 +319,7 @@
 $(call add_json_list, IncludeTags,                $(PRODUCT_INCLUDE_TAGS))
 $(call add_json_list, SourceRootDirs,             $(PRODUCT_SOURCE_ROOT_DIRS))
 
-$(call add_json_list, AfdoProfiles,                $(PRODUCT_AFDO_PROFILES))
+$(call add_json_list, AfdoProfiles,                $(ALL_AFDO_PROFILES))
 
 $(call json_end)