Reconcile with jb-mr1-factory-release jb-mr1-release - do not merge

Change-Id: I588ae4c43c605d0a5d9b6a61e90f868b2fd41ea7
diff --git a/core/Makefile b/core/Makefile
index e0f6da8..49a94c8 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -240,6 +240,12 @@
 
 # -----------------------------------------------------------------
 # Cert-to-package mapping.  Used by the post-build signing tools.
+# Use a macro to add newline to each echo command
+define _apkcerts_echo_with_newline
+$(hide) echo $(1)
+
+endef
+
 name := $(TARGET_PRODUCT)
 ifeq ($(TARGET_BUILD_TYPE),debug)
   name := $(name)_debug
@@ -254,13 +260,15 @@
 	@echo APK certs list: $@
 	@mkdir -p $(dir $@)
 	@rm -f $@
-	$(hide) $(foreach p,$(PACKAGES),\
-          $(if $(PACKAGES.$(p).EXTERNAL_KEY),\
-	    echo 'name="$(p).apk" certificate="EXTERNAL" \
-	         private_key=""' >> $@;,\
-	    echo 'name="$(p).apk" certificate="$(PACKAGES.$(p).CERTIFICATE)" \
-	         private_key="$(PACKAGES.$(p).PRIVATE_KEY)"' >> $@;))
-	# In case $(PACKAGES) is empty.
+	$(foreach p,$(PACKAGES),\
+	  $(if $(PACKAGES.$(p).EXTERNAL_KEY),\
+	    $(call _apkcerts_echo_with_newline,\
+	      'name="$(p).apk" certificate="EXTERNAL" \
+	      private_key=""' >> $@),\
+	    $(call _apkcerts_echo_with_newline,\
+	      'name="$(p).apk" certificate="$(PACKAGES.$(p).CERTIFICATE)" \
+	      private_key="$(PACKAGES.$(p).PRIVATE_KEY)"' >> $@)))
+	# In case value of PACKAGES is empty.
 	$(hide) touch $@
 
 .PHONY: apkcerts-list
@@ -571,14 +579,14 @@
 $(if $(BOARD_CACHEIMAGE_PARTITION_SIZE),$(hide) echo "cache_size=$(BOARD_CACHEIMAGE_PARTITION_SIZE)" >> $(1))
 $(if $(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG),$(hide) echo "extfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG)" >> $(1))
 $(if $(mkyaffs2_extra_flags),$(hide) echo "mkyaffs2_extra_flags=$(mkyaffs2_extra_flags)" >> $(1))
-$(if $(filter true, $(strip $(HAVE_SELINUX))), echo "selinux_fc=$(TARGET_ROOT_OUT)/file_contexts" >> $(1))
+$(hide) echo "selinux_fc=$(TARGET_ROOT_OUT)/file_contexts" >> $(1)
 endef
 
 # -----------------------------------------------------------------
 # Recovery image
 
 # If neither TARGET_NO_KERNEL nor TARGET_NO_RECOVERY are true
-ifeq (,$(filter true, $(TARGET_NO_KERNEL) $(TARGET_NO_RECOVERY) $(BUILD_TINY_ANDROID)))
+ifeq (,$(filter true, $(TARGET_NO_KERNEL) $(TARGET_NO_RECOVERY)))
 
 INSTALLED_RECOVERYIMAGE_TARGET := $(PRODUCT_OUT)/recovery.img
 
diff --git a/core/binary.mk b/core/binary.mk
index 791623b..57c85c2 100644
--- a/core/binary.mk
+++ b/core/binary.mk
@@ -119,7 +119,7 @@
 endif
 
 # Add in libcompiler-rt for all regular device builds
-ifeq (,$(LOCAL_SDK_VERSION)$(LOCAL_IS_HOST_MODULE)$(BUILD_TINY_ANDROID))
+ifeq (,$(LOCAL_SDK_VERSION)$(LOCAL_IS_HOST_MODULE)$(WITHOUT_LIBCOMPILER_RT))
   LOCAL_STATIC_LIBRARIES += $(COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES)
 endif
 
diff --git a/core/build_id.mk b/core/build_id.mk
index a007a1b..cfff307 100644
--- a/core/build_id.mk
+++ b/core/build_id.mk
@@ -1,4 +1,3 @@
-
 #
 # Copyright (C) 2008 The Android Open Source Project
 #
@@ -14,9 +13,20 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
+
+#
+# Defines branch-specific values.
+#
+
 # BUILD_ID is usually used to specify the branch name
 # (like "MAIN") or a branch name and a release candidate
-# (like "CRB01").  It must be a single word, and is
+# (like "TC1-RC5").  It must be a single word, and is
 # capitalized by convention.
+#
+BUILD_ID := JB_MR1
 
-export BUILD_ID=JVP15S
+# DISPLAY_BUILD_NUMBER should only be set for development branches,
+# If set, the BUILD_NUMBER (cl) is appended to the BUILD_ID for
+# a more descriptive BUILD_ID_DISPLAY, otherwise BUILD_ID_DISPLAY
+# is the same as BUILD_ID
+DISPLAY_BUILD_NUMBER := true
diff --git a/core/clear_vars.mk b/core/clear_vars.mk
index 5d55534..dd852a1 100644
--- a/core/clear_vars.mk
+++ b/core/clear_vars.mk
@@ -59,6 +59,7 @@
 LOCAL_INTERMEDIATE_SOURCE_DIR:=
 LOCAL_JAVACFLAGS:=
 LOCAL_JAVA_LIBRARIES:=
+LOCAL_JAVA_LAYERS_FILE:=
 LOCAL_NO_STANDARD_LIBRARIES:=
 LOCAL_CLASSPATH:=
 LOCAL_DROIDDOC_USE_STANDARD_DOCLET:=
diff --git a/core/combo/TARGET_linux-arm.mk b/core/combo/TARGET_linux-arm.mk
index 854037d..0122411 100644
--- a/core/combo/TARGET_linux-arm.mk
+++ b/core/combo/TARGET_linux-arm.mk
@@ -43,7 +43,7 @@
 
 # You can set TARGET_TOOLS_PREFIX to get gcc from somewhere else
 ifeq ($(strip $(TARGET_TOOLS_PREFIX)),)
-TARGET_TOOLCHAIN_ROOT := prebuilts/gcc/$(HOST_PREBUILT_TAG)/arm/arm-linux-androideabi-4.6
+TARGET_TOOLCHAIN_ROOT := prebuilts/gcc/$(HOST_PREBUILT_TAG)/arm/arm-linux-androideabi-$(TARGET_GCC_VERSION)
 TARGET_TOOLS_PREFIX := $(TARGET_TOOLCHAIN_ROOT)/bin/arm-linux-androideabi-
 endif
 
@@ -114,11 +114,11 @@
 TARGET_ANDROID_CONFIG_CFLAGS := -include $(android_config_h) -I $(dir $(android_config_h))
 TARGET_GLOBAL_CFLAGS += $(TARGET_ANDROID_CONFIG_CFLAGS)
 
-# This warning causes dalvik not to build with gcc 4.6.x and -Werror.
+# This warning causes dalvik not to build with gcc 4.6+ and -Werror.
 # We cannot turn it off blindly since the option is not available
 # in gcc-4.4.x.  We also want to disable sincos optimization globally
 # by turning off the builtin sin function.
-ifneq ($(filter 4.6 4.6.%, $(shell $(TARGET_CC) --version)),)
+ifneq ($(filter 4.6 4.6.% 4.7 4.7.%, $(shell $(TARGET_CC) --version)),)
 TARGET_GLOBAL_CFLAGS += -Wno-unused-but-set-variable -fno-builtin-sin \
 			-fno-strict-volatile-bitfields
 endif
diff --git a/core/combo/TARGET_linux-mips.mk b/core/combo/TARGET_linux-mips.mk
index 7c7a9ef..da1f360 100644
--- a/core/combo/TARGET_linux-mips.mk
+++ b/core/combo/TARGET_linux-mips.mk
@@ -43,7 +43,7 @@
 
 # You can set TARGET_TOOLS_PREFIX to get gcc from somewhere else
 ifeq ($(strip $(TARGET_TOOLS_PREFIX)),)
