Add minSdkVersion to default manifests

If the default manifest that doesn't set minSdkVersion is passed to
manifest merger along with a library manifest that does, it will fail
with:
.../DefaultManifest.xml Error:
	uses-sdk:minSdkVersion 1 cannot be smaller than version 14 declared in library ...

Translate LOCAL_MIN_SDK_VERSION or LOCAL_SDK_VERSION to minSdkVersion
in DefaultManifest.xml.

Bug: 79481102
Test: m checkbuild
Change-Id: I4d792d48612e6a1111e05a9e4a71bb4d87eae1ad
diff --git a/core/force_aapt2.mk b/core/force_aapt2.mk
index 3537cba..a097bd2 100644
--- a/core/force_aapt2.mk
+++ b/core/force_aapt2.mk
@@ -49,7 +49,15 @@
         # work around missing manifests by creating a default one
         $(call pretty-warning, Missing manifest file)
         LOCAL_FULL_MANIFEST_FILE := $(call local-intermediates-dir,COMMON)/DefaultManifest.xml
-        $(call create-default-manifest-file,$(LOCAL_FULL_MANIFEST_FILE))
+        ifdef LOCAL_MIN_SDK_VERSION
+          my_manifest_min_sdk_version := $(LOCAL_MIN_SDK_VERSION)
+        else ifneq (,$(filter-out current system_current test_current core_current, $(LOCAL_SDK_VERSION)))
+          my_manifest_min_sdk_version := $(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION))
+        else
+          my_manifest_min_sdk_version := $(DEFAULT_APP_TARGET_SDK)
+        endif
+        $(call create-default-manifest-file,$(LOCAL_FULL_MANIFEST_FILE),$(my_manifest_min_sdk_version))
+        my_manifest_min_sdk_version :=
       endif
     endif
   endif