Add build number if TARGET_BUILD_APPS_WITH_BUILD_NUMBER is defined

This change allows unbundled app builds to embed the build number in the
version name by defining TARGET_BUILD_APPS_WITH_BUILD_NUMBER, so that
APK files from a build can be easily identified.

Ignore-AOSP-First: changes in topics with internal-only projects
Test: manual build
Bug: 340311907
Change-Id: I9a7e4f96f0d92c19d832933b5c68bd6b75ce9ce6
diff --git a/core/config.mk b/core/config.mk
index 43304d5..949ea54 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -1193,6 +1193,11 @@
 
 APPS_DEFAULT_VERSION_NAME := $(PLATFORM_VERSION)
 
+# Add BUILD_NUMBER to apps if TARGET_BUILD_APPS_WITH_BUILD_NUMBER is defined.
+ifeq ($(TARGET_BUILD_APPS_WITH_BUILD_NUMBER),true)
+  APPS_DEFAULT_VERSION_NAME := $(PLATFORM_VERSION)-$(BUILD_NUMBER_FROM_FILE)
+endif
+
 # ANDROID_WARNING_ALLOWED_PROJECTS is generated by build/soong.
 define find_warning_allowed_projects
     $(filter $(ANDROID_WARNING_ALLOWED_PROJECTS),$(1)/)