-TARGET_TOOLCHAIN_ROOT := prebuilts/gcc/$(HOST_PREBUILT_TAG)/mips/mipsel-linux-android-4.6
+TARGET_TOOLCHAIN_ROOT := prebuilts/gcc/$(HOST_PREBUILT_TAG)/mips/mipsel-linux-android-$(TARGET_GCC_VERSION)
 TARGET_TOOLS_PREFIX := $(TARGET_TOOLCHAIN_ROOT)/bin/mipsel-linux-android-
 endif
 
@@ -81,7 +81,7 @@
 TARGET_GLOBAL_CFLAGS += \
 			$(TARGET_mips_CFLAGS) \
 			-Ulinux -U__unix -U__unix__ -Umips \
-			-fpic \
+			-fpic -fPIE\
 			-ffunction-sections \
 			-fdata-sections \
 			-funwind-tables \
@@ -92,10 +92,10 @@
 TARGET_ANDROID_CONFIG_CFLAGS := -include $(android_config_h) -I $(dir $(android_config_h))
 TARGET_GLOBAL_CFLAGS += $(TARGET_ANDROID_CONFIG_CFLAGS)
 
-# This warning causes dalvik not to build with gcc 4.6.x and -Werror.
+# This warning causes dalvik not to build with gcc 4.6+ and -Werror.
 # We cannot turn it off blindly since the option is not available
 # in gcc-4.4.x.
-ifneq ($(filter 4.6 4.6.%, $(shell $(TARGET_CC) --version)),)
+ifneq ($(filter 4.6 4.6.% 4.7 4.7.%, $(shell $(TARGET_CC) --version)),)
 TARGET_GLOBAL_CFLAGS += -Wno-unused-but-set-variable \
                         -fno-strict-volatile-bitfields
 endif
@@ -243,7 +243,7 @@
 endef
 
 define transform-o-to-executable-inner
-$(hide) $(PRIVATE_CXX) -nostdlib -Bdynamic \
+$(hide) $(PRIVATE_CXX) -nostdlib -Bdynamic -fPIE -pie \
 	-Wl,-dynamic-linker,/system/bin/linker \
 	-Wl,--gc-sections \
 	-Wl,-z,nocopyreloc \
diff --git a/core/combo/TARGET_linux-x86.mk b/core/combo/TARGET_linux-x86.mk
index 0e7c17d..569914b 100644
--- a/core/combo/TARGET_linux-x86.mk
+++ b/core/combo/TARGET_linux-x86.mk
@@ -36,7 +36,7 @@
 
 # You can set TARGET_TOOLS_PREFIX to get gcc from somewhere else
 ifeq ($(strip $(TARGET_TOOLS_PREFIX)),)
-TARGET_TOOLCHAIN_ROOT := prebuilts/gcc/$(HOST_PREBUILT_TAG)/x86/i686-linux-android-4.6
+TARGET_TOOLCHAIN_ROOT := prebuilts/gcc/$(HOST_PREBUILT_TAG)/x86/i686-linux-android-$(TARGET_GCC_VERSION)
 TARGET_TOOLS_PREFIX := $(TARGET_TOOLCHAIN_ROOT)/bin/i686-linux-android-
 endif
 
@@ -144,6 +144,7 @@
 
 TARGET_GLOBAL_LDFLAGS += -Wl,-z,noexecstack
 TARGET_GLOBAL_LDFLAGS += -Wl,-z,relro -Wl,-z,now
+TARGET_GLOBAL_LDFLAGS += -Wl,--warn-shared-textrel
 TARGET_GLOBAL_LDFLAGS += -Wl,--gc-sections
 
 TARGET_C_INCLUDES := \
diff --git a/core/config.mk b/core/config.mk
index 747d8ed..1af5a2a 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -225,6 +225,11 @@
 endif
 TARGET_CPU_ABI2 := $(strip $(TARGET_CPU_ABI2))
 
+# default target GCC version
+ifeq ($(strip $(TARGET_GCC_VERSION)),)
+TARGET_GCC_VERSION := 4.6
+endif
+
 # $(1): os/arch
 define select-android-config-h
 build/core/combo/include/arch/$(1)/AndroidConfig.h
diff --git a/core/definitions.mk b/core/definitions.mk
index 06db960..a524b2f 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -178,7 +178,7 @@
 define all-java-files-under
 $(patsubst ./%,%, \
   $(shell cd $(LOCAL_PATH) ; \
-          find $(1) -name "*.java" -and -not -name ".*") \
+          find -L $(1) -name "*.java" -and -not -name ".*") \
  )
 endef
 
@@ -200,7 +200,7 @@
 define all-c-files-under
 $(patsubst ./%,%, \
   $(shell cd $(LOCAL_PATH) ; \
-          find $(1) -name "*.c" -and -not -name ".*") \
+          find -L $(1) -name "*.c" -and -not -name ".*") \
  )
 endef
 
@@ -222,7 +222,7 @@
 define all-Iaidl-files-under
 $(patsubst ./%,%, \
   $(shell cd $(LOCAL_PATH) ; \
-          find $(1) -name "I*.aidl" -and -not -name ".*") \
+          find -L $(1) -name "I*.aidl" -and -not -name ".*") \
  )
 endef
 
@@ -243,7 +243,7 @@
 define all-logtags-files-under
 $(patsubst ./%,%, \
   $(shell cd $(LOCAL_PATH) ; \
-          find $(1) -name "*.logtags" -and -not -name ".*") \
+          find -L $(1) -name "*.logtags" -and -not -name ".*") \
   )
 endef
 
@@ -256,7 +256,7 @@
 define all-proto-files-under
 $(patsubst ./%,%, \
   $(shell cd $(LOCAL_PATH) ; \
-          find $(1) -name "*.proto" -and -not -name ".*") \
+          find -L $(1) -name "*.proto" -and -not -name ".*") \
   )
 endef
 
@@ -269,7 +269,7 @@
 define all-renderscript-files-under
 $(patsubst ./%,%, \
   $(shell cd $(LOCAL_PATH) ; \
-          find $(1) \( -name "*.rs" -or -name "*.fs" \) -and -not -name ".*") \
+          find -L $(1) \( -name "*.rs" -or -name "*.fs" \) -and -not -name ".*") \
   )
 endef
 
@@ -282,7 +282,7 @@
 define all-html-files-under
 $(patsubst ./%,%, \
   $(shell cd $(LOCAL_PATH) ; \
-          find $(1) -name "*.html" -and -not -name ".*") \
+          find -L $(1) -name "*.html" -and -not -name ".*") \
  )
 endef
 
@@ -301,7 +301,7 @@
 ###########################################################
 
 define find-subdir-files
-$(patsubst ./%,%,$(shell cd $(LOCAL_PATH) ; find $(1)))
+$(patsubst ./%,%,$(shell cd $(LOCAL_PATH) ; find -L $(1)))
 endef
 
 ###########################################################
@@ -314,7 +314,7 @@
 
 define find-subdir-subdir-files
 $(filter-out $(patsubst %,$(1)/%,$(3)),$(patsubst ./%,%,$(shell cd \
-            $(LOCAL_PATH) ; find $(1) -maxdepth 1 -name $(2))))
+            $(LOCAL_PATH) ; find -L $(1) -maxdepth 1 -name $(2))))
 endef
 
 ###########################################################
@@ -1475,6 +1475,8 @@
     \@$(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list-uniq \
     || ( rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR) ; exit 41 ) \
 fi
