Merge "move audio policy service to a separate library"
diff --git a/core/64_bit_blacklist.mk b/core/64_bit_blacklist.mk
index 0171e67..9f16536 100644
--- a/core/64_bit_blacklist.mk
+++ b/core/64_bit_blacklist.mk
@@ -16,8 +16,6 @@
 
 # misc build errors
 _64_bit_directory_blacklist += \
-	external/oprofile/daemon \
-	external/oprofile/opcontrol \
 	frameworks/av \
 	frameworks/base \
 	device/generic/goldfish/opengl \
diff --git a/core/binary.mk b/core/binary.mk
index 9d58173..931e422 100644
--- a/core/binary.mk
+++ b/core/binary.mk
@@ -143,7 +143,7 @@
   my_static_libraries += $(ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES)
 endif
 
-ifeq ($(strip $($(LOCAL_2ND_ARCH_VAR_PREFIX)WITHOUT_CLANG)),true)
+ifeq ($(strip $($(LOCAL_2ND_ARCH_VAR_PREFIX)WITHOUT_$(my_prefix)CLANG)),true)
   LOCAL_CLANG :=
 endif
 
diff --git a/core/clang/TARGET_arm64.mk b/core/clang/TARGET_arm64.mk
index 16027fa..9134f1d 100644
--- a/core/clang/TARGET_arm64.mk
+++ b/core/clang/TARGET_arm64.mk
@@ -1,7 +1,7 @@
 
 include $(BUILD_SYSTEM)/clang/arm64.mk
 
-CLANG_CONFIG_arm64_TARGET_TRIPLE := aarch64-linux-androideabi
+CLANG_CONFIG_arm64_TARGET_TRIPLE := aarch64-linux-android
 CLANG_CONFIG_arm64_TARGET_TOOLCHAIN_PREFIX := \
   $(TARGET_TOOLCHAIN_ROOT)/$(CLANG_CONFIG_arm64_TARGET_TRIPLE)/bin
 
@@ -51,4 +51,4 @@
   $(CLANG_CONFIG_arm64_TARGET_EXTRA_LDFLAGS)
 
 $(warning Incorrect arm64 RS_TRIPLE, fix me!)
-RS_TRIPLE := armv7-none-linux-gnueabi
+RS_TRIPLE := aarch64-linux-android
diff --git a/core/clang/config.mk b/core/clang/config.mk
index 1fd69d7..96f860d 100644
--- a/core/clang/config.mk
+++ b/core/clang/config.mk
@@ -1,3 +1,11 @@
+## Clang configurations.
+
+# WITHOUT_CLANG covers both HOST and TARGET
+ifeq ($(WITHOUT_CLANG),true)
+WITHOUT_TARGET_CLANG := true
+WITHOUT_HOST_CLANG := true
+endif
+
 ifeq (true,$(FORCE_BUILD_LLVM_COMPONENTS))
 LLVM_PREBUILTS_PATH := $(BUILD_OUT_EXECUTABLES)
 LLVM_PREBUILTS_HEADER_PATH := external/clang/lib/include
diff --git a/core/cleanbuild.mk b/core/cleanbuild.mk
index fa67332..dfdf43d 100644
--- a/core/cleanbuild.mk
+++ b/core/cleanbuild.mk
@@ -196,7 +196,8 @@
 	$(PRODUCT_OUT)/obj/EXECUTABLES/adbd_intermediates \
 	$(PRODUCT_OUT)/obj/EXECUTABLES/init_intermediates \
 	$(PRODUCT_OUT)/obj/ETC/mac_permissions.xml_intermediates \
-	$(PRODUCT_OUT)/obj/ETC/sepolicy_intermediates
+	$(PRODUCT_OUT)/obj/ETC/sepolicy_intermediates \
+	$(PRODUCT_OUT)/obj/ETC/init.environ.rc_intermediates
 
 # The files/dirs to delete during a dataclean, which removes any files
 # in the staging and emulator data partitions.
diff --git a/core/combo/HOST_darwin-x86.mk b/core/combo/HOST_darwin-x86.mk
index a0aaafa..037dee6 100644
--- a/core/combo/HOST_darwin-x86.mk
+++ b/core/combo/HOST_darwin-x86.mk
@@ -36,7 +36,7 @@
 
 # Workaround differences in inttypes.h between host and target.
 # See bug 12708004.
