Merge "Support custom sdk.atree files." into klp-modular-dev
diff --git a/CleanSpec.mk b/CleanSpec.mk
index c0525ad..ff05194 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -211,6 +211,11 @@
 # 4.4.2
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
 
+# KKWT development
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
+
 # ************************************************
 # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
 # ************************************************
diff --git a/core/android_manifest.mk b/core/android_manifest.mk
new file mode 100644
index 0000000..21b95c2
--- /dev/null
+++ b/core/android_manifest.mk
@@ -0,0 +1,25 @@
+# Handle AndroidManifest.xmls
+# Input: LOCAL_MANIFEST_FILE, LOCAL_FULL_MANIFEST_FILE, LOCAL_FULL_LIBS_MANIFEST_FILES
+# Output: full_android_manifest
+
+ifeq ($(strip $(LOCAL_MANIFEST_FILE)),)
+  LOCAL_MANIFEST_FILE := AndroidManifest.xml
+endif
+ifdef LOCAL_FULL_MANIFEST_FILE
+  full_android_manifest := $(LOCAL_FULL_MANIFEST_FILE)
+else
+  full_android_manifest := $(LOCAL_PATH)/$(LOCAL_MANIFEST_FILE)
+endif
+
+# Set up rules to merge library manifest files
+ifdef LOCAL_FULL_LIBS_MANIFEST_FILES
+main_android_manifest := $(full_android_manifest)
+full_android_manifest := $(intermediates.COMMON)/AndroidManifest.xml
+$(full_android_manifest): PRIVATE_LIBS_MANIFESTS := $(LOCAL_FULL_LIBS_MANIFEST_FILES)
+$(full_android_manifest) : $(main_android_manifest) $(LOCAL_FULL_LIBS_MANIFEST_FILES)
+	@echo "Merge android manifest files: $@ <-- $^"
+	@mkdir -p $(dir $@)
+	$(hide) $(ANDROID_MANIFEST_MERGER) --main $< --libs $(PRIVATE_LIBS_MANIFESTS) \
+	    --out $@
+
+endif
diff --git a/core/clear_vars.mk b/core/clear_vars.mk
index 8863fe6..c212c6d 100644
--- a/core/clear_vars.mk
+++ b/core/clear_vars.mk
@@ -105,10 +105,12 @@
 LOCAL_PROGUARD_ENABLED:= # '',full,custom,nosystem,disabled,obfuscation,optimization
 LOCAL_PROGUARD_FLAGS:=
 LOCAL_PROGUARD_FLAG_FILES:=
+LOCAL_TEST_MODULE_TO_PROGUARD_WITH:=
 LOCAL_EMMA_COVERAGE_FILTER:=
 LOCAL_WARNINGS_ENABLE:=
 LOCAL_FULL_MANIFEST_FILE:=
 LOCAL_MANIFEST_FILE:=
+LOCAL_FULL_LIBS_MANIFEST_FILES:=
 LOCAL_RENDERSCRIPT_INCLUDES:=
 LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE:=
 LOCAL_RENDERSCRIPT_CC:=
diff --git a/core/config.mk b/core/config.mk
index ee47772..08cd818 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -341,6 +341,9 @@
 FINDBUGS := prebuilt/common/findbugs/bin/findbugs
 EMMA_JAR := external/emma/lib/emma$(COMMON_JAVA_PACKAGE_SUFFIX)
 
+# Tool to merge AndroidManifest.xmls
+ANDROID_MANIFEST_MERGER := java -classpath prebuilts/devtools/tools/lib/manifest-merger.jar com.android.manifmerger.Main merge
+
 YACC_HEADER_SUFFIX:= .hpp
 
 # Don't use column under Windows, cygwin or not
diff --git a/core/definitions.mk b/core/definitions.mk
index 7c29e30..9774a68 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -1929,7 +1929,8 @@
 ###########################################################
 define transform-jar-to-proguard
 @echo Proguard: $@
-$(hide) $(PROGUARD) -injars $< -outjars $@ $(PRIVATE_PROGUARD_FLAGS)
+$(hide) $(PROGUARD) -injars $< -outjars $@ $(PRIVATE_PROGUARD_FLAGS) \
+    $(addprefix -injars , $(PRIVATE_EXTRA_INPUT_JAR))
 endef
 
 ###########################################################