+$(if $(PRIVATE_JAVA_LAYERS_FILE), $(hide) build/tools/java-layers.py \
+    $(PRIVATE_JAVA_LAYERS_FILE) \@$(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list-uniq,)
 $(hide) rm -f $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list
 $(hide) rm -f $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list-uniq
 $(if $(PRIVATE_JAR_EXCLUDE_FILES), $(hide) find $(PRIVATE_CLASS_INTERMEDIATES_DIR) \
diff --git a/core/dumpvar.mk b/core/dumpvar.mk
index 5298f35..c47aa0f 100644
--- a/core/dumpvar.mk
+++ b/core/dumpvar.mk
@@ -11,23 +11,23 @@
 
 # Add the ARM toolchain bin dir if it actually exists
 ifeq ($(TARGET_ARCH),arm)
-    ifneq ($(wildcard $(PWD)/prebuilts/gcc/$(HOST_PREBUILT_TAG)/arm/arm-linux-androideabi-4.6/bin),)
+    ifneq ($(wildcard $(PWD)/prebuilts/gcc/$(HOST_PREBUILT_TAG)/arm/arm-linux-androideabi-$(TARGET_GCC_VERSION)/bin),)
         # this should be copied to HOST_OUT_EXECUTABLES instead
-        ABP:=$(ABP):$(PWD)/prebuilts/gcc/$(HOST_PREBUILT_TAG)/arm/arm-linux-androideabi-4.6/bin
+        ABP:=$(ABP):$(PWD)/prebuilts/gcc/$(HOST_PREBUILT_TAG)/arm/arm-linux-androideabi-$(TARGET_GCC_VERSION)/bin
     endif
 else ifeq ($(TARGET_ARCH),x86)
 
 # Add the x86 toolchain bin dir if it actually exists
-    ifneq ($(wildcard $(PWD)/prebuilts/gcc/$(HOST_PREBUILT_TAG)/x86/i686-linux-android-4.6/bin),)
+    ifneq ($(wildcard $(PWD)/prebuilts/gcc/$(HOST_PREBUILT_TAG)/x86/i686-linux-android-$(TARGET_GCC_VERSION)/bin),)
         # this should be copied to HOST_OUT_EXECUTABLES instead
-        ABP:=$(ABP):$(PWD)/prebuilts/gcc/$(HOST_PREBUILT_TAG)/x86/i686-linux-android-4.6/bin
+        ABP:=$(ABP):$(PWD)/prebuilts/gcc/$(HOST_PREBUILT_TAG)/x86/i686-linux-android-$(TARGET_GCC_VERSION)/bin
     endif
 endif
 
 # Add the mips toolchain bin dir if it actually exists
-ifneq ($(wildcard $(PWD)/prebuilts/gcc/$(HOST_PREBUILT_TAG)/mips/mipsel-linux-android-4.6/bin),)
+ifneq ($(wildcard $(PWD)/prebuilts/gcc/$(HOST_PREBUILT_TAG)/mips/mipsel-linux-android-$(TARGET_GCC_VERSION)/bin),)
     # this should be copied to HOST_OUT_EXECUTABLES instead
-    ABP:=$(ABP):$(PWD)/prebuilts/gcc/$(HOST_PREBUILT_TAG)/mips/mipsel-linux-android-4.6/bin
+    ABP:=$(ABP):$(PWD)/prebuilts/gcc/$(HOST_PREBUILT_TAG)/mips/mipsel-linux-android-$(TARGET_GCC_VERSION)/bin
 endif
 
 ANDROID_BUILD_PATHS := $(ABP)
diff --git a/core/host_java_library.mk b/core/host_java_library.mk
index 5930da6..c938d57 100644
--- a/core/host_java_library.mk
+++ b/core/host_java_library.mk
@@ -43,6 +43,10 @@
 
 include $(BUILD_SYSTEM)/base_rules.mk
 
+# The layers file allows you to enforce a layering between java packages.
+# Run build/tools/java-layers.py for more details.
+layers_file := $(addprefix $(LOCAL_PATH)/, $(LOCAL_JAVA_LAYERS_FILE))
+
 ifeq ($(LOCAL_BUILD_HOST_DEX),true)
 $(LOCAL_INTERMEDIATE_TARGETS): \
 	PRIVATE_CLASS_INTERMEDIATES_DIR := $(intermediates.COMMON)/classes
@@ -51,9 +55,11 @@
 
 $(cleantarget): PRIVATE_CLEAN_FILES += $(intermediates.COMMON)
 
+$(full_classes_compiled_jar): PRIVATE_JAVA_LAYERS_FILE := $(layers_file)
 $(full_classes_compiled_jar): PRIVATE_JAVACFLAGS := $(LOCAL_JAVACFLAGS)
 $(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_FILES :=
-$(full_classes_compiled_jar): $(java_sources) $(java_resource_sources) $(full_java_lib_deps) $(jar_manifest_file)
+$(full_classes_compiled_jar): $(java_sources) $(java_resource_sources) $(full_java_lib_deps) \
+        $(jar_manifest_file) $(LOCAL_ADDITIONAL_DEPENDENCIES)
 	$(transform-host-java-to-package)
 
 # Run jarjar if necessary, otherwise just copy the file.
@@ -90,6 +96,8 @@
 else
 $(LOCAL_BUILT_MODULE): PRIVATE_JAVACFLAGS := $(LOCAL_JAVACFLAGS)
 $(LOCAL_BUILT_MODULE): PRIVATE_JAR_EXCLUDE_FILES :=
-$(LOCAL_BUILT_MODULE): $(java_sources) $(java_resource_sources) $(full_java_lib_deps) $(jar_manifest_file)
+$(LOCAL_BUILT_MODULE): PRIVATE_JAVA_LAYERS_FILE := $(layers_file)
+$(LOCAL_BUILT_MODULE): $(java_sources) $(java_resource_sources) $(full_java_lib_deps) \
+		$(jar_manifest_file) $(LOCAL_ADDITIONAL_DEPENDENCIES)
 	$(transform-host-java-to-package)
 endif  # LOCAL_BUILD_HOST_DEX
diff --git a/core/java.mk b/core/java.mk
index 99e67f4..65c9be9 100644
--- a/core/java.mk
+++ b/core/java.mk
@@ -254,6 +254,11 @@
 	$(hide) $(ACP) -fp $(PRIVATE_SOURCE_FILE) $@
 ALL_MODULES.$(LOCAL_MODULE).STUBS := $(full_classes_stubs_jar)
 
+# The layers file allows you to enforce a layering between java packages.
+# Run build/tools/java-layers.py for more details.
+layers_file := $(addprefix $(LOCAL_PATH)/, $(LOCAL_JAVA_LAYERS_FILE))
+$(full_classes_compiled_jar): PRIVATE_JAVA_LAYERS_FILE := $(layers_file)
+
 # Compile the java files to a .jar file.
 # This intentionally depends on java_sources, not all_java_sources.
 # Deps for generated source files must be handled separately,
@@ -261,8 +266,9 @@
 $(full_classes_compiled_jar): PRIVATE_JAVACFLAGS := $(LOCAL_JAVACFLAGS)
 $(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_FILES := $(LOCAL_JAR_EXCLUDE_FILES)
 $(full_classes_compiled_jar): PRIVATE_DONT_DELETE_JAR_META_INF := $(LOCAL_DONT_DELETE_JAR_META_INF)
-$(full_classes_compiled_jar): $(java_sources) $(java_resource_sources) $(full_java_lib_deps) $(jar_manifest_file) \
-	$(RenderScript_file_stamp) $(proto_java_sources_file_stamp)
+$(full_classes_compiled_jar): $(java_sources) $(java_resource_sources) $(full_java_lib_deps) \
+        $(jar_manifest_file) $(layers_file) $(RenderScript_file_stamp) \
+        $(proto_java_sources_file_stamp) $(LOCAL_ADDITIONAL_DEPENDENCIES)
 	$(transform-java-to-classes.jar)
 
 # All of the rules after full_classes_compiled_jar are very unlikely
diff --git a/core/main.mk b/core/main.mk
index 87488f4..e2adb00 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -275,11 +275,6 @@
 is_sdk_build := true
 endif
 
-## have selinux ##
-ifeq ($(HAVE_SELINUX),true)
-ADDITIONAL_BUILD_PROPERTIES += ro.build.selinux=1
-endif # HAVE_SELINUX
-
 ## user/userdebug ##
 
 user_variant := $(filter user userdebug,$(TARGET_BUILD_VARIANT))
@@ -453,25 +448,6 @@
 endif
 
 else	# !SDK_ONLY
-ifeq ($(BUILD_TINY_ANDROID), true)
-
-# TINY_ANDROID is a super-minimal build configuration, handy for board
-# bringup and very low level debugging
-
-subdirs := \
-	bionic \
-	system/core \
-	system/extras/ext4_utils \
-	system/extras/su \
-	build/libs \
-	build/target \
-	build/tools/acp \
-	external/gcc-demangle \
-	external/mksh \
-	external/openssl \
-	external/yaffs2 \
-	external/zlib
-else	# !BUILD_TINY_ANDROID
 #
 # Typical build; include any Android.mk files we can find.
 #
@@ -479,8 +455,6 @@
 
 FULL_BUILD := true
 
-endif	# !BUILD_TINY_ANDROID
-
 endif	# !SDK_ONLY
 
 # Before we go and include all of the module makefiles, stash away
@@ -738,7 +712,6 @@
 .PHONY: files
 files: prebuilt \
         $(modules_to_install) \
-        $(modules_to_check) \
         $(INSTALLED_ANDROID_INFO_TXT_TARGET)
 
 # -------------------------------------------------------------------
@@ -777,10 +750,6 @@
 .PHONY: bootimage
 bootimage: $(INSTALLED_BOOTIMAGE_TARGET)
 
-ifeq ($(BUILD_TINY_ANDROID), true)
-INSTALLED_RECOVERYIMAGE_TARGET :=
-endif
-
 # Build files and then package it into the rom formats
 .PHONY: droidcore
 droidcore: files \
diff --git a/core/product_config.mk b/core/product_config.mk
index 75df954..e05907d 100644
--- a/core/product_config.mk
+++ b/core/product_config.mk
@@ -220,7 +220,7 @@
 else
 # Import just the current product.
 ifndef current_product_makefile
-$(error Cannot locate config makefile for product "$(TARGET_PRODUCT)")
+$(error Can not locate config makefile for product "$(TARGET_PRODUCT)")
 endif
 ifneq (1,$(words $(current_product_makefile)))
 $(error Product "$(TARGET_PRODUCT)" ambiguous: matches $(current_product_makefile))
diff --git a/core/tasks/apicheck.mk b/core/tasks/apicheck.mk
index 8d9928e..63fd4d4 100644
--- a/core/tasks/apicheck.mk
+++ b/core/tasks/apicheck.mk
@@ -17,8 +17,8 @@
 # api compatibility or added apis illegally.
 #
 
-# skip api check for TINY_ANDROID and PDK buid
-ifeq (,$(filter true, $(BUILD_TINY_ANDROID) $(TARGET_BUILD_PDK)))
+# skip api check for PDK buid
+ifeq (,$(filter true, $(WITHOUT_CHECK_API) $(TARGET_BUILD_PDK)))
 
 .PHONY: checkapi
 
diff --git a/target/product/base.mk b/target/product/base.mk
index 9d8ef3f..68fed42 100644
--- a/target/product/base.mk
+++ b/target/product/base.mk
@@ -18,74 +18,46 @@
 PRODUCT_PACKAGES += \
     20-dns.conf \
     95-configured \
-    adb \
-    adbd \
     am \
     android.policy \
     android.test.runner \
     app_process \
     applypatch \
     bmgr \
-    bootanimation \
     bugreport \
     content \
     dbus-daemon \
-    debuggerd \
     dhcpcd \
     dhcpcd-run-hooks \
     dnsmasq \
-    dumpstate \
-    dumpsys \
     framework \
     fsck_msdos \
-    gralloc.default \
-    gzip \
     ime \
-    init \
-    input \
     javax.obex \
-    libEGL \
-    libETC1 \
-    libFFTEm \
-    libGLES_android \
-    libGLESv1_CM \
-    libGLESv2 \
     libSR_AudioIn \
     libandroid \
     libandroid_runtime \
     libandroid_servers \
     libaudioeffect_jni \
     libaudioflinger \
-    libbinder \
     libbundlewrapper \
-    libc \
     libcamera_client \
     libcameraservice \
     libchromium_net \
-    libctest \
-    libcutils \
     libdbus \
     libdl \
     libdrm1 \
     libdrm1_jni \
     libeffects \
-    libgui \
-    libhardware \
-    libhardware_legacy \
     libiprouteutil \
     libjni_latinime \
     libjnigraphics \
-    libjpeg \
-    liblog \
-    libm \
     libmedia \
     libmedia_jni \
     libmediaplayerservice \
     libmtp \
     libnetlink \
     libnetutils \
-    libpixelflinger \
-    libpower \
     libreference-ril \
     libreverbwrapper \
     libril \
@@ -102,24 +74,13 @@
     libstagefright_foundation \
     libstagefright_omx \
     libstagefright_yuv \
-    libstdc++ \
-    libstlport \
-    libsurfaceflinger \
-    libsurfaceflinger_client \
-    libsurfaceflinger_ddmconnection \
     libsystem_server \
-    libsysutils \
-    libthread_db \
-    libui \
     libusbhost \
     libutils \
     libvisualizer \
     libvorbisidec \
     libwebcore \
     libwpa_client \
-    linker \
-    logcat \
-    logwrapper \
     mediaserver \
     monkey \
     mtpd \
@@ -135,15 +96,13 @@
     schedtest \
     screenshot \
     sdcard \
-    service \
-    servicemanager \
     services \
     settings \
-    surfaceflinger \
     svc \
     system_server \
     tc \
-    toolbox \
     vdc \
     vold
 
+$(call inherit-product, $(SRC_TARGET_DIR)/product/embedded.mk)
+
diff --git a/target/product/core.mk b/target/product/core.mk
index 831298a..a7236f0 100644
--- a/target/product/core.mk
+++ b/target/product/core.mk
@@ -129,14 +129,15 @@
     lint \
     uiautomator \
     telephony-common \
-    mms-common \
-    zoneinfo.dat \
-    zoneinfo.idx \
-    zoneinfo.version
+    mms-common
 
-PRODUCT_COPY_FILES += \
-    system/core/rootdir/init.usb.rc:root/init.usb.rc \
-    system/core/rootdir/init.trace.rc:root/init.trace.rc \
+# SELinux packages
+PRODUCT_PACKAGES += \
+    sepolicy \
+    file_contexts \
+    seapp_contexts \
+    property_contexts \
+    mac_permissions.xml
 
 # host-only dependencies
 ifeq ($(WITH_HOST_DALVIK),true)
@@ -151,20 +152,7 @@
         libjavacore \
         libssl \
         libz-host \
-        dalvik \
-        zoneinfo-host.dat \
-        zoneinfo-host.idx \
-        zoneinfo-host.version
-endif
-
-ifeq ($(HAVE_SELINUX),true)
-    PRODUCT_PACKAGES += \
-        sepolicy \
-        file_contexts \
-        seapp_contexts \
-        property_contexts \
-        mac_permissions.xml
+        dalvik
 endif
 
 $(call inherit-product, $(SRC_TARGET_DIR)/product/base.mk)
-
diff --git a/target/product/embedded.mk b/target/product/embedded.mk
new file mode 100644
index 0000000..7f681b1
--- /dev/null
+++ b/target/product/embedded.mk
@@ -0,0 +1,77 @@
+#
+# Copyright (C) 2009 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 is a build configuration for a very minimal build of the
+# Open-Source part of the tree.
+
+PRODUCT_PACKAGES += \
+    adb \
+    adbd \
+    bootanimation \
+    debuggerd \
+    dumpstate \
+    dumpsys \
+    gralloc.default \
+    gzip \
+    init \
+    input \
+    libEGL \
+    libETC1 \
+    libFFTEm \
+    libGLES_android \
+    libGLESv1_CM \
+    libGLESv2 \
+    libbinder \
+    libc \
+    libctest \
+    libcutils \
+    libdl \
+    libgui \
+    libhardware \
+    libhardware_legacy \
+    libjpeg \
+    liblog \
+    libm \
+    libpixelflinger \
+    libpower \
+    libstdc++ \
+    libstlport \
+    libsurfaceflinger \
+    libsurfaceflinger_client \
+    libsurfaceflinger_ddmconnection \
+    libsysutils \
+    libthread_db \
+    libui \
+    libutils \
+    linker \
+    logcat \
+    logwrapper \
+    service \
+    servicemanager \
+    surfaceflinger \
+    toolbox
+
+# SELinux packages
+PRODUCT_PACKAGES += \
+    sepolicy \
+    file_contexts \
+    seapp_contexts \
+    property_contexts \
+    mac_permissions.xml
+
+PRODUCT_COPY_FILES += \
+    system/core/rootdir/init.usb.rc:root/init.usb.rc \
+    system/core/rootdir/init.trace.rc:root/init.trace.rc \
diff --git a/tools/droiddoc/templates-sdk/assets/css/default.css b/tools/droiddoc/templates-sdk/assets/css/default.css
index f3a014d..7678ddf 100644
--- a/tools/droiddoc/templates-sdk/assets/css/default.css
+++ b/tools/droiddoc/templates-sdk/assets/css/default.css
@@ -3854,10 +3854,6 @@
 .slideshow-develop .content-right {
   float: left;
 }
-.slideshow-develop .content-right p.title-intro {
-  position:absolute;
-  margin:0;
-}
 .slideshow-develop .content-right h2 {
   padding:0;
   margin-bottom:10px;
@@ -3873,6 +3869,16 @@
 .slideshow-develop .pagination ul li.active:hover {
   background-color: #F80;
 }
+.slideshow-develop .item hr {
+  margin:5px 0 10px;
+}
+.slideshow-develop .item p {
+  margin:10px 0;
+}
+.slideshow-develop .item p.title-intro {
+  position:absolute;
+  margin:0;
+}
 
 /* Feeds */
 .feed ul {
diff --git a/tools/droiddoc/templates-sdk/assets/css/less_source/home.css b/tools/droiddoc/templates-sdk/assets/css/less_source/home.css
deleted file mode 100644
index 19f9088..0000000
--- a/tools/droiddoc/templates-sdk/assets/css/less_source/home.css
+++ /dev/null
@@ -1,30 +0,0 @@
-.slideshow-home {
-  height: 500px;
-  width: 940px;
-  border-bottom: 1px solid #CCC;
-  position: relative;
-}
-.slideshow-home .frame {
-  width: 940px;
-  height: 500px;
-}
-.slideshow-home img {
-  max-width: 530px;
-  float: left;
-}
-.slideshow-home .content-right {
-  float: left;
-  margin-top: 80px;
-}
-.slideshow-home .item {
-  height: 500px;
-  width: 940px;
-}
-.home-sections ul li {
-  float: left;
-  display: block;
-  list-style: none;
-  width: 220px;
-  height: 35px;
-  border: 1px solid #F3F3F3;
-}
diff --git a/tools/droiddoc/templates-sdk/assets/css/less_source/home.less b/tools/droiddoc/templates-sdk/assets/css/less_source/home.less
deleted file mode 100644
index 0c7b8c5..0000000
--- a/tools/droiddoc/templates-sdk/assets/css/less_source/home.less
+++ /dev/null
@@ -1,70 +0,0 @@
-.slideshow-home {
-  height:500px;
-  width:940px;
-  border-bottom:1px solid #CCC;
-  position:relative;
-  margin: 0 10px 0 10px;
-  
-  .frame {
-   width:940px; 
-   height:500px;
-  }
-  .content-left {
-    float:left;
-    text-align:center;
-    vertical-align:center;
-    margin:0;
-  }
-  
-  .content-right {
-    float:left;
-    margin:70px 0 0 0;
-    
-    p {
-     margin-bottom:30px; 
-    }
-  }
-  
-  .item {
-  	height:500px;
-  	width:940px;
-  }
-    
-}
-
-.home-sections {
-  padding:40px 0 40px 0;
-  margin: 20px 10px;
-  ul {
-    margin:0;
-    li {
-     float:left;
-     display:block; 
-     list-style:none;
-     width:218px;
-     height:35px;
-     border:1px solid #DCDCDC;
-     background-color:#f3f3f3;
-     margin-right:20px;
-     
-     a {
-      font-weight:bold;
-      margin-left:20px;
-      margin-top:8px;
-      line-height:18px;
-      float:left;
-      color:#444;
-     }
-     
-     img {
-       float:left;
-       margin:-8px 0 0 10px;
-     }
-     
-   }
-   
-   li.last {
-       margin-right:0px; 
-    }
-  }
-}
\ No newline at end of file
diff --git a/tools/droiddoc/templates-sdk/assets/design/default.scss b/tools/droiddoc/templates-sdk/assets/design/default.scss
deleted file mode 100644
index d874ee5..0000000
--- a/tools/droiddoc/templates-sdk/assets/design/default.scss
+++ /dev/null
@@ -1,792 +0,0 @@
-/* color definitions */
-
-$text_color: #555;
-$text_color_dark: #333;
-$text_color_light: #777;
-$text_color_lighter: #999;
-
-$ics_blue: #33b5e5;
-$ics_blue_dark: #09c;
-$ics_blue_darkest: #069;
-$ics_blue_desaturated: #7aa1b0;
-
-$panel_background: rgba(0, 0, 0, 0.03);
-$panel_background_dark: rgba(0, 0, 0, 0.05);
-
-$light_shadow_color: rgba(0,0,0,0.25);
-$lighter_shadow_color: rgba(0,0,0,0.12);
-
-$tiny_text_size: 12px;
-$small_text_size: 14px;
-$large_text_size: 16px;
-$default_line_height: 20px;
-$tiny_line_height: 15px;
-
-$thinweight: 100;
-$normalweight: 400;
-$boldweight: 500;
-
-/* 16 column layout */
-
-$col_width: 40px;
-$gutter_width: 20px;
-
-@function gridwidth($n) {
-  @return $n * $col_width + ($n - 1) * $gutter_width;
-}
-
-/* clearfix idiom */
-
-@mixin clearfix {
-  display: inline-block;
-  &:after {
-    content: ".";
-    display: block;
-    height: 0;
-    clear: both;
-    visibility: hidden;
-  }
-  * html & { height: 1px }
-}
-
-/* common mixins */
-
-@mixin fontheight($font_size, $line_height) {
-  font-size: $font_size;
-  line-height: $line_height;
-}
-
-@mixin prefixed($property, $value) {
-  -webkit-#{$property}: $value;
-     -moz-#{$property}: $value;
-          #{$property}: $value;
-}
-
-/* page layout + top-level styles */
-
-::-webkit-selection,
-::-moz-selection,
-::selection {
-  background-color: $ics_blue_dark;
-  color: #fff;
-}
-
-html, body {
-  height: 100%;
-  margin: 0;
-  padding: 0;
-  background: #eee none no-repeat fixed top left;
-  background-image: -webkit-gradient(linear, 100% 0%, 100% 100%, from(#ddd), color-stop(25%, #f2f2f2), color-stop(75%, #f2f2f2), to(#ddd));
-  background-image: -moz-linear-gradient(top, #ddd, #f2f2f2, #f2f2f2, #ddd);
-  -webkit-font-smoothing: antialiased; /* prevent subpixel antialiasing, which thickens the text */
-  /* text-rendering: optimizeLegibility; */ /* turned off ligatures due to bug 5945455 */
-}
-
-body {
-  color: $text_color;
-  font: #{$small_text_size}/#{$default_line_height} Roboto,sans-serif;
-  font-weight: $normalweight;
-}
-
-#page-container {
-  width: gridwidth(16);
-  margin: 0 40px;
-}
-
-#page-header {
-  height: 80px;
-  margin-bottom: 20px;
-  @include fontheight(48px, 48px);
-  font-weight: $thinweight;
-  padding-left: $gutter_width / 2;
-  
-  a {
-    display: block;
-    position: relative;
-    top: 20px;
-    text-decoration :none;
-    color: $text_color !important;
-  }
-}
-
-#main-row {
-  @include clearfix;
-}
-
-#page-footer {
-  margin-left: gridwidth(3) + $gutter_width + 10;
-  margin-top: 80px;
-  color: $text_color_lighter;
-  padding-bottom: 40px;
-  @include fontheight($tiny_text_size, $tiny_line_height);
-
-  a {
-    color: $text_color_light;
-  }
-
-  #copyright {
-    margin-bottom: 10px;
-  }
-}
-
-#nav-container {
-  width: gridwidth(3);
-  min-height: 10px;
-  margin-right: $gutter_width;
-  float: left;
-}
-
-#nav {
-  width: gridwidth(3);
-}
-
-#nav.fixed {
-  position: fixed;
-  top: 40px;
-}
-
-#content {
-  width: gridwidth(13);
-  float: left;
-}
-
-a,
-a:visited {
-  color: $text_color_dark;
-}
-
-a:hover,
-acronym:hover {
-  color: $ics_blue_desaturated !important;
-}
-
-a:focus,
-a:active {
-  color: $ics_blue !important;
-}
-
-img {
-  border: none;
-}
-
-ul {
-  margin: 0;
-  padding: 0;
-}
-
-strong {
-  font-weight: $boldweight;
-}
-
-em {
-  font-style: italic;
-}
-
-code {
-  font-family: Courier New, monospace;
-}
-
-acronym {
-  border-bottom: 1px dotted $text_color;
-  cursor: help;
-}
-
-acronym:hover {
-  border-bottom-color: $ics_blue_desaturated;
-}
-
-img.with-shadow,
-video.with-shadow {
-  box-shadow: 0 2px 4px $light_shadow_color;
-}
-
-/* disclosures mixin */
-
-@mixin disclosure($type) {
-  content: '';
-  background: transparent url(disclosure_#{$type}.png) no-repeat scroll top left;
-  width: 10px;
-  height: 10px;
-}
-
-/* content layout */
-
-.layout-content-row {
-  @include clearfix;
-  margin-bottom: 10px;
-}
-
-.layout-content-col {
-  float: left;
-  margin-left: $gutter_width;
-
-  &:first-child {
-    margin-left: 0;
-  }
-}
-
-@for $n from 1 through 13 {
-  .layout-content-col.span-#{$n} { width: gridwidth($n); }
-}
-
-@for $n from 1 through 16 {
-  .vspace.size-#{$n} { height: 10px * $n; }
-}
-
-/* nav */
-
-#nav {
-  li {
-    list-style-type: none;
-    @include fontheight($small_text_size, 10px);
-  }
-
-  a {
-    color: $text_color;
-    text-decoration: none;
-  }
-
-  li.selected > a,
-  li.selected .nav-section-header a {
-    font-weight: $boldweight;
-    color: $ics_blue_dark !important;
-  }
-
-  /* section header divs */
-
-  .nav-section-header {
-    position: relative;
-    padding: 10px;
-    margin-bottom: 1px;
-
-    /* section header links */
-
-    a {
-      color: $text_color_dark;
-      font-weight: $boldweight;
-      text-transform: uppercase;
-    }
-
-    &:after {
-      @include disclosure(down);
-      display: block;
-      position: absolute;
-      top: 10px;
-      right: 10px;
-    }
-
-    &.empty:after {
-      display: none;
-    }
-  }
-
-  /* expanded section header divs */
-
-  li.expanded .nav-section-header {
-    background: $panel_background_dark;
-
-    &:after {
-      @include disclosure(up);
-    }
-  }
-
-  /* sublinks */
-
-  & > li > ul {
-    height: 0;
-    overflow: hidden;
-    margin-bottom: 0;
-
-    &.animate-height {
-      @include prefixed(transition, height 0.25s ease-in);
-    }
-
-    li {
-      padding: 10px 10px (10px + 1) 10px;
-    }
-  }
-
-  & > li.expanded > ul {
-    height: auto;
-
-    li {
-      background: $panel_background;
-    }
-  }
-
-  #back-dac-section {
-    padding: 10px;
-    border-top: 1px solid #ddd;
-
-    a {
-      color: $text_color_dark;
-      font-weight: $boldweight;
-      text-transform: uppercase;
-    }
-  }
-}
-
-/* content header */
-
-$content_header_height: 30px;
-
-.content-header {
-  border-bottom: 1px solid $ics_blue;
-  height: $content_header_height;
-
-  h2 {
-    border-bottom: 0;
-  }
-
-  &.just-links {
-    border-bottom: 0;
-  }
-}
-
-.content-footer {
-  border-top: 1px solid $ics_blue;
-  margin-top: 10px;
-  height: $content_header_height;
-}
-
-.paging-links {
-  position: relative;
-
-  a {
-    position: absolute;
-    font-size: $small_text_size;
-    line-height: $content_header_height;
-    color: $text_color;
-    text-decoration: none;
-    text-transform: uppercase;
-  }
-
-  .prev-page-link {
-    display: none;
-    left: -5px;
-
-    &:before {
-      @include disclosure(left);
-      display: inline-block;
-      margin-right: 5px;
-    }
-  }
-
-  .next-page-link {
-    display: none;
-    right: 10px;
-
-    &:after {
-      @include disclosure(right);
-      display: inline-block;
-      margin-left: 5px;
-    }
-  }
-}
-
-/* content body */
-
-@-webkit-keyframes glowheader {
-  from {  background-color: rgb(51, 181, 229); color: #000;       border-bottom-color: #000; }
-  to {    background-color: transparent;       color: $ics_blue;  border-bottom-color: $ics_blue; }
-}
-@-moz-keyframes glowheader {
-  from {  background-color: rgb(51, 181, 229); color: #000;       border-bottom-color: #000; }
-  to {    background-color: transparent;       color: $ics_blue;  border-bottom-color: $ics_blue; }
-}
-@keyframes glowheader {
-  from {  background-color: rgb(51, 181, 229); color: #000;       border-bottom-color: #000; }
-  to {    background-color: transparent;       color: $ics_blue;  border-bottom-color: $ics_blue; }
-}
-
-#content {
-  p,
-  ul,
-  ol,
-  h3 {
-    margin: 0 10px 10px 10px;
-  }
-
-  h2 {
-    padding-left: 10px;
-    padding-right: 10px;
-    margin-bottom: 10px;
-    font-size: $large_text_size;
-    line-height: $content_header_height;
-    font-weight: $boldweight;
-    color: $ics_blue;
-    border-bottom: 1px solid $ics_blue;
-    height: $content_header_height;
-
-    &:target {
-      @include prefixed(animation-name, glowheader);
-      @include prefixed(animation-duration, 0.7s);
-      @include prefixed(animation-timing-function, ease-out);
-    }
-  }
-
-  hr {
-    border: 0;
-    border-bottom: 1px solid $ics_blue;
-    margin-bottom: 20px;
-  }
-
-  h3 {
-    color: $ics_blue;
-    text-transform: uppercase;
-    @include fontheight($small_text_size, $default_line_height);
-    font-weight: $boldweight;
-  }
-
-  h4 {
-    margin: 0 10px;
-    color: $text_color_dark;
-    font-weight: $boldweight;
-    @include fontheight($small_text_size, $default_line_height);
-  }
-
-  strong {
-    color: $text_color_dark;
-  }
-
-  ul li,
-  ol li {
-    margin-left: 20px;
-
-    h4 {
-      margin: 0;
-    }
-
-    p {
-      margin-left: 0;
-    }
-  }
-
-  ul li {
-    list-style-type: square;
-    list-style-type: none;
-    position: relative;
-
-    &:before {
-      content: '\2022';
-      font-family: verdana;
-      @include fontheight($small_text_size, $default_line_height);
-      position: absolute;
-      left: -20px;
-      top: -1px;
-    }
-  }
-
-  ol {
-    counter-reset: item;
-
-    li {
-      @include fontheight($small_text_size, $default_line_height);
-      list-style-type: none;
-      position: relative;
-    
-      &:before {
-        content: counter(item) '. ';
-        counter-increment: item;
-        position: absolute;
-        left: -20px;
-        top: 0;
-      }
-
-      @for $n from 1 through 10 {
-        &.value-#{$n}:before {
-          content: '#{$n}. ';
-        }
-      }
-    }
-  }
-
-  .with-callouts ol li {
-    list-style-position: inside;
-    margin-left: 0;
-
-    &:before {
-      position: static;
-      display: inline;
-      left: 0;
-      float: left;
-      width: 17px;
-      color: $ics_blue;
-      font-weight: $boldweight;
-    }
-  }
-}
-
-/* special list items */
-
-li.no-bullet {
-  list-style-type: none !important;
-}
-
-#content li.with-icon {
-  position: relative;
-  margin-left: 40px;
-  min-height: 30px;
-
-  p {
-    margin-left: 0 !important;
-  }
-
-  &:before {
-    position: absolute;
-    left: -40px;
-    top: 0;
-    content: '';
-    width: 30px;
-    height: 30px;
-  }
-
-  &.tablet:before {
-    background-image: url(ico_phone_tablet.png);
-  }
-
-  &.web:before {
-    background-image: url(ico_web.png);
-  }
-
-  &.checklist:before {
-    background-image: url(ico_checklist.png);
-  }
-
-  &.action:before {
-    background-image: url(ico_action.png);
-  }
-
-  &.use:before {
-    background-image: url(ico_use.png);
-  }
-}
-
-/* figures and callouts */
-
-.figure {
-  position: relative;
-
-  &.pad-below {
-    margin-bottom: 20px;
-  }
-
-  .figure-callout {
-    position: absolute;
-    color: #fff;
-    font-weight: $boldweight;
-    @include fontheight($large_text_size, 23px);
-    text-align: center;
-    background: transparent url(callout.png) no-repeat scroll 50% 50%;
-    padding-right: 2px;
-    width: 30px;
-    height: 29px;
-    z-index: 1000;
-
-    &.top {
-      top: -9px;
-    }
-
-    &.right {
-      right: -5px;
-    }
-  }
-}
-
-.figure-caption {
-  margin: 0 10px 20px 10px;
-  @include fontheight($small_text_size, $default_line_height);
-  font-style: italic;
-}
-
-/* rows of figures */
-
-.figure-row {
-  @include fontheight(0, 0); /* to prevent space between figures */
-
-  .figure {
-    display: inline-block;
-    vertical-align: top;
-  }
-
-  .figure + .figure {
-    margin-left: 10px; /* reintroduce space between figures */
-  }
-}
-
-/* video  containers */
-
-.framed-galaxynexus-land-span-13 {
-  background: transparent url(device_galaxynexus_blank_land_span13.png) no-repeat scroll top left;
-  padding: 42px 122px 62px 126px;
-  overflow: hidden;
-
-  &,
-  & video,
-  & img {
-    width: 512px;
-    height: 286px;
-  }
-}
-
-.framed-galaxynexus-port-span-9 {
-  background: transparent url(device_galaxynexus_blank_port_span9.png) no-repeat scroll top left;
-  padding: 95px 122px 107px 124px;
-  overflow: hidden;
-
-  &,
-  & video,
-  & img {
-    width: 274px;
-    height: 488px;
-  }
-}
-
-.framed-galaxynexus-port-span-5 {
-  background: transparent url(device_galaxynexus_blank_port_span5.png) no-repeat scroll top left;
-  padding: 75px 31px 76px 33px;
-  overflow: hidden;
-
-  &,
-  & video,
-  & img {
-    width: 216px;
-    height: 384px;
-  }
-}
-
-/* landing page disclosures */
-
-.landing-page-link {
-  text-decoration: none;
-  font-weight: $boldweight;
-  color: $text_color_dark;
-
-  &:after {
-    @include disclosure(right);
-    display: inline-block;
-    margin-left: 5px;
-  }
-}
-
-/* tooltips */
-
-$tooltip_back_color: rgba(0,0,0,0.9);
-
-.tooltip-box {
-  position: absolute;
-  background-color: $tooltip_back_color;
-  border-radius: 2px;
-  @include fontheight($small_text_size, $default_line_height);
-  color: #fff;
-  padding: 6px 10px;
-  max-width: 250px;
-  z-index: 10000;
-
-  &.below:after {
-    position: absolute;
-    content: '';
-    line-height: 0;
-    display: block;
-    top: -10px;
-    left: 5px;
-    border: 5px solid transparent;
-    border-bottom-color: $tooltip_back_color;
-  }
-}
-
-/* video note */
-
-.video-instructions {
-  margin-top: 10px;
-  margin-bottom: 10px;
-
-  &:before {
-    content: '';
-    background: transparent url(ico_movie_inline.png) no-repeat scroll top left;
-    display: inline-block;
-    width: 12px;
-    height: 12px;
-    margin-right: 8px;
-  }
-
-  &:after {
-    content: 'Click to replay movie.';
-  }
-}
-
-/* download buttons */
-
-.download-button {
-  display: block;
-  margin-bottom: 5px;
-  text-decoration: none;
-  background-color: $ics_blue;
-  color: #fff !important;
-  font-weight: $boldweight;
-  box-shadow: 0 1px 1px $lighter_shadow_color;
-  padding: 6px 12px;
-  border-radius: 2px;
-
-  &:hover,
-  &:focus {
-    background-color: $ics_blue_dark;
-    color: #fff !important;
-  }
-
-  &:active {
-    background-color: $ics_blue_darkest;
-  }
-}
-
-/* UI tables and other things found in Writing style and Settings pattern */
-
-.ui-table {
-  width: 100%;
-  background: #282828;
-  color: #fff;
-  border-radius: 2px;
-  box-shadow: 0 2px 4px rgba(0,0,0,0.25);
-  border-collapse: separate;
-
-  th,
-  td {
-    padding: 5px 10px;
-  }
-
-  thead th {
-    font-weight: 600;
-  }
-
-  tfoot td {
-    border-top: 1px solid #494949;
-    border-right: 1px solid #494949;
-    text-align: center;
-
-    &:last-child {
-      border-right: 0;
-    }
-  }
-}
-
-.layout-with-list-item-margins {
-  margin-left: 30px !important;
-}
-
-.emulate-content-left-padding {
-  margin-left: 10px;
-}
-
-.do-dont-label {
-  margin-bottom: 10px;
-  padding-left: 20px;
-  background: transparent none no-repeat scroll 0px 3px;
-
-  &.bad {
-    background-image: url(ico_wrong.png);
-  }
-
-  &.good {
-    background-image: url(ico_good.png);
-  }
-}
\ No newline at end of file
diff --git a/tools/droiddoc/templates-sdk/class.cs b/tools/droiddoc/templates-sdk/class.cs
index b85d7f0..b2a4791 100644
--- a/tools/droiddoc/templates-sdk/class.cs
+++ b/tools/droiddoc/templates-sdk/class.cs
@@ -90,7 +90,11 @@
 <?cs /if ?>
 </div><!-- end sum-details-links -->
 <div class="api-level">