-HOST_GLOBAL_CFLAGS += -D__STDC_FORMAT_MACROS
+HOST_GLOBAL_CFLAGS += -D__STDC_FORMAT_MACROS -D__STDC_CONSTANT_MACROS
 
 build_mac_version := $(shell sw_vers -productVersion)
 
diff --git a/core/combo/HOST_linux-x86.mk b/core/combo/HOST_linux-x86.mk
index 3d03ed6..129acb0 100644
--- a/core/combo/HOST_linux-x86.mk
+++ b/core/combo/HOST_linux-x86.mk
@@ -25,14 +25,14 @@
 # Previously the prebiult host toolchain is used only for the sdk build,
 # that's why we have "sdk" in the path name.
 ifeq ($(strip $(HOST_TOOLCHAIN_PREFIX)),)
-HOST_TOOLCHAIN_PREFIX := prebuilts/tools/gcc-sdk
+HOST_TOOLCHAIN_PREFIX := prebuilts/tools/gcc-sdk/
 endif
 # Don't do anything if the toolchain is not there
-ifneq (,$(strip $(wildcard $(HOST_TOOLCHAIN_PREFIX)/gcc)))
-HOST_CC  := $(HOST_TOOLCHAIN_PREFIX)/gcc
-HOST_CXX := $(HOST_TOOLCHAIN_PREFIX)/g++
-HOST_AR  := $(HOST_TOOLCHAIN_PREFIX)/ar
-endif # $(HOST_TOOLCHAIN_PREFIX)/gcc exists
+ifneq (,$(strip $(wildcard $(HOST_TOOLCHAIN_PREFIX)gcc)))
+HOST_CC  := $(HOST_TOOLCHAIN_PREFIX)gcc
+HOST_CXX := $(HOST_TOOLCHAIN_PREFIX)g++
+HOST_AR  := $(HOST_TOOLCHAIN_PREFIX)ar
+endif # $(HOST_TOOLCHAIN_PREFIX)gcc exists
 
 ifneq ($(strip $(BUILD_HOST_64bit)),)
 # By default we build everything in 32-bit, because it gives us
@@ -60,6 +60,6 @@
 
 # Workaround differences in inttypes.h between host and target.
 # See bug 12708004.
-HOST_GLOBAL_CFLAGS += -D__STDC_FORMAT_MACROS
+HOST_GLOBAL_CFLAGS += -D__STDC_FORMAT_MACROS -D__STDC_CONSTANT_MACROS
 
 HOST_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined
diff --git a/core/combo/HOST_windows-x86.mk b/core/combo/HOST_windows-x86.mk
index 2f27aa7..1709711 100644
--- a/core/combo/HOST_windows-x86.mk
+++ b/core/combo/HOST_windows-x86.mk
@@ -42,7 +42,7 @@
 
 # Workaround differences in inttypes.h between host and target.
 # See bug 12708004.
-HOST_GLOBAL_CFLAGS += -D__STDC_FORMAT_MACROS
+HOST_GLOBAL_CFLAGS += -D__STDC_FORMAT_MACROS -D__STDC_CONSTANT_MACROS
 
 HOST_CC := $(TOOLS_PREFIX)gcc$(TOOLS_EXE_SUFFIX)
 HOST_CXX := $(TOOLS_PREFIX)g++$(TOOLS_EXE_SUFFIX)
diff --git a/core/combo/TARGET_linux-arm64.mk b/core/combo/TARGET_linux-arm64.mk
index 7a7a0c9..1522834 100644
--- a/core/combo/TARGET_linux-arm64.mk
+++ b/core/combo/TARGET_linux-arm64.mk
@@ -48,7 +48,7 @@
 endif
 
 # TODO: Enable Clang when aarch64 prebuilt is added
-WITHOUT_CLANG := true
+# WITHOUT_TARGET_CLANG := true
 
 include $(TARGET_ARCH_SPECIFIC_MAKEFILE)
 
diff --git a/core/combo/TARGET_linux-mips64.mk b/core/combo/TARGET_linux-mips64.mk
index c1c6439..099edfa 100644
--- a/core/combo/TARGET_linux-mips64.mk
+++ b/core/combo/TARGET_linux-mips64.mk
@@ -48,7 +48,7 @@
 endif
 
 # TODO: Enable Clang when its mips64 prebuilt is added
