New LOCAL_SDK_RES_VERSION config var.

This allows an app to target a different SDK level for its resources
than it uses for its Java code.  This is useful because it is generally
safe to use various newer symbols like attribute names, as older versions
of the platform will simply ignore them.

Change-Id: Ida19ec9f259c4ea70de846e9a63546e263b1c91e
diff --git a/core/clear_vars.mk b/core/clear_vars.mk
index c5e4cc7..4e6858f 100644
--- a/core/clear_vars.mk
+++ b/core/clear_vars.mk
@@ -93,6 +93,7 @@
 LOCAL_DX_FLAGS:=
 LOCAL_CERTIFICATE:=
 LOCAL_SDK_VERSION:=
+LOCAL_SDK_RES_VERSION:=
 LOCAL_NDK_VERSION:=
 LOCAL_NDK_STL_VARIANT:=
 LOCAL_NO_EMMA_INSTRUMENT:=
diff --git a/core/package.mk b/core/package.mk
index e79059a..9f54bb0 100644
--- a/core/package.mk
+++ b/core/package.mk
@@ -161,6 +161,11 @@
 include $(BUILD_SYSTEM)/java.mk
 #################################
 
+LOCAL_SDK_RES_VERSION:=$(strip $(LOCAL_SDK_RES_VERSION))
+ifeq ($(LOCAL_SDK_RES_VERSION),)
+  LOCAL_SDK_RES_VERSION:=$(LOCAL_SDK_VERSION)
+endif
+
 full_android_manifest := $(LOCAL_PATH)/$(LOCAL_MANIFEST_FILE)
 $(LOCAL_INTERMEDIATE_TARGETS): \
     PRIVATE_ANDROID_MANIFEST := $(full_android_manifest)
@@ -250,12 +255,12 @@
 # Most packages should link against the resources defined by framework-res.
 # Even if they don't have their own resources, they may use framework
 # resources.
-ifneq ($(filter-out current,$(LOCAL_SDK_VERSION)),)
+ifneq ($(filter-out current,$(LOCAL_SDK_RES_VERSION)),)
 # for released sdk versions, the platform resources were built into android.jar.
 framework_res_package_export := \
-    $(HISTORICAL_SDK_VERSIONS_ROOT)/$(LOCAL_SDK_VERSION)/android.jar
+    $(HISTORICAL_SDK_VERSIONS_ROOT)/$(LOCAL_SDK_RES_VERSION)/android.jar
 framework_res_package_export_deps := $(framework_res_package_export)
-else # LOCAL_SDK_VERSION
+else # LOCAL_SDK_RES_VERSION
 framework_res_package_export := \
     $(call intermediates-dir-for,APPS,framework-res,,COMMON)/package-export.apk
 # We can't depend directly on the export.apk file; it won't get its
@@ -263,7 +268,7 @@
 # corresponding R.stamp file, which lists the export.apk as a dependency.
 framework_res_package_export_deps := \
     $(dir $(framework_res_package_export))src/R.stamp
-endif # LOCAL_SDK_VERSION
+endif # LOCAL_SDK_RES_VERSION
 $(R_file_stamp): $(framework_res_package_export_deps)
 $(LOCAL_INTERMEDIATE_TARGETS): \
     PRIVATE_AAPT_INCLUDES := $(framework_res_package_export)