Merge "Products launching with API 28 needs system-as-root"
diff --git a/core/binary.mk b/core/binary.mk
index c2fa27c..97429c3 100644
--- a/core/binary.mk
+++ b/core/binary.mk
@@ -225,7 +225,15 @@
 endif
 
 ifneq ($(LOCAL_USE_VNDK),)
-  my_cflags += -D__ANDROID_API__=__ANDROID_API_FUTURE__ -D__ANDROID_VNDK__
+  # Required VNDK version for vendor modules is BOARD_VNDK_VERSION.
+  my_vndk_version := $(BOARD_VNDK_VERSION)
+  ifeq ($(my_vndk_version),current)
+    # Build with current PLATFORM_VNDK_VERSION.
+    # If PLATFORM_VNDK_VERSION has a CODENAME, it will return
+    # __ANDROID_API_FUTURE__.
+    my_vndk_version := $(call codename-or-sdk-to-sdk,$(PLATFORM_VNDK_VERSION))
+  endif
+  my_cflags += -D__ANDROID_API__=$(my_vndk_version) -D__ANDROID_VNDK__
 endif
 
 ifndef LOCAL_IS_HOST_MODULE
diff --git a/core/local_systemsdk.mk b/core/local_systemsdk.mk
index 6dab346..49085fd 100644
--- a/core/local_systemsdk.mk
+++ b/core/local_systemsdk.mk
@@ -25,7 +25,12 @@
   ifneq (,$(filter JAVA_LIBRARIES APPS,$(LOCAL_MODULE_CLASS)))
     ifndef LOCAL_SDK_VERSION
       ifeq ($(_is_vendor_app),true)
-        LOCAL_SDK_VERSION := system_current
+        ifeq (,$(findstring __auto_generated_rro,$(LOCAL_MODULE)))
+          # Runtime resource overlay for framework-res is exempted from building
+          # against System SDK.
+          # TODO(b/35859726): remove this exception
+          LOCAL_SDK_VERSION := system_current
+        endif
       endif
     endif
   endif