Merge "fix timestamps in images to the build date"
diff --git a/CleanSpec.mk b/CleanSpec.mk
index 2908cff..9582513 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -214,6 +214,9 @@
 # 4.4.1
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
 
+# 4.4.2
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+
 # ************************************************
 # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
 # ************************************************
diff --git a/core/combo/javac.mk b/core/combo/javac.mk
index 74490fd..2aea3e1 100644
--- a/core/combo/javac.mk
+++ b/core/combo/javac.mk
@@ -8,10 +8,10 @@
 #   COMMON_JAVAC -- Java compiler command with common arguments
 #
 
-ifeq ($(EXPERIMENTAL_USE_JAVA7_OPENJDK),)
+ifeq ($(EXPERIMENTAL_USE_JAVA7),)
 common_flags := -target 1.5 -Xmaxerrs 9999999
 else
-common_flags := -Xmaxerrs 9999999
+common_flags := -source 1.7 -target 1.7 -Xmaxerrs 9999999
 endif
 
 
diff --git a/core/config.mk b/core/config.mk
index 198608b..f5e92f6 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -390,16 +390,20 @@
 OLD_FLEX := prebuilts/misc/$(HOST_PREBUILT_TAG)/flex/flex-2.5.4a$(HOST_EXECUTABLE_SUFFIX)
 
 ifeq ($(HOST_OS),darwin)
-# Mac OS' screwy version of java uses a non-standard directory layout
-# and doesn't even seem to have tools.jar.  On the other hand, javac seems
-# to be able to magically find the classes in there, wherever they are, so
-# leave this blank
+ifneq ($(EXPERIMENTAL_USE_JAVA7),)
+HOST_JDK_TOOLS_JAR:= $(shell $(BUILD_SYSTEM)/find-jdk-tools-jar.sh)
+else
+# Deliberately set to blank for Java 6 installations on MacOS. These
+# versions allegedly use a non-standard directory structure.
 HOST_JDK_TOOLS_JAR :=
+endif
 else
 HOST_JDK_TOOLS_JAR:= $(shell $(BUILD_SYSTEM)/find-jdk-tools-jar.sh)
+endif
+
+ifneq ($(HOST_JDK_TOOLS_JAR),)
 ifeq ($(wildcard $(HOST_JDK_TOOLS_JAR)),)
-$(error Error: could not find jdk tools.jar, please install JDK6, \
-    which you can download from java.sun.com)
+$(error Error: could not find jdk tools.jar, please install JDK6)
 endif
 endif
 
diff --git a/core/definitions.mk b/core/definitions.mk
index 81f744c..f61ed8b 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -342,6 +342,22 @@
 endef
 
 ###########################################################
+# Use utility find to find given files in the given subdirs.
+# This function uses $(1), instead of LOCAL_PATH as the base.
+# $(1): the base dir, relative to the root of the source tree.
+# $(2): the file name pattern to be passed to find as "-name".
+# $(3): a list of subdirs of the base dir.
+# Returns: a list of paths relative to the base dir.
+###########################################################
+
+define find-files-in-subdirs
+$(patsubst ./%,%, \
+  $(shell cd $(1) ; \
+          find -L $(3) -name $(2) -and -not -name ".*") \
+ )
+endef
+
+###########################################################
 ## Scan through each directory of $(1) looking for files
 ## that match $(2) using $(wildcard).  Useful for seeing if
 ## a given directory or one of its parents contains
diff --git a/core/droiddoc.mk b/core/droiddoc.mk
index fedf14a..605ec1d 100644
--- a/core/droiddoc.mk
+++ b/core/droiddoc.mk
@@ -227,6 +227,8 @@
 	@mkdir -p $(dir $@)
 	$(hide) ( F=$$(pwd)/$@ ; cd $(PRIVATE_DOCS_DIR) && zip -rq $$F * )
 
+$(LOCAL_MODULE)-docs.zip : $(out_zip)
+
 $(call dist-for-goals,docs,$(out_zip))
 
 endif
diff --git a/core/main.mk b/core/main.mk
index f07a7fb..8b6f444 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -138,11 +138,22 @@
 $(error Directory names containing spaces not supported)
 endif
 
+# Check for the current JDK.
+#
+# For Java 1.7, we require OpenJDK on linux and Oracle JDK on Mac OS.
+# For Java 1.6, we require Oracle for all host OSes.
+requires_openjdk := false
+ifneq ($(EXPERIMENTAL_USE_JAVA7),)
+ifeq ($(HOST_OS), linux)
+requires_openjdk := true
+endif
+endif
+
 java_version_str := $(shell java -version 2>&1)
 javac_version_str := $(shell javac -version 2>&1)
 
 # Check for the current jdk
-ifneq ($(EXPERIMENTAL_USE_JAVA7_OPENJDK),)
+ifeq ($(requires_openjdk), true)
 # The user asked for java7 openjdk, so check that the host
 # java version is really openjdk
 ifeq ($(shell echo '$(java_version_str)' | grep -i openjdk),)