diff --git a/core/java.mk b/core/java.mk
index 95ec8f5..8863ac2 100644
--- a/core/java.mk
+++ b/core/java.mk
@@ -435,8 +435,14 @@
 proguard_flag_files := $(addprefix $(LOCAL_PATH)/, $(LOCAL_PROGUARD_FLAG_FILES))
 LOCAL_PROGUARD_FLAGS += $(addprefix -include , $(proguard_flag_files))
 
+ifdef LOCAL_TEST_MODULE_TO_PROGUARD_WITH
+extra_input_jar := $(call intermediates-dir-for,APPS,$(LOCAL_TEST_MODULE_TO_PROGUARD_WITH),,COMMON)/classes.jar
+else
+extra_input_jar :=
+endif
+$(full_classes_proguard_jar): PRIVATE_EXTRA_INPUT_JAR := $(extra_input_jar)
 $(full_classes_proguard_jar): PRIVATE_PROGUARD_FLAGS := $(proguard_flags) $(LOCAL_PROGUARD_FLAGS)
-$(full_classes_proguard_jar) : $(full_classes_jar) $(proguard_flag_files) | $(ACP) $(PROGUARD)
+$(full_classes_proguard_jar) : $(full_classes_jar) $(extra_input_jar) $(proguard_flag_files) | $(ACP) $(PROGUARD)
 	$(call transform-jar-to-proguard)
 
 else  # LOCAL_PROGUARD_ENABLED not defined
diff --git a/core/package.mk b/core/package.mk
index 53192b4..1cdb2fd 100644
--- a/core/package.mk
+++ b/core/package.mk
@@ -58,16 +58,6 @@
 endif
 LOCAL_MODULE := $(LOCAL_PACKAGE_NAME)
 
-ifeq ($(strip $(LOCAL_MANIFEST_FILE)),)
-LOCAL_MANIFEST_FILE := AndroidManifest.xml
-endif
-
-# If you need to put the MANIFEST_FILE outside of LOCAL_PATH
-# you can use FULL_MANIFEST_FILE
-ifeq ($(strip $(LOCAL_FULL_MANIFEST_FILE)),)
-LOCAL_FULL_MANIFEST_FILE := $(LOCAL_PATH)/$(LOCAL_MANIFEST_FILE)
-endif
-
 ifneq ($(strip $(LOCAL_MODULE_CLASS)),)
 $(error $(LOCAL_PATH): Package modules may not set LOCAL_MODULE_CLASS)
 endif
@@ -100,8 +90,14 @@
 
 LOCAL_RESOURCE_DIR := $(package_resource_overlays) $(LOCAL_RESOURCE_DIR)
 