-  <?cs call:since_tags(class) ?>
+  <?cs call:since_tags(class) ?><?cs
+  if:class.deprecatedsince
+    ?><br>Deprecated since <a href="<?cs var:toroot ?>guide/topics/manifest/uses-sdk-element.html#ApiLevels"
+        >API level <?cs var:class.deprecatedsince ?></a><?cs
+  /if ?>
   <?cs call:federated_refs(class) ?>
 </div>
 </div><!-- end api-info-block -->
diff --git a/tools/java-layers.py b/tools/java-layers.py
new file mode 100755
index 0000000..b3aec2b
--- /dev/null
+++ b/tools/java-layers.py
@@ -0,0 +1,257 @@
+#!/usr/bin/env python
+
+import os
+import re
+import sys
+
+def fail_with_usage():
+  sys.stderr.write("usage: java-layers.py DEPENDENCY_FILE SOURCE_DIRECTORIES...\n")
+  sys.stderr.write("\n")
+  sys.stderr.write("Enforces layering between java packages.  Scans\n")
+  sys.stderr.write("DIRECTORY and prints errors when the packages violate\n")
+  sys.stderr.write("the rules defined in the DEPENDENCY_FILE.\n")
+  sys.stderr.write("\n")
+  sys.stderr.write("Prints a warning when an unknown package is encountered\n")
+  sys.stderr.write("on the assumption that it should fit somewhere into the\n")
+  sys.stderr.write("layering.\n")
+  sys.stderr.write("\n")
+  sys.stderr.write("DEPENDENCY_FILE format\n")
+  sys.stderr.write("  - # starts comment\n")
+  sys.stderr.write("  - Lines consisting of two java package names:  The\n")
+  sys.stderr.write("    first package listed must not contain any references\n")
+  sys.stderr.write("    to any classes present in the second package, or any\n")
+  sys.stderr.write("    of its dependencies.\n")
+  sys.stderr.write("  - Lines consisting of one java package name:  The\n")
+  sys.stderr.write("    packge is assumed to be a high level package and\n")
+  sys.stderr.write("    nothing may depend on it.\n")
+  sys.stderr.write("  - Lines consisting of a dash (+) followed by one java\n")
+  sys.stderr.write("    package name: The package is considered a low level\n")
+  sys.stderr.write("    package and may not import any of the other packages\n")
+  sys.stderr.write("    listed in the dependency file.\n")
+  sys.stderr.write("  - Lines consisting of a plus (-) followed by one java\n")
+  sys.stderr.write("    package name: The package is considered \'legacy\'\n")
+  sys.stderr.write("    and excluded from errors.\n")
+  sys.stderr.write("\n")
+  sys.exit(1)
+
+class Dependency:
+  def __init__(self, filename, lineno, lower, top, lowlevel, legacy):
+    self.filename = filename
+    self.lineno = lineno
+    self.lower = lower
+    self.top = top
+    self.lowlevel = lowlevel
+    self.legacy = legacy
+    self.uppers = []
+    self.transitive = set()
+
+  def matches(self, imp):
+    for d in self.transitive:
+      if imp.startswith(d):
+        return True
+    return False
+
+class Dependencies:
+  def __init__(self, deps):
+    def recurse(obj, dep, visited):
+      global err
+      if dep in visited:
+        sys.stderr.write("%s:%d: Circular dependency found:\n"
+            % (dep.filename, dep.lineno))
+        for v in visited:
+          sys.stderr.write("%s:%d:    Dependency: %s\n"
+              % (v.filename, v.lineno, v.lower))
+        err = True
+        return
+      visited.append(dep)
+      for upper in dep.uppers:
+        obj.transitive.add(upper)
+        if upper in deps:
+          recurse(obj, deps[upper], visited)
+    self.deps = deps
+    self.parts = [(dep.lower.split('.'),dep) for dep in deps.itervalues()]
+    # transitive closure of dependencies
+    for dep in deps.itervalues():
+      recurse(dep, dep, [])
+    # disallow everything from the low level components
+    for dep in deps.itervalues():
+      if dep.lowlevel:
+        for d in deps.itervalues():
+          if dep != d and not d.legacy:
+            dep.transitive.add(d.lower)
+    # disallow the 'top' components everywhere but in their own package
+    for dep in deps.itervalues():
+      if dep.top and not dep.legacy:
+        for d in deps.itervalues():
+          if dep != d and not d.legacy:
+            d.transitive.add(dep.lower)
+    for dep in deps.itervalues():
+      dep.transitive = set([x+"." for x in dep.transitive])
+    if False:
+      for dep in deps.itervalues():
+        print "-->", dep.lower, "-->", dep.transitive
+
+  # Lookup the dep object for the given package.  If pkg is a subpackage
+  # of one with a rule, that one will be returned.  If no matches are found,
+  # None is returned.
+  def lookup(self, pkg):
+    # Returns the number of parts that match
+    def compare_parts(parts, pkg):
+      if len(parts) > len(pkg):
+        return 0
+      n = 0
+      for i in range(0, len(parts)):
+        if parts[i] != pkg[i]:
+          return 0
+        n = n + 1
+      return n
+    pkg = pkg.split(".")
+    matched = 0
+    result = None
+    for (parts,dep) in self.parts:
+      x = compare_parts(parts, pkg)
+      if x > matched:
+        matched = x
+        result = dep
+    return result
+
+def parse_dependency_file(filename):
+  global err
+  f = file(filename)
+  lines = f.readlines()
+  f.close()
+  def lineno(s, i):
+    i[0] = i[0] + 1
+    return (i[0],s)
+  n = [0]
+  lines = [lineno(x,n) for x in lines]
+  lines = [(n,s.split("#")[0].strip()) for (n,s) in lines]
+  lines = [(n,s) for (n,s) in lines if len(s) > 0]
+  lines = [(n,s.split()) for (n,s) in lines]
+  deps = {}
+  for n,words in lines:
+    if len(words) == 1:
+      lower = words[0]
+      top = True
+      legacy = False
+      lowlevel = False
+      if lower[0] == '+':
+        lower = lower[1:]
+        top = False
+        lowlevel = True
+      elif lower[0] == '-':
+        lower = lower[1:]
+        legacy = True
+      if lower in deps:
+        sys.stderr.write(("%s:%d: Package '%s' already defined on"
+            + " line %d.\n") % (filename, n, lower, deps[lower].lineno))
+        err = True
+      else:
+        deps[lower] = Dependency(filename, n, lower, top, lowlevel, legacy)
+    elif len(words) == 2:
+      lower = words[0]
+      upper = words[1]
+      if lower in deps:
+        dep = deps[lower]
+        if dep.top:
+          sys.stderr.write(("%s:%d: Can't add dependency to top level package "
+            + "'%s'\n") % (filename, n, lower))
+          err = True
+      else:
+        dep = Dependency(filename, n, lower, False, False, False)
+        deps[lower] = dep
+      dep.uppers.append(upper)
+    else:
+      sys.stderr.write("%s:%d: Too many words on line starting at \'%s\'\n" % (
+          filename, n, words[2]))
+      err = True
+  return Dependencies(deps)
+
+def find_java_files(srcs):
+  result = []
+  for d in srcs:
+    if d[0] == '@':
+      f = file(d[1:])
+      result.extend([fn for fn in [s.strip() for s in f.readlines()]
+          if len(fn) != 0])
+      f.close()
+    else:
+      for root, dirs, files in os.walk(d):
+        result.extend([os.sep.join((root,f)) for f in files
+            if f.lower().endswith(".java")])
+  return result
+
+COMMENTS = re.compile("//.*?\n|/\*.*?\*/", re.S)
+PACKAGE = re.compile("package\s+(.*)")
+IMPORT = re.compile("import\s+(.*)")
+
+def examine_java_file(deps, filename):
+  global err
+  # Yes, this is a crappy java parser.  Write a better one if you want to.
+  f = file(filename)
+  text = f.read()
+  f.close()
+  text = COMMENTS.sub("", text)
+  index = text.find("{")
+  if index < 0:
+    sys.stderr.write(("%s: Error: Unable to parse java. Can't find class "
+        + "declaration.\n") % filename)
+    err = True
+    return
+  text = text[0:index]
+  statements = [s.strip() for s in text.split(";")]
+  # First comes the package declaration.  Then iterate while we see import
+  # statements.  Anything else is either bad syntax that we don't care about
+  # because the compiler will fail, or the beginning of the class declaration.
+  m = PACKAGE.match(statements[0])
+  if not m:
+    sys.stderr.write(("%s: Error: Unable to parse java. Missing package "
+        + "statement.\n") % filename)
+    err = True
+    return
+  pkg = m.group(1)
+  imports = []
+  for statement in statements[1:]:
+    m = IMPORT.match(statement)
+    if not m:
+      break
+    imports.append(m.group(1))
+  # Do the checking
+  if False:
+    print filename
+    print "'%s' --> %s" % (pkg, imports)
+  dep = deps.lookup(pkg)
+  if not dep:
+    sys.stderr.write(("%s: Error: Package does not appear in dependency file: "
+      + "%s\n") % (filename, pkg))
+    err = True
+    return
+  for imp in imports:
+    if dep.matches(imp):
+      sys.stderr.write("%s: Illegal import in package '%s' of '%s'\n"
+          % (filename, pkg, imp))
+      err = True
+
+err = False
+
+def main(argv):
+  if len(argv) < 3:
+    fail_with_usage()
+  deps = parse_dependency_file(argv[1])
+
+  if err:
+    sys.exit(1)
+
+  java = find_java_files(argv[2:])
+  for filename in java:
+    examine_java_file(deps, filename)
+
+  if err:
+    sys.stderr.write("%s: Using this file as dependency file.\n" % argv[1])
+    sys.exit(1)
+
+  sys.exit(0)
+
+if __name__ == "__main__":
+  main(sys.argv)
+