-WITHOUT_CLANG := true
+WITHOUT_TARGET_CLANG := true
 
 include $(TARGET_ARCH_SPECIFIC_MAKEFILE)
 
diff --git a/core/config.mk b/core/config.mk
index 6217f2b..e9884be 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -375,7 +375,7 @@
 
 ifneq ($(HOST_JDK_TOOLS_JAR),)
 ifeq ($(wildcard $(HOST_JDK_TOOLS_JAR)),)
-$(error Error: could not find jdk tools.jar, please install JDK6)
+$(error Error: could not find jdk tools.jar, please check if your JDK was installed correctly)
 endif
 endif
 
@@ -490,6 +490,7 @@
     $(wildcard $(HISTORICAL_SDK_VERSIONS_ROOT)/*/android.jar)))
 
 INTERNAL_PLATFORM_API_FILE := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/public_api.txt
+INTERNAL_PLATFORM_REMOVED_API_FILE := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/removed.txt
 
 # This is the standard way to name a directory containing prebuilt target
 # objects. E.g., prebuilt/$(TARGET_PREBUILT_TAG)/libc.so
diff --git a/core/definitions.mk b/core/definitions.mk
index ba6b9dd..0b60fc9 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -2118,17 +2118,19 @@
 #    $(1)  target
 #    $(2)  stable api file
 #    $(3)  api file to be tested
-#    $(4)  arguments for apicheck
-#    $(5)  command to run if apicheck failed
-#    $(6)  target dependent on this api check
-#    $(7)  additional dependencies
+#    $(4)  stable removed api file
+#    $(5)  removed api file to be tested
+#    $(6)  arguments for apicheck
+#    $(7)  command to run if apicheck failed
+#    $(8)  target dependent on this api check
+#    $(9)  additional dependencies
 define check-api
-$(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/$(strip $(1))-timestamp: $(2) $(3) $(APICHECK) $(7)
+$(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/$(strip $(1))-timestamp: $(2) $(3) $(4) $(APICHECK) $(9)
 	@echo "Checking API:" $(1)
-	$(hide) ( $(APICHECK_COMMAND) $(4) $(2) $(3) || ( $(5) ; exit 38 ) )
+	$(hide) ( $(APICHECK_COMMAND) $(6) $(2) $(3) $(4) $(5) || ( $(7) ; exit 38 ) )
 	$(hide) mkdir -p $$(dir $$@)
 	$(hide) touch $$@
-$(6): $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/$(strip $(1))-timestamp
+$(8): $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/$(strip $(1))-timestamp
 endef
 
 ## Whether to build from source if prebuilt alternative exists
diff --git a/core/dumpvar.mk b/core/dumpvar.mk
index 7af0a0c..d3f3969 100644
--- a/core/dumpvar.mk
+++ b/core/dumpvar.mk
@@ -72,6 +72,7 @@
 $(info   TARGET_BUILD_TYPE=$(TARGET_BUILD_TYPE))
 $(info   TARGET_BUILD_APPS=$(TARGET_BUILD_APPS))
 $(info   TARGET_ARCH=$(TARGET_ARCH))
+$(info   TARGET_2ND_ARCH=$(TARGET_2ND_ARCH))
 $(info   TARGET_ARCH_VARIANT=$(TARGET_ARCH_VARIANT))
 $(info   TARGET_CPU_VARIANT=$(TARGET_CPU_VARIANT))
 $(info   HOST_ARCH=$(HOST_ARCH))
diff --git a/core/dynamic_binary.mk b/core/dynamic_binary.mk
index 6d3d2b5..1d3b99e 100644
--- a/core/dynamic_binary.mk
+++ b/core/dynamic_binary.mk
@@ -104,11 +104,12 @@
 strip_input := $(symbolic_output)
 strip_output := $(LOCAL_BUILT_MODULE)
 
-ifeq ($(strip $(LOCAL_STRIP_MODULE)),)
-  LOCAL_STRIP_MODULE := $(strip $(TARGET_STRIP_MODULE))
+my_strip_module := $(LOCAL_STRIP_MODULE)
+ifeq ($(my_strip_module),)
+  my_strip_module := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_STRIP_MODULE)
 endif
 
-ifeq ($(LOCAL_STRIP_MODULE),true)
+ifeq ($(my_strip_module),true)
 # Strip the binary
 $(strip_output): PRIVATE_STRIP := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_STRIP)
 $(strip_output): PRIVATE_OBJCOPY := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJCOPY)
@@ -129,7 +130,7 @@
 	@echo "target Unstripped: $(PRIVATE_MODULE) ($@)"
 	$(copy-file-to-target-with-cp)
 endif
-endif # LOCAL_STRIP_MODULE
+endif # my_strip_module
 
 
 $(cleantarget): PRIVATE_CLEAN_FILES += \
diff --git a/core/tasks/apicheck.mk b/core/tasks/apicheck.mk
index 00b78b9..4711d17 100644
--- a/core/tasks/apicheck.mk
+++ b/core/tasks/apicheck.mk
@@ -42,6 +42,8 @@
     checkapi-last, \
     $(SRC_API_DIR)/$(last_released_sdk_version).txt, \
     $(INTERNAL_PLATFORM_API_FILE), \
+    frameworks/base/api/removed.txt, \
+    $(INTERNAL_PLATFORM_REMOVED_API_FILE), \
     -hide 2 -hide 3 -hide 4 -hide 5 -hide 6 -hide 24 -hide 25 -hide 26 -hide 27 \
     -error 7 -error 8 -error 9 -error 10 -error 11 -error 12 -error 13 -error 14 -error 15 \
     -error 16 -error 17 -error 18 , \
@@ -56,6 +58,8 @@
     checkapi-current, \
     frameworks/base/api/current.txt, \
     $(INTERNAL_PLATFORM_API_FILE), \
+    frameworks/base/api/removed.txt, \
+    $(INTERNAL_PLATFORM_REMOVED_API_FILE), \
     -error 2 -error 3 -error 4 -error 5 -error 6 \
     -error 7 -error 8 -error 9 -error 10 -error 11 -error 12 -error 13 -error 14 -error 15 \
     -error 16 -error 17 -error 18 -error 19 -error 20 -error 21 -error 23 -error 24 \
@@ -69,5 +73,7 @@
 update-api: $(INTERNAL_PLATFORM_API_FILE) | $(ACP)
 	@echo Copying current.txt
 	$(hide) $(ACP) $(INTERNAL_PLATFORM_API_FILE) frameworks/base/api/current.txt
+	@echo Copying removed.txt
+	$(hide) $(ACP) $(INTERNAL_PLATFORM_REMOVED_API_FILE) frameworks/base/api/removed.txt
 
 endif
diff --git a/envsetup.sh b/envsetup.sh
index d3bfe80..ba4f683 100644
--- a/envsetup.sh
+++ b/envsetup.sh
@@ -191,10 +191,6 @@
     unset ANDROID_HOST_OUT
     export ANDROID_HOST_OUT=$(get_abs_build_var HOST_OUT)
 
-    # needed for processing samples collected by perf counters
-    unset OPROFILE_EVENTS_DIR
-    export OPROFILE_EVENTS_DIR=$T/external/oprofile/events
-
     # needed for building linux on MacOS
     # TODO: fix the path
     #export HOST_EXTRACFLAGS="-I "$T/system/kernel_headers/host_include
diff --git a/target/board/generic_arm64/BoardConfig.mk b/target/board/generic_arm64/BoardConfig.mk
index 0bdcd99..4e056d1 100644
--- a/target/board/generic_arm64/BoardConfig.mk
+++ b/target/board/generic_arm64/BoardConfig.mk
@@ -55,9 +55,4 @@
 BOARD_FLASH_BLOCK_SIZE := 512
 TARGET_USERIMAGES_SPARSE_EXT_DISABLED := true
 
-# FIXME
-# Temporarily disable linking against compiler_rt until there is an arm64
-# version
-WITHOUT_LIBCOMPILER_RT := true
-
 BUILD_EMULATOR := false
diff --git a/target/product/base.mk b/target/product/base.mk
index b0e5de8..f2bef0f 100644
--- a/target/product/base.mk
+++ b/target/product/base.mk
@@ -98,7 +98,6 @@
     racoon \
     run-as \
     schedtest \
-    screenshot \
     sdcard \
     services \
     settings \