-all_assets := $(call find-subdir-assets,$(LOCAL_ASSET_DIR))
-all_assets := $(addprefix $(LOCAL_ASSET_DIR)/,$(patsubst assets/%,%,$(all_assets)))
+all_assets := $(strip \
+    $(foreach dir, $(LOCAL_ASSET_DIR), \
+      $(addprefix $(dir)/, \
+        $(patsubst assets/%,%, \
+          $(call find-subdir-assets, $(dir)) \
+         ) \
+       ) \
+     ))
 
 all_resources := $(strip \
     $(foreach dir, $(LOCAL_RESOURCE_DIR), \
@@ -191,7 +187,8 @@
   LOCAL_SDK_RES_VERSION:=$(LOCAL_SDK_VERSION)
 endif
 
-full_android_manifest := $(LOCAL_FULL_MANIFEST_FILE)
+include $(BUILD_SYSTEM)/android_manifest.mk
+
 $(LOCAL_INTERMEDIATE_TARGETS): \
     PRIVATE_ANDROID_MANIFEST := $(full_android_manifest)
 ifneq (,$(filter-out current, $(LOCAL_SDK_VERSION)))
diff --git a/core/pdk_config.mk b/core/pdk_config.mk
index a7e21e0..b0cccc9 100644
--- a/core/pdk_config.mk
+++ b/core/pdk_config.mk
@@ -57,7 +57,9 @@
 	target/common/obj/JAVA_LIBRARIES/telephony-common_intermediates \
 	target/common/obj/JAVA_LIBRARIES/voip-common_intermediates \
 	target/common/obj/JAVA_LIBRARIES/mms-common_intermediates \
-	target/common/obj/JAVA_LIBRARIES/android-ex-camera2_intermediates
+	target/common/obj/JAVA_LIBRARIES/android-ex-camera2_intermediates \
+	target/common/obj/JAVA_LIBRARIES/android-common_intermediates \
+
 # not java libraries
 PDK_PLATFORM_JAVA_ZIP_CONTENTS += \
 	target/common/obj/APPS/framework-res_intermediates/package-export.apk \
diff --git a/core/static_java_library.mk b/core/static_java_library.mk
index f95a382..f31ccd8 100644
--- a/core/static_java_library.mk
+++ b/core/static_java_library.mk
@@ -66,14 +66,7 @@
 ifneq (,$(all_resources))
 R_file_stamp := $(LOCAL_INTERMEDIATE_SOURCE_DIR)/R.stamp
 
-ifeq ($(strip $(LOCAL_MANIFEST_FILE)),)
-  LOCAL_MANIFEST_FILE := AndroidManifest.xml
-endif
-ifdef LOCAL_FULL_MANIFEST_FILE
-  full_android_manifest := $(LOCAL_FULL_MANIFEST_FILE)
-else
-  full_android_manifest := $(LOCAL_PATH)/$(LOCAL_MANIFEST_FILE)
-endif
+include $(BUILD_SYSTEM)/android_manifest.mk
 
 LOCAL_SDK_RES_VERSION:=$(strip $(LOCAL_SDK_RES_VERSION))
 ifeq ($(LOCAL_SDK_RES_VERSION),)
diff --git a/core/version_defaults.mk b/core/version_defaults.mk
index 99283b0..4929abb 100644
--- a/core/version_defaults.mk
+++ b/core/version_defaults.mk
@@ -41,7 +41,7 @@
   # which is the version that we reveal to the end user.
   # Update this value when the platform version changes (rather
   # than overriding it somewhere else).  Can be an arbitrary string.
-  PLATFORM_VERSION := 4.4.2
+  PLATFORM_VERSION := KKWT
 endif
 
 ifeq "" "$(PLATFORM_SDK_VERSION)"
@@ -59,7 +59,7 @@
 ifeq "" "$(PLATFORM_VERSION_CODENAME)"
   # This is the current development code-name, if the build is not a final
   # release build.  If this is a final release build, it is simply "REL".
-  PLATFORM_VERSION_CODENAME := REL
+  PLATFORM_VERSION_CODENAME := KKWT
 endif
 
 ifeq "" "$(DEFAULT_APP_TARGET_SDK)"
diff --git a/target/product/core_minimal.mk b/target/product/core_minimal.mk
index 79ba0d4..21a6e8b 100644
--- a/target/product/core_minimal.mk
+++ b/target/product/core_minimal.mk
@@ -72,7 +72,7 @@
     apache-xml \
     webviewchromium
 
-PRODUCT_RUNTIMES := runtime_libart_default
-PRODUCT_RUNTIMES += runtime_libdvm
+PRODUCT_RUNTIMES := runtime_libdvm_default
+PRODUCT_RUNTIMES += runtime_libart
 
 $(call inherit-product, $(SRC_TARGET_DIR)/product/base.mk)
diff --git a/target/product/core_tiny.mk b/target/product/core_tiny.mk
index f19fd88..02140af 100644
--- a/target/product/core_tiny.mk
+++ b/target/product/core_tiny.mk
@@ -91,8 +91,6 @@
 PRODUCT_PROPERTY_OVERRIDES += \
     ro.carrier=unknown
 
-MINIMAL_FONT_FOOTPRINT := true
-
 $(call inherit-product-if-exists, frameworks/base/data/fonts/fonts.mk)
 
 # Overrides
diff --git a/target/product/embedded.mk b/target/product/embedded.mk
index 97a50a1..b0a5396 100644
--- a/target/product/embedded.mk
+++ b/target/product/embedded.mk
@@ -20,6 +20,7 @@
 PRODUCT_PACKAGES += \
     adb \
     adbd \
+    atrace \
     bootanimation \
     debuggerd \
     dumpstate \
diff --git a/tools/droiddoc/templates-sdk/assets/css/default.css b/tools/droiddoc/templates-sdk/assets/css/default.css
index 69418df..7515360 100644
--- a/tools/droiddoc/templates-sdk/assets/css/default.css
+++ b/tools/droiddoc/templates-sdk/assets/css/default.css
@@ -1900,6 +1900,7 @@
 .sidebox h5 {
   font-weight:bold;
   margin:0 0 10px;
+  line-height: 16px;
 }
 
 .sidebox * {