@@ -152,7 +163,7 @@
 $(info ************************************************************)
 $(error stop)
 endif # java version is not OpenJdk
-else # if EXPERIMENTAL_USE_JAVA7_OPENJDK
+else # if requires_openjdk
 ifneq ($(shell echo '$(java_version_str)' | grep -i openjdk),)
 $(info ************************************************************)
 $(info You are attempting to build with an unsupported JDK.)
@@ -163,21 +174,21 @@
 $(info ************************************************************)
 $(error stop)
 endif # java version is not Sun Oracle JDK
-endif # if EXPERIMENTAL_USE_JAVA7_OPENJDK
+endif # if requires_openjdk
 
 # Check for the correct version of java, should be 1.7 if
-# EXPERIMENTAL_USE_JAVA7_OPENJDK is set, 1.6 otherwise.
-ifneq ($(EXPERIMENTAL_USE_JAVA7_OPENJDK),)
-required_version := "OpenJDK 1.7"
+# EXPERIMENTAL_USE_JAVA7 is set, 1.6 otherwise.
+ifneq ($(EXPERIMENTAL_USE_JAVA7),)
+required_version := "1.7.x"
 required_javac_version := "1.7"
 java_version := $(shell echo '$(java_version_str)' | grep '^java .*[ "]1\.7[\. "$$]')
 javac_version := $(shell echo '$(javac_version_str)' | grep '[ "]1\.7[\. "$$]')
-else # if EXPERIMENTAL_USE_JAVA7_OPENJDK
-required_version := "JavaSE 1.6"
+else # if EXPERIMENTAL_USE_JAVA7
+required_version := "1.6.x"
 required_javac_version := "1.6"
 java_version := $(shell echo '$(java_version_str)' | grep '^java .*[ "]1\.6[\. "$$]')
 javac_version := $(shell echo '$(javac_version_str)' | head -n 1 | grep '[ "]1\.6[\. "$$]')
-endif # if EXPERIMENTAL_USE_JAVA7_OPENJDK
+endif # if EXPERIMENTAL_USE_JAVA7
 
 ifeq ($(strip $(java_version)),)
 $(info ************************************************************)
diff --git a/core/multi_prebuilt.mk b/core/multi_prebuilt.mk
index be60e2f..bc85cea 100644
--- a/core/multi_prebuilt.mk
+++ b/core/multi_prebuilt.mk
@@ -69,7 +69,11 @@
   $(if $(7), \
     $(eval LOCAL_BUILT_MODULE_STEM := $(7)) \
    , \
-    $(eval LOCAL_BUILT_MODULE_STEM := $(notdir $(LOCAL_SRC_FILES))) \
+    $(if $(word 2,$(tw)), \
+      $(eval LOCAL_BUILT_MODULE_STEM := $(LOCAL_MODULE)$(suffix $(LOCAL_SRC_FILES))) \
+     , \
+      $(eval LOCAL_BUILT_MODULE_STEM := $(notdir $(LOCAL_SRC_FILES))) \
+     ) \
    ) \
   $(eval LOCAL_MODULE_SUFFIX := $(suffix $(LOCAL_SRC_FILES))) \
   $(if $(filter user,$(TARGET_BUILD_VARIANT)), \
diff --git a/core/version_defaults.mk b/core/version_defaults.mk
index 9ed75c9..99283b0 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.1
+  PLATFORM_VERSION := 4.4.2
 endif
 
 ifeq "" "$(PLATFORM_SDK_VERSION)"
diff --git a/target/product/sdk.mk b/target/product/sdk.mk
index 75fdb0c..dab9fbd 100644
--- a/target/product/sdk.mk
+++ b/target/product/sdk.mk
@@ -23,6 +23,7 @@
 	CustomLocale \
 	Development \
 	DevelopmentSettings \
+	Dialer \
 	Fallback \
 	Gallery \
 	GestureBuilder \
diff --git a/tools/releasetools/build_image.py b/tools/releasetools/build_image.py
index 9f71194..a6127f8 100755
--- a/tools/releasetools/build_image.py
+++ b/tools/releasetools/build_image.py
@@ -130,12 +130,15 @@
     return False
   return True
 
-def UnsparseImage(sparse_image_path):
+def UnsparseImage(sparse_image_path, replace=True):
   img_dir = os.path.dirname(sparse_image_path)
   unsparse_image_path = "unsparse_" + os.path.basename(sparse_image_path)
   unsparse_image_path = os.path.join(img_dir, unsparse_image_path)
   if os.path.exists(unsparse_image_path):
-    return True, unsparse_image_path
+    if replace:
+      os.unlink(unsparse_image_path)
+    else:
+      return True, unsparse_image_path
   inflate_command = ["simg2img", sparse_image_path, unsparse_image_path]
   exit_code = RunCommand(inflate_command)
   if exit_code != 0:
@@ -257,7 +260,7 @@
       return False
 
   if run_fsck and prop_dict.get("skip_fsck") != "true":
-    success, unsparse_image = UnsparseImage(out_file)
+    success, unsparse_image = UnsparseImage(out_file, replace=False)
     if not success:
       return False