Merge "releasetools: Stop copying images from RADIO/ to IMAGES/."
diff --git a/core/autogen_test_config.mk b/core/autogen_test_config.mk
index c359bac..d2eb7c3 100644
--- a/core/autogen_test_config.mk
+++ b/core/autogen_test_config.mk
@@ -24,8 +24,13 @@
 
 autogen_test_config_file := $(dir $(LOCAL_BUILT_MODULE))$(LOCAL_MODULE).config
 ifeq (true,$(is_native))
+ifeq ($(LOCAL_NATIVE_BENCHMARK),true)
+autogen_test_config_template := $(NATIVE_BENCHMARK_TEST_CONFIG_TEMPLATE)
+else
+autogen_test_config_template := $(NATIVE_TEST_CONFIG_TEMPLATE)
+endif
 # Auto generating test config file for native test
-$(autogen_test_config_file) : $(NATIVE_TEST_CONFIG_TEMPLATE)
+$(autogen_test_config_file) : $(autogen_test_config_template)
 	@echo "Auto generating test config $(notdir $@)"
 	$(hide) sed 's&{MODULE}&$(PRIVATE_MODULE)&g' $^ > $@
 my_auto_generate_config := true
diff --git a/core/base_rules.mk b/core/base_rules.mk
index f1ba90b..ec04f14 100644
--- a/core/base_rules.mk
+++ b/core/base_rules.mk
@@ -546,10 +546,6 @@
   is_native := true
   multi_arch := true
 endif
-ifeq ($(LOCAL_MODULE_CLASS),NATIVE_BENCHMARK)
-  is_native := true
-  multi_arch := true
-endif
 ifdef LOCAL_MULTILIB
   multi_arch := true
 endif
diff --git a/core/clear_vars.mk b/core/clear_vars.mk
index 5f3cfdf..eac5987 100644
--- a/core/clear_vars.mk
+++ b/core/clear_vars.mk
@@ -163,6 +163,7 @@
 LOCAL_MODULE_UNSUPPORTED_TARGET_ARCH:=
 LOCAL_MODULE_UNSUPPORTED_TARGET_ARCH_WARN:=
 LOCAL_MULTILIB:=
+LOCAL_NATIVE_BENCHMARK:=
 LOCAL_NDK_STL_VARIANT:=
 LOCAL_NDK_VERSION:=current
 LOCAL_NO_CRT:=
@@ -230,6 +231,7 @@
 LOCAL_SANITIZE_DIAG:=
 LOCAL_SANITIZE_RECOVER:=
 LOCAL_SANITIZE_BLACKLIST :=
+LOCAL_SDK_LIBRARIES :=
 LOCAL_SDK_RES_VERSION:=
 LOCAL_SDK_VERSION:=
 LOCAL_SHARED_ANDROID_LIBRARIES:=
diff --git a/core/config.mk b/core/config.mk
index c432c37..b07e9c2 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -152,6 +152,7 @@
 BUILD_TARGET_TEST_CONFIG := $(BUILD_SYSTEM)/target_test_config.mk
 
 INSTRUMENTATION_TEST_CONFIG_TEMPLATE := $(BUILD_SYSTEM)/instrumentation_test_config_template.xml
+NATIVE_BENCHMARK_TEST_CONFIG_TEMPLATE := $(BUILD_SYSTEM)/native_benchmark_test_config_template.xml
 NATIVE_TEST_CONFIG_TEMPLATE := $(BUILD_SYSTEM)/native_test_config_template.xml
 EMPTY_TEST_CONFIG := $(BUILD_SYSTEM)/empty_test_config.xml
 
@@ -963,10 +964,11 @@
 # 23 -> sdk_public_23_android
 # system_current -> sdk_system_current_android
 # $(1): An sdk version (LOCAL_SDK_VERSION)
+# $(2): optional library name (default: android)
 define resolve-prebuilt-sdk-module
 $(if $(findstring _,$(1)),\
-  sdk_$(1)_android,\
-  sdk_public_$(1)_android)
+  sdk_$(1)_$(or $(2),android),\
+  sdk_public_$(1)_$(or $(2),android))
 endef
 
 # Resolve LOCAL_SDK_VERSION to prebuilt framework.aidl
diff --git a/core/java_common.mk b/core/java_common.mk
index a65b6ef..0de8e92 100644
--- a/core/java_common.mk
+++ b/core/java_common.mk
@@ -230,6 +230,7 @@
 my_system_modules :=
 
 ifndef LOCAL_IS_HOST_MODULE
+  sdk_libs :=
   ifeq ($(LOCAL_SDK_VERSION),)
     ifeq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
       # No bootclasspath. But we still need "" to prevent javac from using default host bootclasspath.
@@ -261,9 +262,10 @@
     else ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),core_current)
       full_java_bootclasspath_libs := $(call java-lib-header-files,core.current.stubs)
     else
-      # TARGET_BUILD_APPS is set. Use the modules defined in prebuilts/sdk/Android.mk.
+      # TARGET_BUILD_APPS or numbered SDK. Use the modules defined in prebuilts/sdk/Android.mk.
       _module_name := $(call resolve-prebuilt-sdk-module,$(LOCAL_SDK_VERSION))
       full_java_bootclasspath_libs := $(call java-lib-header-files,$(_module_name))
+      sdk_libs := $(foreach lib_name,$(LOCAL_SDK_LIBRARIES),$(call resolve-prebuilt-sdk-module,$(LOCAL_SDK_VERSION),$(lib_name)))
       _module_name :=
     endif # current, system_current, system_${VER}, test_current or core_current
   endif # LOCAL_SDK_VERSION
@@ -291,10 +293,9 @@
       full_java_bootclasspath_libs += $(call java-lib-header-files,core-lambda-stubs)
     endif
   endif
-
-  full_shared_java_libs := $(call java-lib-files,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE))
-  full_shared_java_header_libs := $(call java-lib-header-files,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE))
-
+  full_shared_java_libs := $(call java-lib-files,$(LOCAL_JAVA_LIBRARIES) $(sdk_libs),$(LOCAL_IS_HOST_MODULE))
+  full_shared_java_header_libs := $(call java-lib-header-files,$(LOCAL_JAVA_LIBRARIES) $(sdk_libs),$(LOCAL_IS_HOST_MODULE))
+  sdk_libs :=
 else # LOCAL_IS_HOST_MODULE
 
   ifeq ($(USE_CORE_LIB_BOOTCLASSPATH),true)
diff --git a/core/native_benchmark_test_config_template.xml b/core/native_benchmark_test_config_template.xml
new file mode 100644
index 0000000..18736bf
--- /dev/null
+++ b/core/native_benchmark_test_config_template.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2018 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+<!-- This test config file is auto-generated. -->
+<configuration description="Runs {MODULE}.">
+    <option name="test-suite-tag" value="apct" />
+    <option name="test-suite-tag" value="apct-native-metric" />
+    <target_preparer class="com.android.tradefed.targetprep.PushFilePreparer">
+        <option name="cleanup" value="true" />
+        <option name="push" value="{MODULE}->/data/local/tmp/{MODULE}" />
+    </target_preparer>
+    <test class="com.android.tradefed.testtype.GoogleBenchmarkTest" >
+        <option name="native-benchmark-device-path" value="/data/local/tmp" />
+        <option name="benchmark-module-name" value="{MODULE}" />
+    </test>
+</configuration>