Reconcile with gingerbread-release honeycomb-mr2-release honeycomb-LTE-release

Change-Id: I6592f9416213bdf7c4190297b2edf08a5de9ce45
diff --git a/CleanSpec.mk b/CleanSpec.mk
index 68c7f6a..70a053f 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -44,20 +44,58 @@
 #$(call add-clean-step, find $(OUT_DIR) -type f -name "IGTalkSession*" -print0 | xargs -0 rm -f)
 #$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/*)
 
+$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system)
+
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libmediaplayerservice_intermediates)
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libmedia_jni_intermediates)
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libstagefright_omx_intermediates)
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/root/default.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/recovery/root/default.prop)
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/vendor)
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/android-info.txt)
 $(call add-clean-step, find $(PRODUCT_OUT) -name "*.apk" | xargs rm)
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/app/*)
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
-$(call add-clean-step, rm -rf $(OUT_DIR))
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/*/LINKED)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
 $(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/*)
+$(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/lib/*.so)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib/*.so)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/symbols/system/lib/*.so)
+$(call add-clean-step, rm -rf $(HOST_OUT_EXECUTABLES)/iself)
+$(call add-clean-step, rm -rf $(HOST_OUT_EXECUTABLES)/lsd)
+$(call add-clean-step, rm -rf $(HOST_OUT_EXECUTABLES)/apriori)
+$(call add-clean-step, rm -rf $(HOST_OUT_EXECUTABLES)/isprelinked)
+$(call add-clean-step, rm -rf $(HOST_OUT_EXECUTABLES)/soslim)
 
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/lib/*.so)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib/*.so)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/symbols/system/lib/*.so)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/YouTube*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
 
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libstagefright_intermediates)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libstagefright_omx_intermediates)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/librtp_jni_intermediates)
+
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/android-info.txt)
+# ************************************************
 # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
 # ************************************************
diff --git a/buildspec.mk.default b/buildspec.mk.default
index c568a82..46aee69 100644
--- a/buildspec.mk.default
+++ b/buildspec.mk.default
@@ -106,9 +106,9 @@
 #WEBCORE_INSTRUMENTATION:=true
 endif
 
-# To enable SVG in webcore define ENABLE_SVG:=true
+# To disable SVG in webcore define ENABLE_SVG:=false
 ifndef ENABLE_SVG
-#ENABLE_SVG:=true
+#ENABLE_SVG:=false
 endif
 
 # when the build system changes such that this file must be updated, this
diff --git a/core/Makefile b/core/Makefile
index f4669f2..87b91bd 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -16,17 +16,16 @@
 # e.g., "system/etc/file.xml".
 # The filter part means "only eval the copy-one-file rule if this
 # src:dest pair is the first one to match the same dest"
-unique_product_copy_files_destinations := $(sort \
-    $(foreach cf,$(PRODUCT_COPY_FILES), $(call word-colon,2,$(cf))))
+unique_product_copy_files_destinations :=
 $(foreach cf,$(PRODUCT_COPY_FILES), \
     $(eval _src := $(call word-colon,1,$(cf))) \
     $(eval _dest := $(call word-colon,2,$(cf))) \
-    $(if $(filter $(unique_product_copy_files_destinations),$(_dest)), \
+    $(if $(filter $(unique_product_copy_files_destinations),$(_dest)),, \
         $(eval _fulldest := $(call append-path,$(PRODUCT_OUT),$(_dest))) \
         $(eval $(call copy-one-file,$(_src),$(_fulldest))) \
         $(eval ALL_DEFAULT_INSTALLED_MODULES += $(_fulldest)) \
-        $(eval unique_product_copy_files_destinations := $(filter-out $(_dest), \
-            $(unique_product_copy_files_destinations)))))
+        $(eval unique_product_copy_files_destinations += $(_dest))))
+unique_product_copy_files_destinations :=
 
 # -----------------------------------------------------------------
 # docs/index.html
@@ -41,7 +40,11 @@
 INSTALLED_DEFAULT_PROP_TARGET := $(TARGET_ROOT_OUT)/default.prop
 ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_DEFAULT_PROP_TARGET)
 ADDITIONAL_DEFAULT_PROPERTIES := \
-	$(call collapse-pairs, $(ADDITIONAL_DEFAULT_PROPERTIES))
+    $(call collapse-pairs, $(ADDITIONAL_DEFAULT_PROPERTIES))
+ADDITIONAL_DEFAULT_PROPERTIES += \
+    $(call collapse-pairs, $(PRODUCT_DEFAULT_PROPERTY_OVERRIDES))
+ADDITIONAL_DEFAULT_PROPERTIES := $(call uniq-pairs-by-first-component, \
+    $(ADDITIONAL_DEFAULT_PROPERTIES),=)
 
 $(INSTALLED_DEFAULT_PROP_TARGET):
 	@echo Target buildinfo: $@
@@ -51,13 +54,16 @@
 	        echo "#" >> $@;
 	$(hide) $(foreach line,$(ADDITIONAL_DEFAULT_PROPERTIES), \
 		echo "$(line)" >> $@;)
+	build/tools/post_process_props.py $@
 
 # -----------------------------------------------------------------
 # build.prop
 INSTALLED_BUILD_PROP_TARGET := $(TARGET_OUT)/build.prop
 ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_BUILD_PROP_TARGET)
 ADDITIONAL_BUILD_PROPERTIES := \
-	$(call collapse-pairs, $(ADDITIONAL_BUILD_PROPERTIES))
+    $(call collapse-pairs, $(ADDITIONAL_BUILD_PROPERTIES))
+ADDITIONAL_BUILD_PROPERTIES := $(call uniq-pairs-by-first-component, \
+    $(ADDITIONAL_BUILD_PROPERTIES),=)
 
 # A list of arbitrary tags describing the build configuration.
 # Force ":=" so we can use +=
@@ -98,6 +104,14 @@
   BUILD_DISPLAY_ID := $(build_desc)
 endif
 
+# Whether there is default locale set in PRODUCT_PROPERTY_OVERRIDES
+product_property_override_locale_language := $(strip \
+    $(patsubst ro.product.locale.language=%,%,\
+    $(filter ro.product.locale.language=%,$(PRODUCT_PROPERTY_OVERRIDES))))
+product_property_overrides_locale_region := $(strip \
+    $(patsubst ro.product.locale.region=%,%,\
+    $(filter ro.product.locale.region=%,$(PRODUCT_PROPERTY_OVERRIDES))))
+
 # Selects the first locale in the list given as the argument,
 # and splits it into language and region, which each may be
 # empty.
@@ -106,16 +120,17 @@
 endef
 
 # Selects the first locale in the list given as the argument
-# and returns the language (or the region)
+# and returns the language (or the region), if it's not set in PRODUCT_PROPERTY_OVERRIDES;
+# Return empty string if it's already set in PRODUCT_PROPERTY_OVERRIDES.
 define default-locale-language
-$(word 2, 2, $(call default-locale, $(1)))
+$(if $(product_property_override_locale_language),,$(word 1, $(call default-locale, $(1))))
 endef
 define default-locale-region
-$(word 3, 3, $(call default-locale, $(1)))
+$(if $(product_property_overrides_locale_region),,$(word 2, $(call default-locale, $(1))))
 endef
 
 BUILDINFO_SH := build/tools/buildinfo.sh
-$(INSTALLED_BUILD_PROP_TARGET): $(BUILDINFO_SH) $(INTERNAL_BUILD_ID_MAKEFILE)
+$(INSTALLED_BUILD_PROP_TARGET): $(BUILDINFO_SH) $(INTERNAL_BUILD_ID_MAKEFILE) $(BUILD_SYSTEM)/version_defaults.mk $(wildcard $(TARGET_DEVICE_DIR)/system.prop)
 	@echo Target buildinfo: $@
 	@mkdir -p $(dir $@)
 	$(hide) TARGET_BUILD_TYPE="$(TARGET_BUILD_VARIANT)" \
@@ -140,6 +155,7 @@
 			TARGET_BOARD_PLATFORM="$(TARGET_BOARD_PLATFORM)" \
 			TARGET_CPU_ABI="$(TARGET_CPU_ABI)" \
 			TARGET_CPU_ABI2="$(TARGET_CPU_ABI2)" \
+			TARGET_AAPT_CHARACTERISTICS="$(TARGET_AAPT_CHARACTERISTICS)" \
 	        bash $(BUILDINFO_SH) > $@
 	$(hide) if [ -f $(TARGET_DEVICE_DIR)/system.prop ]; then \
 	          cat $(TARGET_DEVICE_DIR)/system.prop >> $@; \
@@ -151,6 +167,7 @@
 		        echo "#" >> $@; )
 	$(hide) $(foreach line,$(ADDITIONAL_BUILD_PROPERTIES), \
 		echo "$(line)" >> $@;)
+	$(hide) build/tools/post_process_props.py $@
 
 build_desc :=
 
@@ -205,16 +222,9 @@
 intermediates := \
 	$(call intermediates-dir-for,PACKAGING,apkcerts)
 APKCERTS_FILE := $(intermediates)/$(name).txt
-# Depending on the built packages isn't exactly right,
-# but it should guarantee that the apkcerts file is rebuilt
-# if any packages change which certs they're signed with.
-all_built_packages := $(foreach p,$(PACKAGES),$(ALL_MODULES.$(p).BUILT))
-ifneq ($(TARGET_BUILD_APPS),)
-# We don't need to really build all the modules for apps_only build.
+# We don't need to really build all the modules.
+# TODO: rebuild APKCERTS_FILE if any app change its cert.
 $(APKCERTS_FILE):
-else
-$(APKCERTS_FILE): $(all_built_packages)
-endif
 	@echo APK certs list: $@
 	@mkdir -p $(dir $@)
 	@rm -f $@
@@ -228,7 +238,9 @@
 .PHONY: apkcerts-list
 apkcerts-list: $(APKCERTS_FILE)
 
-$(call dist-for-goals, apps_only, $(APKCERTS_FILE):apkcerts.txt)
+ifneq (,$(TARGET_BUILD_APPS))
+  $(call dist-for-goals, apps_only, $(APKCERTS_FILE):apkcerts.txt)
+endif
 
 # -----------------------------------------------------------------
 # module info file
@@ -572,8 +584,12 @@
 endif
 endif
 
+ifneq (true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED))
+  INTERNAL_USERIMAGES_SPARSE_EXT_FLAG := -s
+endif
+
 ifeq ($(INTERNAL_USERIMAGES_USE_EXT),true)
-INTERNAL_USERIMAGES_DEPS := $(MKEXT2USERIMG) $(MAKE_EXT4FS)
+INTERNAL_USERIMAGES_DEPS := $(MKEXTUSERIMG) $(MAKE_EXT4FS)
 INTERNAL_USERIMAGES_BINARY_PATHS := $(sort $(dir $(INTERNAL_USERIMAGES_DEPS)))
 
 # $(1): src directory
@@ -583,8 +599,8 @@
 # $(5): size of the partition
 define build-userimage-ext-target
   @mkdir -p $(dir $(2))
-    $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$(PATH) \
-	  $(MKEXT2USERIMG) $(1) $(2) $(4) $(3) $(5)
+  $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
+	  $(MKEXTUSERIMG) $(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG) $(1) $(2) $(4) $(3) $(5)
 endef
 else
 INTERNAL_USERIMAGES_DEPS := $(MKYAFFS2)
@@ -645,11 +661,12 @@
 	$(call intermediates-dir-for,PACKAGING,ota_keys)/keys
 DUMPKEY_JAR := $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar
 $(RECOVERY_INSTALL_OTA_KEYS): PRIVATE_OTA_PUBLIC_KEYS := $(OTA_PUBLIC_KEYS)
-$(RECOVERY_INSTALL_OTA_KEYS): $(OTA_PUBLIC_KEYS) $(DUMPKEY_JAR)
-	@echo "DumpPublicKey: $@ <= $(PRIVATE_OTA_PUBLIC_KEYS)"
+$(RECOVERY_INSTALL_OTA_KEYS): extra_keys := $(patsubst %,%.x509.pem,$(PRODUCT_EXTRA_RECOVERY_KEYS))
+$(RECOVERY_INSTALL_OTA_KEYS): $(OTA_PUBLIC_KEYS) $(DUMPKEY_JAR) $(extra_keys)
+	@echo "DumpPublicKey: $@ <= $(PRIVATE_OTA_PUBLIC_KEYS) $(extra_keys)"
 	@rm -rf $@
 	@mkdir -p $(dir $@)
-	java -jar $(DUMPKEY_JAR) $(PRIVATE_OTA_PUBLIC_KEYS) > $@
+	java -jar $(DUMPKEY_JAR) $(PRIVATE_OTA_PUBLIC_KEYS) $(extra_keys) > $@
 
 $(INSTALLED_RECOVERYIMAGE_TARGET): $(MKBOOTFS) $(MKBOOTIMG) $(MINIGZIP) \
 		$(INSTALLED_RAMDISK_TARGET) \
@@ -696,8 +713,14 @@
 mkyaffs2_extra_flags := -c $(BOARD_NAND_PAGE_SIZE)
 else
 mkyaffs2_extra_flags :=
+BOARD_NAND_PAGE_SIZE := 2048
 endif
 
+ifneq ($(BOARD_NAND_SPARE_SIZE),)
+mkyaffs2_extra_flags += -s $(BOARD_NAND_SPARE_SIZE)
+else
+BOARD_NAND_SPARE_SIZE := 64
+endif
 
 # -----------------------------------------------------------------
 # system image
@@ -713,7 +736,7 @@
 	$(ALL_DEFAULT_INSTALLED_MODULES))
 
 ifeq ($(INTERNAL_USERIMAGES_USE_EXT),true)
-## generate an ext2 image
+## generate an ext image
 # $(1): output file
 define build-systemimage-target
     @echo "Target system fs image: $(1)"
@@ -778,8 +801,12 @@
 		$(INSTALLED_SYSTEMTARBALL_TARGET)
 endef
 
+ifndef SYSTEM_TARBALL_FORMAT
+    SYSTEM_TARBALL_FORMAT := bz2
+endif
+
 system_tar := $(PRODUCT_OUT)/system.tar
-INSTALLED_SYSTEMTARBALL_TARGET := $(system_tar).bz2
+INSTALLED_SYSTEMTARBALL_TARGET := $(system_tar).$(SYSTEM_TARBALL_FORMAT)
 $(INSTALLED_SYSTEMTARBALL_TARGET): PRIVATE_SYSTEM_TAR := $(system_tar)
 $(INSTALLED_SYSTEMTARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_SYSTEMIMAGE_FILES)
 	$(build-systemtarball-target)
@@ -793,13 +820,41 @@
 stnod: systemtarball-nodeps
 
 
+#######
+## boot tarball
+define build-boottarball-target
+    $(hide) echo "Target boot fs tarball: $(INSTALLED_BOOTTARBALL_TARGET)"
+    $(hide) mkdir -p $(PRODUCT_OUT)/boot
+    $(hide) cp -f $(INTERNAL_BOOTIMAGE_FILES) $(PRODUCT_OUT)/boot/.
+    $(hide) echo $(BOARD_KERNEL_CMDLINE) > $(PRODUCT_OUT)/boot/cmdline
+    $(hide) $(MKTARBALL) $(FS_GET_STATS) \
+                 $(PRODUCT_OUT) boot $(PRIVATE_BOOT_TAR) \
+                 $(INSTALLED_BOOTTARBALL_TARGET)
+endef
+
+ifndef BOOT_TARBALL_FORMAT
+    BOOT_TARBALL_FORMAT := bz2
+endif
+
+boot_tar := $(PRODUCT_OUT)/boot.tar
+INSTALLED_BOOTTARBALL_TARGET := $(boot_tar).$(BOOT_TARBALL_FORMAT)
+$(INSTALLED_BOOTTARBALL_TARGET): PRIVATE_BOOT_TAR := $(boot_tar)
+$(INSTALLED_BOOTTARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_BOOTIMAGE_FILES)
+	$(build-boottarball-target)
+
+.PHONY: boottarball-nodeps btnod
+boottarball-nodeps btnod: $(FS_GET_STATS) \
+                      $(filter-out boottarball-nodeps btnod,$(MAKECMDGOALS))
+	$(build-boottarball-target)
+
+
 # -----------------------------------------------------------------
 # data partition image
 INTERNAL_USERDATAIMAGE_FILES := \
 	$(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
 
 ifeq ($(INTERNAL_USERIMAGES_USE_EXT),true)
-## Generate an ext image
+## Generate an ext2 image
 define build-userdataimage-target
     $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
     @mkdir -p $(TARGET_OUT_DATA)
@@ -827,7 +882,7 @@
 	$(build-userdataimage-target)
 
 .PHONY: userdataimage-nodeps
-userdataimage-nodeps: $(INTERNAL_USERIMAGES_DEPS)
+userdataimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
 	$(build-userdataimage-target)
 
 #######
@@ -872,6 +927,9 @@
 	  $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar \
 	  $(HOST_OUT_JAVA_LIBRARIES)/signapk.jar \
 	  $(HOST_OUT_EXECUTABLES)/mkuserimg.sh \
+	  $(HOST_OUT_EXECUTABLES)/genext2fs \
+	  $(HOST_OUT_EXECUTABLES)/tune2fs \
+	  $(HOST_OUT_EXECUTABLES)/e2fsck \
 	  $(HOST_OUT_EXECUTABLES)/make_ext4fs
 
 .PHONY: otatools
@@ -1014,6 +1072,12 @@
 ifdef mkyaffs2_extra_flags
 	$(hide) echo "mkyaffs2_extra_flags=$(mkyaffs2_extra_flags)" >> $(zip_root)/META/misc_info.txt
 endif
+ifdef INTERNAL_USERIMAGES_SPARSE_EXT_FLAG
+	$(hide) echo "extfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG)" >> $(zip_root)/META/misc_info.txt
+endif
+ifdef PRODUCT_EXTRA_RECOVERY_KEYS
+	$(hide) echo "extra_recovery_keys=$(PRODUCT_EXTRA_RECOVERY_KEYS)" >> $(zip_root)/META/misc_info.txt
+endif
 	@# Zip everything up, preserving symlinks
 	$(hide) (cd $(zip_root) && zip -qry ../$(notdir $@) .)
 	@# Run fs_config on all the system files in the zip, and save the output
@@ -1026,7 +1090,7 @@
 
 ifneq ($(TARGET_SIMULATOR),true)
 ifneq ($(TARGET_PRODUCT),sdk)
-ifneq ($(TARGET_DEVICE),generic)
+ifeq ($(filter generic%,$(TARGET_DEVICE)),)
 ifneq ($(TARGET_NO_KERNEL),true)
 ifneq ($(recovery_fstab),)
 
@@ -1083,7 +1147,7 @@
 
 endif    # recovery_fstab is defined
 endif    # TARGET_NO_KERNEL != true
-endif    # TARGET_DEVICE != generic
+endif    # TARGET_DEVICE != generic*
 endif    # TARGET_PRODUCT != sdk
 endif    # TARGET_SIMULATOR != true
 
@@ -1219,7 +1283,7 @@
 
 INTERNAL_EMULATOR_PACKAGE_FILES += \
         $(HOST_OUT_EXECUTABLES)/emulator$(HOST_EXECUTABLE_SUFFIX) \
-        prebuilt/android-arm/kernel/kernel-qemu \
+        prebuilt/android-$(TARGET_ARCH)/kernel/kernel-qemu \
         $(INSTALLED_RAMDISK_TARGET) \
 		$(INSTALLED_SYSTEMIMAGE) \
 		$(INSTALLED_USERDATAIMAGE_TARGET)
@@ -1285,11 +1349,29 @@
 
 atree_dir := development/build
 
+# sdk/build/tools.atree contains the generic rules, while
+#
+# sdk/build/tools.$(TARGET_ARCH).atree contains target-specific rules
+# the latter is optional.
+#
+sdk_tools_atree_files := sdk/build/tools.atree
+ifneq (,$(strip $(wildcard sdk/build/tools.$(TARGET_ARCH).atree)))
+  sdk_tools_atree_files += sdk/build/tools.$(TARGET_ARCH).atree
+endif
+
 sdk_atree_files := \
 	$(atree_dir)/sdk.exclude.atree \
 	$(atree_dir)/sdk.atree \
 	$(atree_dir)/sdk-$(HOST_OS)-$(HOST_ARCH).atree \
-	sdk/build/tools.atree
+	$(sdk_tools_atree_files)
+
+# development/build/sdk-android-<abi>.atree is used to differentiate
+# between architecture models (e.g. ARMv5TE versus ARMv7) when copying
+# files like the kernel image. We use TARGET_CPU_ABI because we don't
+# have a better way to distinguish between CPU models.
+ifneq (,$(strip $(wildcard $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree)))
+  sdk_atree_files += $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree
+endif
 
 deps := \
 	$(target_notice_file_txt) \
@@ -1303,7 +1385,7 @@
 	$(INSTALLED_BUILD_PROP_TARGET) \
 	$(ATREE_FILES) \
 	$(atree_dir)/sdk.atree \
-	sdk/build/tools.atree \
+	$(sdk_tools_atree_files) \
 	$(HOST_OUT_EXECUTABLES)/atree \
     $(HOST_OUT_EXECUTABLES)/line_endings
 
@@ -1317,6 +1399,12 @@
 #
 #SDK_GNU_ERROR := true
 
+ifeq ($(HOST_OS),darwin)
+HOST_STRIP_SDK_LLVM := strip
+else
+HOST_STRIP_SDK_LLVM := strip --strip-all
+endif
+
 $(INTERNAL_SDK_TARGET): $(deps)
 	@echo "Package SDK: $@"
 	$(hide) rm -rf $(PRIVATE_DIR) $@
@@ -1337,12 +1425,19 @@
 			-I $(HOST_OUT) \
 			-I $(TARGET_COMMON_OUT_ROOT) \
 			-v "PLATFORM_NAME=android-$(PLATFORM_VERSION)" \
+			-v "OUT_DIR=$(OUT_DIR)" \
+			-v "TARGET_ARCH=$(TARGET_ARCH)" \
+			-v "TARGET_CPU_ABI=$(TARGET_CPU_ABI)" \
 			-o $(PRIVATE_DIR) && \
 		cp -f $(target_notice_file_txt) \
-				$(PRIVATE_DIR)/platforms/android-$(PLATFORM_VERSION)/images/NOTICE.txt && \
+				$(PRIVATE_DIR)/platforms/android-$(PLATFORM_VERSION)/images/$(TARGET_CPU_ABI)/NOTICE.txt && \
 		cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/tools/NOTICE.txt && \
+		cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/platform-tools/NOTICE.txt && \
+		for f in $(PRIVATE_DIR)/platform-tools/llvm-rs-cc-* ; do \
+			if [ -f "$$f" ]; then $(HOST_STRIP_SDK_LLVM) "$$f"; fi; \
+		done && \
 		HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \
-                development/build/tools/sdk_clean.sh $(PRIVATE_DIR) && \
+			development/build/tools/sdk_clean.sh $(PRIVATE_DIR) && \
 		chmod -R ug+rwX $(PRIVATE_DIR) && \
 		cd $(dir $@) && zip -rq $(notdir $@) $(PRIVATE_NAME) \
 	) || ( rm -rf $(PRIVATE_DIR) $@ && exit 44 )
@@ -1386,4 +1481,3 @@
 ifneq ($(sdk_repo_goal),)
 include $(TOPDIR)development/build/tools/sdk_repo.mk
 endif
-
diff --git a/core/apicheck_msg_current.txt b/core/apicheck_msg_current.txt
index 5d3a913..440e7f8 100644
--- a/core/apicheck_msg_current.txt
+++ b/core/apicheck_msg_current.txt
@@ -6,10 +6,10 @@
    1) You can add "@hide" javadoc comments to the methods, etc. listed in the
       errors above.
 
-   2) You can update current.xml by executing the following command:
+   2) You can update current.txt by executing the following command:
          make update-api
 
-      To submit the revised current.xml to the main Android repository,
+      To submit the revised current.txt to the main Android repository,
       you will need approval.
 ******************************
 
diff --git a/core/base_rules.mk b/core/base_rules.mk
index 3c11673..02b04d6 100644
--- a/core/base_rules.mk
+++ b/core/base_rules.mk
@@ -69,7 +69,7 @@
 # Only the tags mentioned in this test are expected to be set by module
 # makefiles. Anything else is either a typo or a source of unexpected
 # behaviors.
-ifneq ($(filter-out user debug eng tests optional samples,$(LOCAL_MODULE_TAGS)),)
+ifneq ($(filter-out user debug eng tests optional samples shell_ash shell_mksh,$(LOCAL_MODULE_TAGS)),)
 $(warning unusual tags $(LOCAL_MODULE_TAGS) on $(LOCAL_MODULE) at $(LOCAL_PATH))
 endif
 
@@ -106,11 +106,11 @@
 # Add implicit tags.
 #
 # If the local directory or one of its parents contains a MODULE_LICENSE_GPL
-# file, tag the module as "gnu".  Search for "*_GNU*" so that we can also
+# file, tag the module as "gnu".  Search for "*_GPL*" and "*_MPL*" so that we can also
 # find files like MODULE_LICENSE_GPL_AND_AFL but exclude files like
 # MODULE_LICENSE_LGPL.
 #
-ifneq ($(call find-parent-file,$(LOCAL_PATH),MODULE_LICENSE*_GPL*),)
+ifneq ($(call find-parent-file,$(LOCAL_PATH),MODULE_LICENSE*_GPL* MODULE_LICENSE*_MPL*),)
   LOCAL_MODULE_TAGS += gnu
 endif
 
@@ -202,7 +202,7 @@
     $(error $(LOCAL_PATH): Illegal use of LOCAL_UNINSTALLABLE_MODULE)
   endif
 else
-  LOCAL_INSTALLED_MODULE := $(LOCAL_MODULE_PATH)/$(LOCAL_MODULE_SUBDIR)$(LOCAL_INSTALLED_MODULE_STEM)
+  LOCAL_INSTALLED_MODULE := $(LOCAL_MODULE_PATH)/$(LOCAL_INSTALLED_MODULE_STEM)
 endif
 
 # Assemble the list of targets to create PRIVATE_ variables for.
@@ -220,6 +220,9 @@
 aidl_java_sources := $(patsubst %.aidl,%.java,$(addprefix $(intermediates.COMMON)/src/, $(aidl_sources)))
 aidl_sources := $(addprefix $(TOP_DIR)$(LOCAL_PATH)/, $(aidl_sources))
 
+ifeq (,$(TARGET_BUILD_APPS))
+LOCAL_AIDL_INCLUDES += $(FRAMEWORKS_BASE_JAVA_SRC_DIRS)
+endif
 aidl_preprocess_import :=
 LOCAL_SDK_VERSION:=$(strip $(LOCAL_SDK_VERSION))
 ifdef LOCAL_SDK_VERSION
@@ -267,6 +270,44 @@
 endif
 
 ###########################################################
+## .proto files: Compile proto files to .java
+###########################################################
+proto_sources := $(filter %.proto,$(LOCAL_SRC_FILES))
+# Because names of the .java files compiled from .proto files are unknown until the
+# .proto files are compiled, we use a timestamp file as depedency.
+proto_java_sources_file_stamp :=
+ifneq ($(proto_sources),)
+proto_sources_fullpath := $(addprefix $(TOP_DIR)$(LOCAL_PATH)/, $(proto_sources))
+# By putting the generated java files into $(LOCAL_INTERMEDIATE_SOURCE_DIR), they will be
+# automatically found by the java compiling function transform-java-to-classes.jar.
+ifneq ($(LOCAL_INTERMEDIATE_SOURCE_DIR),)
+proto_java_intemediate_dir := $(LOCAL_INTERMEDIATE_SOURCE_DIR)/proto
+else
+# LOCAL_INTERMEDIATE_SOURCE_DIR may be not defined in non-java modules.
+proto_java_intemediate_dir := $(intermediates)/proto
+endif
+proto_java_sources_file_stamp := $(proto_java_intemediate_dir)/Proto.stamp
+proto_java_sources_dir := $(proto_java_intemediate_dir)/src
+
+$(proto_java_sources_file_stamp): PRIVATE_PROTO_INCLUDES := $(TOP)
+$(proto_java_sources_file_stamp): PRIVATE_PROTO_SRC_FILES := $(proto_sources_fullpath)
+$(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_DIR := $(proto_java_sources_dir)
+ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),micro)
+$(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_OPTION := --javamicro_out
+else
+$(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_OPTION := --java_out
+endif
+$(proto_java_sources_file_stamp): PRIVATE_PROTOC_FLAGS := $(LOCAL_PROTOC_FLAGS)
+$(proto_java_sources_file_stamp) : $(proto_sources_fullpath) $(PROTOC)
+	$(call transform-proto-to-java)
+
+#TODO: protoc should output the dependencies introduced by imports.
+
+LOCAL_INTERMEDIATE_TARGETS += $(proto_java_sources_file_stamp)
+endif # proto_sources
+
+
+###########################################################
 ## Java: Compile .java files to .class
 ###########################################################
 #TODO: pull this into java.make once host and target are combined
@@ -327,10 +368,11 @@
 	) \
     )
   # The arguments to jar that will include these files in a jar file.
+  # Quote the file name to handle special characters (such as #) correctly.
   extra_jar_args := \
     $(foreach group,$(java_resource_file_groups), \
-	$(addprefix -C $(word 1,$(subst :,$(space),$(group))) , \
-	    $(wordlist 2,9999,$(subst :,$(space),$(group))) \
+	$(addprefix -C "$(word 1,$(subst :,$(space),$(group)))" , \
+	    $(foreach w, $(wordlist 2,9999,$(subst :,$(space),$(group))), "$(w)" ) \
 	) \
     )
   java_resource_file_groups :=
@@ -375,12 +417,14 @@
 #                 to guarantee that the files in full_java_libs will
 #                 be up-to-date.
 ifdef LOCAL_IS_HOST_MODULE
-# TODO: make prebuilt java libraries use the same
-#       intermediates path pattern as target java libraries.
 ifeq ($(LOCAL_BUILD_HOST_DEX),true)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH := -bootclasspath $(call java-lib-files,core-hostdex,$(LOCAL_IS_HOST_MODULE))
+
 full_java_libs := $(call java-lib-files,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE))
 full_java_lib_deps := $(call java-lib-deps,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE))
 else
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH :=
+
 full_java_libs := $(addprefix $(HOST_OUT_JAVA_LIBRARIES)/,$(addsuffix $(COMMON_JAVA_PACKAGE_SUFFIX),$(LOCAL_JAVA_LIBRARIES)))
 full_java_lib_deps := $(full_java_libs)
 endif # LOCAL_BUILD_HOST_DEX
@@ -411,8 +455,10 @@
   full_java_lib_deps += $(link_instr_intermediates_dir.COMMON)/classes.jar
 endif
 
+jar_manifest_file :=
 ifneq ($(strip $(LOCAL_JAR_MANIFEST)),)
-$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JAR_MANIFEST := $(LOCAL_PATH)/$(LOCAL_JAR_MANIFEST)
+jar_manifest_file := $(LOCAL_PATH)/$(LOCAL_JAR_MANIFEST)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JAR_MANIFEST := $(jar_manifest_file)
 else
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JAR_MANIFEST :=
 endif
@@ -477,7 +523,7 @@
 ifneq ($(LOCAL_ACP_UNAVAILABLE),true)
 $(LOCAL_INSTALLED_MODULE): $(LOCAL_BUILT_MODULE) | $(ACP)
 	@echo "Install: $@"
-	$(copy-file-to-target)
+	$(copy-file-to-new-target)
 else
 $(LOCAL_INSTALLED_MODULE): $(LOCAL_BUILT_MODULE)
 	@echo "Install: $@"
@@ -491,7 +537,7 @@
 	@echo "Install: $@"
 	$(copy-file-to-target)
 
-$(LOCAL_INSTALLED_MODULE) : | $(installed_odex)
+$(LOCAL_INSTALLED_MODULE) : $(installed_odex)
 endif
 
 endif # !LOCAL_UNINSTALLABLE_MODULE
diff --git a/core/binary.mk b/core/binary.mk
index 5fb0e75..61026d2 100644
--- a/core/binary.mk
+++ b/core/binary.mk
@@ -28,10 +28,43 @@
   ifndef LOCAL_SDK_VERSION
     $(error $(LOCAL_PATH): LOCAL_NDK_VERSION must be defined with LOCAL_SDK_VERSION)
   endif
+  my_ndk_source_root := $(HISTORICAL_NDK_VERSIONS_ROOT)/android-ndk-r$(LOCAL_NDK_VERSION)/sources
   my_ndk_version_root := $(HISTORICAL_NDK_VERSIONS_ROOT)/android-ndk-r$(LOCAL_NDK_VERSION)/platforms/android-$(LOCAL_SDK_VERSION)/arch-$(TARGET_ARCH)
   ifeq ($(wildcard $(my_ndk_version_root)),)
     $(error $(LOCAL_PATH): ndk version root does not exist: $(my_ndk_version_root))
   endif
+
+  # Set up the NDK stl variant. Starting from NDK-r5 the c++ stl resides in a separate location.
+  # See ndk/docs/CPLUSPLUS-SUPPORT.html
+  my_ndk_stl_include_path :=
+  my_ndk_stl_shared_lib_fullpath :=
+  my_ndk_stl_shared_lib :=
+  my_ndk_stl_static_lib :=
+  ifeq (,$(LOCAL_NDK_STL_VARIANT))
+    LOCAL_NDK_STL_VARIANT := system
+  endif
+  ifneq (1,$(words $(filter system stlport_static stlport_shared gnustl_static, $(LOCAL_NDK_STL_VARIANT))))
+    $(error $(LOCAL_PATH): Unkown LOCAL_NDK_STL_VARIANT $(LOCAL_NDK_STL_VARIANT))
+  endif
+  ifeq (system,$(LOCAL_NDK_STL_VARIANT))
+    my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/system/include
+    # for "system" variant, the shared library exists in the system library and -lstdc++ is added by default.
+  else # LOCAL_NDK_STL_VARIANT is not system
+  ifneq (,$(filter stlport_%, $(LOCAL_NDK_STL_VARIANT)))
+    my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/stlport/stlport
+    ifeq (stlport_static,$(LOCAL_NDK_STL_VARIANT))
+      my_ndk_stl_static_lib := $(my_ndk_source_root)/cxx-stl/stlport/libs/$(TARGET_CPU_ABI)/libstlport_static.a
+    else
+      my_ndk_stl_shared_lib_fullpath := $(my_ndk_source_root)/cxx-stl/stlport/libs/$(TARGET_CPU_ABI)/libstlport_shared.so
+      my_ndk_stl_shared_lib := -lstlport_shared
+    endif
+  else
+    # LOCAL_NDK_STL_VARIANT is gnustl_static
+    my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/gnu-libstdc++/include
+    my_ndk_stl_static_lib := $(my_ndk_source_root)/cxx-stl/gnu-libstdc++/libs/$(TARGET_CPU_ABI)/libstdc++.a
+  endif
+  endif
+
 endif
 
 #######################################
@@ -48,11 +81,17 @@
 endif
 
 ###########################################################
+## Explicitly declare assembly-only __ASSEMBLY__ macro for
+## assembly source
+###########################################################
+LOCAL_ASFLAGS += -D__ASSEMBLY__
+
+###########################################################
 ## Define PRIVATE_ variables from global vars
 ###########################################################
 ifdef LOCAL_NDK_VERSION
 my_target_project_includes :=
-my_target_c_inclues := $(my_ndk_version_root)/usr/include
+my_target_c_inclues := $(my_ndk_stl_include_path) $(my_ndk_version_root)/usr/include
 # TODO: more reliable way to remove platform stuff.
 my_target_global_cflags := $(filter-out -include -I system/%, $(TARGET_GLOBAL_CFLAGS))
 my_target_global_cppflags := $(filter-out -include -I system/%, $(TARGET_GLOBAL_CPPFLAGS))
@@ -98,10 +137,17 @@
 endif
 endif
 
+ifeq (true,$(LOCAL_GROUP_STATIC_LIBRARIES))
+$(LOCAL_BUILT_MODULE): PRIVATE_GROUP_STATIC_LIBRARIES := true
+else
+$(LOCAL_BUILT_MODULE): PRIVATE_GROUP_STATIC_LIBRARIES :=
+endif
+
 ###########################################################
 ## Define arm-vs-thumb-mode flags.
 ###########################################################
 LOCAL_ARM_MODE := $(strip $(LOCAL_ARM_MODE))
+ifeq ($(TARGET_ARCH),arm)
 arm_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),arm)
 normal_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),thumb)
 
@@ -110,6 +156,12 @@
 # actually used (although they are usually empty).
 arm_objects_cflags := $($(my_prefix)$(arm_objects_mode)_CFLAGS)
 normal_objects_cflags := $($(my_prefix)$(normal_objects_mode)_CFLAGS)
+else
+arm_objects_mode :=
+normal_objects_mode :=
+arm_objects_cflags :=
+normal_objects_cflags :=
+endif
 
 ###########################################################
 ## Define per-module debugging flags.  Users can turn on
@@ -133,6 +185,44 @@
 
 
 ###########################################################
+## Compile the .proto files to .cc and then to .o
+###########################################################
+proto_sources := $(filter %.proto,$(LOCAL_SRC_FILES))
+proto_generated_objects :=
+proto_generated_headers :=
+ifneq ($(proto_sources),)
+proto_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(proto_sources))
+proto_generated_cc_sources_dir := $(intermediates)/proto
+proto_generated_cc_sources := $(addprefix $(proto_generated_cc_sources_dir)/, \
+	$(patsubst %.proto,%.pb.cc,$(proto_sources_fullpath)))
+proto_generated_objects := $(patsubst %.cc,%.o, $(proto_generated_cc_sources))
+
+$(proto_generated_cc_sources): PRIVATE_PROTO_INCLUDES := $(TOP)
+$(proto_generated_cc_sources): PRIVATE_PROTO_CC_OUTPUT_DIR := $(proto_generated_cc_sources_dir)
+$(proto_generated_cc_sources): PRIVATE_PROTOC_FLAGS := $(LOCAL_PROTOC_FLAGS)
+$(proto_generated_cc_sources): $(proto_generated_cc_sources_dir)/%.pb.cc: %.proto $(PROTOC)
+	$(transform-proto-to-cc)
+
+proto_generated_headers := $(patsubst %.pb.cc,%.pb.h, $(proto_generated_cc_sources))
+$(proto_generated_headers): $(proto_generated_cc_sources_dir)/%.pb.h: $(proto_generated_cc_sources_dir)/%.pb.cc
+
+$(proto_generated_cc_sources): PRIVATE_ARM_MODE := $(normal_objects_mode)
+$(proto_generated_cc_sources): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
+$(proto_generated_objects): $(proto_generated_cc_sources_dir)/%.o: $(proto_generated_cc_sources_dir)/%.cc
+	$(transform-$(PRIVATE_HOST)cpp-to-o)
+-include $(proto_generated_objects:%.o=%.P)
+
+LOCAL_C_INCLUDES += external/protobuf/src $(proto_generated_cc_sources_dir)
+LOCAL_CFLAGS += -DGOOGLE_PROTOBUF_NO_RTTI
+ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),full)
+LOCAL_STATIC_LIBRARIES += libprotobuf-cpp-2.3.0-full
+else
+LOCAL_STATIC_LIBRARIES += libprotobuf-cpp-2.3.0-lite
+endif
+endif
+
+
+###########################################################
 ## YACC: Compile .y files to .cpp and the to .o.
 ###########################################################
 
@@ -200,7 +290,7 @@
 ifneq ($(strip $(cpp_objects)),)
 $(cpp_objects): $(intermediates)/%.o: \
 		$(TOPDIR)$(LOCAL_PATH)/%$(LOCAL_CPP_EXTENSION) \
-		$(yacc_cpps) $(LOCAL_ADDITIONAL_DEPENDENCIES)
+		$(yacc_cpps) $(proto_generated_headers) $(LOCAL_ADDITIONAL_DEPENDENCIES)
 	$(transform-$(PRIVATE_HOST)cpp-to-o)
 -include $(cpp_objects:%.o=%.P)
 endif
@@ -217,7 +307,7 @@
 # TODO: support compiling certain generated files as arm.
 $(gen_cpp_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
 $(gen_cpp_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
-$(gen_cpp_objects): $(intermediates)/%.o: $(intermediates)/%$(LOCAL_CPP_EXTENSION) $(yacc_cpps) $(LOCAL_ADDITIONAL_DEPENDENCIES)
+$(gen_cpp_objects): $(intermediates)/%.o: $(intermediates)/%$(LOCAL_CPP_EXTENSION) $(yacc_cpps) $(proto_generated_headers) $(LOCAL_ADDITIONAL_DEPENDENCIES)
 	$(transform-$(PRIVATE_HOST)cpp-to-o)
 -include $(gen_cpp_objects:%.o=%.P)
 endif
@@ -264,7 +354,7 @@
 c_objects        := $(c_arm_objects) $(c_normal_objects)
 
 ifneq ($(strip $(c_objects)),)
-$(c_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.c $(yacc_cpps) $(LOCAL_ADDITIONAL_DEPENDENCIES)
+$(c_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.c $(yacc_cpps) $(proto_generated_headers) $(LOCAL_ADDITIONAL_DEPENDENCIES)
 	$(transform-$(PRIVATE_HOST)c-to-o)
 -include $(c_objects:%.o=%.P)
 endif
@@ -281,7 +371,7 @@
 # TODO: support compiling certain generated files as arm.
 $(gen_c_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
 $(gen_c_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
-$(gen_c_objects): $(intermediates)/%.o: $(intermediates)/%.c $(yacc_cpps) $(LOCAL_ADDITIONAL_DEPENDENCIES)
+$(gen_c_objects): $(intermediates)/%.o: $(intermediates)/%.c $(yacc_cpps) $(proto_generated_headers) $(LOCAL_ADDITIONAL_DEPENDENCIES)
 	$(transform-$(PRIVATE_HOST)c-to-o)
 -include $(gen_c_objects:%.o=%.P)
 endif
@@ -294,7 +384,7 @@
 objc_objects := $(addprefix $(intermediates)/,$(objc_sources:.m=.o))
 
 ifneq ($(strip $(objc_objects)),)
-$(objc_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.m $(yacc_cpps) $(PRIVATE_ADDITIONAL_DEPENDENCIES)
+$(objc_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.m $(yacc_cpps) $(proto_generated_headers) $(PRIVATE_ADDITIONAL_DEPENDENCIES)
 	$(transform-$(PRIVATE_HOST)m-to-o)
 -include $(objc_objects:%.o=%.P)
 endif
@@ -337,8 +427,10 @@
 	$(gen_asm_objects) \
 	$(c_objects) \
 	$(gen_c_objects) \
+	$(objc_objects) \
 	$(yacc_objects) \
 	$(lex_objects) \
+	$(proto_generated_objects) \
 	$(addprefix $(TOPDIR)$(LOCAL_PATH)/,$(LOCAL_PREBUILT_OBJ_FILES))
 
 LOCAL_C_INCLUDES += $(TOPDIR)$(LOCAL_PATH) $(intermediates) $(base_intermediates)
@@ -440,8 +532,10 @@
     $(addprefix $($(my_prefix)OUT_SHARED_LIBRARIES)/, \
       $(notdir $(built_shared_libraries)))
 
-my_system_shared_libraries_fullpath := $(addprefix $(my_ndk_version_root)/usr/lib/, \
-    $(addsuffix $(so_suffix), $(LOCAL_SYSTEM_SHARED_LIBRARIES)))
+my_system_shared_libraries_fullpath := \
+    $(my_ndk_stl_shared_lib_fullpath) \
+    $(addprefix $(my_ndk_version_root)/usr/lib/, \
+        $(addsuffix $(so_suffix), $(LOCAL_SYSTEM_SHARED_LIBRARIES)))
 
 built_shared_libraries += $(my_system_shared_libraries_fullpath)
 LOCAL_SHARED_LIBRARIES += $(LOCAL_SYSTEM_SHARED_LIBRARIES)
@@ -462,6 +556,10 @@
       $(call intermediates-dir-for, \
         STATIC_LIBRARIES,$(lib),$(LOCAL_IS_HOST_MODULE))/$(lib)$(a_suffix))
 
+ifdef LOCAL_NDK_VERSION
+built_static_libraries += $(my_ndk_stl_static_lib)
+endif
+
 built_whole_libraries := \
     $(foreach lib,$(LOCAL_WHOLE_STATIC_LIBRARIES), \
       $(call intermediates-dir-for, \
@@ -476,6 +574,11 @@
     $(foreach lib,$(LOCAL_STATIC_LIBRARIES) $(LOCAL_WHOLE_STATIC_LIBRARIES), \
       NOTICE-$(if $(LOCAL_IS_HOST_MODULE),HOST,TARGET)-STATIC_LIBRARIES-$(lib))
 
+# Default is -fno-rtti.
+ifeq ($(strip $(LOCAL_RTTI_FLAG)),)
+LOCAL_RTTI_FLAG := -fno-rtti
+endif
+
 ###########################################################
 # Rule-specific variable definitions
 ###########################################################
@@ -483,10 +586,12 @@
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ASFLAGS := $(LOCAL_ASFLAGS)
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CFLAGS := $(LOCAL_CFLAGS)
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPPFLAGS := $(LOCAL_CPPFLAGS)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RTTI_FLAG := $(LOCAL_RTTI_FLAG)
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_DEBUG_CFLAGS := $(debug_cflags)
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_C_INCLUDES := $(LOCAL_C_INCLUDES)
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDFLAGS := $(LOCAL_LDFLAGS)
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDLIBS := $(LOCAL_LDLIBS)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_NO_CRT := $(LOCAL_NO_CRT)
 
 # this is really the way to get the files onto the command line instead
 # of using $^, because then LOCAL_ADDITIONAL_DEPENDENCIES doesn't work
diff --git a/core/build-system.html b/core/build-system.html
index ce5e869..e547185 100644
--- a/core/build-system.html
+++ b/core/build-system.html
@@ -247,6 +247,7 @@
         for <code>eng</code>.
         <ul>
         <li>Installs modules tagged with: <code>eng</code>, <code>debug</code>,
+            <code>shell_</code>$(TARGET_SHELL),
             <code>user</code>, and/or <code>development</code>.
         <li>Installs non-APK modules that have no tags specified.
         <li>Installs APKs according to the product definition files, in
@@ -266,7 +267,7 @@
         <p>
         This is the flavor intended to be the final release bits.
         <ul>
-        <li>Installs modules tagged with <code>user</code>.
+        <li>Installs modules tagged with <code>shell_</code>$(TARGET_SHELL) and <code>user</code>.
         <li>Installs non-APK modules that have no tags specified.
         <li>Installs APKs according to the product definition files; tags
             are ignored for APK modules.
@@ -681,7 +682,8 @@
 <h4>LOCAL_MODULE_TAGS</h4>
 <p>Set <code>LOCAL_MODULE_TAGS</code> to any number of whitespace-separated
 tags.  If the tag list is empty or contains <code>droid</code>, the module
-will get installed as part of a <code>make droid</code>.  Otherwise, it will
+will get installed as part of a <code>make droid</code>.  Modules with the tag
+<code>shell_</code>$(TARGET_SHELL) will also be installed. Otherwise, it will
 only get installed by running <code>make &lt;your-module&gt;</code>
 or with the <code>make all</code> pseudotarget.</p>
 
diff --git a/core/build_id.mk b/core/build_id.mk
index 8edf986..40bb35d 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 := MASTER
 
-export BUILD_ID=GRJ85
+# 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/cleanbuild.mk b/core/cleanbuild.mk
index 821b03a..2639cae 100644
--- a/core/cleanbuild.mk
+++ b/core/cleanbuild.mk
@@ -117,13 +117,13 @@
   building_sdk :=
 endif
 
-# A change in the list of locales warrants an installclean, too.
-locale_list := $(subst $(space),$(comma),$(strip $(PRODUCT_LOCALES)))
+# A change in the list of aapt configs warrants an installclean, too.
+aapt_config_list := $(strip $(PRODUCT_AAPT_CONFIG))
 
 current_build_config := \
-    $(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT)$(building_sdk)-{$(locale_list)}
+    $(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT)$(building_sdk)-{$(aapt_config_list)}
 building_sdk :=
-locale_list :=
+aapt_config_list :=
 force_installclean := false
 
 # Read the current state from the file, if present.
diff --git a/core/clear_vars.mk b/core/clear_vars.mk
index ee28f21..bc085f5 100644
--- a/core/clear_vars.mk
+++ b/core/clear_vars.mk
@@ -27,6 +27,8 @@
 LOCAL_PREBUILT_OBJ_FILES:=
 LOCAL_STATIC_JAVA_LIBRARIES:=
 LOCAL_STATIC_LIBRARIES:=
+# Group static libraries with "-Wl,--start-group" and "-Wl,--end-group" when linking.
+LOCAL_GROUP_STATIC_LIBRARIES:=
 LOCAL_WHOLE_STATIC_LIBRARIES:=
 LOCAL_SHARED_LIBRARIES:=
 LOCAL_IS_HOST_MODULE:=
@@ -40,10 +42,12 @@
 LOCAL_ASFLAGS:=
 LOCAL_CFLAGS:=
 LOCAL_CPPFLAGS:=
+LOCAL_RTTI_FLAG:=
 LOCAL_C_INCLUDES:=
 LOCAL_LDFLAGS:=
 LOCAL_LDLIBS:=
 LOCAL_AAPT_FLAGS:=
+LOCAL_AAPT_INCLUDE_ALL_RESOURCES:=
 LOCAL_SYSTEM_SHARED_LIBRARIES:=none
 LOCAL_PREBUILT_LIBS:=
 LOCAL_PREBUILT_EXECUTABLES:=
@@ -74,11 +78,11 @@
 LOCAL_COPY_HEADERS:=
 LOCAL_FORCE_STATIC_EXECUTABLE:=
 LOCAL_ADDITIONAL_DEPENDENCIES:=
-LOCAL_PRELINK_MODULE:=
 LOCAL_COMPRESS_MODULE_SYMBOLS:=
 LOCAL_STRIP_MODULE:=
 LOCAL_POST_PROCESS_COMMAND:=true
 LOCAL_JNI_SHARED_LIBRARIES:=
+LOCAL_JNI_SHARED_LIBRARIES_ABI:=
 LOCAL_JAR_MANIFEST:=
 LOCAL_INSTRUMENTATION_FOR:=
 LOCAL_MANIFEST_INSTRUMENTATION_FOR:=
@@ -90,15 +94,22 @@
 LOCAL_CERTIFICATE:=
 LOCAL_SDK_VERSION:=
 LOCAL_NDK_VERSION:=
+LOCAL_NDK_STL_VARIANT:=
 LOCAL_NO_EMMA_INSTRUMENT:=
 LOCAL_NO_EMMA_COMPILE:=
-LOCAL_PROGUARD_ENABLED:= # '',optonly,full,custom
+LOCAL_PROGUARD_ENABLED:= # '',optonly,full,custom,disabled
 LOCAL_PROGUARD_FLAGS:=
 LOCAL_PROGUARD_FLAG_FILES:=
 LOCAL_EMMA_COVERAGE_FILTER:=
+LOCAL_WARNINGS_ENABLE:=
 LOCAL_MANIFEST_FILE:=
+LOCAL_RENDERSCRIPT_INCLUDES:=
+LOCAL_RENDERSCRIPT_CC:=
 LOCAL_BUILD_HOST_DEX:=
 LOCAL_DEX_PREOPT:=
+LOCAL_PROTOC_OPTIMIZE_TYPE:= # lite(default),micro,full
+LOCAL_PROTOC_FLAGS:=
+LOCAL_NO_CRT:=
 
 # Trim MAKEFILE_LIST so that $(call my-dir) doesn't need to
 # iterate over thousands of entries every time.
diff --git a/core/combo/HOST_darwin-x86.mk b/core/combo/HOST_darwin-x86.mk
index 093ecbe..544a29e 100644
--- a/core/combo/HOST_darwin-x86.mk
+++ b/core/combo/HOST_darwin-x86.mk
@@ -45,6 +45,8 @@
 HOST_CC := $(CC)
 HOST_CXX := $(CXX)
 HOST_AR := $(AR)
+HOST_STRIP := $(STRIP)
+HOST_STRIP_COMMAND = $(HOST_STRIP) --strip-debug $< -o $@
 
 HOST_SHLIB_SUFFIX := .dylib
 HOST_JNILIB_SUFFIX := .jnilib
@@ -57,14 +59,16 @@
 HOST_CUSTOM_LD_COMMAND := true
 
 define transform-host-o-to-shared-lib-inner
-    $(HOST_CXX) \
+$(hide) $(PRIVATE_CXX) \
         -dynamiclib -single_module -read_only_relocs suppress \
         $(HOST_GLOBAL_LD_DIRS) \
         $(HOST_GLOBAL_LDFLAGS) \
         $(PRIVATE_ALL_OBJECTS) \
-        $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
-        $(call normalize-target-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
-        $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
+        $(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
+        $(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
+        $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
+        $(call normalize-host-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
+        $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
         $(PRIVATE_LDLIBS) \
         -o $@ \
         $(PRIVATE_LDFLAGS) \
@@ -72,15 +76,17 @@
 endef
 
 define transform-host-o-to-executable-inner
-$(HOST_CXX) \
+$(hide) $(PRIVATE_CXX) \
         -o $@ \
         -Wl,-dynamic -headerpad_max_install_names \
         $(HOST_GLOBAL_LD_DIRS) \
         $(HOST_GLOBAL_LDFLAGS) \
-        $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
+        $(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
         $(PRIVATE_ALL_OBJECTS) \
-        $(call normalize-target-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
-        $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
+        $(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
+        $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
+        $(call normalize-host-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
+        $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
         $(PRIVATE_LDFLAGS) \
         $(PRIVATE_LDLIBS) \
         $(HOST_LIBGCC)
diff --git a/core/combo/TARGET_linux-arm.mk b/core/combo/TARGET_linux-arm.mk
index ae1997c..ea28ca5 100644
--- a/core/combo/TARGET_linux-arm.mk
+++ b/core/combo/TARGET_linux-arm.mk
@@ -44,22 +44,27 @@
 # You can set TARGET_TOOLS_PREFIX to get gcc from somewhere else
 ifeq ($(strip $(TARGET_TOOLS_PREFIX)),)
 TARGET_TOOLS_PREFIX := \
-	prebuilt/$(HOST_PREBUILT_TAG)/toolchain/arm-eabi-4.4.3/bin/arm-eabi-
+	prebuilt/$(HOST_PREBUILT_TAG)/toolchain/arm-linux-androideabi-4.4.x/bin/arm-linux-androideabi-
 endif
 
-TARGET_CC := $(TARGET_TOOLS_PREFIX)gcc$(HOST_EXECUTABLE_SUFFIX)
-TARGET_CXX := $(TARGET_TOOLS_PREFIX)g++$(HOST_EXECUTABLE_SUFFIX)
-TARGET_AR := $(TARGET_TOOLS_PREFIX)ar$(HOST_EXECUTABLE_SUFFIX)
-TARGET_OBJCOPY := $(TARGET_TOOLS_PREFIX)objcopy$(HOST_EXECUTABLE_SUFFIX)
-TARGET_LD := $(TARGET_TOOLS_PREFIX)ld$(HOST_EXECUTABLE_SUFFIX)
+# Only define these if there's actually a gcc in there.
+# The gcc toolchain does not exists for windows/cygwin. In this case, do not reference it.
+ifneq ($(wildcard $(TARGET_TOOLS_PREFIX)gcc$(HOST_EXECUTABLE_SUFFIX)),)
+    TARGET_CC := $(TARGET_TOOLS_PREFIX)gcc$(HOST_EXECUTABLE_SUFFIX)
+    TARGET_CXX := $(TARGET_TOOLS_PREFIX)g++$(HOST_EXECUTABLE_SUFFIX)
+    TARGET_AR := $(TARGET_TOOLS_PREFIX)ar$(HOST_EXECUTABLE_SUFFIX)
+    TARGET_OBJCOPY := $(TARGET_TOOLS_PREFIX)objcopy$(HOST_EXECUTABLE_SUFFIX)
+    TARGET_LD := $(TARGET_TOOLS_PREFIX)ld$(HOST_EXECUTABLE_SUFFIX)
+    TARGET_STRIP := $(TARGET_TOOLS_PREFIX)strip$(HOST_EXECUTABLE_SUFFIX)
+    TARGET_STRIP_COMMAND = $(TARGET_STRIP) --strip-all $< -o $@
+endif
 
 TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined
 
 TARGET_arm_CFLAGS :=    -O2 \
                         -fomit-frame-pointer \
                         -fstrict-aliasing    \
-                        -funswitch-loops     \
-                        -finline-limit=300
+                        -funswitch-loops
 
 # Modules can choose to compile some source as thumb. As
 # non-thumb enabled targets are supported, this is treated
@@ -69,8 +74,7 @@
 TARGET_thumb_CFLAGS :=  -mthumb \
                         -Os \
                         -fomit-frame-pointer \
-                        -fno-strict-aliasing \
-                        -finline-limit=64
+                        -fno-strict-aliasing
 else
 TARGET_thumb_CFLAGS := $(TARGET_arm_CFLAGS)
 endif
@@ -95,6 +99,7 @@
 TARGET_GLOBAL_CFLAGS += \
 			-msoft-float -fpic \
 			-ffunction-sections \
+			-fdata-sections \
 			-funwind-tables \
 			-fstack-protector \
 			-Wa,--noexecstack \
@@ -116,6 +121,7 @@
 
 TARGET_GLOBAL_LDFLAGS += \
 			-Wl,-z,noexecstack \
+			-Wl,--icf=safe \
 			$(arch_variant_ldflags)
 
 # We only need thumb interworking in cases where thumb support
@@ -130,12 +136,11 @@
 
 TARGET_GLOBAL_CPPFLAGS += -fvisibility-inlines-hidden
 
+# More flags/options can be added here
 TARGET_RELEASE_CFLAGS := \
 			-DNDEBUG \
 			-g \
 			-Wstrict-aliasing=2 \
-			-finline-functions \
-			-fno-inline-functions-called-once \
 			-fgcse-after-reload \
 			-frerun-cse-after-loop \
 			-frename-registers
@@ -204,7 +209,7 @@
 	$(libstdc++_root)/include \
 	$(KERNEL_HEADERS) \
 	$(libm_root)/include \
-	$(libm_root)/include/arch/arm \
+	$(libm_root)/include/arm \
 	$(libthread_db_root)/include
 
 TARGET_CRTBEGIN_STATIC_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_static.o
@@ -226,28 +231,30 @@
 endif
 
 define transform-o-to-shared-lib-inner
-$(TARGET_CXX) \
+$(hide) $(PRIVATE_CXX) \
 	-nostdlib -Wl,-soname,$(notdir $@) -Wl,-T,$(BUILD_SYSTEM)/armelf.xsc \
 	-Wl,--gc-sections \
 	-Wl,-shared,-Bsymbolic \
 	$(PRIVATE_TARGET_GLOBAL_LD_DIRS) \
 	$(PRIVATE_ALL_OBJECTS) \
-	$(PRIVATE_TARGET_CRTBEGIN_SO_O) \
+	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTBEGIN_SO_O)) \
 	-Wl,--whole-archive \
-	$(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
+	$(call normalize-target-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
 	-Wl,--no-whole-archive \
+	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
 	$(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
+	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
 	$(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
 	-o $@ \
 	$(PRIVATE_TARGET_GLOBAL_LDFLAGS) \
 	$(PRIVATE_LDFLAGS) \
 	$(PRIVATE_TARGET_FDO_LIB) \
 	$(PRIVATE_TARGET_LIBGCC) \
-	$(PRIVATE_TARGET_CRTEND_SO_O)
+	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_SO_O))
 endef
 
 define transform-o-to-executable-inner
-$(TARGET_CXX) -nostdlib -Bdynamic -Wl,-T,$(BUILD_SYSTEM)/armelf.x \
+$(hide) $(PRIVATE_CXX) -nostdlib -Bdynamic -Wl,-T,$(BUILD_SYSTEM)/armelf.x \
 	-Wl,-dynamic-linker,/system/bin/linker \
     -Wl,--gc-sections \
 	-Wl,-z,nocopyreloc \
@@ -255,27 +262,33 @@
 	$(TARGET_GLOBAL_LD_DIRS) \
 	-Wl,-rpath-link=$(TARGET_OUT_INTERMEDIATE_LIBRARIES) \
 	$(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
-	$(TARGET_CRTBEGIN_DYNAMIC_O) \
+	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTBEGIN_DYNAMIC_O)) \
 	$(PRIVATE_ALL_OBJECTS) \
+	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
 	$(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
+	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
 	$(TARGET_GLOBAL_LDFLAGS) \
 	$(PRIVATE_LDFLAGS) \
 	$(TARGET_FDO_LIB) \
 	$(TARGET_LIBGCC) \
-	$(TARGET_CRTEND_O)
+	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTEND_O))
 endef
 
 define transform-o-to-static-executable-inner
-$(TARGET_CXX) -nostdlib -Bstatic -Wl,-T,$(BUILD_SYSTEM)/armelf.x \
+$(hide) $(PRIVATE_CXX) -nostdlib -Bstatic -Wl,-T,$(BUILD_SYSTEM)/armelf.x \
     -Wl,--gc-sections \
 	-o $@ \
 	$(TARGET_GLOBAL_LD_DIRS) \
-	$(TARGET_CRTBEGIN_STATIC_O) \
+	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTBEGIN_STATIC_O)) \
 	$(TARGET_GLOBAL_LDFLAGS) \
 	$(PRIVATE_LDFLAGS) \
 	$(PRIVATE_ALL_OBJECTS) \
-	$(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
+	$(call normalize-target-libraries,$(filter-out %libc_nomalloc.a,$(filter-out %libc.a,$(PRIVATE_ALL_STATIC_LIBRARIES)))) \
+	-Wl,--start-group \
+	$(call normalize-target-libraries,$(filter %libc.a,$(PRIVATE_ALL_STATIC_LIBRARIES))) \
+	$(call normalize-target-libraries,$(filter %libc_nomalloc.a,$(PRIVATE_ALL_STATIC_LIBRARIES))) \
 	$(TARGET_FDO_LIB) \
 	$(TARGET_LIBGCC) \
-	$(TARGET_CRTEND_O)
+	-Wl,--end-group \
+	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTEND_O))
 endef
diff --git a/core/combo/TARGET_linux-sh.mk b/core/combo/TARGET_linux-sh.mk
index f373d21d..f54a49e 100644
--- a/core/combo/TARGET_linux-sh.mk
+++ b/core/combo/TARGET_linux-sh.mk
@@ -28,6 +28,8 @@
 TARGET_AR := $(TARGET_TOOLS_PREFIX)ar$(HOST_EXECUTABLE_SUFFIX)
 TARGET_OBJCOPY := $(TARGET_TOOLS_PREFIX)objcopy$(HOST_EXECUTABLE_SUFFIX)
 TARGET_LD := $(TARGET_TOOLS_PREFIX)ld$(HOST_EXECUTABLE_SUFFIX)
+TARGET_STRIP := $(TARGET_TOOLS_PREFIX)strip$(HOST_EXECUTABLE_SUFFIX)
+TARGET_STRIP_COMMAND = $(TARGET_STRIP) --strip-debug $< -o $@
 
 TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined
 
@@ -97,42 +99,45 @@
 	$(libstdc++_root)/include \
 	$(KERNEL_HEADERS) \
 	$(libm_root)/include \
-	$(libm_root)/include/arch/sh \
+	$(libm_root)/include/sh \
 	$(libthread_db_root)/include
 
 TARGET_CRTBEGIN_STATIC_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_static.o
 TARGET_CRTBEGIN_DYNAMIC_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_dynamic.o
 TARGET_CRTEND_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_android.o
+
 TARGET_CRTBEGIN_SO_O := $(TARGET_OUT_STATIC_LIBRARIES)/sobegin.o
 TARGET_CRTEND_SO_O := $(TARGET_OUT_STATIC_LIBRARIES)/soend.o
 
-TARGET_STRIP_MODULE:=false
+TARGET_STRIP_MODULE:=true
 
 TARGET_DEFAULT_SYSTEM_SHARED_LIBRARIES := libc libstdc++ libm
 
 TARGET_CUSTOM_LD_COMMAND := true
 define transform-o-to-shared-lib-inner
-$(TARGET_CXX) \
+$(hide) $(PRIVATE_CXX) \
 	-nostdlib -Wl,-soname,$(notdir $@) -Wl,-T,$(BUILD_SYSTEM)/shlelf.xsc \
 	-Wl,--gc-sections -Wl,-z,norelro \
 	-Wl,-shared,-Bsymbolic \
 	$(PRIVATE_TARGET_GLOBAL_LD_DIRS) \
-	$(PRIVATE_TARGET_CRTBEGIN_SO_O) \
+	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTBEGIN_SO_O)) \
 	$(PRIVATE_ALL_OBJECTS) \
 	-Wl,--whole-archive \
-	$(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
+	$(call normalize-target-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
 	-Wl,--no-whole-archive \
+	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
 	$(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
+	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
 	$(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
 	-o $@ \
 	$(PRIVATE_LDFLAGS) \
 	$(subst -lrt,, $(subst -lpthread,,$(PRIVATE_LDLIBS))) \
 	$(PRIVATE_TARGET_LIBGCC) \
-	$(PRIVATE_TARGET_CRTEND_SO_O)
+	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_SO_O))
 endef
 
 define transform-o-to-executable-inner
-$(TARGET_CXX) -nostdlib -Bdynamic  -Wl,-T,$(BUILD_SYSTEM)/shlelf.x \
+$(hide) $(PRIVATE_CXX) -nostdlib -Bdynamic  -Wl,-T,$(BUILD_SYSTEM)/shlelf.x \
 	-Wl,-dynamic-linker,/system/bin/linker \
 	-Wl,--gc-sections -Wl,-z,norelro \
 	-Wl,-z,nocopyreloc \
@@ -140,25 +145,29 @@
 	$(TARGET_GLOBAL_LD_DIRS) \
 	-Wl,-rpath-link=$(TARGET_OUT_INTERMEDIATE_LIBRARIES) \
 	$(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
-	$(TARGET_CRTBEGIN_DYNAMIC_O) \
+	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTBEGIN_DYNAMIC_O)) \
 	$(PRIVATE_ALL_OBJECTS) \
+	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
 	$(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
+	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
 	$(PRIVATE_LDFLAGS) \
 	$(TARGET_LIBGCC) \
 	$(subst -lrt,, $(subst -lpthread,,$(PRIVATE_LDLIBS))) \
-	$(TARGET_CRTEND_O)
+	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTEND_O))
 endef
 
 define transform-o-to-static-executable-inner
-$(TARGET_CXX) -nostdlib -Bstatic  -Wl,-T,$(BUILD_SYSTEM)/shlelf.x \
+$(hide) $(PRIVATE_CXX) -nostdlib -Bstatic  -Wl,-T,$(BUILD_SYSTEM)/shlelf.x \
 	-Wl,--gc-sections -Wl,-z,norelro \
 	-o $@ \
 	$(TARGET_GLOBAL_LD_DIRS) \
-	$(TARGET_CRTBEGIN_STATIC_O) \
+	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTBEGIN_STATIC_O)) \
 	$(PRIVATE_LDFLAGS) \
 	$(PRIVATE_ALL_OBJECTS) \
+	-Wl,--start-group \
 	$(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
+	-Wl,--end-group \
 	$(TARGET_LIBGCC) \
 	$(subst -lrt,, $(subst -lpthread,,$(PRIVATE_LDLIBS))) \
-	$(TARGET_CRTEND_O)
+	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTEND_O))
 endef
diff --git a/core/combo/TARGET_linux-x86.mk b/core/combo/TARGET_linux-x86.mk
index 6629cbd..d8056e3 100644
--- a/core/combo/TARGET_linux-x86.mk
+++ b/core/combo/TARGET_linux-x86.mk
@@ -25,7 +25,9 @@
 TARGET_GLOBAL_CFLAGS := $(HOST_GLOBAL_CFLAGS) -m32
 TARGET_GLOBAL_LDFLAGS := $(HOST_GLOBAL_LDFLAGS) -m32 -lpthread
 TARGET_NO_UNDEFINED_LDFLAGS := $(HOST_NO_UNDEFINED_LDFLAGS)
+ifeq ($(strip $(TARGET_ARCH_VARIANT)),)
 TARGET_ARCH_VARIANT := x86
+endif
 else #simulator
 
 # Provide a default variant.
@@ -36,7 +38,7 @@
 # You can set TARGET_TOOLS_PREFIX to get gcc from somewhere else
 ifeq ($(strip $(TARGET_TOOLS_PREFIX)),)
 TARGET_TOOLS_PREFIX := \
-	prebuilt/$(HOST_PREBUILT_TAG)/toolchain/i686-unknown-linux-gnu-4.2.1/bin/i686-unknown-linux-gnu-
+	prebuilt/$(HOST_PREBUILT_TAG)/toolchain/i686-android-linux-4.4.3/bin/i686-android-linux-
 endif
 
 TARGET_CC := $(TARGET_TOOLS_PREFIX)gcc$(HOST_EXECUTABLE_SUFFIX)
@@ -44,11 +46,12 @@
 TARGET_AR := $(TARGET_TOOLS_PREFIX)ar$(HOST_EXECUTABLE_SUFFIX)
 TARGET_OBJCOPY := $(TARGET_TOOLS_PREFIX)objcopy$(HOST_EXECUTABLE_SUFFIX)
 TARGET_LD := $(TARGET_TOOLS_PREFIX)ld$(HOST_EXECUTABLE_SUFFIX)
+TARGET_STRIP := $(TARGET_TOOLS_PREFIX)strip$(HOST_EXECUTABLE_SUFFIX)
+TARGET_STRIP_COMMAND = $(TARGET_STRIP) --strip-debug $< -o $@
 
 ifneq ($(wildcard $(TARGET_CC)),)
 TARGET_LIBGCC := \
-	$(shell $(TARGET_CC) -m32 -print-file-name=libgcc.a) \
-        $(shell $(TARGET_CC) -m32 -print-file-name=libgcc_eh.a)
+	$(shell $(TARGET_CC) -m32 -print-file-name=libgcc.a)
 endif
 
 TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined
@@ -72,14 +75,50 @@
 KERNEL_HEADERS := $(KERNEL_HEADERS_COMMON) $(KERNEL_HEADERS_ARCH)
 
 TARGET_GLOBAL_CFLAGS += \
-			-march=i686 \
-			-m32 \
+			-O2 \
+			-Ulinux \
+			-Wa,--noexecstack \
+			-Werror=format-security \
+			-Wstrict-aliasing=2 \
 			-fPIC \
+			-ffunction-sections \
+			-finline-functions \
+			-finline-limit=300 \
+			-fno-inline-functions-called-once \
+			-fno-short-enums \
+			-fstrict-aliasing \
+			-funswitch-loops \
+			-funwind-tables \
 			-include $(call select-android-config-h,target_linux-x86)
 
+# Needs to be fixed later
+#TARGET_GLOBAL_CFLAGS += \
+#			-fstack-protector
+
+# Needs to be added for RELEASE
+#TARGET_GLOBAL_CFLAGS += \
+#			-DNDEBUG
+
+
+# Fix this after ssp.c is fixed for x86
+# TARGET_GLOBAL_CFLAGS += -fstack-protector
+
 TARGET_GLOBAL_CPPFLAGS += \
 			-fno-use-cxa-atexit
 
+ifeq ($(TARGET_ARCH_VARIANT),x86-atom)
+    TARGET_GLOBAL_CFLAGS += -march=atom -mstackrealign -DUSE_SSSE3 -DUSE_SSE2 -mfpmath=sse
+else
+    TARGET_GLOBAL_CFLAGS += -march=i686
+endif
+
+TARGET_GLOBAL_CFLAGS += -mbionic
+TARGET_GLOBAL_CFLAGS += -D__ANDROID__
+
+TARGET_GLOBAL_LDFLAGS += -m32
+TARGET_GLOBAL_LDFLAGS += -Wl,-z,noexecstack
+TARGET_GLOBAL_LDFLAGS += -Wl,--gc-sections
+
 TARGET_C_INCLUDES := \
 	$(libc_root)/arch-x86/include \
 	$(libc_root)/include \
@@ -93,38 +132,39 @@
 TARGET_CRTBEGIN_DYNAMIC_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_dynamic.o
 TARGET_CRTEND_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_android.o
 
-
 TARGET_CRTBEGIN_SO_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_so.o
 TARGET_CRTEND_SO_O := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_so.o
 
-# TARGET_STRIP_MODULE:=true
+TARGET_STRIP_MODULE:=true
 
 TARGET_DEFAULT_SYSTEM_SHARED_LIBRARIES := libc libstdc++ libm
 
 TARGET_CUSTOM_LD_COMMAND := true
 define transform-o-to-shared-lib-inner
-$(TARGET_CXX) \
+$(hide) $(PRIVATE_CXX) \
 	$(PRIVATE_TARGET_GLOBAL_LDFLAGS) \
 	 -nostdlib -Wl,-soname,$(notdir $@) \
 	 -shared -Bsymbolic \
-	-fPIC -march=i686 \
+	$(TARGET_GLOBAL_CFLAGS) \
 	$(PRIVATE_TARGET_GLOBAL_LD_DIRS) \
-	$(PRIVATE_TARGET_CRTBEGIN_SO_O) \
+	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTBEGIN_SO_O)) \
 	$(PRIVATE_ALL_OBJECTS) \
 	-Wl,--whole-archive \
-	$(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
+	$(call normalize-target-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
 	-Wl,--no-whole-archive \
+	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
 	$(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
+	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
 	$(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
 	-o $@ \
 	$(PRIVATE_LDFLAGS) \
 	$(PRIVATE_TARGET_LIBGCC) \
-	$(PRIVATE_TARGET_CRTEND_SO_O)
+	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_SO_O))
 endef
 
 
 define transform-o-to-executable-inner
-$(TARGET_CXX) \
+$(hide) $(PRIVATE_CXX) \
 	$(TARGET_GLOBAL_LDFLAGS) \
 	-nostdlib -Bdynamic \
 	-Wl,-dynamic-linker,/system/bin/linker \
@@ -133,31 +173,30 @@
 	$(TARGET_GLOBAL_LD_DIRS) \
 	-Wl,-rpath-link=$(TARGET_OUT_INTERMEDIATE_LIBRARIES) \
 	$(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
-	$(TARGET_CRTBEGIN_DYNAMIC_O) \
+	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTBEGIN_DYNAMIC_O)) \
 	$(PRIVATE_ALL_OBJECTS) \
+	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
 	$(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
+	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
 	$(PRIVATE_LDFLAGS) \
 	$(TARGET_LIBGCC) \
-	$(TARGET_CRTEND_O)
+	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTEND_O))
 endef
 
 define transform-o-to-static-executable-inner
-$(TARGET_CXX) \
+$(hide) $(PRIVATE_CXX) \
 	$(TARGET_GLOBAL_LDFLAGS) \
 	-nostdlib -Bstatic \
 	-o $@ \
 	$(TARGET_GLOBAL_LD_DIRS) \
-	$(TARGET_CRTBEGIN_STATIC_O) \
+	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTBEGIN_STATIC_O)) \
 	$(PRIVATE_LDFLAGS) \
 	$(PRIVATE_ALL_OBJECTS) \
 	-Wl,--start-group \
 	$(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
 	$(TARGET_LIBGCC) \
 	-Wl,--end-group \
-	$(TARGET_CRTEND_O)
+	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(TARGET_CRTEND_O))
 endef
 
-TARGET_GLOBAL_CFLAGS += -m32
-TARGET_GLOBAL_LDFLAGS += -m32
-
 endif #simulator
diff --git a/core/combo/javac.mk b/core/combo/javac.mk
index d4c04e7..f8c99fb 100644
--- a/core/combo/javac.mk
+++ b/core/combo/javac.mk
@@ -8,7 +8,7 @@
 #   COMMON_JAVAC -- Java compiler command with common arguments
 
 # Whatever compiler is on this system.
-ifeq ($(HOST_OS), windows)
+ifeq ($(BUILD_OS), windows)
     COMMON_JAVAC := development/host/windows/prebuilt/javawrap.exe -J-Xmx256m \
         -target 1.5 -Xmaxerrs 9999999
 else
diff --git a/core/combo/select.mk b/core/combo/select.mk
index 797c573..cdeb68a 100644
--- a/core/combo/select.mk
+++ b/core/combo/select.mk
@@ -28,6 +28,7 @@
 $(combo_target)CC := $(CC)
 $(combo_target)CXX := $(CXX)
 $(combo_target)AR := $(AR)
+$(combo_target)STRIP := $(STRIP)
 
 $(combo_target)BINDER_MINI := 0
 
@@ -55,19 +56,27 @@
 $(combo_target)JNILIB_SUFFIX := $($(combo_target)SHLIB_SUFFIX)
 $(combo_target)STATIC_LIB_SUFFIX := .a
 
-$(combo_target)PRELINKER_MAP := $(BUILD_SYSTEM)/prelink-$(combo_os_arch).map
-
 # Now include the combo for this specific target.
 include $(BUILD_COMBOS)/$(combo_target)$(combo_os_arch).mk
 
 ifneq ($(USE_CCACHE),)
-  ccache := prebuilt/$(HOST_PREBUILT_TAG)/ccache/ccache
-  # prepend ccache if necessary
-  ifneq ($(ccache),$(firstword $($(combo_target)CC)))
-    $(combo_target)CC := $(ccache) $($(combo_target)CC)
+  CCACHE_HOST_TAG := $(HOST_PREBUILT_TAG)
+  # If we are cross-compiling Windows binaries on Linux
+  # then use the linux ccache binary instead.
+  ifeq ($(HOST_OS)-$(BUILD_OS),windows-linux)
+    CCACHE_HOST_TAG := linux-$(BUILD_ARCH)
   endif
-  ifneq ($(ccache),$(firstword $($(combo_target)CXX)))
-    $(combo_target)CXX := $(ccache) $($(combo_target)CXX)
+  ccache := prebuilt/$(CCACHE_HOST_TAG)/ccache/ccache
+  # Check that the executable is here.
+  ccache := $(strip $(wildcard $(ccache)))
+  ifdef ccache
+    # prepend ccache if necessary
+    ifneq ($(ccache),$(firstword $($(combo_target)CC)))
+      $(combo_target)CC := $(ccache) $($(combo_target)CC)
+    endif
+    ifneq ($(ccache),$(firstword $($(combo_target)CXX)))
+      $(combo_target)CXX := $(ccache) $($(combo_target)CXX)
+    endif
+    ccache =
   endif
-  ccache =
 endif
diff --git a/core/config.mk b/core/config.mk
index f8bee80..82238e9 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -61,6 +61,7 @@
 BUILD_RAW_EXECUTABLE:= $(BUILD_SYSTEM)/raw_executable.mk
 BUILD_HOST_EXECUTABLE:= $(BUILD_SYSTEM)/host_executable.mk
 BUILD_PACKAGE:= $(BUILD_SYSTEM)/package.mk
+BUILD_PHONY_PACKAGE:= $(BUILD_SYSTEM)/phony_package.mk
 BUILD_HOST_PREBUILT:= $(BUILD_SYSTEM)/host_prebuilt.mk
 BUILD_PREBUILT:= $(BUILD_SYSTEM)/prebuilt.mk
 BUILD_MULTI_PREBUILT:= $(BUILD_SYSTEM)/multi_prebuilt.mk
@@ -69,7 +70,8 @@
 BUILD_HOST_JAVA_LIBRARY:= $(BUILD_SYSTEM)/host_java_library.mk
 BUILD_DROIDDOC:= $(BUILD_SYSTEM)/droiddoc.mk
 BUILD_COPY_HEADERS := $(BUILD_SYSTEM)/copy_headers.mk
-BUILD_KEY_CHAR_MAP := $(BUILD_SYSTEM)/key_char_map.mk
+BUILD_NATIVE_TEST := $(BUILD_SYSTEM)/native_test.mk
+BUILD_HOST_NATIVE_TEST := $(BUILD_SYSTEM)/host_native_test.mk
 
 # ###############################################################
 # Parse out any modifier targets.
@@ -103,8 +105,8 @@
 # TODO: do symbol compression
 TARGET_COMPRESS_MODULE_SYMBOLS := false
 
-# Default is to prelink modules.
-TARGET_PRELINK_MODULE := true
+# Default shell is mksh. Other possible value is ash.
+TARGET_SHELL := mksh
 
 # ###############################################################
 # Include sub-configuration files
@@ -197,6 +199,7 @@
 DOXYGEN:= doxygen
 AAPT := $(HOST_OUT_EXECUTABLES)/aapt$(HOST_EXECUTABLE_SUFFIX)
 AIDL := $(HOST_OUT_EXECUTABLES)/aidl$(HOST_EXECUTABLE_SUFFIX)
+PROTOC := $(HOST_OUT_EXECUTABLES)/aprotoc$(HOST_EXECUTABLE_SUFFIX)
 ICUDATA := $(HOST_OUT_EXECUTABLES)/icudata$(HOST_EXECUTABLE_SUFFIX)
 SIGNAPK_JAR := $(HOST_OUT_JAVA_LIBRARIES)/signapk$(COMMON_JAVA_PACKAGE_SUFFIX)
 MKBOOTFS := $(HOST_OUT_EXECUTABLES)/mkbootfs$(HOST_EXECUTABLE_SUFFIX)
@@ -207,14 +210,16 @@
 FS_GET_STATS := $(HOST_OUT_EXECUTABLES)/fs_get_stats$(HOST_EXECUTABLE_SUFFIX)
 MKEXT2IMG := $(HOST_OUT_EXECUTABLES)/genext2fs$(HOST_EXECUTABLE_SUFFIX)
 MAKE_EXT4FS := $(HOST_OUT_EXECUTABLES)/make_ext4fs$(HOST_EXECUTABLE_SUFFIX)
-MKEXT2USERIMG := $(HOST_OUT_EXECUTABLES)/mkuserimg.sh
+MKEXTUSERIMG := $(HOST_OUT_EXECUTABLES)/mkuserimg.sh
 MKEXT2BOOTIMG := external/genext2fs/mkbootimg_ext2.sh
 MKTARBALL := build/tools/mktarball.sh
-TUNE2FS := tune2fs
-E2FSCK := e2fsck
+TUNE2FS := $(HOST_OUT_EXECUTABLES)/tune2fs$(HOST_EXECUTABLE_SUFFIX)
+E2FSCK := $(HOST_OUT_EXECUTABLES)/e2fsck$(HOST_EXECUTABLE_SUFFIX)
 JARJAR := $(HOST_OUT_JAVA_LIBRARIES)/jarjar.jar
 PROGUARD := external/proguard/bin/proguard.sh
 JAVATAGS := build/tools/java-event-log-tags.py
+LLVM_RS_CC := $(HOST_OUT_EXECUTABLES)/llvm-rs-cc$(HOST_EXECUTABLE_SUFFIX)
+LLVM_RS_LINK := $(HOST_OUT_EXECUTABLES)/llvm-rs-link$(HOST_EXECUTABLE_SUFFIX)
 DEXOPT := $(HOST_OUT_EXECUTABLES)/dexopt$(HOST_EXECUTABLE_SUFFIX)
 DEXPREOPT := dalvik/tools/dex-preopt
 
@@ -223,17 +228,11 @@
 
 # dx is java behind a shell script; no .exe necessary.
 DX := $(HOST_OUT_EXECUTABLES)/dx
-KCM := $(HOST_OUT_EXECUTABLES)/kcm$(HOST_EXECUTABLE_SUFFIX)
 ZIPALIGN := $(HOST_OUT_EXECUTABLES)/zipalign$(HOST_EXECUTABLE_SUFFIX)
 FINDBUGS := prebuilt/common/findbugs/bin/findbugs
 LOCALIZE := $(HOST_OUT_EXECUTABLES)/localize$(HOST_EXECUTABLE_SUFFIX)
 EMMA_JAR := external/emma/lib/emma$(COMMON_JAVA_PACKAGE_SUFFIX)
 
-# Binary prelinker/compressor tools
-APRIORI := $(HOST_OUT_EXECUTABLES)/apriori$(HOST_EXECUTABLE_SUFFIX)
-LSD := $(HOST_OUT_EXECUTABLES)/lsd$(HOST_EXECUTABLE_SUFFIX)
-SOSLIM := $(HOST_OUT_EXECUTABLES)/soslim$(HOST_EXECUTABLE_SUFFIX)
-
 # Deal with archaic version of bison on Mac OS X.
 ifeq ($(filter 1.28,$(shell $(YACC) -V)),)
 YACC_HEADER_SUFFIX:= .hpp
@@ -265,6 +264,10 @@
 HOST_JDK_TOOLS_JAR :=
 else
 HOST_JDK_TOOLS_JAR:= $(shell $(BUILD_SYSTEM)/find-jdk-tools-jar.sh)
+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)
+endif
 endif
 
 # Is the host JDK 64-bit version?
@@ -280,6 +283,11 @@
 MD5SUM:=md5sum
 endif
 
+APICHECK_CLASSPATH := $(HOST_JDK_TOOLS_JAR)
+APICHECK_CLASSPATH := $(APICHECK_CLASSPATH):$(HOST_OUT_JAVA_LIBRARIES)/doclava$(COMMON_JAVA_PACKAGE_SUFFIX)
+APICHECK_CLASSPATH := $(APICHECK_CLASSPATH):$(HOST_OUT_JAVA_LIBRARIES)/jsilver$(COMMON_JAVA_PACKAGE_SUFFIX)
+APICHECK_COMMAND := $(APICHECK) -JXmx1024m -J"classpath $(APICHECK_CLASSPATH)"
+
 # ###############################################################
 # Set up final options.
 # ###############################################################
@@ -352,4 +360,14 @@
     $(patsubst $(HISTORICAL_NDK_VERSIONS_ROOT)/android-ndk-r%,%, \
     $(wildcard $(HISTORICAL_NDK_VERSIONS_ROOT)/android-ndk-r*)))
 
-INTERNAL_PLATFORM_API_FILE := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/public_api.xml
+INTERNAL_PLATFORM_API_FILE := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/public_api.txt
+
+# This is the standard way to name a directory containing prebuilt target
+# objects. E.g., prebuilt/$(TARGET_PREBUILT_TAG)/libc.so
+ifeq ($(TARGET_SIMULATOR),true)
+  TARGET_PREBUILT_TAG := $(TARGET_OS)-$(TARGET_ARCH)
+else
+  TARGET_PREBUILT_TAG := android-$(TARGET_ARCH)
+endif
+
+include $(BUILD_SYSTEM)/dumpvar.mk
diff --git a/core/definitions.mk b/core/definitions.mk
index 11cea3f..4c499ad 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -66,7 +66,7 @@
 # These all have an order-only dependency on the copied headers
 ALL_C_CPP_ETC_OBJECTS:=
 
-# The list of dynamic binaries that haven't been stripped/compressed/prelinked.
+# The list of dynamic binaries that haven't been stripped/compressed/etc.
 ALL_ORIGINAL_DYNAMIC_BINARIES:=
 
 # These files go into the SDK
@@ -154,7 +154,7 @@
 
 # $(1): List of directories to look for under this directory
 define all-named-subdir-makefiles
-$(wildcard $(addsuffix /Android.mk, $(addprefix $(my-dir)/,$(1))))
+$(wildcard $(addsuffix /Android.mk, $(addprefix $(call my-dir)/,$(1))))
 endef
 
 ###########################################################
@@ -236,6 +236,32 @@
 endef
 
 ###########################################################
+## Find all of the .proto files under the named directories.
+## Meant to be used like:
+##    SRC_FILES := $(call all-proto-files-under,src)
+###########################################################
+
+define all-proto-files-under
+$(patsubst ./%,%, \
+  $(shell cd $(LOCAL_PATH) ; \
+          find $(1) -name "*.proto" -and -not -name ".*") \
+  )
+endef
+
+###########################################################
+## Find all of the RenderScript files under the named directories.
+##  Meant to be used like:
+##    SRC_FILES := $(call all-renderscript-files-under,src)
+###########################################################
+
+define all-renderscript-files-under
+$(patsubst ./%,%, \
+  $(shell cd $(LOCAL_PATH) ; \
+          find $(1) -name "*.rs" -and -not -name ".*") \
+  )
+endef
+
+###########################################################
 ## Find all of the html files under the named directories.
 ## Meant to be used like:
 ##    SRC_FILES := $(call all-html-files-under,src tests)
@@ -313,7 +339,7 @@
 
 define find-parent-file
 $(strip \
-  $(eval _fpf := $(wildcard $(strip $(1))/$(strip $(2)))) \
+  $(eval _fpf := $(wildcard $(foreach f, $(2), $(strip $(1))/$(f)))) \
   $(if $(_fpf),$(_fpf), \
        $(if $(filter-out ./ .,$(1)), \
              $(call find-parent-file,$(patsubst %/,%,$(dir $(1))),$(2)) \
@@ -510,6 +536,30 @@
 endef
 
 ###########################################################
+## Run rot13 on a string
+## $(1): the string.  Must be one line.
+###########################################################
+define rot13
+$(shell echo $(1) | tr 'a-zA-Z' 'n-za-mN-ZA-M')
+endef
+
+
+###########################################################
+## Returns true if $(1) and $(2) are equal.  Returns
+## the empty string if they are not equal.
+###########################################################
+define streq
+$(strip $(if $(strip $(1)),\
+  $(if $(strip $(2)),\
+    $(if $(filter-out __,_$(subst $(strip $(1)),,$(strip $(2)))$(subst $(strip $(2)),,$(strip $(1)))_),,true), \
+    ),\
+  $(if $(strip $(2)),\
+    ,\
+    true)\
+ ))
+endef
+
+###########################################################
 ## Convert "a b c" into "a:b:c"
 ###########################################################
 
@@ -550,6 +600,21 @@
 endef
 
 ###########################################################
+## Given a list of pairs, if multiple pairs have the same
+## first components, keep only the first pair.
+##
+## $(1): list of pairs
+## $(2): the separator word, such as ":", "=", etc.
+define uniq-pairs-by-first-component
+$(eval _upbfc_fc_set :=)\
+$(strip $(foreach w,$(1), $(eval _first := $(word 1,$(subst $(2),$(space),$(w))))\
+    $(if $(filter $(_upbfc_fc_set),$(_first)),,$(w)\
+        $(eval _upbfc_fc_set += $(_first)))))\
+$(eval _upbfc_fc_set :=)\
+$(eval _first:=)
+endef
+
+###########################################################
 ## MODULE_TAG set operations
 ###########################################################
 
@@ -666,6 +731,7 @@
 @echo PRIVATE_ALL_STATIC_LIBRARIES=$(PRIVATE_ALL_STATIC_LIBRARIES);
 @echo PRIVATE_ALL_WHOLE_STATIC_LIBRARIES=$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES);
 @echo PRIVATE_ALL_OBJECTS=$(PRIVATE_ALL_OBJECTS);
+@echo PRIVATE_NO_CRT=$(PRIVATE_NO_CRT);
 endef
 
 ###########################################################
@@ -685,7 +751,7 @@
 ###########################################################
 
 define transform-d-to-p
-@cp $(@:%.o=%.d) $(@:%.o=%.P); \
+$(hide) cp $(@:%.o=%.d) $(@:%.o=%.P); \
 	sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
 		-e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
 	rm -f $(@:%.o=%.d)
@@ -721,6 +787,28 @@
 rm -f $(@:$1=$(YACC_HEADER_SUFFIX))
 endef
 
+###########################################################
+## Commands to compile RenderScript
+###########################################################
+
+define transform-renderscripts-to-java-and-bc
+@echo "RenderScript: $(PRIVATE_MODULE) <= $(PRIVATE_RS_SOURCE_FILES)"
+$(hide) rm -rf $(PRIVATE_RS_OUTPUT_DIR)
+$(hide) mkdir -p $(PRIVATE_RS_OUTPUT_DIR)/res/raw
+$(hide) mkdir -p $(PRIVATE_RS_OUTPUT_DIR)/src
+$(hide) $(PRIVATE_RS_CC) \
+  -o $(PRIVATE_RS_OUTPUT_DIR)/res/raw \
+  -p $(PRIVATE_RS_OUTPUT_DIR)/src \
+  -d $(PRIVATE_RS_OUTPUT_DIR) \
+  -a $@ -MD \
+  $(foreach inc,$(PRIVATE_RS_INCLUDES),$(addprefix -I , $(inc))) \
+  $(PRIVATE_RS_SOURCE_FILES)
+#$(hide) $(LLVM_RS_LINK) \
+#  $(PRIVATE_RS_OUTPUT_DIR)/res/raw/*.bc
+$(hide) mkdir -p $(dir $@)
+$(hide) touch $@
+endef
+
 
 ###########################################################
 ## Commands for running aidl
@@ -746,6 +834,36 @@
 
 
 ###########################################################
+## Commands for running protoc to compile .proto into .java
+###########################################################
+
+define transform-proto-to-java
+@mkdir -p $(dir $@)
+@echo "Protoc: $@ <= $(PRIVATE_PROTO_SRC_FILES)"
+@rm -rf $(PRIVATE_PROTO_JAVA_OUTPUT_DIR)
+@mkdir -p $(PRIVATE_PROTO_JAVA_OUTPUT_DIR)
+$(hide) $(PROTOC) \
+	$(addprefix --proto_path=, $(PRIVATE_PROTO_INCLUDES)) \
+	$(PRIVATE_PROTO_JAVA_OUTPUT_OPTION)=$(PRIVATE_PROTO_JAVA_OUTPUT_DIR) \
+	$(PRIVATE_PROTOC_FLAGS) \
+	$(PRIVATE_PROTO_SRC_FILES)
+$(hide) touch $@
+endef
+
+######################################################################
+## Commands for running protoc to compile .proto into .pb.cc and .pb.h
+######################################################################
+define transform-proto-to-cc
+@mkdir -p $(dir $@)
+@echo "Protoc: $@ <= $<"
+$(hide) $(PROTOC) \
+	$(addprefix --proto_path=, $(PRIVATE_PROTO_INCLUDES)) \
+	$(PRIVATE_PROTOC_FLAGS) \
+	--cpp_out=$(PRIVATE_PROTO_CC_OUTPUT_DIR) $<
+endef
+
+
+###########################################################
 ## Commands for running gcc to compile a C++ file
 ###########################################################
 
@@ -753,27 +871,24 @@
 @mkdir -p $(dir $@)
 @echo "target $(PRIVATE_ARM_MODE) C++: $(PRIVATE_MODULE) <= $<"
 $(hide) $(PRIVATE_CXX) \
-	$(foreach incdir, \
-	    $(PRIVATE_C_INCLUDES) \
+	$(addprefix -I , $(PRIVATE_C_INCLUDES)) \
+	$(addprefix -isystem ,\
 	    $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
-		$(PRIVATE_TARGET_PROJECT_INCLUDES) \
-		$(PRIVATE_TARGET_C_INCLUDES) \
-	     ) \
-	  , \
-	    -I $(incdir) \
-	 ) \
+	        $(filter-out $(PRIVATE_C_INCLUDES), \
+	            $(PRIVATE_TARGET_PROJECT_INCLUDES) \
+	            $(PRIVATE_TARGET_C_INCLUDES)))) \
 	-c \
 	$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
 	    $(PRIVATE_TARGET_GLOBAL_CFLAGS) \
 	    $(PRIVATE_TARGET_GLOBAL_CPPFLAGS) \
 	    $(PRIVATE_ARM_CFLAGS) \
 	 ) \
-	-fno-rtti \
+	$(PRIVATE_RTTI_FLAG) \
 	$(PRIVATE_CFLAGS) \
 	$(PRIVATE_CPPFLAGS) \
 	$(PRIVATE_DEBUG_CFLAGS) \
 	-MD -o $@ $<
-$(hide) $(transform-d-to-p)
+$(transform-d-to-p)
 endef
 
 
@@ -785,15 +900,12 @@
 define transform-c-or-s-to-o-no-deps
 @mkdir -p $(dir $@)
 $(hide) $(PRIVATE_CC) \
-	$(foreach incdir, \
-	    $(PRIVATE_C_INCLUDES) \
+	$(addprefix -I , $(PRIVATE_C_INCLUDES)) \
+	$(addprefix -isystem ,\
 	    $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
-		$(PRIVATE_TARGET_PROJECT_INCLUDES) \
-		$(PRIVATE_TARGET_C_INCLUDES) \
-	     ) \
-	  , \
-	    -I $(incdir) \
-	 ) \
+	        $(filter-out $(PRIVATE_C_INCLUDES), \
+	            $(PRIVATE_TARGET_PROJECT_INCLUDES) \
+	            $(PRIVATE_TARGET_C_INCLUDES)))) \
 	-c \
 	$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
 	    $(PRIVATE_TARGET_GLOBAL_CFLAGS) \
@@ -817,12 +929,12 @@
 
 define transform-c-to-o
 $(transform-c-to-o-no-deps)
-$(hide) $(transform-d-to-p)
+$(transform-d-to-p)
 endef
 
 define transform-s-to-o
 $(transform-s-to-o-no-deps)
-$(hide) $(transform-d-to-p)
+$(transform-d-to-p)
 endef
 
 ###########################################################
@@ -838,7 +950,7 @@
 
 define transform-m-to-o
 $(transform-m-to-o-no-deps)
-$(hide) $(transform-d-to-p)
+$(transform-d-to-p)
 endef
 
 ###########################################################
@@ -849,15 +961,12 @@
 @mkdir -p $(dir $@)
 @echo "host C++: $(PRIVATE_MODULE) <= $<"
 $(hide) $(PRIVATE_CXX) \
-	$(foreach incdir, \
-	    $(PRIVATE_C_INCLUDES) \
+	$(addprefix -I , $(PRIVATE_C_INCLUDES)) \
+	$(addprefix -isystem ,\
 	    $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
-		$(HOST_PROJECT_INCLUDES) \
-		$(HOST_C_INCLUDES) \
-	     ) \
-	  , \
-	    -I $(incdir) \
-	 ) \
+	        $(filter-out $(PRIVATE_C_INCLUDES), \
+	            $(HOST_PROJECT_INCLUDES) \
+	            $(HOST_C_INCLUDES)))) \
 	-c \
 	$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
 	    $(HOST_GLOBAL_CFLAGS) \
@@ -879,15 +988,12 @@
 define transform-host-c-or-s-to-o-no-deps
 @mkdir -p $(dir $@)
 $(hide) $(PRIVATE_CC) \
-	$(foreach incdir, \
-	    $(PRIVATE_C_INCLUDES) \
+	$(addprefix -I , $(PRIVATE_C_INCLUDES)) \
+	$(addprefix -isystem ,\
 	    $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
-		$(HOST_PROJECT_INCLUDES) \
-		$(HOST_C_INCLUDES) \
-	     ) \
-	  , \
-	    -I $(incdir) \
-	 ) \
+	        $(filter-out $(PRIVATE_C_INCLUDES), \
+	            $(HOST_PROJECT_INCLUDES) \
+	            $(HOST_C_INCLUDES)))) \
 	-c \
 	$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
 	    $(HOST_GLOBAL_CFLAGS) \
@@ -927,7 +1033,7 @@
 $(call transform-host-c-or-s-to-o-no-deps)
 endef
 
-define tranform-host-m-to-o
+define transform-host-m-to-o
 $(transform-host-m-to-o-no-deps)
 $(transform-d-to-p)
 endef
@@ -936,19 +1042,42 @@
 ## Commands for running ar
 ###########################################################
 
+define _concat-if-arg2-not-empty
+$(if $(2),$(hide) $(1) $(2))
+endef
+
+# Split long argument list into smaller groups and call the command repeatedly
+#
+# $(1): the command without arguments
+# $(2): the arguments
+define split-long-arguments
+$(call _concat-if-arg2-not-empty,$(1),$(wordlist 1,500,$(2)))
+$(call _concat-if-arg2-not-empty,$(1),$(wordlist 501,1000,$(2)))
+$(call _concat-if-arg2-not-empty,$(1),$(wordlist 1001,1500,$(2)))
+$(call _concat-if-arg2-not-empty,$(1),$(wordlist 1501,2000,$(2)))
+$(call _concat-if-arg2-not-empty,$(1),$(wordlist 2001,2500,$(2)))
+$(call _concat-if-arg2-not-empty,$(1),$(wordlist 2501,3000,$(2)))
+$(call _concat-if-arg2-not-empty,$(1),$(wordlist 3001,99999,$(2)))
+endef
+
+# $(1): the full path of the source static library.
+define _extract-and-include-single-target-whole-static-lib
+@echo "preparing StaticLib: $(PRIVATE_MODULE) [including $(1)]"
+$(hide) ldir=$(PRIVATE_INTERMEDIATES_DIR)/WHOLE/$(basename $(notdir $(1)))_objs;\
+    rm -rf $$ldir; \
+    mkdir -p $$ldir; \
+    filelist=; \
+    for f in `$(TARGET_AR) t $(1)`; do \
+        $(TARGET_AR) p $(1) $$f > $$ldir/$$f; \
+        filelist="$$filelist $$ldir/$$f"; \
+    done ; \
+    $(TARGET_AR) $(TARGET_GLOBAL_ARFLAGS) $(PRIVATE_ARFLAGS) $@ $$filelist
+
+endef
+
 define extract-and-include-target-whole-static-libs
 $(foreach lib,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES), \
-	$(hide) echo "preparing StaticLib: $(PRIVATE_MODULE) [including $(lib)]"; \
-	ldir=$(PRIVATE_INTERMEDIATES_DIR)/WHOLE/$(basename $(notdir $(lib)))_objs;\
-	rm -rf $$ldir; \
-	mkdir -p $$ldir; \
-	filelist=; \
-	for f in `$(TARGET_AR) t $(lib)`; do \
-	    $(TARGET_AR) p $(lib) $$f > $$ldir/$$f; \
-	    filelist="$$filelist $$ldir/$$f"; \
-	done ; \
-	$(TARGET_AR) $(TARGET_GLOBAL_ARFLAGS) $(PRIVATE_ARFLAGS) $@ $$filelist;\
-)
+    $(call _extract-and-include-single-target-whole-static-lib, $(lib)))
 endef
 
 # Explicitly delete the archive first so that ar doesn't
@@ -958,27 +1087,31 @@
 @rm -f $@
 $(extract-and-include-target-whole-static-libs)
 @echo "target StaticLib: $(PRIVATE_MODULE) ($@)"
-$(hide) echo $(filter %.o, $^) | \
-    xargs $(TARGET_AR) $(TARGET_GLOBAL_ARFLAGS) $(PRIVATE_ARFLAGS) $@
+$(call split-long-arguments,$(TARGET_AR) $(TARGET_GLOBAL_ARFLAGS) $(PRIVATE_ARFLAGS) $@,$(filter %.o, $^))
 endef
 
 ###########################################################
 ## Commands for running host ar
 ###########################################################
 
+# $(1): the full path of the source static library.
+define _extract-and-include-single-host-whole-static-lib
+@echo "preparing StaticLib: $(PRIVATE_MODULE) [including $(1)]"
+$(hide) ldir=$(PRIVATE_INTERMEDIATES_DIR)/WHOLE/$(basename $(notdir $(1)))_objs;\
+    rm -rf $$ldir; \
+    mkdir -p $$ldir; \
+    filelist=; \
+    for f in `$(HOST_AR) t $(1) | grep '\.o$$'`; do \
+        $(HOST_AR) p $(1) $$f > $$ldir/$$f; \
+        filelist="$$filelist $$ldir/$$f"; \
+    done ; \
+    $(HOST_AR) $(HOST_GLOBAL_ARFLAGS) $(PRIVATE_ARFLAGS) $@ $$filelist
+
+endef
+
 define extract-and-include-host-whole-static-libs
 $(foreach lib,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES), \
-	@echo "preparing StaticLib: $(PRIVATE_MODULE) [including $(lib)]"; \
-	ldir=$(PRIVATE_INTERMEDIATES_DIR)/WHOLE/$(basename $(notdir $(lib)))_objs;\
-	rm -rf $$ldir; \
-	mkdir -p $$ldir; \
-	filelist=; \
-	for f in `$(HOST_AR) t $(lib) | grep '\.o$$'`; do \
-	    $(HOST_AR) p $(lib) $$f > $$ldir/$$f; \
-	    filelist="$$filelist $$ldir/$$f"; \
-	done ; \
-	$(HOST_AR) $(HOST_GLOBAL_ARFLAGS) $(PRIVATE_ARFLAGS) $@ $$filelist;\
-)
+    $(call _extract-and-include-single-host-whole-static-lib, $(lib)))
 endef
 
 # Explicitly delete the archive first so that ar doesn't
@@ -988,8 +1121,7 @@
 @rm -f $@
 $(extract-and-include-host-whole-static-libs)
 @echo "host StaticLib: $(PRIVATE_MODULE) ($@)"
-echo $(filter %.o, $^) | \
-	xargs $(HOST_AR) $(HOST_GLOBAL_ARFLAGS) $(PRIVATE_ARFLAGS) $@
+$(call split-long-arguments,$(HOST_AR) $(HOST_GLOBAL_ARFLAGS) $(PRIVATE_ARFLAGS) $@,$(filter %.o, $^))
 endef
 
 
@@ -1001,8 +1133,8 @@
 # it to be overriden en-masse see combo/linux-arm.make for an example.
 ifneq ($(HOST_CUSTOM_LD_COMMAND),true)
 define transform-host-o-to-shared-lib-inner
-$(PRIVATE_CXX) \
-	-Wl,-rpath-link=$(TARGET_OUT_INTERMEDIATE_LIBRARIES) \
+$(hide) $(PRIVATE_CXX) \
+	-Wl,-rpath-link=$(HOST_OUT_INTERMEDIATE_LIBRARIES) \
 	-Wl,-rpath,\$$ORIGIN/../lib \
 	-shared -Wl,-soname,$(notdir $@) \
 	$(PRIVATE_LDFLAGS) \
@@ -1014,7 +1146,9 @@
 	-Wl,--whole-archive \
 	$(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
 	-Wl,--no-whole-archive \
+	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
 	$(call normalize-host-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
+	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
 	$(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
 	-o $@ \
 	$(PRIVATE_LDLIBS)
@@ -1024,13 +1158,13 @@
 define transform-host-o-to-shared-lib
 @mkdir -p $(dir $@)
 @echo "host SharedLib: $(PRIVATE_MODULE) ($@)"
-$(hide) $(transform-host-o-to-shared-lib-inner)
+$(transform-host-o-to-shared-lib-inner)
 endef
 
 define transform-host-o-to-package
 @mkdir -p $(dir $@)
 @echo "host Package: $(PRIVATE_MODULE) ($@)"
-$(hide) $(transform-host-o-to-shared-lib-inner)
+$(transform-host-o-to-shared-lib-inner)
 endef
 
 
@@ -1051,7 +1185,7 @@
 # it to be overriden en-masse see combo/linux-arm.make for an example.
 ifneq ($(TARGET_CUSTOM_LD_COMMAND),true)
 define transform-o-to-shared-lib-inner
-$(PRIVATE_CXX) \
+$(hide) $(PRIVATE_CXX) \
 	$(PRIVATE_TARGET_GLOBAL_LDFLAGS) \
 	-Wl,-rpath-link=$(TARGET_OUT_INTERMEDIATE_LIBRARIES) \
 	-Wl,-rpath,\$$ORIGIN/../lib \
@@ -1060,9 +1194,11 @@
 	$(PRIVATE_TARGET_GLOBAL_LD_DIRS) \
 	$(PRIVATE_ALL_OBJECTS) \
 	-Wl,--whole-archive \
-	$(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
+	$(call normalize-target-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
 	-Wl,--no-whole-archive \
+	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
 	$(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
+	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
 	$(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
 	-o $@ \
 	$(PRIVATE_LDLIBS)
@@ -1072,13 +1208,13 @@
 define transform-o-to-shared-lib
 @mkdir -p $(dir $@)
 @echo "target SharedLib: $(PRIVATE_MODULE) ($@)"
-$(hide) $(transform-o-to-shared-lib-inner)
+$(transform-o-to-shared-lib-inner)
 endef
 
 define transform-o-to-package
 @mkdir -p $(dir $@)
 @echo "target Package: $(PRIVATE_MODULE) ($@)"
-$(hide) $(transform-o-to-shared-lib-inner)
+$(transform-o-to-shared-lib-inner)
 endef
 
 
@@ -1086,24 +1222,10 @@
 ## Commands for filtering a target executable or library
 ###########################################################
 
-# Because of bug 743462 ("Prelinked image magic gets stripped
-# by arm-elf-objcopy"), we have to use soslim to strip target
-# binaries.
 define transform-to-stripped
 @mkdir -p $(dir $@)
 @echo "target Strip: $(PRIVATE_MODULE) ($@)"
-$(hide) $(SOSLIM) --strip --shady --quiet $< --outfile $@
-endef
-
-define transform-to-prelinked
-@mkdir -p $(dir $@)
-@echo "target Prelink: $(PRIVATE_MODULE) ($@)"
-$(hide) $(APRIORI) \
-		--prelinkmap $(TARGET_PRELINKER_MAP) \
-		--locals-only \
-		--quiet \
-		$< \
-		--output $@
+$(hide) $(TARGET_STRIP_COMMAND)
 endef
 
 
@@ -1113,7 +1235,7 @@
 
 ifneq ($(TARGET_CUSTOM_LD_COMMAND),true)
 define transform-o-to-executable-inner
-$(PRIVATE_CXX) \
+$(hide) $(PRIVATE_CXX) \
 	$(TARGET_GLOBAL_LDFLAGS) \
 	-Wl,-rpath-link=$(TARGET_OUT_INTERMEDIATE_LIBRARIES) \
 	$(TARGET_GLOBAL_LD_DIRS) \
@@ -1125,7 +1247,9 @@
 	-Wl,--whole-archive \
 	$(call normalize-target-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
 	-Wl,--no-whole-archive \
+	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
 	$(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
+	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
 	$(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
 	-o $@ \
 	$(PRIVATE_LDLIBS)
@@ -1135,7 +1259,7 @@
 define transform-o-to-executable
 @mkdir -p $(dir $@)
 @echo "target Executable: $(PRIVATE_MODULE) ($@)"
-$(hide) $(transform-o-to-executable-inner)
+$(transform-o-to-executable-inner)
 endef
 
 
@@ -1154,7 +1278,7 @@
 define transform-o-to-static-executable
 @mkdir -p $(dir $@)
 @echo "target StaticExecutable: $(PRIVATE_MODULE) ($@)"
-$(hide) $(transform-o-to-static-executable-inner)
+$(transform-o-to-static-executable-inner)
 endef
 
 
@@ -1164,8 +1288,8 @@
 
 ifneq ($(HOST_CUSTOM_LD_COMMAND),true)
 define transform-host-o-to-executable-inner
-$(PRIVATE_CXX) \
-	-Wl,-rpath-link=$(TARGET_OUT_INTERMEDIATE_LIBRARIES) \
+$(hide) $(PRIVATE_CXX) \
+	-Wl,-rpath-link=$(HOST_OUT_INTERMEDIATE_LIBRARIES) \
 	-Wl,-rpath,\$$ORIGIN/../lib \
 	$(HOST_GLOBAL_LD_DIRS) \
 	$(PRIVATE_LDFLAGS) \
@@ -1176,7 +1300,9 @@
 	-Wl,--whole-archive \
 	$(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
 	-Wl,--no-whole-archive \
+	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
 	$(call normalize-host-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
+	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
 	$(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
 	-o $@ \
 	$(PRIVATE_LDLIBS)
@@ -1186,7 +1312,7 @@
 define transform-host-o-to-executable
 @mkdir -p $(dir $@)
 @echo "host Executable: $(PRIVATE_MODULE) ($@)"
-$(hide) $(transform-host-o-to-executable-inner)
+$(transform-host-o-to-executable-inner)
 endef
 
 
@@ -1207,12 +1333,12 @@
 # Maybe we should just use approach (1).
 
 # This rule creates the R.java and Manifest.java files, both of which
-# are PRODUCT-neutral.  Don't pass PRODUCT_AAPT_CONFIG to this invocation.
+# are PRODUCT-neutral.  Don't pass PRIVATE_PRODUCT_AAPT_CONFIG to this invocation.
 define create-resource-java-files
 @mkdir -p $(PRIVATE_SOURCE_INTERMEDIATES_DIR)
 @mkdir -p $(dir $(PRIVATE_RESOURCE_PUBLICS_OUTPUT))
 $(hide) $(AAPT) package $(PRIVATE_AAPT_FLAGS) -m \
-    $(eval # PRODUCT_AAPT_CONFIG is intentionally missing-- see comment.) \
+    $(eval # PRIVATE_PRODUCT_AAPT_CONFIG is intentionally missing-- see comment.) \
     $(addprefix -J , $(PRIVATE_SOURCE_INTERMEDIATES_DIR)) \
     $(addprefix -M , $(PRIVATE_ANDROID_MANIFEST)) \
     $(addprefix -P , $(PRIVATE_RESOURCE_PUBLICS_OUTPUT)) \
@@ -1220,10 +1346,10 @@
     $(addprefix -A , $(PRIVATE_ASSET_DIR)) \
     $(addprefix -I , $(PRIVATE_AAPT_INCLUDES)) \
     $(addprefix -G , $(PRIVATE_PROGUARD_OPTIONS_FILE)) \
-    $(addprefix --min-sdk-version , $(DEFAULT_APP_TARGET_SDK)) \
-    $(addprefix --target-sdk-version , $(DEFAULT_APP_TARGET_SDK)) \
+    $(addprefix --min-sdk-version , $(PRIVATE_DEFAULT_APP_TARGET_SDK)) \
+    $(addprefix --target-sdk-version , $(PRIVATE_DEFAULT_APP_TARGET_SDK)) \
     $(if $(filter --version-code,$(PRIVATE_AAPT_FLAGS)),,$(addprefix --version-code , $(PLATFORM_SDK_VERSION))) \
-    $(if $(filter --version-name,$(PRIVATE_AAPT_FLAGS)),,$(addprefix --version-name , $(PLATFORM_VERSION))) \
+    $(if $(filter --version-name,$(PRIVATE_AAPT_FLAGS)),,$(addprefix --version-name , $(PLATFORM_VERSION)-$(BUILD_NUMBER))) \
     $(addprefix --rename-manifest-package , $(PRIVATE_MANIFEST_PACKAGE_NAME)) \
     $(addprefix --rename-instrumentation-target-package , $(PRIVATE_MANIFEST_INSTRUMENTATION_FOR))
 endef
@@ -1231,7 +1357,13 @@
 ifeq ($(HOST_OS),windows)
 xlint_unchecked :=
 else
-#xlint_unchecked := -Xlint:unchecked
+xlint_unchecked := -Xlint:unchecked
+endif
+
+ifeq (true, $(ENABLE_INCREMENTALJAVAC))
+incremental_dex := --incremental
+else
+incremental_dex :=
 endif
 
 # emit-line, <word list>, <output file>
@@ -1262,7 +1394,12 @@
         @$(call emit-line,$(wordlist 3401,3600,$(1)),$(2))
         @$(call emit-line,$(wordlist 3601,3800,$(1)),$(2))
         @$(call emit-line,$(wordlist 3801,4000,$(1)),$(2))
-        @$(if $(wordlist 4001,4002,$(1)),$(error Too many words ($(words $(1)))))
+        @$(call emit-line,$(wordlist 4001,4200,$(1)),$(2))
+        @$(call emit-line,$(wordlist 4201,4400,$(1)),$(2))
+        @$(call emit-line,$(wordlist 4401,4600,$(1)),$(2))
+        @$(call emit-line,$(wordlist 4601,4800,$(1)),$(2))
+        @$(call emit-line,$(wordlist 4801,5000,$(1)),$(2))
+        @$(if $(wordlist 5001,5002,$(1)),$(error Too many words ($(words $(1)))))
 endef
 
 # For a list of jar files, unzip them to a specified directory,
@@ -1282,37 +1419,96 @@
   done
 endef
 
-# below we write the list of java files to java-source-list to avoid argument
-# list length problems with Cygwin we filter out duplicate java file names
-# because eclipse's compiler doesn't like them.
-define transform-java-to-classes.jar
-@echo "target Java: $(PRIVATE_MODULE) ($(PRIVATE_CLASS_INTERMEDIATES_DIR))"
+# Common definition to invoke javac on the host and target.
+#
+# Some historical notes:
+# - below we write the list of java files to java-source-list to avoid argument
+#   list length problems with Cygwin
+# - we filter out duplicate java file names because eclipse's compiler
+#   doesn't like them.
+#
+# $(1): javac
+# $(2): bootclasspath
+define compile-java
 $(hide) rm -f $@
 $(hide) rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR)
+$(hide) mkdir -p $(dir $@)
 $(hide) mkdir -p $(PRIVATE_CLASS_INTERMEDIATES_DIR)
-$(call unzip-jar-files,$(PRIVATE_STATIC_JAVA_LIBRARIES), \
-    $(PRIVATE_CLASS_INTERMEDIATES_DIR))
-$(call dump-words-to-file,$(PRIVATE_JAVA_SOURCES),$(dir $(PRIVATE_CLASS_INTERMEDIATES_DIR))/java-source-list)
+$(call unzip-jar-files,$(PRIVATE_STATIC_JAVA_LIBRARIES),$(PRIVATE_CLASS_INTERMEDIATES_DIR))
+$(call dump-words-to-file,$(PRIVATE_JAVA_SOURCES),$(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list)
 $(hide) if [ -d "$(PRIVATE_SOURCE_INTERMEDIATES_DIR)" ]; then \
-	    find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) -name '*.java' >> $(dir $(PRIVATE_CLASS_INTERMEDIATES_DIR))/java-source-list; \
+	    find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) -name '*.java' >> $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list; \
 fi
-$(hide) tr ' ' '\n' < $(dir $(PRIVATE_CLASS_INTERMEDIATES_DIR))/java-source-list \
-    | sort -u > $(dir $(PRIVATE_CLASS_INTERMEDIATES_DIR))/java-source-list-uniq
-$(hide) $(TARGET_JAVAC) -encoding ascii $(PRIVATE_BOOTCLASSPATH) \
+$(hide) tr ' ' '\n' < $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list \
+    | sort -u > $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list-uniq
+$(hide) $(1) -encoding UTF-8 \
+    $(strip $(PRIVATE_JAVAC_DEBUG_FLAGS)) \
+    $(if $(findstring true,$(LOCAL_WARNINGS_ENABLE)),$(xlint_unchecked),) \
+    $(2) \
     $(addprefix -classpath ,$(strip \
         $(call normalize-path-list,$(PRIVATE_ALL_JAVA_LIBRARIES)))) \
-    $(PRIVATE_JAVACFLAGS) $(strip $(PRIVATE_JAVAC_DEBUG_FLAGS)) $(xlint_unchecked) \
+    $(if $(findstring true,$(LOCAL_WARNINGS_ENABLE)),$(xlint_unchecked),) \
     -extdirs "" -d $(PRIVATE_CLASS_INTERMEDIATES_DIR) \
-    \@$(dir $(PRIVATE_CLASS_INTERMEDIATES_DIR))/java-source-list-uniq \
+    $(PRIVATE_JAVACFLAGS) \
+    \@$(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list-uniq \
     || ( rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR) ; exit 41 )
-$(hide) rm -f $(dir $(PRIVATE_CLASS_INTERMEDIATES_DIR))/java-source-list
-$(hide) rm -f $(dir $(PRIVATE_CLASS_INTERMEDIATES_DIR))/java-source-list-uniq
-$(hide) mkdir -p $(dir $@)
+$(hide) rm -f $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list
+$(hide) rm -f $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list-uniq
 $(hide) jar $(if $(strip $(PRIVATE_JAR_MANIFEST)),-cfm,-cf) \
     $@ $(PRIVATE_JAR_MANIFEST) -C $(PRIVATE_CLASS_INTERMEDIATES_DIR) .
+endef
+
+define transform-java-to-classes.jar
+@echo "target Java: $(PRIVATE_MODULE) ($(PRIVATE_CLASS_INTERMEDIATES_DIR))"
+$(call compile-java,$(TARGET_JAVAC),$(PRIVATE_BOOTCLASSPATH))
 $(hide) rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR)
 endef
 
+# Override the above definitions if we want to do incremetal javac
+ifeq (true, $(ENABLE_INCREMENTALJAVAC))
+define compile-java
+$(hide) mkdir -p $(dir $@)
+$(hide) mkdir -p $(PRIVATE_CLASS_INTERMEDIATES_DIR)
+$(hide) touch $(PRIVATE_CLASS_INTERMEDIATES_DIR)/newstamp
+$(call unzip-jar-files,$(PRIVATE_STATIC_JAVA_LIBRARIES),$(PRIVATE_CLASS_INTERMEDIATES_DIR))
+$(hide) if [ -e $(PRIVATE_CLASS_INTERMEDIATES_DIR)/stamp ] ; then \
+        newerFlag=$$(echo -n "-newer $(PRIVATE_CLASS_INTERMEDIATES_DIR)/stamp") ; \
+    fi ; \
+    find $(PRIVATE_JAVA_SOURCES) $$newerFlag > $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list ; \
+    if [ -d "$(PRIVATE_SOURCE_INTERMEDIATES_DIR)" ]; then \
+        find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) -name '*.java' $$newerFlag >> $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list; \
+    fi
+$(hide) tr ' ' '\n' < $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list \
+    | sort -u > $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list-uniq
+@echo "(Incremental) build source files:"
+@cat $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list-uniq
+$(hide) if [ -s $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list-uniq ] ; then \
+    $(1) -encoding UTF-8 \
+    $(strip $(PRIVATE_JAVAC_DEBUG_FLAGS)) \
+    $(if $(findstring true,$(LOCAL_WARNINGS_ENABLE)),$(xlint_unchecked),) \
+    $(2) \
+    $(addprefix -classpath ,$(strip \
+        $(call normalize-path-list,$(PRIVATE_ALL_JAVA_LIBRARIES) $(PRIVATE_CLASS_INTERMEDIATES_DIR)))) \
+    $(if $(findstring true,$(LOCAL_WARNINGS_ENABLE)),$(xlint_unchecked),) \
+    -extdirs "" -d $(PRIVATE_CLASS_INTERMEDIATES_DIR) \
+    $(PRIVATE_JAVACFLAGS) \
+    \@$(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list-uniq \
+    || ( exit 41 ) \
+fi
+$(hide) rm -f $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list
+$(hide) rm -f $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list-uniq
+$(hide) rm -f $@
+$(hide) jar $(if $(strip $(PRIVATE_JAR_MANIFEST)),-cfm,-cf) \
+    $@ $(PRIVATE_JAR_MANIFEST) -C $(PRIVATE_CLASS_INTERMEDIATES_DIR) .
+$(hide) mv $(PRIVATE_CLASS_INTERMEDIATES_DIR)/newstamp $(PRIVATE_CLASS_INTERMEDIATES_DIR)/stamp
+endef
+
+define transform-java-to-classes.jar
+@echo "target Java: $(PRIVATE_MODULE) ($(PRIVATE_CLASS_INTERMEDIATES_DIR))"
+$(call compile-java,$(TARGET_JAVAC),$(PRIVATE_BOOTCLASSPATH))
+endef
+endif # ENABLE_INCREMENTALJAVAC
+
 define transform-classes.jar-to-emma
 $(hide) java -classpath $(EMMA_JAR) emma instr -outmode fullcopy -outfile \
     $(PRIVATE_EMMA_COVERAGE_FILE) -ip $< -d $(PRIVATE_EMMA_INTERMEDIATES_DIR) \
@@ -1328,6 +1524,7 @@
 $(hide) $(DX) \
     $(if $(findstring windows,$(HOST_OS)),,-JXms16M -JXmx1536M) \
     --dex --output=$@ \
+    $(incremental_dex) \
     $(if $(NO_OPTIMIZE_DX), \
         --no-optimize) \
     $(if $(GENERATE_DEX_DEBUG), \
@@ -1360,16 +1557,16 @@
 #them in their manifest.
 define add-assets-to-package
 $(hide) $(AAPT) package -u $(PRIVATE_AAPT_FLAGS) \
-    $(addprefix -c , $(PRODUCT_AAPT_CONFIG)) \
+    $(addprefix -c , $(PRIVATE_PRODUCT_AAPT_CONFIG)) \
     $(addprefix -M , $(PRIVATE_ANDROID_MANIFEST)) \
     $(addprefix -S , $(PRIVATE_RESOURCE_DIR)) \
     $(addprefix -A , $(PRIVATE_ASSET_DIR)) \
     $(addprefix -I , $(PRIVATE_AAPT_INCLUDES)) \
-    $(addprefix --min-sdk-version , $(DEFAULT_APP_TARGET_SDK)) \
-    $(addprefix --target-sdk-version , $(DEFAULT_APP_TARGET_SDK)) \
+    $(addprefix --min-sdk-version , $(PRIVATE_DEFAULT_APP_TARGET_SDK)) \
+    $(addprefix --target-sdk-version , $(PRIVATE_DEFAULT_APP_TARGET_SDK)) \
     $(addprefix --product , $(TARGET_AAPT_CHARACTERISTICS)) \
     $(if $(filter --version-code,$(PRIVATE_AAPT_FLAGS)),,$(addprefix --version-code , $(PLATFORM_SDK_VERSION))) \
-    $(if $(filter --version-name,$(PRIVATE_AAPT_FLAGS)),,$(addprefix --version-name , $(PLATFORM_VERSION))) \
+    $(if $(filter --version-name,$(PRIVATE_AAPT_FLAGS)),,$(addprefix --version-name , $(PLATFORM_VERSION)-$(BUILD_NUMBER))) \
     $(addprefix --rename-manifest-package , $(PRIVATE_MANIFEST_PACKAGE_NAME)) \
     $(addprefix --rename-instrumentation-target-package , $(PRIVATE_MANIFEST_INSTRUMENTATION_FOR)) \
     -F $@
@@ -1377,8 +1574,8 @@
 
 define add-jni-shared-libs-to-package
 $(hide) rm -rf $(dir $@)lib
-$(hide) mkdir -p $(dir $@)lib/$(TARGET_CPU_ABI)
-$(hide) cp $(PRIVATE_JNI_SHARED_LIBRARIES) $(dir $@)lib/$(TARGET_CPU_ABI)
+$(hide) mkdir -p $(dir $@)lib/$(PRIVATE_JNI_SHARED_LIBRARIES_ABI)
+$(hide) cp $(PRIVATE_JNI_SHARED_LIBRARIES) $(dir $@)lib/$(PRIVATE_JNI_SHARED_LIBRARIES_ABI)
 $(hide) (cd $(dir $@) && zip -r $(notdir $@) lib)
 $(hide) rm -rf $(dir $@)lib
 endef
@@ -1394,7 +1591,9 @@
 endef
 
 define add-java-resources-to-package
-$(hide) jar uf $@ $(PRIVATE_EXTRA_JAR_ARGS)
+$(call dump-words-to-file, $(PRIVATE_EXTRA_JAR_ARGS), $(dir $@)jar-arg-list)
+$(hide) jar uf $@ @$(dir $@)jar-arg-list
+@rm -f $(dir $@)jar-arg-list
 endef
 
 # Sign a package using the specified key/cert.
@@ -1432,31 +1631,12 @@
 # new prebuilt rules to work, we should change this to copy the
 # resources to the out directory and then copy the resources.
 
-# Note: not using aapt tool for this because we aren't making
-# an android package for the host.
+# Note: we intentionally don't clean PRIVATE_CLASS_INTERMEDIATES_DIR
+# in transform-java-to-classes for the sake of vm-tests.
 define transform-host-java-to-package
 @echo "host Java: $(PRIVATE_MODULE) ($(PRIVATE_CLASS_INTERMEDIATES_DIR))"
-@rm -f $@
-@rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR)
-@mkdir -p $(dir $@)
-@mkdir -p $(PRIVATE_CLASS_INTERMEDIATES_DIR)
-$(call unzip-jar-files,$(PRIVATE_STATIC_JAVA_LIBRARIES), \
-    $(PRIVATE_CLASS_INTERMEDIATES_DIR))
-$(call dump-words-to-file,$(sort\
-	$(PRIVATE_JAVA_SOURCES)),\
-	$(PRIVATE_INTERMEDIATES_DIR)/java-source-list-uniq)
-$(hide) $(HOST_JAVAC) -encoding ascii -g \
-	$(PRIVATE_JAVACFLAGS) $(xlint_unchecked) \
-	$(addprefix -classpath ,$(strip \
-		$(call normalize-path-list,$(PRIVATE_ALL_JAVA_LIBRARIES)))) \
-	-extdirs "" -d $(PRIVATE_CLASS_INTERMEDIATES_DIR)\
-        \@$(PRIVATE_INTERMEDIATES_DIR)/java-source-list-uniq || \
-	( rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR) ; exit 41 )
-$(hide) rm -f $(PRIVATE_INTERMEDIATES_DIR)/java-source-list
-$(hide) rm -f $(PRIVATE_INTERMEDIATES_DIR)/java-source-list-uniq
-$(hide) jar $(if $(strip $(PRIVATE_JAR_MANIFEST)),-cfm,-cf) \
-    $@ $(PRIVATE_JAR_MANIFEST) $(PRIVATE_EXTRA_JAR_ARGS) \
-    -C $(PRIVATE_CLASS_INTERMEDIATES_DIR) .
+$(call compile-java,$(HOST_JAVAC),$(PRIVATE_BOOTCLASSPATH))
+$(if $(PRIVATE_EXTRA_JAR_ARGS), $(call add-java-resources-to-package))
 endef
 
 ###########################################################
@@ -1519,9 +1699,12 @@
 # Copy a single file from one place to another,
 # preserving permissions and overwriting any existing
 # file.
+# We disable the "-t" option for acp can not handle
+# high resolution timestamp correctly on file systems like ext4.
+# Therefore copy-file-to-target is the same as copy-file-to-new-target.
 define copy-file-to-target
 @mkdir -p $(dir $@)
-$(hide) $(ACP) -fpt $< $@
+$(hide) $(ACP) -fp $< $@
 endef
 
 # The same as copy-file-to-target, but use the local
@@ -1588,7 +1771,7 @@
 endef
 else
 define transform-host-ranlib-copy-hack
-true
+@true
 endef
 endif
 
@@ -1598,7 +1781,7 @@
 endef
 else
 define transform-ranlib-copy-hack
-true
+@true
 endef
 endif
 
@@ -1610,7 +1793,7 @@
 # Command to copy the file with acp, if proguard is disabled.
 define proguard-disabled-commands
 @echo Copying: $@
-$(hide) $(ACP) $< $@
+$(hide) $(ACP) -fp $< $@
 endef
 
 # Command to call Proguard
@@ -1656,10 +1839,13 @@
 
 # Convert a partition data size (eg, as reported in /proc/mtd) to the
 # size of the image used to flash that partition (which includes a
-# 64-byte spare area for each 2048-byte page).
+# spare area for each page).
 # $(1): the partition data size
 define image-size-from-data-size
-$(shell echo $$(($(1) / 2048 * (2048+64))))
+$(strip $(eval _isfds_value := $$(shell echo $$$$(($(1) / $(BOARD_NAND_PAGE_SIZE) * \
+  ($(BOARD_NAND_PAGE_SIZE)+$(BOARD_NAND_SPARE_SIZE))))))\
+$(if $(filter 0, $(_isfds_value)),$(shell echo $$(($(BOARD_NAND_PAGE_SIZE)+$(BOARD_NAND_SPARE_SIZE)))),$(_isfds_value))\
+$(eval _isfds_value :=))
 endef
 
 # $(1): The file(s) to check (often $@)
@@ -1724,7 +1910,6 @@
 endef
 define add-radio-file-internal
 INSTALLED_RADIOIMAGE_TARGET += $$(PRODUCT_OUT)/$(2)
-ALL_PREBUILT += $$(PRODUCT_OUT)/$(2)
 $$(PRODUCT_OUT)/$(2) : $$(LOCAL_PATH)/$(1) | $$(ACP)
 	$$(transform-prebuilt-to-target)
 endef
diff --git a/core/dex_preopt.mk b/core/dex_preopt.mk
index 6e0b093..9f44c32 100644
--- a/core/dex_preopt.mk
+++ b/core/dex_preopt.mk
@@ -4,7 +4,7 @@
 ####################################
 
 # TODO: replace it with device's BOOTCLASSPATH
-DEXPREOPT_BOOT_JARS := core:bouncycastle:ext:framework:android.policy:services:core-junit
+DEXPREOPT_BOOT_JARS := core:apache-xml:bouncycastle:ext:framework:android.policy:services:core-junit
 DEXPREOPT_BOOT_JARS_MODULES := $(subst :, ,$(DEXPREOPT_BOOT_JARS))
 
 DEXPREOPT_BUILD_DIR := $(OUT_DIR)
@@ -51,7 +51,7 @@
 	@echo "Dexpreopt Boot Jar: $$@"
 	$(hide) rm -f $$@
 	$(hide) mkdir -p $$(dir $$@)
-	$(hide) $(ACP) -fpt $$< $$(PRIVATE_DBJ_JAR)
+	$(hide) $(ACP) -fp $$< $$(PRIVATE_DBJ_JAR)
 	$$(call dexpreopt-one-file,$$(PRIVATE_DBJ_JAR),$$@)
 
 $(_dbj_jar_no_dex) : $(_dbj_src_jar) | $(ACP) $(AAPT)
@@ -60,6 +60,7 @@
 
 $(eval _dbj_jar :=)
 $(eval _dbj_odex :=)
+$(eval _dbj_jar_no_dex :=)
 $(eval _dbj_src_jar :=)
 endef
 
diff --git a/core/droiddoc.mk b/core/droiddoc.mk
index 87576dc..91d8166 100644
--- a/core/droiddoc.mk
+++ b/core/droiddoc.mk
@@ -40,11 +40,8 @@
 LOCAL_DROIDDOC_SOURCE_PATH := $(LOCAL_PATH)
 endif
 
-ifeq ($(LOCAL_DROIDDOC_TEMPLATE_DIR),)
-LOCAL_DROIDDOC_TEMPLATE_DIR := $(SRC_DROIDDOC_DIR)/templates
-endif
 ifeq ($(LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR),)
-LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR := $(SRC_DROIDDOC_DIR)/templates
+LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR := $(SRC_DROIDDOC_DIR)/$(LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR)
 endif
 
 ifeq ($(LOCAL_DROIDDOC_ASSET_DIR),)
@@ -85,13 +82,13 @@
 
 endif # !LOCAL_IS_HOST_MODULE
 
-intermediates := $(call local-intermediates-dir)
+intermediates.COMMON := $(call local-intermediates-dir,COMMON)
 
 $(full_target): PRIVATE_SOURCE_PATH := $(call normalize-path-list,$(LOCAL_DROIDDOC_SOURCE_PATH))
 $(full_target): PRIVATE_JAVA_FILES := $(filter %.java,$(full_src_files))
 $(full_target): PRIVATE_JAVA_FILES += $(addprefix $($(my_prefix)OUT_COMMON_INTERMEDIATES)/, $(filter %.java,$(LOCAL_INTERMEDIATE_SOURCES)))
-$(full_target): PRIVATE_SOURCE_INTERMEDIATES_DIR := $(intermediates)/src
-$(full_target): PRIVATE_SRC_LIST_FILE := $(intermediates)/droiddoc-src-list
+$(full_target): PRIVATE_SOURCE_INTERMEDIATES_DIR := $(intermediates.COMMON)/src
+$(full_target): PRIVATE_SRC_LIST_FILE := $(intermediates.COMMON)/droiddoc-src-list
 
 ifneq ($(strip $(LOCAL_ADDITIONAL_JAVA_DIR)),)
 $(full_target): PRIVATE_ADDITIONAL_JAVA_DIR := $(LOCAL_ADDITIONAL_JAVA_DIR)
@@ -125,26 +122,21 @@
 ##
 
 droiddoc_templates := \
-    $(shell find $(LOCAL_DROIDDOC_TEMPLATE_DIR) -type f) \
     $(shell find $(LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR) -type f)
 
 droiddoc := \
 	$(HOST_JDK_TOOLS_JAR) \
-	$(HOST_OUT_JAVA_LIBRARIES)/droiddoc$(COMMON_JAVA_PACKAGE_SUFFIX) \
-	$(HOST_OUT_JAVA_LIBRARIES)/clearsilver$(COMMON_JAVA_PACKAGE_SUFFIX) \
-	$(HOST_OUT_SHARED_LIBRARIES)/libclearsilver-jni$(HOST_JNILIB_SUFFIX)
+	$(HOST_OUT_JAVA_LIBRARIES)/doclava$(COMMON_JAVA_PACKAGE_SUFFIX)
 
-$(full_target): PRIVATE_DOCLETPATH := $(HOST_OUT_JAVA_LIBRARIES)/clearsilver$(COMMON_JAVA_PACKAGE_SUFFIX):$(HOST_OUT_JAVA_LIBRARIES)/droiddoc$(COMMON_JAVA_PACKAGE_SUFFIX):$(HOST_OUT_JAVA_LIBRARIES)/apicheck$(COMMON_JAVA_PACKAGE_SUFFIX)
+$(full_target): PRIVATE_DOCLETPATH := $(HOST_OUT_JAVA_LIBRARIES)/jsilver$(COMMON_JAVA_PACKAGE_SUFFIX):$(HOST_OUT_JAVA_LIBRARIES)/doclava$(COMMON_JAVA_PACKAGE_SUFFIX)
 $(full_target): PRIVATE_CURRENT_BUILD := -hdf page.build $(BUILD_ID)-$(BUILD_NUMBER)
 $(full_target): PRIVATE_CURRENT_TIME :=  -hdf page.now "$(shell date "+%d %b %Y %k:%M")"
-$(full_target): PRIVATE_TEMPLATE_DIR := $(LOCAL_DROIDDOC_TEMPLATE_DIR)
 $(full_target): PRIVATE_CUSTOM_TEMPLATE_DIR := $(LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR)
-$(full_target): PRIVATE_IN_ASSET_DIR := $(LOCAL_DROIDDOC_TEMPLATE_DIR)/$(LOCAL_DROIDDOC_ASSET_DIR)
 $(full_target): PRIVATE_IN_CUSTOM_ASSET_DIR := $(LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR)/$(LOCAL_DROIDDOC_CUSTOM_ASSET_DIR)
 $(full_target): PRIVATE_OUT_ASSET_DIR := $(out_dir)/$(LOCAL_DROIDDOC_ASSET_DIR)
 $(full_target): PRIVATE_OUT_CUSTOM_ASSET_DIR := $(out_dir)/$(LOCAL_DROIDDOC_CUSTOM_ASSET_DIR)
 ifneq ($(strip $(LOCAL_DROIDDOC_HTML_DIR)),)
-$(full_target): PRIVATE_DROIDDOC_HTML_DIR := $(foreach dir,$(LOCAL_DROIDDOC_HTML_DIR),-htmldir $(dir))
+$(full_target): PRIVATE_DROIDDOC_HTML_DIR := -htmldir $(LOCAL_PATH)/$(LOCAL_DROIDDOC_HTML_DIR)
 else
 $(full_target): PRIVATE_DROIDDOC_HTML_DIR := 
 endif
@@ -160,17 +152,14 @@
 	$(call prepare-doc-source-list,$(PRIVATE_SRC_LIST_FILE),$(PRIVATE_JAVA_FILES), \
 			$(PRIVATE_SOURCE_INTERMEDIATES_DIR) $(PRIVATE_ADDITIONAL_JAVA_DIR))
 	$(hide) ( \
-		LD_LIBRARY_PATH=$(HOST_OUT_SHARED_LIBRARIES) \
 		javadoc \
                 \@$(PRIVATE_SRC_LIST_FILE) \
-                -J-Xmx768m \
-                -J-Djava.library.path=$(HOST_OUT_SHARED_LIBRARIES) \
+                -J-Xmx1280m \
                 $(PRIVATE_PROFILING_OPTIONS) \
                 -quiet \
-                -doclet DroidDoc \
+                -doclet com.google.doclava.Doclava \
                 -docletpath $(PRIVATE_DOCLETPATH) \
                 -templatedir $(PRIVATE_CUSTOM_TEMPLATE_DIR) \
-                -templatedir $(PRIVATE_TEMPLATE_DIR) \
                 $(PRIVATE_DROIDDOC_HTML_DIR) \
                 $(addprefix -bootclasspath ,$(PRIVATE_BOOTCLASSPATH)) \
                 $(addprefix -classpath ,$(PRIVATE_CLASSPATH)) \
@@ -178,12 +167,6 @@
                 -d $(PRIVATE_OUT_DIR) \
                 $(PRIVATE_CURRENT_BUILD) $(PRIVATE_CURRENT_TIME) \
                 $(PRIVATE_DROIDDOC_OPTIONS) \
-        && rm -rf $(PRIVATE_OUT_ASSET_DIR) \
-        && rm -rf $(PRIVATE_OUT_CUSTOM_ASSET_DIR) \
-        && mkdir -p $(PRIVATE_OUT_ASSET_DIR) \
-        && mkdir -p $(PRIVATE_OUT_CUSTOM_ASSET_DIR) \
-        && cp -fr $(PRIVATE_IN_ASSET_DIR)/* $(PRIVATE_OUT_ASSET_DIR)/ \
-        && cp -fr $(PRIVATE_IN_CUSTOM_ASSET_DIR)/* $(PRIVATE_OUT_CUSTOM_ASSET_DIR)/ \
         && touch -f $@ \
     ) || (rm -rf $(PRIVATE_OUT_DIR) $(PRIVATE_SRC_LIST_FILE); exit 45)
 
@@ -204,7 +187,7 @@
 		javadoc \
                 $(PRIVATE_DROIDDOC_OPTIONS) \
                 \@$(PRIVATE_SRC_LIST_FILE) \
-                -J-Xmx768m \
+                -J-Xmx1024m \
                 $(PRIVATE_PROFILING_OPTIONS) \
                 $(addprefix -classpath ,$(PRIVATE_CLASSPATH)) \
                 -sourcepath $(PRIVATE_SOURCE_PATH)$(addprefix :,$(PRIVATE_CLASSPATH)) \
@@ -227,6 +210,8 @@
 .PHONY: $(LOCAL_MODULE)-docs
 $(LOCAL_MODULE)-docs : $(full_target)
 
+ifeq ($(strip $(LOCAL_UNINSTALLABLE_MODULE)),)
+
 # Define a rule to create a zip of these docs.
 out_zip := $(OUT_DOCS)/$(LOCAL_MODULE)-docs.zip
 $(out_zip): PRIVATE_DOCS_DIR := $(out_dir)
@@ -237,3 +222,5 @@
 	$(hide) ( F=$$(pwd)/$@ ; cd $(PRIVATE_DOCS_DIR) && zip -rq $$F * )
 
 $(call dist-for-goals,docs,$(out_zip))
+
+endif
diff --git a/core/dumpvar.mk b/core/dumpvar.mk
new file mode 100644
index 0000000..831ed97
--- /dev/null
+++ b/core/dumpvar.mk
@@ -0,0 +1,81 @@
+# ---------------------------------------------------------------
+# the setpath shell function in envsetup.sh uses this to figure out
+# what to add to the path given the config we have chosen.
+ifeq ($(CALLED_FROM_SETUP),true)
+
+ABP:=$(PWD)/$(HOST_OUT_EXECUTABLES)
+
+ifeq ($(TARGET_SIMULATOR),true)
+	ABP:=$(ABP):$(TARGET_OUT_EXECUTABLES)
+else
+	# Add the toolchain bin dir if it actually exists
+	ifneq ($(wildcard $(PWD)/prebuilt/$(HOST_PREBUILT_TAG)/toolchain/arm-linux-androideabi-4.4.x/bin),)
+		# this should be copied to HOST_OUT_EXECUTABLES instead
+		ABP:=$(ABP):$(PWD)/prebuilt/$(HOST_PREBUILT_TAG)/toolchain/arm-linux-androideabi-4.4.x/bin
+	endif
+endif
+ANDROID_BUILD_PATHS := $(ABP)
+ANDROID_PREBUILTS := prebuilt/$(HOST_PREBUILT_TAG)
+
+# The "dumpvar" stuff lets you say something like
+#
+#     CALLED_FROM_SETUP=true \
+#       make -f config/envsetup.make dumpvar-TARGET_OUT
+# or
+#     CALLED_FROM_SETUP=true \
+#       make -f config/envsetup.make dumpvar-abs-HOST_OUT_EXECUTABLES
+#
+# The plain (non-abs) version just dumps the value of the named variable.
+# The "abs" version will treat the variable as a path, and dumps an
+# absolute path to it.
+#
+dumpvar_goals := \
+	$(strip $(patsubst dumpvar-%,%,$(filter dumpvar-%,$(MAKECMDGOALS))))
+ifdef dumpvar_goals
+
+  ifneq ($(words $(dumpvar_goals)),1)
+    $(error Only one "dumpvar-" goal allowed. Saw "$(MAKECMDGOALS)")
+  endif
+
+  # If the goal is of the form "dumpvar-abs-VARNAME", then
+  # treat VARNAME as a path and return the absolute path to it.
+  absolute_dumpvar := $(strip $(filter abs-%,$(dumpvar_goals)))
+  ifdef absolute_dumpvar
+    dumpvar_goals := $(patsubst abs-%,%,$(dumpvar_goals))
+    DUMPVAR_VALUE := $(PWD)/$($(dumpvar_goals))
+    dumpvar_target := dumpvar-abs-$(dumpvar_goals)
+  else
+    DUMPVAR_VALUE := $($(dumpvar_goals))
+    dumpvar_target := dumpvar-$(dumpvar_goals)
+  endif
+
+.PHONY: $(dumpvar_target)
+$(dumpvar_target):
+	@echo $(DUMPVAR_VALUE)
+
+endif # dumpvar_goals
+
+ifneq ($(dumpvar_goals),report_config)
+PRINT_BUILD_CONFIG:=
+endif
+
+endif # CALLED_FROM_SETUP
+
+
+ifneq ($(PRINT_BUILD_CONFIG),)
+$(info ============================================)
+$(info   PLATFORM_VERSION_CODENAME=$(PLATFORM_VERSION_CODENAME))
+$(info   PLATFORM_VERSION=$(PLATFORM_VERSION))
+$(info   TARGET_PRODUCT=$(TARGET_PRODUCT))
+$(info   TARGET_BUILD_VARIANT=$(TARGET_BUILD_VARIANT))
+$(info   TARGET_SIMULATOR=$(TARGET_SIMULATOR))
+$(info   TARGET_BUILD_TYPE=$(TARGET_BUILD_TYPE))
+$(info   TARGET_BUILD_APPS=$(TARGET_BUILD_APPS))
+$(info   TARGET_ARCH=$(TARGET_ARCH))
+$(info   TARGET_ARCH_VARIANT=$(TARGET_ARCH_VARIANT))
+$(info   HOST_ARCH=$(HOST_ARCH))
+$(info   HOST_OS=$(HOST_OS))
+$(info   HOST_BUILD_TYPE=$(HOST_BUILD_TYPE))
+$(info   BUILD_ID=$(BUILD_ID))
+$(info ============================================)
+endif
diff --git a/core/dynamic_binary.mk b/core/dynamic_binary.mk
index cfbe740..0ca1858 100644
--- a/core/dynamic_binary.mk
+++ b/core/dynamic_binary.mk
@@ -75,7 +75,7 @@
 $(error Symbol compression not yet supported.)
 compress_output := $(intermediates)/COMPRESSED-$(LOCAL_BUILT_MODULE_STEM)
 
-#TODO: write the real $(SOSLIM) rule.
+#TODO: write the real $(STRIPPER) rule.
 #TODO: define a rule to build TARGET_SYMBOL_FILTER_FILE, and
 #      make it depend on ALL_ORIGINAL_DYNAMIC_BINARIES.
 $(compress_output): $(compress_input) $(TARGET_SYMBOL_FILTER_FILE) | $(ACP)
@@ -86,49 +86,20 @@
 compress_output := $(compress_input)
 endif
 
-
 ###########################################################
-## Pre-link
+## Store a copy with symbols for symbolic debugging
 ###########################################################
-prelink_input := $(compress_output)
-# The output of the prelink step is the binary we want to use
-# for symbolic debugging;  the prelink step may move sections
-# around, so we have to use this version.
-prelink_output := $(LOCAL_UNSTRIPPED_PATH)/$(LOCAL_MODULE_SUBDIR)$(LOCAL_BUILT_MODULE_STEM)
-
-# Skip prelinker if it is FDO instrumentation build.
-ifneq ($(strip $(BUILD_FDO_INSTRUMENT)),)
-ifneq ($(LOCAL_NO_FDO_SUPPORT),true)
-LOCAL_PRELINK_MODULE := false
-endif
-endif
-
-ifeq ($(LOCAL_PRELINK_MODULE),true)
-$(prelink_output): $(prelink_input) $(TARGET_PRELINKER_MAP) $(APRIORI)
-	$(transform-to-prelinked)
-else
-# Don't prelink the binary, just copy it.  We can't skip this step
-# because people always expect a copy of the binary to appear
-# in the UNSTRIPPED directory.
-#
-# If the binary we're copying is acp or a prerequisite,
-# use cp(1) instead.
-ifneq ($(LOCAL_ACP_UNAVAILABLE),true)
-$(prelink_output): $(prelink_input) | $(ACP)
-	@echo "target Non-prelinked: $(PRIVATE_MODULE) ($@)"
+symbolic_input := $(compress_output)
+symbolic_output := $(LOCAL_UNSTRIPPED_PATH)/$(LOCAL_BUILT_MODULE_STEM)
+$(symbolic_output) : $(symbolic_input) | $(ACP)
+	@echo "target Symbolic: $(PRIVATE_MODULE) ($@)"
 	$(copy-file-to-target)
-else
-$(prelink_output): $(prelink_input)
-	@echo "target Non-prelinked: $(PRIVATE_MODULE) ($@)"
-	$(copy-file-to-target-with-cp)
-endif
-endif
 
 
 ###########################################################
 ## Strip
 ###########################################################
-strip_input := $(prelink_output)
+strip_input := $(symbolic_output)
 strip_output := $(LOCAL_BUILT_MODULE)
 
 ifeq ($(strip $(LOCAL_STRIP_MODULE)),)
@@ -137,7 +108,7 @@
 
 ifeq ($(LOCAL_STRIP_MODULE),true)
 # Strip the binary
-$(strip_output): $(strip_input) | $(SOSLIM)
+$(strip_output): $(strip_input) | $(TARGET_STRIP)
 	$(transform-to-stripped)
 else
 # Don't strip the binary, just copy it.  We can't skip this step
@@ -160,5 +131,5 @@
 $(cleantarget): PRIVATE_CLEAN_FILES := \
 			$(PRIVATE_CLEAN_FILES) \
 			$(linked_module) \
-			$(compress_output) \
-			$(prelink_output)
+			$(symbolic_output) \
+			$(compress_output)
diff --git a/core/envsetup.mk b/core/envsetup.mk
index c70a5e2..b02d8c6 100644
--- a/core/envsetup.mk
+++ b/core/envsetup.mk
@@ -26,7 +26,7 @@
 ifeq ($(TARGET_SIMULATOR),true)
 TARGET_PRODUCT := sim
 else
-TARGET_PRODUCT := generic
+TARGET_PRODUCT := full
 endif
 endif
 
@@ -36,18 +36,6 @@
 TARGET_BUILD_VARIANT := eng
 endif
 
-# Read the product specs so we an get TARGET_DEVICE and other
-# variables that we need in order to locate the output files.
-include $(BUILD_SYSTEM)/product_config.mk
-
-build_variant := $(filter-out eng user userdebug tests,$(TARGET_BUILD_VARIANT))
-ifneq ($(build_variant)-$(words $(TARGET_BUILD_VARIANT)),-1)
-$(warning bad TARGET_BUILD_VARIANT: $(TARGET_BUILD_VARIANT))
-$(error must be empty or one of: eng user userdebug tests)
-endif
-
-
-
 # ---------------------------------------------------------------
 # Set up configuration for host machine.  We don't do cross-
 # compiles except for arm, so the HOST is whatever we are
@@ -119,17 +107,15 @@
   HOST_PREBUILT_TAG := $(HOST_OS)-$(HOST_ARCH)
 endif
 
-# Default to building dalvikvm on hosts that support it...
-ifeq ($(HOST_OS),linux)
-# ... but not if we're building the sim...
-ifneq ($(TARGET_SIMULATOR),true)
-# ... or if the if the option is already set
-ifeq ($(WITH_HOST_DALVIK),)
-	WITH_HOST_DALVIK := true
-endif
-endif
-endif
+# Read the product specs so we an get TARGET_DEVICE and other
+# variables that we need in order to locate the output files.
+include $(BUILD_SYSTEM)/product_config.mk
 
+build_variant := $(filter-out eng user userdebug tests,$(TARGET_BUILD_VARIANT))
+ifneq ($(build_variant)-$(words $(TARGET_BUILD_VARIANT)),-1)
+$(warning bad TARGET_BUILD_VARIANT: $(TARGET_BUILD_VARIANT))
+$(error must be empty or one of: eng user userdebug tests)
+endif
 
 # ---------------------------------------------------------------
 # Set up configuration for target machine.
@@ -158,14 +144,6 @@
 TARGET_BUILD_TYPE := release
 endif
 
-# This is the standard way to name a directory containing prebuilt target
-# objects. E.g., prebuilt/$(TARGET_PREBUILT_TAG)/libc.so
-ifeq ($(TARGET_SIMULATOR),true)
-  TARGET_PREBUILT_TAG := $(TARGET_OS)-$(TARGET_ARCH)
-else
-  TARGET_PREBUILT_TAG := android-$(TARGET_ARCH)
-endif
-
 # ---------------------------------------------------------------
 # figure out the output directories
 
@@ -238,6 +216,7 @@
 TARGET_OUT_ETC := $(TARGET_OUT)/etc
 TARGET_OUT_STATIC_LIBRARIES:= $(TARGET_OUT_INTERMEDIATES)/lib
 TARGET_OUT_NOTICE_FILES:=$(TARGET_OUT_INTERMEDIATES)/NOTICE_FILES
+TARGET_OUT_FAKE := $(PRODUCT_OUT)/fake_packages
 
 TARGET_OUT_DATA := $(PRODUCT_OUT)/data
 TARGET_OUT_DATA_EXECUTABLES:= $(TARGET_OUT_EXECUTABLES)
@@ -248,6 +227,7 @@
 TARGET_OUT_DATA_KEYCHARS := $(TARGET_OUT_KEYCHARS)
 TARGET_OUT_DATA_ETC := $(TARGET_OUT_ETC)
 TARGET_OUT_DATA_STATIC_LIBRARIES:= $(TARGET_OUT_STATIC_LIBRARIES)
+TARGET_OUT_DATA_NATIVE_TESTS := $(TARGET_OUT_DATA)/nativetest
 
 TARGET_OUT_UNSTRIPPED := $(PRODUCT_OUT)/symbols
 TARGET_OUT_EXECUTABLES_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/system/bin
@@ -283,81 +263,3 @@
 ifeq ($(PRINT_BUILD_CONFIG),)
 PRINT_BUILD_CONFIG := true
 endif
-
-# ---------------------------------------------------------------
-# the setpath shell function in envsetup.sh uses this to figure out
-# what to add to the path given the config we have chosen.
-ifeq ($(CALLED_FROM_SETUP),true)
-
-ABP:=$(PWD)/$(HOST_OUT_EXECUTABLES)
-
-ifeq ($(TARGET_SIMULATOR),true)
-	ABP:=$(ABP):$(TARGET_OUT_EXECUTABLES)
-else
-	# this should be copied to HOST_OUT_EXECUTABLES instead
-	ABP:=$(ABP):$(PWD)/prebuilt/$(HOST_PREBUILT_TAG)/toolchain/arm-eabi-4.4.3/bin
-endif
-ANDROID_BUILD_PATHS := $(ABP)
-ANDROID_PREBUILTS := prebuilt/$(HOST_PREBUILT_TAG)
-
-# The "dumpvar" stuff lets you say something like
-#
-#     CALLED_FROM_SETUP=true \
-#       make -f config/envsetup.make dumpvar-TARGET_OUT
-# or
-#     CALLED_FROM_SETUP=true \
-#       make -f config/envsetup.make dumpvar-abs-HOST_OUT_EXECUTABLES
-#
-# The plain (non-abs) version just dumps the value of the named variable.
-# The "abs" version will treat the variable as a path, and dumps an
-# absolute path to it.
-#
-dumpvar_goals := \
-	$(strip $(patsubst dumpvar-%,%,$(filter dumpvar-%,$(MAKECMDGOALS))))
-ifdef dumpvar_goals
-
-  ifneq ($(words $(dumpvar_goals)),1)
-    $(error Only one "dumpvar-" goal allowed. Saw "$(MAKECMDGOALS)")
-  endif
-
-  # If the goal is of the form "dumpvar-abs-VARNAME", then
-  # treat VARNAME as a path and return the absolute path to it.
-  absolute_dumpvar := $(strip $(filter abs-%,$(dumpvar_goals)))
-  ifdef absolute_dumpvar
-    dumpvar_goals := $(patsubst abs-%,%,$(dumpvar_goals))
-    DUMPVAR_VALUE := $(PWD)/$($(dumpvar_goals))
-    dumpvar_target := dumpvar-abs-$(dumpvar_goals)
-  else
-    DUMPVAR_VALUE := $($(dumpvar_goals))
-    dumpvar_target := dumpvar-$(dumpvar_goals)
-  endif
-
-.PHONY: $(dumpvar_target)
-$(dumpvar_target):
-	@echo $(DUMPVAR_VALUE)
-
-endif # dumpvar_goals
-
-ifneq ($(dumpvar_goals),report_config)
-PRINT_BUILD_CONFIG:=
-endif
-
-endif # CALLED_FROM_SETUP
-
-
-ifneq ($(PRINT_BUILD_CONFIG),)
-$(info ============================================)
-$(info   PLATFORM_VERSION_CODENAME=$(PLATFORM_VERSION_CODENAME))
-$(info   PLATFORM_VERSION=$(PLATFORM_VERSION))
-$(info   TARGET_PRODUCT=$(TARGET_PRODUCT))
-$(info   TARGET_BUILD_VARIANT=$(TARGET_BUILD_VARIANT))
-$(info   TARGET_SIMULATOR=$(TARGET_SIMULATOR))
-$(info   TARGET_BUILD_TYPE=$(TARGET_BUILD_TYPE))
-$(info   TARGET_BUILD_APPS=$(TARGET_BUILD_APPS))
-$(info   TARGET_ARCH=$(TARGET_ARCH))
-$(info   HOST_ARCH=$(HOST_ARCH))
-$(info   HOST_OS=$(HOST_OS))
-$(info   HOST_BUILD_TYPE=$(HOST_BUILD_TYPE))
-$(info   BUILD_ID=$(BUILD_ID))
-$(info ============================================)
-endif
diff --git a/core/executable.mk b/core/executable.mk
index 623c766..6138adb 100644
--- a/core/executable.mk
+++ b/core/executable.mk
@@ -12,11 +12,6 @@
 LOCAL_MODULE_SUFFIX := $(TARGET_EXECUTABLE_SUFFIX)
 endif
 
-# Executables are not prelinked.  If we decide to start prelinking
-# them, the LOCAL_PRELINK_MODULE definitions should be moved from
-# here and shared_library.make and consolidated in dynamic_binary.make.
-LOCAL_PRELINK_MODULE := false
-
 include $(BUILD_SYSTEM)/dynamic_binary.mk
 
 ifeq ($(LOCAL_FORCE_STATIC_EXECUTABLE),true)
diff --git a/core/find-jdk-tools-jar.sh b/core/find-jdk-tools-jar.sh
index e772a15..e1278c3 100755
--- a/core/find-jdk-tools-jar.sh
+++ b/core/find-jdk-tools-jar.sh
@@ -3,12 +3,11 @@
 else
     JAVAC=$(which javac)
     if [ -z "$JAVAC" ] ; then
-	echo "Please-install-JDK-6.0,-which-you-can-download-from-java.sun.com"
-	exit 1
+        exit 1
     fi
-    while [ -L $JAVAC ] ; do
-        LSLINE=$(ls -l $JAVAC)
-        JAVAC=$(echo -n $LSLINE | sed -e "s/.* -> //")
+    while [ -L "$JAVAC" ] ; do
+        LSLINE=$(ls -l "$JAVAC")
+        JAVAC=$(echo -n "$LSLINE" | sed -e "s/.* -> //")
     done
     echo $JAVAC | sed -e "s:\(.*\)/bin/javac.*:\\1/lib/tools.jar:"
 fi
diff --git a/core/help.mk b/core/help.mk
new file mode 100644
index 0000000..9e37f82
--- /dev/null
+++ b/core/help.mk
@@ -0,0 +1,42 @@
+#
+# Copyright (C) 2010 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.
+#
+
+ifeq ($(MAKECMDGOALS),help)
+dont_bother := true
+endif
+ifeq ($(MAKECMDGOALS),out)
+dont_bother := true
+endif
+
+.PHONY: help
+help:
+	@echo
+	@echo "Common make targets:"
+	@echo "----------------------------------------------------------------------------------"
+	@echo "droid                   Default target"
+	@echo "clean                   (aka clobber) equivalent to rm -rf out/"
+	@echo "snod                    Quickly rebuild the system image from built packages"
+	@echo "offline-sdk-docs        Generate the HTML for the developer SDK docs"
+	@echo "doc-comment-check-docs  Check HTML doc links & validity, without generating HTML"
+	@echo "libandroid_runtime      All the JNI framework stuff"
+	@echo "framework               All the java framework stuff"
+	@echo "services                The system server (Java) and friends"
+	@echo "help                    You're reading it right now"
+
+.PHONY: out
+out:
+	@echo "I'm sure you're nice and all, but no thanks."
+
diff --git a/core/host_java_library.mk b/core/host_java_library.mk
index 27174f2..322d10f 100644
--- a/core/host_java_library.mk
+++ b/core/host_java_library.mk
@@ -27,10 +27,14 @@
 intermediates := $(call local-intermediates-dir)
 intermediates.COMMON := $(call local-intermediates-dir,COMMON)
 
+full_classes_compiled_jar := $(intermediates.COMMON)/classes-full-debug.jar
+full_classes_jarjar_jar := $(intermediates.COMMON)/classes-jarjar.jar
 full_classes_jar := $(intermediates.COMMON)/classes.jar
 built_dex := $(intermediates.COMMON)/classes.dex
 
 LOCAL_INTERMEDIATE_TARGETS += \
+    $(full_classes_compiled_jar) \
+    $(full_classes_jarjar_jar) \
     $(full_classes_jar) \
     $(built_dex)
 
@@ -47,10 +51,26 @@
 
 $(cleantarget): PRIVATE_CLEAN_FILES += $(intermediates.COMMON)
 
-$(full_classes_jar): PRIVATE_JAVACFLAGS := $(LOCAL_JAVACFLAGS)
-$(full_classes_jar): $(java_sources) $(java_resource_sources) $(full_java_lib_deps) $(jar_manifest_file)
+$(full_classes_compiled_jar): PRIVATE_JAVACFLAGS := $(LOCAL_JAVACFLAGS)
+$(full_classes_compiled_jar): $(java_sources) $(java_resource_sources) $(full_java_lib_deps) $(jar_manifest_file)
 	$(transform-host-java-to-package)
 
+# Run jarjar if necessary, otherwise just copy the file.
+ifneq ($(strip $(LOCAL_JARJAR_RULES)),)
+$(full_classes_jarjar_jar): PRIVATE_JARJAR_RULES := $(LOCAL_JARJAR_RULES)
+$(full_classes_jarjar_jar): $(full_classes_compiled_jar) | $(JARJAR)
+	@echo JarJar: $@
+	$(hide) java -jar $(JARJAR) process $(PRIVATE_JARJAR_RULES) $< $@
+else
+$(full_classes_jarjar_jar): $(full_classes_compiled_jar) | $(ACP)
+	@echo Copying: $@
+	$(hide) $(ACP) -fp $< $@
+endif
+
+$(full_classes_jar): $(full_classes_jarjar_jar) | $(ACP)
+	@echo Copying: $@
+	$(hide) $(ACP) -fp $< $@
+
 $(built_dex): PRIVATE_INTERMEDIATES_DIR := $(intermediates.COMMON)
 $(built_dex): PRIVATE_DX_FLAGS := $(LOCAL_DX_FLAGS)
 $(built_dex): $(full_classes_jar) $(DX)
diff --git a/core/host_native_test.mk b/core/host_native_test.mk
new file mode 100644
index 0000000..a5d87e4
--- /dev/null
+++ b/core/host_native_test.mk
@@ -0,0 +1,13 @@
+################################################
+## A thin wrapper around BUILD_HOST_EXECUTABLE
+## Common flags for host native tests are added.
+################################################
+
+LOCAL_CFLAGS += -DGTEST_OS_LINUX -DGTEST_HAS_STD_STRING -O0 -g
+LOCAL_C_INCLUDES +=  \
+    external/gtest/include
+
+LOCAL_STATIC_LIBRARIES += libgtest_host libgtest_main_host
+LOCAL_SHARED_LIBRARIES +=
+
+include $(BUILD_HOST_EXECUTABLE)
diff --git a/core/java.mk b/core/java.mk
index 6b8d04d..5324e7d 100644
--- a/core/java.mk
+++ b/core/java.mk
@@ -32,6 +32,16 @@
     LOCAL_JAVA_LIBRARIES := core core-junit ext framework $(LOCAL_JAVA_LIBRARIES)
   endif
 endif
+
+proto_sources := $(filter %.proto,$(LOCAL_SRC_FILES))
+ifneq ($(proto_sources),)
+ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),micro)
+    LOCAL_STATIC_JAVA_LIBRARIES += libprotobuf-java-2.3.0-micro
+else
+    LOCAL_STATIC_JAVA_LIBRARIES += libprotobuf-java-2.3.0-lite
+endif
+endif
+
 LOCAL_JAVA_LIBRARIES := $(sort $(LOCAL_JAVA_LIBRARIES))
 
 LOCAL_BUILT_MODULE_STEM := $(strip $(LOCAL_BUILT_MODULE_STEM))
@@ -78,7 +88,7 @@
 ifdef LOCAL_PROGUARD_ENABLED
 proguard_jar_leaf := proguard.classes.jar
 built_dex_intermediate_leaf := proguard.$(built_dex_intermediate_leaf)
-built_dex_leaf := progaurd.classes.dex
+built_dex_leaf := proguard.classes.dex
 else
 proguard_jar_leaf := noproguard.classes.jar
 built_dex_intermediate_leaf := noproguard.$(built_dex_intermediate_leaf)
@@ -113,6 +123,54 @@
 
 LOCAL_INTERMEDIATE_SOURCE_DIR := $(intermediates.COMMON)/src
 
+###############################################################
+## .rs files: RenderScript sources to .java files and .bc files
+###############################################################
+renderscript_sources := $(filter %.rs,$(LOCAL_SRC_FILES))
+# Because names of the java files from RenderScript are unknown until the
+# .rs file(s) are compiled, we have to depend on a timestamp file.
+RenderScript_file_stamp :=
+ifneq ($(renderscript_sources),)
+renderscript_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(renderscript_sources))
+RenderScript_file_stamp := $(LOCAL_INTERMEDIATE_SOURCE_DIR)/RenderScript.stamp
+renderscript_intermediate := $(LOCAL_INTERMEDIATE_SOURCE_DIR)/renderscript
+
+# prepend the RenderScript system include path
+ifneq ($(filter-out current,$(LOCAL_SDK_VERSION)),)
+LOCAL_RENDERSCRIPT_INCLUDES := \
+    $(HISTORICAL_SDK_VERSIONS_ROOT)/$(LOCAL_SDK_VERSION)/renderscript/clang-include \
+    $(HISTORICAL_SDK_VERSIONS_ROOT)/$(LOCAL_SDK_VERSION)/renderscript/include \
+    $(LOCAL_RENDERSCRIPT_INCLUDES)
+else
+LOCAL_RENDERSCRIPT_INCLUDES := \
+     $(TOPDIR)external/clang/lib/Headers \
+     $(TOPDIR)frameworks/base/libs/rs/scriptc \
+     $(LOCAL_RENDERSCRIPT_INCLUDES)
+endif
+
+ifeq ($(LOCAL_RENDERSCRIPT_CC),)
+LOCAL_RENDERSCRIPT_CC := $(LLVM_RS_CC)
+endif
+
+$(RenderScript_file_stamp): PRIVATE_RS_INCLUDES := $(LOCAL_RENDERSCRIPT_INCLUDES)
+$(RenderScript_file_stamp): PRIVATE_RS_CC := $(LOCAL_RENDERSCRIPT_CC)
+$(RenderScript_file_stamp): PRIVATE_RS_SOURCE_FILES := $(renderscript_sources_fullpath)
+# By putting the generated java files into $(LOCAL_INTERMEDIATE_SOURCE_DIR), they will be
+# automatically found by the java compiling function transform-java-to-classes.jar.
+$(RenderScript_file_stamp): PRIVATE_RS_OUTPUT_DIR := $(renderscript_intermediate)
+$(RenderScript_file_stamp): $(renderscript_sources_fullpath) $(LOCAL_RENDERSCRIPT_CC)
+	$(transform-renderscripts-to-java-and-bc)
+
+# include the dependency files (.d) generated by llvm-rs-cc.
+renderscript_generated_dep_files := $(addprefix $(renderscript_intermediate)/, \
+    $(patsubst %.rs,%.d, $(notdir $(renderscript_sources))))
+-include $(renderscript_generated_dep_files)
+
+LOCAL_INTERMEDIATE_TARGETS += $(RenderScript_file_stamp)
+# Make sure the generated resource will be added to the apk.
+LOCAL_RESOURCE_DIR := $(LOCAL_INTERMEDIATE_SOURCE_DIR)/renderscript/res $(LOCAL_RESOURCE_DIR)
+endif
+
 # TODO: It looks like the only thing we need from base_rules is
 # all_java_sources.  See if we can get that by adding a
 # common_java.mk, and moving the include of base_rules.mk to
@@ -167,7 +225,8 @@
 # Deps for generated source files must be handled separately,
 # via deps on the target that generates the sources.
 $(full_classes_compiled_jar): PRIVATE_JAVACFLAGS := $(LOCAL_JAVACFLAGS)
-$(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) \
+	$(RenderScript_file_stamp) $(proto_java_sources_file_stamp)
 	$(transform-java-to-classes.jar)
 
 # All of the rules after full_classes_compiled_jar are very unlikely
@@ -190,7 +249,7 @@
 else
 $(full_classes_jarjar_jar): $(full_classes_compiled_jar) | $(ACP)
 	@echo Copying: $@
-	$(hide) $(ACP) $< $@
+	$(hide) $(ACP) -fp $< $@
 endif
 
 ifeq ($(LOCAL_IS_STATIC_JAVA_LIBRARY),true)
@@ -228,7 +287,7 @@
 # Keep a copy of the jar just before proguard processing.
 $(full_classes_jar): $(full_classes_emma_jar) | $(ACP)
 	@echo Copying: $@
-	$(hide) $(ACP) $< $@
+	$(hide) $(ACP) -fp $< $@
 
 # Run proguard if necessary, otherwise just copy the file.
 proguard_dictionary := $(intermediates.COMMON)/proguard_dictionary
@@ -272,17 +331,33 @@
 
 ALL_MODULES.$(LOCAL_MODULE).PROGUARD_ENABLED:=$(LOCAL_PROGUARD_ENABLED)
 
+# Override PRIVATE_INTERMEDIATES_DIR so that install-dex-debug
+# will work even when intermediates != intermediates.COMMON.
+$(built_dex_intermediate): PRIVATE_INTERMEDIATES_DIR := $(intermediates.COMMON)
+
+ifeq (,$(filter --target-api=%, $(LOCAL_DX_FLAGS)))
+possible_dx_target_api :=
+ifneq (,$(LOCAL_MANIFEST_FILE))
+  manifest_min_sdk_version := \
+      $(shell grep -o 'android:minSdkVersion="[0-9]\{1,\}"' $(LOCAL_PATH)/$(LOCAL_MANIFEST_FILE) 2>/dev/null)
+  possible_dx_target_api := $(patsubst android:minSdkVersion="%",%,$(firstword $(manifest_min_sdk_version)))
+endif
+ifeq (,$(possible_dx_target_api))
+# In case minSdkVersion is not available, eg shared library built against SDK,
+# LOCAL_SDK_VERSION may be a good guess
+ifneq (,$(filter-out current, $(LOCAL_SDK_VERSION)))
+  possible_dx_target_api := $(LOCAL_SDK_VERSION)
+endif
+endif
+LOCAL_DX_FLAGS += $(addprefix --target-api=, $(possible_dx_target_api))
+endif # --target-api not defined in LOCAL_DX_FLAGS
+$(built_dex_intermediate): PRIVATE_DX_FLAGS := $(LOCAL_DX_FLAGS)
 # If you instrument class files that have local variable debug information in
 # them emma does not correctly maintain the local variable table.
 # This will cause an error when you try to convert the class files for Android.
 # The workaround here is to build different dex file here based on emma switch
 # then later copy into classes.dex. When emma is on, dx is run with --no-locals
 # option to remove local variable information
-
-# Override PRIVATE_INTERMEDIATES_DIR so that install-dex-debug
-# will work even when intermediates != intermediates.COMMON.
-$(built_dex_intermediate): PRIVATE_INTERMEDIATES_DIR := $(intermediates.COMMON)
-$(built_dex_intermediate): PRIVATE_DX_FLAGS := $(LOCAL_DX_FLAGS)
 ifneq ($(LOCAL_NO_EMMA_COMPILE),true)
 $(built_dex_intermediate): PRIVATE_DX_FLAGS += --no-locals
 endif
@@ -290,7 +365,7 @@
 	$(transform-classes.jar-to-dex)
 $(built_dex): $(built_dex_intermediate) | $(ACP)
 	@echo Copying: $@
-	$(hide) $(ACP) $< $@
+	$(hide) $(ACP) -fp $< $@
 ifneq ($(GENERATE_DEX_DEBUG),)
 	$(install-dex-debug)
 endif
diff --git a/core/java_library.mk b/core/java_library.mk
index dbf6981..23417d0 100644
--- a/core/java_library.mk
+++ b/core/java_library.mk
@@ -42,10 +42,13 @@
 #################################
 
 ifeq ($(LOCAL_IS_STATIC_JAVA_LIBRARY),true)
-# No dex or resources; all we want are the .class files.
-$(common_javalib.jar) : $(full_classes_jar)
+# No dex; all we want are the .class files with resources.
+$(common_javalib.jar) : $(full_classes_jar) $(java_resource_sources)
 	@echo "target Static Jar: $(PRIVATE_MODULE) ($@)"
 	$(copy-file-to-target)
+ifneq ($(extra_jar_args),)
+	$(add-java-resources-to-package)
+endif
 
 $(LOCAL_BUILT_MODULE): $(common_javalib.jar)
 	$(copy-file-to-target)
diff --git a/core/key_char_map.mk b/core/key_char_map.mk
deleted file mode 100644
index 0f112f2..0000000
--- a/core/key_char_map.mk
+++ /dev/null
@@ -1,27 +0,0 @@
-###########################################################
-## Standard rules for building an executable file.
-##
-## Additional inputs from base_rules.make:
-## None.
-###########################################################
-
-ifeq ($(strip $(LOCAL_MODULE_CLASS)),)
-LOCAL_MODULE_CLASS := KEYCHARS
-endif
-ifeq ($(strip $(LOCAL_MODULE_SUFFIX)),)
-LOCAL_MODULE_SUFFIX := .bin
-endif
-
-LOCAL_MODULE := $(LOCAL_SRC_FILES)
-
-include $(BUILD_SYSTEM)/base_rules.mk
-
-full_src_files := $(addprefix $(LOCAL_PATH)/,$(LOCAL_SRC_FILES))
-
-$(LOCAL_BUILT_MODULE) : PRIVATE_SRC_FILES := $(full_src_files)
-
-$(LOCAL_BUILT_MODULE) : $(full_src_files) $(KCM)
-	@echo KeyCharMap: $@
-	@mkdir -p $(dir $@)
-	$(hide) $(KCM) $(PRIVATE_SRC_FILES) $@
-    
diff --git a/core/legacy_prebuilts.mk b/core/legacy_prebuilts.mk
new file mode 100644
index 0000000..41943b1
--- /dev/null
+++ b/core/legacy_prebuilts.mk
@@ -0,0 +1,126 @@
+#
+# Copyright (C) 2010 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 the list of modules grandfathered to use ALL_PREBUILT
+
+# DO NOT ADD ANY NEW MODULE TO THIS FILE
+#
+# ALL_PREBUILT modules are hard to control and audit and we don't want
+# to add any new such module in the system
+
+GRANDFATHERED_ALL_PREBUILT := \
+	akmd2 \
+	am \
+	ap_gain.bin \
+	audio.conf \
+	auto_pairing.conf \
+	AVRCP.kl \
+	baseline11k.par \
+	baseline8k.par \
+	baseline.par \
+	basic.ok \
+	batch \
+	bitmap_size.txt \
+	blacklist.conf \
+	bmgr \
+	boolean.g2g \
+	bp.img \
+	brcm_guci_drv \
+	bypassfactory \
+	cdt.bin \
+	chat-ril \
+	cmu6plus.ok.zip \
+	cpcap-key.kl \
+	data \
+	dbus.conf \
+	dev \
+	egl.cfg \
+	enroll.ok \
+	en-US-ttp.data \
+	firmware_error.565 \
+	firmware_install.565 \
+	ftmipcd \
+	generic11_f.swimdl \
+	generic11.lda \
+	generic11_m.swimdl \
+	generic8_f.swimdl \
+	generic8.lda \
+	generic8_m.swimdl \
+	generic.swiarb \
+	gps.conf \
+	gpsconfig.xml \
+	gps.stingray.so \
+	gralloc.omap3.so \
+	gralloc.tegra.so \
+	hosts \
+	hwcomposer.tegra.so \
+	ime \
+	init.goldfish.rc \
+	init.goldfish.sh \
+	init.olympus.rc \
+	init.rc \
+	init.sholes.rc \
+	init.stingray.rc \
+	input \
+	input.conf \
+	kernel \
+	lbl \
+	libEGL_POWERVR_SGX530_121.so \
+	libEGL_tegra.so \
+	libGLESv1_CM_POWERVR_SGX530_121.so \
+	libGLESv1_CM_tegra.so \
+	libGLESv2_POWERVR_SGX530_121.so \
+	libGLESv2_tegra.so \
+	libmdmctrl.a \
+	libmoto_ril.so \
+	libpppd_plugin-ril.so \
+	libril_rds.so \
+	location \
+	location.cfg \
+	main.conf \
+	mbm.bin \
+	mbm_consumer.bin \
+	mdm_panicd \
+	monkey \
+	network.conf \
+	phone_type_choice.g2g \
+	pm \
+	pppd-ril \
+	pppd-ril.options \
+	proc \
+	qwerty.kl \
+	radio.img \
+	rdl.bin \
+	RFFspeed_501.bmd \
+	RFFstd_501.bmd \
+	savebpver \
+	sbin \
+	sholes-keypad.kl \
+	suplcerts.bks \
+	svc \
+	sys \
+	system \
+	tcmd \
+	ueventd.goldfish.rc \
+	ueventd.olympus.rc \
+	ueventd.rc \
+	ueventd.stingray.rc \
+	VoiceDialer.g2g \
+	vold.fstab \
+	wl1271.bin \
+	zoneinfo.dat \
+	zoneinfo.idx \
+	zoneinfo.version
diff --git a/core/main.mk b/core/main.mk
index 3da0648..277315b 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -12,6 +12,13 @@
 # this turns off the suffix rules built into make
 .SUFFIXES:
 
+# this turns off the RCS / SCCS implicit rules of GNU Make
+% : RCS/%,v
+% : RCS/%
+% : %,v
+% : s.%
+% : SCCS/s.%
+
 # If a rule fails, delete $@.
 .DELETE_ON_ERROR:
 
@@ -31,11 +38,11 @@
 #endif
 
 # check for broken versions of make
-ifeq (0,$(shell expr $$(echo $(MAKE_VERSION) | sed "s/[^0-9\.].*//") \>= 3.81))
+ifeq (0,$(shell expr $$(echo $(MAKE_VERSION) | sed "s/[^0-9\.].*//") = 3.81))
 $(warning ********************************************************************************)
 $(warning *  You are using version $(MAKE_VERSION) of make.)
-$(warning *  You must upgrade to version 3.81 or greater.)
-$(warning *  see http://source.android.com/download)
+$(warning *  Android can only be built by version 3.81.)
+$(warning *  see http://source.android.com/source/download.html)
 $(warning ********************************************************************************)
 $(error stopping)
 endif
@@ -54,6 +61,9 @@
 .PHONY: FORCE
 FORCE:
 
+# Targets that provide quick help on the build system.
+include $(BUILD_SYSTEM)/help.mk
+
 # Set up various standard variables based on configuration
 # and host information.
 include $(BUILD_SYSTEM)/config.mk
@@ -113,7 +123,7 @@
 $(info The correct version is: 1.6.)
 $(info $(space))
 $(info Please follow the machine setup instructions at)
-$(info $(space)$(space)$(space)$(space)http://source.android.com/download)
+$(info $(space)$(space)$(space)$(space)http://source.android.com/source/download.html)
 $(info ************************************************************)
 $(error stop)
 endif
@@ -129,7 +139,7 @@
 $(info The correct version is: 1.6.)
 $(info $(space))
 $(info Please follow the machine setup instructions at)
-$(info $(space)$(space)$(space)$(space)http://source.android.com/download)
+$(info $(space)$(space)$(space)$(space)http://source.android.com/source/download.html)
 $(info ************************************************************)
 $(error stop)
 endif
@@ -141,7 +151,23 @@
 # These are the modifier targets that don't do anything themselves, but
 # change the behavior of the build.
 # (must be defined before including definitions.make)
-INTERNAL_MODIFIER_TARGETS := showcommands checkbuild
+INTERNAL_MODIFIER_TARGETS := showcommands checkbuild all incrementaljavac
+
+.PHONY: incrementaljavac
+incrementaljavac: ;
+
+# WARNING:
+# ENABLE_INCREMENTALJAVAC should NOT be enabled by default, because change of
+# a Java source file won't trigger rebuild of its dependent Java files.
+# You can only enable it by adding "incrementaljavac" to your make command line.
+# You are responsible for the correctness of the incremental build.
+# This may decrease incremental build time dramatically for large Java libraries,
+# such as core.jar, framework.jar, etc.
+ENABLE_INCREMENTALJAVAC :=
+ifneq (,$(filter incrementaljavac, $(MAKECMDGOALS)))
+ENABLE_INCREMENTALJAVAC := true
+MAKECMDGOALS := $(filter-out incrementaljavac, $(MAKECMDGOALS))
+endif
 
 # Bring in standard build system definitions.
 include $(BUILD_SYSTEM)/definitions.mk
@@ -205,13 +231,15 @@
     enable_target_debugging :=
   endif
 
-  # TODO: Remove this and the corresponding block in
-  # config/product_config.make once host-based Dalvik preoptimization is
-  # working.
+  # Turn on Dalvik preoptimization for user builds, but only if not
+  # explicitly disabled and the build is running on Linux (since host
+  # Dalvik isn't built for non-Linux hosts).
   ifneq (true,$(DISABLE_DEXPREOPT))
-  ifeq ($(HOST_OS)-$(WITH_DEXPREOPT_buildbot),linux-true)
-    WITH_DEXPREOPT := true
-  endif
+    ifeq ($(user_variant),user)
+      ifeq ($(HOST_OS),linux)
+        WITH_DEXPREOPT := true
+      endif
+    endif
   endif
 
   # Disallow mock locations by default for user builds
@@ -284,6 +312,7 @@
   ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.dexopt-flags=m=y
 endif
 
+ifneq ($(BUILD_TINY_ANDROID),true)
 # Install an apns-conf.xml file if one's not already being installed.
 ifeq (,$(filter %:system/etc/apns-conf.xml, $(PRODUCT_COPY_FILES)))
   PRODUCT_COPY_FILES += \
@@ -292,17 +321,6 @@
     $(warning implicitly installing apns-conf_sdk.xml)
   endif
 endif
-# If we're on an eng or tests build, but not on the sdk, and we have
-# a better one, use that instead.
-ifneq ($(filter eng tests,$(TARGET_BUILD_VARIANT)),)
-  ifndef is_sdk_build
-    apns_to_use := $(wildcard vendor/google/etc/apns-conf.xml)
-    ifneq ($(strip $(apns_to_use)),)
-      PRODUCT_COPY_FILES := \
-            $(filter-out %:system/etc/apns-conf.xml,$(PRODUCT_COPY_FILES)) \
-            $(strip $(apns_to_use)):system/etc/apns-conf.xml
-    endif
-  endif
 endif
 
 ADDITIONAL_BUILD_PROPERTIES += net.bt.name=Android
@@ -380,17 +398,21 @@
 	dalvik/libdex \
 	dalvik/tools/dmtracedump \
 	dalvik/tools/hprof-conv \
-	development/tools/line_endings \
-	development/tools/etc1tool \
-	sdk/emulator/mksdcard \
-	sdk/sdklauncher \
 	development/host \
+	development/tools/etc1tool \
+	development/tools/line_endings \
+	external/clang \
+	external/easymock \
 	external/expat \
 	external/libpng \
+	external/llvm \
 	external/qemu \
 	external/sqlite/dist \
 	external/zlib \
 	frameworks/base \
+	frameworks/compile \
+	sdk/emulator/mksdcard \
+	sdk/sdklauncher \
 	system/core/adb \
 	system/core/fastboot \
 	system/core/libcutils \
@@ -407,13 +429,17 @@
 	sdk/archquery \
 	sdk/androidprefs \
 	sdk/apkbuilder \
+	sdk/common \
+	sdk/ddms \
+	sdk/hierarchyviewer2 \
+	sdk/ide_common \
 	sdk/jarutils \
 	sdk/layoutlib_api \
-	sdk/layoutlib_utils \
+	sdk/layoutopt \
 	sdk/ninepatch \
 	sdk/sdkstats \
 	sdk/sdkmanager \
-	sdk/layoutopt \
+	sdk/swtmenubar \
 	development/apps \
 	development/tools/mkstubs \
 	packages
@@ -429,7 +455,7 @@
 else	# !SDK_ONLY
 ifeq ($(BUILD_TINY_ANDROID), true)
 
-# TINY_ANDROID is a super-minimal build configuration, handy for board 
+# TINY_ANDROID is a super-minimal build configuration, handy for board
 # bringup and very low level debugging
 
 subdirs := \
@@ -440,11 +466,6 @@
 	build/libs \
 	build/target \
 	build/tools/acp \
-	build/tools/apriori \
-	build/tools/kcm \
-	build/tools/soslim \
-	external/elfcopy \
-	external/elfutils \
 	external/yaffs2 \
 	external/zlib
 else	# !BUILD_TINY_ANDROID
@@ -460,6 +481,13 @@
 
 endif	# !SDK_ONLY
 
+# Before we go and include all of the module makefiles, stash away
+# the PRODUCT_* values so that later we can verify they are not modified.
+stash_product_vars:=true
+ifeq ($(stash_product_vars),true)
+  $(call stash-product-vars, __STASHED)
+endif
+
 ifneq ($(ONE_SHOT_MAKEFILE),)
 # We've probably been invoked by the "mm" shell function
 # with a subdirectory's makefile.
@@ -490,6 +518,26 @@
 include $(subdir_makefiles)
 endif # ONE_SHOT_MAKEFILE
 
+ifeq ($(stash_product_vars),true)
+  $(call assert-product-vars, __STASHED)
+endif
+
+include $(BUILD_SYSTEM)/legacy_prebuilts.mk
+ifneq ($(filter-out $(GRANDFATHERED_ALL_PREBUILT),$(strip $(notdir $(ALL_PREBUILT)))),)
+  $(warning *** Some files have been added to ALL_PREBUILT.)
+  $(warning *)
+  $(warning * ALL_PREBUILT is a deprecated mechanism that)
+  $(warning * should not be used for new files.)
+  $(warning * As an alternative, use PRODUCT_COPY_FILES in)
+  $(warning * the appropriate product definition.)
+  $(warning * build/target/product/core.mk is the product)
+  $(warning * definition used in all products.)
+  $(warning *)
+  $(foreach bad_prebuilt,$(filter-out $(GRANDFATHERED_ALL_PREBUILT),$(strip $(notdir $(ALL_PREBUILT)))),$(warning * unexpected $(bad_prebuilt) in ALL_PREBUILT))
+  $(warning *)
+  $(error ALL_PREBUILT contains unexpected files)
+endif
+
 # -------------------------------------------------------------------
 # All module makefiles have been included at this point.
 # -------------------------------------------------------------------
@@ -536,6 +584,7 @@
  )
 m :=
 r :=
+i :=
 add-required-deps :=
 
 # -------------------------------------------------------------------
@@ -568,7 +617,7 @@
 endif
 # Use tags to get the non-APPS user modules.  Use the product
 # definition files to get the APPS user modules.
-user_MODULES := $(sort $(call get-tagged-modules,user))
+user_MODULES := $(sort $(call get-tagged-modules,user shell_$(TARGET_SHELL)))
 user_MODULES := $(user_MODULES) $(user_PACKAGES)
 
 eng_MODULES := $(sort $(call get-tagged-modules,eng))
@@ -667,9 +716,16 @@
 .PHONY: systemtarball
 systemtarball: $(INSTALLED_SYSTEMTARBALL_TARGET)
 
+.PHONY: boottarball
+boottarball: $(INSTALLED_BOOTTARBALL_TARGET)
+
 .PHONY: userdataimage
 userdataimage: $(INSTALLED_USERDATAIMAGE_TARGET)
 
+ifneq (,$(filter userdataimage, $(MAKECMDGOALS)))
+$(call dist-for-goals, userdataimage, $(BUILT_USERDATAIMAGE_TARGET))
+endif
+
 .PHONY: userdatatarball
 userdatatarball: $(INSTALLED_USERDATATARBALL_TARGET)
 
@@ -689,12 +745,15 @@
 	$(INSTALLED_USERDATAIMAGE_TARGET) \
 	$(INSTALLED_FILES_FILE)
 
+# dist_files only for putting your library into the dist directory with a full build.
+.PHONY: dist_files
+
 ifeq ($(EMMA_INSTRUMENT),true)
-  $(call dist-for-goals, droid, $(EMMA_META_ZIP))
+  $(call dist-for-goals, dist_files, $(EMMA_META_ZIP))
 endif
 
-# dist_libraries only for putting your library into the dist directory with a full build.
-.PHONY: dist_libraries
+# Dist for droid if droid is among the cmd goals, or no cmd goal is given.
+ifneq ($(filter droid,$(MAKECMDGOALS))$(filter ||,|$(filter-out $(INTERNAL_MODIFIER_TARGETS),$(MAKECMDGOALS))|),)
 
 ifneq ($(TARGET_BUILD_APPS),)
   # If this build is just for apps, only build apps and not the full system by default.
@@ -733,9 +792,10 @@
    )
 
 # Building a full system-- the default is to build droidcore
-droid: droidcore dist_libraries
+droid: droidcore dist_files
 
-endif
+endif # TARGET_BUILD_APPS
+endif # droid in $(MAKECMDGOALS)
 
 
 .PHONY: droid tests
@@ -753,12 +813,26 @@
 sdk: $(ALL_SDK_TARGETS)
 ifneq ($(filter sdk win_sdk,$(MAKECMDGOALS)),)
 $(call dist-for-goals,sdk win_sdk, \
-	$(ALL_SDK_TARGETS) \
-	$(SYMBOLS_ZIP) \
-	$(INSTALLED_BUILD_PROP_TARGET) \
- )
+    $(ALL_SDK_TARGETS) \
+    $(SYMBOLS_ZIP) \
+    $(INSTALLED_BUILD_PROP_TARGET) \
+)
 endif
 
+.PHONY: samplecode
+sample_MODULES := $(sort $(call get-tagged-modules,samples))
+sample_APKS_DEST_PATH := $(TARGET_COMMON_OUT_ROOT)/samples
+sample_APKS_COLLECTION := \
+        $(foreach module,$(sample_MODULES),$(sample_APKS_DEST_PATH)/$(notdir $(module)))
+$(foreach module,$(sample_MODULES),$(eval $(call \
+        copy-one-file,$(module),$(sample_APKS_DEST_PATH)/$(notdir $(module)))))
+sample_ADDITIONAL_INSTALLED := \
+        $(filter-out $(modules_to_install) $(modules_to_check) $(ALL_PREBUILT),$(sample_MODULES))
+samplecode: $(sample_APKS_COLLECTION)
+	@echo "Collect sample code apks: $^"
+	# remove apks that are not intended to be installed.
+	rm -f $(sample_ADDITIONAL_INSTALLED)
+
 .PHONY: findbugs
 findbugs: $(INTERNAL_FINDBUGS_HTML_TARGET) $(INTERNAL_FINDBUGS_XML_TARGET)
 
diff --git a/core/native_test.mk b/core/native_test.mk
new file mode 100644
index 0000000..3253a5e
--- /dev/null
+++ b/core/native_test.mk
@@ -0,0 +1,18 @@
+###########################################
+## A thin wrapper around BUILD_EXECUTABLE
+## Common flags for native tests are added.
+###########################################
+
+LOCAL_CFLAGS += -DGTEST_OS_LINUX -DGTEST_HAS_STD_STRING
+LOCAL_C_INCLUDES += bionic \
+                    bionic/libstdc++/include \
+                    external/gtest/include \
+                    external/stlport/stlport
+LOCAL_STATIC_LIBRARIES += libgtest libgtest_main
+LOCAL_SHARED_LIBRARIES += libstlport
+
+ifndef LOCAL_MODULE_PATH
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_NATIVE_TESTS)/$(LOCAL_MODULE)
+endif
+
+include $(BUILD_EXECUTABLE)
diff --git a/core/notice_files.mk b/core/notice_files.mk
index fd76d51..74beb49 100644
--- a/core/notice_files.mk
+++ b/core/notice_files.mk
@@ -2,9 +2,9 @@
 ## Track NOTICE files
 ###########################################################
 
-notice_file:=$(shell find $(LOCAL_PATH) -maxdepth 1 -name NOTICE)
+notice_file:=$(strip $(wildcard $(LOCAL_PATH)/NOTICE))
 
-ifneq ($(strip $(notice_file)),)
+ifdef notice_file
 
 # This relies on the name of the directory in PRODUCT_OUT matching where
 # it's installed on the target - i.e. system, data, etc.  This does
diff --git a/core/package.mk b/core/package.mk
index 34792d9..e79059a 100644
--- a/core/package.mk
+++ b/core/package.mk
@@ -19,7 +19,7 @@
 ##
 ## Additional inputs from base_rules.make:
 ## LOCAL_PACKAGE_NAME: The name of the package; the directory
-##		will be called this.
+## will be called this.
 ##
 ## MODULE, MODULE_PATH, and MODULE_SUFFIX will
 ## be set for you.
@@ -76,8 +76,6 @@
 LOCAL_MODULE_TAGS := optional
 endif
 
-#$(warning $(LOCAL_PATH) $(LOCAL_PACKAGE_NAME) $(sort $(LOCAL_MODULE_TAGS)))
-
 ifeq ($(filter tests, $(LOCAL_MODULE_TAGS)),)
 # Force localization check if it's not tagged as tests.
 LOCAL_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) -z
@@ -97,11 +95,6 @@
     $(addprefix $(dir)/, $(LOCAL_RESOURCE_DIR)))) \
   $(LOCAL_RESOURCE_DIR)
 
-# this is an app, so add the system libraries to the search path
-LOCAL_AIDL_INCLUDES += $(FRAMEWORKS_BASE_JAVA_SRC_DIRS)
-
-#$(warning Finding assets for $(LOCAL_ASSET_DIR))
-
 all_assets := $(call find-subdir-assets,$(LOCAL_ASSET_DIR))
 all_assets := $(addprefix $(LOCAL_ASSET_DIR)/,$(patsubst assets/%,%,$(all_assets)))
 
@@ -164,19 +157,20 @@
 endif
 endif
 
-# The dex files go in the package, so we don't
-# want to install them separately for this module.
-old_DONT_INSTALL_DEX_FILES := $(DONT_INSTALL_DEX_FILES)
-DONT_INSTALL_DEX_FILES := true
 #################################
 include $(BUILD_SYSTEM)/java.mk
 #################################
-DONT_INSTALL_DEX_FILES := $(old_DONT_INSTALL_DEX_FILES)
-old_DONT_INSTALL_DEX_FILES =
 
 full_android_manifest := $(LOCAL_PATH)/$(LOCAL_MANIFEST_FILE)
 $(LOCAL_INTERMEDIATE_TARGETS): \
-	PRIVATE_ANDROID_MANIFEST := $(full_android_manifest)
+    PRIVATE_ANDROID_MANIFEST := $(full_android_manifest)
+ifneq (,$(filter-out current, $(LOCAL_SDK_VERSION)))
+$(LOCAL_INTERMEDIATE_TARGETS): \
+    PRIVATE_DEFAULT_APP_TARGET_SDK := $(LOCAL_SDK_VERSION)
+else
+$(LOCAL_INTERMEDIATE_TARGETS): \
+    PRIVATE_DEFAULT_APP_TARGET_SDK := $(DEFAULT_APP_TARGET_SDK)
+endif
 
 ifneq ($(all_resources),)
 
@@ -197,25 +191,23 @@
 $(R_file_stamp): PRIVATE_RESOURCE_PUBLICS_OUTPUT := \
 			$(intermediates.COMMON)/public_resources.xml
 $(R_file_stamp): PRIVATE_PROGUARD_OPTIONS_FILE := $(proguard_options_file)
-$(R_file_stamp): $(all_res_assets) $(full_android_manifest) $(AAPT) | $(ACP)
+$(R_file_stamp): $(all_res_assets) $(full_android_manifest) $(RenderScript_file_stamp) $(AAPT) | $(ACP)
 	@echo "target R.java/Manifest.java: $(PRIVATE_MODULE) ($@)"
 	@rm -f $@
 	$(create-resource-java-files)
 	$(hide) for GENERATED_MANIFEST_FILE in `find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) \
 					-name Manifest.java 2> /dev/null`; do \
-		dir=`grep package $$GENERATED_MANIFEST_FILE | head -n1 | \
-			awk '{print $$2}' | tr -d ";" | tr . /`; \
+		dir=`awk '/package/{gsub(/\./,"/",$$2);gsub(/;/,"",$$2);print $$2;exit}' $$GENERATED_MANIFEST_FILE`; \
 		mkdir -p $(TARGET_COMMON_OUT_ROOT)/R/$$dir; \
-		$(ACP) -fpt $$GENERATED_MANIFEST_FILE $(TARGET_COMMON_OUT_ROOT)/R/$$dir; \
+		$(ACP) -fp $$GENERATED_MANIFEST_FILE $(TARGET_COMMON_OUT_ROOT)/R/$$dir; \
 	done;
 	$(hide) for GENERATED_R_FILE in `find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) \
 					-name R.java 2> /dev/null`; do \
-		dir=`grep package $$GENERATED_R_FILE | head -n1 | \
-			awk '{print $$2}' | tr -d ";" | tr . /`; \
+		dir=`awk '/package/{gsub(/\./,"/",$$2);gsub(/;/,"",$$2);print $$2;exit}' $$GENERATED_R_FILE`; \
 		mkdir -p $(TARGET_COMMON_OUT_ROOT)/R/$$dir; \
-		$(ACP) -fpt $$GENERATED_R_FILE $(TARGET_COMMON_OUT_ROOT)/R/$$dir \
+		$(ACP) -fp $$GENERATED_R_FILE $(TARGET_COMMON_OUT_ROOT)/R/$$dir \
 			|| exit 31; \
-		$(ACP) -fpt $$GENERATED_R_FILE $@ || exit 32; \
+		$(ACP) -fp $$GENERATED_R_FILE $@ || exit 32; \
 	done; \
 
 $(proguard_options_file): $(R_file_stamp)
@@ -229,8 +221,8 @@
 
 # add-assets-to-package looks at PRODUCT_AAPT_CONFIG, but this target
 # can't know anything about PRODUCT.  Clear it out just for this target.
-$(resource_export_package): PRODUCT_AAPT_CONFIG :=
-$(resource_export_package): $(all_res_assets) $(full_android_manifest) $(AAPT)
+$(resource_export_package): PRIVATE_PRODUCT_AAPT_CONFIG :=
+$(resource_export_package): $(all_res_assets) $(full_android_manifest) $(RenderScript_file_stamp) $(AAPT)
 	@echo "target Export Resources: $(PRIVATE_MODULE) ($@)"
 	$(create-empty-package)
 	$(add-assets-to-package)
@@ -248,7 +240,7 @@
 $(full_classes_compiled_jar): $(R_file_stamp)
 endif
 
-endif	# all_resources
+endif  # all_resources
 
 ifeq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
 # We need to explicitly clear this var so that we don't
@@ -261,20 +253,20 @@
 ifneq ($(filter-out current,$(LOCAL_SDK_VERSION)),)
 # for released sdk versions, the platform resources were built into android.jar.
 framework_res_package_export := \
-	$(HISTORICAL_SDK_VERSIONS_ROOT)/$(LOCAL_SDK_VERSION)/android.jar
+    $(HISTORICAL_SDK_VERSIONS_ROOT)/$(LOCAL_SDK_VERSION)/android.jar
 framework_res_package_export_deps := $(framework_res_package_export)
 else # LOCAL_SDK_VERSION
 framework_res_package_export := \
-	$(call intermediates-dir-for,APPS,framework-res,,COMMON)/package-export.apk
+    $(call intermediates-dir-for,APPS,framework-res,,COMMON)/package-export.apk
 # We can't depend directly on the export.apk file; it won't get its
 # PRIVATE_ vars set up correctly if we do.  Instead, depend on the
 # corresponding R.stamp file, which lists the export.apk as a dependency.
 framework_res_package_export_deps := \
-	$(dir $(framework_res_package_export))src/R.stamp
+    $(dir $(framework_res_package_export))src/R.stamp
 endif # LOCAL_SDK_VERSION
 $(R_file_stamp): $(framework_res_package_export_deps)
 $(LOCAL_INTERMEDIATE_TARGETS): \
-	PRIVATE_AAPT_INCLUDES := $(framework_res_package_export)
+    PRIVATE_AAPT_INCLUDES := $(framework_res_package_export)
 endif # LOCAL_NO_STANDARD_LIBRARIES
 
 ifneq ($(full_classes_jar),)
@@ -292,6 +284,16 @@
       $(addsuffix $(so_suffix), \
         $(LOCAL_JNI_SHARED_LIBRARIES)))
 
+# Set the abi directory used by the local JNI shared libraries.
+# (Doesn't change how the local shared libraries are compiled, just
+# sets where they are stored in the apk.)
+
+ifeq ($(LOCAL_JNI_SHARED_LIBRARIES_ABI),)
+    jni_shared_libraries_abi := $(TARGET_CPU_ABI)
+else
+    jni_shared_libraries_abi := $(LOCAL_JNI_SHARED_LIBRARIES_ABI)
+endif
+
 # Pick a key to sign the package with.  If this package hasn't specified
 # an explicit certificate, use the default.
 # Secure release builds will have their packages signed after the fact,
@@ -329,9 +331,15 @@
 $(LOCAL_BUILT_MODULE): $(DEXPREOPT_BOOT_ODEXS) | $(DEXPREOPT) $(DEXOPT)
 endif
 $(LOCAL_BUILT_MODULE): PRIVATE_JNI_SHARED_LIBRARIES := $(jni_shared_libraries)
+$(LOCAL_BUILT_MODULE): PRIVATE_JNI_SHARED_LIBRARIES_ABI := $(jni_shared_libraries_abi)
 ifneq ($(TARGET_BUILD_APPS),)
     # Include all resources for unbundled apps.
-    $(LOCAL_BUILT_MODULE): PRODUCT_AAPT_CONFIG :=
+    LOCAL_AAPT_INCLUDE_ALL_RESOURCES := true
+endif
+ifeq ($(LOCAL_AAPT_INCLUDE_ALL_RESOURCES),true)
+    $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_CONFIG :=
+else
+    $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_CONFIG := $(PRODUCT_AAPT_CONFIG)
 endif
 $(LOCAL_BUILT_MODULE): $(all_res_assets) $(jni_shared_libraries) $(full_android_manifest)
 	@echo "target Package: $(PRIVATE_MODULE) ($@)"
diff --git a/core/pathmap.mk b/core/pathmap.mk
index 6cd3b8f..78dee49 100644
--- a/core/pathmap.mk
+++ b/core/pathmap.mk
@@ -48,7 +48,8 @@
     libthread_db:bionic/libthread_db/include \
     mkbootimg:system/core/mkbootimg \
     recovery:bootable/recovery \
-    system-core:system/core/include
+    system-core:system/core/include \
+    speex:external/speex/include
 
 #
 # Returns the path to the requested module's include directory,
@@ -82,12 +83,14 @@
 	    graphics \
 	    location \
 	    media \
+	    drm \
 	    opengl \
 	    sax \
 	    telephony \
 	    wifi \
 	    vpn \
 	    keystore \
+	    icu4j \
 	    voip \
 	 )
 
diff --git a/core/phony_package.mk b/core/phony_package.mk
new file mode 100644
index 0000000..3644db8
--- /dev/null
+++ b/core/phony_package.mk
@@ -0,0 +1,17 @@
+ifneq ($(strip $(LOCAL_SRC_FILES)),)
+$(error LOCAL_SRC_FILES are not allowed for phony packages)
+endif
+
+ifeq ($(strip $(LOCAL_REQUIRED_MODULES)),)
+$(error LOCAL_REQUIRED_MODULES is required for phony packages)
+endif
+
+LOCAL_MODULE_CLASS := FAKE
+LOCAL_MODULE_SUFFIX := -timestamp
+
+include $(BUILD_SYSTEM)/base_rules.mk
+
+$(LOCAL_BUILT_MODULE):
+	$(hide) echo "Fake: $@"
+	$(hide) mkdir -p $(dir $@)
+	$(hide) touch $@
diff --git a/core/prelink-linux-arm.map b/core/prelink-linux-arm.map
deleted file mode 100644
index 7daaf98..0000000
--- a/core/prelink-linux-arm.map
+++ /dev/null
@@ -1,213 +0,0 @@
-# 0xC0000000 - 0xFFFFFFFF Kernel
-# 0xB0100000 - 0xBFFFFFFF Thread 0 Stack
-# 0xB0000000 - 0xB00FFFFF Linker
-# 0xA0000000 - 0xBFFFFFFF Prelinked System Libraries
-# 0x90000000 - 0x9FFFFFFF Prelinked App Libraries
-# 0x80000000 - 0x8FFFFFFF Non-prelinked Libraries
-# 0x40000000 - 0x7FFFFFFF mmap'd stuff
-# 0x10000000 - 0x3FFFFFFF Thread Stacks
-# 0x00000000 - 0x0FFFFFFF .text / .data / heap
-
-# Note: The general rule is that libraries should be aligned on 1MB
-# boundaries. For ease of updating this file, you will find a comment
-# on each line, indicating the observed size of the library, which is
-# one of:
-#
-#     [<64K] observed to be less than 64K
-#     [~1M] rounded up, one megabyte (similarly for other sizes)
-#     [???] no size observed, assumed to be one megabyte
-#
-# note: look at the LOAD sections in the library header:
-#
-#   arm-eabi-objdump -x <lib>
-#
-
-# core system libraries
-libdl.so                0xAFF00000 # [<64K]
-libc.so                 0xAFD00000 # [~2M]
-libstdc++.so            0xAFC00000 # [<64K]
-libm.so                 0xAFB00000 # [~1M]
-liblog.so               0xAFA00000 # [<64K]
-libcutils.so            0xAF900000 # [~1M]
-libthread_db.so         0xAF800000 # [<64K]
-libz.so                 0xAF700000 # [~1M]
-libevent.so             0xAF600000 # [???]
-libssl.so               0xAF400000 # [~2M]
-libcrypto.so            0xAF000000 # [~4M]
-libsysutils.so          0xAEF00000 # [~1M]
-
-# bluetooth
-liba2dp.so              0xAEE00000 # [~1M]
-audio.so                0xAED00000 # [~1M]
-input.so                0xAEC00000 # [~1M]
-libbluetoothd.so        0xAEA00000 # [~2M]
-libbluedroid.so         0xAE900000 # [<64K]
-libbluetooth.so         0xAE800000 # [~1M]
-libdbus.so              0xAE700000 # [~1M]
-
-# extended system libraries
-libril.so               0xAE600000 # [~1M]
-libreference-ril.so     0xAE500000 # [~1M]
-libwpa_client.so        0xAE400000 # [<64K]
-libnetutils.so          0xAE300000 # [~1M]
-
-# core dalvik runtime support
-libandroid_servers.so   0xAE200000 # [~1M]
-libicuuc.so             0xADE00000 # [~4M]
-libicui18n.so           0xAD900000 # [~5M]
-libandroid_runtime.so   0xAD300000 # [~6M]
-libnativehelper.so      0xAD100000 # [~2M]
-libdvm-ARM.so           0xAD000000 # [???]
-libdvm.so               0xACA00000 # [~6M]
-# Note: libicudata.so intentionally omitted
-
-# graphics
-libpixelflinger.so      0xAC900000 # [~1M]
-# libcorecg is for backward-compatibility with donut
-libcorecg.so            0xAC800000 # [???]
-libsurfaceflinger_client.so 0xAC700000 # [~1M]
-libsurfaceflinger.so    0xAC500000 # [~2M]
-libGLES_android.so      0xAC400000 # [~1M]
-libagl.so               0xAC300000 # [???]
-
-libGLESv1_CM.so         0xAC200000 # [~1M]
-libGLESv2.so            0xAC100000 # [~1M]
-libOpenVG_CM.so         0xAC000000 # [???]
-libOpenVGU_CM.so        0xABF00000 # [???]
-libEGL.so               0xABE00000 # [~1M]
-libETC1.so              0xABD00000 # [<64K]
-
-libacc.so               0xABC00000 # [~1M]
-
-libexif.so              0xABB00000 # [~1M]
-libcamera_client.so     0xABA80000 # [~1M]
-libui.so                0xAB900000 # [~1M]
-libgui.so               0xAB800000 # [~1M]
-libskia.so              0xAB100000 # [~2M]
-librs_jni.so            0xAB000000 # [~1M]
-libRS.so                0xA9E00000 # [~2M]
-libandroid.so           0xA9D80000 # [<64K]
-libjnigraphics.so       0xA9D00000 # [<64K]
-libskiagl.so            0xA9C00000 # [~1M]
-
-# audio
-libFLAC.so              0xA9B00000 # [???]
-libaudiopolicy.so       0xA9A00000 # [~1M]
-libeffects.so           0xA9980000 # [<64K]
-libaudioeffect_jni.so   0xA9900000 # [<64K]
-libsoundpool.so         0xA9800000 # [~1M]
-libaudio.so             0xA9700000 # [~1M]
-libspeech.so            0xA9600000 # [~1M]
-libsonivox.so           0xA9500000 # [~1M]
-libvorbisidec.so        0xA9400000 # [~1M]
-libmedia_jni.so         0xA9300000 # [~1M]
-libmediaplayerservice.so 0xA9200000 # [~1M]
-libmedia.so             0xA9000000 # [~2M]
-libFFTEm.so             0xA8F00000 # [~1M]
-libSR_AudioIn.so        0xA8E00000 # [~1M] for external/srec
-libaudioflinger.so      0xA8D00000 # [~1M]
-
-# assorted system libraries
-libsqlite.so            0xA8B00000 # [~2M]
-libexpat.so             0xA8A00000 # [~1M]
-libwebcore.so           0xA8300000 # [~7M]
-libbinder.so            0xA8200000 # [~1M]
-libutils.so             0xA8100000 # [~1M]
-libcameraservice.so     0xA8000000 # [~1M]
-libhardware.so          0xA7F00000 # [<64K]
-libhardware_legacy.so   0xA7E00000 # [~1M]
-libapp_process.so       0xA7D00000 # [???]
-libsystem_server.so     0xA7C00000 # [~1M]
-libime.so               0xA7B00000 # [???]
-libgps.so               0xA7A00000 # [~1M]
-libcamera.so            0xA7900000 # [~1M]
-liboemcamera.so         0xA7700000 # [~2M]
-libdiskconfig.so        0xA7600000 # [<64K]
-libemoji.so             0xA7500000 # [<64K]
-libjni_latinime.so      0xA7400000 # [~1M]
-libjni_pinyinime.so     0xA7300000 # [~1M]
-libttssynthproxy.so     0xA7200000 # [~1M] for frameworks/base
-libttspico.so           0xA7000000 # [~2M] for external/svox
-
-# pv libraries
-libpvasf.so                    0xA6F00000 # [???]
-libpvasfreg.so                 0xA6E00000 # [???]
-libomx_sharedlibrary.so        0xA6D00000 # [~1M]
-libopencore_download.so        0xA6C00000 # [~1M]
-libopencore_downloadreg.so     0xA6B00000 # [~1M]
-libopencore_net_support.so     0xA6800000 # [~3M]
-libopencore_rtsp.so            0xA6200000 # [~6M]
-libopencore_rtspreg.so         0xA6100000 # [~1M]
-libopencore_author.so          0xA5D00000 # [~4M]
-libomx_aacdec_sharedlibrary.so 0xA5B00000 # [~2M]
-libomx_amrdec_sharedlibrary.so 0xA5A00000 # [~1M]
-libomx_amrenc_sharedlibrary.so 0xA5900000 # [~1M]
-libomx_avcdec_sharedlibrary.so 0xA5800000 # [~1M]
-libomx_avcenc_sharedlibrary.so 0xA5700000 # [???]
-libomx_m4vdec_sharedlibrary.so 0xA5600000 # [~1M]
-libomx_m4venc_sharedlibrary.so 0xA5500000 # [???]
-libomx_mp3dec_sharedlibrary.so 0xA5400000 # [~1M]
-libopencore_mp4local.so        0xA5200000 # [~2M]
-libopencore_mp4localreg.so     0xA5100000 # [~1M]
-libopencore_player.so          0xA4800000 # [~9M]
-
-# opencore hardware support
-libmm-adspsvc.so              0xA4700000 # [<64K]
-libOmxCore.so                 0xA4600000 # [<64K]
-libOmxMpeg4Dec.so             0xA4500000 # [~1M]
-libOmxH264Dec.so              0xA4400000 # [~1M]
-libOmxVidEnc.so               0xA4300000 # [~1M]
-libopencorehw.so              0xA4200000 # [~1M]
-libOmxVdec.so                 0xA4100000 # [~1M]
-libmm-omxcore.so              0xA4000000 # [<64K]
-
-# pv libraries
-libopencore_common.so         0xA3900000 # [~7M]
-libqcomm_omx.so               0xA3800000 # [<64K]
-
-# stagefright libraries
-libstagefright_amrnb_common.so     0xA3700000 # [~1M]
-libstagefright_avc_common.so       0xA3600000 # [~1M]
-libstagefright_color_conversion.so 0xA3500000 # [<64K]
-libstagefright_omx.so              0xA3400000 # [~1M]
-libstagefrighthw.so                0xA3300000 # [~1M]
-libstagefright.so                  0xA2F00000 # [~4M]
-
-# libraries for specific hardware
-libgsl.so               0xA2E00000 # [~1M]
-libhtc_acoustic.so      0xA2D00000 # [<64K]
-libhtc_ril.so           0xA2C00000 # [~1M]
-liblvmxipc.so           0xA2B00000 # [~1M] for vendor/nxp
-libreference-cdma-sms.so 0xA2A00000 # [<64K] for hardware/ril
-
-# libraries for specific apps or temporary libraries
-libcam_ipl.so           0x9F000000 # [???]
-libwbxml.so             0x9EF00000 # [???]
-libwbxml_jni.so         0x9EE00000 # [~1M]
-libxml2wbxml.so         0x9EB00000 # [~1M]
-libdrm1.so              0x9EA00000 # [~1M]
-libdrm1_jni.so          0x9E900000 # [<64K]
-libwapcore.so           0x9E800000 # [???]
-libstreetview.so        0x9E700000 # [???]
-libwapbrowsertest.so    0x9E600000 # [???]
-libminiglobe.so         0x9E500000 # [???]
-libearth.so             0x9E400000 # [???]
-libembunit.so           0x9E300000 # [<64K]
-libneon.so              0x9E200000 # [???]
-libjni_example.so       0x9E100000 # [???]
-libjni_load_test.so     0x9E000000 # [???]
-libjni_lib_test.so      0x9DF00000 # [???]
-librunperf.so           0x9DE00000 # [???]
-libctest.so             0x9DD00000 # [<64K]
-libUAPI_jni.so          0x9DC00000 # [???]
-librpc.so               0x9DB00000 # [~1M]
-libtrace_test.so        0x9DA00000 # [???]
-libsrec_jni.so          0x9D800000 # [~2M]
-libjpeg.so              0x9D700000 # [~1M]
-libiprouteutil.so       0x9D600000 # [~1M] for external/iproute2
-libnetlink.so           0x9D500000 # [<64K] for external/iproute2
-libpagemap.so           0x9D400000 # [<64K] for system/extras/libpagemap
-libstlport.so           0x9D100000 # [~3M] for external/stlport
-libzxing.so             0x9D000000 # [<64K] for goggles
-libinterstitial.so      0x9CF00000 # [<64K] for goggles
-liblept.so              0x9CA00000 # [~5M] for external/leptonica
diff --git a/core/product.mk b/core/product.mk
index 4a0ee01..2efc446 100644
--- a/core/product.mk
+++ b/core/product.mk
@@ -63,14 +63,17 @@
     PRODUCT_NAME \
     PRODUCT_MODEL \
     PRODUCT_LOCALES \
+    PRODUCT_AAPT_CONFIG \
     PRODUCT_PACKAGES \
     PRODUCT_DEVICE \
     PRODUCT_MANUFACTURER \
     PRODUCT_BRAND \
     PRODUCT_PROPERTY_OVERRIDES \
+    PRODUCT_DEFAULT_PROPERTY_OVERRIDES \
     PRODUCT_CHARACTERISTICS \
     PRODUCT_COPY_FILES \
     PRODUCT_OTA_PUBLIC_KEYS \
+    PRODUCT_EXTRA_RECOVERY_KEYS \
     PRODUCT_PACKAGE_OVERLAYS \
     DEVICE_PACKAGE_OVERLAYS \
     PRODUCT_CONTRIBUTORS_FILE \
@@ -187,3 +190,72 @@
 define resolve-short-product-name
 $(strip $(call _resolve-short-product-name,$(1)))
 endef
+
+
+_product_stash_var_list := $(_product_var_list) \
+	TARGET_ARCH \
+	TARGET_ARCH_VARIANT \
+	TARGET_BOARD_PLATFORM \
+	TARGET_BOARD_PLATFORM_GPU \
+	TARGET_BOOTLOADER_BOARD_NAME \
+	TARGET_COMPRESS_MODULE_SYMBOLS \
+	TARGET_NO_BOOTLOADER \
+	TARGET_NO_KERNEL \
+	TARGET_NO_RECOVERY \
+	TARGET_NO_RADIOIMAGE \
+	TARGET_HARDWARE_3D \
+	TARGET_PROVIDES_INIT_RC \
+	TARGET_CPU_ABI \
+	TARGET_CPU_ABI2 \
+	TARGET_CPU_SMP \
+
+
+_product_stash_var_list += \
+	BOARD_WPA_SUPPLICANT_DRIVER \
+	BOARD_WLAN_DEVICE \
+	BOARD_USES_GENERIC_AUDIO \
+	BOARD_KERNEL_CMDLINE \
+	BOARD_KERNEL_BASE \
+	BOARD_HAVE_BLUETOOTH \
+	BOARD_HAVE_BLUETOOTH_BCM \
+	BOARD_VENDOR_QCOM_AMSS_VERSION \
+	BOARD_VENDOR_USE_AKMD \
+	BOARD_EGL_CFG \
+	BOARD_BOOTIMAGE_PARTITION_SIZE \
+	BOARD_RECOVERYIMAGE_PARTITION_SIZE \
+	BOARD_SYSTEMIMAGE_PARTITION_SIZE \
+	BOARD_USERDATAIMAGE_PARTITION_SIZE \
+	BOARD_FLASH_BLOCK_SIZE \
+	BOARD_SYSTEMIMAGE_PARTITION_SIZE \
+	BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE \
+	BOARD_VENDOR_QCOM_GPS_LOC_API_AMSS_VERSION \
+	BOARD_INSTALLER_CMDLINE \
+
+
+#
+# Stash vaues of the variables in _product_stash_var_list.
+# $(1): Renamed prefix
+#
+define stash-product-vars
+$(foreach v,$(_product_stash_var_list), \
+        $(eval $(strip $(1))_$(call rot13,$(v)):=$$($$(v))) \
+ )
+endef
+
+#
+# Assert that the the variable stashed by stash-product-vars remains untouched.
+# $(1): The prefix as supplied to stash-product-vars
+#
+define assert-product-vars
+$(strip \
+  $(eval changed_variables:=)
+  $(foreach v,$(_product_stash_var_list), \
+    $(if $(call streq,$($(v)),$($(strip $(1))_$(call rot13,$(v)))),, \
+        $(eval $(warning $(v) has been modified: $($(v)))) \
+        $(eval $(warning previous value: $($(strip $(1))_$(call rot13,$(v))))) \
+        $(eval changed_variables := $(changed_variables) $(v))) \
+   ) \
+  $(if $(changed_variables),\
+    $(eval $(error The following variables have been changed: $(changed_variables))),)
+)
+endef
diff --git a/core/product_config.mk b/core/product_config.mk
index 70ac894..d766ba7 100644
--- a/core/product_config.mk
+++ b/core/product_config.mk
@@ -124,15 +124,6 @@
     default_goal_substitution := tests-build-target
   endif
 
-  # Hack to make the linux build servers use dexpreopt (emulator-based
-  # preoptimization). Most engineers don't use this type of target
-  # ("make PRODUCT-blah-user"), so this should only tend to happen when
-  # using buildbot.
-  # TODO: Remove this once host Dalvik preoptimization is working.
-  ifeq ($(TARGET_BUILD_VARIANT),user)
-    WITH_DEXPREOPT_buildbot := true
-  endif
-
   # Replace the PRODUCT-* goal with the build goal that it refers to.
   # Note that this will ensure that it appears in the same relative
   # position, in case it matters.
@@ -173,6 +164,27 @@
 endif # unbundled_goals
 
 # ---------------------------------------------------------------
+# Simulator overrides
+ifeq ($(TARGET_PRODUCT),sim)
+  # Tell the build system to turn on some special cases
+  # to deal with the simulator product.
+  TARGET_SIMULATOR := true
+  # dexpreopt doesn't work when building the simulator
+  DISABLE_DEXPREOPT := true
+endif
+
+# Default to building dalvikvm on hosts that support it...
+ifeq ($(HOST_OS),linux)
+# ... but not if we're building the sim...
+ifneq ($(TARGET_SIMULATOR),true)
+# ... or if the if the option is already set
+ifeq ($(WITH_HOST_DALVIK),)
+  WITH_HOST_DALVIK := true
+endif
+endif
+endif
+
+# ---------------------------------------------------------------
 # Include the product definitions.
 # We need to do this to translate TARGET_PRODUCT into its
 # underlying TARGET_DEVICE before we start defining any rules.
@@ -194,8 +206,11 @@
   $(call import-products, $(get-all-product-makefiles))
 endif # TARGET_BUILD_APPS
 $(check-all-products)
-#$(dump-products)
-#$(error done)
+
+ifneq ($(filter dump-products, $(MAKECMDGOALS)),)
+$(dump-products)
+$(error done)
+endif
 
 # Convert a short name like "sooner" into the path to the product
 # file defining that product.
@@ -223,17 +238,18 @@
   extra_locales :=
 endif
 
+# Add PRODUCT_LOCALES to PRODUCT_AAPT_CONFIG
+PRODUCT_AAPT_CONFIG := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_AAPT_CONFIG))
+PRODUCT_AAPT_CONFIG := $(PRODUCT_LOCALES) $(PRODUCT_AAPT_CONFIG)
+
 # Default to medium-density assets.
-# (Can be overridden in the device config, e.g.: PRODUCT_LOCALES += hdpi)
-PRODUCT_LOCALES := $(strip \
-	$(PRODUCT_LOCALES) \
-	$(if $(filter %dpi,$(PRODUCT_LOCALES)),,mdpi))
+# (Can be overridden in the device config, e.g.: PRODUCT_AAPT_CONFIG += hdpi)
+PRODUCT_AAPT_CONFIG := $(strip \
+	$(PRODUCT_AAPT_CONFIG) \
+	$(if $(filter %dpi,$(PRODUCT_AAPT_CONFIG)),,mdpi))
 
 # Everyone gets nodpi assets which are density-independent.
-PRODUCT_LOCALES += nodpi
-
-# Assemble the list of options.
-PRODUCT_AAPT_CONFIG := $(PRODUCT_LOCALES)
+PRODUCT_AAPT_CONFIG += nodpi
 
 # Convert spaces to commas.
 comma := ,
@@ -279,6 +295,12 @@
 PRODUCT_PROPERTY_OVERRIDES := \
 	$(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PROPERTY_OVERRIDES))
 
+# A list of property assignments, like "key = value", with zero or more
+# whitespace characters on either side of the '='.
+# used for adding properties to default.prop
+PRODUCT_DEFAULT_PROPERTY_OVERRIDES := \
+	$(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_DEFAULT_PROPERTY_OVERRIDES))
+
 # Should we use the default resources or add any product specific overlays
 PRODUCT_PACKAGE_OVERLAYS := \
 	$(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGE_OVERLAYS))
@@ -300,12 +322,5 @@
 PRODUCT_OTA_PUBLIC_KEYS := $(sort \
     $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_OTA_PUBLIC_KEYS))
 
-# ---------------------------------------------------------------
-# Simulator overrides
-ifeq ($(TARGET_PRODUCT),sim)
-  # Tell the build system to turn on some special cases
-  # to deal with the simulator product.
-  TARGET_SIMULATOR := true
-  # dexpreopt doesn't work when building the simulator
-  DISABLE_DEXPREOPT := true
-endif
+PRODUCT_EXTRA_RECOVERY_KEYS := $(sort \
+    $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_EXTRA_RECOVERY_KEYS))
diff --git a/core/shared_library.mk b/core/shared_library.mk
index 77d253f..47a089a 100644
--- a/core/shared_library.mk
+++ b/core/shared_library.mk
@@ -13,9 +13,6 @@
 ifeq ($(strip $(LOCAL_MODULE_SUFFIX)),)
 LOCAL_MODULE_SUFFIX := $(TARGET_SHLIB_SUFFIX)
 endif
-ifeq ($(strip $(LOCAL_PRELINK_MODULE)),)
-LOCAL_PRELINK_MODULE := $(strip $(TARGET_PRELINK_MODULE))
-endif
 ifneq ($(strip $(OVERRIDE_BUILT_MODULE_PATH)),)
 $(error $(LOCAL_PATH): Illegal use of OVERRIDE_BUILT_MODULE_PATH)
 endif
@@ -34,12 +31,11 @@
 my_target_crtbegin_so_o := $(TARGET_CRTBEGIN_SO_O)
 my_target_crtend_so_o := $(TARGET_CRTEND_SO_O)
 ifdef LOCAL_NDK_VERSION
-my_target_global_ld_dirs += -L$(my_ndk_version_root)/usr/lib
-# The latest ndk does NOT support TARGET_CRTBEGIN_SO_O and TARGET_CRTEND_SO_O yet.
-# my_target_crtbegin_so_o := $(my_ndk_version_root)/usr/lib/crtbegin_so.o
-# my_target_crtend_so_o := $(my_ndk_version_root)/usr/lib/crtend_so.o
-my_target_crtbegin_so_o :=
-my_target_crtend_so_o :=
+my_target_global_ld_dirs += $(addprefix -L, $(patsubst %/,%,$(dir $(my_ndk_stl_shared_lib_fullpath))) \
+   $(my_ndk_version_root)/usr/lib)
+my_target_global_ldflags := $(my_ndk_stl_shared_lib) $(my_target_global_ldflags)
+my_target_crtbegin_so_o := $(wildcard $(my_ndk_version_root)/usr/lib/crtbegin_so.o)
+my_target_crtend_so_o := $(wildcard $(my_ndk_version_root)/usr/lib/crtend_so.o)
 endif
 $(linked_module): PRIVATE_TARGET_GLOBAL_LD_DIRS := $(my_target_global_ld_dirs)
 $(linked_module): PRIVATE_TARGET_GLOBAL_LDFLAGS := $(my_target_global_ldflags)
diff --git a/core/tasks/apicheck.mk b/core/tasks/apicheck.mk
index 740668c..96e0f44 100644
--- a/core/tasks/apicheck.mk
+++ b/core/tasks/apicheck.mk
@@ -25,14 +25,14 @@
 #
 # Args:
 #    $(1)  target
-#    $(2)  stable api xml file
-#    $(3)  api xml file to be tested
+#    $(2)  stable api file
+#    $(3)  api file to be tested
 #    $(4)  arguments for apicheck
 #    $(5)  command to run if apicheck failed
 define check-api
 $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/$(strip $(1))-timestamp: $(2) $(3) $(APICHECK)
 	@echo "Checking API:" $(1)
-	$(hide) ( $(APICHECK) $(4) $(2) $(3) || ( $(5) ; exit 38 ) )
+	$(hide) ( $(APICHECK_COMMAND) $(4) $(2) $(3) || ( $(5) ; exit 38 ) )
 	$(hide) mkdir -p $$(dir $$@)
 	$(hide) touch $$@
 checkapi: $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/$(strip $(1))-timestamp
@@ -41,10 +41,11 @@
 # Run the checkapi rules by default.
 droidcore: checkapi
 
-last_released_sdk_version := $(lastword $(call numerically_sort,\
-    $(patsubst $(SRC_API_DIR)/%.xml,%, \
-    $(filter-out $(SRC_API_DIR)/current.xml, \
-    $(wildcard $(SRC_API_DIR)/*.xml)))))
+last_released_sdk_version := $(lastword $(call numerically_sort, \
+            $(filter-out $(SRC_API_DIR)/current, \
+                $(patsubst $(SRC_API_DIR)/%.txt,%, $(wildcard $(SRC_API_DIR)/*.txt)) \
+             )\
+        ))
 
 # INTERNAL_PLATFORM_API_FILE is the one build by droiddoc.
 
@@ -52,7 +53,7 @@
 # SDK version.
 $(eval $(call check-api, \
 	checkapi-last, \
-	$(SRC_API_DIR)/$(last_released_sdk_version).xml, \
+	$(SRC_API_DIR)/$(last_released_sdk_version).txt, \
 	$(INTERNAL_PLATFORM_API_FILE), \
 	-hide 2 -hide 3 -hide 4 -hide 5 -hide 6 -hide 24 -hide 25 \
 	-error 7 -error 8 -error 9 -error 10 -error 11 -error 12 -error 13 -error 14 -error 15 \
@@ -64,7 +65,7 @@
 # SDK version.
 $(eval $(call check-api, \
 	checkapi-current, \
-	$(SRC_API_DIR)/current.xml, \
+	$(SRC_API_DIR)/current.txt, \
 	$(INTERNAL_PLATFORM_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 \
@@ -75,7 +76,7 @@
 
 .PHONY: update-api
 update-api: $(INTERNAL_PLATFORM_API_FILE) | $(ACP)
-	@echo Copying current.xml
-	$(hide) $(ACP) $(INTERNAL_PLATFORM_API_FILE) $(SRC_API_DIR)/current.xml
+	@echo Copying current.txt
+	$(hide) $(ACP) $(INTERNAL_PLATFORM_API_FILE) $(SRC_API_DIR)/current.txt
 
 endif
diff --git a/core/tasks/cts.mk b/core/tasks/cts.mk
index 8c36ef6..c2bfa27 100644
--- a/core/tasks/cts.mk
+++ b/core/tasks/cts.mk
@@ -28,34 +28,38 @@
 DDMLIB_JAR := $(HOST_OUT_JAVA_LIBRARIES)/ddmlib-prebuilt.jar
 junit_host_jar := $(HOST_OUT_JAVA_LIBRARIES)/junit.jar
 HOSTTESTLIB_JAR := $(HOST_OUT_JAVA_LIBRARIES)/hosttestlib.jar
+TF_JAR := $(HOST_OUT_JAVA_LIBRARIES)/tradefed-prebuilt.jar
+CTS_TF_JAR := $(HOST_OUT_JAVA_LIBRARIES)/cts-tradefed.jar
+CTS_TF_EXEC_PATH := $(HOST_OUT_EXECUTABLES)/cts-tradefed
+CTS_TF_README_PATH := $(cts_tools_src_dir)/tradefed-host/README
 
 CTS_CORE_CASE_LIST := \
-	android.core.tests.dom \
-	android.core.tests.luni.io \
-	android.core.tests.luni.lang \
-	android.core.tests.luni.net \
-	android.core.tests.luni.util \
-	android.core.tests.xml \
+	android.core.tests.libcore.package.dalvik \
+	android.core.tests.libcore.package.com \
+	android.core.tests.libcore.package.sun \
+	android.core.tests.libcore.package.tests \
+	android.core.tests.libcore.package.org \
+	android.core.tests.libcore.package.libcore \
 	android.core.tests.runner
 
 -include cts/CtsTestCaseList.mk
 CTS_CASE_LIST := $(CTS_CORE_CASE_LIST) $(CTS_TEST_CASE_LIST)
 
-DEFAULT_TEST_PLAN := $(PRIVATE_DIR)/resource/plans
+DEFAULT_TEST_PLAN := $(cts_dir)/$(cts_name)/resource/plans
 
 $(cts_dir)/all_cts_files_stamp: PRIVATE_JUNIT_HOST_JAR := $(junit_host_jar)
 
 -include cts/CtsHostLibraryList.mk
-$(cts_dir)/all_cts_files_stamp: $(CTS_CASE_LIST) $(junit_host_jar) $(HOSTTESTLIB_JAR) $(CTS_HOST_LIBRARY_JARS) $(ACP)
+$(cts_dir)/all_cts_files_stamp: $(CTS_CASE_LIST) $(junit_host_jar) $(HOSTTESTLIB_JAR) $(CTS_HOST_LIBRARY_JARS) $(TF_JAR) $(CTS_TF_JAR) $(CTS_TF_EXEC_PATH) $(CTS_TF_README_PATH) $(ACP)
 # Make necessary directory for CTS
-	@rm -rf $(PRIVATE_CTS_DIR)
-	@mkdir -p $(TMP_DIR)
-	@mkdir -p $(PRIVATE_DIR)/docs
-	@mkdir -p $(PRIVATE_DIR)/tools
-	@mkdir -p $(PRIVATE_DIR)/repository/testcases
-	@mkdir -p $(PRIVATE_DIR)/repository/plans
+	$(hide) rm -rf $(PRIVATE_CTS_DIR)
+	$(hide) mkdir -p $(TMP_DIR)
+	$(hide) mkdir -p $(PRIVATE_DIR)/docs
+	$(hide) mkdir -p $(PRIVATE_DIR)/tools
+	$(hide) mkdir -p $(PRIVATE_DIR)/repository/testcases
+	$(hide) mkdir -p $(PRIVATE_DIR)/repository/plans
 # Copy executable and JARs to CTS directory
-	$(hide) $(ACP) -fp $(CTS_HOST_JAR) $(CTS_EXECUTABLE_PATH) $(DDMLIB_JAR) $(PRIVATE_JUNIT_HOST_JAR) $(HOSTTESTLIB_JAR) $(CTS_HOST_LIBRARY_JARS) $(PRIVATE_DIR)/tools
+	$(hide) $(ACP) -fp $(CTS_HOST_JAR) $(CTS_EXECUTABLE_PATH) $(DDMLIB_JAR) $(PRIVATE_JUNIT_HOST_JAR) $(HOSTTESTLIB_JAR) $(CTS_HOST_LIBRARY_JARS) $(TF_JAR) $(CTS_TF_JAR) $(CTS_TF_EXEC_PATH) $(CTS_TF_README_PATH) $(PRIVATE_DIR)/tools
 # Change mode of the executables
 	$(hide) chmod ug+rwX $(PRIVATE_DIR)/tools/$(notdir $(CTS_EXECUTABLE_PATH))
 	$(foreach apk,$(CTS_CASE_LIST), \
@@ -68,58 +72,62 @@
 # Parameters:
 # $1 : The output file where the description should be written (without the '.xml' extension)
 # $2 : The AndroidManifest.xml corresponding to the test package
-# $3 : The name of the TestSuite generator class to use
-# $4 : The directory containing vogar expectations files
-# $5 : The Android.mk corresponding to the test package (required for host-side tests only)
+# $3 : The jar file name on PRIVATE_CLASSPATH containing junit tests to search for
+# $4 : The package prefix of classes to include, possible empty
+# $5 : The directory containing vogar expectations files
+# $6 : The Android.mk corresponding to the test package (required for host-side tests only)
 define generate-core-test-description
 @echo "Generate core-test description ("$(notdir $(1))")"
-$(hide) java $(PRIVATE_JAVAOPTS) \
-	-classpath $(PRIVATE_CLASSPATH) \
-	$(PRIVATE_PARAMS) CollectAllTests $(1) \
-	$(2) $(3) $(4) $(5)
+$(hide) java -Xmx256M \
+	-classpath $(PRIVATE_CLASSPATH):$(HOST_OUT_JAVA_LIBRARIES)/descGen.jar:$(HOST_JDK_TOOLS_JAR) \
+	$(PRIVATE_PARAMS) CollectAllTests $(1) $(2) $(3) "$(4)" $(5) $(6)
 endef
 
 CORE_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core,,COMMON)
+BOUNCYCASTLE_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,bouncycastle,,COMMON)
+APACHEXML_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,apache-xml,,COMMON)
+SQLITEJDBC_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,sqlite-jdbc,,COMMON)
 JUNIT_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-junit,,COMMON)
-RUNNER_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-junitrunner,,COMMON)
-SUPPORT_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-tests-support,,COMMON)
-DOM_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-tests-dom,,COMMON)
-XML_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-tests-xml,,COMMON)
-TESTS_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-tests,,COMMON)
-GEN_CLASSPATH := $(CORE_INTERMEDIATES)/classes.jar:$(JUNIT_INTERMEDIATES)/classes.jar:$(RUNNER_INTERMEDIATES)/classes.jar:$(SUPPORT_INTERMEDIATES)/classes.jar:$(DOM_INTERMEDIATES)/classes.jar:$(XML_INTERMEDIATES)/classes.jar:$(TESTS_INTERMEDIATES)/classes.jar:$(CORE_INTERMEDIATES)/javalib.jar:$(JUNIT_INTERMEDIATES)/javalib.jar:$(RUNNER_INTERMEDIATES)/javalib.jar:$(SUPPORT_INTERMEDIATES)/javalib.jar:$(DOM_INTERMEDIATES)/javalib.jar:$(XML_INTERMEDIATES)/javalib.jar:$(TESTS_INTERMEDIATES)/javalib.jar:$(HOST_OUT_JAVA_LIBRARIES)/descGen.jar:$(HOST_JDK_TOOLS_JAR)
+CORETESTS_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-tests,,COMMON)
+
+GEN_CLASSPATH := $(CORE_INTERMEDIATES)/classes.jar:$(BOUNCYCASTLE_INTERMEDIATES)/classes.jar:$(APACHEXML_INTERMEDIATES)/classes.jar:$(JUNIT_INTERMEDIATES)/classes.jar:$(SQLITEJDBC_INTERMEDIATES)/javalib.jar:$(CORETESTS_INTERMEDIATES)/javalib.jar
 
 $(cts_dir)/all_cts_core_files_stamp: PRIVATE_CLASSPATH:=$(GEN_CLASSPATH)
-$(cts_dir)/all_cts_core_files_stamp: PRIVATE_JAVAOPTS:=-Xmx256M
-$(cts_dir)/all_cts_core_files_stamp: PRIVATE_PARAMS:=-Dcts.useSuppliedTestResult=true
-$(cts_dir)/all_cts_core_files_stamp: PRIVATE_PARAMS+=-Dcts.useEnhancedJunit=true
 # Why does this depend on javalib.jar instead of classes.jar?  Because
 # even though the tool will operate on the classes.jar files, the
 # build system requires that dependencies use javalib.jar.  If
 # javalib.jar is up-to-date, then classes.jar is as well.  Depending
 # on classes.jar will build the files incorrectly.
-$(cts_dir)/all_cts_core_files_stamp: $(CTS_CORE_CASE_LIST) $(HOST_OUT_JAVA_LIBRARIES)/descGen.jar $(CORE_INTERMEDIATES)/javalib.jar $(JUNIT_INTERMEDIATES)/javalib.jar $(RUNNER_INTERMEDIATES)/javalib.jar $(SUPPORT_INTERMEDIATES)/javalib.jar $(DOM_INTERMEDIATES)/javalib.jar $(XML_INTERMEDIATES)/javalib.jar $(TESTS_INTERMEDIATES)/javalib.jar $(cts_dir)/all_cts_files_stamp | $(ACP)
-	$(call generate-core-test-description,$(cts_dir)/$(cts_name)/repository/testcases/android.core.tests.dom,\
-		cts/tests/core/dom/AndroidManifest.xml,\
-		tests.dom.AllTests, libcore/expectations)
-	$(call generate-core-test-description,$(cts_dir)/$(cts_name)/repository/testcases/android.core.tests.luni.io,\
-		cts/tests/core/luni-io/AndroidManifest.xml,\
-		tests.luni.AllTestsIo, libcore/expectations)
-	$(call generate-core-test-description,$(cts_dir)/$(cts_name)/repository/testcases/android.core.tests.luni.lang,\
-		cts/tests/core/luni-lang/AndroidManifest.xml,\
-		tests.luni.AllTestsLang, libcore/expectations)
-	$(call generate-core-test-description,$(cts_dir)/$(cts_name)/repository/testcases/android.core.tests.luni.net,\
-		cts/tests/core/luni-net/AndroidManifest.xml,\
-		tests.luni.AllTestsNet, libcore/expectations)
-	$(call generate-core-test-description,$(cts_dir)/$(cts_name)/repository/testcases/android.core.tests.luni.util,\
-		cts/tests/core/luni-util/AndroidManifest.xml,\
-		tests.luni.AllTestsUtil, libcore/expectations)
-	$(call generate-core-test-description,$(cts_dir)/$(cts_name)/repository/testcases/android.core.tests.xml,\
-		cts/tests/core/xml/AndroidManifest.xml,\
-		tests.xml.AllTests, libcore/expectations)
+$(cts_dir)/all_cts_core_files_stamp: $(CTS_CORE_CASE_LIST) $(HOST_OUT_JAVA_LIBRARIES)/descGen.jar $(CORE_INTERMEDIATES)/javalib.jar $(BOUNCYCASTLE_INTERMEDIATES)/javalib.jar $(APACHEXML_INTERMEDIATES)/javalib.jar $(SQLITEJDBC_INTERMEDIATES)/javalib.jar $(JUNIT_INTERMEDIATES)/javalib.jar $(CORETESTS_INTERMEDIATES)/javalib.jar $(cts_dir)/all_cts_files_stamp | $(ACP)
+	$(call generate-core-test-description,$(cts_dir)/$(cts_name)/repository/testcases/android.core.tests.libcore.package.dalvik,\
+		cts/tests/core/libcore/dalvik/AndroidManifest.xml,\
+		$(CORETESTS_INTERMEDIATES)/javalib.jar,dalvik,\
+		libcore/expectations)
+	$(call generate-core-test-description,$(cts_dir)/$(cts_name)/repository/testcases/android.core.tests.libcore.package.com,\
+		cts/tests/core/libcore/com/AndroidManifest.xml,\
+		$(CORETESTS_INTERMEDIATES)/javalib.jar,com,\
+		libcore/expectations)
+	$(call generate-core-test-description,$(cts_dir)/$(cts_name)/repository/testcases/android.core.tests.libcore.package.sun,\
+		cts/tests/core/libcore/sun/AndroidManifest.xml,\
+		$(CORETESTS_INTERMEDIATES)/javalib.jar,sun,\
+		libcore/expectations)
+	$(call generate-core-test-description,$(cts_dir)/$(cts_name)/repository/testcases/android.core.tests.libcore.package.tests,\
+		cts/tests/core/libcore/tests/AndroidManifest.xml,\
+		$(CORETESTS_INTERMEDIATES)/javalib.jar,tests,\
+		libcore/expectations)
+	$(call generate-core-test-description,$(cts_dir)/$(cts_name)/repository/testcases/android.core.tests.libcore.package.org,\
+		cts/tests/core/libcore/org/AndroidManifest.xml,\
+		$(CORETESTS_INTERMEDIATES)/javalib.jar,org,\
+		libcore/expectations)
+	$(call generate-core-test-description,$(cts_dir)/$(cts_name)/repository/testcases/android.core.tests.libcore.package.libcore,\
+		cts/tests/core/libcore/libcore/AndroidManifest.xml,\
+		$(CORETESTS_INTERMEDIATES)/javalib.jar,libcore,\
+		libcore/expectations)
 	$(hide) touch $@
 
 
 # ----- Generate the test descriptions for the vm-tests -----
+#  TODO: remove this section once cts-tf replaces cts.
 #
 CORE_VM_TEST_DESC := $(cts_dir)/$(cts_name)/repository/testcases/android.core.vm-tests
 
@@ -127,22 +135,41 @@
 # core tests only needed to get hold of junit-framework-classes
 CORE_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core,,COMMON)
 JUNIT_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-junit,,COMMON)
-RUNNER_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-junitrunner,,COMMON)
-TESTS_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-tests,,COMMON)
 
-GEN_CLASSPATH := $(CORE_INTERMEDIATES)/classes.jar:$(JUNIT_INTERMEDIATES)/classes.jar:$(RUNNER_INTERMEDIATES)/classes.jar:$(TESTS_INTERMEDIATES)/classes.jar:$(VMTESTS_INTERMEDIATES)/android.core.vm-tests.jar:$(HOST_OUT_JAVA_LIBRARIES)/descGen.jar:$(HOSTTESTLIB_JAR):$(DDMLIB_JAR):$(HOST_JDK_TOOLS_JAR)
+GEN_CLASSPATH := $(CORE_INTERMEDIATES)/classes.jar:$(JUNIT_INTERMEDIATES)/classes.jar:$(VMTESTS_INTERMEDIATES)/android.core.vm-tests.jar:$(HOSTTESTLIB_JAR):$(DDMLIB_JAR)
 
 $(CORE_VM_TEST_DESC): PRIVATE_CLASSPATH:=$(GEN_CLASSPATH)
-$(CORE_VM_TEST_DESC): PRIVATE_PARAMS:=-Dcts.useSuppliedTestResult=true
-$(CORE_VM_TEST_DESC): PRIVATE_PARAMS+=-Dcts.useEnhancedJunit=true
-$(CORE_VM_TEST_DESC): PRIVATE_JAVAOPTS:=-Xmx256M
 # Please see big comment above on why this line depends on javalib.jar instead of classes.jar
-$(CORE_VM_TEST_DESC): vm-tests $(HOST_OUT_JAVA_LIBRARIES)/descGen.jar $(CORE_INTERMEDIATES)/javalib.jar $(JUNIT_INTERMEDIATES)/javalib.jar $(RUNNER_INTERMEDIATES)/javalib.jar $(VMTESTS_INTERMEDIATES)/android.core.vm-tests.jar $(TESTS_INTERMEDIATES)/javalib.jar  $(HOSTTESTLIB_JAR) $(DDMLIB_JAR) $(cts_dir)/all_cts_files_stamp | $(ACP)
+$(CORE_VM_TEST_DESC): vm-tests $(HOST_OUT_JAVA_LIBRARIES)/descGen.jar $(CORE_INTERMEDIATES)/javalib.jar $(JUNIT_INTERMEDIATES)/javalib.jar $(VMTESTS_INTERMEDIATES)/android.core.vm-tests.jar $(HOSTTESTLIB_JAR) $(DDMLIB_JAR) $(cts_dir)/all_cts_files_stamp | $(ACP)
 	$(call generate-core-test-description,$(CORE_VM_TEST_DESC),\
 		cts/tests/vm-tests/AndroidManifest.xml,\
-		dot.junit.AllJunitHostTests, libcore/expectations, cts/tools/vm-tests/Android.mk)
+		$(VMTESTS_INTERMEDIATES)/android.core.vm-tests.jar,"",\
+		libcore/expectations,\
+		cts/tools/vm-tests/Android.mk)
 	$(ACP) -fv $(VMTESTS_INTERMEDIATES)/android.core.vm-tests.jar $(PRIVATE_DIR)/repository/testcases/android.core.vm-tests.jar
 
+# ----- Generate the test descriptions for the vm-tests-tf -----
+#
+CORE_VM_TEST_TF_DESC := $(cts_dir)/$(cts_name)/repository/testcases/android.core.vm-tests-tf
+
+VMTESTSTF_INTERMEDIATES :=$(call intermediates-dir-for,EXECUTABLES,vm-tests-tf,1,)
+# core tests only needed to get hold of junit-framework-classes
+CORE_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core,,COMMON)
+JUNIT_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-junit,,COMMON)
+
+GEN_CLASSPATH := $(CORE_INTERMEDIATES)/classes.jar:$(JUNIT_INTERMEDIATES)/classes.jar:$(VMTESTSTF_INTERMEDIATES)/android.core.vm-tests-tf.jar:$(DDMLIB_JAR):$(TF_JAR)
+
+$(CORE_VM_TEST_TF_DESC): PRIVATE_CLASSPATH:=$(GEN_CLASSPATH)
+# Please see big comment above on why this line depends on javalib.jar instead of classes.jar
+$(CORE_VM_TEST_TF_DESC): $(HOST_OUT_JAVA_LIBRARIES)/descGen.jar $(CORE_INTERMEDIATES)/javalib.jar $(JUNIT_INTERMEDIATES)/javalib.jar $(VMTESTSTF_INTERMEDIATES)/android.core.vm-tests-tf.jar $(DDMLIB_JAR) $(cts_dir)/all_cts_files_stamp | $(ACP)
+	$(call generate-core-test-description,$(CORE_VM_TEST_TF_DESC),\
+		cts/tests/vm-tests-tf/AndroidManifest.xml,\
+		$(VMTESTSTF_INTERMEDIATES)/android.core.vm-tests-tf.jar,\
+		libcore/expectations,\
+		cts/tools/vm-tests-tf/Android.mk)
+	$(ACP) -fv $(VMTESTSTF_INTERMEDIATES)/android.core.vm-tests-tf.jar $(PRIVATE_DIR)/repository/testcases/android.core.vm-tests-tf.jar
+
+
 # Move app security host-side tests to the repository
 APP_SECURITY_LIB := $(cts_dir)/$(cts_name)/repository/testcases/CtsAppSecurityTests.jar
 
@@ -151,7 +178,7 @@
 
 # Generate the default test plan for User.
 # Usage: buildCts.py <testRoot> <ctsOutputDir> <tempDir> <androidRootDir> <docletPath>
-$(DEFAULT_TEST_PLAN): $(cts_dir)/all_cts_files_stamp $(cts_dir)/all_cts_core_files_stamp $(cts_tools_src_dir)/utils/buildCts.py $(CORE_VM_TEST_DESC) $(APP_SECURITY_LIB) $(HOST_OUT_JAVA_LIBRARIES)/descGen.jar
+$(DEFAULT_TEST_PLAN): $(cts_dir)/all_cts_files_stamp $(cts_dir)/all_cts_core_files_stamp $(cts_tools_src_dir)/utils/buildCts.py $(CORE_VM_TEST_TF_DESC) $(CORE_VM_TEST_DESC) $(APP_SECURITY_LIB) $(HOST_OUT_JAVA_LIBRARIES)/descGen.jar
 	$(hide) $(cts_tools_src_dir)/utils/buildCts.py cts/tests/tests/ $(PRIVATE_DIR) $(TMP_DIR) \
 		$(TOP) $(HOST_OUT_JAVA_LIBRARIES)/descGen.jar
 
@@ -165,7 +192,7 @@
 $(INTERNAL_CTS_TARGET): PRIVATE_DIR := $(cts_dir)/$(cts_name)
 $(INTERNAL_CTS_TARGET): TMP_DIR := $(cts_dir)/temp
 $(INTERNAL_CTS_TARGET): $(cts_dir)/all_cts_files_stamp $(DEFAULT_TEST_PLAN) $(CORE_VM_TEST_DESC)
-	@echo "Package CTS: $@"
+	$(hide) echo "Package CTS: $@"
 	$(hide) cd $(dir $@) && zip -rq $(notdir $@) $(PRIVATE_NAME)
 
 .PHONY: cts
diff --git a/core/tasks/sdk-addon.mk b/core/tasks/sdk-addon.mk
index e21fedc..797314a 100644
--- a/core/tasks/sdk-addon.mk
+++ b/core/tasks/sdk-addon.mk
@@ -55,10 +55,10 @@
 
 # All SDK add-ons have these files
 files_to_copy += \
-        $(BUILT_SYSTEMIMAGE):images/system.img \
-        $(BUILT_USERDATAIMAGE_TARGET):images/userdata.img \
-        $(BUILT_RAMDISK_TARGET):images/ramdisk.img \
-        $(target_notice_file_txt):images/NOTICE.txt
+        $(BUILT_SYSTEMIMAGE):images/$(TARGET_CPU_ABI)/system.img \
+        $(BUILT_USERDATAIMAGE_TARGET):images/$(TARGET_CPU_ABI)/userdata.img \
+        $(BUILT_RAMDISK_TARGET):images/$(TARGET_CPU_ABI)/ramdisk.img \
+        $(target_notice_file_txt):images/$(TARGET_CPU_ABI)/NOTICE.txt
 
 # Generate rules to copy the requested files
 $(foreach cf,$(files_to_copy), \
@@ -94,15 +94,19 @@
 .PHONY: sdk_addon
 sdk_addon: $(full_target)
 
-# Keep the name of the addon final zip around for sdk_repo.
-# This is used by development/build/tools/sdk_repo.mk.
+ifneq ($(sdk_repo_goal),)
+# If we're building the sdk_repo, keep the name of the addon zip
+# around so that development/build/tools/sdk_repo.mk can dist it
+# at the appropriate location.
 ADDON_SDK_ZIP := $(full_target)
-
+else
+# When not building an sdk_repo, just dist the addon zip file
+# as-is.
 $(call dist-for-goals, sdk_addon, $(full_target))
+endif
 
 else # addon_name
 ifneq ($(filter sdk_addon,$(MAKECMDGOALS)),)
 $(error Trying to build sdk_addon, but product '$(INTERNAL_PRODUCT)' does not define one)
 endif
 endif # addon_name
-
diff --git a/core/user_tags.mk b/core/user_tags.mk
index 3d8e5a6..d30e86b 100644
--- a/core/user_tags.mk
+++ b/core/user_tags.mk
@@ -38,6 +38,7 @@
 	am \
 	android \
 	android-common \
+	android-common-carousel \
 	android.policy \
 	androidprefs \
 	android.test.runner \
@@ -48,14 +49,16 @@
 	apkcheck \
 	applypatch \
 	app_process \
-	apriori \
 	archquery \
 	asm-3.1 \
 	atree \
 	audio \
+	badblocks \
+	badblocks_host \
 	bb2sym \
 	bb_dump \
 	bbprof \
+	bcc \
 	bison \
 	bluetoothd \
 	bmgr \
@@ -65,12 +68,13 @@
 	cfassembler \
 	check_stack \
 	check_trace \
-	clearsilver \
 	cmu2nuance \
 	com.android.inputmethod.pinyin.lib \
 	com.android.phone.common \
+	com.android.vcard \
 	commons-compress-1.0 \
 	copybit.qsd8k \
+	copybit.s5pc110 \
 	coverage \
 	cpufeatures \
 	cts \
@@ -79,10 +83,13 @@
 	dasm \
 	dbus-daemon \
 	ddmlib \
+	ddmlib-prebuilt \
+	ddmlibTests \
 	ddms \
 	ddmuilib \
 	debuggerd \
 	descGen \
+	dexgen \
 	dexpreopt \
 	dex-tools \
 	dhcpcd \
@@ -90,16 +97,20 @@
 	dhcpcd-run-hooks \
 	dictTest \
 	dnsmasq \
+	doclava \
 	draw9patch \
-	droiddoc \
 	dumpeventlog \
 	dumpkey \
 	dump_regions \
 	dumpstate \
 	dumpsys \
 	dx-tests \
+	e2fsck \
+	e2fsck_host \
 	easymock \
+	easymocklib \
 	edify \
+	elftree \
 	emmalib \
 	emulator \
 	emulator-arm \
@@ -131,6 +142,9 @@
 	gzip \
 	hciattach \
 	hierarchyviewer \
+	hierarchyviewer1 \
+	hierarchyviewer2 \
+	hierarchyviewerlib \
 	hist_trace \
 	hosttestlib \
 	icudata \
@@ -138,11 +152,8 @@
 	ime \
 	init \
 	input \
-	installd \
+	ip \
 	iptables \
-	ip-up-vpn \
-	iself \
-	isprelinked \
 	jarjar \
 	javax.obex \
 	jcommon-1.0.12 \
@@ -150,11 +161,11 @@
 	jdwpspy \
 	jfreechart-1.0.9 \
 	jfreechart-1.0.9-swt \
+	jsilver \
 	jsr305 \
 	jsr305lib \
 	junit \
 	jython \
-	kcm \
 	keystore \
 	kxml2-2.3.0 \
 	launch-wrapper \
@@ -165,7 +176,6 @@
 	layoutopt \
 	liba2dp \
 	libabi \
-	libacc \
 	libandroid \
 	libandroid_runtime \
 	libandroid_servers \
@@ -190,12 +200,14 @@
 	libcameraservice \
 	libcamerastub \
 	libc_common \
+	libchromium_net \
 	libc_nomalloc \
 	libctest \
 	libcutils \
 	libdb \
 	libdbus \
 	libdiskconfig \
+	libdiskconfig_host \
 	libdl \
 	libdrm1 \
 	libdrm1_jni \
@@ -206,12 +218,23 @@
 	libeffects \
 	libEGL \
 	libelf \
-	libelfcopy \
 	libESR_Portable \
 	libESR_Shared \
 	libETC1 \
 	libexif \
 	libext \
+	libext2_blkid \
+	libext2_blkid_host \
+	libext2_com_err \
+	libext2_com_err_host \
+	libext2_e2p \
+	libext2_e2p_host \
+	libext2fs \
+	libext2fs_host \
+	libext2_profile \
+	libext2_profile_host \
+	libext2_uuid \
+	libext2_uuid_host \
 	libfdlibm \
 	libfdlibm-host \
 	libFFTEm \
@@ -222,11 +245,12 @@
 	libGLES_android \
 	libGLESv1_CM \
 	libGLESv2 \
-	libglib_static \
+	libglib \
 	libgui \
 	libhardware \
 	libhardware_legacy \
 	libhost \
+	libhyphenation \
 	libiprouteutil \
 	libiptc \
 	libjnigraphics \
@@ -242,9 +266,11 @@
 	libmedia_jni \
 	libmediaplayerservice \
 	libmincrypt \
+	libminelf \
 	libminui \
 	libminzip \
 	libmtdutils \
+	libmtp \
 	libmusicbundle \
 	libneo_cgi \
 	libneo_cs \
@@ -257,17 +283,20 @@
 	libOpenSLESUT \
 	libpcap \
 	libpixelflinger \
-	libpixelflinger_armv6 \
 	libpixelflinger_static \
 	libpng \
 	libpopt \
 	libpower \
+	libprotobuf-cpp-2.3.0-full \
+	libprotobuf-cpp-2.3.0-lite \
+	libprotobuf-java-2.3.0-lite \
+	libprotobuf-java-2.3.0-micro \
 	librecovery_ui_htc \
-	libreference-cdma-sms \
 	libreference-ril \
 	libreverb \
 	libreverbwrapper \
 	libril \
+	librilproto-java \
 	librpc \
 	librtp_jni \
 	libsafe_iop \
@@ -321,6 +350,7 @@
 	libstagefright_rtsp \
 	libstagefright_vorbisdec \
 	libstagefright_vpxdec \
+	libstagefright_yuv \
 	libstdc++ \
 	libstlport \
 	libstlport_static \
@@ -338,6 +368,7 @@
 	libttssynthproxy \
 	libui \
 	libunz \
+	libusbhost \
 	libutil \
 	libutils \
 	libv8 \
@@ -348,16 +379,17 @@
 	libwpa_client \
 	libwrapsim \
 	libxml2 \
+	libxslt \
 	libzipfile \
 	lights.kraken \
 	lights.qsd8k \
 	line_endings \
 	linker \
+	llvm-rs-link \
 	localize \
 	logcat \
 	logwrapper \
 	lsd \
-	mahimahi-keypad.kcm \
 	make_cfst \
 	makedict \
 	make_ext4fs \
@@ -368,17 +400,23 @@
 	minigzip \
 	mkbootfs \
 	mkbootimg \
+	mke2fs \
+	mke2fs_host \
 	mksdcard \
 	mksnapshot \
 	mkstubs \
 	mkuserimg.sh \
 	mkyaffs2image \
+	mockrilcontroller \
 	monkey \
 	monkeyrunner \
+	MonkeyRunnerTest \
+	mtp \
 	mtpd \
 	ndc \
 	netcfg \
 	netd \
+	network \
 	ninepatch \
 	oauth \
 	obbtool \
@@ -401,19 +439,21 @@
 	profile_trace \
 	q2dm \
 	q2g \
-	qwerty2.kcm \
-	qwerty.kcm \
+	qemu-android \
 	racoon \
 	read_addr \
 	read_method \
 	read_pid \
 	read_trace \
+	resize2fs \
+	resize2fs_host \
 	rgb2565 \
 	rild \
 	rsg-generator \
 	run-as \
 	runtime \
 	schedtest \
+	screenshot \
 	screenshot2 \
 	sdcard \
 	sdklauncher \
@@ -430,7 +470,6 @@
 	service \
 	servicemanager \
 	services \
-	sh \
 	sig \
 	sig-check \
 	sig-create \
@@ -438,7 +477,6 @@
 	signature-tools \
 	simg2img \
 	simulator \
-	soslim \
 	spec-progress \
 	sqlite3 \
 	stack_dump \
@@ -448,6 +486,7 @@
 	swing-worker-1.1 \
 	swt \
 	system_server \
+	tblgen \
 	tc \
 	temp_layoutlib \
 	test_g2g \
@@ -457,16 +496,15 @@
 	test_zipfile \
 	toolbox \
 	traceview \
-	tuttle2.kcm \
+	tune2fs \
+	tune2fs_host \
 	uix \
 	usbtest \
 	vdc \
 	vm-tests \
 	vold \
 	wdsclient \
+	whisperd \
 	wpa_supplicant \
-	wpa_supplicant.conf \
-	xmlwriter \
 	yuv420sp2rgb \
 	zipalign
-
diff --git a/core/version_defaults.mk b/core/version_defaults.mk
index db626a8..986dac9 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 := 2.3.5
+  PLATFORM_VERSION := IceCreamSandwich
 endif
 
 ifeq "" "$(PLATFORM_SDK_VERSION)"
@@ -53,13 +53,13 @@
   # intermediate builds).  During development, this number remains at the
   # SDK version the branch is based on and PLATFORM_VERSION_CODENAME holds
   # the code-name of the new development work.
-  PLATFORM_SDK_VERSION := 10
+  PLATFORM_SDK_VERSION := 13
 endif
 
 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 := IceCreamSandwich
 endif
 
 ifeq "" "$(DEFAULT_APP_TARGET_SDK)"
@@ -96,3 +96,4 @@
   # anyone trying to parse it as an integer will probably get "0".
   BUILD_NUMBER := eng.$(USER).$(shell date +%Y%m%d.%H%M%S)
 endif
+
diff --git a/envsetup.sh b/envsetup.sh
index 2911fd7..a845a18 100644
--- a/envsetup.sh
+++ b/envsetup.sh
@@ -29,8 +29,8 @@
         echo "Couldn't locate the top of the tree.  Try setting TOP." >&2
         return
     fi
-    CALLED_FROM_SETUP=true BUILD_SYSTEM=build/core \
-      make --no-print-directory -C "$T" -f build/core/config.mk dumpvar-abs-$1
+    (cd $T; CALLED_FROM_SETUP=true BUILD_SYSTEM=build/core \
+      make --no-print-directory -C "$T" -f build/core/config.mk dumpvar-abs-$1)
 }
 
 # Get the exact value of a build variable.
@@ -95,21 +95,39 @@
     #                                                                #
     ##################################################################
 
+    # Note: on windows/cygwin, ANDROID_BUILD_PATHS will contain spaces
+    # due to "C:\Program Files" being in the path.
+
     # out with the old
-    if [ -n $ANDROID_BUILD_PATHS ] ; then
+    if [ -n "$ANDROID_BUILD_PATHS" ] ; then
         export PATH=${PATH/$ANDROID_BUILD_PATHS/}
     fi
-    if [ -n $ANDROID_PRE_BUILD_PATHS ] ; then
+    if [ -n "$ANDROID_PRE_BUILD_PATHS" ] ; then
         export PATH=${PATH/$ANDROID_PRE_BUILD_PATHS/}
+        # strip trailing ':', if any
+        export PATH=${PATH/%:/}
     fi
 
     # and in with the new
     CODE_REVIEWS=
     prebuiltdir=$(getprebuilt)
-    export ANDROID_EABI_TOOLCHAIN=$prebuiltdir/toolchain/arm-eabi-4.4.3/bin
+
+    # The gcc toolchain does not exists for windows/cygwin. In this case, do not reference it.
+    export ANDROID_EABI_TOOLCHAIN=
+    toolchaindir=toolchain/arm-linux-androideabi-4.4.x/bin
+    if [ -d "$prebuiltdir/$toolchaindir" ]; then
+        export ANDROID_EABI_TOOLCHAIN=$prebuiltdir/$toolchaindir
+    fi
+
+    export ARM_EABI_TOOLCHAIN=
+    toolchaindir=toolchain/arm-eabi-4.4.3/bin
+    if [ -d "$prebuiltdir/$toolchaindir" ]; then
+        export ARM_EABI_TOOLCHAIN=$prebuiltdir/$toolchaindir
+    fi
+
     export ANDROID_TOOLCHAIN=$ANDROID_EABI_TOOLCHAIN
     export ANDROID_QTOOLS=$T/development/emulator/qtools
-    export ANDROID_BUILD_PATHS=:$(get_build_var ANDROID_BUILD_PATHS):$ANDROID_QTOOLS:$ANDROID_TOOLCHAIN:$ANDROID_EABI_TOOLCHAIN$CODE_REVIEWS
+    export ANDROID_BUILD_PATHS=:$(get_build_var ANDROID_BUILD_PATHS):$ANDROID_QTOOLS:$ANDROID_TOOLCHAIN:$ARM_EABI_TOOLCHAIN$CODE_REVIEWS
     export PATH=$PATH$ANDROID_BUILD_PATHS
 
     unset ANDROID_JAVA_TOOLCHAIN
@@ -131,9 +149,6 @@
     # needed for building linux on MacOS
     # TODO: fix the path
     #export HOST_EXTRACFLAGS="-I "$T/system/kernel_headers/host_include
-
-    # needed for OProfile to post-process collected samples
-    export OPROFILE_EVENTS_DIR=$prebuiltdir/oprofile
 }
 
 function printconfig()
@@ -314,7 +329,7 @@
         if [ "$TARGET_SIMULATOR" = true ] ; then
             default_value=sim
         else
-            default_value=generic
+            default_value=full
         fi
     fi
 
@@ -379,7 +394,7 @@
             export TARGET_BUILD_VARIANT=$default_value
         elif (echo -n $ANSWER | grep -q -e "^[0-9][0-9]*$") ; then
             if [ "$ANSWER" -le "${#VARIANT_CHOICES[@]}" ] ; then
-                export TARGET_BUILD_VARIANT=${VARIANT_CHOICES[$(($ANSWER-$_arrayoffset))]}
+                export TARGET_BUILD_VARIANT=${VARIANT_CHOICES[$(($ANSWER-1))]}
             fi
         else
             if check_variant $ANSWER
@@ -432,13 +447,9 @@
 }
 
 # add the default one here
-add_lunch_combo generic-eng
-
-# if we're on linux, add the simulator.  There is a special case
-# in lunch to deal with the simulator
-if [ "$(uname)" = "Linux" ] ; then
-    add_lunch_combo simulator
-fi
+add_lunch_combo full-eng
+add_lunch_combo full_x86-eng
+add_lunch_combo vbox_x86-eng
 
 function print_lunch_menu()
 {
@@ -467,7 +478,7 @@
         answer=$1
     else
         print_lunch_menu
-        echo -n "Which would you like? [generic-eng] "
+        echo -n "Which would you like? [full-eng] "
         read answer
     fi
 
@@ -475,7 +486,7 @@
 
     if [ -z "$answer" ]
     then
-        selection=generic-eng
+        selection=full-eng
     elif [ "$answer" = "simulator" ]
     then
         selection=simulator
@@ -483,7 +494,7 @@
     then
         if [ $answer -le ${#LUNCH_MENU_CHOICES[@]} ]
         then
-            selection=${LUNCH_MENU_CHOICES[$(($answer-$_arrayoffset))]}
+            selection=${LUNCH_MENU_CHOICES[$(($answer-1))]}
         fi
     elif (echo -n $answer | grep -q -e "^[^\-][^\-]*-[^\-][^\-]*$")
     then
@@ -545,6 +556,19 @@
     printconfig
 }
 
+# Tab completion for lunch.
+function _lunch()
+{
+    local cur prev opts
+    COMPREPLY=()
+    cur="${COMP_WORDS[COMP_CWORD]}"
+    prev="${COMP_WORDS[COMP_CWORD-1]}"
+
+    COMPREPLY=( $(compgen -W "${LUNCH_MENU_CHOICES[*]}" -- ${cur}) )
+    return 0
+}
+complete -F _lunch lunch
+
 # Configures the build to build unbundled apps.
 # Run tapas with one ore more app names (from LOCAL_PACKAGE_NAME)
 function tapas()
@@ -563,7 +587,7 @@
         apps=all
     fi
 
-    export TARGET_PRODUCT=generic
+    export TARGET_PRODUCT=full
     export TARGET_BUILD_VARIANT=$variant
     export TARGET_SIMULATOR=false
     export TARGET_BUILD_TYPE=release
@@ -683,6 +707,8 @@
                     ARGS="$ARGS showcommands"
                 elif [ "$DIR" = dist ]; then
                     ARGS="$ARGS dist"
+                elif [ "$DIR" = incrementaljavac ]; then
+                    ARGS="$ARGS incrementaljavac"
                 else
                     echo "No Android.mk in $DIR."
                     return 1
@@ -768,7 +794,11 @@
        local PID
        local PROG="$3"
        if [ "$PROG" ] ; then
-           PID=`pid $3`
+           if [[ "$PROG" =~ ^[0-9]+$ ]] ; then
+               PID="$3"
+           else
+               PID=`pid $3`
+           fi
            adb forward "tcp$PORT" "tcp$PORT"
            adb shell gdbserver $PORT --attach $PID &
            sleep 2
@@ -786,7 +816,7 @@
        echo >>"$OUT_ROOT/gdbclient.cmds" "target remote $PORT"
        echo >>"$OUT_ROOT/gdbclient.cmds" ""
 
-       arm-eabi-gdb -x "$OUT_ROOT/gdbclient.cmds" "$OUT_EXE_SYMBOLS/$EXE"
+       arm-linux-androideabi-gdb -x "$OUT_ROOT/gdbclient.cmds" "$OUT_EXE_SYMBOLS/$EXE"
   else
        echo "Unable to determine build system output dir."
    fi
@@ -797,55 +827,55 @@
     Darwin)
         function sgrep()
         {
-            find -E . -type f -iregex '.*\.(c|h|cpp|S|java|xml|sh|mk)' -print0 | xargs -0 grep --color -n "$@"
+            find -E . -name .repo -prune -o -name .git -prune -o  -type f -iregex '.*\.(c|h|cpp|S|java|xml|sh|mk)' -print0 | xargs -0 grep --color -n "$@"
         }
 
         ;;
     *)
         function sgrep()
         {
-            find . -type f -iregex '.*\.\(c\|h\|cpp\|S\|java\|xml\|sh\|mk\)' -print0 | xargs -0 grep --color -n "$@"
+            find . -name .repo -prune -o -name .git -prune -o  -type f -iregex '.*\.\(c\|h\|cpp\|S\|java\|xml\|sh\|mk\)' -print0 | xargs -0 grep --color -n "$@"
         }
         ;;
 esac
 
 function jgrep()
 {
-    find . -type f -name "*\.java" -print0 | xargs -0 grep --color -n "$@"
+    find . -name .repo -prune -o -name .git -prune -o  -type f -name "*\.java" -print0 | xargs -0 grep --color -n "$@"
 }
 
 function cgrep()
 {
-    find . -type f \( -name '*.c' -o -name '*.cc' -o -name '*.cpp' -o -name '*.h' \) -print0 | xargs -0 grep --color -n "$@"
+    find . -name .repo -prune -o -name .git -prune -o -type f \( -name '*.c' -o -name '*.cc' -o -name '*.cpp' -o -name '*.h' \) -print0 | xargs -0 grep --color -n "$@"
 }
 
 function resgrep()
 {
-    for dir in `find . -name res -type d`; do find $dir -type f -name '*\.xml' -print0 | xargs -0 grep --color -n "$@"; done;
+    for dir in `find . -name .repo -prune -o -name .git -prune -o -name res -type d`; do find $dir -type f -name '*\.xml' -print0 | xargs -0 grep --color -n "$@"; done;
 }
 
 case `uname -s` in
     Darwin)
         function mgrep()
         {
-            find -E . -type f -iregex '.*/(Makefile|Makefile\..*|.*\.make|.*\.mak|.*\.mk)' -print0 | xargs -0 grep --color -n "$@"
+            find -E . -name .repo -prune -o -name .git -prune -o  -type f -iregex '.*/(Makefile|Makefile\..*|.*\.make|.*\.mak|.*\.mk)' -print0 | xargs -0 grep --color -n "$@"
         }
 
         function treegrep()
         {
-            find -E . -type f -iregex '.*\.(c|h|cpp|S|java|xml)' -print0 | xargs -0 grep --color -n -i "$@"
+            find -E . -name .repo -prune -o -name .git -prune -o -type f -iregex '.*\.(c|h|cpp|S|java|xml)' -print0 | xargs -0 grep --color -n -i "$@"
         }
 
         ;;
     *)
         function mgrep()
         {
-            find . -regextype posix-egrep -iregex '(.*\/Makefile|.*\/Makefile\..*|.*\.make|.*\.mak|.*\.mk)' -type f -print0 | xargs -0 grep --color -n "$@"
+            find . -name .repo -prune -o -name .git -prune -o -regextype posix-egrep -iregex '(.*\/Makefile|.*\/Makefile\..*|.*\.make|.*\.mak|.*\.mk)' -type f -print0 | xargs -0 grep --color -n "$@"
         }
 
         function treegrep()
         {
-            find . -regextype posix-egrep -iregex '.*\.(c|h|cpp|S|java|xml)' -type f -print0 | xargs -0 grep --color -n -i "$@"
+            find . -name .repo -prune -o -name .git -prune -o -regextype posix-egrep -iregex '.*\.(c|h|cpp|S|java|xml)' -type f -print0 | xargs -0 grep --color -n -i "$@"
         }
 
         ;;
@@ -908,10 +938,10 @@
 {
     # process standard adb options
     local adbTarget=""
-    if [ $1 = "-d" -o $1 = "-e" ]; then
+    if [ "$1" = "-d" -o "$1" = "-e" ]; then
         adbTarget=$1
         shift 1
-    elif [ $1 = "-s" ]; then
+    elif [ "$1" = "-s" ]; then
         adbTarget="$1 $2"
         shift 2
     fi
@@ -920,10 +950,9 @@
 
     # runhat options
     local targetPid=$1
-    local outputFile=$2
 
     if [ "$targetPid" = "" ]; then
-        echo "Usage: runhat [ -d | -e | -s serial ] target-pid [output-file]"
+        echo "Usage: runhat [ -d | -e | -s serial ] target-pid"
         return
     fi
 
@@ -933,18 +962,14 @@
         return
     fi
 
-    adb ${adbOptions} shell >/dev/null mkdir /data/misc
-    adb ${adbOptions} shell chmod 777 /data/misc
-
-    # send a SIGUSR1 to cause the hprof dump
+    # issue "am" command to cause the hprof dump
+    local devFile=/sdcard/hprof-$targetPid
     echo "Poking $targetPid and waiting for data..."
-    adb ${adbOptions} shell kill -10 $targetPid
+    adb ${adbOptions} shell am dumpheap $targetPid $devFile
     echo "Press enter when logcat shows \"hprof: heap dump completed\""
     echo -n "> "
     read
 
-    local availFiles=( $(adb ${adbOptions} shell ls /data/misc | grep '^heap-dump' | sed -e 's/.*heap-dump-/heap-dump-/' | sort -r | tr '[:space:][:cntrl:]' ' ') )
-    local devFile=/data/misc/${availFiles[0]}
     local localFile=/tmp/$$-hprof
 
     echo "Retrieving file $devFile..."
@@ -995,6 +1020,21 @@
     adb shell service call window 3
 }
 
+function key_home()
+{
+    adb shell input keyevent 3
+}
+
+function key_back()
+{
+    adb shell input keyevent 4
+}
+
+function key_menu()
+{
+    adb shell input keyevent 82
+}
+
 function smoketest()
 {
     if [ ! "$ANDROID_PRODUCT_OUT" ]; then
@@ -1039,7 +1079,7 @@
         echo ""
     fi
     local lines
-    lines=($(grep "$1" $T/filelist | sed -e 's/\/[^/]*$//' | sort | uniq)) 
+    lines=($(grep "$1" $T/filelist | sed -e 's/\/[^/]*$//' | sort | uniq))
     if [[ ${#lines[@]} = 0 ]]; then
         echo "Not found"
         return
@@ -1052,7 +1092,7 @@
             local line
             for line in ${lines[@]}; do
                 printf "%6s %s\n" "[$index]" $line
-                index=$(($index + 1)) 
+                index=$(($index + 1))
             done
             echo
             echo -n "Select one: "
@@ -1062,10 +1102,9 @@
                 echo "Invalid choice"
                 continue
             fi
-            pathname=${lines[$(($choice-$_arrayoffset))]}
+            pathname=${lines[$(($choice-1))]}
         done
     else
-        # even though zsh arrays are 1-based, $foo[0] is an alias for $foo[1]
         pathname=${lines[0]}
     fi
     cd $T/$pathname
@@ -1085,18 +1124,18 @@
     fi
 }
 
-# determine whether arrays are zero-based (bash) or one-based (zsh)
-_xarray=(a b c)
-if [ -z "${_xarray[${#_xarray[@]}]}" ]
-then
-    _arrayoffset=1
-else
-    _arrayoffset=0
+if [ "x$SHELL" != "x/bin/bash" ]; then
+    case `ps -o command -p $$` in
+        *bash*)
+            ;;
+        *)
+            echo "WARNING: Only bash is supported, use of other shell would lead to erroneous results"
+            ;;
+    esac
 fi
-unset _xarray
 
 # Execute the contents of any vendorsetup.sh files we can find.
-for f in `/bin/ls vendor/*/vendorsetup.sh vendor/*/build/vendorsetup.sh device/*/*/vendorsetup.sh 2> /dev/null`
+for f in `/bin/ls vendor/*/vendorsetup.sh vendor/*/*/vendorsetup.sh device/*/*/vendorsetup.sh 2> /dev/null`
 do
     echo "including $f"
     . $f
diff --git a/libs/host/CopyFile.c b/libs/host/CopyFile.c
index a822b41..23f1260 100644
--- a/libs/host/CopyFile.c
+++ b/libs/host/CopyFile.c
@@ -63,6 +63,23 @@
 }
 
 /*
+ * Returns true if the source file has high resolution modification
+ * date. Cygwin/Mingw doesn't support st_mtim and always returns false.
+ */
+static bool isHiresMtime(const struct stat* pSrcStat)
+{
+#if HAVE_STAT_ST_MTIM
+#if defined(MACOSX_RSRC)
+    return pSrcStat->st_mtimespec.tv_nsec > 0;
+#else
+    return pSrcStat->st_mtim.tv_nsec > 0;
+#endif
+#else
+    return 0;
+#endif
+}
+
+/*
  * Returns true if the source and destination files are actually the
  * same thing.  We detect this by checking the inode numbers, which seems
  * to work on Cygwin.
@@ -151,6 +168,8 @@
          */
         ut.actime = pSrcStat->st_atime;
         ut.modtime = pSrcStat->st_mtime;
+        if (isHiresMtime(pSrcStat))
+            ut.modtime += 1;
         if (utime(dst, &ut) != 0) {
             DBUG(("---   unable to set timestamps on '%s': %s\n",
                 dst, strerror(errno)));
diff --git a/target/board/Android.mk b/target/board/Android.mk
index 82dee3c..58164f6 100644
--- a/target/board/Android.mk
+++ b/target/board/Android.mk
@@ -20,9 +20,6 @@
   INSTALLED_KERNEL_TARGET :=
 endif
 
-# Use the add-radio-file function to add values to this variable.
-INSTALLED_RADIOIMAGE_TARGET :=
-
 -include $(TARGET_DEVICE_DIR)/AndroidBoard.mk
 
 # Generate a file that contains various information about the
@@ -30,10 +27,14 @@
 # with everything else.
 #
 # If the file "board-info.txt" appears in $(TARGET_DEVICE_DIR),
-# it will be appended to the output file.
+# it will be used; otherwise TARGET_BOARD_INFO_FILE is used, which
+# can be set in BoardConfig.mk.
 #
 INSTALLED_ANDROID_INFO_TXT_TARGET := $(PRODUCT_OUT)/android-info.txt
 board_info_txt := $(wildcard $(TARGET_DEVICE_DIR)/board-info.txt)
+ifndef board_info_txt
+board_info_txt := $(TARGET_BOARD_INFO_FILE)
+endif
 $(INSTALLED_ANDROID_INFO_TXT_TARGET): $(board_info_txt)
 	$(call pretty,"Generated: ($@)")
 ifdef board_info_txt
diff --git a/target/board/emulator/AndroidBoard.mk b/target/board/emulator/AndroidBoard.mk
index 09badee..7911f61 100644
--- a/target/board/emulator/AndroidBoard.mk
+++ b/target/board/emulator/AndroidBoard.mk
@@ -1,10 +1 @@
 LOCAL_PATH := $(call my-dir)
-
-file := $(TARGET_OUT_KEYLAYOUT)/tuttle2.kl
-ALL_PREBUILT += $(file)
-$(file) : $(LOCAL_PATH)/tuttle2.kl | $(ACP)
-	$(transform-prebuilt-to-target)
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := tuttle2.kcm
-include $(BUILD_KEY_CHAR_MAP)
diff --git a/target/board/emulator/tuttle2.kcm b/target/board/emulator/tuttle2.kcm
deleted file mode 100644
index 0a2dd8c..0000000
--- a/target/board/emulator/tuttle2.kcm
+++ /dev/null
@@ -1,66 +0,0 @@
-[type=QWERTY]                                           
-                                                        
-# keycode       display number  base    caps    fn      caps_fn
-                                                        
-A               'A'     '%'     'a'     'A'     '%'     0x00
-B               'B'     '='     'b'     'B'     '='     0x00
-C               'C'     '8'     'c'     'C'     '8'     0x00E7
-D               'D'     '5'     'd'     'D'     '5'     0x00
-E               'E'     '2'     'e'     'E'     '2'     0x0301
-F               'F'     '6'     'f'     'F'     '6'     0x00A5
-G               'G'     '-'     'g'     'G'     '-'     '_'
-H               'H'     '['     'h'     'H'     '['     '{'
-I               'I'     '$'     'i'     'I'     '$'     0x0302
-J               'J'     ']'     'j'     'J'     ']'     '}'
-K               'K'     '"'     'k'     'K'     '"'     '~'
-L               'L'     '''     'l'     'L'     '''     '`'
-M               'M'     '>'     'm'     'M'     '>'     0x00
-N               'N'     '<'     'n'     'N'     '<'     0x0303
-O               'O'     '('     'o'     'O'     '('     0x00
-P               'P'     ')'     'p'     'P'     ')'     0x00
-Q               'Q'     '*'     'q'     'Q'     '*'     0x0300
-R               'R'     '3'     'r'     'R'     '3'     0x20AC
-S               'S'     '4'     's'     'S'     '4'     0x00DF
-T               'T'     '+'     't'     'T'     '+'     0x00A3
-U               'U'     '&'     'u'     'U'     '&'     0x0308
-V               'V'     '9'     'v'     'V'     '9'     '^'
-W               'W'     '1'     'w'     'W'     '1'     0x00
-X               'X'     '7'     'x'     'X'     '7'     0xEF00
-Y               'Y'     '!'     'y'     'Y'     '!'     0x00A1
-Z               'Z'     '#'     'z'     'Z'     '#'     0x00
-                                                        
-COMMA           ','     ','     ','     ';'     ';'     '|'
-PERIOD          '.'     '.'     '.'     ':'     ':'     0x2026
-AT              '@'     '0'     '@'     '0'     '0'     0x2022
-SLASH           '/'     '/'     '/'     '?'     '?'     '\'
-                                                        
-SPACE           0x20    0x20    0x20    0x20    0xEF01  0xEF01
-ENTER         0xa     0xa     0xa     0xa     0xa     0xa
-                                                        
-# on pc keyboards
-TAB             0x9     0x9     0x9     0x9     0x9     0x9
-0               '0'     '0'     '0'     ')'     ')'     ')'
-1               '1'     '1'     '1'     '!'     '!'     '!'
-2               '2'     '2'     '2'     '@'     '@'     '@'
-3               '3'     '3'     '3'     '#'     '#'     '#'
-4               '4'     '4'     '4'     '$'     '$'     '$'
-5               '5'     '5'     '5'     '%'     '%'     '%'
-6               '6'     '6'     '6'     '^'     '^'     '^'
-7               '7'     '7'     '7'     '&'     '&'     '&'
-8               '8'     '8'     '8'     '*'     '*'     '*'
-9               '9'     '9'     '9'     '('     '('     '('
-                                                        
-GRAVE           '`'     '`'     '`'     '~'     '`'     '~'
-MINUS           '-'     '-'     '-'     '_'     '-'     '_'
-EQUALS          '='     '='     '='     '+'     '='     '+'
-LEFT_BRACKET    '['     '['     '['     '{'     '['     '{'
-RIGHT_BRACKET   ']'     ']'     ']'     '}'     ']'     '}'
-BACKSLASH       '\'     '\'     '\'     '|'     '\'     '|'
-SEMICOLON       ';'     ';'     ';'     ':'     ';'     ':'
-APOSTROPHE      '''     '''     '''     '"'     '''     '"'
-STAR            '*'     '*'     '*'     '*'     '*'     '*'
-POUND           '#'     '#'     '#'     '#'     '#'     '#'
-PLUS            '+'     '+'     '+'     '+'     '+'     '+'
-                                                        
-                                                        
-                                                        
diff --git a/target/board/emulator/tuttle2.kl b/target/board/emulator/tuttle2.kl
deleted file mode 100644
index a48a5ab..0000000
--- a/target/board/emulator/tuttle2.kl
+++ /dev/null
@@ -1,74 +0,0 @@
-key 2     1
-key 3     2
-key 4     3
-key 5     4
-key 6     5
-key 7     6
-key 8     7
-key 9     8
-key 10    9
-key 11    0
-key 158   BACK              WAKE_DROPPED
-key 230   SOFT_RIGHT        WAKE
-key 60    SOFT_RIGHT        WAKE
-key 107   ENDCALL           WAKE_DROPPED
-key 62    ENDCALL           WAKE_DROPPED
-key 229   MENU         WAKE_DROPPED
-key 59    MENU         WAKE_DROPPED
-key 228   POUND
-key 227   STAR
-key 231   CALL              WAKE_DROPPED
-key 61    CALL              WAKE_DROPPED
-key 232   DPAD_CENTER       WAKE_DROPPED
-key 108   DPAD_DOWN         WAKE_DROPPED
-key 103   DPAD_UP           WAKE_DROPPED
-key 102   HOME              WAKE
-key 105   DPAD_LEFT         WAKE_DROPPED
-key 106   DPAD_RIGHT        WAKE_DROPPED
-key 115   VOLUME_UP
-key 114   VOLUME_DOWN
-key 116   POWER             WAKE
-key 212   SLASH
-
-key 16    Q
-key 17    W
-key 18    E
-key 19    R
-key 20    T
-key 21    Y
-key 22    U
-key 23    I
-key 24    O
-key 25    P
-
-key 30    A
-key 31    S
-key 32    D
-key 33    F
-key 34    G
-key 35    H
-key 36    J
-key 37    K
-key 38    L
-key 14    DEL
-        
-key 44    Z
-key 45    X
-key 46    C
-key 47    V
-key 48    B
-key 49    N
-key 50    M
-key 51    COMMA
-key 52    PERIOD
-key 28    ENTER
-        
-key 56    ALT_LEFT
-key 42    SHIFT_LEFT
-key 215   AT
-key 57    SPACE
-key 53    SLASH
-key 127   SYM
-key 100   ALT_RIGHT
-
-key 399   GRAVE
diff --git a/target/board/generic/AndroidBoard.mk b/target/board/generic/AndroidBoard.mk
index 09badee..7911f61 100644
--- a/target/board/generic/AndroidBoard.mk
+++ b/target/board/generic/AndroidBoard.mk
@@ -1,10 +1 @@
 LOCAL_PATH := $(call my-dir)
-
-file := $(TARGET_OUT_KEYLAYOUT)/tuttle2.kl
-ALL_PREBUILT += $(file)
-$(file) : $(LOCAL_PATH)/tuttle2.kl | $(ACP)
-	$(transform-prebuilt-to-target)
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := tuttle2.kcm
-include $(BUILD_KEY_CHAR_MAP)
diff --git a/target/board/generic/BoardConfig.mk b/target/board/generic/BoardConfig.mk
index 9e52d25..d02205b 100644
--- a/target/board/generic/BoardConfig.mk
+++ b/target/board/generic/BoardConfig.mk
@@ -6,9 +6,27 @@
 # The generic product target doesn't have any hardware-specific pieces.
 TARGET_NO_BOOTLOADER := true
 TARGET_NO_KERNEL := true
-TARGET_CPU_ABI := armeabi
+
+# Note: we build the platform images for ARMv7-A _without_ NEON.
+#
+# Technically, the emulator supports ARMv7-A _and_ NEON instructions, but
+# emulated NEON code paths typically ends up 2x slower than the normal C code
+# it is supposed to replace (unlike on real devices where it is 2x to 3x
+# faster).
+#
+# What this means is that the platform image will not use NEON code paths
+# that are slower to emulate. On the other hand, it is possible to emulate
+# application code generated with the NDK that uses NEON in the emulator.
+#
+TARGET_ARCH_VARIANT := armv7-a
+TARGET_CPU_ABI := armeabi-v7a
+TARGET_CPU_ABI2 := armeabi
+
 HAVE_HTC_AUDIO_DRIVER := true
 BOARD_USES_GENERIC_AUDIO := true
 
 # no hardware camera
 USE_CAMERA_STUB := true
+
+# Set /system/bin/sh to ash, not mksh, to make sure we can switch back.
+TARGET_SHELL := ash
diff --git a/target/board/generic/device.mk b/target/board/generic/device.mk
new file mode 100644
index 0000000..f57a0dc
--- /dev/null
+++ b/target/board/generic/device.mk
@@ -0,0 +1,29 @@
+#
+# 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 the product aspects that
+# are specific to the emulator.
+
+PRODUCT_PROPERTY_OVERRIDES := \
+    ro.ril.hsxpa=1 \
+    ro.ril.gprsclass=10
+
+PRODUCT_COPY_FILES := \
+    development/data/etc/apns-conf.xml:system/etc/apns-conf.xml \
+    development/data/etc/vold.conf:system/etc/vold.conf
+
+PRODUCT_PACKAGES := \
+    audio.primary.goldfish
diff --git a/target/board/generic/tuttle2.kcm b/target/board/generic/tuttle2.kcm
deleted file mode 100644
index 0a2dd8c..0000000
--- a/target/board/generic/tuttle2.kcm
+++ /dev/null
@@ -1,66 +0,0 @@
-[type=QWERTY]                                           
-                                                        
-# keycode       display number  base    caps    fn      caps_fn
-                                                        
-A               'A'     '%'     'a'     'A'     '%'     0x00
-B               'B'     '='     'b'     'B'     '='     0x00
-C               'C'     '8'     'c'     'C'     '8'     0x00E7
-D               'D'     '5'     'd'     'D'     '5'     0x00
-E               'E'     '2'     'e'     'E'     '2'     0x0301
-F               'F'     '6'     'f'     'F'     '6'     0x00A5
-G               'G'     '-'     'g'     'G'     '-'     '_'
-H               'H'     '['     'h'     'H'     '['     '{'
-I               'I'     '$'     'i'     'I'     '$'     0x0302
-J               'J'     ']'     'j'     'J'     ']'     '}'
-K               'K'     '"'     'k'     'K'     '"'     '~'
-L               'L'     '''     'l'     'L'     '''     '`'
-M               'M'     '>'     'm'     'M'     '>'     0x00
-N               'N'     '<'     'n'     'N'     '<'     0x0303
-O               'O'     '('     'o'     'O'     '('     0x00
-P               'P'     ')'     'p'     'P'     ')'     0x00
-Q               'Q'     '*'     'q'     'Q'     '*'     0x0300
-R               'R'     '3'     'r'     'R'     '3'     0x20AC
-S               'S'     '4'     's'     'S'     '4'     0x00DF
-T               'T'     '+'     't'     'T'     '+'     0x00A3
-U               'U'     '&'     'u'     'U'     '&'     0x0308
-V               'V'     '9'     'v'     'V'     '9'     '^'
-W               'W'     '1'     'w'     'W'     '1'     0x00
-X               'X'     '7'     'x'     'X'     '7'     0xEF00
-Y               'Y'     '!'     'y'     'Y'     '!'     0x00A1
-Z               'Z'     '#'     'z'     'Z'     '#'     0x00
-                                                        
-COMMA           ','     ','     ','     ';'     ';'     '|'
-PERIOD          '.'     '.'     '.'     ':'     ':'     0x2026
-AT              '@'     '0'     '@'     '0'     '0'     0x2022
-SLASH           '/'     '/'     '/'     '?'     '?'     '\'
-                                                        
-SPACE           0x20    0x20    0x20    0x20    0xEF01  0xEF01
-ENTER         0xa     0xa     0xa     0xa     0xa     0xa
-                                                        
-# on pc keyboards
-TAB             0x9     0x9     0x9     0x9     0x9     0x9
-0               '0'     '0'     '0'     ')'     ')'     ')'
-1               '1'     '1'     '1'     '!'     '!'     '!'
-2               '2'     '2'     '2'     '@'     '@'     '@'
-3               '3'     '3'     '3'     '#'     '#'     '#'
-4               '4'     '4'     '4'     '$'     '$'     '$'
-5               '5'     '5'     '5'     '%'     '%'     '%'
-6               '6'     '6'     '6'     '^'     '^'     '^'
-7               '7'     '7'     '7'     '&'     '&'     '&'
-8               '8'     '8'     '8'     '*'     '*'     '*'
-9               '9'     '9'     '9'     '('     '('     '('
-                                                        
-GRAVE           '`'     '`'     '`'     '~'     '`'     '~'
-MINUS           '-'     '-'     '-'     '_'     '-'     '_'
-EQUALS          '='     '='     '='     '+'     '='     '+'
-LEFT_BRACKET    '['     '['     '['     '{'     '['     '{'
-RIGHT_BRACKET   ']'     ']'     ']'     '}'     ']'     '}'
-BACKSLASH       '\'     '\'     '\'     '|'     '\'     '|'
-SEMICOLON       ';'     ';'     ';'     ':'     ';'     ':'
-APOSTROPHE      '''     '''     '''     '"'     '''     '"'
-STAR            '*'     '*'     '*'     '*'     '*'     '*'
-POUND           '#'     '#'     '#'     '#'     '#'     '#'
-PLUS            '+'     '+'     '+'     '+'     '+'     '+'
-                                                        
-                                                        
-                                                        
diff --git a/target/board/generic/tuttle2.kl b/target/board/generic/tuttle2.kl
deleted file mode 100644
index a78a6eb..0000000
--- a/target/board/generic/tuttle2.kl
+++ /dev/null
@@ -1,74 +0,0 @@
-key 2     1
-key 3     2
-key 4     3
-key 5     4
-key 6     5
-key 7     6
-key 8     7
-key 9     8
-key 10    9
-key 11    0
-key 158   BACK              WAKE_DROPPED
-key 230   SOFT_RIGHT        WAKE
-key 60    SOFT_RIGHT        WAKE
-key 107   ENDCALL           WAKE_DROPPED
-key 62    ENDCALL           WAKE_DROPPED
-key 229   MENU         WAKE_DROPPED
-key 59    MENU         WAKE_DROPPED
-key 228   POUND
-key 227   STAR
-key 231   CALL              WAKE_DROPPED
-key 61    CALL              WAKE_DROPPED
-key 232   DPAD_CENTER       WAKE_DROPPED
-key 108   DPAD_DOWN         WAKE_DROPPED
-key 103   DPAD_UP           WAKE_DROPPED
-key 102   HOME              WAKE
-key 105   DPAD_LEFT         WAKE_DROPPED
-key 106   DPAD_RIGHT        WAKE_DROPPED
-key 115   VOLUME_UP
-key 114   VOLUME_DOWN
-key 116   POWER             WAKE
-key 212   SLASH
-
-key 16    Q
-key 17    W
-key 18    E
-key 19    R
-key 20    T
-key 21    Y
-key 22    U
-key 23    I
-key 24    O
-key 25    P
-
-key 30    A
-key 31    S
-key 32    D
-key 33    F
-key 34    G
-key 35    H
-key 36    J
-key 37    K
-key 38    L
-key 14    DEL
-        
-key 44    Z
-key 45    X
-key 46    C
-key 47    V
-key 48    B
-key 49    N
-key 50    M
-key 51    COMMA
-key 52    PERIOD
-key 28    ENTER
-        
-key 56    ALT_LEFT
-key 42    SHIFT_LEFT
-key 215   AT
-key 57    SPACE
-key 53    SLASH
-key 127   SYM
-key 100   ALT_LEFT
-
-key 399   GRAVE
diff --git a/target/board/generic_x86/AndroidBoard.mk b/target/board/generic_x86/AndroidBoard.mk
deleted file mode 100644
index ff46149..0000000
--- a/target/board/generic_x86/AndroidBoard.mk
+++ /dev/null
@@ -1,17 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := init.rc
-LOCAL_SRC_FILES := init.rc
-LOCAL_MODULE_CLASS := SHARED_LIBRARIES
-LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
-include $(BUILD_PREBUILT)
-
-ifeq ($(TARGET_PREBUILT_KERNEL),)
-LOCAL_KERNEL := prebuilt/android-x86/kernel/kernel
-else
-LOCAL_KERNEL := $(TARGET_PREBUILT_KERNEL)
-endif
-
-PRODUCT_COPY_FILES += \
-    $(LOCAL_KERNEL):kernel
diff --git a/target/board/generic_x86/BoardConfig.mk b/target/board/generic_x86/BoardConfig.mk
index 608aee1..7277908 100644
--- a/target/board/generic_x86/BoardConfig.mk
+++ b/target/board/generic_x86/BoardConfig.mk
@@ -1,20 +1,22 @@
-TARGET_COMPRESS_MODULE_SYMBOLS := false
-TARGET_PRELINK_MODULE := false
-TARGET_NO_RECOVERY := true
-TARGET_HARDWARE_3D := false
-BOARD_USES_GENERIC_AUDIO := true
-USE_CAMERA_STUB := true
-TARGET_PROVIDES_INIT_RC := true
-USE_CUSTOM_RUNTIME_HEAP_MAX := "32M"
-TARGET_CPU_ABI := x86
-TARGET_USERIMAGES_USE_EXT2 := true
-TARGET_BOOTIMAGE_USE_EXT2 := true
+# config.mk
+#
+# Product-specific compile-time definitions.
+#
 
-# For VirtualBox and likely other emulators
-BOARD_INSTALLER_CMDLINE := init=/init console=ttyS0 console=tty0 androidboot.hardware=generic_x86 vga=788 verbose
-BOARD_KERNEL_CMDLINE := init=/init console=tty0 console=ttyS0 androidboot.hardware=generic_x86 vga=788
-TARGET_USE_DISKINSTALLER := true
-TARGET_DISK_LAYOUT_CONFIG := build/target/board/generic_x86/disk_layout.conf
-BOARD_BOOTIMAGE_MAX_SIZE := 8388608
-BOARD_SYSLOADER_MAX_SIZE := 7340032
-BOARD_FLASH_BLOCK_SIZE := 512
+# The generic product target doesn't have any hardware-specific pieces.
+TARGET_NO_BOOTLOADER := true
+TARGET_NO_KERNEL := true
+TARGET_CPU_ABI := x86
+TARGET_ARCH := x86
+TARGET_ARCH_VARIANT := x86-atom
+TARGET_PRELINK_MODULE := false
+
+# The IA emulator (qemu) uses the Goldfish devices
+HAVE_HTC_AUDIO_DRIVER := true
+BOARD_USES_GENERIC_AUDIO := true
+
+# no hardware camera
+USE_CAMERA_STUB := true
+
+# Set /system/bin/sh to ash, not mksh, to make sure we can switch back.
+TARGET_SHELL := ash
diff --git a/target/board/generic_x86/README.txt b/target/board/generic_x86/README.txt
index 97e2d5b..938d982 100644
--- a/target/board/generic_x86/README.txt
+++ b/target/board/generic_x86/README.txt
@@ -1,33 +1,8 @@
-The generic_x86 board target provides basic services on very basic
-hardware (really for an emulation). To build with generic_x86, you will
-need an appropriate kernel for your emulation (or device).
+The "generic_x86" product defines a non-hardware-specific IA target
+without a kernel or bootloader.
 
-A1. Create a new top level directory and pull the AOSP repository
-        mkdir $HOME/AOSP
-        cd $HOME/AOSP
-        repo init -u git://android.git.kernel.org/platform/manifest.git
-        repo sync
+It can be used to build the entire user-level system, and
+will work with the IA version of the emulator,
 
-A2. Copy in the buildspeck.mk
-        cd $HOME/AOSP
-        cp build/target/board/generic_x86/buildspec-generic_x86.mk buildspec.mk
-
-A3. Copy in the kernel
-        cd $HOME/AOSP
-        cp ~/bzImage.your_device $HOME/AOSP/prebuilt/android-x86/kernel/kernel
-
-A4. Build
-        cd $HOME/AOSP
-        source build/envsetup.sh
-        lunch generic_x86-eng
-        make -j8
-
-The build will generate some image files whose format may or may not be correct for your
-device. You can build an installer image disk for the VirtualBox emulator using the command:
-
-A5. Build a VirtualBox installer image
-	cd $HOME/AOSP
-        source build/envsetup.sh
-        lunch generic_x86-eng
-        make -j8 installer_vdi
-
+It is not a product "base class"; no other products inherit
+from it or use it in any way.
diff --git a/target/board/generic_x86/buildspec-generic_x86.mk b/target/board/generic_x86/buildspec-generic_x86.mk
deleted file mode 100644
index fbc3947..0000000
--- a/target/board/generic_x86/buildspec-generic_x86.mk
+++ /dev/null
@@ -1,7 +0,0 @@
-BUILD_ENV_SEQUENCE_NUMBER := 9
-DISABLE_DEXPREOPT := true
-TARGET_ARCH := x86
-
-# The eth0 device should be started with dhcp on boot.
-# Useful for emulators that don't provide a wifi connection.
-NET_ETH0_STARTONBOOT := true
diff --git a/target/board/generic_x86/device.mk b/target/board/generic_x86/device.mk
new file mode 100644
index 0000000..0b4dc27
--- /dev/null
+++ b/target/board/generic_x86/device.mk
@@ -0,0 +1,26 @@
+#
+# 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 the product aspects that
+# are specific to the emulator.
+
+PRODUCT_PROPERTY_OVERRIDES := \
+    ro.ril.hsxpa=1 \
+    ro.ril.gprsclass=10
+
+PRODUCT_COPY_FILES := \
+    development/data/etc/apns-conf.xml:system/etc/apns-conf.xml \
+    development/data/etc/vold.conf:system/etc/vold.conf
diff --git a/target/board/generic_x86/disk_layout.conf b/target/board/generic_x86/disk_layout.conf
deleted file mode 100644
index 7b073ee..0000000
--- a/target/board/generic_x86/disk_layout.conf
+++ /dev/null
@@ -1,54 +0,0 @@
-device {
-    path /dev/block/sda
-
-    scheme mbr
-
-    # bytes in a disk sector (== 1 LBA), must be a power of 2!
-    sector_size 512
-
-    # What LBA should the partitions start at?
-    start_lba 2048
-
-    # Autodetect disk size if == 0
-    num_lba 0
-
-    partitions {
-        sysloader {
-            active y
-            type linux
-            len 7M
-        }
-
-        recovery {
-            active y
-            type linux
-            len 16M
-        }
-
-        boot {
-            active y
-            type linux
-            len 8M
-        }
-
-        cache {
-            type linux
-            len 512M
-        }
-
-        system {
-            type linux
-            len 512M
-        }
-
-        third_party {
-            type linux
-            len 512M
-        }
-
-        data {
-            type linux
-            len -1
-        }
-    }
-}
diff --git a/target/board/generic_x86/init.rc b/target/board/generic_x86/init.rc
deleted file mode 100644
index 235083d..0000000
--- a/target/board/generic_x86/init.rc
+++ /dev/null
@@ -1,254 +0,0 @@
-
-on init
-
-sysclktz 0
-
-loglevel 3
-
-# setup the global environment
-    export PATH /sbin:/system/sbin:/system/bin:/system/xbin
-    export LD_LIBRARY_PATH /system/lib
-    export ANDROID_BOOTLOGO 1
-    export ANDROID_ROOT /system
-    export ANDROID_ASSETS /system/app
-    export ANDROID_DATA /data
-    export EXTERNAL_STORAGE /sdcard
-    export BOOTCLASSPATH /system/framework/core.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/android.policy.jar:/system/framework/services.jar
-
-# Backward compatibility
-    symlink /system/etc /etc
-
-# create mountpoints and mount tmpfs on sqlite_stmt_journals and debugfs on d
-    mkdir /d
-    mkdir /sdcard 0000 system system
-    mkdir /system
-    mkdir /data 0771 system system
-    mkdir /cache 0770 system cache
-    mkdir /sqlite_stmt_journals 01777 root root
-    mount tmpfs tmpfs /sqlite_stmt_journals
-    mount debugfs debugfs /d
-
-    mount rootfs rootfs / rw remount
-
-    write /proc/sys/kernel/panic_on_oops 1
-    write /proc/sys/kernel/hung_task_timeout_secs 0
-    write /proc/cpu/alignment 4
-    write /proc/sys/kernel/sched_latency_ns 10000000
-    write /proc/sys/kernel/sched_wakeup_granularity_ns 2000000
-
-# mount mtd partitions
-    # Hack...
-    #   We'll attempt to mount both as sdcard and harddisk...
-    #   Only one or the other will actually work... this way, we can
-    #   use the same init.rc for both
-    mount ext3 /dev/block/mmcblk0p6 /system
-    mount ext3 /dev/block/mmcblk0p6 /system rw remount
-    mount ext3 /dev/block/mmcblk0p2 /data nosuid nodev
-    mount ext3 /dev/block/mmcblk0p7 /cache nosuid nodev
-    mount ext3 /dev/block/sda6 /system
-    mount ext3 /dev/block/sda6 /system rw remount
-    mount ext3 /dev/block/sda8 /data
-
-    # We chown/chmod /data again so because mount is run as root + defaults
-    chown system system /data
-    chmod 0771 /data
-
-    # Same reason as /data above
-    chown system cache /cache
-    chmod 0770 /cache
-
-    # This may have been created by the recovery system with odd permissions
-    chown system system /cache/recovery
-    chmod 0770 /cache/recovery
-
-# create basic filesystem structure
-    mkdir /data/misc 01771 system misc
-    mkdir /data/misc/hcid 0770 bluetooth bluetooth
-    mkdir /data/local 0771 shell shell
-    mkdir /data/local/tmp 0771 shell shell
-    mkdir /data/data 0771 system system
-    mkdir /data/app-private 0771 system system
-    mkdir /data/app 0771 system system
-    mkdir /data/property 0700 root root
-
-    # create dalvik-cache and double-check the perms
-    mkdir /data/dalvik-cache 0771 system system
-    chown system system /data/dalvik-cache
-    chmod 0771 /data/dalvik-cache
-
-    # create the lost+found directories, so as to enforce our permissions
-    mkdir /system/lost+found 0770
-    mkdir /data/lost+found 0770
-    mkdir /cache/lost+found 0770
-
-    # double check the perms, in case lost+found already exists, and set owner
-    chown root root /data/lost+found
-    chmod 0770 /data/lost+found
-    chown root root /cache/lost+found
-    chmod 0770 /cache/lost+found
-
-on boot
-
-### Load some modules
-
-# basic network init
-    ifup lo
-    hostname localhost
-    domainname localdomain
-
-
-# set RLIMIT_NICE to allow priorities from 19 to -20
-    setrlimit 13 40 40
-    mkdir /data/core 0777
-    write /proc/sys/kernel/core_pattern /data/core/%e.%p
-    setrlimit 4 -1 -1
-
-# Define the oom_adj values for the classes of processes that can be
-# killed by the kernel.  These are used in ActivityManagerService.
-    setprop ro.FOREGROUND_APP_ADJ 0
-    setprop ro.VISIBLE_APP_ADJ 1
-    setprop ro.SECONDARY_SERVER_ADJ 2
-    setprop ro.HIDDEN_APP_MIN_ADJ 7
-    setprop ro.CONTENT_PROVIDER_ADJ 14
-    setprop ro.EMPTY_APP_ADJ 15
-    setprop ro.BACKUP_APP_ADJ 2
-    setprop ro.HOME_APP_ADJ 4
-
-
-# Define the memory thresholds at which the above process classes will
-# be killed.  These numbers are in pages (4k).
-    setprop ro.FOREGROUND_APP_MEM 1536
-    setprop ro.VISIBLE_APP_MEM 2048
-    setprop ro.SECONDARY_SERVER_MEM 4096
-    setprop ro.BACKUP_APP_MEM 4096
-    setprop ro.HOME_APP_MEM 4096
-    setprop ro.HIDDEN_APP_MEM 5120
-    setprop ro.CONTENT_PROVIDER_MEM 5632
-    setprop ro.EMPTY_APP_MEM 6144
-
-
-# Write value must be consistent with the above properties.
-    write /sys/module/lowmemorykiller/parameters/adj 0,1,2,7,14,15
-
-    write /proc/sys/vm/overcommit_memory 1
-    write /sys/module/lowmemorykiller/parameters/minfree 1536,2048,4096,8192,16384
-
-    # Set init its forked children's oom_adj.
-    write /proc/1/oom_adj -16
-
-    # Permissions for System Server and daemons.
-    chown radio system /sys/android_power/state
-    chown radio system /sys/android_power/request_state
-    chown radio system /sys/android_power/acquire_full_wake_lock
-    chown radio system /sys/android_power/acquire_partial_wake_lock
-    chown radio system /sys/android_power/release_wake_lock
-    chown radio system /sys/power/state
-    chown radio system /sys/power/wake_lock
-    chown radio system /sys/power/wake_unlock
-    chmod 0660 /sys/power/state
-    chmod 0660 /sys/power/wake_lock
-    chmod 0660 /sys/power/wake_unlock
-
-    chown system system /sys/class/timed_output/vibrator/enable
-    chown system system /sys/class/leds/keyboard-backlight/brightness
-    chown system system /sys/class/leds/lcd-backlight/brightness
-    chown system system /sys/class/leds/button-backlight/brightness
-    chown system system /sys/class/leds/red/brightness
-    chown system system /sys/class/leds/green/brightness
-    chown system system /sys/class/leds/blue/brightness
-    chown system system /sys/class/leds/red/device/grpfreq
-    chown system system /sys/class/leds/red/device/grppwm
-    chown system system /sys/class/leds/red/device/blink
-    chown system system /sys/class/leds/red/brightness
-    chown system system /sys/class/leds/green/brightness
-    chown system system /sys/class/leds/blue/brightness
-    chown system system /sys/class/leds/red/device/grpfreq
-    chown system system /sys/class/leds/red/device/grppwm
-    chown system system /sys/class/leds/red/device/blink
-    chown system system /sys/class/timed_output/vibrator/enable
-    chown bluetooth bluetooth /sys/module/board_trout/parameters/bluetooth_power_on
-    chown system system /sys/module/sco/parameters/disable_esco
-    chmod 0660 /sys/module/board_trout/parameters/bluetooth_power_on
-    chown radio audio /system/etc/AudioPara4.csv
-    chown system system /sys/kernel/ipv4/tcp_wmem_min
-    chown system system /sys/kernel/ipv4/tcp_wmem_def
-    chown system system /sys/kernel/ipv4/tcp_wmem_max
-    chown system system /sys/kernel/ipv4/tcp_rmem_min
-    chown system system /sys/kernel/ipv4/tcp_rmem_def
-    chown system system /sys/kernel/ipv4/tcp_rmem_max
-    chown root radio /proc/cmdline
-
-# Enable audio based on existing /dev/dsp
-    chmod 0666 /dev/snd/dsp
-
-# Define TCP buffer sizes for various networks
-#   ReadMin, ReadInitial, ReadMax, WriteMin, WriteInitial, WriteMax,
-    setprop net.tcp.buffersize.default 4096,87380,110208,4096,16384,110208
-    setprop net.tcp.buffersize.wifi    4095,87380,110208,4096,16384,110208
-    setprop net.tcp.buffersize.umts    4094,87380,110208,4096,16384,110208
-    setprop net.tcp.buffersize.edge    4093,26280,35040,4096,16384,35040
-    setprop net.tcp.buffersize.gprs    4092,8760,11680,4096,8760,11680
-
-    class_start default
-
-
-## Daemon processes to be run by init.
-##
-service console /system/bin/sh
-    console
-
-# adbd is controlled by the persist.service.adb.enable system property
-service adbd /sbin/adbd
-#    disabled
-
-# adbd on at boot in emulator
-on property:ro.kernel.qemu=1
-    start adbd
-
-# adbd on at boot in insecure builds
-on property:ro.secure=0
-    start adbd
-
-on property:persist.service.adb.enable=1
-    start adbd
-
-on property:persist.service.adb.enable=0
-    stop adbd
-
-service servicemanager /system/bin/servicemanager
-    user system
-    critical
-    onrestart restart zygote
-    onrestart restart media
-
-service vold /system/bin/vold
-    socket vold stream 0660 root mount
-
-service zygote /system/bin/app_process -Xzygote -Xint:fast /system/bin --zygote --start-system-server
-    socket zygote stream 666
-    onrestart write /sys/android_power/request_state wake
-
-service media /system/bin/mediaserver
-    user media
-    group system audio camera graphics inet net_bt net_bt_admin
-
-service dbus /system/bin/dbus-daemon --system --nofork
-    socket dbus stream 660 bluetooth bluetooth
-    user bluetooth
-    group bluetooth net_bt_admin
-
-service brick /system/bin/wipe nuke
-    disabled
-
-service installd /system/bin/installd
-    socket installd stream 600 system system
-
-#
-# Set by PRODUCT_PROPERTY_OVERRIDES in <product>.mk
-on property:net.eth0.startonboot=1
-    setprop ro.com.android.dataroaming true
-    start start_eth0
-
-service start_eth0 /system/bin/netcfg eth0 dhcp
-    oneshot
-    disabled
diff --git a/target/board/generic_x86/system.prop b/target/board/generic_x86/system.prop
new file mode 100644
index 0000000..137a0f9
--- /dev/null
+++ b/target/board/generic_x86/system.prop
@@ -0,0 +1,6 @@
+#
+# system.prop for generic sdk
+#
+
+rild.libpath=/system/lib/libreference-ril.so
+rild.libargs=-d /dev/ttyS0
diff --git a/target/board/sim/BoardConfig.mk b/target/board/sim/BoardConfig.mk
index ba25c18..ba55b92 100644
--- a/target/board/sim/BoardConfig.mk
+++ b/target/board/sim/BoardConfig.mk
@@ -3,13 +3,11 @@
 # Product-specific compile-time definitions.
 #
 
-# Don't try prelinking or compressing the shared libraries
-# used by the simulator.  The host OS won't know what to do
-# with them, and they may not even be ELF files.
+# Don't try compressing the shared libraries used by the simulator.  The host
+# OS won't know what to do with them, and they may not even be ELF files.
 #
 # These definitions override the defaults in config/config.make.
 TARGET_COMPRESS_MODULE_SYMBOLS := false
-TARGET_PRELINK_MODULE := false
 
 # Don't try to build a bootloader.
 TARGET_NO_BOOTLOADER := true
diff --git a/target/board/vbox_x86/AndroidBoard.mk b/target/board/vbox_x86/AndroidBoard.mk
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/target/board/vbox_x86/AndroidBoard.mk
@@ -0,0 +1 @@
+
diff --git a/target/board/vbox_x86/BoardConfig.mk b/target/board/vbox_x86/BoardConfig.mk
new file mode 100644
index 0000000..94df57c
--- /dev/null
+++ b/target/board/vbox_x86/BoardConfig.mk
@@ -0,0 +1,38 @@
+#
+# IA target for VitualBox
+#
+
+TARGET_ARCH=x86
+DISABLE_DEXPREOPT := true
+TARGET_COMPRESS_MODULE_SYMBOLS := false
+TARGET_NO_RECOVERY := true
+TARGET_HARDWARE_3D := false
+BOARD_USES_GENERIC_AUDIO := true
+USE_CAMERA_STUB := true
+TARGET_PROVIDES_INIT_RC := true
+USE_CUSTOM_RUNTIME_HEAP_MAX := "32M"
+TARGET_CPU_ABI := x86
+TARGET_USERIMAGES_USE_EXT4 := true
+TARGET_BOOTIMAGE_USE_EXT2 := true
+
+# For VirtualBox and likely other emulators
+BOARD_INSTALLER_CMDLINE := init=/init console=ttyS0 console=tty0 vga=788 verbose
+BOARD_KERNEL_CMDLINE := init=/init qemu=1 console=ttyS0 console=tty0 vga=788 verbose androidboot.hardware=vbox_x86 androidboot.console=ttyS0 android.qemud=ttyS1
+TARGET_USE_DISKINSTALLER := true
+
+TARGET_DISK_LAYOUT_CONFIG := build/target/board/vbox_x86/disk_layout.conf
+BOARD_BOOTIMAGE_MAX_SIZE := 8388608
+BOARD_SYSLOADER_MAX_SIZE := 7340032
+BOARD_FLASH_BLOCK_SIZE := 512
+# 50M
+BOARD_USERDATAIMAGE_PARTITION_SIZE := 52428800
+# 500M
+BOARD_INSTALLERIMAGE_PARTITION_SIZE := 524288000
+TARGET_USERIMAGES_SPARSE_EXT_DISABLED := true
+# Reserve 265M  for the system partition
+BOARD_SYSTEMIMAGE_PARTITION_SIZE := 268435456
+
+
+# The eth0 device should be started with dhcp on boot.
+# Useful for emulators that don't provide a wifi connection.
+NET_ETH0_STARTONBOOT := true
diff --git a/target/board/vbox_x86/README.txt b/target/board/vbox_x86/README.txt
new file mode 100644
index 0000000..568dc5f
--- /dev/null
+++ b/target/board/vbox_x86/README.txt
@@ -0,0 +1,9 @@
+The "vbox_x86" product defines a non-hardware-specific target intended
+to run on the VirtualBox emulator.
+
+Most of the Android devices (networking, phones, sound, etc) do not work.
+
+ADB via ethernet works with this target. You can use 'adb install' to
+test applications that do not require network, phone or sound support.
+This emulation is useful because VirtualBox runs much faster then does the
+QEMU emulators (at least until a KVM enabled QEMU emulator is available).
diff --git a/target/board/vbox_x86/device.mk b/target/board/vbox_x86/device.mk
new file mode 100644
index 0000000..a028b98
--- /dev/null
+++ b/target/board/vbox_x86/device.mk
@@ -0,0 +1,33 @@
+#
+# 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 the product aspects that
+# are specific to the emulator.
+
+LOCAL_PATH := $(call my-dir)
+
+PRODUCT_PROPERTY_OVERRIDES := \
+    ro.ril.hsxpa=1 \
+    ro.ril.gprsclass=10
+
+LOCAL_KERNEL := prebuilt/android-x86/kernel/kernel-vbox
+
+PRODUCT_COPY_FILES := \
+    development/data/etc/apns-conf.xml:system/etc/apns-conf.xml \
+    development/data/etc/vold.conf:system/etc/vold.conf \
+    build/target/board/vbox_x86/init.rc:root/init.rc \
+    build/target/board/vbox_x86/init.vbox_x86.rc:root/init.vbox_x86.rc \
+    $(LOCAL_KERNEL):kernel
diff --git a/target/board/vbox_x86/disk_layout.conf b/target/board/vbox_x86/disk_layout.conf
new file mode 100644
index 0000000..12241ab
--- /dev/null
+++ b/target/board/vbox_x86/disk_layout.conf
@@ -0,0 +1,76 @@
+# Best to align all partion start/ends on a cylinder boundary (fdisk prefers it)
+# 512 bytes/sector
+# 63 sectors/track
+# 32 tracks/cylinder
+
+# LBAs are in 'k', so...
+# 1008 blocks (1k each) (1032192 bytes) / cylinder
+
+device {
+
+    path /dev/block/sda
+
+    scheme mbr
+
+    # bytes in a disk sector (== 1 LBA), must be a power of 2!
+    sector_size 512
+
+    # Start_lba should be on a cylindar boundary.
+    start_lba 63
+
+    # Autodetect disk size if == 0
+    num_lba 0
+
+    partitions {
+        # /dev/sdX1
+        sysloader {
+            active y
+            type linux
+            # 8 cyls in length... about 8M
+            len 8064
+        }
+
+        # /dev/sdX2
+        recovery {
+            active y
+            type linux
+            # 8 cyls in length... about 8M
+            len 8064
+        }
+
+        # /dev/sdX3
+        boot {
+            active y
+            type linux
+            # 8 cyls in length... about 8M
+            len 8064
+        }
+
+        # /dev/sdX4
+        # (extended partion begins)
+
+        # /dev/sdX5
+        cache {
+            type linux
+            len 512M
+        }
+
+        # /dev/sdX6
+        system {
+            type linux
+            len 512M
+        }
+
+        # /dev/sdX7
+        third_party {
+            type linux
+            len 512M
+        }
+
+        # /dev/sdX8
+        data {
+            type linux
+            len -1
+        }
+    }
+}
diff --git a/target/board/vbox_x86/init.rc b/target/board/vbox_x86/init.rc
new file mode 100644
index 0000000..100cc09
--- /dev/null
+++ b/target/board/vbox_x86/init.rc
@@ -0,0 +1,426 @@
+on early-init
+    start ueventd
+
+on init
+
+sysclktz 0
+
+loglevel 3
+
+# setup the global environment
+    export PATH /sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin
+    export LD_LIBRARY_PATH /vendor/lib:/system/lib
+    export ANDROID_BOOTLOGO 1
+    export ANDROID_ROOT /system
+    export ANDROID_ASSETS /system/app
+    export ANDROID_DATA /data
+    export EXTERNAL_STORAGE /mnt/sdcard
+    export ASEC_MOUNTPOINT /mnt/asec
+    export LOOP_MOUNTPOINT /mnt/obb
+    export BOOTCLASSPATH /system/framework/core.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/android.policy.jar:/system/framework/services.jar:/system/framework/core-junit.jar
+
+# Backward compatibility
+    symlink /system/etc /etc
+    symlink /sys/kernel/debug /d
+
+# Right now vendor lives on the same filesystem as system,
+# but someday that may change.
+    symlink /system/vendor /vendor
+
+# create mountpoints
+    mkdir /mnt 0775 root system
+    mkdir /mnt/sdcard 0000 system system
+
+# Create cgroup mount point for cpu accounting
+    mkdir /acct
+    mount cgroup none /acct cpuacct
+    mkdir /acct/uid
+
+# Backwards Compat - XXX: Going away in G*
+    symlink /mnt/sdcard /sdcard
+
+    mkdir /system
+    mkdir /data 0771 system system
+    mkdir /cache 0770 system cache
+    mkdir /config 0500 root root
+
+    # Directory for putting things only root should see.
+    mkdir /mnt/secure 0700 root root
+
+    # Directory for staging bindmounts
+    mkdir /mnt/secure/staging 0700 root root
+
+    # Directory-target for where the secure container
+    # imagefile directory will be bind-mounted
+    mkdir /mnt/secure/asec  0700 root root
+
+    # Secure container public mount points.
+    mkdir /mnt/asec  0700 root system
+    mount tmpfs tmpfs /mnt/asec mode=0755,gid=1000
+
+    # Filesystem image public mount points.
+    mkdir /mnt/obb 0700 root system
+    mount tmpfs tmpfs /mnt/obb mode=0755,gid=1000
+
+    write /proc/sys/kernel/panic_on_oops 1
+    write /proc/sys/kernel/hung_task_timeout_secs 0
+    write /proc/cpu/alignment 4
+    write /proc/sys/kernel/sched_latency_ns 10000000
+    write /proc/sys/kernel/sched_wakeup_granularity_ns 2000000
+    write /proc/sys/kernel/sched_compat_yield 1
+    write /proc/sys/kernel/sched_child_runs_first 0
+
+# Create cgroup mount points for process groups
+    mkdir /dev/cpuctl
+    mount cgroup none /dev/cpuctl cpu
+    chown system system /dev/cpuctl
+    chown system system /dev/cpuctl/tasks
+    chmod 0777 /dev/cpuctl/tasks
+    write /dev/cpuctl/cpu.shares 1024
+
+    mkdir /dev/cpuctl/fg_boost
+    chown system system /dev/cpuctl/fg_boost/tasks
+    chmod 0777 /dev/cpuctl/fg_boost/tasks
+    write /dev/cpuctl/fg_boost/cpu.shares 1024
+
+    mkdir /dev/cpuctl/bg_non_interactive
+    chown system system /dev/cpuctl/bg_non_interactive/tasks
+    chmod 0777 /dev/cpuctl/bg_non_interactive/tasks
+    # 5.0 %
+    write /dev/cpuctl/bg_non_interactive/cpu.shares 52
+
+on fs
+# mount sda partitions
+    mount ext4 /dev/block/sda6 /system
+    mount ext4 /dev/block/sda6 /system ro remount
+    mount ext4 /dev/block/sda7 /data nosuid nodev
+    mount ext4 /dev/block/sda8 /cache nosuid nodev
+
+on post-fs
+    # once everything is setup, no need to modify /
+    mount rootfs rootfs / ro remount
+
+    # We chown/chmod /data again so because mount is run as root + defaults
+    chown system system /data
+    chmod 0771 /data
+
+    # Create dump dir and collect dumps.
+    # Do this before we mount cache so eventually we can use cache for
+    # storing dumps on platforms which do not have a dedicated dump partition.
+   
+    mkdir /data/dontpanic
+    chown root log /data/dontpanic
+    chmod 0750 /data/dontpanic
+
+    # Collect apanic data, free resources and re-arm trigger
+    copy /proc/apanic_console /data/dontpanic/apanic_console
+    chown root log /data/dontpanic/apanic_console
+    chmod 0640 /data/dontpanic/apanic_console
+
+    copy /proc/apanic_threads /data/dontpanic/apanic_threads
+    chown root log /data/dontpanic/apanic_threads
+    chmod 0640 /data/dontpanic/apanic_threads
+
+    write /proc/apanic_console 1
+
+    # Same reason as /data above
+    chown system cache /cache
+    chmod 0770 /cache
+
+    # This may have been created by the recovery system with odd permissions
+    chown system cache /cache/recovery
+    chmod 0770 /cache/recovery
+
+    #change permissions on vmallocinfo so we can grab it from bugreports
+    chown root log /proc/vmallocinfo
+    chmod 0440 /proc/vmallocinfo
+
+    #change permissions on kmsg & sysrq-trigger so bugreports can grab kthread stacks
+    chown root system /proc/kmsg
+    chmod 0440 /proc/kmsg
+    chown root system /proc/sysrq-trigger
+    chmod 0220 /proc/sysrq-trigger
+
+# create basic filesystem structure
+    mkdir /data/misc 01771 system misc
+    mkdir /data/misc/bluetoothd 0770 bluetooth bluetooth
+    mkdir /data/misc/bluetooth 0770 system system
+    mkdir /data/misc/keystore 0700 keystore keystore
+    mkdir /data/misc/vpn 0770 system system
+    mkdir /data/misc/systemkeys 0700 system system
+    mkdir /data/misc/vpn/profiles 0770 system system
+    # give system access to wpa_supplicant.conf for backup and restore
+    mkdir /data/misc/wifi 0770 wifi wifi
+    chmod 0770 /data/misc/wifi
+    chmod 0660 /data/misc/wifi/wpa_supplicant.conf
+    mkdir /data/local 0771 shell shell
+    mkdir /data/local/tmp 0771 shell shell
+    mkdir /data/data 0771 system system
+    mkdir /data/app-private 0771 system system
+    mkdir /data/app 0771 system system
+    mkdir /data/property 0700 root root
+
+    # create dalvik-cache and double-check the perms
+    mkdir /data/dalvik-cache 0771 system system
+    chown system system /data/dalvik-cache
+    chmod 0771 /data/dalvik-cache
+
+    # create the lost+found directories, so as to enforce our permissions
+    mkdir /data/lost+found 0770
+    mkdir /cache/lost+found 0770
+
+    # double check the perms, in case lost+found already exists, and set owner
+    chown root root /data/lost+found
+    chmod 0770 /data/lost+found
+    chown root root /cache/lost+found
+    chmod 0770 /cache/lost+found
+
+    # create data/drm directory
+    mkdir /data/drm 0774 drm drm
+    chown drm drm /data/drm
+    chmod 0774 /data/drm
+
+on boot
+# basic network init
+    ifup lo
+    hostname localhost
+    domainname localdomain
+
+# set RLIMIT_NICE to allow priorities from 19 to -20
+    setrlimit 13 40 40
+
+# Define the oom_adj values for the classes of processes that can be
+# killed by the kernel.  These are used in ActivityManagerService.
+    setprop ro.FOREGROUND_APP_ADJ 0
+    setprop ro.VISIBLE_APP_ADJ 1
+    setprop ro.PERCEPTIBLE_APP_ADJ 2
+    setprop ro.HEAVY_WEIGHT_APP_ADJ 3
+    setprop ro.SECONDARY_SERVER_ADJ 4
+    setprop ro.BACKUP_APP_ADJ 5
+    setprop ro.HOME_APP_ADJ 6
+    setprop ro.HIDDEN_APP_MIN_ADJ 7
+    setprop ro.EMPTY_APP_ADJ 15
+
+# Define the memory thresholds at which the above process classes will
+# be killed.  These numbers are in pages (4k).
+    setprop ro.FOREGROUND_APP_MEM 2048
+    setprop ro.VISIBLE_APP_MEM 3072
+    setprop ro.PERCEPTIBLE_APP_MEM 4096
+    setprop ro.HEAVY_WEIGHT_APP_MEM 4096
+    setprop ro.SECONDARY_SERVER_MEM 6144
+    setprop ro.BACKUP_APP_MEM 6144
+    setprop ro.HOME_APP_MEM 6144
+    setprop ro.HIDDEN_APP_MEM 7168
+    setprop ro.EMPTY_APP_MEM 8192
+
+# Write value must be consistent with the above properties.
+# Note that the driver only supports 6 slots, so we have combined some of
+# the classes into the same memory level; the associated processes of higher
+# classes will still be killed first.
+    write /sys/module/lowmemorykiller/parameters/adj 0,1,2,4,7,15
+
+    write /proc/sys/vm/overcommit_memory 1
+    write /proc/sys/vm/min_free_order_shift 4
+    write /sys/module/lowmemorykiller/parameters/minfree 2048,3072,4096,6144,7168,8192
+
+    # Set init its forked children's oom_adj.
+    write /proc/1/oom_adj -16
+
+    # Tweak background writeout
+    write /proc/sys/vm/dirty_expire_centisecs 200
+    write /proc/sys/vm/dirty_background_ratio  5
+
+    # Permissions for System Server and daemons.
+    chown radio system /sys/android_power/state
+    chown radio system /sys/android_power/request_state
+    chown radio system /sys/android_power/acquire_full_wake_lock
+    chown radio system /sys/android_power/acquire_partial_wake_lock
+    chown radio system /sys/android_power/release_wake_lock
+    chown radio system /sys/power/state
+    chown radio system /sys/power/wake_lock
+    chown radio system /sys/power/wake_unlock
+    chmod 0660 /sys/power/state
+    chmod 0660 /sys/power/wake_lock
+    chmod 0660 /sys/power/wake_unlock
+    chown system system /sys/class/timed_output/vibrator/enable
+    chown system system /sys/class/leds/keyboard-backlight/brightness
+    chown system system /sys/class/leds/lcd-backlight/brightness
+    chown system system /sys/class/leds/button-backlight/brightness
+    chown system system /sys/class/leds/jogball-backlight/brightness
+    chown system system /sys/class/leds/red/brightness
+    chown system system /sys/class/leds/green/brightness
+    chown system system /sys/class/leds/blue/brightness
+    chown system system /sys/class/leds/red/device/grpfreq
+    chown system system /sys/class/leds/red/device/grppwm
+    chown system system /sys/class/leds/red/device/blink
+    chown system system /sys/class/leds/red/brightness
+    chown system system /sys/class/leds/green/brightness
+    chown system system /sys/class/leds/blue/brightness
+    chown system system /sys/class/leds/red/device/grpfreq
+    chown system system /sys/class/leds/red/device/grppwm
+    chown system system /sys/class/leds/red/device/blink
+    chown system system /sys/class/timed_output/vibrator/enable
+    chown system system /sys/module/sco/parameters/disable_esco
+    chown system system /sys/kernel/ipv4/tcp_wmem_min
+    chown system system /sys/kernel/ipv4/tcp_wmem_def
+    chown system system /sys/kernel/ipv4/tcp_wmem_max
+    chown system system /sys/kernel/ipv4/tcp_rmem_min
+    chown system system /sys/kernel/ipv4/tcp_rmem_def
+    chown system system /sys/kernel/ipv4/tcp_rmem_max
+    chown root radio /proc/cmdline
+
+# Define TCP buffer sizes for various networks
+#   ReadMin, ReadInitial, ReadMax, WriteMin, WriteInitial, WriteMax,
+    setprop net.tcp.buffersize.default 4096,87380,110208,4096,16384,110208
+    setprop net.tcp.buffersize.wifi    4095,87380,110208,4096,16384,110208
+    setprop net.tcp.buffersize.umts    4094,87380,110208,4096,16384,110208
+    setprop net.tcp.buffersize.edge    4093,26280,35040,4096,16384,35040
+    setprop net.tcp.buffersize.gprs    4092,8760,11680,4096,8760,11680
+
+    class_start default
+
+## Daemon processes to be run by init.
+##
+service ueventd /sbin/ueventd
+    critical
+
+service console /system/bin/sh
+    console
+    disabled
+    user shell
+    group log
+
+on property:ro.secure=0
+    start console
+
+# adbd is controlled by the persist.service.adb.enable system property
+service adbd /sbin/adbd
+    disabled
+
+# adbd on at boot in emulator
+on property:ro.kernel.qemu=1
+    start adbd
+
+on property:persist.service.adb.enable=1
+    start adbd
+
+on property:persist.service.adb.enable=0
+    stop adbd
+
+service servicemanager /system/bin/servicemanager
+    user system
+    critical
+    onrestart restart zygote
+    onrestart restart media
+
+service vold /system/bin/vold
+    socket vold stream 0660 root mount
+    ioprio be 2
+
+service netd /system/bin/netd
+    socket netd stream 0660 root system
+    socket dnsproxyd stream 0660 root inet
+
+service debuggerd /system/bin/debuggerd
+
+service ril-daemon /system/bin/rild
+    socket rild stream 660 root radio
+    socket rild-debug stream 660 radio system
+    user root
+    group radio cache inet misc audio sdcard_rw
+
+service zygote /system/bin/app_process -Xzygote /system/bin --zygote --start-system-server
+    socket zygote stream 666
+    onrestart write /sys/android_power/request_state wake
+    onrestart write /sys/power/state on
+    onrestart restart media
+    onrestart restart netd
+
+service drm /system/bin/drmserver
+    user drm
+    group system root inet
+
+service drmio /system/bin/drmioserver
+    user drmio
+
+service media /system/bin/mediaserver
+    user media
+    group system audio camera graphics inet net_bt net_bt_admin net_raw
+    ioprio rt 4
+
+service bootanim /system/bin/bootanimation
+    user graphics
+    group graphics
+    disabled
+    oneshot
+
+service dbus /system/bin/dbus-daemon --system --nofork
+    socket dbus stream 660 bluetooth bluetooth
+    user bluetooth
+    group bluetooth net_bt_admin
+
+service bluetoothd /system/bin/bluetoothd -n
+    socket bluetooth stream 660 bluetooth bluetooth
+    socket dbus_bluetooth stream 660 bluetooth bluetooth
+    # init.rc does not yet support applying capabilities, so run as root and
+    # let bluetoothd drop uid to bluetooth with the right linux capabilities
+    group bluetooth net_bt_admin misc
+    disabled
+
+service hfag /system/bin/sdptool add --channel=10 HFAG
+    user bluetooth
+    group bluetooth net_bt_admin
+    disabled
+    oneshot
+
+service hsag /system/bin/sdptool add --channel=11 HSAG
+    user bluetooth
+    group bluetooth net_bt_admin
+    disabled
+    oneshot
+
+service opush /system/bin/sdptool add --channel=12 OPUSH
+    user bluetooth
+    group bluetooth net_bt_admin
+    disabled
+    oneshot
+
+service pbap /system/bin/sdptool add --channel=19 PBAP
+    user bluetooth
+    group bluetooth net_bt_admin
+    disabled
+    oneshot
+
+service installd /system/bin/installd
+    socket installd stream 600 system system
+
+service flash_recovery /system/etc/install-recovery.sh
+    oneshot
+
+service racoon /system/bin/racoon
+    socket racoon stream 600 system system
+    # racoon will setuid to vpn after getting necessary resources.
+    group net_admin
+    disabled
+    oneshot
+
+service mtpd /system/bin/mtpd
+    socket mtpd stream 600 system system
+    user vpn
+    group vpn net_admin net_raw
+    disabled
+    oneshot
+
+service keystore /system/bin/keystore /data/misc/keystore
+    user keystore
+    group keystore
+    socket keystore stream 666
+
+service dumpstate /system/bin/dumpstate -s
+    socket dumpstate stream 0660 shell log
+    disabled
+    oneshot
+
+# Enable networking so that adb can connect
+service netcfg /system/bin/netcfg eth0 dhcp
+    oneshot
diff --git a/target/board/vbox_x86/init.vbox_x86.rc b/target/board/vbox_x86/init.vbox_x86.rc
new file mode 100644
index 0000000..4c5d55c
--- /dev/null
+++ b/target/board/vbox_x86/init.vbox_x86.rc
@@ -0,0 +1,52 @@
+on boot
+    setprop ARGH ARGH
+    setprop net.eth0.dns1 10.0.2.3
+    setprop net.gprs.local-ip 10.0.2.15
+    setprop ro.radio.use-ppp no
+    setprop ro.build.product generic
+    setprop ro.product.device generic
+
+# fake some battery state
+    setprop status.battery.state Slow
+    setprop status.battery.level 5
+    setprop status.battery.level_raw  50
+    setprop status.battery.level_scale 9
+
+# disable some daemons the emulator doesn't want
+    stop dund
+    stop akmd
+
+    setprop ro.setupwizard.mode EMULATOR
+
+# enable Google-specific location features,
+# like NetworkLocationProvider and LocationCollector
+    setprop ro.com.google.locationfeatures 1
+
+# For the emulator, which bypasses Setup Wizard, you can specify
+# account info for the device via these two properties.  Google
+# Login Service will insert these accounts into the database when
+# it is created (ie, after a data wipe).
+#
+#   setprop ro.config.hosted_account username@hosteddomain.org:password
+#   setprop ro.config.google_account username@gmail.com:password
+#
+# You MUST have a Google account on the device, and you MAY
+# additionally have a hosted account.  No other configuration is
+# supported, and arbitrary breakage may result if you specify
+# something else.
+
+service goldfish-setup /system/etc/init.goldfish.sh
+   oneshot
+
+service qemud /system/bin/qemud
+    socket qemud    stream 666
+    oneshot
+
+# -Q is a special logcat option that forces the
+# program to check wether it runs on the emulator
+# if it does, it redirects its output to the device
+# named by the androidboot.console kernel option
+# if not, is simply exit immediately
+
+service goldfish-logcat /system/bin/logcat -Q
+    oneshot
diff --git a/target/board/vbox_x86/system.prop b/target/board/vbox_x86/system.prop
new file mode 100644
index 0000000..137a0f9
--- /dev/null
+++ b/target/board/vbox_x86/system.prop
@@ -0,0 +1,6 @@
+#
+# system.prop for generic sdk
+#
+
+rild.libpath=/system/lib/libreference-ril.so
+rild.libargs=-d /dev/ttyS0
diff --git a/target/product/AndroidProducts.mk b/target/product/AndroidProducts.mk
index 9a91da9..fafd222 100644
--- a/target/product/AndroidProducts.mk
+++ b/target/product/AndroidProducts.mk
@@ -25,17 +25,22 @@
 # it includes.
 #
 
-# An unbundled app build needs only generic.mk.
+# Unbundled apps will be built with the default product config.
 ifneq ($(TARGET_BUILD_APPS),)
 PRODUCT_MAKEFILES := \
     $(LOCAL_DIR)/core.mk \
-    $(LOCAL_DIR)/generic.mk
+    $(LOCAL_DIR)/generic.mk \
+    $(LOCAL_DIR)/full.mk
 else
 PRODUCT_MAKEFILES := \
     $(LOCAL_DIR)/core.mk \
     $(LOCAL_DIR)/generic.mk \
     $(LOCAL_DIR)/generic_x86.mk \
     $(LOCAL_DIR)/full.mk \
+    $(LOCAL_DIR)/full_x86.mk \
+    $(LOCAL_DIR)/vbox_x86.mk \
     $(LOCAL_DIR)/sdk.mk \
-    $(LOCAL_DIR)/sim.mk
+    $(LOCAL_DIR)/sdk_x86.mk \
+    $(LOCAL_DIR)/sim.mk \
+    $(LOCAL_DIR)/large_emu_hw.mk
 endif
diff --git a/target/product/core.mk b/target/product/core.mk
index 0b906e0..6c8e21f 100644
--- a/target/product/core.mk
+++ b/target/product/core.mk
@@ -23,46 +23,63 @@
     ro.config.alarm_alert=Alarm_Classic.ogg
 
 PRODUCT_PACKAGES := \
+    apache-xml \
     bouncycastle \
+    bu \
+    cacerts \
     com.android.location.provider \
     com.android.location.provider.xml \
     core \
     core-junit \
-    create_test_dmtrace \
     dalvikvm \
     dexdeps \
     dexdump \
     dexlist \
     dexopt \
     dmtracedump \
-    dvz \
     dx \
     ext \
     framework-res \
     hprof-conv \
     icu.dat \
-    jasmin \
-    jasmin.jar \
+    installd \
+    ip-up-vpn \
     libcrypto \
     libdex \
     libdvm \
     libexpat \
+    libgabi++ \
     libicui18n \
     libicuuc \
     libjavacore \
     libnativehelper \
     libnfc_ndef \
+    libOpenMAXAL \
+    libOpenSLES \
     libsqlite_jni \
     libssl \
+    libstagefright_soft_aacdec \
+    libstagefright_soft_amrdec \
+    libstagefright_soft_avcdec \
+    libstagefright_soft_g711dec \
+    libstagefright_soft_mp3dec \
+    libstagefright_soft_mpeg4dec \
+    libstagefright_soft_vorbisdec \
+    libstagefright_soft_vpxdec \
+    libwilhelm \
+    libfilterfw \
+    libfilterpack_imageproc \
     libz \
-    sqlite-jdbc \
+    wpa_supplicant.conf \
+    KeyChain \
     Browser \
     Contacts \
     Home \
     HTMLViewer \
-    Phone \
     ApplicationsProvider \
+    BackupRestoreConfirmation \
     ContactsProvider \
+    VoicemailProvider \
     DownloadProvider \
     DownloadProviderUi \
     MediaProvider \
@@ -74,13 +91,18 @@
     UserDictionaryProvider \
     PackageInstaller \
     DefaultContainerService \
-    Bugreport
+    Bugreport \
+    ip \
+    screencap \
+    sensorservice \
+    libspeexresampler
 
 # host-only dependencies
 ifeq ($(WITH_HOST_DALVIK),true)
     PRODUCT_PACKAGES += \
+        apache-xml-hostdex \
         bouncycastle-hostdex \
         core-hostdex \
-        libjavacore-host
+        libjavacore-host \
+        dalvik
 endif
-
diff --git a/target/product/full.mk b/target/product/full.mk
index c204aad..8231e99 100644
--- a/target/product/full.mk
+++ b/target/product/full.mk
@@ -16,44 +16,14 @@
 
 # This is a build configuration for a full-featured build of the
 # Open-Source part of the tree. It's geared toward a US-centric
-# build of the emulator, but all those aspects can be overridden
-# in inherited configurations.
+# build quite specifically for the emulator, and might not be
+# entirely appropriate to inherit from for on-device configurations.
 
-PRODUCT_PACKAGES := \
-    OpenWnn \
-    PinyinIME \
-    VoiceDialer \
-    libWnnEngDic \
-    libWnnJpnDic \
-    libwnndict
-
-# Additional settings used in all AOSP builds
-PRODUCT_PROPERTY_OVERRIDES := \
-    keyguard.no_require_sim=true \
-    ro.com.android.dateformat=MM-dd-yyyy \
-    ro.com.android.dataroaming=true \
-    ro.ril.hsxpa=1 \
-    ro.ril.gprsclass=10
-
-PRODUCT_COPY_FILES := \
-    development/data/etc/apns-conf.xml:system/etc/apns-conf.xml \
-    development/data/etc/vold.conf:system/etc/vold.conf
-
-# Pick up some sounds - stick with the short list to save space
-# on smaller devices.
-$(call inherit-product, frameworks/base/data/sounds/OriginalAudio.mk)
-
-# Get the TTS language packs
-$(call inherit-product-if-exists, external/svox/pico/lang/all_pico_languages.mk)
-
-# Get a list of languages. We use the small list to save space
-# on smaller devices.
-$(call inherit-product, build/target/product/languages_small.mk)
-
-$(call inherit-product, build/target/product/generic.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/product/full_base_telephony.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/board/generic/device.mk)
 
 # Overrides
 PRODUCT_NAME := full
-PRODUCT_BRAND := generic
 PRODUCT_DEVICE := generic
-PRODUCT_MODEL := Full Android
+PRODUCT_BRAND := Android
+PRODUCT_MODEL := Full Android on Emulator
diff --git a/target/product/full_base.mk b/target/product/full_base.mk
new file mode 100644
index 0000000..8ad812e
--- /dev/null
+++ b/target/product/full_base.mk
@@ -0,0 +1,54 @@
+#
+# 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 full-featured build of the
+# Open-Source part of the tree. It's geared toward a US-centric
+# build of the emulator, but all those aspects can be overridden
+# in inherited configurations.
+
+PRODUCT_PACKAGES := \
+    drmserver \
+    libdrmframework \
+    libdrmframework_jni \
+    libfwdlockengine \
+    OpenWnn \
+    PinyinIME \
+    libWnnEngDic \
+    libWnnJpnDic \
+    libwnndict \
+    WAPPushManager
+
+# Additional settings used in all AOSP builds
+PRODUCT_PROPERTY_OVERRIDES := \
+    ro.com.android.dateformat=MM-dd-yyyy \
+    ro.config.ringtone=Ring_Synth_04.ogg \
+    ro.config.notification_sound=pixiedust.ogg
+
+# Put en_US first in the list, so make it default.
+PRODUCT_LOCALES := en_US
+
+# Get some sounds
+$(call inherit-product-if-exists, frameworks/base/data/sounds/AllAudio.mk)
+
+# Get the TTS language packs
+$(call inherit-product-if-exists, external/svox/pico/lang/all_pico_languages.mk)
+
+# Get a list of languages.
+$(call inherit-product, $(SRC_TARGET_DIR)/product/locales_full.mk)
+
+# Get everything else from the parent package
+$(call inherit-product, $(SRC_TARGET_DIR)/product/generic_no_telephony.mk)
+
diff --git a/target/product/full_base_telephony.mk b/target/product/full_base_telephony.mk
new file mode 100644
index 0000000..c376314
--- /dev/null
+++ b/target/product/full_base_telephony.mk
@@ -0,0 +1,33 @@
+#
+# 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 full-featured build of the
+# Open-Source part of the tree. It's geared toward a US-centric
+# build quite specifically for the emulator, and might not be
+# entirely appropriate to inherit from for on-device configurations.
+
+PRODUCT_PACKAGES := \
+    VoiceDialer
+
+PRODUCT_PROPERTY_OVERRIDES := \
+    keyguard.no_require_sim=true \
+    ro.com.android.dataroaming=true
+
+PRODUCT_COPY_FILES := \
+    development/data/etc/apns-conf.xml:system/etc/apns-conf.xml
+
+$(call inherit-product, $(SRC_TARGET_DIR)/product/full_base.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/product/telephony.mk)
diff --git a/target/product/full_x86.mk b/target/product/full_x86.mk
new file mode 100644
index 0000000..d6a169a
--- /dev/null
+++ b/target/product/full_x86.mk
@@ -0,0 +1,41 @@
+#
+# 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 full-featured build of the
+# Open-Source part of the tree. It's geared toward a US-centric
+# build quite specifically for the emulator, and might not be
+# entirely appropriate to inherit from for on-device configurations.
+
+# If running on an emulator or some other device that has a LAN connection
+# that isn't a wifi connection. This will instruct init.rc to enable the
+# network connection so that you can use it with ADB
+ifdef NET_ETH0_STARTONBOOT
+  PRODUCT_PROPERTY_OVERRIDES += net.eth0.startonboot=1
+endif
+
+$(call inherit-product, $(SRC_TARGET_DIR)/product/full_base.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/board/generic_x86/device.mk)
+
+# Ensure we package the BIOS files too.
+PRODUCT_PACKAGES += \
+	bios.bin \
+	vgabios-cirrus.bin \
+
+# Overrides
+PRODUCT_NAME := full_x86
+PRODUCT_DEVICE := generic_x86
+PRODUCT_BRAND := Android
+PRODUCT_MODEL := Full Android on x86 Emulator
diff --git a/target/product/generic.mk b/target/product/generic.mk
index eed354a..dd0d663 100644
--- a/target/product/generic.mk
+++ b/target/product/generic.mk
@@ -14,36 +14,11 @@
 # limitations under the License.
 #
 
-# This is a generic product that isn't specialized for a specific device.
+# This is a generic phone product that isn't specialized for a specific device.
 # It includes the base Android platform.
 
-PRODUCT_PACKAGES := \
-    AccountAndSyncSettings \
-    DeskClock \
-    AlarmProvider \
-    Bluetooth \
-    Calculator \
-    Calendar \
-    Camera \
-    CertInstaller \
-    DrmProvider \
-    Email \
-    Gallery3D \
-    LatinIME \
-    Launcher2 \
-    Mms \
-    Music \
-    Provision \
-    Protips \
-    QuickSearchBox \
-    Settings \
-    Sync \
-    SystemUI \
-    Updater \
-    CalendarProvider \
-    SyncProvider
-
-$(call inherit-product, $(SRC_TARGET_DIR)/product/core.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/product/generic_no_telephony.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/product/telephony.mk)
 
 # Overrides
 PRODUCT_BRAND := generic
diff --git a/target/product/generic_no_telephony.mk b/target/product/generic_no_telephony.mk
new file mode 100644
index 0000000..020b0dd
--- /dev/null
+++ b/target/product/generic_no_telephony.mk
@@ -0,0 +1,77 @@
+#
+# Copyright (C) 2007 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 generic phone product that isn't specialized for a specific device.
+# It includes the base Android platform.
+
+PRODUCT_POLICY := android.policy_phone
+
+PRODUCT_PACKAGES := \
+    AccountAndSyncSettings \
+    DeskClock \
+    AlarmProvider \
+    Bluetooth \
+    Calculator \
+    Calendar \
+    Camera \
+    CertInstaller \
+    DrmProvider \
+    Email \
+    Exchange \
+    GalleryNew3D \
+    LatinIME \
+    Launcher2 \
+    Music \
+    Provision \
+    Phone \
+    QuickSearchBox \
+    Settings \
+    Sync \
+    SystemUI \
+    Updater \
+    CalendarProvider \
+    SyncProvider \
+    VpnDialogs
+
+PRODUCT_PACKAGES += \
+    icu.dat
+
+PRODUCT_PACKAGES += \
+    librs_jni \
+    libvideoeditor_jni \
+    libvideoeditorplayer \
+    libvideoeditor_core
+
+PRODUCT_PACKAGES += \
+    audio.primary.default \
+    audio_policy.default
+
+PRODUCT_COPY_FILES := \
+        system/bluetooth/data/audio.conf:system/etc/bluetooth/audio.conf \
+        system/bluetooth/data/auto_pairing.conf:system/etc/bluetooth/auto_pairing.conf \
+        system/bluetooth/data/blacklist.conf:system/etc/bluetooth/blacklist.conf \
+        system/bluetooth/data/input.conf:system/etc/bluetooth/input.conf \
+        system/bluetooth/data/network.conf:system/etc/bluetooth/network.conf \
+        frameworks/base/media/libeffects/data/audio_effects.conf:system/etc/audio_effects.conf
+
+$(call inherit-product-if-exists, frameworks/base/data/fonts/fonts.mk)
+$(call inherit-product-if-exists, frameworks/base/data/keyboards/keyboards.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/product/core.mk)
+
+# Overrides
+PRODUCT_BRAND := generic
+PRODUCT_DEVICE := generic
+PRODUCT_NAME := generic_no_telephony
diff --git a/target/product/generic_x86.mk b/target/product/generic_x86.mk
index 9713900..7e77a27 100644
--- a/target/product/generic_x86.mk
+++ b/target/product/generic_x86.mk
@@ -1,34 +1,26 @@
+#
+# Copyright (C) 2007 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 generic product that isn't specialized for a specific device.
-# It includes the base Android platform. If you need Google-specific features,
-# you should derive from generic_with_google.mk
+# It includes the base Android platform.
 
-PRODUCT_PACKAGES := \
-    AlarmClock \
-    AlarmProvider \
-    Calendar \
-    Camera \
-    DrmProvider \
-    LatinIME \
-    Mms \
-    Music \
-    Settings \
-    Sync \
-    Updater \
-    CalendarProvider \
-    SubscribedFeedsProvider \
-    SyncProvider
-
+$(call inherit-product, $(SRC_TARGET_DIR)/product/generic.mk)
 $(call inherit-product, $(SRC_TARGET_DIR)/product/core.mk)
 
 # Overrides
 PRODUCT_BRAND := generic_x86
 PRODUCT_DEVICE := generic_x86
 PRODUCT_NAME := generic_x86
-PRODUCT_POLICY := android.policy_phone
-
-# If running on an emulator or some other device that has a LAN connection
-# that isn't a wifi connection. This will instruct init.rc to enable the
-# network connection so that you can use it with ADB
-ifdef NET_ETH0_STARTONBOOT
-  PRODUCT_PROPERTY_OVERRIDES += net.eth0.startonboot=1
-endif
diff --git a/target/product/languages_full.mk b/target/product/languages_full.mk
index 236dfa2..b18f78f 100644
--- a/target/product/languages_full.mk
+++ b/target/product/languages_full.mk
@@ -21,7 +21,5 @@
 
 # Those are all the locales that have translations and are displayable
 # by TextView in this branch.
-PRODUCT_LOCALES := en_US fr_FR it_IT es_ES de_DE nl_NL cs_CZ pl_PL ja_JP zh_TW zh_CN ru_RU ko_KR nb_NO es_US da_DK el_GR tr_TR pt_PT pt_BR rm_CH sv_SE bg_BG ca_ES en_GB fi_FI hr_HR hu_HU in_ID iw_IL lt_LT lv_LV ro_RO sk_SK sl_SI sr_RS uk_UA vi_VN tl_PH
-
-# Not currently usable:
-# ar, fa, th
+PRODUCT_LOCALES := en_US fr_FR it_IT es_ES de_DE nl_NL cs_CZ pl_PL ja_JP zh_TW zh_CN ru_RU ko_KR nb_NO es_US da_DK el_GR tr_TR pt_PT pt_BR rm_CH sv_SE bg_BG ca_ES en_GB fi_FI hr_HR hu_HU in_ID iw_IL lt_LT lv_LV ro_RO sk_SK sl_SI sr_RS uk_UA vi_VN tl_PH ar_EG fa_IR th_TH sw_TZ ms_MY af_ZA zu_ZA
+# We don't have the fonts to display am_ET yet
diff --git a/target/product/large_emu_hw.mk b/target/product/large_emu_hw.mk
new file mode 100644
index 0000000..f38ef61
--- /dev/null
+++ b/target/product/large_emu_hw.mk
@@ -0,0 +1,52 @@
+#
+# Copyright (C) 2007 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 generic product for devices with large display but not specialized
+# for a specific device. It includes the base Android platform.
+
+PRODUCT_POLICY := android.policy_mid
+
+PRODUCT_PACKAGES := \
+    AccountAndSyncSettings \
+    CarHome \
+    DeskClock \
+    AlarmProvider \
+    Bluetooth \
+    Calculator \
+    Calendar \
+    Camera \
+    CertInstaller \
+    DrmProvider \
+    Email \
+    Exchange \
+    GalleryNew3D \
+    LatinIME \
+    Launcher2 \
+    Music \
+    Provision \
+    QuickSearchBox \
+    Settings \
+    Sync \
+    Updater \
+    CalendarProvider \
+    SyncProvider
+
+$(call inherit-product, $(SRC_TARGET_DIR)/product/core.mk)
+
+# Overrides
+PRODUCT_BRAND := generic
+PRODUCT_DEVICE := generic
+PRODUCT_NAME := large_emu_hw
diff --git a/target/product/locales_full.mk b/target/product/locales_full.mk
new file mode 100644
index 0000000..cf10392
--- /dev/null
+++ b/target/product/locales_full.mk
@@ -0,0 +1,5 @@
+# The locales from the ICU "-large.dat" data set.
+# See external/icu4c/stubdata.
+# This is distinct from "languages_full.mk", which contains those locales for
+# which we have translations. If you like, this file is i18n rather than l18n.
+PRODUCT_LOCALES := cs_CZ da_DK de_AT de_CH de_DE de_LI el_GR en_AU en_CA en_GB en_NZ en_SG en_US es_ES fr_CA fr_CH fr_BE fr_FR it_CH it_IT ja_JP ko_KR nb_NO nl_BE nl_NL pl_PL pt_PT ru_RU sv_SE tr_TR zh_CN zh_HK zh_TW
diff --git a/target/product/sdk.mk b/target/product/sdk.mk
index d73e702..7e470b9 100644
--- a/target/product/sdk.mk
+++ b/target/product/sdk.mk
@@ -14,42 +14,53 @@
 # limitations under the License.
 #
 
+PRODUCT_POLICY := android.policy_phone
 PRODUCT_PROPERTY_OVERRIDES :=
 
 PRODUCT_PACKAGES := \
-	SystemUI \
-	AccountAndSyncSettings \
-	Camera \
 	Calculator \
+	Camera \
 	DeskClock \
-	Development \
-	DrmProvider \
 	Email \
-	Fallback \
+	Exchange \
 	Gallery \
-	GPSEnable \
-	Launcher2 \
-	Protips \
 	Music \
 	Mms \
+	OpenWnn \
+	libWnnEngDic \
+	libWnnJpnDic \
+	libwnndict \
+        Phone \
+	PinyinIME \
+	Protips \
+	SoftKeyboard \
+	SystemUI \
+	Launcher2 \
+	AccountAndSyncSettings \
+	Development \
+	DrmProvider \
+	Fallback \
+	GPSEnable \
 	Settings \
 	SdkSetup \
 	CustomLocale \
 	gpstest \
 	sqlite3 \
 	LatinIME \
-	PinyinIME \
-	OpenWnn \
-	libWnnEngDic \
-	libWnnJpnDic \
-	libwnndict \
 	CertInstaller \
 	LiveWallpapersPicker \
 	ApiDemos \
 	GestureBuilder \
-	SoftKeyboard \
 	CubeLiveWallpapers \
-	QuickSearchBox
+	QuickSearchBox \
+	WidgetPreview \
+	monkeyrunner \
+	guavalib \
+	jsr305lib \
+	jython \
+	jsilver \
+	librs_jni
+
 
 # Host tools that are parts of the SDK.
 # See development/build/sdk.atree
@@ -60,13 +71,16 @@
 	hprof-conv \
 	mksdcard \
 	emulator \
+	bios.bin \
+	vgabios-cirrus.bin \
 	ddms \
 	hierarchyviewer \
 	draw9patch \
 	layoutopt \
 	traceview \
 	android \
-	dexdump
+	dexdump \
+	monkeyrunner
 
 # Native host Java libraries that are parts of the SDK.
 # See development/build/sdk.atree
@@ -77,8 +91,8 @@
 	ddms \
 	ddmlib \
 	ddmuilib \
-	hierarchyviewer \
 	draw9patch \
+	hierarchyviewer \
 	layoutopt \
 	uix \
 	traceview \
@@ -86,12 +100,11 @@
 	sdklib \
 	sdkuilib \
 	sdkmanager \
+	swtmenubar \
 	swing-worker-1.1 \
 	groovy-all-1.7.0 \
 	commons-compress-1.0 \
 	emmalib \
-	org-netbeans-api-visual \
-	org-openide-util \
 	jcommon-1.0.12 \
 	jfreechart-1.0.9 \
 	jfreechart-1.0.9-swt \
@@ -99,7 +112,17 @@
 	org.eclipse.equinox.common_3.4.0.v20080421-2006 \
 	org.eclipse.jface_3.4.2.M20090107-0800 \
 	osgi \
-	layoutlib
+	layoutlib \
+	monkeyrunner \
+	guavalib \
+	jsr305lib \
+	jython \
+	ddmlib-tests \
+	ninepatch-tests \
+	common-tests \
+	sdklib-tests \
+	sdkuilib-tests \
+	layoutlib-tests
 
 PRODUCT_PACKAGE_OVERLAYS := development/sdk_overlay
 
@@ -109,16 +132,22 @@
 	frameworks/base/data/sounds/effects/VideoRecord.ogg:system/media/audio/ui/VideoRecord.ogg \
 	frameworks/base/data/etc/android.hardware.camera.autofocus.xml:system/etc/permissions/android.hardware.camera.autofocus.xml
 
+$(call inherit-product-if-exists, frameworks/base/data/fonts/fonts.mk)
+$(call inherit-product-if-exists, frameworks/base/data/keyboards/keyboards.mk)
 $(call inherit-product, $(SRC_TARGET_DIR)/product/core.mk)
 
 # Overrides
 PRODUCT_BRAND := generic
 PRODUCT_NAME := sdk
 PRODUCT_DEVICE := generic
-PRODUCT_LOCALES := \
+
+# locale + densities. en_US is both first and in alphabetical order to
+# ensure this is the default locale.
+PRODUCT_LOCALES = \
 	ldpi \
 	hdpi \
 	mdpi \
+	en_US \
 	ar_EG \
 	ar_IL \
 	bg_BG \
@@ -178,9 +207,9 @@
 	zh_TW
 
 # include available languages for TTS in the system image
-include external/svox/pico/lang/PicoLangDeDeInSystem.mk
-include external/svox/pico/lang/PicoLangEnGBInSystem.mk
-include external/svox/pico/lang/PicoLangEnUsInSystem.mk
-include external/svox/pico/lang/PicoLangEsEsInSystem.mk
-include external/svox/pico/lang/PicoLangFrFrInSystem.mk
-include external/svox/pico/lang/PicoLangItItInSystem.mk
+-include external/svox/pico/lang/PicoLangDeDeInSystem.mk
+-include external/svox/pico/lang/PicoLangEnGBInSystem.mk
+-include external/svox/pico/lang/PicoLangEnUsInSystem.mk
+-include external/svox/pico/lang/PicoLangEsEsInSystem.mk
+-include external/svox/pico/lang/PicoLangFrFrInSystem.mk
+-include external/svox/pico/lang/PicoLangItItInSystem.mk
diff --git a/target/product/sdk_x86.mk b/target/product/sdk_x86.mk
new file mode 100644
index 0000000..6c5e746
--- /dev/null
+++ b/target/product/sdk_x86.mk
@@ -0,0 +1,28 @@
+#
+# 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 full-featured build of the
+# Open-Source part of the tree. It's geared toward a US-centric
+# build quite specifically for the emulator, and might not be
+# entirely appropriate to inherit from for on-device configurations.
+
+$(call inherit-product, $(SRC_TARGET_DIR)/product/sdk.mk)
+
+# Overrides
+PRODUCT_BRAND := generic_x86
+PRODUCT_NAME := sdk_x86
+PRODUCT_DEVICE := generic_x86
+PRODUCT_MODEL := Android SDK built for x86
diff --git a/target/product/sim.mk b/target/product/sim.mk
index 51b3676..09722d6 100644
--- a/target/product/sim.mk
+++ b/target/product/sim.mk
@@ -1,6 +1,6 @@
 $(call inherit-product, $(SRC_TARGET_DIR)/product/generic.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/product/locales_full.mk)
 
 # Overrides
 PRODUCT_NAME := sim
 PRODUCT_DEVICE := sim
-PRODUCT_LOCALES := en_US
diff --git a/tools/apicheck/src/Android.mk b/target/product/telephony.mk
similarity index 61%
rename from tools/apicheck/src/Android.mk
rename to target/product/telephony.mk
index c4e7c6e..a0220de 100644
--- a/tools/apicheck/src/Android.mk
+++ b/target/product/telephony.mk
@@ -1,4 +1,5 @@
-# Copyright (C) 2008 The Android Open Source Project
+#
+# Copyright (C) 2007 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.
@@ -11,18 +12,12 @@
 # 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.
+#
 
-LOCAL_PATH := $(call my-dir)
+# This is the list of product-level settings that are specific
+# to products that have telephony hardware.
 
+PRODUCT_PACKAGES := \
+    Mms
 
-# apicheck java library
-# ============================================================
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-LOCAL_JAR_MANIFEST := MANIFEST.mf
-
-LOCAL_MODULE:= apicheck
-
-include $(BUILD_HOST_JAVA_LIBRARY)
-
+PRODUCT_COPY_FILES := \
diff --git a/target/product/vbox_x86.mk b/target/product/vbox_x86.mk
new file mode 100644
index 0000000..f0d4232
--- /dev/null
+++ b/target/product/vbox_x86.mk
@@ -0,0 +1,30 @@
+#
+# 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 full-featured build of the
+# Open-Source part of the tree. It's geared toward a US-centric
+# build quite specifically for the emulator, and might not be
+# entirely appropriate to inherit from for on-device configurations.
+ifdef NET_ETH0_STARTONBOOT
+  PRODUCT_PROPERTY_OVERRIDES += net.eth0.startonboot=1
+endif
+
+$(call inherit-product, $(SRC_TARGET_DIR)/product/full_base.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/board/vbox_x86/device.mk)
+
+PRODUCT_NAME := vbox_x86
+PRODUCT_DEVICE := vbox_x86
+PRODUCT_MODEL := Full Android on x86 VirtualBox
diff --git a/tools/Android.mk b/tools/Android.mk
index fa9d0b7..92603f5 100644
--- a/tools/Android.mk
+++ b/tools/Android.mk
@@ -14,7 +14,7 @@
 # limitations under the License.
 #
 
-LOCAL_PATH := $(my-dir)
+LOCAL_PATH := $(call my-dir)
 
 # If we're building only unbundled apps, this is the only tool we need.
 ifneq ($(TARGET_BUILD_APPS),)
diff --git a/tools/adbs b/tools/adbs
index 8277790..b571d48 100755
--- a/tools/adbs
+++ b/tools/adbs
@@ -113,7 +113,7 @@
     path = os.environ['ANDROID_PRODUCT_OUT'] + "/symbols"
   except:
     cmd = "CALLED_FROM_SETUP=true BUILD_SYSTEM=build/core " \
-      + "SRC_TARGET_DIR=build/target make -f build/core/envsetup.mk " \
+      + "SRC_TARGET_DIR=build/target make -f build/core/config.mk " \
       + "dumpvar-abs-TARGET_OUT_UNSTRIPPED"
     stream = os.popen(cmd)
     str = stream.read()
@@ -144,23 +144,23 @@
       uname = "darwin-ppc"
   elif uname == "Linux":
     uname = "linux-x86"
-  prefix = "./prebuilt/" + uname + "/toolchain/arm-eabi-4.4.3/bin/"
-  addr2line_cmd = prefix + "arm-eabi-addr2line"
+  prefix = "./prebuilt/" + uname + "/toolchain/arm-linux-androideabi-4.4.x/bin/"
+  addr2line_cmd = prefix + "arm-linux-androideabi-addr2line"
 
   if (not os.path.exists(addr2line_cmd)):
     try:
       prefix = os.environ['ANDROID_BUILD_TOP'] + "/prebuilt/" + uname + \
-               "/toolchain/arm-eabi-4.4.3/bin/"
+               "/toolchain/arm-linux-androideabi-4.4.x/bin/"
     except:
       prefix = "";
 
-    addr2line_cmd = prefix + "arm-eabi-addr2line"
+    addr2line_cmd = prefix + "arm-linux-androideabi-addr2line"
     if (not os.path.exists(addr2line_cmd)):
       print addr2line_cmd + " not found!"
       sys.exit(1)
 
-  objdump_cmd = prefix + "arm-eabi-objdump"
-  cppfilt_cmd = prefix + "arm-eabi-c++filt"
+  objdump_cmd = prefix + "arm-linux-androideabi-objdump"
+  cppfilt_cmd = prefix + "arm-linux-androideabi-c++filt"
 
 ###############################################################################
 # look up the function and file/line number for a raw stack trace line
diff --git a/tools/apicheck/Android.mk b/tools/apicheck/Android.mk
index a2ff8a2..24f697c 100644
--- a/tools/apicheck/Android.mk
+++ b/tools/apicheck/Android.mk
@@ -29,16 +29,10 @@
 
 include $(BUILD_SYSTEM)/base_rules.mk
 
-$(LOCAL_BUILT_MODULE): $(HOST_OUT_JAVA_LIBRARIES)/apicheck$(COMMON_JAVA_PACKAGE_SUFFIX)
+$(LOCAL_BUILT_MODULE): $(HOST_OUT_JAVA_LIBRARIES)/doclava$(COMMON_JAVA_PACKAGE_SUFFIX)
 $(LOCAL_BUILT_MODULE): $(LOCAL_PATH)/etc/apicheck | $(ACP)
 	@echo "Copy: $(PRIVATE_MODULE) ($@)"
 	$(copy-file-to-new-target)
 	$(hide) chmod 755 $@
 
-# the other stuff
-# ============================================================
-subdirs := $(addprefix $(LOCAL_PATH)/,$(addsuffix /Android.mk, \
-		src \
-	))
-
-include $(subdirs)
+# Apicheck is now part of Doclava -- See external/doclava.
diff --git a/tools/apicheck/etc/apicheck b/tools/apicheck/etc/apicheck
index 5d0480c..c710c46 100644
--- a/tools/apicheck/etc/apicheck
+++ b/tools/apicheck/etc/apicheck
@@ -16,6 +16,10 @@
 
 # Set up prog to be the path of this script, including following symlinks,
 # and set up progdir to be the fully-qualified pathname of its directory.
+#
+# The classpath and other java options used in apicheck are specified in
+# build/core/tasks/apicheck.mk.
+
 prog="$0"
 while [ -h "${prog}" ]; do
     newProg=`/bin/ls -ld "${prog}"`
@@ -34,8 +38,6 @@
 prog="${progdir}"/`basename "${prog}"`
 cd "${oldwd}"
 
-libdir=`dirname $progdir`/framework
-
 javaOpts=""
 while expr "x$1" : 'x-J' >/dev/null; do
     opt=`expr "x$1" : 'x-J\(.*\)'`
@@ -43,4 +45,4 @@
     shift
 done
 
-exec java $javaOpts -jar $libdir/apicheck.jar "$@"
+exec java $javaOpts com.google.doclava.apicheck.ApiCheck "$@"
diff --git a/tools/apicheck/src/MANIFEST.mf b/tools/apicheck/src/MANIFEST.mf
deleted file mode 100644
index e6dc263..0000000
--- a/tools/apicheck/src/MANIFEST.mf
+++ /dev/null
@@ -1,2 +0,0 @@
-Manifest-Version: 1.0
-Main-Class: com.android.apicheck.ApiCheck
diff --git a/tools/apicheck/src/com/android/apicheck/AbstractMethodInfo.java b/tools/apicheck/src/com/android/apicheck/AbstractMethodInfo.java
deleted file mode 100644
index ca90820..0000000
--- a/tools/apicheck/src/com/android/apicheck/AbstractMethodInfo.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-package com.android.apicheck;
-
-public interface AbstractMethodInfo {
-  
-    public void addException(String exec);
-    public void addParameter(ParameterInfo p);
-
-}
diff --git a/tools/apicheck/src/com/android/apicheck/ApiCheck.java b/tools/apicheck/src/com/android/apicheck/ApiCheck.java
deleted file mode 100644
index c8272dd..0000000
--- a/tools/apicheck/src/com/android/apicheck/ApiCheck.java
+++ /dev/null
@@ -1,241 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-package com.android.apicheck;
-
-import org.xml.sax.*;
-import org.xml.sax.helpers.*;
-import java.io.*;
-import java.util.ArrayList;
-import java.util.Stack;
-
-public class ApiCheck {
-        // parse out and consume the -whatever command line flags
-        private static ArrayList<String[]> parseFlags(ArrayList<String> allArgs) {
-            ArrayList<String[]> ret = new ArrayList<String[]>();
-
-            int i;
-            for (i = 0; i < allArgs.size(); i++) {
-                // flags with one value attached
-                String flag = allArgs.get(i);
-                if (flag.equals("-error")
-                        || flag.equals("-warning")
-                        || flag.equals("-hide")) {
-                    String[] arg = new String[2];
-                    arg[0] = flag;
-                    arg[1] = allArgs.get(++i);
-                    ret.add(arg);
-                } else {
-                    // we've consumed all of the -whatever args, so we're done
-                    break;
-                }
-            }
-
-            // i now points to the first non-flag arg; strip what came before
-            for (; i > 0; i--) {
-                allArgs.remove(0);
-            }
-            return ret;
-        }
-
-        public static void main(String[] originalArgs) {
-            // translate to an ArrayList<String> for munging
-            ArrayList<String> args = new ArrayList<String>(originalArgs.length);
-            for (String a: originalArgs) {
-                args.add(a);
-            }
-
-            ArrayList<String[]> flags = ApiCheck.parseFlags(args);
-            for (String[] a: flags) {
-                if (a[0].equals("-error") || a[0].equals("-warning")
-                        || a[0].equals("-hide")) {
-                    try {
-                        int level = -1;
-                        if (a[0].equals("-error")) {
-                            level = Errors.ERROR;
-                        }
-                        else if (a[0].equals("-warning")) {
-                            level = Errors.WARNING;
-                        }
-                        else if (a[0].equals("-hide")) {
-                            level = Errors.HIDDEN;
-                        }
-                        Errors.setErrorLevel(Integer.parseInt(a[1]), level);
-                    }
-                    catch (NumberFormatException e) {
-                        System.err.println("Bad argument: " + a[0] + " " + a[1]);
-                        System.exit(2);
-                    }
-                }
-            }
-
-            ApiCheck acheck = new ApiCheck();
-
-            ApiInfo oldApi = acheck.parseApi(args.get(0));
-            ApiInfo newApi = acheck.parseApi(args.get(1));
-
-            // only run the consistency check if we haven't had XML parse errors
-            if (!Errors.hadError) {
-                oldApi.isConsistent(newApi);
-            }
-
-            Errors.printErrors();
-            System.exit(Errors.hadError ? 1 : 0);
-        }
-
-    public ApiInfo parseApi(String xmlFile) {
-        FileReader fileReader = null;
-        try {
-            XMLReader xmlreader = XMLReaderFactory.createXMLReader();
-            MakeHandler handler = new MakeHandler();
-            xmlreader.setContentHandler(handler);
-            xmlreader.setErrorHandler(handler);
-            fileReader = new FileReader(xmlFile);
-            xmlreader.parse(new InputSource(fileReader));
-            ApiInfo apiInfo = handler.getApi();
-            apiInfo.resolveSuperclasses();
-            return apiInfo;
-        } catch (SAXParseException e) {
-            Errors.error(Errors.PARSE_ERROR,
-                    new SourcePositionInfo(xmlFile, e.getLineNumber(), 0),
-                    e.getMessage());
-        } catch (Exception e) {
-            e.printStackTrace();
-            Errors.error(Errors.PARSE_ERROR,
-                    new SourcePositionInfo(xmlFile, 0, 0), e.getMessage());
-        } finally {
-            if (fileReader != null) {
-                try {
-                    fileReader.close();
-                } catch (IOException ignored) {}
-            }
-        }
-        return null;
-    }
-
-    private static class MakeHandler extends DefaultHandler {
-
-            private ApiInfo mApi;
-            private PackageInfo mCurrentPackage;
-            private ClassInfo mCurrentClass;
-            private AbstractMethodInfo mCurrentMethod;
-            private Stack<ClassInfo> mClassScope = new Stack<ClassInfo>();
-
-
-            public MakeHandler() {
-                super();
-                mApi = new ApiInfo();
-            }
-
-            @Override
-            public void startElement(String uri, String localName, String qName,
-                                     Attributes attributes) {
-                if (qName.equals("package")) {
-                    mCurrentPackage = new PackageInfo(attributes.getValue("name"),
-                            SourcePositionInfo.fromXml(attributes.getValue("source")));
-                } else if (qName.equals("class")
-                        || qName.equals("interface")) {
-                    // push the old outer scope for later recovery, then set
-                    // up the new current class object
-                    mClassScope.push(mCurrentClass);
-                    mCurrentClass = new ClassInfo(attributes.getValue("name"),
-                                                  mCurrentPackage,
-                                                  attributes.getValue("extends") ,
-                                                  qName.equals("interface"),
-                                                  Boolean.valueOf(
-                                                      attributes.getValue("abstract")),
-                                                  Boolean.valueOf(
-                                                      attributes.getValue("static")),
-                                                  Boolean.valueOf(
-                                                      attributes.getValue("final")),
-                                                  attributes.getValue("deprecated"),
-                                                  attributes.getValue("visibility"),
-                                                  SourcePositionInfo.fromXml(attributes.getValue("source")),
-                                                  mCurrentClass);
-                } else if (qName.equals("method")) {
-                    mCurrentMethod = new MethodInfo(attributes.getValue("name"),
-                                                    attributes.getValue("return") ,
-                                                    Boolean.valueOf(
-                                                        attributes.getValue("abstract")),
-                                                    Boolean.valueOf(
-                                                        attributes.getValue("native")),
-                                                    Boolean.valueOf(
-                                                        attributes.getValue("synchronized")),
-                                                    Boolean.valueOf(
-                                                        attributes.getValue("static")),
-                                                    Boolean.valueOf(
-                                                        attributes.getValue("final")),
-                                                    attributes.getValue("deprecated"),
-                                                    attributes.getValue("visibility"),
-                                                    SourcePositionInfo.fromXml(attributes.getValue("source")),
-                                                    mCurrentClass);
-                } else if (qName.equals("constructor")) {
-                    mCurrentMethod = new ConstructorInfo(attributes.getValue("name"),
-                                                         attributes.getValue("type") ,
-                                                         Boolean.valueOf(
-                                                             attributes.getValue("static")),
-                                                         Boolean.valueOf(
-                                                             attributes.getValue("final")),
-                                                         attributes.getValue("deprecated"),
-                                                         attributes.getValue("visibility"),
-                                                         SourcePositionInfo.fromXml(attributes.getValue("source")),
-                                                         mCurrentClass);
-                } else if (qName.equals("field")) {
-                    FieldInfo fInfo = new FieldInfo(attributes.getValue("name"),
-                                                    attributes.getValue("type") ,
-                                                    Boolean.valueOf(
-                                                        attributes.getValue("transient")),
-                                                    Boolean.valueOf(
-                                                        attributes.getValue("volatile")),
-                                                    attributes.getValue("value"),
-                                                    Boolean.valueOf(
-                                                        attributes.getValue("static")),
-                                                    Boolean.valueOf(
-                                                        attributes.getValue("final")),
-                                                    attributes.getValue("deprecated"),
-                                                    attributes.getValue("visibility"),
-                                                    SourcePositionInfo.fromXml(attributes.getValue("source")),
-                                                    mCurrentClass);
-                    mCurrentClass.addField(fInfo);
-                } else if (qName.equals("parameter")) {
-                    mCurrentMethod.addParameter(new ParameterInfo(attributes.getValue("type"),
-                                                                  attributes.getValue("name")));
-                } else if (qName.equals("exception")) {
-                    mCurrentMethod.addException(attributes.getValue("type"));
-                } else if (qName.equals("implements")) {
-                    mCurrentClass.addInterface(attributes.getValue("name"));
-                }
-            }
-
-            @Override
-            public void endElement(String uri, String localName, String qName) {
-                if (qName.equals("method")) {
-                    mCurrentClass.addMethod((MethodInfo) mCurrentMethod);
-                } else if (qName.equals("constructor")) {
-                    mCurrentClass.addConstructor((ConstructorInfo) mCurrentMethod);
-                } else if (qName.equals("class")
-                        || qName.equals("interface")) {
-                    mCurrentPackage.addClass(mCurrentClass);
-                    mCurrentClass = mClassScope.pop();
-                } else if (qName.equals("package")){
-                    mApi.addPackage(mCurrentPackage);
-                }
-            }
-            public ApiInfo getApi() {
-                return mApi;
-            }
-        }
-}
diff --git a/tools/apicheck/src/com/android/apicheck/ApiInfo.java b/tools/apicheck/src/com/android/apicheck/ApiInfo.java
deleted file mode 100644
index c237814..0000000
--- a/tools/apicheck/src/com/android/apicheck/ApiInfo.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-package com.android.apicheck;
-import java.util.*;
-
-public class ApiInfo {
-  
-    private HashMap<String, PackageInfo> mPackages;
-    private HashMap<String, ClassInfo> mAllClasses;
-    
-    public ApiInfo() {
-        mPackages = new HashMap<String, PackageInfo>();
-        mAllClasses = new HashMap<String, ClassInfo>();
-    }
-
-    public ClassInfo findClass(String name) {
-        return mAllClasses.get(name);
-    }
-
-    private void resolveInterfaces() {
-        for (ClassInfo c : mAllClasses.values()) {
-            c.resolveInterfaces(this);
-        }
-    }
-    
-    public boolean isConsistent(ApiInfo otherApi) {
-        resolveInterfaces();
-        boolean consistent = true;
-        for (PackageInfo pInfo : mPackages.values()) {
-            if (otherApi.getPackages().containsKey(pInfo.name())) {
-                if (!pInfo.isConsistent(otherApi.getPackages().get(pInfo.name()))) {
-                    consistent = false;
-                }
-            } else {
-                Errors.error(Errors.REMOVED_PACKAGE, pInfo.position(),
-                        "Removed package " + pInfo.name());
-                consistent = false;
-            }
-        }
-        for (PackageInfo pInfo : otherApi.mPackages.values()) {
-            if (!pInfo.isInBoth()) {
-                Errors.error(Errors.ADDED_PACKAGE, pInfo.position(),
-                        "Added package " + pInfo.name());
-                consistent = false;
-            }
-        }
-        return consistent;
-    }
-    
-    public HashMap<String, PackageInfo> getPackages() {
-        return mPackages;
-    }
-    
-    public void addPackage(PackageInfo pInfo) {
-        // track the set of organized packages in the API
-        mPackages.put(pInfo.name(), pInfo);
-        
-        // accumulate a direct map of all the classes in the API
-        for (ClassInfo cl: pInfo.allClasses().values()) {
-            mAllClasses.put(cl.qualifiedName(), cl);
-        }
-    }
-
-    public void resolveSuperclasses() {
-        for (ClassInfo cl: mAllClasses.values()) {
-            // java.lang.Object has no superclass
-            if (!cl.qualifiedName().equals("java.lang.Object")) {
-                String scName = cl.superclassName();
-                if (scName == null) {
-                    scName = "java.lang.Object";
-                }
-
-                ClassInfo superclass = mAllClasses.get(scName);
-                cl.setSuperClass(superclass);
-            }
-        }
-    }
-}
diff --git a/tools/apicheck/src/com/android/apicheck/ClassInfo.java b/tools/apicheck/src/com/android/apicheck/ClassInfo.java
deleted file mode 100644
index e62a3d0..0000000
--- a/tools/apicheck/src/com/android/apicheck/ClassInfo.java
+++ /dev/null
@@ -1,331 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-package com.android.apicheck;
-import java.util.*;
-
-public class ClassInfo {
-    private String mName;
-    private String mSuperClassName;
-    private boolean mIsInterface;
-    private boolean mIsAbstract;
-    private boolean mIsStatic;
-    private boolean mIsFinal;
-    private String mDeprecated;
-    private String mScope;
-    private List<String> mInterfaceNames;
-    private List<ClassInfo> mInterfaces;
-    private HashMap<String, MethodInfo> mMethods;
-    private HashMap<String, FieldInfo> mFields;
-    private HashMap<String, ConstructorInfo> mConstructors;
-    private boolean mExistsInBoth;
-    private PackageInfo mPackage;
-    private SourcePositionInfo mSourcePosition;
-    private ClassInfo mSuperClass;
-    private ClassInfo mParentClass;
-
-    public ClassInfo(String name, PackageInfo pack, String superClass, boolean isInterface,
-                     boolean isAbstract, boolean isStatic, boolean isFinal, String deprecated,
-                     String visibility, SourcePositionInfo source, ClassInfo parent) {
-        mName = name;
-        mPackage = pack;
-        mSuperClassName = superClass;
-        mIsInterface = isInterface;
-        mIsAbstract = isAbstract;
-        mIsStatic = isStatic;
-        mIsFinal = isFinal;
-        mDeprecated = deprecated;
-        mScope = visibility;
-        mInterfaceNames = new ArrayList<String>();
-        mInterfaces = new ArrayList<ClassInfo>();
-        mMethods = new HashMap<String, MethodInfo>();
-        mFields = new HashMap<String, FieldInfo>();
-        mConstructors = new HashMap<String, ConstructorInfo>();
-        mExistsInBoth = false;
-        mSourcePosition = source;
-        mParentClass = parent;
-    }
-
-    public String name() {
-        return mName;
-    }
-
-    public String qualifiedName() {
-        String parentQName = (mParentClass != null)
-                ? (mParentClass.qualifiedName() + ".")
-                : "";
-        return mPackage.name() + "." + parentQName + name();
-    }
-
-    public String superclassName() {
-        return mSuperClassName;
-    }
-    
-    public SourcePositionInfo position() {
-        return mSourcePosition;
-    }
-
-    public boolean isInterface() {
-        return mIsInterface;
-    }
-
-    public boolean isFinal() {
-        return mIsFinal;
-    }
-    
-    // Find a superclass implementation of the given method.  Looking at our superclass
-    // instead of at 'this' is unusual, but it fits the point-of-call demands well.
-    public MethodInfo overriddenMethod(MethodInfo candidate) {
-        if (mSuperClass == null) {
-            return null;
-        }
-        
-        // does our immediate superclass have it?
-        ClassInfo sup = mSuperClass;
-        for (MethodInfo mi : sup.mMethods.values()) {
-            if (mi.matches(candidate)) {
-                // found it
-                return mi;
-            }
-        }
-
-        // no, so recurse
-        if (sup.mSuperClass != null) {
-            return mSuperClass.overriddenMethod(candidate);
-        }
-        
-        // no parent, so we just don't have it
-        return null;
-    }
-    
-    // Find a superinterface declaration of the given method.
-    public MethodInfo interfaceMethod(MethodInfo candidate) {
-        for (ClassInfo interfaceInfo : mInterfaces) {
-            for (MethodInfo mi : interfaceInfo.mMethods.values()) {
-                if (mi.matches(candidate)) {
-                    return mi;
-                }
-            }
-        }
-        return (mSuperClass != null) ? mSuperClass.interfaceMethod(candidate) : null;
-    }
-
-    public boolean isConsistent(ClassInfo cl) {
-        cl.mExistsInBoth = true;
-        mExistsInBoth = true;
-        boolean consistent = true;
-
-        if (isInterface() != cl.isInterface()) {
-            Errors.error(Errors.CHANGED_CLASS, cl.position(),
-                    "Class " + cl.qualifiedName()
-                    + " changed class/interface declaration");
-            consistent = false;
-        }
-        for (String iface : mInterfaceNames) {
-            boolean found = false;
-            for (ClassInfo c = cl; c != null && !found; c = c.mSuperClass) {
-                found = c.mInterfaceNames.contains(iface);
-            }
-            if (!found) {
-                Errors.error(Errors.REMOVED_INTERFACE, cl.position(),
-                        "Class " + qualifiedName() + " no longer implements " + iface);
-            }
-        }
-        for (String iface : cl.mInterfaceNames) {
-          if (!mInterfaceNames.contains(iface)) {
-              Errors.error(Errors.ADDED_INTERFACE, cl.position(),
-                      "Added interface " + iface + " to class "
-                      + qualifiedName());
-              consistent = false;
-            }
-        }
-        
-        for (MethodInfo mInfo : mMethods.values()) {
-            if (cl.mMethods.containsKey(mInfo.getHashableName())) {
-                if (!mInfo.isConsistent(cl.mMethods.get(mInfo.getHashableName()))) {
-                    consistent = false;
-                }
-            } else {
-                /* This class formerly provided this method directly, and now does not.
-                 * Check our ancestry to see if there's an inherited version that still
-                 * fulfills the API requirement.
-                 */
-                MethodInfo mi = mInfo.containingClass().overriddenMethod(mInfo);
-                if (mi == null) {
-                    mi = mInfo.containingClass().interfaceMethod(mInfo);
-                }
-                if (mi == null) {
-                    Errors.error(Errors.REMOVED_METHOD, mInfo.position(),
-                            "Removed public method " + mInfo.qualifiedName());
-                    consistent = false;
-                }
-            }
-        }
-        for (MethodInfo mInfo : cl.mMethods.values()) {
-            if (!mInfo.isInBoth()) {
-                /* Similarly to the above, do not fail if this "new" method is
-                 * really an override of an existing superclass method.
-                 */
-                MethodInfo mi = mInfo.containingClass().overriddenMethod(mInfo);
-                if (mi == null) {
-                    Errors.error(Errors.ADDED_METHOD, mInfo.position(),
-                            "Added public method " + mInfo.qualifiedName());
-                    consistent = false;
-                }
-            }
-        }
-        
-        for (ConstructorInfo mInfo : mConstructors.values()) {
-          if (cl.mConstructors.containsKey(mInfo.getHashableName())) {
-              if (!mInfo.isConsistent(cl.mConstructors.get(mInfo.getHashableName()))) {
-                  consistent = false;
-              }
-          } else {
-              Errors.error(Errors.REMOVED_METHOD, mInfo.position(),
-                      "Removed public constructor " + mInfo.prettySignature());
-              consistent = false;
-          }
-        }
-        for (ConstructorInfo mInfo : cl.mConstructors.values()) {
-            if (!mInfo.isInBoth()) {
-                Errors.error(Errors.ADDED_METHOD, mInfo.position(),
-                        "Added public constructor " + mInfo.prettySignature());
-                consistent = false;
-            }
-        }
-        
-        for (FieldInfo mInfo : mFields.values()) {
-          if (cl.mFields.containsKey(mInfo.name())) {
-              if (!mInfo.isConsistent(cl.mFields.get(mInfo.name()))) {
-                  consistent = false;
-              }
-          } else {
-              Errors.error(Errors.REMOVED_FIELD, mInfo.position(),
-                      "Removed field " + mInfo.qualifiedName());
-              consistent = false;
-          }
-        }
-        for (FieldInfo mInfo : cl.mFields.values()) {
-            if (!mInfo.isInBoth()) {
-                Errors.error(Errors.ADDED_FIELD, mInfo.position(),
-                        "Added public field " + mInfo.qualifiedName());
-                consistent = false;
-            }
-        }
-        
-        if (mIsAbstract != cl.mIsAbstract) {
-            consistent = false;
-            Errors.error(Errors.CHANGED_ABSTRACT, cl.position(),
-                    "Class " + cl.qualifiedName() + " changed abstract qualifier");
-        }
-      
-        if (mIsFinal != cl.mIsFinal) {
-            consistent = false;
-            Errors.error(Errors.CHANGED_FINAL, cl.position(),
-                    "Class " + cl.qualifiedName() + " changed final qualifier");
-        }
-      
-        if (mIsStatic != cl.mIsStatic) {
-            consistent = false;
-            Errors.error(Errors.CHANGED_STATIC, cl.position(),
-                    "Class " + cl.qualifiedName() + " changed static qualifier");
-        }
-     
-        if (!mScope.equals(cl.mScope)) {
-            consistent = false;
-            Errors.error(Errors.CHANGED_SCOPE, cl.position(),
-                    "Class " + cl.qualifiedName() + " scope changed from "
-                    + mScope + " to " + cl.mScope);
-        }
-        
-        if (!mDeprecated.equals(cl.mDeprecated)) {
-            consistent = false;
-            Errors.error(Errors.CHANGED_DEPRECATED, cl.position(),
-                    "Class " + cl.qualifiedName() + " has changed deprecation state");
-        }
-        
-        if (mSuperClassName != null) {
-            if (cl.mSuperClassName == null || !mSuperClassName.equals(cl.mSuperClassName)) {
-                consistent = false;
-                Errors.error(Errors.CHANGED_SUPERCLASS, cl.position(),
-                        "Class " + qualifiedName() + " superclass changed from "
-                        + mSuperClassName + " to " + cl.mSuperClassName);
-            }
-        } else if (cl.mSuperClassName != null) {
-            consistent = false;
-            Errors.error(Errors.CHANGED_SUPERCLASS, cl.position(),
-                    "Class " + qualifiedName() + " superclass changed from "
-                    + "null to " + cl.mSuperClassName);
-        }
-        
-        return consistent;
-    }
-
-    public void resolveInterfaces(ApiInfo apiInfo) {
-        for (String interfaceName : mInterfaceNames) {
-            mInterfaces.add(apiInfo.findClass(interfaceName));
-        }
-    }
-    
-    public void addInterface(String name) {
-        mInterfaceNames.add(name);
-    }
-    
-    public void addMethod(MethodInfo mInfo) {
-        mMethods.put(mInfo.getHashableName(), mInfo);
-    }
-    
-    public void addConstructor(ConstructorInfo cInfo) {
-        mConstructors.put(cInfo.getHashableName(), cInfo);
-        
-    }
-    
-    public void addField(FieldInfo fInfo) {
-        mFields.put(fInfo.name(), fInfo);
-      
-    }
-    
-    public void setSuperClass(ClassInfo superclass) {
-        mSuperClass = superclass;
-    }
-    
-    public boolean isInBoth() {
-        return mExistsInBoth;
-    }
-
-    public Map<String, ConstructorInfo> allConstructors() {
-        return mConstructors;
-    }
-
-    public Map<String, FieldInfo> allFields() {
-        return mFields;
-    }
-
-    public Map<String, MethodInfo> allMethods() {
-        return mMethods;
-    }
-
-    /**
-     * Returns the class hierarchy for this class, starting with this class.
-     */
-    public Iterable<ClassInfo> hierarchy() {
-        List<ClassInfo> result = new ArrayList<ClassInfo>(4);
-        for (ClassInfo c  = this; c != null; c = c.mSuperClass) {
-            result.add(c);
-        }
-        return result;
-    }
-}
diff --git a/tools/apicheck/src/com/android/apicheck/ConstructorInfo.java b/tools/apicheck/src/com/android/apicheck/ConstructorInfo.java
deleted file mode 100644
index f36c7cd..0000000
--- a/tools/apicheck/src/com/android/apicheck/ConstructorInfo.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-package com.android.apicheck;
-import java.util.*;
-
-public class ConstructorInfo implements AbstractMethodInfo {
-    
-    private String mName;
-    private String mType;
-    private boolean mIsStatic;
-    private boolean mIsFinal;
-    private String mDeprecated;
-    private String mScope;
-    private List<String> mExceptions;
-    private List<ParameterInfo> mParameters;
-    private boolean mExistsInBoth;
-    private SourcePositionInfo mSourcePosition;
-    private ClassInfo mClass;
-    
-    public ConstructorInfo(String name, String type, boolean isStatic, boolean isFinal,
-                           String deprecated, String scope, SourcePositionInfo pos, ClassInfo clazz) {
-        mName = name;
-        mType = type;
-        mIsStatic = isStatic;
-        mIsFinal = isFinal;
-        mDeprecated= deprecated;
-        mScope = scope;
-        mExistsInBoth = false;
-        mExceptions = new ArrayList<String>();
-        mParameters = new ArrayList<ParameterInfo>();
-        mSourcePosition = pos;
-        mClass = clazz;
-    }
-    
-    public void addParameter(ParameterInfo pInfo) {
-        mParameters.add(pInfo);
-    }
-    
-    public void addException(String exec) {
-        mExceptions.add(exec);
-    }
-    
-    public String getHashableName() {
-      StringBuilder result = new StringBuilder();
-      result.append(name());
-      for (ParameterInfo pInfo : mParameters) {
-          result.append(":").append(pInfo.getType());
-      }
-      return result.toString();
-    }
-    
-    public boolean isInBoth() {
-        return mExistsInBoth;
-    }
-    
-    public SourcePositionInfo position() {
-        return mSourcePosition;
-    }
-    
-    public String name() {
-        return mName;
-    }
-    
-    public String qualifiedName() {
-        String baseName = (mClass != null)
-                ? (mClass.qualifiedName() + ".")
-                : "";
-        return baseName + name();
-    }
-    
-    public String prettySignature() {
-        String params = "";
-        for (ParameterInfo pInfo : mParameters) {
-            if (params.length() > 0) {
-                params += ", ";
-            }
-            params += pInfo.getType();
-        }
-        return qualifiedName() + '(' + params + ')';
-    }
-    
-    public boolean isConsistent(ConstructorInfo mInfo) {
-      mInfo.mExistsInBoth = true;
-      mExistsInBoth = true;
-      boolean consistent = true;
-      
-      if (mIsFinal != mInfo.mIsFinal) {
-          consistent = false;
-          Errors.error(Errors.CHANGED_FINAL, mInfo.position(),
-                  "Constructor " + mInfo.qualifiedName() + " has changed 'final' qualifier");
-      }
-      
-      if (mIsStatic != mInfo.mIsStatic) {
-          consistent = false;
-          Errors.error(Errors.CHANGED_FINAL, mInfo.position(),
-                  "Constructor " + mInfo.qualifiedName() + " has changed 'static' qualifier");
-      }
-     
-      if (!mScope.equals(mInfo.mScope)) {
-          consistent = false;
-          Errors.error(Errors.CHANGED_SCOPE, mInfo.position(),
-                  "Constructor " + mInfo.qualifiedName() + " changed scope from "
-                  + mScope + " to " + mInfo.mScope);
-      }
-      
-      if (!mDeprecated.equals(mInfo.mDeprecated)) {
-          consistent = false;
-          Errors.error(Errors.CHANGED_DEPRECATED, mInfo.position(),
-                  "Constructor " + mInfo.qualifiedName() + " has changed deprecation state");
-      }
-      
-      for (String exec : mExceptions) {
-          if (!mInfo.mExceptions.contains(exec)) {
-              Errors.error(Errors.CHANGED_THROWS, mInfo.position(),
-                      "Constructor " + mInfo.qualifiedName() + " no longer throws exception "
-                      + exec);
-              consistent = false;
-          }
-      }
-      
-      for (String exec : mInfo.mExceptions) {
-          if (!mExceptions.contains(exec)) {
-              Errors.error(Errors.CHANGED_THROWS, mInfo.position(),
-                      "Constructor " + mInfo.qualifiedName() + " added thrown exception "
-                      + exec);
-            consistent = false;
-          }
-      }
-      
-      return consistent;
-  }
-    
-
-}
diff --git a/tools/apicheck/src/com/android/apicheck/Errors.java b/tools/apicheck/src/com/android/apicheck/Errors.java
deleted file mode 100644
index b0b620e..0000000
--- a/tools/apicheck/src/com/android/apicheck/Errors.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-package com.android.apicheck;
-
-import java.lang.Comparable;
-import java.util.TreeSet;
-
-public class Errors
-{
-    public static boolean hadError = false;
-    private static boolean warningsAreErrors = false;
-    private static TreeSet<Message> allErrors = new TreeSet<Message>();
-
-    private static class Message implements Comparable {
-        SourcePositionInfo pos;
-        String msg;
-
-        Message(SourcePositionInfo p, String m) {
-            pos = p;
-            msg = m;
-        }
-
-        public int compareTo(Object o) {
-            Message that = (Message)o;
-            int r = this.pos.compareTo(that.pos);
-            if (r != 0) return r;
-            return this.msg.compareTo(that.msg);
-        }
-
-        @Override
-        public String toString() {
-            return this.pos.toString() + this.msg;
-        }
-    }
-
-    public static void error(Error error, SourcePositionInfo where, String text) {
-        if (error.level == HIDDEN) {
-            return;
-        }
-
-        String which = (!warningsAreErrors && error.level == WARNING) ? " warning " : " error ";
-        String message = which + error.code + ": " + text;
-
-        if (where == null) {
-            where = new SourcePositionInfo("unknown", 0, 0);
-        }
-
-        allErrors.add(new Message(where, message));
-
-        if (error.level == ERROR || (warningsAreErrors && error.level == WARNING)) {
-            hadError = true;
-        }
-    }
-
-    public static void printErrors() {
-        for (Message m: allErrors) {
-            System.err.println(m.toString());
-        }
-    }
-
-    public static int HIDDEN = 0;
-    public static int WARNING = 1;
-    public static int ERROR = 2;
-
-    public static void setWarningsAreErrors(boolean val) {
-        warningsAreErrors = val;
-    }
-
-    public static class Error {
-        public int code;
-        public int level;
-
-        public Error(int code, int level)
-        {
-            this.code = code;
-            this.level = level;
-        }
-    }
-
-    public static Error PARSE_ERROR = new Error(1, ERROR);
-    public static Error ADDED_PACKAGE = new Error(2, WARNING);
-    public static Error ADDED_CLASS = new Error(3, WARNING);
-    public static Error ADDED_METHOD = new Error(4, WARNING);
-    public static Error ADDED_FIELD = new Error(5, WARNING);
-    public static Error ADDED_INTERFACE = new Error(6, WARNING);
-    public static Error REMOVED_PACKAGE = new Error(7, WARNING);
-    public static Error REMOVED_CLASS = new Error(8, WARNING);
-    public static Error REMOVED_METHOD = new Error(9, WARNING);
-    public static Error REMOVED_FIELD = new Error(10, WARNING);
-    public static Error REMOVED_INTERFACE = new Error(11, WARNING);
-    public static Error CHANGED_STATIC = new Error(12, WARNING);
-    public static Error CHANGED_FINAL = new Error(13, WARNING);
-    public static Error CHANGED_TRANSIENT = new Error(14, WARNING);
-    public static Error CHANGED_VOLATILE = new Error(15, WARNING);
-    public static Error CHANGED_TYPE = new Error(16, WARNING);
-    public static Error CHANGED_VALUE = new Error(17, WARNING);
-    public static Error CHANGED_SUPERCLASS = new Error(18, WARNING);
-    public static Error CHANGED_SCOPE = new Error(19, WARNING);
-    public static Error CHANGED_ABSTRACT = new Error(20, WARNING);
-    public static Error CHANGED_THROWS = new Error(21, WARNING);
-    public static Error CHANGED_NATIVE = new Error(22, HIDDEN);
-    public static Error CHANGED_CLASS = new Error(23, WARNING);
-    public static Error CHANGED_DEPRECATED = new Error(24, WARNING);
-    public static Error CHANGED_SYNCHRONIZED = new Error(25, ERROR);
-
-    public static Error[] ERRORS = {
-        PARSE_ERROR,
-        ADDED_PACKAGE,
-        ADDED_CLASS,
-        ADDED_METHOD,
-        ADDED_FIELD,
-        ADDED_INTERFACE,
-        REMOVED_PACKAGE,
-        REMOVED_CLASS,
-        REMOVED_METHOD,
-        REMOVED_FIELD,
-        REMOVED_INTERFACE,
-        CHANGED_STATIC,
-        CHANGED_FINAL,
-        CHANGED_TRANSIENT,
-        CHANGED_VOLATILE,
-        CHANGED_TYPE,
-        CHANGED_VALUE,
-        CHANGED_SUPERCLASS,
-        CHANGED_SCOPE,
-        CHANGED_ABSTRACT,
-        CHANGED_THROWS,
-        CHANGED_NATIVE,
-        CHANGED_CLASS,
-        CHANGED_DEPRECATED,
-        CHANGED_SYNCHRONIZED,
-        };
-
-    public static boolean setErrorLevel(int code, int level) {
-        for (Error e: ERRORS) {
-            if (e.code == code) {
-                e.level = level;
-                return true;
-            }
-        }
-        return false;
-    }
-}
diff --git a/tools/apicheck/src/com/android/apicheck/FieldInfo.java b/tools/apicheck/src/com/android/apicheck/FieldInfo.java
deleted file mode 100644
index d80d9f6..0000000
--- a/tools/apicheck/src/com/android/apicheck/FieldInfo.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-package com.android.apicheck;
-
-public class FieldInfo {
-  
-    private String mName;
-    private String mType;
-    private boolean mIsTransient;
-    private boolean mIsVolatile;
-    private String mValue;
-    private boolean mIsStatic;
-    private boolean mIsFinal;
-    private String mDeprecated;
-    private String mScope;
-    private boolean mExistsInBoth;
-    private SourcePositionInfo mSourcePosition;
-    private ClassInfo mClass;
-    
-    public FieldInfo (String name, String type, boolean isTransient, boolean isVolatile,
-                       String value, boolean isStatic, boolean isFinal, String deprecated,
-                       String scope, SourcePositionInfo source, ClassInfo parent) {
-        mName = name;
-        mType = type;
-        mIsTransient = isTransient;
-        mIsVolatile = isVolatile;
-        mValue = value;
-        mIsStatic = isStatic;
-        mIsFinal = isFinal;
-        mDeprecated = deprecated;
-        mScope = scope;
-        mExistsInBoth = false;
-        mSourcePosition = source;
-        mClass = parent;
-    }
-    
-    public boolean isInBoth() {
-        return mExistsInBoth;
-    }
-    public SourcePositionInfo position() {
-        return mSourcePosition;
-    }
-    
-    public String name() {
-        return mName;
-    }
-    
-    public String qualifiedName() {
-        String parentQName = (mClass != null)
-                ? (mClass.qualifiedName() + ".")
-                : "";
-        return parentQName + name();
-    }
-    
-    // Check the declared value with a typed comparison, not a string comparison,
-    // to accommodate toolchains with different fp -> string conversions.
-    public boolean valueEquals(FieldInfo other) {
-        // Type mismatch means nonequal, as does a null/non-null mismatch
-        if (!mType.equals(other.mType)
-                || ((mValue == null) != (other.mValue == null))) {
-            return false;
-        }
-
-        // Null values are considered equal
-        if (mValue == null) {
-            return true;
-        }
-
-        // Floating point gets an implementation-type comparison; all others just use the string
-        // If float/double parse fails, fall back to string comparison -- it means that it's a
-        // canonical droiddoc-generated constant expression that represents a NaN.
-        try {
-            if (mType.equals("float")) {
-                float val = Float.parseFloat(mValue);
-                float otherVal = Float.parseFloat(other.mValue);
-                return (val == otherVal);
-            } else if (mType.equals("double")) {
-                double val = Double.parseDouble(mValue);
-                double otherVal = Double.parseDouble(other.mValue);
-                return (val == otherVal);
-            }
-        } catch (NumberFormatException e) {
-            // fall through
-        }
-        
-        return mValue.equals(other.mValue);
-    }
-
-    public boolean isConsistent(FieldInfo fInfo) {
-      fInfo.mExistsInBoth = true;
-      mExistsInBoth = true;
-      boolean consistent = true;
-      if (!mType.equals(fInfo.mType)) {
-          Errors.error(Errors.CHANGED_TYPE, fInfo.position(),
-                  "Field " + fInfo.qualifiedName() + " has changed type");
-          consistent = false;
-      }
-
-      if (!this.valueEquals(fInfo)) {
-          Errors.error(Errors.CHANGED_VALUE, fInfo.position(),
-                  "Field " + fInfo.qualifiedName() + " has changed value from "
-                  + mValue + " to " + fInfo.mValue);
-          consistent = false;
-      }
-      
-      if (!mScope.equals(fInfo.mScope)) {
-          Errors.error(Errors.CHANGED_SCOPE, fInfo.position(),
-                  "Method " + fInfo.qualifiedName() + " changed scope from "
-                  + mScope + " to " + fInfo.mScope);
-          consistent = false;
-      }
-      
-      if (mIsStatic != fInfo.mIsStatic) {
-          Errors.error(Errors.CHANGED_STATIC, fInfo.position(),
-                  "Field " + fInfo.qualifiedName() + " has changed 'static' qualifier");
-          consistent = false;
-      }
-      
-      if (mIsFinal != fInfo.mIsFinal) {
-          Errors.error(Errors.CHANGED_FINAL, fInfo.position(),
-                  "Field " + fInfo.qualifiedName() + " has changed 'final' qualifier");
-          consistent = false;
-      }
-      
-      if (mIsTransient != fInfo.mIsTransient) {
-          Errors.error(Errors.CHANGED_TRANSIENT, fInfo.position(),
-                  "Field " + fInfo.qualifiedName() + " has changed 'transient' qualifier");
-          consistent = false;
-      }
-      
-      if (mIsVolatile != fInfo.mIsVolatile) {
-          Errors.error(Errors.CHANGED_VOLATILE, fInfo.position(),
-                  "Field " + fInfo.qualifiedName() + " has changed 'volatile' qualifier");
-          consistent = false;
-      }
-      
-      if (!mDeprecated.equals(fInfo.mDeprecated)) {
-          Errors.error(Errors.CHANGED_DEPRECATED, fInfo.position(),
-                  "Field " + fInfo.qualifiedName() + " has changed deprecation state");
-          consistent = false;
-      }
-      
-      return consistent;
-    }
-
-}
diff --git a/tools/apicheck/src/com/android/apicheck/MethodInfo.java b/tools/apicheck/src/com/android/apicheck/MethodInfo.java
deleted file mode 100644
index e4e4537..0000000
--- a/tools/apicheck/src/com/android/apicheck/MethodInfo.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-package com.android.apicheck;
-import java.util.*;
-
-public class MethodInfo implements AbstractMethodInfo {
-  
-    private String mName;
-    private String mReturn;
-    private boolean mIsAbstract;
-    private boolean mIsNative;
-    private boolean mIsSynchronized;
-    private boolean mIsStatic;
-    private boolean mIsFinal;
-    private String mDeprecated;
-    private String mScope;
-    private boolean mExistsInBoth;
-    private List<ParameterInfo> mParameters;
-    private List<String> mExceptions;
-    private SourcePositionInfo mSourcePosition;
-    private ClassInfo mClass;
-    
-    public MethodInfo (String name, String returnType, boolean isAbstract, boolean isNative,
-                        boolean isSynchronized, boolean isStatic, boolean isFinal, String deprecated
-                        , String scope, SourcePositionInfo source, ClassInfo parent) {
-        
-        mName = name;
-        mReturn = returnType;
-        mIsAbstract = isAbstract;
-        mIsNative = isNative;
-        mIsSynchronized = isSynchronized;
-        mIsStatic = isStatic;
-        mIsFinal = isFinal;
-        mDeprecated = deprecated;
-        mScope = scope;
-        mParameters = new ArrayList<ParameterInfo>();
-        mExceptions = new ArrayList<String>();
-        mExistsInBoth = false;
-        mSourcePosition = source;
-        mClass = parent;
-    }
-    
-    
-    public String name() {
-        return mName;
-    }
-    
-    public String qualifiedName() {
-        String parentQName = (mClass != null)
-                ? (mClass.qualifiedName() + ".")
-                : "";
-        return parentQName + name();
-    }
-    
-    public String prettySignature() {
-        String params = "";
-        for (ParameterInfo pInfo : mParameters) {
-            if (params.length() > 0) {
-                params += ", ";
-            }
-            params += pInfo.getType();
-        }
-        return qualifiedName() + '(' + params + ')';
-    }
-    
-    public SourcePositionInfo position() {
-        return mSourcePosition;
-    }
-    
-    public ClassInfo containingClass() {
-        return mClass;
-    }
-
-    public boolean matches(MethodInfo other) {
-        return getSignature().equals(other.getSignature());
-    }
-    
-    public boolean isConsistent(MethodInfo mInfo) {
-        mInfo.mExistsInBoth = true;
-        mExistsInBoth = true;
-        boolean consistent = true;
-        if (!mReturn.equals(mInfo.mReturn)) {
-            consistent = false;
-            Errors.error(Errors.CHANGED_TYPE, mInfo.position(),
-                    "Method " + mInfo.qualifiedName() + " has changed return type from "
-                    + mReturn + " to " + mInfo.mReturn);
-        }
-        
-        if (mIsAbstract != mInfo.mIsAbstract) {
-            consistent = false;
-            Errors.error(Errors.CHANGED_ABSTRACT, mInfo.position(),
-                    "Method " + mInfo.qualifiedName() + " has changed 'abstract' qualifier");
-        }
-        
-        if (mIsNative != mInfo.mIsNative) {
-            consistent = false;
-            Errors.error(Errors.CHANGED_NATIVE, mInfo.position(),
-                    "Method " + mInfo.qualifiedName() + " has changed 'native' qualifier");
-        }
-        
-        if (mIsFinal != mInfo.mIsFinal) {
-            // Compiler-generated methods vary in their 'final' qual between versions of
-            // the compiler, so this check needs to be quite narrow.  A change in 'final'
-            // status of a method is only relevant if (a) the method is not declared 'static'
-            // and (b) the method's class is not itself 'final'.
-            if (!mIsStatic) {
-                if ((mClass == null) || (!mClass.isFinal())) {
-                    consistent = false;
-                    Errors.error(Errors.CHANGED_FINAL, mInfo.position(),
-                            "Method " + mInfo.qualifiedName() + " has changed 'final' qualifier");
-                }
-            }
-        }
-        
-        if (mIsStatic != mInfo.mIsStatic) {
-            consistent = false;
-            Errors.error(Errors.CHANGED_STATIC, mInfo.position(),
-                    "Method " + mInfo.qualifiedName() + " has changed 'static' qualifier");
-        }
-       
-        if (!mScope.equals(mInfo.mScope)) {
-            consistent = false;
-            Errors.error(Errors.CHANGED_SCOPE, mInfo.position(),
-                    "Method " + mInfo.qualifiedName() + " changed scope from "
-                    + mScope + " to " + mInfo.mScope);
-        }
-        
-        if (!mDeprecated.equals(mInfo.mDeprecated)) {
-            Errors.error(Errors.CHANGED_DEPRECATED, mInfo.position(),
-                    "Method " + mInfo.qualifiedName() + " has changed deprecation state");
-            consistent = false;
-        }
-        
-        if (mIsSynchronized != mInfo.mIsSynchronized) {
-            Errors.error(Errors.CHANGED_SYNCHRONIZED, mInfo.position(),
-                    "Method " + mInfo.qualifiedName() + " has changed 'synchronized' qualifier from " + mIsSynchronized + " to " + mInfo.mIsSynchronized);
-            consistent = false;
-        }
-        
-        for (String exec : mExceptions) {
-            if (!mInfo.mExceptions.contains(exec)) {
-                // exclude 'throws' changes to finalize() overrides with no arguments
-                if (!name().equals("finalize") || (mParameters.size() > 0)) {
-                    Errors.error(Errors.CHANGED_THROWS, mInfo.position(),
-                            "Method " + mInfo.qualifiedName() + " no longer throws exception "
-                            + exec);
-                    consistent = false;
-                }
-            }
-        }
-        
-        for (String exec : mInfo.mExceptions) {
-            // exclude 'throws' changes to finalize() overrides with no arguments
-            if (!mExceptions.contains(exec)) {
-                if (!name().equals("finalize") || (mParameters.size() > 0)) {
-                    Errors.error(Errors.CHANGED_THROWS, mInfo.position(),
-                            "Method " + mInfo.qualifiedName() + " added thrown exception "
-                            + exec);
-                    consistent = false;
-                }
-            }
-        }
-        
-        return consistent;
-    }
-    
-    public void addParameter(ParameterInfo pInfo) {
-        mParameters.add(pInfo);
-    }
-    
-    public void addException(String exc) {
-        mExceptions.add(exc);
-    }
-    
-    public String getParameterHash() {
-        String hash = "";
-        for (ParameterInfo pInfo : mParameters) {
-            hash += ":" + pInfo.getType();
-        }
-        return hash;
-    }
-    
-    public String getHashableName() {
-        return name() + getParameterHash();
-    }
-    
-    public String getSignature() {
-        return name() + getParameterHash();
-    }
-    
-    public boolean isInBoth() {
-        return mExistsInBoth;
-    }
-
-}
diff --git a/tools/apicheck/src/com/android/apicheck/PackageInfo.java b/tools/apicheck/src/com/android/apicheck/PackageInfo.java
deleted file mode 100644
index 2262f21..0000000
--- a/tools/apicheck/src/com/android/apicheck/PackageInfo.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-package com.android.apicheck;
-import java.util.*;
-
-public class PackageInfo {
-    private String mName;
-    private HashMap<String, ClassInfo> mClasses;
-    private boolean mExistsInBoth;
-    private SourcePositionInfo mPosition;
-    
-    public PackageInfo(String name, SourcePositionInfo position) {
-        mName = name;
-        mClasses = new HashMap<String, ClassInfo>();
-        mExistsInBoth = false;
-        mPosition = position;
-    }
-    
-    public void addClass(ClassInfo cl) {
-        mClasses.put(cl.name() , cl);
-    }
-    
-    public HashMap<String, ClassInfo> allClasses() {
-        return mClasses;
-    }
-    
-    public String name() {
-        return mName;
-    }
-    
-    public SourcePositionInfo position() {
-        return mPosition;
-    }
-    
-    public boolean isConsistent(PackageInfo pInfo) {
-        mExistsInBoth = true;
-        pInfo.mExistsInBoth = true;
-        boolean consistent = true;
-        for (ClassInfo cInfo : mClasses.values()) {
-            if (pInfo.mClasses.containsKey(cInfo.name())) {
-                if (!cInfo.isConsistent(pInfo.mClasses.get(cInfo.name()))) {
-                    consistent = false;
-                }
-            } else {
-                Errors.error(Errors.REMOVED_CLASS, cInfo.position(),
-                        "Removed public class " + cInfo.qualifiedName());
-                consistent = false;
-            }
-        }
-        for (ClassInfo cInfo : pInfo.mClasses.values()) {
-            if (!cInfo.isInBoth()) {
-                Errors.error(Errors.ADDED_CLASS, cInfo.position(),
-                        "Added class " + cInfo.name() + " to package "
-                        + pInfo.name());
-                consistent = false;
-            }
-        }
-        return consistent;
-    }
-    
-    public boolean isInBoth() {
-        return mExistsInBoth;
-    }
-}
diff --git a/tools/apicheck/src/com/android/apicheck/ParameterInfo.java b/tools/apicheck/src/com/android/apicheck/ParameterInfo.java
deleted file mode 100644
index 5788814..0000000
--- a/tools/apicheck/src/com/android/apicheck/ParameterInfo.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-package com.android.apicheck;
-
-public class ParameterInfo {
-    private String mType;
-    private String mName;
-    
-    public ParameterInfo(String type, String name) {
-        mType = type;
-        mName = name;
-    }
-    
-    public String getType() {
-        return mType;
-    }
-    
-    public String getName() {
-        return mName;
-    }
-}
diff --git a/tools/apicheck/src/com/android/apicheck/SourcePositionInfo.java b/tools/apicheck/src/com/android/apicheck/SourcePositionInfo.java
deleted file mode 100644
index 276771b..0000000
--- a/tools/apicheck/src/com/android/apicheck/SourcePositionInfo.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-package com.android.apicheck;
-
-import java.lang.Comparable;
-
-public class SourcePositionInfo implements Comparable
-{
-    public SourcePositionInfo() {
-        this.file = "<unknown>";
-        this.line = 0;
-        this.column = 0;
-    }
-
-    public SourcePositionInfo(String file, int line, int column)
-    {
-        this.file = file;
-        this.line = line;
-        this.column = column;
-    }
-
-    public SourcePositionInfo(SourcePositionInfo that)
-    {
-        this.file = that.file;
-        this.line = that.line;
-        this.column = that.column;
-    }
-
-    /**
-     * Given this position and str which occurs at that position, as well as str an index into str,
-     * find the SourcePositionInfo.
-     *
-     * @throw StringIndexOutOfBoundsException if index &gt; str.length()
-     */
-    public static SourcePositionInfo add(SourcePositionInfo that, String str, int index)
-    {
-        if (that == null) {
-            return null;
-        }
-        int line = that.line;
-        char prev = 0;
-        for (int i=0; i<index; i++) {
-            char c = str.charAt(i);
-            if (c == '\r' || (c == '\n' && prev != '\r')) {
-                line++;
-            }
-            prev = c;
-        }
-        return new SourcePositionInfo(that.file, line, 0);
-    }
-
-    public static SourcePositionInfo findBeginning(SourcePositionInfo that, String str)
-    {
-        if (that == null) {
-            return null;
-        }
-        int line = that.line-1; // -1 because, well, it seems to work
-        int prev = 0;
-        for (int i=str.length()-1; i>=0; i--) {
-            char c = str.charAt(i);
-            if ((c == '\r' && prev != '\n') || (c == '\n')) {
-                line--;
-            }
-            prev = c;
-        }
-        return new SourcePositionInfo(that.file, line, 0);
-    }
-
-    @Override
-    public String toString()
-    {
-        if (this.file == null) {
-            return "(unknown)";
-        } else {
-            if (this.line == 0) {
-                return this.file + ':';
-            } else {
-                return this.file + ':' + this.line + ':';
-            }
-        }
-    }
-
-    public int compareTo(Object o) {
-        SourcePositionInfo that = (SourcePositionInfo)o;
-        int r = this.file.compareTo(that.file);
-        if (r != 0) return r;
-        return this.line - that.line;
-    }
-
-    /**
-     * Build a SourcePositionInfo from the XML source= notation
-     */
-    public static SourcePositionInfo fromXml(String source) {
-        if (source != null) {
-            for (int i = 0; i < source.length(); i++) {
-                if (source.charAt(i) == ':') {
-                    return new SourcePositionInfo(source.substring(0, i),
-                            Integer.parseInt(source.substring(i+1)), 0);
-                }
-            }
-        }
-
-        return new SourcePositionInfo("(unknown)", 0, 0);
-    }
-
-    public String file;
-    public int line;
-    public int column;
-}
diff --git a/tools/apriori/Android.mk b/tools/apriori/Android.mk
deleted file mode 100644
index 79ecf7f..0000000
--- a/tools/apriori/Android.mk
+++ /dev/null
@@ -1,61 +0,0 @@
-# Copyright 2005 The Android Open Source Project
-#
-# Android.mk for apriori
-#
-
-LOCAL_PATH:= $(call my-dir)
-
-ifneq ($(TARGET_SIMULATOR),true)
-include $(CLEAR_VARS)
-
-LOCAL_LDLIBS += -ldl
-LOCAL_CFLAGS += -O2 -g
-LOCAL_CFLAGS += -fno-function-sections -fno-data-sections -fno-inline
-LOCAL_CFLAGS += -Wall -Wno-unused-function #-Werror
-LOCAL_CFLAGS += -DSUPPORT_ANDROID_PRELINK_TAGS
-LOCAL_CFLAGS += -DDEBUG
-LOCAL_CFLAGS += -DADJUST_ELF=1
-
-ifeq ($(TARGET_ARCH),arm)
-LOCAL_CFLAGS += -DARM_SPECIFIC_HACKS
-LOCAL_CFLAGS += -DBIG_ENDIAN=1
-endif
-
-ifeq ($(HOST_OS),darwin)
-LOCAL_CFLAGS += -DFSCANF_IS_BROKEN
-endif
-ifeq ($(HOST_OS),windows)
-LOCAL_CFLAGS += -DFSCANF_IS_BROKEN
-LOCAL_LDLIBS += -lintl
-endif
-
-
-
-LOCAL_SRC_FILES := \
-	apriori.c \
-	cmdline.c \
-	debug.c \
-	hash.c \
-	main.c \
-	prelink_info.c \
-	rangesort.c \
-	source.c \
-	prelinkmap.c
-
-LOCAL_C_INCLUDES:= \
-	$(LOCAL_PATH)/ \
-	external/elfutils/lib/ \
-	external/elfutils/libelf/ \
-	external/elfutils/libebl/ \
-	external/elfcopy/
-
-LOCAL_STATIC_LIBRARIES := libelfcopy libelf libebl #dl
-
-ifeq ($(TARGET_ARCH),arm)
-LOCAL_STATIC_LIBRARIES += libebl_arm
-endif
-
-LOCAL_MODULE := apriori
-
-include $(BUILD_HOST_EXECUTABLE)
-endif # TARGET_SIMULATOR != true
diff --git a/tools/apriori/apriori.c b/tools/apriori/apriori.c
deleted file mode 100644
index d1807b3..0000000
--- a/tools/apriori/apriori.c
+++ /dev/null
@@ -1,2601 +0,0 @@
-#include <stdio.h>
-#include <common.h>
-#include <debug.h>
-#include <libelf.h>
-#include <libebl.h>
-#ifdef ARM_SPECIFIC_HACKS
-    #include <libebl_arm.h>
-#endif/*ARM_SPECIFIC_HACKS*/
-#include <elf.h>
-#include <gelf.h>
-#include <string.h>
-#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <hash.h>
-#include <apriori.h>
-#include <source.h>
-#include <tweak.h>
-#include <rangesort.h>
-#include <prelink_info.h>
-#include <prelinkmap.h>
-#include <libgen.h>
-
-#ifndef ADJUST_ELF
-#error "ADJUST_ELF must be defined!"
-#endif
-
-/* When this macro is defined, apriori sets to ZERO those relocation values for
-   which it canot find the appropriate referent.
-*/
-#define PERMISSIVE
-#define COPY_SECTION_DATA_BUFFER (0)
-/* When this macro is set to a nonzero value, we replace calls to elf_strptr()
-   on the target ELF handle with code that extracts the strings directly from
-   the data buffers of that ELF handle.  In this case, elf_strptr() does not
-   work as expected, as it tries to read the data buffer of the associated
-   string section directly from the file, and that buffer does not exist yet
-   in the file, since we haven't committed our changes yet.
-*/
-#define ELF_STRPTR_IS_BROKEN     (1)
-
-/* When the macro below is defined, apriori does not mark for removal those
-   relocation sections that it fully handles.  Instead, apriori just sets their
-   sizes to zero.  This is more for debugging than of any actual use.
-
-   This macro is meaningful only when ADJUST_ELF!=0
-*/
-#define REMOVE_HANDLED_SECTIONS
-
-extern int verbose_flag;
-
-static source_t *sources = NULL;
-
-#if defined(DEBUG) && 0
-
-static void print_shdr(source_t *source, Elf_Scn *scn)
-{
-    GElf_Shdr shdr_mem, *shdr;
-    shdr = gelf_getshdr(scn, &shdr_mem);
-    Elf_Data *data = elf_getdata(scn, NULL);
-    INFO("\t%02d: data = %p, hdr = { offset = %8lld, size = %lld }, "
-         "data->d_buf = %p data->d_off = %lld, data->d_size = %d\n",
-         elf_ndxscn(scn),
-         data,
-         shdr->sh_offset, shdr->sh_size,
-         data->d_buf, data->d_off, data->d_size);
-}
-
-static void print_shdr_idx(source_t *source, Elf *elf, int idx)
-{
-    print_shdr(source, elf_getscn(elf, idx));
-}
-
-static void print_shdrs(source_t *source) {
-  Elf_Scn *scn = NULL;
-  INFO("section offset dump for new ELF\n");
-  while ((scn = elf_nextscn (source->elf, scn)) != NULL)
-    print_shdr(source, scn);
-
-  INFO("\nsection offset dump for original ELF\n");
-  while ((scn = elf_nextscn (source->oldelf, scn)) != NULL)
-    print_shdr(source, scn);
-
-#if 0
-  {
-    INFO("section offset dump for new ELF\n");
-    int i = 0;
-    for (i = 0; i < source->shnum; i++) {
-      scn = elf_getscn(source->elf, i);
-      print_shdr(source, scn);
-    }
-  }
-#endif
-}
-
-#endif /* DEBUG */
-
-static char * find_file(const char *libname,
-                        char **lib_lookup_dirs,
-                        int num_lib_lookup_dirs);
-
-static inline source_t* find_source(const char *name,
-                                    char **lib_lookup_dirs,
-                                    int num_lib_lookup_dirs) {
-    char *full = find_file(name, lib_lookup_dirs, num_lib_lookup_dirs);
-    if (full) {
-        source_t *trav = sources;
-        while (trav) {
-            if (!strcmp(trav->name, full))
-                break;
-            trav = trav->next;
-        }
-        free(full);
-        return trav;
-    }
-    return NULL;
-}
-
-static inline void add_to_sources(source_t *src) {
-    src->next = sources;
-    sources = src;
-}
-
-static void handle_range_error(range_error_t err,
-                               range_t *left, range_t *right) {
-    switch (err) {
-    case ERROR_CONTAINS:
-        ERROR("ERROR: section (%lld, %lld bytes) contains "
-              "section (%lld, %lld bytes)\n",
-              left->start, left->length,
-              right->start, right->length);
-        break;
-    case ERROR_OVERLAPS:
-        ERROR("ERROR: Section (%lld, %lld bytes) intersects "
-              "section (%lld, %lld bytes)\n",
-              left->start, left->length,
-              right->start, right->length);
-        break;
-    default:
-        ASSERT(!"Unknown range error code!");
-    }
-
-    FAILIF(1, "Range error.\n");
-}
-
-static void create_elf_sections(source_t *source, Elf *elf)
-{
-    INFO("Creating new ELF sections.\n");
-    ASSERT(elf == NULL || source->elf == NULL || source->elf == elf);
-    if (elf == NULL) {
-        ASSERT(source->elf != NULL);
-        elf = source->elf;
-    }
-
-    int cnt = 1;
-    Elf_Scn *oldscn = NULL, *scn;
-    while ((oldscn = elf_nextscn (source->oldelf, oldscn)) != NULL) {
-        GElf_Shdr *oldshdr, oldshdr_mem;
-
-        scn = elf_newscn(elf);
-        FAILIF_LIBELF(NULL == scn, elf_newscn);
-
-        oldshdr = gelf_getshdr(oldscn, &oldshdr_mem);
-        FAILIF_LIBELF(NULL == oldshdr, gelf_getshdr);
-        /* Set the section header of the new section to be the same as the
-           headset of the old section by default. */
-        gelf_update_shdr(scn, oldshdr);
-
-        /* Copy the section data */
-        Elf_Data *olddata = elf_getdata(oldscn, NULL);
-        FAILIF_LIBELF(NULL == olddata, elf_getdata);
-
-        Elf_Data *data = elf_newdata(scn);
-        FAILIF_LIBELF(NULL == data, elf_newdata);
-        *data = *olddata;
-#if COPY_SECTION_DATA_BUFFER
-        if (olddata->d_buf != NULL) {
-            data->d_buf = MALLOC(data->d_size);
-            memcpy(data->d_buf, olddata->d_buf, olddata->d_size);
-        }
-#endif
-
-        INFO("\tsection %02d: [%-30s] created\n",
-             cnt,
-             elf_strptr(source->oldelf,
-                        source->shstrndx,
-                        oldshdr->sh_name));
-
-        if (ADJUST_ELF) {
-            ASSERT(source->shdr_info != NULL);
-            /* Create a new section. */
-            source->shdr_info[cnt].idx = cnt;
-            source->shdr_info[cnt].newscn = scn;
-            source->shdr_info[cnt].data = data;
-            source->shdr_info[cnt].
-                use_old_shdr_for_relocation_calculations = 1;
-            INFO("\tsection [%s]  (old offset %lld, old size %lld) "
-                 "will have index %d (was %d).\n",
-                 source->shdr_info[cnt].name,
-                 source->shdr_info[cnt].old_shdr.sh_offset,
-                 source->shdr_info[cnt].old_shdr.sh_size,
-                 source->shdr_info[cnt].idx,
-                 elf_ndxscn(source->shdr_info[cnt].scn));
-            /* Same as the next assert */
-            ASSERT(elf_ndxscn (source->shdr_info[cnt].newscn) ==
-                   source->shdr_info[cnt].idx);
-        }
-
-        ASSERT(elf_ndxscn(scn) == (size_t)cnt);
-        cnt++;
-    }
-}
-
-/* This function sets up the shdr_info[] array of a source_t.  We call it only
-   when ADJUST_ELF is non-zero (i.e., support for adjusting an ELF file for
-   changes in sizes and numbers of relocation sections is compiled in.  Note
-   that setup_shdr_info() depends only on the information in source->oldelf,
-   not on source->elf.
-*/
-
-static void setup_shdr_info(source_t *source)
-{
-    if (ADJUST_ELF)
-    {
-        /* Allocate the section-header-info buffer. */
-        INFO("Allocating section-header info structure (%d) bytes...\n",
-             source->shnum * sizeof (shdr_info_t));
-
-        source->shdr_info = (shdr_info_t *)CALLOC(source->shnum,
-                                                  sizeof (shdr_info_t));
-
-        /* Mark the SHT_NULL section as handled. */
-        source->shdr_info[0].idx = 2;
-
-        int cnt = 1;
-        Elf_Scn *oldscn = NULL;
-        while ((oldscn = elf_nextscn (source->oldelf, oldscn)) != NULL) {
-            /* Copy the section header */
-            ASSERT(elf_ndxscn(oldscn) == (size_t)cnt);
-
-            /* Initialized the corresponding shdr_info entry */
-            {
-                /* Mark the section with a non-zero index.  Later, when we
-                   decide to drop a section, we will set its idx to zero, and
-                   assign section numbers to the remaining sections.
-                */
-                source->shdr_info[cnt].idx = 1;
-
-                source->shdr_info[cnt].scn = oldscn;
-
-                /* NOTE: Here we pupulate the section-headset struct with the
-                         same values as the original section's.  After the
-                         first run of prelink(), we will update the sh_size
-                         fields of those sections that need resizing.
-                */
-                FAILIF_LIBELF(NULL == 
-                              gelf_getshdr(oldscn,
-                                           &source->shdr_info[cnt].shdr),
-                              gelf_getshdr);
-                
-                /* Get the name of the section. */
-                source->shdr_info[cnt].name =
-                    elf_strptr (source->oldelf, source->shstrndx,
-                                source->shdr_info[cnt].shdr.sh_name);
-
-                INFO("\tname: %s\n", source->shdr_info[cnt].name);
-                FAILIF(source->shdr_info[cnt].name == NULL,
-                       "Malformed file: section %d name is null\n",
-                       cnt);
-
-                /* Remember the shdr.sh_link value.  We need to remember this
-                   value for those sections that refer to other sections.  For
-                   example, we need to remember it for relocation-entry
-                   sections, because if we modify the symbol table that a
-                   relocation-entry section is relative to, then we need to
-                   patch the relocation section.  By the time we get to
-                   deciding whether we need to patch the relocation section, we
-                   will have overwritten its header's sh_link field with a new
-                   value.
-                */
-                source->shdr_info[cnt].old_shdr = source->shdr_info[cnt].shdr;
-                INFO("\t\toriginal sh_link: %08d\n",
-                     source->shdr_info[cnt].old_shdr.sh_link);
-                INFO("\t\toriginal sh_addr: %lld\n",
-                     source->shdr_info[cnt].old_shdr.sh_addr);
-                INFO("\t\toriginal sh_offset: %lld\n",
-                     source->shdr_info[cnt].old_shdr.sh_offset);
-                INFO("\t\toriginal sh_size: %lld\n",
-                     source->shdr_info[cnt].old_shdr.sh_size);
-
-                FAILIF(source->shdr_info[cnt].shdr.sh_type == SHT_SYMTAB_SHNDX,
-                       "Cannot handle sh_type SHT_SYMTAB_SHNDX!\n");
-                FAILIF(source->shdr_info[cnt].shdr.sh_type == SHT_GROUP,
-                       "Cannot handle sh_type SHT_GROUP!\n");
-                FAILIF(source->shdr_info[cnt].shdr.sh_type == SHT_GNU_versym,
-                       "Cannot handle sh_type SHT_GNU_versym!\n");
-            }
-
-            cnt++;
-        } /* for each section */
-    } /* if (ADJUST_ELF) */
-}
-
-static Elf * init_elf(source_t *source, bool create_new_sections)
-{
-    Elf *elf;
-    if (source->output != NULL) {
-        if (source->output_is_dir) {
-            source->output_is_dir++;
-            char *dir = source->output;
-            int dirlen = strlen(dir);
-            /* The main() function maintains a pointer to source->output; it
-               frees the buffer after apriori() returns.
-            */
-            source->output = MALLOC(dirlen +
-                                    1 + /* slash */
-                                    strlen(source->name) +
-                                    1); /* null terminator */
-            strcpy(source->output, dir);
-            source->output[dirlen] = '/';
-            strcpy(source->output + dirlen + 1,
-                   basename(source->name));
-        }
-
-        source->newelf_fd = open(source->output,
-                                 O_RDWR | O_CREAT,
-                                 0666);
-        FAILIF(source->newelf_fd < 0, "open(%s): %s (%d)\n",
-               source->output,
-               strerror(errno),
-               errno);
-        elf = elf_begin(source->newelf_fd, ELF_C_WRITE, NULL);
-        FAILIF_LIBELF(elf == NULL, elf_begin);
-    } else {
-        elf = elf_clone(source->oldelf, ELF_C_EMPTY);
-        FAILIF_LIBELF(elf == NULL, elf_clone);
-    }
-
-    GElf_Ehdr *oldehdr = gelf_getehdr(source->oldelf, &source->old_ehdr_mem);
-    FAILIF_LIBELF(NULL == oldehdr, gelf_getehdr);
-
-    /* Create new ELF and program headers for the elf file */
-    INFO("Creating empty ELF and program headers...\n");
-    FAILIF_LIBELF(gelf_newehdr (elf, gelf_getclass (source->oldelf)) == 0,
-                  gelf_newehdr);
-    FAILIF_LIBELF(oldehdr->e_type != ET_REL
-                  && gelf_newphdr (elf,
-                                   oldehdr->e_phnum) == 0,
-                  gelf_newphdr);
-
-    /* Copy the elf header */
-    INFO("Copying ELF header...\n");
-    GElf_Ehdr *ehdr = gelf_getehdr(elf, &source->ehdr_mem);
-    FAILIF_LIBELF(NULL == ehdr, gelf_getehdr);
-    memcpy(ehdr, oldehdr, sizeof(GElf_Ehdr));
-    FAILIF_LIBELF(!gelf_update_ehdr(elf, ehdr), gelf_update_ehdr);
-
-    /* Copy out the old program header: notice that if the ELF file does not
-       have a program header, this loop won't execute.
-    */
-    INFO("Copying ELF program header...\n");
-    {
-        int cnt;
-        source->phdr_info = (GElf_Phdr *)CALLOC(ehdr->e_phnum,
-                                                sizeof(GElf_Phdr));
-        for (cnt = 0; cnt < ehdr->e_phnum; ++cnt) {
-            INFO("\tRetrieving entry %d\n", cnt);
-            FAILIF_LIBELF(NULL ==
-                          gelf_getphdr(source->oldelf, cnt,
-                                       source->phdr_info + cnt),
-                          gelf_getphdr);
-            FAILIF_LIBELF(gelf_update_phdr (elf, cnt, 
-                                            source->phdr_info + cnt) == 0,
-                          gelf_update_phdr);
-        }
-    }
-
-    /* Copy the sections and the section headers. */
-    if (create_new_sections)
-    {
-        create_elf_sections(source, elf);
-    }
-
-    /* The ELF library better follows our layout when this is not a
-       relocatable object file. */
-    elf_flagelf (elf, ELF_C_SET, (ehdr->e_type != ET_REL ? ELF_F_LAYOUT : 0));
-
-    return elf;
-}
-
-static shdr_info_t *lookup_shdr_info_by_new_section(
-    source_t *source,
-    const char *sname,
-    Elf_Scn *newscn)
-{
-    if (source->shdr_info == NULL) return NULL;
-    int cnt;
-    for (cnt = 0; cnt < source->shnum; cnt++) {
-        if (source->shdr_info[cnt].newscn == newscn) {
-            INFO("\t\tnew section at %p matches shdr_info[%d], "
-                 "section [%s]!\n",
-                 newscn,
-                 cnt,
-                 source->shdr_info[cnt].name);
-            FAILIF(strcmp(sname, source->shdr_info[cnt].name),
-                   "Matched section's name [%s] does not match "
-                   "looked-up section's name [%s]!\n",
-                   source->shdr_info[cnt].name,
-                   sname);
-            return source->shdr_info + cnt;
-        }
-    }
-    return NULL;
-}
-
-static bool do_init_source(source_t *source, unsigned base)
-{
-    /* Find various sections. */
-    size_t scnidx;
-    Elf_Scn *scn;
-    GElf_Shdr *shdr, shdr_mem;
-    source->sorted_sections = init_range_list();
-    INFO("Processing [%s]'s sections...\n", source->name);
-    for (scnidx = 1; scnidx < (size_t)source->shnum; scnidx++) {
-        INFO("\tGetting section index %d...\n", scnidx);
-        scn = elf_getscn(source->elf, scnidx);
-        if (NULL == scn) {
-            /* If we get an error from elf_getscn(), it means that a section
-               at the requested index does not exist.  This may happen when
-               we remove sections.  Since we do not update source->shnum
-               (we can't, since we need to know the original number of sections
-               to know source->shdr_info[]'s length), we will attempt to
-               retrieve a section for an index that no longer exists in the
-               new ELF file. */
-            INFO("\tThere is no section at index %d anymore, continuing.\n",
-                 scnidx);
-            continue;
-        }
-        shdr = gelf_getshdr(scn, &shdr_mem);
-        FAILIF_LIBELF(NULL == shdr, gelf_getshdr);
-
-        /* We haven't modified the shstrtab section, and so shdr->sh_name
-           has the same value as before.  Thus we look up the name based
-           on the old ELF handle.  We cannot use shstrndx on the new ELF
-           handle because the index of the shstrtab section may have
-           changed (and calling elf_getshstrndx() returns the same section
-           index, so libelf can't handle thise ither).
-        */
-        const char *sname =
-          elf_strptr(source->oldelf, source->shstrndx, shdr->sh_name);
-        ASSERT(sname);
-
-        INFO("\tAdding [%s] (%lld, %lld)...\n",
-             sname,
-             shdr->sh_addr,
-             shdr->sh_addr + shdr->sh_size);
-        if ((shdr->sh_flags & SHF_ALLOC) == SHF_ALLOC) {
-            add_unique_range_nosort(source->sorted_sections,
-                                    shdr->sh_addr,
-                                    shdr->sh_size,
-                                    scn,
-                                    handle_range_error,
-                                    NULL); /* no user-data destructor */
-        }
-
-        if (shdr->sh_type == SHT_DYNSYM) {
-            source->symtab.scn = scn;
-            source->symtab.data = elf_getdata(scn, NULL);
-            FAILIF_LIBELF(NULL == source->symtab.data, elf_getdata);
-            memcpy(&source->symtab.shdr, shdr, sizeof(GElf_Shdr));
-            source->symtab.info = lookup_shdr_info_by_new_section(
-                source, sname, scn);
-            ASSERT(source->shdr_info == NULL || source->symtab.info != NULL);
-
-            /* The sh_link field of the section header of the symbol table
-               contains the index of the associated strings table. */
-            source->strtab.scn = elf_getscn(source->elf,
-                                            source->symtab.shdr.sh_link);
-            FAILIF_LIBELF(NULL == source->strtab.scn, elf_getscn);
-            FAILIF_LIBELF(NULL == gelf_getshdr(source->strtab.scn,
-                                               &source->strtab.shdr),
-                          gelf_getshdr);
-            source->strtab.data = elf_getdata(source->strtab.scn, NULL);
-            FAILIF_LIBELF(NULL == source->strtab.data, elf_getdata);
-            source->strtab.info = lookup_shdr_info_by_new_section(
-                source,
-                elf_strptr(source->oldelf, source->shstrndx,
-                           source->strtab.shdr.sh_name),
-                source->strtab.scn);
-            ASSERT(source->shdr_info == NULL || source->strtab.info != NULL);
-        } else if (shdr->sh_type == SHT_DYNAMIC) {
-            source->dynamic.scn = scn;
-            source->dynamic.data = elf_getdata(scn, NULL);
-            FAILIF_LIBELF(NULL == source->dynamic.data, elf_getdata);
-            memcpy(&source->dynamic.shdr, shdr, sizeof(GElf_Shdr));
-            source->dynamic.info = lookup_shdr_info_by_new_section(
-                source, sname, scn);
-            ASSERT(source->shdr_info == NULL || source->dynamic.info != NULL);
-        } else if (shdr->sh_type == SHT_HASH) {
-            source->hash.scn = scn;
-            source->hash.data = elf_getdata(scn, NULL);
-            FAILIF_LIBELF(NULL == source->hash.data, elf_getdata);
-            memcpy(&source->hash.shdr, shdr, sizeof(GElf_Shdr));
-            source->hash.info = lookup_shdr_info_by_new_section(
-                source, sname, scn);
-            ASSERT(source->shdr_info == NULL || source->hash.info != NULL);
-        } else if (shdr->sh_type == SHT_REL || shdr->sh_type == SHT_RELA) {
-            if (source->num_relocation_sections ==
-                    source->relocation_sections_size) {
-                source->relocation_sections_size += 5;
-                source->relocation_sections =
-                (section_info_t *)REALLOC(source->relocation_sections,
-                                          source->relocation_sections_size *
-                                          sizeof(section_info_t));
-            }
-            section_info_t *reloc =
-            source->relocation_sections + source->num_relocation_sections;
-            reloc->scn = scn;
-            reloc->info = lookup_shdr_info_by_new_section(source, sname, scn);
-            ASSERT(source->shdr_info == NULL || reloc->info != NULL);
-            reloc->data = elf_getdata(scn, NULL);
-            FAILIF_LIBELF(NULL == reloc->data, elf_getdata);
-            memcpy(&reloc->shdr, shdr, sizeof(GElf_Shdr));
-            source->num_relocation_sections++;
-        } else if (!strcmp(sname, ".bss")) {
-            source->bss.scn = scn;
-            source->bss.data = elf_getdata(scn, NULL);
-            source->bss.info = lookup_shdr_info_by_new_section(
-                source, sname, scn);
-            ASSERT(source->shdr_info == NULL || source->bss.info != NULL);
-            /* The BSS section occupies no space in the ELF file. */
-            FAILIF_LIBELF(NULL == source->bss.data, elf_getdata)
-            FAILIF(NULL != source->bss.data->d_buf,
-                   "Enexpected: section [%s] has data!",
-                   sname);
-            memcpy(&source->bss.shdr, shdr, sizeof(GElf_Shdr));
-        }
-    }
-    sort_ranges(source->sorted_sections);
-
-    source->unfinished =
-        (unfinished_relocation_t *)CALLOC(source->num_relocation_sections,
-                                          sizeof(unfinished_relocation_t));
-
-    if (source->dynamic.scn == NULL) {
-        INFO("File [%s] does not have a dynamic section!\n", source->name);
-        /* If this is a static executable, we won't update anything. */
-        source->dry_run = 1;
-        return false;
-    }
-
-    FAILIF(source->symtab.scn == NULL,
-           "File [%s] does not have a dynamic symbol table!\n",
-           source->name);
-    FAILIF(source->hash.scn == NULL,
-           "File [%s] does not have a hash table!\n",
-           source->name);
-    FAILIF(source->hash.shdr.sh_link != elf_ndxscn(source->symtab.scn),
-           "Hash points to section %d, not to %d as expected!\n",
-           source->hash.shdr.sh_link,
-           elf_ndxscn(source->symtab.scn));
-
-    /* Now, find out how many symbols we have and allocate the array of
-       satisfied symbols.
-
-       NOTE: We don't count the number of undefined symbols here; we will
-       iterate over the symbol table later, and count them then, when it is
-       more convenient.
-    */
-    size_t symsize = gelf_fsize (source->elf,
-                                 ELF_T_SYM,
-                                 1, source->elf_hdr.e_version);
-    ASSERT(symsize);
-
-    source->num_syms = source->symtab.data->d_size / symsize;
-    source->base = (source->oldelf_hdr.e_type == ET_DYN) ? base : 0;
-    INFO("Relink base for [%s]: 0x%lx\n", source->name, source->base);
-    FAILIF(source->base == -1,
-           "Can't prelink [%s]: it's a shared library and you did not "
-           "provide a prelink address!\n",
-           source->name);
-#ifdef SUPPORT_ANDROID_PRELINK_TAGS
-    FAILIF(source->prelinked && source->base != source->prelink_base,
-           "ERROR: file [%s] has already been prelinked for 0x%08lx.  "
-           "Cannot change to 0x%08lx!\n",
-           source->name,
-           source->prelink_base,
-           source->base);
-#endif/*SUPPORT_ANDROID_PRELINK_TAGS*/
-
-    return true;
-}
-
-static source_t* init_source(const char *full_path,
-                             const char *output, int is_file,
-                             int base, int dry_run)
-{
-    source_t *source = (source_t *)CALLOC(1, sizeof(source_t));
-
-    ASSERT(full_path);
-    source->name = full_path;
-    source->output = output;
-    source->output_is_dir = !is_file;
-
-    source->newelf_fd = -1;
-    source->elf_fd = -1;
-    INFO("Opening %s...\n", full_path);
-    source->elf_fd =
-        open(full_path, ((dry_run || output != NULL) ? O_RDONLY : O_RDWR));
-    FAILIF(source->elf_fd < 0, "open(%s): %s (%d)\n",
-           full_path,
-           strerror(errno),
-           errno);
-
-	FAILIF(fstat(source->elf_fd, &source->elf_file_info) < 0,
-		   "fstat(%s(fd %d)): %s (%d)\n",
-		   source->name,
-		   source->elf_fd,
-		   strerror(errno),
-		   errno);
-	INFO("File [%s]'s size is %lld bytes!\n",
-		 source->name,
-		 source->elf_file_info.st_size);
-
-    INFO("Calling elf_begin(%s)...\n", full_path);
-
-    source->oldelf =
-        elf_begin(source->elf_fd,
-                  (dry_run || output != NULL) ? ELF_C_READ : ELF_C_RDWR,
-                  NULL);
-    FAILIF_LIBELF(source->oldelf == NULL, elf_begin);
-
-    /* libelf can recognize COFF and A.OUT formats, but we handle only ELF. */
-    if(elf_kind(source->oldelf) != ELF_K_ELF) {
-        ERROR("Input file %s is not in ELF format!\n", full_path);
-        return NULL;
-    }
-
-    /* Make sure this is a shared library or an executable. */
-    {
-        INFO("Making sure %s is a shared library or an executable...\n",
-             full_path);
-        FAILIF_LIBELF(0 == gelf_getehdr(source->oldelf, &source->oldelf_hdr),
-                      gelf_getehdr);
-        FAILIF(source->oldelf_hdr.e_type != ET_DYN &&
-               source->oldelf_hdr.e_type != ET_EXEC,
-               "%s must be a shared library (elf type is %d, expecting %d).\n",
-               full_path,
-               source->oldelf_hdr.e_type,
-               ET_DYN);
-    }
-
-#ifdef SUPPORT_ANDROID_PRELINK_TAGS
-    /* First, check to see if the file has been prelinked. */
-    source->prelinked =
-        check_prelinked(source->name,
-                        source->oldelf_hdr.e_ident[EI_DATA] == ELFDATA2LSB,
-                        &source->prelink_base);
-    /* Note that in the INFO() below we need to use oldelf_hdr because we
-       haven't cloned the ELF file yet, and source->elf_hdr is not defined. */
-    if (source->prelinked) {
-        PRINT("%s [%s] is already prelinked at 0x%08lx!\n",
-              (source->oldelf_hdr.e_type == ET_EXEC ?
-               "Executable" : "Shared library"),
-              source->name,
-              source->prelink_base);
-        /* Force a dry run when the file has already been prelinked */
-        source->dry_run = dry_run = 1;
-    }
-    else {
-        INFO("%s [%s] is not prelinked!\n",
-             (source->oldelf_hdr.e_type == ET_EXEC ?
-              "Executable" : "Shared library"),
-             source->name);
-        source->dry_run = dry_run;
-    }
-#endif/*SUPPORT_ANDROID_PRELINK_TAGS*/
-
-    /* Get the index of the section-header-strings-table section. */
-    FAILIF_LIBELF(elf_getshstrndx (source->oldelf, &source->shstrndx) < 0,
-                  elf_getshstrndx);
-
-    FAILIF_LIBELF(elf_getshnum (source->oldelf, (size_t *)&source->shnum) < 0,
-                  elf_getshnum);
-
-    /* When we have a dry run, or when ADJUST_ELF is enabled, we use
-       source->oldelf for source->elf, because the former is mmapped privately,
-       so changes to it have no effect.  With ADJUST_ELF, the first run of
-       prelink() is a dry run.  We will reopen the elf file for write access
-       after that dry run, before we call adjust_elf. */
-
-    source->elf = (ADJUST_ELF || source->dry_run) ?
-        source->oldelf : init_elf(source, ADJUST_ELF == 0);
-
-    FAILIF_LIBELF(0 == gelf_getehdr(source->elf, &source->elf_hdr),
-                  gelf_getehdr);
-#ifdef DEBUG
-    ASSERT(!memcmp(&source->oldelf_hdr,
-                   &source->elf_hdr,
-                   sizeof(source->elf_hdr)));
-#endif
-
-    /* Get the EBL handling.  The -g option is currently the only reason
-       we need EBL so dont open the backend unless necessary.  */
-    source->ebl = ebl_openbackend (source->elf);
-    FAILIF_LIBELF(NULL == source->ebl, ebl_openbackend);
-#ifdef ARM_SPECIFIC_HACKS
-    FAILIF_LIBELF(0 != arm_init(source->elf, source->elf_hdr.e_machine,
-                                source->ebl, sizeof(Ebl)),
-                  arm_init);
-#endif/*ARM_SPECIFIC_HACKS*/
-
-    add_to_sources(source);
-    if (do_init_source(source, base) == false) return NULL;
-    return source;
-}
-
-/* complements do_init_source() */
-static void do_destroy_source(source_t *source)
-{
-    int cnt;
-    destroy_range_list(source->sorted_sections);
-    source->sorted_sections = NULL;
-    for (cnt = 0; cnt < source->num_relocation_sections; cnt++) {
-        FREEIF(source->unfinished[cnt].rels);
-        source->unfinished[cnt].rels = NULL;
-        source->unfinished[cnt].num_rels = 0;
-        source->unfinished[cnt].rels_size = 0;
-    }
-    if (source->jmprel.sections != NULL) {
-        destroy_range_list(source->jmprel.sections);
-        source->jmprel.sections = NULL;
-    }
-    if (source->rel.sections != NULL) {
-        destroy_range_list(source->rel.sections);
-        source->rel.sections = NULL;
-    }
-    FREE(source->unfinished); /* do_init_source() */
-    source->unfinished = NULL;
-    FREE(source->relocation_sections); /* do_init_source() */
-    source->relocation_sections = NULL;
-    source->num_relocation_sections = source->relocation_sections_size = 0;
-}
-
-static void destroy_source(source_t *source)
-{
-    /* Is this a little-endian ELF file? */
-    if (source->oldelf != source->elf) {
-        /* If it's a dynamic executable, this must not be a dry run. */
-        if (!source->dry_run && source->dynamic.scn != NULL)
-        {
-            FAILIF_LIBELF(elf_update(source->elf, ELF_C_WRITE) == -1,
-                          elf_update);
-        }
-        FAILIF_LIBELF(elf_end(source->oldelf), elf_end);
-    }
-    ebl_closebackend(source->ebl);
-    FAILIF_LIBELF(elf_end(source->elf), elf_end);
-    FAILIF(close(source->elf_fd) < 0, "Could not close file %s: %s (%d)!\n",
-           source->name, strerror(errno), errno);
-    FAILIF((source->newelf_fd >= 0) && (close(source->newelf_fd) < 0),
-           "Could not close output file: %s (%d)!\n", strerror(errno), errno);
-
-#ifdef SUPPORT_ANDROID_PRELINK_TAGS
-    if (!source->dry_run) {
-        if (source->dynamic.scn != NULL &&
-            source->elf_hdr.e_type != ET_EXEC)
-        {
-            /* For some reason, trying to write directly to source->elf_fd
-               causes a "bad file descriptor" error because of something libelf
-               does.  We just close the file descriptor and open a new one in
-               function setup_prelink_info() below. */
-            INFO("%s: setting up prelink tag at end of file.\n",
-                 source->output ? source->output : source->name);
-            setup_prelink_info(source->output ? source->output : source->name,
-                               source->elf_hdr.e_ident[EI_DATA] == ELFDATA2LSB,
-                               source->base);
-        }
-        else INFO("%s: executable, NOT setting up prelink tag.\n",
-                  source->name);
-    }
-#endif/*SUPPORT_ANDROID_PRELINK_TAGS*/
-
-    do_destroy_source(source);
-
-    if (source->shstrtab_data != NULL)
-        FREEIF(source->shstrtab_data->d_buf); /* adjust_elf */
-
-    FREE(source->lib_deps); /* list of library dependencies (process_file()) */
-    FREEIF(source->shdr_info); /* setup_shdr_info() */
-    FREEIF(source->phdr_info); /* init_elf() */
-    FREE(source->name); /* assigned to by init_source() */
-    /* If the output is a directory, in init_elf() we allocate a buffer where
-       we copy the directory, a slash, and the file name.  Here we free that
-       buffer.
-    */
-    if (source->output_is_dir > 1) {
-        FREE(source->output);
-    }
-    FREE(source); /* init_source() */
-}
-
-static void reinit_source(source_t *source)
-{
-    do_destroy_source(source);
-    do_init_source(source, source->base);
-
-    {
-        /* We've gathered all the DT_DYNAMIC entries; now we need to figure
-           out which relocation sections fit in which range as described by
-           the entries.  Before we do so, however, we will populate the
-           jmprel and rel members of source, as well as their sizes.
-        */
-
-        size_t dynidx, numdyn;
-        GElf_Dyn *dyn, dyn_mem;
-
-        numdyn = source->dynamic.shdr.sh_size /
-            source->dynamic.shdr.sh_entsize;
-
-        source->rel.idx = source->rel.sz_idx = -1;
-        source->jmprel.idx = source->jmprel.sz_idx = -1;
-        for (dynidx = 0; dynidx < numdyn; dynidx++) {
-            dyn = gelf_getdyn (source->dynamic.data,
-                               dynidx,
-                               &dyn_mem);
-            FAILIF_LIBELF(NULL == dyn, gelf_getdyn);
-            switch (dyn->d_tag)
-            {
-            case DT_NEEDED:
-                break;
-            case DT_JMPREL:
-                INFO("reinit_source: DT_JMPREL is at index %d, 0x%08llx.\n",
-                     dynidx, dyn->d_un.d_ptr);
-                source->jmprel.idx = dynidx;
-                source->jmprel.addr = dyn->d_un.d_ptr;
-                break;
-            case DT_PLTRELSZ:
-                INFO("reinit_source: DT_PLTRELSZ is at index %d, 0x%08llx.\n",
-                     dynidx, dyn->d_un.d_val);
-                source->jmprel.sz_idx = dynidx;
-                source->jmprel.size = dyn->d_un.d_val;
-                break;
-            case DT_REL:
-                INFO("reinit_source: DT_REL is at index %d, 0x%08llx.\n",
-                     dynidx, dyn->d_un.d_ptr);
-                source->rel.idx = dynidx;
-                source->rel.addr = dyn->d_un.d_ptr;
-                break;
-            case DT_RELSZ:
-                INFO("reinit_source: DT_RELSZ is at index %d, 0x%08llx.\n",
-                     dynidx, dyn->d_un.d_val);
-                source->rel.sz_idx = dynidx;
-                source->rel.size = dyn->d_un.d_val;
-                break;
-            case DT_RELA:
-            case DT_RELASZ:
-                FAILIF(1, "Can't handle DT_RELA and DT_RELASZ entries!\n");
-                break;
-            } /* switch */
-        } /* for each dynamic entry... */
-    }
-}
-
-static GElf_Sym *hash_lookup_global_or_weak_symbol(source_t *lib,
-                                                   const char *symname,
-                                                   GElf_Sym *lib_sym_mem)
-{
-    int lib_symidx = hash_lookup(lib->elf,
-                                 lib->hash.data,
-                                 lib->symtab.data,
-                                 lib->strtab.data,
-                                 symname);
-
-    GElf_Sym sym_mem;
-    if (SHN_UNDEF != lib_symidx) {
-        /* We found the symbol--now check to see if it is global
-           or weak.  If this is the case, then the symbol satisfies
-           the dependency. */
-        GElf_Sym *lib_sym = gelf_getsymshndx(lib->symtab.data,
-                                             NULL,
-                                             lib_symidx,
-                                             &sym_mem,
-                                             NULL);
-        FAILIF_LIBELF(NULL == lib_sym, gelf_getsymshndx);
-#if ELF_STRPTR_IS_BROKEN
-        ASSERT(!strcmp(
-                   symname,
-                   ((char *)elf_getdata(elf_getscn(lib->elf,
-                                                   lib->symtab.shdr.sh_link),
-                                        NULL)->d_buf) +
-                   lib_sym->st_name));
-#else
-        ASSERT(!strcmp(
-                   symname,
-                   elf_strptr(lib->elf, lib->symtab.shdr.sh_link,
-                              lib_sym->st_name)));
-#endif
-        if (lib_sym->st_shndx != SHN_UNDEF &&
-            (GELF_ST_BIND(lib_sym->st_info) == STB_GLOBAL ||
-             GELF_ST_BIND(lib_sym->st_info) == STB_WEAK)) {
-            memcpy(lib_sym_mem, &sym_mem, sizeof(GElf_Sym));
-            return lib_sym;
-        }
-    }
-
-    return NULL;
-}
-
-static source_t *lookup_symbol_in_dependencies(source_t *source,
-                                               const char *symname,
-                                               GElf_Sym *found_sym)
-{
-    source_t *sym_source = NULL; /* return value */
-
-    /* This is an undefined symbol.  Go over the list of libraries
-       and look it up. */
-    size_t libidx;
-    int found = 0;
-    source_t *last_found = NULL;
-    for (libidx = 0; libidx < (size_t)source->num_lib_deps; libidx++) {
-        source_t *lib = source->lib_deps[libidx];
-        if (hash_lookup_global_or_weak_symbol(lib, symname, found_sym) != NULL)
-        {
-            sym_source = lib;
-            if (found) {
-                if (found == 1) {
-                    found++;
-                    ERROR("ERROR: multiple definitions found for [%s:%s]!\n",
-                          source->name, symname);
-                    ERROR("\tthis definition     [%s]\n", lib->name);
-                }
-                ERROR("\tprevious definition [%s]\n", last_found->name);
-            }
-            last_found = lib;
-            if (!found) found = 1;
-        }
-    }
-
-#if ELF_STRPTR_IS_BROKEN
-    ASSERT(!sym_source ||
-           !strcmp(symname,
-                   (char *)(elf_getdata(elf_getscn(
-                                            sym_source->elf,
-                                            sym_source->symtab.shdr.sh_link),
-                                        NULL)->d_buf) +
-                   found_sym->st_name));
-#else
-    ASSERT(!sym_source ||
-           !strcmp(symname,
-                   elf_strptr(sym_source->elf,
-                              sym_source->symtab.shdr.sh_link,
-                              found_sym->st_name)));
-#endif
-
-    return sym_source;
-}
-
-static int do_prelink(source_t *source,
-                      Elf_Data *reloc_scn_data,
-                      int reloc_scn_entry_size,
-                      unfinished_relocation_t *unfinished,
-                      int locals_only,
-                      bool dry_run,
-                      char **lib_lookup_dirs, int num_lib_lookup_dirs,
-                      char **default_libs, int num_default_libs,
-                      int *num_unfinished_relocs)
-{
-    int num_relocations = 0;
-
-    size_t num_rels;
-    num_rels = reloc_scn_data->d_size / reloc_scn_entry_size;
-
-    INFO("\tThere are %d relocations.\n", num_rels);
-
-    int rel_idx;
-    for (rel_idx = 0; rel_idx < (size_t)num_rels; rel_idx++) {
-        GElf_Rel *rel, rel_mem;
-
-        //INFO("\tHandling relocation %d/%d\n", rel_idx, num_rels);
-
-        rel = gelf_getrel(reloc_scn_data, rel_idx, &rel_mem);
-        FAILIF_LIBELF(rel == NULL, gelf_getrel);
-        GElf_Sym *sym = NULL, sym_mem;
-        unsigned sym_idx = GELF_R_SYM(rel->r_info);
-        source_t *sym_source = NULL;
-        /* found_sym points to found_sym_mem, when sym_source != NULL, and
-           to sym, when the sybmol is locally defined.  If the symbol is
-           not locally defined and sym_source == NULL, then sym is not
-           defined either. */
-        GElf_Sym *found_sym = NULL, found_sym_mem;
-        const char *symname = NULL;
-        int sym_is_local = 1;
-        if (sym_idx) {
-          sym = gelf_getsymshndx(source->symtab.data,
-                                 NULL,
-                                 sym_idx,
-                                 &sym_mem,
-                                 NULL);
-          FAILIF_LIBELF(NULL == sym, gelf_getsymshndx);
-#if ELF_STRPTR_IS_BROKEN
-          symname =
-              ((char *)source->strtab.data->d_buf) +
-              sym->st_name;
-#else
-          symname = elf_strptr(source->elf,
-                               elf_ndxscn(source->strtab.scn),
-                               sym->st_name);
-#endif
-
-          /* If the symbol is defined and is either not in the BSS
-             section, or if it is in the BSS then the relocation is
-             not a copy relocation, then the symbol's source is this
-             library (i.e., it is locally-defined).  Otherwise, the
-             symbol is imported.
-          */
-
-          sym_is_local = 0;
-          if (sym->st_shndx != SHN_UNDEF &&
-              (source->bss.scn == NULL ||
-               sym->st_shndx != elf_ndxscn(source->bss.scn) ||
-#ifdef ARM_SPECIFIC_HACKS
-               GELF_R_TYPE(rel->r_info) != R_ARM_COPY
-#else
-               1
-#endif
-               ))
-            {
-              sym_is_local = 1;
-            }
-
-          if (sym_is_local) {
-            INFO("\t\tSymbol [%s:%s] is defined locally.\n",
-                 source->name,
-                 symname);
-            sym_source = source;
-            found_sym = sym;
-          }
-          else if (!locals_only) {
-            sym_source = lookup_symbol_in_dependencies(source,
-                                                       symname,
-                                                       &found_sym_mem);
-
-            /* The symbol was not in the list of dependencies, which by
-               itself is an error:  it means either that the symbol does
-               not exist anywhere, or that the library which has the symbol
-               has not been listed as a dependency in this library or
-               executable. It could also mean (for a library) that the
-               symbol is defined in the executable that links agsinst it,
-               which is obviously not a good thing.  These are bad things,
-               but they do happen, which is why we have the ability to
-               provide a list of default dependencies, including
-               executables. Here we check to see if the symbol has been
-               defined in any of them.
-            */
-            if (NULL == sym_source) {
-              INFO("\t\tChecking default dependencies...\n");
-              int i;
-              source_t *lib, *old_sym_source = NULL;
-              int printed_initial_error = 0;
-              for (i = 0; i < num_default_libs; i++) {
-                INFO("\tChecking in [%s].\n", default_libs[i]);
-                lib = find_source(default_libs[i],
-                                  lib_lookup_dirs,
-                                  num_lib_lookup_dirs);
-                FAILIF(NULL == lib,
-                       "Can't find default library [%s]!\n",
-                       default_libs[i]);
-                if (hash_lookup_global_or_weak_symbol(lib,
-                                                      symname,
-                                                      &found_sym_mem)) {
-                  found_sym = &found_sym_mem;
-                  sym_source = lib;
-#if ELF_STRPTR_IS_BROKEN
-                  ASSERT(!strcmp(symname,
-                                 (char *)(elf_getdata(
-                                              elf_getscn(
-                                                  sym_source->elf,
-                                                  sym_source->symtab.
-                                                      shdr.sh_link),
-                                              NULL)->d_buf) +
-                                 found_sym->st_name));
-#else
-                  ASSERT(!strcmp(symname,
-                                 elf_strptr(sym_source->elf,
-                                            sym_source->symtab.shdr.sh_link,
-                                            found_sym->st_name)));
-
-#endif
-                  INFO("\tFound symbol [%s] in [%s]!\n",
-                       symname, lib->name);
-                  if (old_sym_source) {
-                    if (printed_initial_error == 0) {
-                      printed_initial_error = 1;
-                      ERROR("Multiple definition of [%s]:\n"
-                            "\t[%s]\n",
-                            symname,
-                            old_sym_source->name);
-                    }
-                    ERROR("\t[%s]\n", sym_source->name);
-                  }
-                  old_sym_source = sym_source;
-                } else {
-                  INFO("\tCould not find symbol [%s] in default "
-                       "lib [%s]!\n", symname, lib->name);
-                }
-              }
-              if (sym_source) {
-                ERROR("ERROR: Could not find [%s:%s] in dependent "
-                      "libraries (but found in default [%s])!\n",
-                      source->name,
-                      symname,
-                      sym_source->name);
-              }
-            } else {
-              found_sym = &found_sym_mem;
-              /* We found the symbol in a dependency library. */
-              INFO("\t\tSymbol [%s:%s, value %lld] is imported from [%s]\n",
-                   source->name,
-                   symname,
-                   found_sym->st_value,
-                   sym_source->name);
-            }
-          } /* if symbol is defined in this library... */
-
-          if (!locals_only) {
-            /* If a symbol is weak and we haven't found it, then report
-               an error.  We really need to find a way to set its value
-               to zero.  The problem is that it needs to refer to some
-               section. */
-
-            FAILIF(NULL == sym_source &&
-                   GELF_ST_BIND(sym->st_info) == STB_WEAK,
-                   "Cannot handle weak symbols yet (%s:%s <- %s).\n",
-                   source->name,
-                   symname,
-                   sym_source->name);
-#ifdef PERMISSIVE
-            if (GELF_ST_BIND(sym->st_info) != STB_WEAK &&
-                NULL == sym_source) {
-              ERROR("ERROR: Can't find symbol [%s:%s] in dependent or "
-                    "default libraries!\n", source->name, symname);
-            }
-#else
-            FAILIF(GELF_ST_BIND(sym->st_info) != STB_WEAK &&
-                   NULL == sym_source,
-                   "Can't find symbol [%s:%s] in dependent or default "
-                   "libraries!\n",
-                   source->name,
-                   symname);
-#endif
-          } /* if (!locals_only) */
-        }
-#if 0 // too chatty
-        else
-          INFO("\t\tno symbol is associated with this relocation\n");
-#endif
-
-
-        // We prelink only local symbols when locals_only == 1.
-
-        bool can_relocate = true;
-        if (!sym_is_local &&
-            (symname[0] == 'd' && symname[1] == 'l' && symname[2] != '\0' &&
-             (!strcmp(symname + 2, "open") ||
-              !strcmp(symname + 2, "close") ||
-              !strcmp(symname + 2, "sym") ||
-              !strcmp(symname + 2, "error")))) {
-            INFO("********* NOT RELOCATING LIBDL SYMBOL [%s]\n", symname);
-            can_relocate = false;
-        }
-
-        if (can_relocate && (sym_is_local || !locals_only))
-        {
-            GElf_Shdr shdr_mem; Elf_Scn *scn; Elf_Data *data;
-            find_section(source, rel->r_offset, &scn, &shdr_mem, &data);
-            unsigned *dest =
-              (unsigned*)(((char *)data->d_buf) +
-                          (rel->r_offset - shdr_mem.sh_addr));
-            unsigned rel_type = GELF_R_TYPE(rel->r_info);
-            char buf[64];
-            INFO("\t\t%-15s ",
-                 ebl_reloc_type_name(source->ebl,
-                                     GELF_R_TYPE(rel->r_info),
-                                     buf,
-                                     sizeof(buf)));
-
-            /* Section-name offsets do not change, so we use oldelf to get the
-               strings.  This makes a difference in the second pass of the
-               perlinker, after the call to adjust_elf, because
-               source->shstrndx no longer contains the index of the
-               section-header-strings table.
-            */
-            const char *sname = elf_strptr(
-                source->oldelf, source->shstrndx, shdr_mem.sh_name);
-
-            switch (rel_type) {
-            case R_ARM_JUMP_SLOT:
-            case R_ARM_GLOB_DAT:
-            case R_ARM_ABS32:
-              ASSERT(data->d_buf != NULL);
-              ASSERT(data->d_size >= rel->r_offset - shdr_mem.sh_addr);
-#ifdef PERMISSIVE
-              if (sym_source == NULL) {
-                ERROR("ERROR: Permissive relocation "
-                      "[%-15s] [%s:%s]: [0x%llx] = ZERO\n",
-                      ebl_reloc_type_name(source->ebl,
-                                          GELF_R_TYPE(rel->r_info),
-                                          buf,
-                                          sizeof(buf)),
-                      sname,
-                      symname,
-                      rel->r_offset);
-                if (!dry_run)
-                  *dest = 0;
-              } else
-#endif
-                {
-                  ASSERT(sym_source);
-                  INFO("[%s:%s]: [0x%llx] = 0x%llx + 0x%lx\n",
-                       sname,
-                       symname,
-                       rel->r_offset,
-                       found_sym->st_value,
-                       sym_source->base);
-                  if (!dry_run)
-                    *dest = found_sym->st_value + sym_source->base;
-                }
-              num_relocations++;
-              break;
-            case R_ARM_RELATIVE:
-              ASSERT(data->d_buf != NULL);
-              ASSERT(data->d_size >= rel->r_offset - shdr_mem.sh_addr);
-              FAILIF(sym != NULL,
-                     "Unsupported RELATIVE form (symbol != 0)...\n");
-              INFO("[%s:%s]: [0x%llx] = 0x%x + 0x%lx\n",
-                   sname,
-                   symname ?: "(symbol has no name)",
-                   rel->r_offset, *dest, source->base);
-              if (!dry_run)
-                *dest += source->base;
-              num_relocations++;
-              break;
-            case R_ARM_COPY:
-#ifdef PERMISSIVE
-              if (sym_source == NULL) {
-                ERROR("ERROR: Permissive relocation "
-                      "[%-15s] [%s:%s]: NOT PERFORMING\n",
-                      ebl_reloc_type_name(source->ebl,
-                                          GELF_R_TYPE(rel->r_info),
-                                          buf,
-                                          sizeof(buf)),
-                      sname,
-                      symname);
-              } else
-#endif
-                {
-                  ASSERT(sym);
-                  ASSERT(sym_source);
-                  GElf_Shdr src_shdr_mem;
-                  Elf_Scn *src_scn;
-                  Elf_Data *src_data;
-                  find_section(sym_source, found_sym->st_value,
-                               &src_scn,
-                               &src_shdr_mem,
-                               &src_data);
-                  INFO("Found [%s:%s (%lld)] in section [%s] .\n",
-                       sym_source->name,
-                       symname,
-                       found_sym->st_value,
-#if ELF_STRPTR_IS_BROKEN
-                       (((char *)elf_getdata(
-                             elf_getscn(sym_source->elf,
-                                        sym_source->shstrndx),
-                             NULL)->d_buf) + src_shdr_mem.sh_name)
-#else
-                       elf_strptr(sym_source->elf,
-                                  sym_source->shstrndx,
-                                  src_shdr_mem.sh_name)
-#endif
-                      );
-
-                  unsigned *src = NULL;
-                  if (src_data->d_buf == NULL)
-                    {
-#ifdef PERMISSIVE
-                      if (sym_source->bss.scn == NULL ||
-                          elf_ndxscn(src_scn) !=
-                          elf_ndxscn(sym_source->bss.scn)) {
-                        ERROR("ERROR: Permissive relocation (NULL source "
-                              "not from .bss) [%-15s] [%s:%s]: "
-                              "NOT PERFORMING\n",
-                              ebl_reloc_type_name(source->ebl,
-                                                  GELF_R_TYPE(rel->r_info),
-                                                  buf,
-                                                  sizeof(buf)),
-                              sname,
-                              symname);
-                      }
-#endif
-                    }
-                  else {
-                    ASSERT(src_data->d_size >=
-                           found_sym->st_value - src_shdr_mem.sh_addr);
-                    src = (unsigned*)(((char *)src_data->d_buf) +
-                                      (found_sym->st_value -
-                                       src_shdr_mem.sh_addr));
-                  }
-                  ASSERT(symname);
-                  INFO("[%s:%s]: [0x%llx] <- [0x%llx] size %lld\n",
-                       sname,
-                       symname, rel->r_offset,
-                       found_sym->st_value,
-                       found_sym->st_size);
-
-#ifdef PERMISSIVE
-                  if (src_data->d_buf != NULL ||
-                      (sym_source->bss.scn != NULL &&
-                       elf_ndxscn(src_scn) ==
-                       elf_ndxscn(sym_source->bss.scn)))
-#endif/*PERMISSIVE*/
-                    {
-                      if (data->d_buf == NULL) {
-                        INFO("Incomplete relocation [%-15s] of [%s:%s].\n",
-                             ebl_reloc_type_name(source->ebl,
-                                                 GELF_R_TYPE(rel->r_info),
-                                                 buf,
-                                                 sizeof(buf)),
-                             sname,
-                             symname);
-                        FAILIF(unfinished == NULL,
-                               "You passed unfinished as NULL expecting "
-                               "to handle all relocations, "
-                               "but at least one cannot be handled!\n");
-                        if (unfinished->num_rels == unfinished->rels_size) {
-                          unfinished->rels_size += 10;
-                          unfinished->rels = (GElf_Rel *)REALLOC(
-                              unfinished->rels,
-                              unfinished->rels_size *
-                              sizeof(GElf_Rel));
-                        }
-                        unfinished->rels[unfinished->num_rels++] = *rel;
-                        num_relocations--;
-                        (*num_unfinished_relocs)++;
-                      }
-                      else {
-                        if (src_data->d_buf != NULL)
-                          {
-                            ASSERT(data->d_buf != NULL);
-                            ASSERT(data->d_size >= rel->r_offset -
-                                   shdr_mem.sh_addr);
-                            if (!dry_run)
-                              memcpy(dest, src, found_sym->st_size);
-                          }
-                        else {
-                          ASSERT(src == NULL);
-                          ASSERT(elf_ndxscn(src_scn) ==
-                                 elf_ndxscn(sym_source->bss.scn));
-                          if (!dry_run)
-                            memset(dest, 0, found_sym->st_size);
-                        }
-                      }
-                    }
-                  num_relocations++;
-                }
-              break;
-            default:
-              FAILIF(1, "Unknown relocation type %d!\n", rel_type);
-            } // switch
-        } // relocate
-        else {
-          INFO("\t\tNot relocating symbol [%s]%s\n",
-               symname,
-               (can_relocate ? ", relocating only locals" : 
-                ", which is a libdl symbol"));
-          FAILIF(unfinished == NULL,
-                 "You passed unfinished as NULL expecting to handle all "
-                 "relocations, but at least one cannot be handled!\n");
-          if (unfinished->num_rels == unfinished->rels_size) {
-              unfinished->rels_size += 10;
-              unfinished->rels = (GElf_Rel *)REALLOC(
-                  unfinished->rels,
-                  unfinished->rels_size *
-                  sizeof(GElf_Rel));
-          }
-          unfinished->rels[unfinished->num_rels++] = *rel;
-          (*num_unfinished_relocs)++;
-        }
-    } // for each relocation entry
-
-    return num_relocations;
-}
-
-static int prelink(source_t *source,
-                   int locals_only,
-                   bool dry_run,
-                   char **lib_lookup_dirs, int num_lib_lookup_dirs,
-                   char **default_libs, int num_default_libs,
-                   int *num_unfinished_relocs)
-{
-    INFO("Prelinking [%s] (number of relocation sections: %d)%s...\n",
-         source->name, source->num_relocation_sections,
-         (dry_run ? " (dry run)" : ""));
-    int num_relocations = 0;
-    int rel_scn_idx;
-    for (rel_scn_idx = 0; rel_scn_idx < source->num_relocation_sections;
-         rel_scn_idx++)
-    {
-        section_info_t *reloc_scn = source->relocation_sections + rel_scn_idx;
-        unfinished_relocation_t *unfinished = source->unfinished + rel_scn_idx;
-
-        /* We haven't modified the shstrtab section, and so shdr->sh_name has
-           the same value as before.  Thus we look up the name based on the old
-           ELF handle.  We cannot use shstrndx on the new ELF handle because
-           the index of the shstrtab section may have changed (and calling
-           elf_getshstrndx() returns the same section index, so libelf can't
-           handle thise ither).
-
-           If reloc_scn->info is available, we can assert that the
-           section-name has not changed.  If this assertion fails,
-           then we cannot use the elf_strptr() trick below to get
-           the section name.  One solution would be to save it in
-           the section_info_t structure.
-        */
-        ASSERT(reloc_scn->info == NULL ||
-               reloc_scn->shdr.sh_name == reloc_scn->info->old_shdr.sh_name);
-        const char *sname =
-          elf_strptr(source->oldelf,
-                     source->shstrndx,
-                     reloc_scn->shdr.sh_name);
-        ASSERT(sname != NULL);
-
-        INFO("\n\tIterating relocation section [%s]...\n", sname);
-
-        /* In general, the new size of the section differs from the original
-           size of the section, because we can handle some of the relocations.
-           This was communicated to adjust_elf, which modified the ELF file
-           according to the new section sizes.  Now, when prelink() does the
-           actual work of prelinking, it needs to know the original size of the
-           relocation section so that it can see all of the original relocation
-           entries!
-        */
-        size_t d_size = reloc_scn->data->d_size;
-        if (reloc_scn->info != NULL &&
-            reloc_scn->data->d_size != reloc_scn->info->old_shdr.sh_size)
-        {
-            INFO("Setting size of section [%s] to from new size %d to old "
-                 "size %lld temporarily (so prelinker can see all "
-                 "relocations).\n",
-                 reloc_scn->info->name,
-                 d_size,
-                 reloc_scn->info->old_shdr.sh_size);
-            reloc_scn->data->d_size = reloc_scn->info->old_shdr.sh_size;
-        }
-
-        num_relocations +=
-          do_prelink(source,
-                     reloc_scn->data, reloc_scn->shdr.sh_entsize,
-                     unfinished,
-                     locals_only, dry_run,
-                     lib_lookup_dirs, num_lib_lookup_dirs,
-                     default_libs, num_default_libs,
-                     num_unfinished_relocs);
-
-        if (reloc_scn->data->d_size != d_size)
-        {
-            ASSERT(reloc_scn->info != NULL);
-            INFO("Resetting size of section [%s] to %d\n",
-                 reloc_scn->info->name,
-                 d_size);
-            reloc_scn->data->d_size = d_size;
-        }
-    }
-
-    /* Now prelink those relocation sections which were fully handled, and
-       therefore removed.  They are not a part of the
-       source->relocation_sections[] array anymore, but we can find them by
-       scanning source->shdr_info[] and looking for sections with idx == 0.
-    */
-
-    if (ADJUST_ELF && source->shdr_info != NULL) {
-        /* Walk over the shdr_info[] array to see if we've removed any
-           relocation sections.  prelink() those sections as well.
-        */
-        int i;
-        for (i = 0; i < source->shnum; i++) {
-            shdr_info_t *info = source->shdr_info + i;
-            if (info->idx == 0 &&
-                (info->shdr.sh_type == SHT_REL ||
-                 info->shdr.sh_type == SHT_RELA)) {
-
-              Elf_Data *data = elf_getdata(info->scn, NULL);
-              ASSERT(data->d_size == 0);
-              data->d_size = info->old_shdr.sh_size;
-
-              INFO("\n\tIterating relocation section [%s], which was "
-                   "discarded (size %d, entry size %lld).\n",
-                   info->name,
-                   data->d_size,
-                   info->old_shdr.sh_entsize);
-
-              num_relocations +=
-                do_prelink(source,
-                           data, info->old_shdr.sh_entsize,
-                           NULL, /* the section was fully handled */
-                           locals_only, dry_run,
-                           lib_lookup_dirs, num_lib_lookup_dirs,
-                           default_libs, num_default_libs,
-                           num_unfinished_relocs);
-
-              data->d_size = 0;
-            }
-        }
-    }
-    return num_relocations;
-}
-
-static char * find_file(const char *libname,
-                        char **lib_lookup_dirs,
-                        int num_lib_lookup_dirs) {
-    if (libname[0] == '/') {
-        /* This is an absolute path name--just return it. */
-        /* INFO("ABSOLUTE PATH: [%s].\n", libname); */
-        return strdup(libname);
-    } else {
-        /* First try the working directory. */
-        int fd;
-        if ((fd = open(libname, O_RDONLY)) > 0) {
-            close(fd);
-            /* INFO("FOUND IN CURRENT DIR: [%s].\n", libname); */
-            return strdup(libname);
-        } else {
-            /* Iterate over all library paths.  For each path, append the file
-               name and see if there is a file at that place. If that fails,
-               bail out. */
-
-            char *name;
-            while (num_lib_lookup_dirs--) {
-                size_t lib_len = strlen(*lib_lookup_dirs);
-                /* one extra character for the slash, and another for the
-                   terminating NULL. */
-                name = (char *)MALLOC(lib_len + strlen(libname) + 2);
-                strcpy(name, *lib_lookup_dirs);
-                name[lib_len] = '/';
-                strcpy(name + lib_len + 1, libname);
-                if ((fd = open(name, O_RDONLY)) > 0) {
-                    close(fd);
-                    /* INFO("FOUND: [%s] in [%s].\n", libname, name); */
-                    return name;
-                }
-                INFO("NOT FOUND: [%s] in [%s].\n", libname, name);
-                free(name);
-            }
-        }
-    }
-    return NULL;
-}
-
-static void adjust_dynamic_segment_entry_size(source_t *source,
-                                              dt_rel_info_t *dyn)
-{
-    /* Update the size entry in the DT_DYNAMIC segment. */
-    GElf_Dyn *dyn_entry, dyn_entry_mem;
-    dyn_entry = gelf_getdyn(source->dynamic.data,
-                            dyn->sz_idx,
-                            &dyn_entry_mem);
-    FAILIF_LIBELF(NULL == dyn_entry, gelf_getdyn);
-    /* If we are calling this function to adjust the size of the dynamic entry,
-       then there should be some unfinished relocations remaining.  If there
-       are none, then we should remove the entry from the dynamic section
-       altogether.
-    */
-    ASSERT(dyn->num_unfinished_relocs);
-
-    size_t relsize = gelf_fsize(source->elf,
-                                ELF_T_REL,
-                                1,
-                                source->elf_hdr.e_version);
-
-    if (unlikely(verbose_flag)) {
-        char buf[64];
-        INFO("Updating entry %d: [%-10s], %08llx --> %08x\n",
-             dyn->sz_idx,
-             ebl_dynamic_tag_name (source->ebl, dyn_entry->d_tag,
-                                   buf, sizeof (buf)),
-             dyn_entry->d_un.d_val,
-             dyn->num_unfinished_relocs * relsize);
-    }
-
-    dyn_entry->d_un.d_val = dyn->num_unfinished_relocs * relsize;
-
-    FAILIF_LIBELF(!gelf_update_dyn(source->dynamic.data,
-                                   dyn->sz_idx,
-                                   dyn_entry),
-                  gelf_update_dyn);
-}
-
-static void adjust_dynamic_segment_entries(source_t *source)
-{
-    /* This function many remove entries from the dynamic segment, but it won't
-       resize the relevant section.  It'll just fill the remainted with empty
-       DT entries.
-
-       FIXME: This is not guaranteed right now.  If a dynamic segment does not
-       end with null DT entries, I think this will break.
-    */
-    FAILIF(source->rel.processed,
-           "More than one section matches DT_REL entry in dynamic segment!\n");
-    FAILIF(source->jmprel.processed,
-           "More than one section matches DT_JMPREL entry in "
-           "dynamic segment!\n");
-    source->rel.processed =
-      source->jmprel.processed = 1;
-
-    if (source->rel.num_unfinished_relocs > 0)
-        adjust_dynamic_segment_entry_size(source, &source->rel);
-
-    if (source->jmprel.num_unfinished_relocs > 0)
-        adjust_dynamic_segment_entry_size(source, &source->jmprel);
-
-    /* If at least one of the entries is empty, then we need to remove it.  We
-       have already adjusted the size of the other.
-    */
-    if (source->rel.num_unfinished_relocs == 0 ||
-        source->jmprel.num_unfinished_relocs == 0)
-    {
-        /* We need to delete the DT_REL/DT_RELSZ and DT_PLTREL/DT_PLTRELSZ
-           entries from the dynamic segment. */
-
-        GElf_Dyn *dyn_entry, dyn_entry_mem;
-        size_t dynidx, updateidx;
-
-        size_t numdyn =
-            source->dynamic.shdr.sh_size /
-            source->dynamic.shdr.sh_entsize;
-
-        for (updateidx = dynidx = 0; dynidx < numdyn; dynidx++)
-        {
-            dyn_entry = gelf_getdyn(source->dynamic.data,
-                                    dynidx,
-                                    &dyn_entry_mem);
-            FAILIF_LIBELF(NULL == dyn_entry, gelf_getdyn);
-            if ((source->rel.num_unfinished_relocs == 0 &&
-                 (dynidx == source->rel.idx ||
-                  dynidx == source->rel.sz_idx)) ||
-                (source->jmprel.num_unfinished_relocs == 0 &&
-                 (dynidx == source->jmprel.idx ||
-                  dynidx == source->jmprel.sz_idx)))
-            {
-                if (unlikely(verbose_flag)) {
-                    char buf[64];
-                    INFO("\t(!)\tRemoving entry %02d: [%-10s], %08llx\n",
-                         dynidx,
-                         ebl_dynamic_tag_name (source->ebl, dyn_entry->d_tag,
-                                               buf, sizeof (buf)),
-                         dyn_entry->d_un.d_val);
-                }
-                continue;
-            }
-
-            if (unlikely(verbose_flag)) {
-                char buf[64];
-                INFO("\t\tKeeping  entry %02d: [%-10s], %08llx\n",
-                     dynidx,
-                     ebl_dynamic_tag_name (source->ebl, dyn_entry->d_tag,
-                                           buf, sizeof (buf)),
-                     dyn_entry->d_un.d_val);
-            }
-
-            gelf_update_dyn(source->dynamic.data,
-                            updateidx,
-                            &dyn_entry_mem);
-            updateidx++;
-        }
-    }
-} /* adjust_dynamic_segment_entries */
-
-static bool adjust_dynamic_segment_for(source_t *source,
-                                       dt_rel_info_t *dyn,
-                                       bool adjust_section_size_only)
-{
-    bool dropped_sections = false;
-
-    /* Go over the sections that belong to this dynamic range. */
-    dyn->num_unfinished_relocs = 0;
-    if (dyn->sections) {
-        int num_scns, idx;
-        range_t *scns = get_sorted_ranges(dyn->sections, &num_scns);
-
-        INFO("\tdynamic range %s:[%lld, %lld) contains %d sections.\n",
-             source->name,
-             dyn->addr,
-             dyn->addr + dyn->size,
-             num_scns);
-
-        ASSERT(scns);
-        int next_idx = 0, next_rel_off = 0;
-        /* The total number of unfinished relocations for this dynamic
-         * entry. */
-        section_info_t *next = (section_info_t *)scns[next_idx].user;
-        section_info_t *first = next;
-        ASSERT(first);
-        for (idx = 0; idx < num_scns; idx++) {
-            section_info_t *reloc_scn = (section_info_t *)scns[idx].user;
-            size_t rel_scn_idx = reloc_scn - source->relocation_sections;
-            ASSERT(rel_scn_idx < (size_t)source->num_relocation_sections);
-            unfinished_relocation_t *unfinished =
-                &source->unfinished[rel_scn_idx];
-            int unf_idx;
-
-            ASSERT(reloc_scn->info == NULL ||
-                   reloc_scn->shdr.sh_name ==
-                   reloc_scn->info->old_shdr.sh_name);
-            const char *sname =
-              elf_strptr(source->oldelf,
-                         source->shstrndx,
-                         reloc_scn->shdr.sh_name);
-
-            INFO("\tsection [%s] contains %d unfinished relocs.\n",
-                 sname,
-                 unfinished->num_rels);
-
-            for (unf_idx = 0; unf_idx < unfinished->num_rels; unf_idx++)
-            {
-                /* There are unfinished relocations.  Copy them forward to the
-                   lowest section we can. */
-
-                while (next_rel_off == 
-                       (int)(next->shdr.sh_size/next->shdr.sh_entsize))
-                {
-                    INFO("\tsection [%s] has filled up with %d unfinished "
-                         "relocs.\n",
-                         sname,
-                         next_rel_off);
-
-                    next_idx++;
-                    ASSERT(next_idx <= idx);
-                    next = (section_info_t *)scns[next_idx].user;
-                    next_rel_off = 0;
-                }
-
-                if (!adjust_section_size_only) {
-                    INFO("\t\tmoving unfinished relocation %2d to [%s:%d]\n",
-                         unf_idx,
-                         sname,
-                         next_rel_off);
-                    FAILIF_LIBELF(0 ==
-                                  gelf_update_rel(next->data,
-                                                  next_rel_off,
-                                                  &unfinished->rels[unf_idx]),
-                                  gelf_update_rel);
-                }
-
-                next_rel_off++;
-                dyn->num_unfinished_relocs++;
-            }
-        } /* for */
-
-        /* Set the size of the last section, and mark all subsequent
-           sections for removal.  At this point, next is the section
-           to which we last wrote data, next_rel_off is the offset before
-           which we wrote the last relocation, and so next_rel_off *
-           relsize is the new size of the section.
-        */
-
-        bool adjust_file = ADJUST_ELF && source->elf_hdr.e_type != ET_EXEC;
-        if (adjust_file && !source->dry_run)
-        {
-            size_t relsize = gelf_fsize(source->elf,
-                                        ELF_T_REL,
-                                        1,
-                                        source->elf_hdr.e_version);
-
-            ASSERT(next->info == NULL ||
-                   next->shdr.sh_name == next->info->old_shdr.sh_name);
-            const char *sname =
-              elf_strptr(source->oldelf,
-                         source->shstrndx,
-                         next->shdr.sh_name);
-
-            INFO("\tsection [%s] (index %d) has %d unfinished relocs, "
-                 "changing its size to %ld bytes (from %ld bytes).\n",
-                 sname,
-                 elf_ndxscn(next->scn),
-                 next_rel_off,
-                 (long)(next_rel_off * relsize),
-                 (long)(next->shdr.sh_size));
-
-            /* source->shdr_info[] must be allocated prior to calling this
-               function.  This is in fact done in process_file(), by calling
-               setup_shdr_info() just before we call adjust_dynamic_segment().
-            */
-            ASSERT(source->shdr_info != NULL);
-
-            /* We do not update the data field of shdr_info[], because it does
-               not exist yet (with ADJUST_ELF != 0).  We create the new section
-               and section data after the first call to prelink().  For now, we
-               save the results of our analysis by modifying the sh_size field
-               of the section header.  When we create the new sections' data,
-               we set the size of the data from the sh_size fields of the
-               section headers.
-
-               NOTE: The assertion applies only to the first call of
-                     adjust_dynamic_segment (which calls this function).  By
-                     the second call, we've already created the data for the
-                     new sections.  The only sections for which we haven't
-                     created data are the relocation sections we are removing.
-            */
-#ifdef DEBUG
-            ASSERT((!adjust_section_size_only &&
-                    (source->shdr_info[elf_ndxscn(next->scn)].idx > 0)) ||
-                   source->shdr_info[elf_ndxscn(next->scn)].data == NULL);
-#endif
-
-            //FIXME: what else do we need to do here?  Do we need to update
-            //       another copy of the shdr so that it's picked up when we
-            //       commit the file?
-            next->shdr.sh_size = next_rel_off * relsize;
-            source->shdr_info[elf_ndxscn(next->scn)].shdr.sh_size =
-                next->shdr.sh_size;
-            if (next_rel_off * relsize == 0) {
-#ifdef REMOVE_HANDLED_SECTIONS
-                INFO("\tsection [%s] (index %d) is now empty, marking for "
-                     "removal.\n",
-                     sname,
-                     elf_ndxscn(next->scn));
-                source->shdr_info[elf_ndxscn(next->scn)].idx = 0;
-                dropped_sections = true;
-#endif
-            }
-
-            while (++next_idx < num_scns) {
-                next = (section_info_t *)scns[next_idx].user;
-#ifdef REMOVE_HANDLED_SECTIONS
-                ASSERT(next->info == NULL ||
-                       next->shdr.sh_name == next->info->old_shdr.sh_name);
-                const char *sname =
-                  elf_strptr(source->oldelf,
-                             source->shstrndx,
-                             next->shdr.sh_name);
-                INFO("\tsection [%s] (index %d) is now empty, marking for "
-                     "removal.\n",
-                     sname,
-                     elf_ndxscn(next->scn));
-                /* mark for removal */
-                source->shdr_info[elf_ndxscn(next->scn)].idx = 0;
-                dropped_sections = true;
-#endif
-            }
-        }
-
-    } /* if (dyn->sections) */
-    else {
-        /* The dynamic entry won't have any sections when it itself doesn't
-           exist.  This could happen when we remove all relocation sections
-           from a dynamic entry because we have managed to handle all
-           relocations in them.
-        */
-        INFO("\tNo section for dynamic entry!\n");
-    }
-
-    return dropped_sections;
-}
-
-static bool adjust_dynamic_segment(source_t *source,
-                                   bool adjust_section_size_only)
-{
-    bool dropped_section;
-    INFO("Adjusting dynamic segment%s.\n",
-         (adjust_section_size_only ? " (section sizes only)" : ""));
-    INFO("\tadjusting dynamic segment REL.\n");
-    dropped_section =
-        adjust_dynamic_segment_for(source, &source->rel,
-                                   adjust_section_size_only);
-    INFO("\tadjusting dynamic segment JMPREL.\n");
-    dropped_section =
-        adjust_dynamic_segment_for(source, &source->jmprel,
-                                   adjust_section_size_only) ||
-        dropped_section;
-    if (!adjust_section_size_only)
-        adjust_dynamic_segment_entries(source);
-    return dropped_section;
-}
-
-static void match_relocation_sections_to_dynamic_ranges(source_t *source)
-{
-    /* We've gathered all the DT_DYNAMIC entries; now we need to figure out
-       which relocation sections fit in which range as described by the
-       entries.
-    */
-
-    int relidx;
-    for (relidx = 0; relidx < source->num_relocation_sections; relidx++) {
-        section_info_t *reloc_scn = &source->relocation_sections[relidx];
-
-        int index = elf_ndxscn(reloc_scn->scn);
-
-        ASSERT(reloc_scn->info == NULL ||
-               reloc_scn->shdr.sh_name == reloc_scn->info->old_shdr.sh_name);
-        const char *sname =
-          elf_strptr(source->oldelf,
-                     source->shstrndx,
-                     reloc_scn->shdr.sh_name);
-
-        INFO("Checking section [%s], index %d, for match to dynamic ranges\n",
-             sname, index);
-        if (source->shdr_info == NULL || reloc_scn->info->idx > 0) {
-            if (source->rel.addr &&
-                source->rel.addr <= reloc_scn->shdr.sh_addr &&
-                reloc_scn->shdr.sh_addr < source->rel.addr + source->rel.size)
-                {
-                    /* The entire section must fit in the dynamic range. */
-                    if((reloc_scn->shdr.sh_addr + reloc_scn->shdr.sh_size) >
-                       (source->rel.addr + source->rel.size))
-                        {
-                            PRINT("WARNING: In [%s], section %s:[%lld,%lld) "
-                                  "is not fully contained in dynamic range "
-                                  "[%lld,%lld)!\n",
-                                  source->name,
-                                  sname,
-                                  reloc_scn->shdr.sh_addr,
-                                  reloc_scn->shdr.sh_addr +
-                                      reloc_scn->shdr.sh_size,
-                                  source->rel.addr,
-                                  source->rel.addr + source->rel.size);
-                        }
-
-                    if (NULL == source->rel.sections) {
-                        source->rel.sections = init_range_list();
-                        ASSERT(source->rel.sections);
-                    }
-                    add_unique_range_nosort(source->rel.sections,
-                                            reloc_scn->shdr.sh_addr,
-                                            reloc_scn->shdr.sh_size,
-                                            reloc_scn,
-                                            NULL,
-                                            NULL);
-                    INFO("\tSection [%s] matches dynamic range REL.\n",
-                         sname);
-                }
-            else if (source->jmprel.addr &&
-                     source->jmprel.addr <= reloc_scn->shdr.sh_addr &&
-                     reloc_scn->shdr.sh_addr <= source->jmprel.addr +
-                     source->jmprel.size)
-                {
-                    if((reloc_scn->shdr.sh_addr + reloc_scn->shdr.sh_size) >
-                       (source->jmprel.addr + source->jmprel.size))
-                        {
-                            PRINT("WARNING: In [%s], section %s:[%lld,%lld) "
-                                  "is not fully "
-                                  "contained in dynamic range [%lld,%lld)!\n",
-                                  source->name,
-                                  sname,
-                                  reloc_scn->shdr.sh_addr,
-                                  reloc_scn->shdr.sh_addr +
-                                      reloc_scn->shdr.sh_size,
-                                  source->jmprel.addr,
-                                  source->jmprel.addr + source->jmprel.size);
-                        }
-
-                    if (NULL == source->jmprel.sections) {
-                        source->jmprel.sections = init_range_list();
-                        ASSERT(source->jmprel.sections);
-                    }
-                    add_unique_range_nosort(source->jmprel.sections,
-                                            reloc_scn->shdr.sh_addr,
-                                            reloc_scn->shdr.sh_size,
-                                            reloc_scn,
-                                            NULL,
-                                            NULL);
-                    INFO("\tSection [%s] matches dynamic range JMPREL.\n",
-                         sname);
-                }
-            else
-                PRINT("WARNING: Relocation section [%s:%s] does not match "
-                      "any DT_ entry.\n",
-                      source->name,
-                      sname);
-        }
-        else {
-            INFO("Section [%s] was removed, not matching it to dynamic "
-                 "ranges.\n",
-                 sname);
-        }
-    } /* for ... */
-
-    if (source->rel.sections) sort_ranges(source->rel.sections);
-    if (source->jmprel.sections) sort_ranges(source->jmprel.sections);
-}
-
-static void drop_sections(source_t *source)
-{
-    INFO("We are dropping some sections from [%s]--creating section entries "
-         "only for remaining sections.\n",
-         source->name);
-    /* Renumber the sections.  The numbers for the sections after those we are
-       dropping will be shifted back by the number of dropped sections. */
-    int cnt, idx;
-    for (cnt = idx = 1; cnt < source->shnum; ++cnt) {
-        if (source->shdr_info[cnt].idx > 0) {
-            source->shdr_info[cnt].idx = idx++;
-            
-            /* Create a new section. */
-            FAILIF_LIBELF((source->shdr_info[cnt].newscn =
-                           elf_newscn(source->elf)) == NULL, elf_newscn);
-            ASSERT(elf_ndxscn (source->shdr_info[cnt].newscn) ==
-                   source->shdr_info[cnt].idx);
-            
-            /* Copy the section data */
-            Elf_Data *olddata =
-                elf_getdata(source->shdr_info[cnt].scn, // old section
-                            NULL);
-            FAILIF_LIBELF(NULL == olddata, elf_getdata);
-            Elf_Data *data = 
-                elf_newdata(source->shdr_info[cnt].newscn);
-            FAILIF_LIBELF(NULL == data, elf_newdata);
-            *data = *olddata;
-#if COPY_SECTION_DATA_BUFFER
-            if (olddata->d_buf != NULL) {
-                data->d_buf = MALLOC(data->d_size);
-                memcpy(data->d_buf, olddata->d_buf, olddata->d_size);
-            }
-#endif
-            source->shdr_info[cnt].data = data;
-            
-            if (data->d_size !=
-                source->shdr_info[cnt].shdr.sh_size) {
-                INFO("Trimming new-section data from %d to %lld bytes "
-                     "(as calculated by adjust_dynamic_segment()).\n",
-                     data->d_size,
-                     source->shdr_info[cnt].shdr.sh_size);
-                data->d_size =
-                    source->shdr_info[cnt].shdr.sh_size;
-            }
-            
-            INFO("\tsection [%s] (old offset %lld, old size %lld) "
-                 "will have index %d (was %d), new size %d\n",
-                 source->shdr_info[cnt].name,
-                 source->shdr_info[cnt].old_shdr.sh_offset,
-                 source->shdr_info[cnt].old_shdr.sh_size,
-                 source->shdr_info[cnt].idx,
-                 elf_ndxscn(source->shdr_info[cnt].scn),
-                 data->d_size);
-        } else {
-            INFO("\tIgnoring section [%s] (offset %lld, size %lld, index %d), "
-                 "it will be discarded.\n",
-                 source->shdr_info[cnt].name,
-                 source->shdr_info[cnt].shdr.sh_offset,
-                 source->shdr_info[cnt].shdr.sh_size,
-                 elf_ndxscn(source->shdr_info[cnt].scn));
-        }
-
-        /* NOTE: We mark use_old_shdr_for_relocation_calculations even for the
-           sections we are removing.  adjust_elf has an assertion that makes
-           sure that if the values for the size of a section according to its
-           header and its data structure differ, then we are using explicitly
-           the old section header for calculations, and that the section in
-           question is a relocation section.
-        */
-        source->shdr_info[cnt].use_old_shdr_for_relocation_calculations = true;
-    } /* for */
-}
-
-static source_t* process_file(const char *filename,
-                              const char *output, int is_file,
-                              void (*report_library_size_in_memory)(
-                                  const char *name, off_t fsize),
-                              unsigned (*get_next_link_address)(
-                                  const char *name),
-                              int locals_only,
-                              char **lib_lookup_dirs,
-                              int num_lib_lookup_dirs,
-                              char **default_libs,
-                              int num_default_libs,
-                              int dry_run,
-                              int *total_num_handled_relocs,
-                              int *total_num_unhandled_relocs)
-{
-    /* Look up the file in the list of already-handles files, which are
-       represented by source_t structs.  If we do not find the file, then we
-       haven't prelinked it yet.  If we find it, then we have, so we do
-       nothing.  Keep in mind that apriori operates on an entire collection
-       of files, and if application A used library L, and so does application
-       B, if we process A first, then by the time we get to B we will have
-       prelinked L already; that's why we check first to see if a library has
-       been prelinked.
-    */
-    source_t *source =
-        find_source(filename, lib_lookup_dirs, num_lib_lookup_dirs);
-    if (NULL == source) {
-        /* If we could not find the source, then it hasn't been processed yet,
-           so we go ahead and process it! */
-        INFO("Processing [%s].\n", filename);
-        char *full = find_file(filename, lib_lookup_dirs, num_lib_lookup_dirs);
-        FAILIF(NULL == full,
-               "Could not find [%s] in the current directory or in any of "
-               "the search paths!\n", filename);
-
-        unsigned base = get_next_link_address(full);
-
-        source = init_source(full, output, is_file, base, dry_run);
-
-        if (source == NULL) {
-            INFO("File [%s] is a static executable.\n", filename);
-            return NULL;
-        }
-		ASSERT(source->dynamic.scn != NULL);
-
-        /* We need to increment the next prelink address only when the file we
-           are currently handing is a shared library.  Executables do not need
-           to be prelinked at a different address, they are always at address
-           zero.
-
-           Also, if we are prelinking locals only, then we are handling a
-           single file per invokation of apriori, so there is no need to
-           increment the prelink address unless there is a global prelink map,
-           in which case we do need to check to see if the library isn't
-           running into its neighbouts in the prelink map.
-        */
-        if (source->oldelf_hdr.e_type != ET_EXEC && 
-            (!locals_only ||
-             report_library_size_in_memory == 
-             pm_report_library_size_in_memory)) {
-            /* This sets the next link address only if an increment was not
-               specified by the user.  If an address increment was specified,
-               then we just check to make sure that the file size is less than
-               the increment.
-
-               NOTE: The file size is the absolute highest number of bytes that
-               the file may occupy in memory, if the entire file is loaded, but
-               this is almost next the case.  A file will often have sections
-               which are not loaded, which could add a lot of size.  That's why
-               we start off with the file size and then subtract the size of
-               the biggest sections that will not get loaded, which are the
-               varios DWARF sections, all of which of which are named starting
-               with ".debug_".
-
-               We could do better than this (by caculating exactly how many
-               bytes from that file will be loaded), but that's an overkill.
-               Unless the prelink-address increment becomes too small, the file
-               size after subtracting the sizes of the DWARF section will be a
-               good-enough upper bound.
-            */
-
-            unsigned long fsize = source->elf_file_info.st_size;
-            INFO("Calculating loadable file size for next link address.  "
-                 "Starting with %ld.\n", fsize);
-            if (true) {
-                Elf_Scn *scn = NULL;
-                GElf_Shdr shdr_mem, *shdr;
-                const char *scn_name;
-                while ((scn = elf_nextscn (source->oldelf, scn)) != NULL) {
-                    shdr = gelf_getshdr(scn, &shdr_mem);
-                    FAILIF_LIBELF(NULL == shdr, gelf_getshdr);
-                    scn_name = elf_strptr (source->oldelf,
-                                           source->shstrndx, shdr->sh_name);
-                    ASSERT(scn_name != NULL);
-
-                    if (!(shdr->sh_flags & SHF_ALLOC)) {
-                        INFO("\tDecrementing by %lld on account of section "
-                             "[%s].\n",
-                             shdr->sh_size,
-                             scn_name);
-                        fsize -= shdr->sh_size;
-                    }                    
-                }
-            }
-            INFO("Done calculating loadable file size for next link address: "
-                 "Final value is %ld.\n", fsize);
-            report_library_size_in_memory(source->name, fsize);
-        }
-
-        /* Identify the dynamic segment and process it.  Specifically, we find
-           out what dependencies, if any, this file has.  Whenever we encounter
-           such a dependency, we process it recursively; we find out where the
-           various relocation information sections are stored. */
-
-        size_t dynidx;
-        GElf_Dyn *dyn, dyn_mem;
-        size_t numdyn =
-            source->dynamic.shdr.sh_size /
-            source->dynamic.shdr.sh_entsize;
-        ASSERT(source->dynamic.shdr.sh_size == source->dynamic.data->d_size);
-
-        source->rel.idx = source->rel.sz_idx = -1;
-        source->jmprel.idx = source->jmprel.sz_idx = -1;
-
-        for (dynidx = 0; dynidx < numdyn; dynidx++) {
-            dyn = gelf_getdyn (source->dynamic.data,
-                               dynidx,
-                               &dyn_mem);
-            FAILIF_LIBELF(NULL == dyn, gelf_getdyn);
-            /* When we are processing only the local relocations in a file,
-               we don't need to handle any of the dependencies.  It won't
-               hurt if we do, but we will be doing unnecessary work.
-            */
-            switch (dyn->d_tag)
-            {
-            case DT_NEEDED:
-                if (!locals_only) {
-                    /* Process the needed library recursively.
-                     */
-                    const char *dep_lib =
-#if ELF_STRPTR_IS_BROKEN
-                        (((char *)elf_getdata(
-                            elf_getscn(source->elf,
-                                       source->dynamic.shdr.sh_link),
-                            NULL)->d_buf) + dyn->d_un.d_val);
-#else
-                    elf_strptr (source->elf,
-                                source->dynamic.shdr.sh_link,
-                                dyn->d_un.d_val);
-#endif
-                    ASSERT(dep_lib != NULL);
-                    INFO("[%s] depends on [%s].\n", filename, dep_lib);
-                    ASSERT(output == NULL || is_file == 0);
-                    source_t *dep = process_file(dep_lib,
-                                                 output, is_file,
-                                                 report_library_size_in_memory,
-                                                 get_next_link_address,
-                                                 locals_only,
-                                                 lib_lookup_dirs,
-                                                 num_lib_lookup_dirs,
-                                                 default_libs,
-                                                 num_default_libs,
-                                                 dry_run,
-                                                 total_num_handled_relocs,
-                                                 total_num_unhandled_relocs);
-
-                    /* Add the library to the dependency list. */
-                    if (source->num_lib_deps == source->lib_deps_size) {
-                        source->lib_deps_size += 10;
-                        source->lib_deps = REALLOC(source->lib_deps,
-                                                   source->lib_deps_size *
-                                                   sizeof(source_t *));
-                    }
-                    source->lib_deps[source->num_lib_deps++] = dep;
-                }
-                break;
-            case DT_JMPREL:
-                source->jmprel.idx = dynidx;
-                source->jmprel.addr = dyn->d_un.d_ptr;
-                break;
-            case DT_PLTRELSZ:
-                source->jmprel.sz_idx = dynidx;
-                source->jmprel.size = dyn->d_un.d_val;
-                break;
-            case DT_REL:
-                source->rel.idx = dynidx;
-                source->rel.addr = dyn->d_un.d_ptr;
-                break;
-            case DT_RELSZ:
-                source->rel.sz_idx = dynidx;
-                source->rel.size = dyn->d_un.d_val;
-                break;
-            case DT_RELA:
-            case DT_RELASZ:
-                FAILIF(1, "Can't handle DT_RELA and DT_RELASZ entries!\n");
-                break;
-            } /* switch */
-        } /* for each dynamic entry... */
-
-        INFO("Handling [%s].\n", filename);
-
-#ifdef SUPPORT_ANDROID_PRELINK_TAGS
-        if (!source->prelinked)
-#endif
-		{
-            /* When ADJUST_ELF is defined, this call to prelink is a dry run
-               intended to calculate the number of relocations that could not
-               be handled.  This, in turn, allows us to calculate the amount by
-               which we can shrink the various relocation sections before we
-               call adjust_elf.  After we've adjusted the sections, we will
-               call prelink() one more time to do the actual work.
-
-               NOTE: Even when ADJUST_ELF != 0, we cannot adjust an ELF file
-               that is an executabe, because an executable is not PIC.
-            */
-
-            int num_unfinished_relocs = 0;
-            bool adjust_file = ADJUST_ELF && source->elf_hdr.e_type != ET_EXEC;
-            INFO("\n\n\tPRELINKING %s\n\n",
-                 adjust_file ?
-                 "(CALCULATE NUMBER OF HANDLED RELOCATIONS)" :
-                 "(ACTUAL)");
-            int num_relocs = prelink(source, locals_only,
-                                     adjust_file || dry_run,
-                                     lib_lookup_dirs, num_lib_lookup_dirs,
-                                     default_libs, num_default_libs,
-                                     &num_unfinished_relocs);
-            INFO("[%s]: (calculate changes) handled %d, could not handle %d "
-                 "relocations.\n",
-                 source->name,
-                 num_relocs,
-                 num_unfinished_relocs);
-
-            if (adjust_file && !dry_run)
-            {
-                /* Find out the new section sizes of the relocation sections,
-                   but do not move any relocations around, because adjust_elf
-                   needs to know about all relocations in order to adjust the
-                   file correctly.
-                */
-                match_relocation_sections_to_dynamic_ranges(source);
-
-                /* We haven't set up source->shdr_info[] yet, so we do it now.
-
-                   NOTE: setup_shdr_info() depends only on source->oldelf, not
-                   on source->elf!  source->elf is not even defined yet.  We
-                   initialize source->shdr_info[] based on the section
-                   information of the unmodified ELF file, and then make our
-                   modifications in the call to adjust_dynamic_segment() based
-                   on this information.  adjust_dynamic_segment() will
-                   rearrange the unhandled relocations in the beginning of
-                   their relocation sections, and adjust the size of those
-                   relocation sections.  In the case when a relocation section
-                   is completely handled, adjust_dynamic_segment() will mark it
-                   for removal by function adjust_elf.
-                 */
-
-                ASSERT(source->elf == source->oldelf);
-                ASSERT(source->shdr_info == NULL);
-                setup_shdr_info(source);
-                ASSERT(source->shdr_info != NULL);
-
-                INFO("\n\n\tADJUSTING DYNAMIC SEGMENT "
-                     "(CALCULATE CHANGES)\n\n");
-                bool drop_some_sections = adjust_dynamic_segment(source, true);
-
-                /* Reopen the elf file!  Note that we are not doing a dry run
-                   (the if statement above makes sure of that.)
-
-                   NOTE: We call init_elf() after we called
-                         adjust_dynamic_segment() in order to have
-                         adjust_dynamic_segment() refer to source->oldelf when
-                         it refers to source->elf.  Since
-                         adjust_dynamic_segment doesn't actually write to the
-                         ELF file, this is OK.  adjust_dynamic_segment()
-                         updates the sh_size fields of saved section headers
-                         and optionally marks sections for removal.
-
-                         Having adjust_dynamic_segment() refer to
-                         source->oldelf means that we'll have access to
-                         section-name strings so we can print them out in our
-                         logging and debug output.
-                */
-                source->elf = init_elf(source, false);
-
-                /* This is the same code as in init_source() after the call to
-                 * init_elf(). */
-                ASSERT(source->elf != source->oldelf);
-                ebl_closebackend(source->ebl);
-                source->ebl = ebl_openbackend (source->elf);
-                FAILIF_LIBELF(NULL == source->ebl, ebl_openbackend);
-#ifdef ARM_SPECIFIC_HACKS
-                FAILIF_LIBELF(0 != arm_init(source->elf,
-                                            source->elf_hdr.e_machine,
-                                            source->ebl, sizeof(Ebl)),
-                              arm_init);
-#endif/*ARM_SPECIFIC_HACKS*/
-
-                if (drop_some_sections)
-                    drop_sections(source);
-                else {
-                  INFO("All sections remain in [%s]--we are changing at "
-                       "most section sizes.\n", source->name);
-                    create_elf_sections(source, NULL);
-                    int cnt, idx;
-                    for (cnt = idx = 1; cnt < source->shnum; ++cnt) {
-                        Elf_Data *data = elf_getdata(
-                            source->shdr_info[cnt].newscn, // new section
-                            NULL);
-                        if (data->d_size !=
-                            source->shdr_info[cnt].shdr.sh_size) {
-                            INFO("Trimming new-section data from %d to %lld "
-                                 "bytes (as calculated by "
-                                 "adjust_dynamic_segment()).\n",
-                                 data->d_size,
-                                 source->shdr_info[cnt].shdr.sh_size);
-                            data->d_size = source->shdr_info[cnt].shdr.sh_size;
-                        }
-                    }
-                }
-
-                /* Shrink it! */
-                INFO("\n\n\tADJUSTING ELF\n\n");
-                adjust_elf(
-                    source->oldelf, source->name,
-                    source->elf, source->name,
-                    source->ebl,
-                    &source->old_ehdr_mem,
-                    NULL, 0, // no symbol filter
-                    source->shdr_info, // information on how to adjust the ELF
-                    source->shnum, // length of source->shdr_info[]
-                    source->phdr_info, // program-header info
-                    source->shnum, // irrelevant--we're not rebuilding shstrtab
-                    source->shnum, // number of sections in file
-                    source->shstrndx, // index of shstrtab (both in 
-                                      // shdr_info[] and as a section index)
-                    NULL, // irrelevant, since we are not rebuilding shstrtab
-                    drop_some_sections, // some sections are being dropped
-                    elf_ndxscn(source->dynamic.scn), // index of .dynamic
-                    elf_ndxscn(source->symtab.scn), // index of .dynsym
-                    1, // allow shady business
-                    &source->shstrtab_data,
-                    true,
-                    false); // do not rebuild shstrtab
-
-                INFO("\n\n\tREINITIALIZING STRUCTURES "
-                     "(TO CONTAIN ADJUSTMENTS)\n\n");
-                reinit_source(source);
-
-                INFO("\n\n\tPRELINKING (ACTUAL)\n\n");
-#ifdef DEBUG
-                int old_num_unfinished_relocs = num_unfinished_relocs;
-#endif
-                num_unfinished_relocs = 0;
-#ifdef DEBUG
-                int num_relocs_take_two =
-#endif
-                prelink(source, locals_only,
-                        false, /* not a dry run */
-                        lib_lookup_dirs, num_lib_lookup_dirs,
-                        default_libs, num_default_libs,
-                        &num_unfinished_relocs);
-
-                /* The numbers for the total number of relocations and the
-                   number of unhandled relocations between the first and second
-                   invokationof prelink() must be the same!  The first time we
-                   ran prelink() just to calculate the numbers so that we could
-                   calculate the adjustments to pass to adjust_elf, and the
-                   second time we actually carry out the prelinking; the
-                   numbers must stay the same!
-                */
-                ASSERT(num_relocs == num_relocs_take_two);
-                ASSERT(old_num_unfinished_relocs == num_unfinished_relocs);
-
-                INFO("[%s]: (actual prelink) handled %d, could not "
-                     "handle %d relocations.\n",
-                     source->name,
-                     num_relocs,
-                     num_unfinished_relocs);
-            } /* if (adjust_elf && !dry_run) */
-
-            *total_num_handled_relocs += num_relocs;
-            *total_num_unhandled_relocs += num_unfinished_relocs;
-
-            if(num_unfinished_relocs != 0 &&
-               source->elf_hdr.e_type != ET_EXEC &&
-               !locals_only)
-            {
-                /* One reason you could have unfinished relocations in an
-                   executable file is if this file used dlopen() and friends.
-                   We do not adjust relocation entries to those symbols,
-                   because libdl is a dummy only--the real functions are
-                   provided for by the dynamic linker itsef.
-
-                   NOTE FIXME HACK:  This is specific to the Android dynamic
-                   linker, and may not be true in other cases.
-                */
-                PRINT("WARNING: Expecting to have unhandled relocations only "
-                      "for executables (%s is not an executable)!\n",
-                      source->name);
-            }
-
-            match_relocation_sections_to_dynamic_ranges(source);
-
-            /* Now, for each relocation section, check to see if its address
-               matches one of the DT_DYNAMIC relocation pointers.  If so, then
-               if the section has no unhandled relocations, simply set the
-               associated DT_DYNAMIC entry's size to zero.  If the section does
-               have unhandled entries, then lump them all together at the front
-               of the respective section and update the size of the respective
-               DT_DYNAMIC entry to the new size of the section.  A better
-               approach would be do delete a relocation section if it has been
-               fully relocated and to remove its entry from the DT_DYNAMIC
-               array, and for relocation entries that still have some
-               relocations in them, we should shrink the section if that won't
-               violate relative offsets.  This is more work, however, and for
-               the speed improvement we expect from a prelinker, just patching
-               up DT_DYNAMIC will suffice.
-
-               Note: adjust_dynamic_segment() will modify source->shdr_info[]
-                     to denote any change in a relocation section's size.  This
-                     will be picked up by adjust_elf, which will rearrange the
-                     file to eliminate the gap created by the decrease in size
-                     of the relocation section.  We do not need to do this, but
-                     the relocation section could be large, and reduced
-                     drastically by the prelinking process, so it pays to
-                     adjust the file.
-            */
-
-            INFO("\n\n\tADJUSTING DYNAMIC SEGMENT (ACTUAL)\n\n");
-            adjust_dynamic_segment(source, false);
-        }
-#ifdef SUPPORT_ANDROID_PRELINK_TAGS
-        else INFO("[%s] is already prelinked at 0x%08lx.\n",
-                  filename,
-                  source->prelink_base);
-#endif
-    } else INFO("[%s] has been processed already.\n", filename);
-
-    return source;
-}
-
-void apriori(char **execs, int num_execs,
-             char *output,
-             void (*report_library_size_in_memory)(
-                 const char *name, off_t fsize),
-             int (*get_next_link_address)(const char *name),
-             int locals_only,
-             int dry_run,
-             char **lib_lookup_dirs, int num_lib_lookup_dirs,
-             char **default_libs, int num_default_libs,
-			 char *mapfile)
-{
-    source_t *source; /* for general usage */
-    int input_idx;
-
-    ASSERT(report_library_size_in_memory != NULL);
-    ASSERT(get_next_link_address != NULL);
-
-    /* Process and prelink each executable and object file.  Function
-       process_file() is called for each executable in the loop below.
-       It calls itself recursively for each library.   We prelink each library
-       after prelinking its dependencies. */
-    int total_num_handled_relocs = 0, total_num_unhandled_relocs = 0;
-    for (input_idx = 0; input_idx < num_execs; input_idx++) {
-        INFO("executable: [%s]\n", execs[input_idx]);
-        /* Here process_file() is actually processing the top-level
-           executable files. */
-        process_file(execs[input_idx], output, num_execs == 1,
-                     report_library_size_in_memory,
-                     get_next_link_address, /* executables get a link address
-                                               of zero, regardless of this 
-                                               value */
-                     locals_only,
-                     lib_lookup_dirs, num_lib_lookup_dirs,
-                     default_libs, num_default_libs,
-                     dry_run,
-                     &total_num_handled_relocs,
-                     &total_num_unhandled_relocs);
-        /* if source is NULL, then the respective executable is static */
-        /* Mark the source as an executable */
-    } /* for each input executable... */
-
-    PRINT("Handled %d relocations.\n", total_num_handled_relocs);
-    PRINT("Could not handle %d relocations.\n", total_num_unhandled_relocs);
-
-    /* We are done!  Since the end result of our calculations is a set of
-       symbols for each library that other libraries or executables link
-       against, we iterate over the set of libraries one last time, and for
-       each symbol that is marked as satisfying some dependence, we emit
-       a line with the symbol's name to a text file derived from the library's
-       name by appending the suffix .syms to it. */
-
-    if (mapfile != NULL) {
-        const char *mapfile_name = mapfile;
-		FILE *fp;
-        if (*mapfile == '+') {
-            mapfile_name = mapfile + 1;
-            INFO("Opening map file %s for append/write.\n",
-                 mapfile_name);
-            fp = fopen(mapfile_name, "a");
-        }
-        else fp = fopen(mapfile_name, "w");
-
-		FAILIF(fp == NULL, "Cannot open file [%s]: %s (%d)!\n",
-			   mapfile_name,
-			   strerror(errno),
-			   errno);
-        source = sources;
-        while (source) {
-            /* If it's a library, print the results. */
-            if (source->elf_hdr.e_type == ET_DYN) {
-                /* Add to the memory map file. */
-				fprintf(fp, "%s 0x%08lx %lld\n",
-						basename(source->name),
-						source->base,
-						source->elf_file_info.st_size);
-            }
-            source = source->next;
-        }
-		fclose(fp);
-    }
-
-    /* Free the resources--you can't do it in the loop above because function
-       print_symbol_references() accesses nodes other than the one being
-       iterated over.
-     */
-    source = sources;
-    while (source) {
-        source_t *old = source;
-        source = source->next;
-        /* Destroy the evidence. */
-        destroy_source(old);
-    }
-}
diff --git a/tools/apriori/apriori.h b/tools/apriori/apriori.h
deleted file mode 100644
index 5e396fd..0000000
--- a/tools/apriori/apriori.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef LSD_H
-#define LSD_H
-
-void apriori(char **execs, int num_execs,
-             char *output,
-             void (*set_next_link_address)(const char *name, off_t fsize),
-             int (*get_next_link_address)(const char *name),
-             int locals_only,
-             int dry_run,
-             char **lib_lookup_dirs, int num_lib_lookup_dirs,
-             char **default_libs, int num_default_libs,
-			 char *mapfile);
-
-#endif
diff --git a/tools/apriori/cmdline.c b/tools/apriori/cmdline.c
deleted file mode 100644
index 95f112a..0000000
--- a/tools/apriori/cmdline.c
+++ /dev/null
@@ -1,186 +0,0 @@
-#include <debug.h>
-#include <cmdline.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <getopt.h>
-#include <string.h>
-#include <ctype.h>
-
-extern char *optarg;
-extern int optind, opterr, optopt;
-
-static struct option long_options[] = {
-    {"start-address", required_argument, 0, 's'},
-    {"inc-address",   required_argument, 0, 'i'},
-    {"locals-only",   no_argument,       0, 'l'},
-    {"quiet",         no_argument,       0, 'Q'},
-    {"noupdate",      no_argument,       0, 'n'},
-    {"lookup",        required_argument, 0, 'L'},
-    {"default",       required_argument, 0, 'D'},
-    {"verbose",       no_argument,       0, 'V'},
-    {"help",          no_argument,       0, 'h'},
-	{"mapfile",       required_argument, 0, 'M'},
-	{"output",        required_argument, 0, 'o'},
-    {"prelinkmap",    required_argument, 0, 'p'},
-    {0, 0, 0, 0},
-};
-
-/* This array must parallel long_options[] */
-static const char *descriptions[] = {
-    "start address to prelink libraries to",
-    "address increment for each library",
-    "prelink local relocations only",
-    "suppress informational and non-fatal error messages",
-    "do a dry run--calculate the prelink info but do not update any files",
-    "provide a directory for library lookup",
-    "provide a default library or executable for symbol lookup",
-    "print verbose output",
-    "print help screen",
-	"print a list of prelink addresses to file (prefix filename with + to append instead of overwrite)",
-    "specify an output directory (if multiple inputs) or file (is single input)",
-    "specify a file with prelink addresses instead of a --start-address/--inc-address combination",
-};
-
-void print_help(const char *name) {
-    fprintf(stdout,
-            "invokation:\n"
-            "\t%s file1 [file2 file3 ...] -Ldir1 [-Ldir2 ...] -saddr -iinc [-Vqn] [-M<logfile>]\n"
-            "\t%s -l file [-Vqn] [-M<logfile>]\n"
-            "\t%s -h\n\n", name, name, name);
-    fprintf(stdout, "options:\n");
-    struct option *opt = long_options;
-    const char **desc = descriptions;
-    while (opt->name) {
-        fprintf(stdout, "\t-%c/--%s%s: %s\n",
-                opt->val,
-                opt->name,
-                (opt->has_arg ? " (argument)" : ""),
-                *desc);
-        opt++;
-        desc++;
-    }
-}
-
-int get_options(int argc, char **argv,
-                int *start_addr,
-                int *inc_addr,
-                int *locals_only,
-                int *quiet,
-                int *dry_run,
-                char ***dirs,
-                int *num_dirs,
-                char ***defaults,
-                int *num_defaults,
-                int *verbose,
-				char **mapfile,
-                char **output,
-                char **prelinkmap) {
-    int c;
-
-    ASSERT(dry_run); *dry_run = 0;
-    ASSERT(quiet); *quiet = 0;
-    ASSERT(verbose); *verbose = 0;
-    ASSERT(dirs); *dirs = NULL;
-    ASSERT(num_dirs); *num_dirs = 0;
-    ASSERT(defaults); *defaults = NULL;
-    ASSERT(num_defaults); *num_defaults = 0;
-    ASSERT(start_addr); *start_addr = -1;
-    ASSERT(inc_addr); *inc_addr =   -1;
-    ASSERT(locals_only); *locals_only = 0;
-	ASSERT(mapfile); *mapfile = NULL;
-	ASSERT(output); *output = NULL;
-    ASSERT(prelinkmap); *prelinkmap = NULL;
-    int dirs_size = 0;
-    int defaults_size = 0;
-
-    while (1) {
-        /* getopt_long stores the option index here. */
-        int option_index = 0;
-
-        c = getopt_long (argc, argv,
-                         "VhnQlL:D:s:i:M:o:p:",
-                         long_options,
-                         &option_index);
-        /* Detect the end of the options. */
-        if (c == -1) break;
-
-        if (isgraph(c)) {
-            INFO ("option -%c with value `%s'\n", c, (optarg ?: "(null)"));
-        }
-
-#define SET_STRING_OPTION(name) do {                                   \
-    ASSERT(optarg);                                                    \
-    (*name) = strdup(optarg);                                          \
-} while(0)
-
-#define SET_REPEATED_STRING_OPTION(arr, num, size) do {                \
-	if (*num == size) {                                                \
-		size += 10;                                                    \
-		*arr = (char **)REALLOC(*arr, size * sizeof(char *));          \
-	}                                                                  \
-	SET_STRING_OPTION(((*arr) + *num));                                \
-	(*num)++;                                                          \
-} while(0)
-
-#define SET_INT_OPTION(val) do {                                       \
-    ASSERT(optarg);                                                    \
-	if (strlen(optarg) >= 2 && optarg[0] == '0' && optarg[1] == 'x') { \
-			FAILIF(1 != sscanf(optarg+2, "%x", val),                   \
-				   "Expecting a hexadecimal argument!\n");             \
-	} else {                                                           \
-		FAILIF(1 != sscanf(optarg, "%d", val),                         \
-			   "Expecting a decimal argument!\n");                     \
-	}                                                                  \
-} while(0)
-
-        switch (c) {
-        case 0:
-            /* If this option set a flag, do nothing else now. */
-            if (long_options[option_index].flag != 0)
-                break;
-            INFO ("option %s", long_options[option_index].name);
-            if (optarg)
-                INFO (" with arg %s", optarg);
-            INFO ("\n");
-            break;
-        case 'Q': *quiet = 1; break;
-		case 'n': *dry_run = 1; break;
-		case 'M':
-			SET_STRING_OPTION(mapfile);
-			break;
-		case 'o':
-			SET_STRING_OPTION(output);
-			break;
-        case 'p':
-            SET_STRING_OPTION(prelinkmap);
-            break;
-        case 's':
-            SET_INT_OPTION(start_addr);
-            break;
-        case 'i':
-            SET_INT_OPTION(inc_addr);
-            break;
-        case 'L':
-            SET_REPEATED_STRING_OPTION(dirs, num_dirs, dirs_size);
-            break;
-        case 'D':
-            SET_REPEATED_STRING_OPTION(defaults, num_defaults, defaults_size);
-            break;
-        case 'l': *locals_only = 1; break;
-        case 'h': print_help(argv[0]); exit(1); break;
-        case 'V': *verbose = 1; break;
-        case '?':
-            /* getopt_long already printed an error message. */
-            break;
-
-#undef SET_STRING_OPTION
-#undef SET_REPEATED_STRING_OPTION
-#undef SET_INT_OPTION
-
-        default:
-            FAILIF(1, "Unknown option");
-        }
-    }
-
-    return optind;
-}
diff --git a/tools/apriori/cmdline.h b/tools/apriori/cmdline.h
deleted file mode 100644
index 8f7f394..0000000
--- a/tools/apriori/cmdline.h
+++ /dev/null
@@ -1,21 +0,0 @@
-#ifndef CMDLINE_H
-#define CMDLINE_H
-
-void print_help(const char *executable_name);
-
-int get_options(int argc, char **argv,
-                int *start_addr,
-                int *addr_increment,
-                int *locals_only,
-                int *quiet,
-                int *dry_run,
-                char ***dirs,
-                int *num_dirs,
-                char ***defaults,
-                int *num_defaults,
-                int *verbose,
-				char **mapfile,
-                char **output,
-                char **prelinkmap);
-
-#endif/*CMDLINE_H*/
diff --git a/tools/apriori/common.h b/tools/apriori/common.h
deleted file mode 100644
index f5d9d2e..0000000
--- a/tools/apriori/common.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef COMMON_H
-#define COMMON_H
-
-#include <libelf.h>
-#include <elf.h>
-
-#define unlikely(expr) __builtin_expect (expr, 0)
-#define likely(expr)   __builtin_expect (expr, 1)
-
-#define MIN(a,b) ((a)<(b)?(a):(b)) /* no side effects in arguments allowed! */
-
-static inline int is_host_little(void)
-{
-    short val = 0x10;
-    return ((char *)&val)[0] != 0;
-}
-
-static inline long switch_endianness(long val)
-{
-	long newval;
-	((char *)&newval)[3] = ((char *)&val)[0];
-	((char *)&newval)[2] = ((char *)&val)[1];
-	((char *)&newval)[1] = ((char *)&val)[2];
-	((char *)&newval)[0] = ((char *)&val)[3];
-	return newval;
-}
-
-#endif/*COMMON_H*/
diff --git a/tools/apriori/debug.c b/tools/apriori/debug.c
deleted file mode 100644
index 263e09f..0000000
--- a/tools/apriori/debug.c
+++ /dev/null
@@ -1,38 +0,0 @@
-#include <debug.h>
-#include <stdio.h>
-#include <ctype.h>
-
-#define NUM_COLS  (32)
-
-int dump_hex_buffer(FILE *s, void *b, size_t len, size_t elsize) {
-    int num_nonprintable = 0;
-    int i, last;
-    char *pchr = (char *)b;
-    fputc('\n', s);
-    fprintf(s, "%p: ", b);
-    for (i = last = 0; i < len; i++) {
-        if (!elsize) {
-            if (i && !(i % 4)) fprintf(s, " ");
-            if (i && !(i % 8)) fprintf(s, " ");
-        } else {
-            if (i && !(i % elsize)) fprintf(s, " ");
-        }
-
-        if (i && !(i % NUM_COLS)) {
-            while (last < i) {
-                if (isprint(pchr[last]))
-                    fputc(pchr[last], s);
-                else {
-                    fputc('.', s); 
-                    num_nonprintable++;
-                }
-                last++;
-            }
-            fprintf(s, " (%d)\n%p: ", i, b);
-        }
-        fprintf(s, "%02x", (unsigned char)pchr[i]);
-    }
-    if (i && (i % NUM_COLS)) fputs("\n", s);
-    return num_nonprintable;
-}
-
diff --git a/tools/apriori/debug.h b/tools/apriori/debug.h
deleted file mode 100644
index 3996898..0000000
--- a/tools/apriori/debug.h
+++ /dev/null
@@ -1,88 +0,0 @@
-#ifndef DEBUG_H
-#define DEBUG_H
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <common.h>
-
-#ifdef DEBUG
-
-    #define FAILIF(cond, msg...) do {                        \
-	if (unlikely(cond)) {                                \
-        fprintf(stderr, "%s(%d): ", __FILE__, __LINE__); \
-		fprintf(stderr, ##msg);                          \
-		exit(1);                                         \
-	}                                                    \
-} while(0)
-
-/* Debug enabled */
-    #define ASSERT(x) do {                                \
-	if (unlikely(!(x))) {                             \
-		fprintf(stderr,                               \
-				"ASSERTION FAILURE %s:%d: [%s]\n",    \
-				__FILE__, __LINE__, #x);              \
-		exit(1);                                      \
-	}                                                 \
-} while(0)
-
-#else
-
-    #define FAILIF(cond, msg...) do { \
-	if (unlikely(cond)) {         \
-		fprintf(stderr, ##msg);   \
-		exit(1);                  \
-	}                             \
-} while(0)
-
-/* No debug */
-    #define ASSERT(x)   do { } while(0)
-
-#endif/* DEBUG */
-
-#define FAILIF_LIBELF(cond, function) \
-    FAILIF(cond, "%s(): %s\n", #function, elf_errmsg(elf_errno()));
-
-static inline void *MALLOC(unsigned int size) {
-    void *m = malloc(size);
-    FAILIF(NULL == m, "malloc(%d) failed!\n", size);
-    return m;
-}
-
-static inline void *CALLOC(unsigned int num_entries, unsigned int entry_size) {
-    void *m = calloc(num_entries, entry_size);
-    FAILIF(NULL == m, "calloc(%d, %d) failed!\n", num_entries, entry_size);
-    return m;
-}
-
-static inline void *REALLOC(void *ptr, unsigned int size) {
-    void *m = realloc(ptr, size);
-    FAILIF(NULL == m, "realloc(%p, %d) failed!\n", ptr, size);
-    return m;
-}
-
-static inline void FREE(void *ptr) {
-    free(ptr);
-}
-
-static inline void FREEIF(void *ptr) {
-    if (ptr) FREE(ptr);
-}
-
-#define PRINT(x...)  do {                             \
-    extern int quiet_flag;                            \
-    if(likely(!quiet_flag))                           \
-        fprintf(stdout, ##x);                         \
-} while(0)
-
-#define ERROR PRINT
-
-#define INFO(x...)  do {                              \
-    extern int verbose_flag;                          \
-    if(unlikely(verbose_flag))                        \
-        fprintf(stdout, ##x);                         \
-} while(0)
-
-/* Prints a hex and ASCII dump of the selected buffer to the selected stream. */
-int dump_hex_buffer(FILE *s, void *b, size_t l, size_t elsize);
-
-#endif/*DEBUG_H*/
diff --git a/tools/apriori/hash.c b/tools/apriori/hash.c
deleted file mode 100644
index 9f1a614..0000000
--- a/tools/apriori/hash.c
+++ /dev/null
@@ -1,27 +0,0 @@
-#include <common.h>
-#include <debug.h>
-#include <libelf.h>
-#include <hash.h>
-#include <string.h>
-
-int hash_lookup(Elf *elf, 
-                Elf_Data *hash,
-                Elf_Data *symtab,
-                Elf_Data *symstr,
-                const char *symname) {
-    Elf32_Word *hash_data = (Elf32_Word *)hash->d_buf;
-    Elf32_Word index;
-    Elf32_Word nbuckets = *hash_data++;
-    Elf32_Word *buckets = ++hash_data;
-    Elf32_Word *chains  = hash_data + nbuckets;
-
-    index = buckets[elf_hash(symname) % nbuckets];
-    while (index != STN_UNDEF &&
-           strcmp((char *)symstr->d_buf + 
-                  ((Elf32_Sym *)symtab->d_buf)[index].st_name,
-                  symname)) {
-        index = chains[index];
-    }
-
-    return index;
-}
diff --git a/tools/apriori/hash.h b/tools/apriori/hash.h
deleted file mode 100644
index af29b9e..0000000
--- a/tools/apriori/hash.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef HASH_H
-#define HASH_H
-
-#include <common.h>
-#include <libelf.h>
-#include <gelf.h>
-
-int hash_lookup(Elf *elf, 
-                Elf_Data *hash,
-                Elf_Data *symtab,
-                Elf_Data *symstr,
-                const char *symname);
-
-#endif/*HASH_H*/
diff --git a/tools/apriori/main.c b/tools/apriori/main.c
deleted file mode 100644
index 552392a..0000000
--- a/tools/apriori/main.c
+++ /dev/null
@@ -1,229 +0,0 @@
-/* TODO:
-   1. check the ARM EABI version--this works for versions 1 and 2.
-   2. use a more-intelligent approach to finding the symbol table,
-      symbol-string table, and the .dynamic section.
-   3. fix the determination of the host and ELF-file endianness
-   4. write the help screen
-*/
-
-#include <stdio.h>
-#include <common.h>
-#include <debug.h>
-#include <libelf.h>
-#include <elf.h>
-#include <gelf.h>
-#include <cmdline.h>
-#include <string.h>
-#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <apriori.h>
-#include <prelinkmap.h>
-
-/* Flag set by --verbose.  This variable is global as it is accessed by the
-   macro INFO() in multiple compilation unites. */
-int verbose_flag = 0;
-/* Flag set by --quiet.  This variable is global as it is accessed by the
-   macro PRINT() in multiple compilation unites. */
-int quiet_flag = 0;
-static void print_dynamic_symbols(Elf *elf, const char *symtab_name);
-
-static unsigned s_next_link_addr;
-static off_t s_addr_increment;
-
-static void report_library_size_in_memory(const char *name, off_t fsize)
-{
-    ASSERT(s_next_link_addr != -1UL);
-	INFO("Setting next link address (current is at 0x%08x):\n",
-         s_next_link_addr);
-	if (s_addr_increment) {
-		FAILIF(s_addr_increment < fsize,
-			   "Command-line-specified address increment of 0x%08llx (%lld) "
-               "less than file [%s]'s size of %lld bytes!\n",
-			   s_addr_increment, s_addr_increment, name, fsize);
-		FAILIF(s_next_link_addr % 4096,
-			   "User-provided address increment 0x%08lx "
-               "is not page-aligned!\n",
-			   s_addr_increment);
-		INFO("\tignoring file size, adjusting by address increment.\n");
-		s_next_link_addr += s_addr_increment;
-	}
-	else {
-		INFO("\tuser address increment is zero, adjusting by file size.\n");
-		s_next_link_addr += fsize;
-		s_next_link_addr &= ~(4096 - 1);
-	}
-	INFO("\t[%s] file size 0x%08lx\n",
-		 name,
-		 fsize);
-	INFO("\tnext prelink address: 0x%08x\n", s_next_link_addr);
-	ASSERT(!(s_next_link_addr % 4096)); /* New address must be page-aligned */
-}
-
-static unsigned get_next_link_address(const char *name) {
-    return s_next_link_addr;
-}
-
-int main(int argc, char **argv) {
-    /* Do not issue INFO() statements before you call get_options() to set
-       the verbose flag as necessary.
-    */
-
-    char **lookup_dirs, **default_libs;
-	char *mapfile, *output, *prelinkmap;
-    int start_addr, inc_addr, locals_only, num_lookup_dirs, 
-        num_default_libs, dry_run;
-    int first = get_options(argc, argv,
-                            &start_addr, &inc_addr, &locals_only,
-                            &quiet_flag,
-                            &dry_run,
-                            &lookup_dirs, &num_lookup_dirs,
-                            &default_libs, &num_default_libs,
-                            &verbose_flag,
-							&mapfile,
-                            &output,
-                            &prelinkmap);
-
-    /* Perform some command-line-parameter checks. */
-    int cmdline_err = 0;
-    if (first == argc) {
-        ERROR("You must specify at least one input ELF file!\n");
-        cmdline_err++;
-    }
-    /* We complain when the user does not specify a start address for
-       prelinking when the user does not pass the locals_only switch.  The
-       reason is that we will have a collection of executables, which we always
-       prelink to zero, and shared libraries, which we prelink at the specified
-       prelink address.  When the user passes the locals_only switch, we do not
-       fail if the user does not specify start_addr, because the file to
-       prelink may be an executable, and not a shared library.  At this moment,
-       we do not know what the case is.  We find that out when we call function
-       init_source().
-    */
-    if (!locals_only && start_addr == -1) {
-        ERROR("You must specify --start-addr!\n");
-        cmdline_err++;
-    }
-    if (start_addr == -1 && inc_addr != -1) {
-        ERROR("You must provide a start address if you provide an "
-              "address increment!\n");
-        cmdline_err++;
-    }
-    if (prelinkmap != NULL && start_addr != -1) {
-        ERROR("You may not provide a prelink-map file (-p) and use -s/-i "
-              "at the same time!\n");
-        cmdline_err++;
-    }
-    if (inc_addr == 0) {
-        ERROR("You may not specify a link-address increment of zero!\n");
-        cmdline_err++;
-    }
-    if (locals_only) {
-        if (argc - first == 1) {
-            if (inc_addr != -1) {
-                ERROR("You are prelinking a single file; there is no point in "
-                      "specifying a prelink-address increment!\n");
-                /* This is nonfatal error, but paranoia is healthy. */
-                cmdline_err++;
-            }
-        }
-        if (lookup_dirs != NULL || default_libs != NULL) {
-            ERROR("You are prelinking local relocations only; there is "
-                  "no point in specifying lookup directories!\n");
-            /* This is nonfatal error, but paranoia is healthy. */
-            cmdline_err++;
-        }
-    }
-
-    /* If there is an output option, then that must specify a file, if there is
-       a single input file, or a directory, if there are multiple input
-       files. */
-    if (output != NULL) {
-        struct stat output_st;
-        FAILIF(stat(output, &output_st) < 0 && errno != ENOENT,
-               "stat(%s): %s (%d)\n",
-               output,
-               strerror(errno),
-               errno);
-
-        if (argc - first == 1) {
-            FAILIF(!errno && !S_ISREG(output_st.st_mode),
-                   "you have a single input file: -o must specify a "
-                   "file name!\n");
-        }
-        else {
-            FAILIF(errno == ENOENT,
-                   "you have multiple input files: -o must specify a "
-                   "directory name, but %s does not exist!\n",
-                   output);
-            FAILIF(!S_ISDIR(output_st.st_mode),
-                   "you have multiple input files: -o must specify a "
-                   "directory name, but %s is not a directory!\n",
-                   output);
-        }
-    }
-
-    if (cmdline_err) {
-        print_help(argv[0]);
-        FAILIF(1, "There are command-line-option errors.\n");
-    }
-
-    /* Check to see whether the ELF library is current. */
-    FAILIF (elf_version(EV_CURRENT) == EV_NONE, "libelf is out of date!\n");
-
-	if (inc_addr < 0) {
-        if (!locals_only)
-            PRINT("User has not provided an increment address, "
-                  "will use library size to calculate successive "
-                  "prelink addresses.\n");
-        inc_addr = 0;
-	}
-
-    void (*func_report_library_size_in_memory)(const char *name, off_t fsize);
-    unsigned (*func_get_next_link_address)(const char *name);
-
-    if (prelinkmap != NULL) {
-        INFO("Reading prelink addresses from prelink-map file [%s].\n",
-             prelinkmap);
-        pm_init(prelinkmap);
-        func_report_library_size_in_memory = pm_report_library_size_in_memory;
-        func_get_next_link_address = pm_get_next_link_address;
-    }
-    else {
-        INFO("Start address: 0x%x\n", start_addr);
-        INFO("Increment address: 0x%x\n", inc_addr);
-        s_next_link_addr = start_addr;
-        s_addr_increment = inc_addr;
-        func_report_library_size_in_memory = report_library_size_in_memory;
-        func_get_next_link_address = get_next_link_address;
-    }
-
-    /* Prelink... */
-    apriori(&argv[first], argc - first, output,
-            func_report_library_size_in_memory, func_get_next_link_address,
-            locals_only,
-            dry_run,
-            lookup_dirs, num_lookup_dirs,
-            default_libs, num_default_libs,
-			mapfile);
-
-	FREEIF(mapfile);
-    FREEIF(output);
-	if (lookup_dirs) {
-		ASSERT(num_lookup_dirs);
-		while (num_lookup_dirs--)
-			FREE(lookup_dirs[num_lookup_dirs]);
-		FREE(lookup_dirs);
-	}
-	if (default_libs) {
-		ASSERT(num_default_libs);
-		while (num_default_libs--)
-			FREE(default_libs[num_default_libs]);
-		FREE(default_libs);
-	}
-
-    return 0;
-}
diff --git a/tools/apriori/prelink_info.c b/tools/apriori/prelink_info.c
deleted file mode 100644
index da7ca05..0000000
--- a/tools/apriori/prelink_info.c
+++ /dev/null
@@ -1,106 +0,0 @@
-#ifdef SUPPORT_ANDROID_PRELINK_TAGS
-
-#include <sys/types.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-
-#include <prelink_info.h>
-#include <debug.h>
-#include <common.h>
-
-typedef struct {
-	int32_t mmap_addr;
-	char tag[4]; /* 'P', 'R', 'E', ' ' */
-} prelink_info_t __attribute__((packed));
-
-static inline void set_prelink(long *prelink_addr, 
-							   int elf_little,
-							   prelink_info_t *info)
-{
-    FAILIF(sizeof(prelink_info_t) != 8, "Unexpected sizeof(prelink_info_t) == %d!\n", sizeof(prelink_info_t));
-	if (prelink_addr) {
-		if (!(elf_little ^ is_host_little())) {
-			/* Same endianness */
-			*prelink_addr = info->mmap_addr;
-		}
-		else {
-			/* Different endianness */
-			*prelink_addr = switch_endianness(info->mmap_addr);
-		}
-	}
-}
-
-int check_prelinked(const char *fname, int elf_little, long *prelink_addr)
-{
-    FAILIF(sizeof(prelink_info_t) != 8, "Unexpected sizeof(prelink_info_t) == %d!\n", sizeof(prelink_info_t));
-	int fd = open(fname, O_RDONLY);
-	FAILIF(fd < 0, "open(%s, O_RDONLY): %s (%d)!\n",
-		   fname, strerror(errno), errno);
-	off_t end = lseek(fd, 0, SEEK_END);
-
-    int nr = sizeof(prelink_info_t);
-
-    off_t sz = lseek(fd, -nr, SEEK_CUR);
-	ASSERT((long)(end - sz) == (long)nr);
-	FAILIF(sz == (off_t)-1, 
-		   "lseek(%d, 0, SEEK_END): %s (%d)!\n", 
-		   fd, strerror(errno), errno);
-
-	prelink_info_t info;
-	int num_read = read(fd, &info, nr);
-	FAILIF(num_read < 0, 
-		   "read(%d, &info, sizeof(prelink_info_t)): %s (%d)!\n",
-		   fd, strerror(errno), errno);
-	FAILIF(num_read != sizeof(info),
-		   "read(%d, &info, sizeof(prelink_info_t)): did not read %d bytes as "
-		   "expected (read %d)!\n",
-		   fd, sizeof(info), num_read);
-
-	int prelinked = 0;
-	if (!strncmp(info.tag, "PRE ", 4)) {
-		set_prelink(prelink_addr, elf_little, &info);
-		prelinked = 1;
-	}
-	FAILIF(close(fd) < 0, "close(%d): %s (%d)!\n", fd, strerror(errno), errno);
-	return prelinked;
-}
-
-void setup_prelink_info(const char *fname, int elf_little, long base)
-{
-    FAILIF(sizeof(prelink_info_t) != 8, "Unexpected sizeof(prelink_info_t) == %d!\n", sizeof(prelink_info_t));
-    int fd = open(fname, O_WRONLY);
-    FAILIF(fd < 0, 
-           "open(%s, O_WRONLY): %s (%d)\n" ,
-           fname, strerror(errno), errno);
-    prelink_info_t info;
-    off_t sz = lseek(fd, 0, SEEK_END);
-    FAILIF(sz == (off_t)-1, 
-           "lseek(%d, 0, SEEK_END): %s (%d)!\n", 
-           fd, strerror(errno), errno);
-
-    if (!(elf_little ^ is_host_little())) {
-        /* Same endianness */
-        INFO("Host and ELF file [%s] have same endianness.\n", fname);
-        info.mmap_addr = base;
-    }
-    else {
-        /* Different endianness */
-        INFO("Host and ELF file [%s] have different endianness.\n", fname);
-		info.mmap_addr = switch_endianness(base);
-    }
-    strncpy(info.tag, "PRE ", 4);
-
-    int num_written = write(fd, &info, sizeof(info));
-    FAILIF(num_written < 0, 
-           "write(%d, &info, sizeof(info)): %s (%d)\n",
-           fd, strerror(errno), errno);
-    FAILIF(sizeof(info) != num_written, 
-           "Could not write %d bytes (wrote only %d bytes) as expected!\n",
-           sizeof(info), num_written);
-    FAILIF(close(fd) < 0, "close(%d): %s (%d)!\n", fd, strerror(errno), errno);
-}
-
-#endif /*SUPPORT_ANDROID_PRELINK_TAGS*/
diff --git a/tools/apriori/prelink_info.h b/tools/apriori/prelink_info.h
deleted file mode 100644
index e2787cb..0000000
--- a/tools/apriori/prelink_info.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef PRELINK_INFO_H
-#define PRELINK_INFO_H
-#ifdef SUPPORT_ANDROID_PRELINK_TAGS
-
-int check_prelinked(const char *fname, int elf_little, long *prelink_addr);
-void setup_prelink_info(const char *fname, int elf_little, long base);
-
-#endif
-#endif/*PRELINK_INFO_H*/
diff --git a/tools/apriori/prelinkmap.c b/tools/apriori/prelinkmap.c
deleted file mode 100644
index 9fb00e4..0000000
--- a/tools/apriori/prelinkmap.c
+++ /dev/null
@@ -1,170 +0,0 @@
-#include <prelinkmap.h>
-#include <debug.h>
-#include <errno.h>
-#include <string.h>
-#include <libgen.h>
-#include <ctype.h>
-
-typedef struct mapentry mapentry;
-
-#define MAX_ALIASES 10
-
-struct mapentry
-{
-    mapentry *next;
-    unsigned base;
-    char *names[MAX_ALIASES];
-    int num_names;
-};
-
-static mapentry *maplist = 0;
-
-/* These values limit the address range within which we prelinked libraries
-   reside.  The limit is not set in stone, but should be observed in the 
-   prelink map, or the prelink step will fail.
-*/
-
-#define PRELINK_MIN 0x90000000
-#define PRELINK_MAX 0xBFFFFFFF
-
-void pm_init(const char *file)
-{
-    unsigned line = 0;
-    char buf[256];
-    char *x;
-    FILE *fp;
-    mapentry *me;
-    unsigned last = -1UL;
-    
-    fp = fopen(file, "r");
-    FAILIF(fp == NULL, "Error opening file %s: %s (%d)\n", 
-           file, strerror(errno), errno);
-
-    while(fgets(buf, 256, fp)){
-        x = buf;
-        line++;
-        
-        /* eat leading whitespace */
-        while(isspace(*x)) x++;
-
-        /* comment or blank line? skip! */
-        if(*x == '#') continue;
-        if(*x == 0) continue;
-
-        /* skip name */
-        while(*x && !isspace(*x)) x++;
-
-        if(*x) {
-            *x++ = 0;
-            /* skip space before address */
-            while(*x && isspace(*x)) x++;
-        }
-
-        /* no address? complain. */
-        if(*x == 0) {
-            fprintf(stderr,"warning: %s:%d no base address specified\n",
-                    file, line);
-            continue;
-        }
-        
-        if (isalpha(*x)) {
-            /* Assume that this is an alias, and look through the list of
-               already-installed libraries.
-            */
-            me = maplist;
-            while(me) {
-                /* The strlen() call ignores the newline at the end of x */
-                if (!strncmp(me->names[0], x, strlen(me->names[0]))) {
-                    PRINT("Aliasing library %s to %s at %08x\n",
-                          buf, x, me->base);
-                    break;
-                }
-                me = me->next;
-            }
-            FAILIF(!me, "Nonexistent alias %s -> %s\n", buf, x);
-        }
-        else {
-            unsigned n = strtoul(x, 0, 16);
-            /* Note that this is not the only bounds check.  If a library's
-               size exceeds its slot as defined in the prelink map, the
-               prelinker will exit with an error.  See
-               pm_report_library_size_in_memory().
-            */
-            FAILIF((n < PRELINK_MIN) || (n > PRELINK_MAX),
-                   "%s:%d base 0x%08x out of range.\n",
-                   file, line, n);
-
-            me = malloc(sizeof(mapentry));
-            FAILIF(me == NULL, "Out of memory parsing %s\n", file);
-
-            FAILIF(last <= n, "The prelink map is not in descending order "
-                   "at entry %s (%08x)!\n", buf, n);
-            last = n;
-
-            me->base = n;
-            me->next = maplist;
-            me->num_names = 0;
-            maplist = me;
-        }
-
-        FAILIF(me->num_names >= MAX_ALIASES,
-               "Too many aliases for library %s, maximum is %d.\n",
-               me->names[0],
-               MAX_ALIASES);
-        me->names[me->num_names] = strdup(buf);
-        me->num_names++;
-    }
-
-    fclose(fp);
-}
-
-/* apriori() calls this function when it determine the size of a library 
-   in memory.  pm_report_library_size_in_memory() makes sure that the library
-   fits in the slot provided by the prelink map.
-*/
-void pm_report_library_size_in_memory(const char *name,
-                                      off_t fsize)
-{
-    char *x;
-    mapentry *me;
-    int n;
-    
-    x = strrchr(name,'/');
-    if(x) name = x+1;
-
-    for(me = maplist; me; me = me->next){
-        for (n = 0; n < me->num_names; n++) {
-            if(!strcmp(name, me->names[n])) {
-                off_t slot = me->next ? me->next->base : PRELINK_MAX;
-                slot -= me->base;
-                FAILIF(fsize > slot,
-                       "prelink map error: library %s@0x%08x is too big "
-                       "at %lld bytes, it runs %lld bytes into "
-                       "library %s@0x%08x!\n",
-                       me->names[0], me->base, fsize, fsize - slot,
-                       me->next->names[0], me->next->base);
-                return;
-            }
-        }
-    }
-    
-    FAILIF(1, "library '%s' not in prelink map\n", name);
-}
-
-unsigned pm_get_next_link_address(const char *lookup_name)
-{
-    char *x;
-    mapentry *me;
-    int n;
-    
-    x = strrchr(lookup_name,'/');
-    if(x) lookup_name = x+1;
-    
-    for(me = maplist; me; me = me->next)
-        for (n = 0; n < me->num_names; n++)
-            if(!strcmp(lookup_name, me->names[n]))
-                return me->base;
-
-    FAILIF(1, "library '%s' not in prelink map\n", lookup_name);
-    return 0;
-}
diff --git a/tools/apriori/prelinkmap.h b/tools/apriori/prelinkmap.h
deleted file mode 100644
index 17f7660..0000000
--- a/tools/apriori/prelinkmap.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef PRELINKMAP_H
-#define PRELINKMAP_H
-
-#include <sys/types.h>
-
-extern void pm_init(const char *file);
-extern void pm_report_library_size_in_memory(const char *name, off_t fsize);
-extern unsigned pm_get_next_link_address(const char *name);
-
-#endif/*PRELINKMAP_H*/
diff --git a/tools/apriori/rangesort.c b/tools/apriori/rangesort.c
deleted file mode 100644
index b0295e8..0000000
--- a/tools/apriori/rangesort.c
+++ /dev/null
@@ -1,317 +0,0 @@
-#include <common.h>
-#include <debug.h>
-#include <rangesort.h>
-
-#define PARALLEL_ARRAY_SIZE (5)
-
-struct range_list_t {
-    range_t *array;
-#ifdef DEBUG
-    int is_sorted;
-#endif
-    int array_length;
-    int num_ranges;
-};
-
-range_list_t* init_range_list(void) {
-    range_list_t *ranges = (range_list_t *)MALLOC(sizeof(range_list_t));
-
-    ranges->array = (range_t *)MALLOC(PARALLEL_ARRAY_SIZE*sizeof(range_t));
-    ranges->array_length = PARALLEL_ARRAY_SIZE;
-    ranges->num_ranges = 0;
-#ifdef DEBUG
-    ranges->is_sorted = 0;
-#endif
-    return ranges; 
-}
-
-void destroy_range_list(range_list_t *ranges) {
-    int idx;
-    for (idx = 0; idx < ranges->num_ranges; idx++) {
-        if (ranges->array[idx].user_dtor) {
-            ASSERT(ranges->array[idx].user);
-            ranges->array[idx].user_dtor(ranges->array[idx].user);
-        }
-    }
-    FREE(ranges->array);
-    FREE(ranges);
-}
-
-static inline int CONTAINS(range_t *container, range_t *contained) {
-    return container->start <= contained->start && contained->length && 
-    (container->start + container->length > 
-     contained->start + contained->length);
-}
-
-static inline int IN_RANGE(range_t *range, GElf_Off point) {
-    return 
-    range->start <= point && 
-    point < (range->start + range->length);
-}
-
-static inline int INTERSECT(range_t *left, range_t *right) {
-    return 
-    (IN_RANGE(left, right->start) && 
-     IN_RANGE(right, left->start + left->length)) ||
-    (IN_RANGE(right, left->start) && 
-     IN_RANGE(left, right->start + right->length));
-}
-
-static int range_cmp_for_search(const void *l, const void *r) {
-    range_t *left = (range_t *)l, *right = (range_t *)r;
-    if (INTERSECT(left, right) ||
-        CONTAINS(left, right) ||
-        CONTAINS(right, left)) {
-        return 0;
-    }
-    return left->start - right->start;
-}
-
-static inline void run_checks(const void *l, const void *r) {
-    range_t *left = (range_t *)l, *right = (range_t *)r;
-    if (CONTAINS(left, right)) {
-        if (left->err_fn)
-            left->err_fn(ERROR_CONTAINS, left, right);
-        FAILIF(1, "Range sorting error: [%lld, %lld) contains [%lld, %lld)!\n",
-               left->start, left->start + left->length,
-               right->start, right->start + right->length);
-    }
-    if (CONTAINS(right, left)) {
-        if (right->err_fn)
-            right->err_fn(ERROR_CONTAINS, left, right);
-        FAILIF(1, "Range sorting error: [%lld, %lld) contains [%lld, %lld)!\n",
-               right->start, right->start + right->length,
-               left->start, left->start + left->length);
-    }
-    if (INTERSECT(left, right)) {
-        if (left->err_fn)
-            left->err_fn(ERROR_OVERLAPS, left, right);
-        FAILIF(1, "Range sorting error: [%lld, %lld)and [%lld, %lld) intersect!\n",
-               left->start, left->start + left->length,
-               right->start, right->start + right->length);
-    }
-}
-
-static int range_cmp(const void *l, const void *r) {
-    run_checks(l, r);
-    range_t *left = (range_t *)l, *right = (range_t *)r;
-    return left->start - right->start;
-}
-
-void add_unique_range_nosort(
-                            range_list_t *ranges, 
-                            GElf_Off start, 
-                            GElf_Off length, 
-                            void *user,
-                            void (*err_fn)(range_error_t, range_t *, range_t *),
-                            void (*user_dtor)(void * )) 
-{
-    if (ranges->num_ranges == ranges->array_length) {
-        ranges->array_length += PARALLEL_ARRAY_SIZE;
-        ranges->array = REALLOC(ranges->array, 
-                                ranges->array_length*sizeof(range_t));
-    }
-    ranges->array[ranges->num_ranges].start  = start;
-    ranges->array[ranges->num_ranges].length = length;
-    ranges->array[ranges->num_ranges].user   = user;
-    ranges->array[ranges->num_ranges].err_fn = err_fn;
-    ranges->array[ranges->num_ranges].user_dtor = user_dtor;
-    ranges->num_ranges++;
-}
-
-range_list_t *sort_ranges(range_list_t *ranges) {
-    if (ranges->num_ranges > 1)
-        qsort(ranges->array, ranges->num_ranges, sizeof(range_t), range_cmp);
-    ranges->is_sorted = 1;
-    return ranges;
-}
-
-range_t *find_range(range_list_t *ranges, GElf_Off value) {
-#if 1
-    int i;
-    for (i = 0; i < ranges->num_ranges; i++) {
-        if (ranges->array[i].start <= value && 
-            value < ranges->array[i].start + ranges->array[i].length)
-            return ranges->array + i;
-    }
-    return NULL;
-#else
-    ASSERT(ranges->is_sorted); /* The range list must be sorted */
-    range_t lookup;
-    lookup.start = value;
-    lookup.length = 0;
-    return 
-    (range_t *)bsearch(&lookup, 
-                       ranges->array, ranges->num_ranges, sizeof(range_t), 
-                       range_cmp_for_search);
-#endif
-}
-
-int get_num_ranges(const range_list_t *ranges)
-{
-    return ranges->num_ranges;
-}
-
-range_t *get_sorted_ranges(const range_list_t *ranges, int *num_ranges) {
-    ASSERT(ranges->is_sorted); /* The range list must be sorted */
-    if (num_ranges) {
-        *num_ranges = ranges->num_ranges;
-    }
-    return ranges->array;
-}
-
-GElf_Off get_last_address(const range_list_t *ranges) {
-    ASSERT(ranges->num_ranges);
-    return 
-    ranges->array[ranges->num_ranges-1].start +
-    ranges->array[ranges->num_ranges-1].length;
-}
-
-static void handle_range_error(range_error_t err, 
-                               range_t *left, range_t *right) {
-    switch (err) {
-    case ERROR_CONTAINS:
-        ERROR("ERROR: section (%lld, %lld bytes) contains "
-              "section (%lld, %lld bytes)\n",
-              left->start, left->length,
-              right->start, right->length);
-        break;
-    case ERROR_OVERLAPS:
-        ERROR("ERROR: Section (%lld, %lld bytes) intersects "
-              "section (%lld, %lld bytes)\n",
-              left->start, left->length,
-              right->start, right->length);
-        break;
-    default:
-        ASSERT(!"Unknown range error code!");
-    }
-
-    FAILIF(1, "Range error.\n");
-}
-
-static void destroy_contiguous_range_info(void *user) {
-    contiguous_range_info_t *info = (contiguous_range_info_t *)user;
-    FREE(info->ranges);
-    FREE(info);
-}
-
-static void handle_contiguous_range_error(range_error_t err, 
-                                          range_t *left, 
-                                          range_t *right)
-{
-    contiguous_range_info_t *left_data = 
-        (contiguous_range_info_t *)left->user;
-    ASSERT(left_data);
-    contiguous_range_info_t *right_data = 
-        (contiguous_range_info_t *)right->user;
-    ASSERT(right_data);
-
-    PRINT("Contiguous-range overlap error.  Printing contained ranges:\n");
-    int cnt;
-    PRINT("\tLeft ranges:\n");
-    for (cnt = 0; cnt < left_data->num_ranges; cnt++) {
-        PRINT("\t\t[%lld, %lld)\n",
-              left_data->ranges[cnt].start,
-              left_data->ranges[cnt].start + left_data->ranges[cnt].length);
-    }
-    PRINT("\tRight ranges:\n");
-    for (cnt = 0; cnt < right_data->num_ranges; cnt++) {
-        PRINT("\t\t[%lld, %lld)\n",
-              right_data->ranges[cnt].start,
-              right_data->ranges[cnt].start + right_data->ranges[cnt].length);
-    }
-
-    handle_range_error(err, left, right);
-}
-
-range_list_t* get_contiguous_ranges(const range_list_t *input)
-{
-    ASSERT(input);
-    FAILIF(!input->is_sorted, 
-           "get_contiguous_ranges(): input range list is not sorted!\n");
-
-    range_list_t* ret = init_range_list();
-    int num_ranges;
-    range_t *ranges = get_sorted_ranges(input, &num_ranges);
-
-    int end_idx = 0;
-    while (end_idx < num_ranges) {
-        int start_idx = end_idx++;
-        int old_end_idx = start_idx;
-        int total_length = ranges[start_idx].length;
-        while (end_idx < num_ranges) {
-            if (ranges[old_end_idx].start + ranges[old_end_idx].length !=
-                ranges[end_idx].start)
-                break;
-            old_end_idx = end_idx++;
-            total_length += ranges[old_end_idx].length;
-        }
-
-        contiguous_range_info_t *user = 
-            (contiguous_range_info_t *)MALLOC(sizeof(contiguous_range_info_t));
-        user->num_ranges = end_idx - start_idx;
-        user->ranges = (range_t *)MALLOC(user->num_ranges * sizeof(range_t));
-        int i;
-        for (i = 0; i < end_idx - start_idx; i++)
-            user->ranges[i] = ranges[start_idx + i];
-        add_unique_range_nosort(ret, 
-                                ranges[start_idx].start,
-                                total_length,
-                                user,
-                                handle_contiguous_range_error,
-                                destroy_contiguous_range_info);
-    }
-
-    return ret;
-}
-
-range_list_t* subtract_ranges(const range_list_t *r, const range_list_t *s)
-{
-    ASSERT(r);  ASSERT(r->is_sorted);
-    ASSERT(s);  ASSERT(s->is_sorted);
-
-    range_list_t *result = init_range_list();
-
-    int r_num_ranges, r_idx;
-    range_t *r_ranges = get_sorted_ranges(r, &r_num_ranges);
-    ASSERT(r_ranges);
-
-    int s_num_ranges, s_idx;
-    range_t *s_ranges = get_sorted_ranges(s, &s_num_ranges);
-    ASSERT(s_ranges);
-
-    s_idx = 0;
-    for (r_idx = 0; r_idx < r_num_ranges; r_idx++) {
-        GElf_Off last_start = r_ranges[r_idx].start;
-        for (; s_idx < s_num_ranges; s_idx++) {
-            if (CONTAINS(&r_ranges[r_idx], &s_ranges[s_idx])) {
-                if (last_start == 
-                    r_ranges[r_idx].start + r_ranges[r_idx].length) {
-                    break;
-                }
-                if (last_start == s_ranges[s_idx].start) {
-                    last_start += s_ranges[s_idx].length;
-                    continue;
-                }
-                INFO("Adding subtracted range [%lld, %lld)\n",
-                     last_start,
-                     s_ranges[s_idx].start);
-                add_unique_range_nosort(
-                    result, 
-                    last_start,
-                    s_ranges[s_idx].start - last_start,
-                    NULL,
-                    NULL,
-                    NULL);
-                last_start = s_ranges[s_idx].start + s_ranges[s_idx].length;
-            } else {
-                ASSERT(!INTERSECT(&r_ranges[r_idx], &s_ranges[s_idx]));
-                break;
-            }
-        } /* while (s_idx < s_num_ranges) */
-    } /* for (r_idx = 0; r_idx < r_num_ranges; r_idx++) */
-
-    return result;
-}
-
-
diff --git a/tools/apriori/rangesort.h b/tools/apriori/rangesort.h
deleted file mode 100644
index 21db357..0000000
--- a/tools/apriori/rangesort.h
+++ /dev/null
@@ -1,105 +0,0 @@
-#ifndef RANGESORT_H
-#define RANGESORT_H
-
-/* This implements a simple sorted list of non-overlapping ranges. */
-
-#include <debug.h>
-#include <common.h>
-#include <gelf.h>
-
-typedef enum range_error_t {
-    ERROR_CONTAINS,
-    ERROR_OVERLAPS
-} range_error_t;
-
-typedef struct range_t range_t;
-struct range_t {
-    GElf_Off start;
-    GElf_Off length;
-    void *user;
-    void (*err_fn)(range_error_t, range_t *, range_t *);
-    void (*user_dtor)(void *);
-};
-
-typedef struct range_list_t range_list_t;
-
-range_list_t* init_range_list();
-void destroy_range_list(range_list_t *);
-
-/* Just adds a range to the list. We won't detect whether the range overlaps
-   other ranges or contains them, or is contained by them, till we call 
-   sort_ranges(). */
-void add_unique_range_nosort(range_list_t *ranges, 
-                             GElf_Off start, GElf_Off length, 
-                             void *user,
-                             void (*err_fn)(range_error_t, range_t *, range_t *),
-                             void (*user_dtor)(void * ));
-
-/* Sorts the ranges.  If there are overlapping ranges or ranges that contain
-   other ranges, it will cause the program to exit with a FAIL. */
-range_list_t* sort_ranges(range_list_t *ranges);
-/* Find which range value falls in.  Return that range or NULL if value does
-   not fall within any range. */
-range_t *find_range(range_list_t *ranges, GElf_Off value);
-int get_num_ranges(const range_list_t *ranges);
-range_t *get_sorted_ranges(const range_list_t *ranges, int *num_ranges);
-GElf_Off get_last_address(const range_list_t *ranges);
-
-/* This returns a range_list_t handle that contains ranges composed of the 
-   adjacent ranges of the input range list.  The user data of each range in 
-   the range list is a structure of the type contiguous_range_info_t. 
-   This structure contains an array of pointers to copies of the original 
-   range_t structures comprising each new contiguous range, as well as the 
-   length of that array.  
-
-   NOTE: The input range must be sorted!
-
-   NOTE: destroy_range_list() will take care of releasing the data that it
-   allocates as a result of calling get_contiguous_ranges().  Do not free that
-   data yourself.
-
-   NOTE: the user data of the original range_t structures is simply copied, so 
-   be careful handling it. You can destroy the range_list_t with 
-   destroy_range_list() as usual.  On error, the function does not return--the 
-   program terminates. 
-
-   NOTE: The returned range is not sorted.  You must call sort_ranges() if you
-   need to.
-*/
-
-typedef struct {
-    int num_ranges;
-    range_t *ranges;
-} contiguous_range_info_t;
-
-range_list_t* get_contiguous_ranges(const range_list_t *);
-
-/* The function below takes in two range lists: r and s, and subtracts the 
-   ranges in s from those in r.  For example, if r and s are as follows:
-
-   r = { [0, 10) }
-   s = { [3, 5), [7, 9) }
-
-   Then r - s is { [0, 3), [5, 7), [9, 10) }
-
-   NOTE: Both range lists must be sorted on input.  This is guarded by an 
-         assertion.
-
-   NOTE: Range s must contain ranges, which are fully contained by the span of
-         range r (the span being the interval between the start of the lowest
-         range in r, inclusive, and the end of the highest range in r, 
-         exclusive).
-
-   NOTE: In addition to the requirement above, range s must contain ranges, 
-         each of which is a subrange of one of the ranges of r.
-
-   NOTE: There is no user info associated with the resulting range. 
-
-   NOTE: The resulting range is not sorted.
-
-   Ther returned list must be destroyed with destroy_range_list().
-*/
-
-range_list_t* subtract_ranges(const range_list_t *r, const range_list_t *s);
-
-#endif/*RANGESORT_H*/
diff --git a/tools/apriori/source.c b/tools/apriori/source.c
deleted file mode 100644
index 69c57c7..0000000
--- a/tools/apriori/source.c
+++ /dev/null
@@ -1,18 +0,0 @@
-#include <source.h>
-
-void find_section(source_t *source, Elf64_Addr address,
-                  Elf_Scn **scn, 
-                  GElf_Shdr *shdr, 
-                  Elf_Data **data)
-{
-    range_t *range = find_range(source->sorted_sections, address);
-    FAILIF(NULL == range, 
-           "Cannot match address %lld to any range in [%s]!\n",
-           address,
-           source->name);
-    *scn = (Elf_Scn *)range->user;
-    ASSERT(*scn);
-    FAILIF_LIBELF(NULL == gelf_getshdr(*scn, shdr), gelf_getshdr);
-    *data = elf_getdata(*scn, NULL);
-    FAILIF_LIBELF(NULL == *data, elf_getdata);
-}
diff --git a/tools/apriori/source.h b/tools/apriori/source.h
deleted file mode 100644
index a5d96bd..0000000
--- a/tools/apriori/source.h
+++ /dev/null
@@ -1,121 +0,0 @@
-#ifndef SOURCE_H
-#define SOURCE_H
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <libelf.h>
-#include <libebl.h>
-#ifdef ARM_SPECIFIC_HACKS
-    #include <libebl_arm.h>
-#endif/*ARM_SPECIFIC_HACKS*/
-#include <elf.h>
-#include <gelf.h>
-#include <rangesort.h>
-#include <elfcopy.h>
-
-typedef struct source_t source_t;
-
-typedef struct {
-    Elf_Scn *scn;
-    GElf_Shdr shdr;
-    Elf_Data *data;
-    shdr_info_t *info;
-} section_info_t;
-
-typedef struct {
-    GElf_Rel *rels;
-    int num_rels; /* number of relocations that were not finished */
-    int rels_size; /* this is the size of rels[], NOT the number of rels! */
-} unfinished_relocation_t;
-
-typedef struct {
-    int processed;
-    size_t idx; /* index of DT entry in the .dynamic section, if entry has a ptr value */
-    Elf64_Addr addr; /* if DT entry's value is an address, we save it here */
-    size_t sz_idx; /* index of DT entry in the .dynamic section, if entry has a size value */
-    Elf64_Xword size; /* if DT entry's value is a size, we save it here */
-
-    range_list_t *sections; /* list of sections corresponding to this entry */
-    int num_unfinished_relocs; /* this variables is populated by adjust_dynamic_segment_for()
-                                  during the second pass of the prelinker */
-} dt_rel_info_t;
-
-struct source_t {
-    source_t *next;
-
-    char *name;  /* full path name of this executable file */
-    char *output; /* name of the output file or directory */
-    int output_is_dir; /* nonzero if output is a directory, 0 if output is a file */
-    /* ELF-related information: */
-    Elf *oldelf;
-    Elf *elf;
-    /* info[] is an array of structures describing the sections of the new ELF
-       file.  We populate the info[] array in clone_elf(), and use it to
-       adjust the size of the ELF file when we modify the relocation-entry
-       section.
-    */
-    shdr_info_t *shdr_info;
-    GElf_Ehdr old_ehdr_mem; /* store ELF header of original library */
-    GElf_Ehdr ehdr_mem; /* store ELF header of new library */
-    GElf_Phdr *phdr_info;
-    Ebl *ebl;
-    Elf_Data *shstrtab_data;
-    int elf_fd;
-    int newelf_fd; /* fd of output file, -1 if output == NULL */
-	struct stat elf_file_info;
-    GElf_Ehdr elf_hdr, oldelf_hdr;
-    size_t shstrndx;
-    int shnum; /* number of sections */
-    int dry_run; /* 0 if we do not update the files, 1 (default) otherwise */
-
-    section_info_t symtab;
-    section_info_t strtab;
-    section_info_t dynamic;
-    section_info_t hash;
-    section_info_t bss;
-
-    range_list_t *sorted_sections;
-
-    section_info_t *relocation_sections; /* relocation sections in file */
-    int num_relocation_sections; /* number of relocation sections (<= relocation_sections_size) */
-    int relocation_sections_size; /* sice of array -- NOT number of relocs! */
-
-    /* relocation sections that contain relocations that could not be handled.
-       This array is parallel to relocation_sections, and for each entry
-       in that array, it contains a list of relocations that could not be
-       handled.
-    */
-    unfinished_relocation_t *unfinished;
-
-    /* The sections field of these two structuer contains a list of elements
-       of the member variable relocations. */
-    dt_rel_info_t rel;
-    dt_rel_info_t jmprel;
-
-    int num_syms; /* number of symbols in symbol table.  This is the length of
-                     both exports[] and satisfied[] arrays. */
-
-    /* This is an array that contains one element for each library dependency
-       listed in the executable or shared library. */
-    source_t **lib_deps; /* list of library dependencies */
-    int num_lib_deps; /* actual number of library dependencies */
-    int lib_deps_size; /* size of lib_deps array--NOT actual number of deps! */
-
-    /* This is zero for executables.  For shared libraries, it is the address
-	   at which the library was prelinked. */
-    unsigned base;
-#ifdef SUPPORT_ANDROID_PRELINK_TAGS
-	/* When we read in a file, if it has the prelinked tag, we set prelinked
-	   to 1 and the prelink address in the tag to prelink_base.  This address
-	   must match the value of base that we choose. */
-	int prelinked;
-	long prelink_base; /* valid if prelinked != 0 */
-#endif/*SUPPORT_ANDROID_PRELINK_TAGS*/
-};
-
-extern void find_section(source_t *source, Elf64_Addr address,
-                         Elf_Scn **scn,
-                         GElf_Shdr *shdr,
-                         Elf_Data **data);
-
-#endif/*SOURCE_H*/
diff --git a/tools/apriori/tweak.h b/tools/apriori/tweak.h
deleted file mode 100755
index 3afedee..0000000
--- a/tools/apriori/tweak.h
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifndef TWEAK_H

-#define TWEAK_H

-

-#include <source.h>

-

-/* This function will break up the .bss section into multiple subsegments, 

-   depending on whether the .bss segment contains copy-relocated symbols.  This

-   will produce a nonstandard ELF file (with multiple .bss sections), tht the

-   linker will need to know how to handle.  The return value is the number of

-   segments that the .bss segment was broken into (zero if the .bss segment was

-   not modified. */

-

-int tweak_bss_if_necessary(source_t *source);

-

-#endif/*TWEAK_H*/

diff --git a/tools/buildinfo.sh b/tools/buildinfo.sh
index 6c85149..e3fe99c 100755
--- a/tools/buildinfo.sh
+++ b/tools/buildinfo.sh
@@ -25,8 +25,12 @@
   echo "ro.product.cpu.abi2=$TARGET_CPU_ABI2"
 fi
 echo "ro.product.manufacturer=$PRODUCT_MANUFACTURER"
-echo "ro.product.locale.language=$PRODUCT_DEFAULT_LANGUAGE"
-echo "ro.product.locale.region=$PRODUCT_DEFAULT_REGION"
+if [ -n "$PRODUCT_DEFAULT_LANGUAGE" ] ; then
+  echo "ro.product.locale.language=$PRODUCT_DEFAULT_LANGUAGE"
+fi
+if [ -n "$PRODUCT_DEFAULT_REGION" ] ; then
+  echo "ro.product.locale.region=$PRODUCT_DEFAULT_REGION"
+fi
 echo "ro.wifi.channels=$PRODUCT_DEFAULT_WIFI_CHANNELS"
 echo "ro.board.platform=$TARGET_BOARD_PLATFORM"
 
@@ -36,5 +40,6 @@
 echo "# Do not try to parse ro.build.description or .fingerprint"
 echo "ro.build.description=$PRIVATE_BUILD_DESC"
 echo "ro.build.fingerprint=$BUILD_FINGERPRINT"
+echo "ro.build.characteristics=$TARGET_AAPT_CHARACTERISTICS"
 
 echo "# end build properties"
diff --git a/tools/droiddoc/Android.mk b/tools/droiddoc/Android.mk
index d2d7a95..ff08edc 100644
--- a/tools/droiddoc/Android.mk
+++ b/tools/droiddoc/Android.mk
@@ -14,5 +14,4 @@
 
 LOCAL_PATH := $(call my-dir)
 
-include $(LOCAL_PATH)/src/Android.mk
-
+# Droiddoc is now Doclava -- See external/doclava.
diff --git a/tools/droiddoc/NOTICE b/tools/droiddoc/NOTICE
deleted file mode 100644
index 3f1b1bb..0000000
--- a/tools/droiddoc/NOTICE
+++ /dev/null
@@ -1,45 +0,0 @@
-
-Copyright (C) 2008 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.
-
-
-======================================================================
-
-jQuery 1.2.6 - New Wave Javascript
-
-Copyright (c) 2008 John Resig (jquery.com)
-Dual licensed under the MIT (MIT-LICENSE.txt)
-and GPL (GPL-LICENSE.txt) licenses.
-
-Copyright (c) 2009 John Resig, http://jquery.com/
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
diff --git a/tools/droiddoc/src/Android.mk b/tools/droiddoc/src/Android.mk
deleted file mode 100644
index 30270b5..0000000
--- a/tools/droiddoc/src/Android.mk
+++ /dev/null
@@ -1,69 +0,0 @@
-# Copyright (C) 2008 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.
-
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
-    AnnotationInstanceInfo.java \
-    AnnotationValueInfo.java \
-	AttributeInfo.java \
-	AttrTagInfo.java \
-	ClassInfo.java \
-	DroidDoc.java \
-	ClearPage.java \
-	Comment.java \
-	ContainerInfo.java \
-	Converter.java \
-	DocFile.java \
-	DocInfo.java \
-	Errors.java \
-	FieldInfo.java \
-	Hierarchy.java \
-	InheritedTags.java \
-	KeywordEntry.java \
-    LinkReference.java \
-	LiteralTagInfo.java \
-	MemberInfo.java \
-	MethodInfo.java \
-	NavTree.java \
-	PackageInfo.java \
-	ParamTagInfo.java \
-	ParameterInfo.java \
-	ParsedTagInfo.java \
-	Proofread.java \
-	SampleCode.java \
-	SampleTagInfo.java \
-    Scoped.java \
-	SeeTagInfo.java \
-	SinceTagger.java \
-	Sorter.java \
-	SourcePositionInfo.java \
-    Stubs.java \
-	TagInfo.java \
-    TextTagInfo.java \
-	ThrowsTagInfo.java \
-	TodoFile.java \
-	TypeInfo.java
-
-LOCAL_JAVA_LIBRARIES := \
-	apicheck \
-	clearsilver
-
-LOCAL_CLASSPATH := \
-	$(HOST_JDK_TOOLS_JAR)
-
-LOCAL_MODULE:= droiddoc
-
-include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/tools/droiddoc/src/AnnotationInstanceInfo.java b/tools/droiddoc/src/AnnotationInstanceInfo.java
deleted file mode 100644
index c4abc7e..0000000
--- a/tools/droiddoc/src/AnnotationInstanceInfo.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-class AnnotationInstanceInfo
-{
-    private ClassInfo mType;
-    private AnnotationValueInfo[] mElementValues;
-
-    public AnnotationInstanceInfo(ClassInfo type, AnnotationValueInfo[] elementValues)
-    {
-        mType = type;
-        mElementValues = elementValues;
-    }
-
-    ClassInfo type()
-    {
-        return mType;
-    }
-
-    AnnotationValueInfo[] elementValues()
-    {
-        return mElementValues;
-    }
-
-    @Override
-    public String toString()
-    {
-        StringBuilder str = new StringBuilder();
-        str.append("@");
-        str.append(mType.qualifiedName());
-        str.append("(");
-        AnnotationValueInfo[] values = mElementValues;
-        final int N = values.length;
-        for (int i=0; i<N; i++) {
-            AnnotationValueInfo value = values[i];
-            str.append(value.element().name());
-            str.append("=");
-            str.append(value.valueString());
-            if (i != N-1) {
-                str.append(",");
-            }
-        }
-        str.append(")");
-        return str.toString();
-    }
-}
-
diff --git a/tools/droiddoc/src/AnnotationValueInfo.java b/tools/droiddoc/src/AnnotationValueInfo.java
deleted file mode 100644
index a2d869a..0000000
--- a/tools/droiddoc/src/AnnotationValueInfo.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-public class AnnotationValueInfo
-{
-    private Object mValue;
-    private String mString;
-    private MethodInfo mElement;
-
-    public AnnotationValueInfo(MethodInfo element)
-    {
-        mElement = element;
-    }
-
-    public void init(Object value)
-    {
-        mValue = value;
-    }
-
-    public MethodInfo element()
-    {
-        return mElement;
-    }
-
-    public Object value()
-    {
-        return mValue;
-    }
-
-    public String valueString()
-    {
-        Object v = mValue;
-        if (v instanceof TypeInfo) {
-            return ((TypeInfo)v).fullName();
-        }
-        else if (v instanceof FieldInfo) {
-            StringBuilder str = new StringBuilder();
-            FieldInfo f = (FieldInfo)v;
-            str.append(f.containingClass().qualifiedName());
-            str.append('.');
-            str.append(f.name());
-            return str.toString();
-        }
-        else if (v instanceof AnnotationInstanceInfo) {
-            return v.toString();
-        }
-        else if (v instanceof AnnotationValueInfo[]) {
-            StringBuilder str = new StringBuilder();
-            AnnotationValueInfo[] array = (AnnotationValueInfo[])v;
-            final int N = array.length;
-            str.append("{");
-            for (int i=0; i<array.length; i++) {
-                str.append(array[i].valueString());
-                if (i != N-1) {
-                    str.append(",");
-                }
-            }
-            str.append("}");
-            return str.toString();
-        }
-        else {
-            return FieldInfo.constantLiteralValue(v);
-        }
-    }
-}
-
diff --git a/tools/droiddoc/src/AttrTagInfo.java b/tools/droiddoc/src/AttrTagInfo.java
deleted file mode 100644
index 7f1b4d9..0000000
--- a/tools/droiddoc/src/AttrTagInfo.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-import java.util.regex.Pattern;
-import java.util.regex.Matcher;
-import org.clearsilver.HDF;
-import org.clearsilver.CS;
-
-
-public class AttrTagInfo extends TagInfo
-{
-    private static final String REF_COMMAND = "ref";
-    private static final String NAME_COMMAND = "name";
-    private static final String DESCRIPTION_COMMAND = "description";
-    private static final Pattern TEXT = Pattern.compile("(\\S+)\\s*(.*)", Pattern.DOTALL);
-    private static final Pattern NAME_TEXT = Pattern.compile("(\\S+)(.*)",
-                                                Pattern.DOTALL);
-
-    private ContainerInfo mBase;
-    private String mCommand;
-
-    // if mCommand == "ref"
-    private FieldInfo mRefField;
-    private AttributeInfo mAttrInfo;
-
-    // if mCommand == "name"
-    private String mAttrName;
-
-    // if mCommand == "description"
-    private Comment mDescrComment;
-
-    AttrTagInfo(String name, String kind, String text, ContainerInfo base,
-            SourcePositionInfo position)
-    {
-        super(name, kind, text, position);
-        mBase = base;
-
-        parse(text, base, position);
-    }
-
-    void parse(String text, ContainerInfo base, SourcePositionInfo position) {
-        Matcher m;
-
-        m = TEXT.matcher(text);
-        if (!m.matches()) {
-            Errors.error(Errors.BAD_ATTR_TAG, position, "Bad @attr tag: " + text);
-            return;
-        }
-
-        String command = m.group(1);
-        String more = m.group(2);
-
-        if (REF_COMMAND.equals(command)) {
-            String ref = more.trim();
-            LinkReference linkRef = LinkReference.parse(ref, mBase, position, false);
-            if (!linkRef.good) {
-                Errors.error(Errors.BAD_ATTR_TAG, position, "Unresolved @attr ref: " + ref);
-                return;
-            }
-            if (!(linkRef.memberInfo instanceof FieldInfo)) {
-                Errors.error(Errors.BAD_ATTR_TAG, position, "@attr must be a field: " + ref);
-                return;
-            }
-            mCommand = command;
-            mRefField = (FieldInfo)linkRef.memberInfo;
-        }
-        else if (NAME_COMMAND.equals(command)) {
-            m = NAME_TEXT.matcher(more);
-            if (!m.matches() || m.group(2).trim().length() != 0) {
-                Errors.error(Errors.BAD_ATTR_TAG, position, "Bad @attr name tag: " + more);
-                return;
-            }
-            mCommand = command;
-            mAttrName = m.group(1);
-        }
-        else if (DESCRIPTION_COMMAND.equals(command)) {
-            mCommand = command;
-            mDescrComment = new Comment(more, base, position);
-        }
-        else {
-            Errors.error(Errors.BAD_ATTR_TAG, position, "Bad @attr command: " + command);
-        }
-    }
-
-    public FieldInfo reference() {
-        return REF_COMMAND.equals(mCommand) ? mRefField : null;
-    }
-
-    @Override
-    public String name() {
-        return NAME_COMMAND.equals(mCommand) ? mAttrName : null;
-    }
-
-    public Comment description() {
-        return DESCRIPTION_COMMAND.equals(mCommand) ? mDescrComment : null;
-    }
-
-    @Override
-    public void makeHDF(HDF data, String base)
-    {
-        super.makeHDF(data, base);
-    }
-
-    public void setAttribute(AttributeInfo info) {
-        mAttrInfo = info;
-    }
-
-    public static void makeReferenceHDF(HDF data, String base, AttrTagInfo[] tags)
-    {
-        int i=0;
-        for (AttrTagInfo t: tags) {
-            if (REF_COMMAND.equals(t.mCommand)) {
-                if (t.mAttrInfo == null) {
-                    String msg = "ERROR: unlinked attr: " + t.mRefField.name();
-                    if (false) {
-                        System.out.println(msg);
-                    } else {
-                        throw new RuntimeException(msg);
-                    }
-                } else {
-                    data.setValue(base + "." + i + ".name", t.mAttrInfo.name());
-                    data.setValue(base + "." + i + ".href", t.mAttrInfo.htmlPage());
-                    i++;
-                }
-            }
-        }
-    }
-
-}
diff --git a/tools/droiddoc/src/AttributeInfo.java b/tools/droiddoc/src/AttributeInfo.java
deleted file mode 100644
index a24106b..0000000
--- a/tools/droiddoc/src/AttributeInfo.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-import java.util.ArrayList;
-import java.util.Comparator;
-
-import org.clearsilver.HDF;
-import org.clearsilver.CS;
-
-public class AttributeInfo {
-    public static final Comparator<AttributeInfo> comparator = new Comparator<AttributeInfo>() {
-        public int compare(AttributeInfo a, AttributeInfo b) {
-            return a.name().compareTo(b.name());
-        }
-    };
-    
-    public FieldInfo attrField;
-    public ArrayList<MethodInfo> methods = new ArrayList<MethodInfo>();
-    
-    private ClassInfo mClass;
-    private String mName;
-    private Comment mComment;
-
-    public AttributeInfo(ClassInfo cl, FieldInfo f) {
-        mClass = cl;
-        attrField = f;
-    }
-
-    public String name() {
-        if (mName == null) {
-            for (AttrTagInfo comment: attrField.comment().attrTags()) {
-                String n = comment.name();
-                if (n != null) {
-                    mName = n;
-                    return n;
-                }
-            }
-        }
-        return mName;
-    }
-
-    public Comment comment() {
-        if (mComment == null) {
-            for (AttrTagInfo attr: attrField.comment().attrTags()) {
-                Comment c = attr.description();
-                if (c != null) {
-                    mComment = c;
-                    return c;
-                }
-            }
-        }
-        if (mComment == null) {
-            return new Comment("", mClass, new SourcePositionInfo());
-        }
-        return mComment;
-    }
-    
-    public String anchor() {
-        return "attr_" + name();
-    }
-    public String htmlPage() {
-        return mClass.htmlPage() + "#" + anchor();
-    }
-
-    public void makeHDF(HDF data, String base) {
-        data.setValue(base + ".name", name());
-        data.setValue(base + ".anchor", anchor());
-        data.setValue(base + ".href", htmlPage());
-        data.setValue(base + ".R.name", attrField.name());
-        data.setValue(base + ".R.href", attrField.htmlPage());
-        TagInfo.makeHDF(data, base + ".deprecated", attrField.comment().deprecatedTags());
-        TagInfo.makeHDF(data, base + ".shortDescr", comment().briefTags());
-        TagInfo.makeHDF(data, base + ".descr", comment().tags());
-
-        int i=0;
-        for (MethodInfo m: methods) {
-            String s = base + ".methods." + i;
-            data.setValue(s + ".href", m.htmlPage());
-            data.setValue(s + ".name", m.name() + m.prettySignature());
-        }
-    }
-
-    public boolean checkLevel() {
-        return attrField.checkLevel();
-    }
-}
-
diff --git a/tools/droiddoc/src/ClassInfo.java b/tools/droiddoc/src/ClassInfo.java
deleted file mode 100644
index f3f11de..0000000
--- a/tools/droiddoc/src/ClassInfo.java
+++ /dev/null
@@ -1,1464 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-import com.sun.javadoc.*;
-import com.sun.tools.doclets.*;
-import org.clearsilver.HDF;
-import org.clearsilver.CS;
-import java.util.*;
-import java.io.*;
-
-public class ClassInfo extends DocInfo implements ContainerInfo, Comparable, Scoped
-{
-    public static final Comparator<ClassInfo> comparator = new Comparator<ClassInfo>() {
-        public int compare(ClassInfo a, ClassInfo b) {
-            return a.name().compareTo(b.name());
-        }
-    };
-
-    public static final Comparator<ClassInfo> qualifiedComparator = new Comparator<ClassInfo>() {
-        public int compare(ClassInfo a, ClassInfo b) {
-            return a.qualifiedName().compareTo(b.qualifiedName());
-        }
-    };
-
-    public ClassInfo(
-            ClassDoc cl,
-            String rawCommentText, SourcePositionInfo position,
-            boolean isPublic, boolean isProtected, boolean isPackagePrivate,
-            boolean isPrivate, boolean isStatic,
-            boolean isInterface, boolean isAbstract, boolean isOrdinaryClass,
-            boolean isException, boolean isError, boolean isEnum, boolean isAnnotation,
-            boolean isFinal, boolean isIncluded, String name,
-            String qualifiedName, String qualifiedTypeName, boolean isPrimitive)
-    {
-        super(rawCommentText, position);
-
-        mClass = cl;
-        mIsPublic = isPublic;
-        mIsProtected = isProtected;
-        mIsPackagePrivate = isPackagePrivate;
-        mIsPrivate = isPrivate;
-        mIsStatic = isStatic;
-        mIsInterface = isInterface;
-        mIsAbstract = isAbstract;
-        mIsOrdinaryClass = isOrdinaryClass;
-        mIsException = isException;
-        mIsError = isError;
-        mIsEnum = isEnum;
-        mIsAnnotation = isAnnotation;
-        mIsFinal = isFinal;
-        mIsIncluded = isIncluded;
-        mName = name;
-        mQualifiedName = qualifiedName;
-        mQualifiedTypeName = qualifiedTypeName;
-        mIsPrimitive = isPrimitive;
-        mNameParts = name.split("\\.");
-    }
-
-    public void init(TypeInfo typeInfo, ClassInfo[] interfaces, TypeInfo[] interfaceTypes,
-            ClassInfo[] innerClasses,
-            MethodInfo[] constructors, MethodInfo[] methods, MethodInfo[] annotationElements,
-            FieldInfo[] fields, FieldInfo[] enumConstants,
-            PackageInfo containingPackage, ClassInfo containingClass,
-            ClassInfo superclass, TypeInfo superclassType, AnnotationInstanceInfo[] annotations)
-    {
-        mTypeInfo = typeInfo;
-        mRealInterfaces = interfaces;
-        mRealInterfaceTypes = interfaceTypes;
-        mInnerClasses = innerClasses;
-        mAllConstructors = constructors;
-        mAllSelfMethods = methods;
-        mAnnotationElements = annotationElements;
-        mAllSelfFields = fields;
-        mEnumConstants = enumConstants;
-        mContainingPackage = containingPackage;
-        mContainingClass = containingClass;
-        mRealSuperclass = superclass;
-        mRealSuperclassType = superclassType;
-        mAnnotations = annotations;
-
-        // after providing new methods and new superclass info,clear any cached
-        // lists of self + superclass methods, ctors, etc.
-        mSuperclassInit = false;
-        mConstructors = null;
-        mMethods = null;
-        mSelfMethods = null;
-        mFields = null;
-        mSelfFields = null;
-        mSelfAttributes = null;
-        mDeprecatedKnown = false;
-
-        Arrays.sort(mEnumConstants, FieldInfo.comparator);
-        Arrays.sort(mInnerClasses, ClassInfo.comparator);
-    }
-
-    public void init2() {
-        // calling this here forces the AttrTagInfo objects to be linked to the AttribtueInfo
-        // objects
-        selfAttributes();
-    }
-
-    public void init3(TypeInfo[] types, ClassInfo[] realInnerClasses){
-      mTypeParameters = types;
-      mRealInnerClasses = realInnerClasses;
-    }
-
-    public ClassInfo[] getRealInnerClasses(){
-      return mRealInnerClasses;
-    }
-
-    public TypeInfo[] getTypeParameters(){
-      return mTypeParameters;
-    }
-
-    public boolean checkLevel()
-    {
-        int val = mCheckLevel;
-        if (val >= 0) {
-            return val != 0;
-        } else {
-            boolean v = DroidDoc.checkLevel(mIsPublic, mIsProtected,
-                                                mIsPackagePrivate, mIsPrivate, isHidden());
-            mCheckLevel = v ? 1 : 0;
-            return v;
-        }
-    }
-
-    public int compareTo(Object that) {
-        if (that instanceof ClassInfo) {
-            return mQualifiedName.compareTo(((ClassInfo)that).mQualifiedName);
-        } else {
-            return this.hashCode() - that.hashCode();
-        }
-    }
-
-    @Override
-    public ContainerInfo parent()
-    {
-        return this;
-    }
-
-    public boolean isPublic()
-    {
-        return mIsPublic;
-    }
-
-    public boolean isProtected()
-    {
-        return mIsProtected;
-    }
-
-    public boolean isPackagePrivate()
-    {
-        return mIsPackagePrivate;
-    }
-
-    public boolean isPrivate()
-    {
-        return mIsPrivate;
-    }
-
-    public boolean isStatic()
-    {
-        return mIsStatic;
-    }
-
-    public boolean isInterface()
-    {
-        return mIsInterface;
-    }
-
-    public boolean isAbstract()
-    {
-        return mIsAbstract;
-    }
-
-    public PackageInfo containingPackage()
-    {
-        return mContainingPackage;
-    }
-
-    public ClassInfo containingClass()
-    {
-        return mContainingClass;
-    }
-
-    public boolean isOrdinaryClass()
-    {
-        return mIsOrdinaryClass;
-    }
-
-    public boolean isException()
-    {
-        return mIsException;
-    }
-
-    public boolean isError()
-    {
-        return mIsError;
-    }
-
-    public boolean isEnum()
-    {
-        return mIsEnum;
-    }
-
-    public boolean isAnnotation()
-    {
-        return mIsAnnotation;
-    }
-
-    public boolean isFinal()
-    {
-        return mIsFinal;
-    }
-
-    public boolean isIncluded()
-    {
-        return mIsIncluded;
-    }
-
-    public HashSet<String> typeVariables()
-    {
-        HashSet<String> result = TypeInfo.typeVariables(mTypeInfo.typeArguments());
-        ClassInfo cl = containingClass();
-        while (cl != null) {
-            TypeInfo[] types = cl.asTypeInfo().typeArguments();
-            if (types != null) {
-                TypeInfo.typeVariables(types, result);
-            }
-            cl = cl.containingClass();
-        }
-        return result;
-    }
-
-    private static void gatherHiddenInterfaces(ClassInfo cl, HashSet<ClassInfo> interfaces) {
-        for (ClassInfo iface: cl.mRealInterfaces) {
-            if (iface.checkLevel()) {
-                interfaces.add(iface);
-            } else {
-                gatherHiddenInterfaces(iface, interfaces);
-            }
-        }
-    }
-
-    public ClassInfo[] interfaces()
-    {
-        if (mInterfaces == null) {
-            if (checkLevel()) {
-                HashSet<ClassInfo> interfaces = new HashSet<ClassInfo>();
-                ClassInfo superclass = mRealSuperclass;
-                while (superclass != null && !superclass.checkLevel()) {
-                    gatherHiddenInterfaces(superclass, interfaces);
-                    superclass = superclass.mRealSuperclass;
-                }
-                gatherHiddenInterfaces(this, interfaces);
-                mInterfaces = interfaces.toArray(new ClassInfo[interfaces.size()]);
-            } else {
-                // put something here in case someone uses it
-                mInterfaces = mRealInterfaces;
-            }
-            Arrays.sort(mInterfaces, ClassInfo.qualifiedComparator);
-        }
-        return mInterfaces;
-    }
-
-    public ClassInfo[] realInterfaces()
-    {
-        return mRealInterfaces;
-    }
-
-    TypeInfo[] realInterfaceTypes()
-    {
-        return mRealInterfaceTypes;
-    }
-
-    public String name()
-    {
-        return mName;
-    }
-
-    public String[] nameParts()
-    {
-        return mNameParts;
-    }
-
-    public String leafName()
-    {
-        return mNameParts[mNameParts.length-1];
-    }
-
-    public String qualifiedName()
-    {
-        return mQualifiedName;
-    }
-
-    public String qualifiedTypeName()
-    {
-        return mQualifiedTypeName;
-    }
-
-    public boolean isPrimitive()
-    {
-        return mIsPrimitive;
-    }
-
-    public MethodInfo[] allConstructors() {
-        return mAllConstructors;
-    }
-
-    public MethodInfo[] constructors()
-    {
-        if (mConstructors == null) {
-            MethodInfo[] methods = mAllConstructors;
-            ArrayList<MethodInfo> ctors = new ArrayList<MethodInfo>();
-            for (int i=0; i<methods.length; i++) {
-                MethodInfo m = methods[i];
-                if (!m.isHidden()) {
-                    ctors.add(m);
-                }
-            }
-            mConstructors = ctors.toArray(new MethodInfo[ctors.size()]);
-            Arrays.sort(mConstructors, MethodInfo.comparator);
-        }
-        return mConstructors;
-    }
-
-    public ClassInfo[] innerClasses()
-    {
-        return mInnerClasses;
-    }
-
-    public TagInfo[] inlineTags()
-    {
-        return comment().tags();
-    }
-
-    public TagInfo[] firstSentenceTags()
-    {
-        return comment().briefTags();
-    }
-
-    public boolean isDeprecated() {
-        boolean deprecated = false;
-        if (!mDeprecatedKnown) {
-            boolean commentDeprecated = (comment().deprecatedTags().length > 0);
-            boolean annotationDeprecated = false;
-            for (AnnotationInstanceInfo annotation : annotations()) {
-                if (annotation.type().qualifiedName().equals("java.lang.Deprecated")) {
-                    annotationDeprecated = true;
-                    break;
-                }
-            }
-
-            if (commentDeprecated != annotationDeprecated) {
-                Errors.error(Errors.DEPRECATION_MISMATCH, position(),
-                        "Class " + qualifiedName()
-                        + ": @Deprecated annotation and @deprecated comment do not match");
-            }
-
-            mIsDeprecated = commentDeprecated | annotationDeprecated;
-            mDeprecatedKnown = true;
-        }
-        return mIsDeprecated;
-    }
-
-    public TagInfo[] deprecatedTags()
-    {
-        // Should we also do the interfaces?
-        return comment().deprecatedTags();
-    }
-
-    public MethodInfo[] methods()
-    {
-        if (mMethods == null) {
-            TreeMap<String,MethodInfo> all = new TreeMap<String,MethodInfo>();
-
-            ClassInfo[] ifaces = interfaces();
-            for (ClassInfo iface: ifaces) {
-                if (iface != null) {
-                    MethodInfo[] inhereted = iface.methods();
-                    for (MethodInfo method: inhereted) {
-                        String key = method.name() + method.signature();
-                        all.put(key, method);
-                    }
-                }
-            }
-
-            ClassInfo superclass = superclass();
-            if (superclass != null) {
-                MethodInfo[] inhereted = superclass.methods();
-                for (MethodInfo method: inhereted) {
-                    String key = method.name() + method.signature();
-                    all.put(key, method);
-                }
-            }
-
-            MethodInfo[] methods = selfMethods();
-            for (MethodInfo method: methods) {
-                String key = method.name() + method.signature();
-                MethodInfo old = all.put(key, method);
-            }
-
-            mMethods = all.values().toArray(new MethodInfo[all.size()]);
-        }
-        return mMethods;
-    }
-
-    public MethodInfo[] annotationElements()
-    {
-        return mAnnotationElements;
-    }
-
-    public AnnotationInstanceInfo[] annotations()
-    {
-        return mAnnotations;
-    }
-
-    private static void addFields(ClassInfo cl, TreeMap<String,FieldInfo> all)
-    {
-        FieldInfo[] fields = cl.fields();
-        int N = fields.length;
-        for (int i=0; i<N; i++) {
-            FieldInfo f = fields[i];
-            all.put(f.name(), f);
-        }
-    }
-
-    public FieldInfo[] fields()
-    {
-        if (mFields == null) {
-            int N;
-            TreeMap<String,FieldInfo> all = new TreeMap<String,FieldInfo>();
-
-            ClassInfo[] interfaces = interfaces();
-            N = interfaces.length;
-            for (int i=0; i<N; i++) {
-                addFields(interfaces[i], all);
-            }
-
-            ClassInfo superclass = superclass();
-            if (superclass != null) {
-                addFields(superclass, all);
-            }
-
-            FieldInfo[] fields = selfFields();
-            N = fields.length;
-            for (int i=0; i<N; i++) {
-                FieldInfo f = fields[i];
-                if (!f.isHidden()) {
-                    String key = f.name();
-                    all.put(key, f);
-                }
-            }
-
-            mFields = all.values().toArray(new FieldInfo[0]);
-        }
-        return mFields;
-    }
-
-    public void gatherFields(ClassInfo owner, ClassInfo cl, HashMap<String,FieldInfo> fields) {
-        FieldInfo[] flds = cl.selfFields();
-        for (FieldInfo f: flds) {
-            if (f.checkLevel()) {
-                fields.put(f.name(), f.cloneForClass(owner));
-            }
-        }
-    }
-
-    public FieldInfo[] selfFields()
-    {
-        if (mSelfFields == null) {
-            HashMap<String,FieldInfo> fields = new HashMap<String,FieldInfo>();
-            // our hidden parents
-            if (mRealSuperclass != null && !mRealSuperclass.checkLevel()) {
-                gatherFields(this, mRealSuperclass, fields);
-            }
-            for (ClassInfo iface: mRealInterfaces) {
-                if (!iface.checkLevel()) {
-                    gatherFields(this, iface, fields);
-                }
-            }
-            // mine
-            FieldInfo[] selfFields = mAllSelfFields;
-            for (int i=0; i<selfFields.length; i++) {
-                FieldInfo f = selfFields[i];
-                if (!f.isHidden()) {
-                    fields.put(f.name(), f);
-                }
-            }
-            // combine and return in
-            mSelfFields = fields.values().toArray(new FieldInfo[fields.size()]);
-            Arrays.sort(mSelfFields, FieldInfo.comparator);
-        }
-        return mSelfFields;
-    }
-
-    public FieldInfo[] allSelfFields() {
-        return mAllSelfFields;
-    }
-
-    public void gatherMethods(ClassInfo owner, ClassInfo cl, HashMap<String,MethodInfo> methods) {
-        MethodInfo[] meth = cl.selfMethods();
-        for (MethodInfo m: meth) {
-            if (m.checkLevel()) {
-                methods.put(m.name()+m.signature(), m.cloneForClass(owner));
-            }
-        }
-    }
-
-    public MethodInfo[] selfMethods()
-    {
-        if (mSelfMethods == null) {
-            HashMap<String,MethodInfo> methods = new HashMap<String,MethodInfo>();
-            // our hidden parents
-            if (mRealSuperclass != null && !mRealSuperclass.checkLevel()) {
-                gatherMethods(this, mRealSuperclass, methods);
-            }
-            for (ClassInfo iface: mRealInterfaces) {
-                if (!iface.checkLevel()) {
-                    gatherMethods(this, iface, methods);
-                }
-            }
-            // mine
-            MethodInfo[] selfMethods = mAllSelfMethods;
-            for (int i=0; i<selfMethods.length; i++) {
-                MethodInfo m = selfMethods[i];
-                if (m.checkLevel()) {
-                    methods.put(m.name()+m.signature(), m);
-                }
-            }
-            // combine and return it
-            mSelfMethods = methods.values().toArray(new MethodInfo[methods.size()]);
-            Arrays.sort(mSelfMethods, MethodInfo.comparator);
-        }
-        return mSelfMethods;
-    }
-
-    public MethodInfo[] allSelfMethods() {
-        return mAllSelfMethods;
-    }
-
-    public void addMethod(MethodInfo method) {
-        MethodInfo[] methods = new MethodInfo[mAllSelfMethods.length + 1];
-        int i = 0;
-        for (MethodInfo m : mAllSelfMethods) {
-            methods[i] = m;
-            i++;
-        }
-        methods[i] = method;
-        mAllSelfMethods = methods;
-    }
-
-    public AttributeInfo[] selfAttributes()
-    {
-        if (mSelfAttributes == null) {
-            TreeMap<FieldInfo,AttributeInfo> attrs = new TreeMap<FieldInfo,AttributeInfo>();
-
-            // the ones in the class comment won't have any methods
-            for (AttrTagInfo tag: comment().attrTags()) {
-                FieldInfo field = tag.reference();
-                if (field != null) {
-                    AttributeInfo attr = attrs.get(field);
-                    if (attr == null) {
-                        attr = new AttributeInfo(this, field);
-                        attrs.put(field, attr);
-                    }
-                    tag.setAttribute(attr);
-                }
-            }
-
-            // in the methods
-            for (MethodInfo m: selfMethods()) {
-                for (AttrTagInfo tag: m.comment().attrTags()) {
-                    FieldInfo field = tag.reference();
-                    if (field != null) {
-                        AttributeInfo attr = attrs.get(field);
-                        if (attr == null) {
-                            attr = new AttributeInfo(this, field);
-                            attrs.put(field, attr);
-                        }
-                        tag.setAttribute(attr);
-                        attr.methods.add(m);
-                    }
-                }
-            }
-
-            //constructors too
-           for (MethodInfo m: constructors()) {
-              for (AttrTagInfo tag: m.comment().attrTags()) {
-                  FieldInfo field = tag.reference();
-                  if (field != null) {
-                      AttributeInfo attr = attrs.get(field);
-                      if (attr == null) {
-                          attr = new AttributeInfo(this, field);
-                          attrs.put(field, attr);
-                      }
-                      tag.setAttribute(attr);
-                      attr.methods.add(m);
-                  }
-              }
-          }
-
-            mSelfAttributes = attrs.values().toArray(new AttributeInfo[attrs.size()]);
-            Arrays.sort(mSelfAttributes, AttributeInfo.comparator);
-        }
-        return mSelfAttributes;
-    }
-
-    public FieldInfo[] enumConstants()
-    {
-        return mEnumConstants;
-    }
-
-    public ClassInfo superclass()
-    {
-        if (!mSuperclassInit) {
-            if (this.checkLevel()) {
-                // rearrange our little inheritance hierarchy, because we need to hide classes that
-                // don't pass checkLevel
-                ClassInfo superclass = mRealSuperclass;
-                while (superclass != null && !superclass.checkLevel()) {
-                    superclass = superclass.mRealSuperclass;
-                }
-                mSuperclass = superclass;
-            } else {
-                mSuperclass = mRealSuperclass;
-            }
-        }
-        return mSuperclass;
-    }
-
-    public ClassInfo realSuperclass()
-    {
-        return mRealSuperclass;
-    }
-
-    /** always the real superclass, not the collapsed one we get through superclass(),
-     * also has the type parameter info if it's generic.
-     */
-    public TypeInfo superclassType()
-    {
-        return mRealSuperclassType;
-    }
-
-    public TypeInfo asTypeInfo()
-    {
-        return mTypeInfo;
-    }
-
-    TypeInfo[] interfaceTypes()
-    {
-        ClassInfo[] infos = interfaces();
-        int len = infos.length;
-        TypeInfo[] types = new TypeInfo[len];
-        for (int i=0; i<len; i++) {
-            types[i] = infos[i].asTypeInfo();
-        }
-        return types;
-    }
-
-    public String htmlPage()
-    {
-        String s = containingPackage().name();
-        s = s.replace('.', '/');
-        s += '/';
-        s += name();
-        s += ".html";
-        s = DroidDoc.javadocDir + s;
-        return s;
-    }
-
-    /** Even indirectly */
-    public boolean isDerivedFrom(ClassInfo cl)
-    {
-        ClassInfo dad = this.superclass();
-        if (dad != null) {
-            if (dad.equals(cl)) {
-                return true;
-            } else {
-                if (dad.isDerivedFrom(cl)) {
-                    return true;
-                }
-            }
-        }
-        for (ClassInfo iface: interfaces()) {
-            if (iface.equals(cl)) {
-                return true;
-            } else {
-                if (iface.isDerivedFrom(cl)) {
-                    return true;
-                }
-            }
-        }
-        return false;
-    }
-
-    public void makeKeywordEntries(List<KeywordEntry> keywords)
-    {
-        if (!checkLevel()) {
-            return;
-        }
-
-        String htmlPage = htmlPage();
-        String qualifiedName = qualifiedName();
-
-        keywords.add(new KeywordEntry(name(), htmlPage,
-                "class in " + containingPackage().name()));
-
-        FieldInfo[] fields = selfFields();
-        FieldInfo[] enumConstants = enumConstants();
-        MethodInfo[] ctors = constructors();
-        MethodInfo[] methods = selfMethods();
-
-        // enum constants
-        for (FieldInfo field: enumConstants()) {
-            if (field.checkLevel()) {
-                keywords.add(new KeywordEntry(field.name(),
-                            htmlPage + "#" + field.anchor(),
-                            "enum constant in " + qualifiedName));
-            }
-        }
-
-        // constants
-        for (FieldInfo field: fields) {
-            if (field.isConstant() && field.checkLevel()) {
-                keywords.add(new KeywordEntry(field.name(),
-                            htmlPage + "#" + field.anchor(),
-                            "constant in " + qualifiedName));
-            }
-        }
-
-        // fields
-        for (FieldInfo field: fields) {
-            if (!field.isConstant() && field.checkLevel()) {
-                keywords.add(new KeywordEntry(field.name(),
-                            htmlPage + "#" + field.anchor(),
-                            "field in " + qualifiedName));
-            }
-        }
-
-        // public constructors
-        for (MethodInfo m: ctors) {
-            if (m.isPublic() && m.checkLevel()) {
-                keywords.add(new KeywordEntry(m.name() + m.prettySignature(),
-                            htmlPage + "#" + m.anchor(),
-                            "constructor in " + qualifiedName));
-            }
-        }
-
-        // protected constructors
-        if (DroidDoc.checkLevel(DroidDoc.SHOW_PROTECTED)) {
-            for (MethodInfo m: ctors) {
-                if (m.isProtected() && m.checkLevel()) {
-                    keywords.add(new KeywordEntry(m.name() + m.prettySignature(),
-                                htmlPage + "#" + m.anchor(),
-                                "constructor in " + qualifiedName));
-                }
-            }
-        }
-
-        // package private constructors
-        if (DroidDoc.checkLevel(DroidDoc.SHOW_PACKAGE)) {
-            for (MethodInfo m: ctors) {
-                if (m.isPackagePrivate() && m.checkLevel()) {
-                    keywords.add(new KeywordEntry(m.name() + m.prettySignature(),
-                                htmlPage + "#" + m.anchor(),
-                                "constructor in " + qualifiedName));
-                }
-            }
-        }
-
-        // private constructors
-        if (DroidDoc.checkLevel(DroidDoc.SHOW_PRIVATE)) {
-            for (MethodInfo m: ctors) {
-                if (m.isPrivate() && m.checkLevel()) {
-                    keywords.add(new KeywordEntry(m.name() + m.prettySignature(),
-                                htmlPage + "#" + m.anchor(),
-                                "constructor in " + qualifiedName));
-                }
-            }
-        }
-
-        // public methods
-        for (MethodInfo m: methods) {
-            if (m.isPublic() && m.checkLevel()) {
-                keywords.add(new KeywordEntry(m.name() + m.prettySignature(),
-                            htmlPage + "#" + m.anchor(),
-                            "method in " + qualifiedName));
-            }
-        }
-
-        // protected methods
-        if (DroidDoc.checkLevel(DroidDoc.SHOW_PROTECTED)) {
-            for (MethodInfo m: methods) {
-                if (m.isProtected() && m.checkLevel()) {
-                    keywords.add(new KeywordEntry(m.name() + m.prettySignature(),
-                                htmlPage + "#" + m.anchor(),
-                                "method in " + qualifiedName));
-                }
-            }
-        }
-
-        // package private methods
-        if (DroidDoc.checkLevel(DroidDoc.SHOW_PACKAGE)) {
-            for (MethodInfo m: methods) {
-                if (m.isPackagePrivate() && m.checkLevel()) {
-                    keywords.add(new KeywordEntry(m.name() + m.prettySignature(),
-                                htmlPage + "#" + m.anchor(),
-                                "method in " + qualifiedName));
-                }
-            }
-        }
-
-        // private methods
-        if (DroidDoc.checkLevel(DroidDoc.SHOW_PRIVATE)) {
-            for (MethodInfo m: methods) {
-                if (m.isPrivate() && m.checkLevel()) {
-                    keywords.add(new KeywordEntry(m.name() + m.prettySignature(),
-                                htmlPage + "#" + m.anchor(),
-                                "method in " + qualifiedName));
-                }
-            }
-        }
-    }
-
-    public void makeLink(HDF data, String base)
-    {
-        data.setValue(base + ".label", this.name());
-        if (!this.isPrimitive() && this.isIncluded() && this.checkLevel()) {
-            data.setValue(base + ".link", this.htmlPage());
-        }
-    }
-
-    public static void makeLinkListHDF(HDF data, String base, ClassInfo[] classes) {
-        final int N = classes.length;
-        for (int i=0; i<N; i++) {
-            ClassInfo cl = classes[i];
-            if (cl.checkLevel()) {
-                cl.asTypeInfo().makeHDF(data, base + "." + i);
-            }
-        }
-    }
-
-    /**
-     * Used in lists of this class (packages, nested classes, known subclasses)
-     */
-    public void makeShortDescrHDF(HDF data, String base)
-    {
-        mTypeInfo.makeHDF(data, base + ".type");
-        data.setValue(base + ".kind", this.kind());
-        TagInfo.makeHDF(data, base + ".shortDescr", this.firstSentenceTags());
-        TagInfo.makeHDF(data, base + ".deprecated", deprecatedTags());
-        data.setValue(base + ".since", getSince());
-    }
-
-    /**
-     * Turns into the main class page
-     */
-    public void makeHDF(HDF data)
-    {
-        int i, j, n;
-        String name = name();
-        String qualified = qualifiedName();
-        AttributeInfo[] selfAttributes = selfAttributes();
-        MethodInfo[] methods = selfMethods();
-        FieldInfo[] fields = selfFields();
-        FieldInfo[] enumConstants = enumConstants();
-        MethodInfo[] ctors = constructors();
-        ClassInfo[] inners = innerClasses();
-
-        // class name
-        mTypeInfo.makeHDF(data, "class.type");
-        mTypeInfo.makeQualifiedHDF(data, "class.qualifiedType");
-        data.setValue("class.name", name);
-        data.setValue("class.qualified", qualified);
-        String scope = "";
-        if (isProtected()) {
-            data.setValue("class.scope", "protected");
-        }
-        else if (isPublic()) {
-            data.setValue("class.scope", "public");
-        }
-        if (isStatic()) {
-            data.setValue("class.static", "static");
-        }
-        if (isFinal()) {
-            data.setValue("class.final", "final");
-        }
-        if (isAbstract() && !isInterface()) {
-            data.setValue("class.abstract", "abstract");
-        }
-
-        // class info
-        String kind = kind();
-        if (kind != null) {
-            data.setValue("class.kind", kind);
-        }
-        data.setValue("class.since", getSince());
-
-        // the containing package -- note that this can be passed to type_link,
-        // but it also contains the list of all of the packages
-        containingPackage().makeClassLinkListHDF(data, "class.package");
-
-        // inheritance hierarchy
-        Vector<ClassInfo> superClasses = new Vector<ClassInfo>();
-        superClasses.add(this);
-        ClassInfo supr = superclass();
-        while (supr != null) {
-            superClasses.add(supr);
-            supr = supr.superclass();
-        }
-        n = superClasses.size();
-        for (i=0; i<n; i++) {
-            supr = superClasses.elementAt(n-i-1);
-
-            supr.asTypeInfo().makeQualifiedHDF(data, "class.inheritance." + i + ".class");
-            supr.asTypeInfo().makeHDF(data, "class.inheritance." + i + ".short_class");
-            j = 0;
-            for (TypeInfo t: supr.interfaceTypes()) {
-                t.makeHDF(data, "class.inheritance." + i + ".interfaces." + j);
-                j++;
-            }
-        }
-
-        // class description
-        TagInfo.makeHDF(data, "class.descr", inlineTags());
-        TagInfo.makeHDF(data, "class.seeAlso", comment().seeTags());
-        TagInfo.makeHDF(data, "class.deprecated", deprecatedTags());
-
-        // known subclasses
-        TreeMap<String, ClassInfo> direct = new TreeMap<String, ClassInfo>();
-        TreeMap<String, ClassInfo> indirect = new TreeMap<String, ClassInfo>();
-        ClassInfo[] all = Converter.rootClasses();
-        for (ClassInfo cl: all) {
-            if (cl.superclass() != null && cl.superclass().equals(this)) {
-                direct.put(cl.name(), cl);
-            }
-            else if (cl.isDerivedFrom(this)) {
-                indirect.put(cl.name(), cl);
-            }
-        }
-        // direct
-        i = 0;
-        for (ClassInfo cl: direct.values()) {
-            if (cl.checkLevel()) {
-                cl.makeShortDescrHDF(data, "class.subclasses.direct." + i);
-            }
-            i++;
-        }
-        // indirect
-        i = 0;
-        for (ClassInfo cl: indirect.values()) {
-            if (cl.checkLevel()) {
-                cl.makeShortDescrHDF(data, "class.subclasses.indirect." + i);
-            }
-            i++;
-        }
-
-        // nested classes
-        i=0;
-        for (ClassInfo inner: inners) {
-            if (inner.checkLevel()) {
-                inner.makeShortDescrHDF(data, "class.inners." + i);
-            }
-            i++;
-        }
-
-        // enum constants
-        i=0;
-        for (FieldInfo field: enumConstants) {
-            if (field.isConstant()) {
-                field.makeHDF(data, "class.enumConstants." + i);
-                i++;
-            }
-        }
-
-        // constants
-        i=0;
-        for (FieldInfo field: fields) {
-            if (field.isConstant()) {
-                field.makeHDF(data, "class.constants." + i);
-                i++;
-            }
-        }
-
-        // fields
-        i=0;
-        for (FieldInfo field: fields) {
-            if (!field.isConstant()) {
-                field.makeHDF(data, "class.fields." + i);
-                i++;
-            }
-        }
-
-        // public constructors
-        i=0;
-        for (MethodInfo ctor: ctors) {
-            if (ctor.isPublic()) {
-                ctor.makeHDF(data, "class.ctors.public." + i);
-                i++;
-            }
-        }
-
-        // protected constructors
-        if (DroidDoc.checkLevel(DroidDoc.SHOW_PROTECTED)) {
-            i=0;
-            for (MethodInfo ctor: ctors) {
-                if (ctor.isProtected()) {
-                    ctor.makeHDF(data, "class.ctors.protected." + i);
-                    i++;
-                }
-            }
-        }
-
-        // package private constructors
-        if (DroidDoc.checkLevel(DroidDoc.SHOW_PACKAGE)) {
-            i=0;
-            for (MethodInfo ctor: ctors) {
-                if (ctor.isPackagePrivate()) {
-                    ctor.makeHDF(data, "class.ctors.package." + i);
-                    i++;
-                }
-            }
-        }
-
-        // private constructors
-        if (DroidDoc.checkLevel(DroidDoc.SHOW_PRIVATE)) {
-            i=0;
-            for (MethodInfo ctor: ctors) {
-                if (ctor.isPrivate()) {
-                    ctor.makeHDF(data, "class.ctors.private." + i);
-                    i++;
-                }
-            }
-        }
-
-        // public methods
-        i=0;
-        for (MethodInfo method: methods) {
-            if (method.isPublic()) {
-                method.makeHDF(data, "class.methods.public." + i);
-                i++;
-            }
-        }
-
-        // protected methods
-        if (DroidDoc.checkLevel(DroidDoc.SHOW_PROTECTED)) {
-            i=0;
-            for (MethodInfo method: methods) {
-                if (method.isProtected()) {
-                    method.makeHDF(data, "class.methods.protected." + i);
-                    i++;
-                }
-            }
-        }
-
-        // package private methods
-        if (DroidDoc.checkLevel(DroidDoc.SHOW_PACKAGE)) {
-            i=0;
-            for (MethodInfo method: methods) {
-                if (method.isPackagePrivate()) {
-                    method.makeHDF(data, "class.methods.package." + i);
-                    i++;
-                }
-            }
-        }
-
-        // private methods
-        if (DroidDoc.checkLevel(DroidDoc.SHOW_PRIVATE)) {
-            i=0;
-            for (MethodInfo method: methods) {
-                if (method.isPrivate()) {
-                    method.makeHDF(data, "class.methods.private." + i);
-                    i++;
-                }
-            }
-        }
-
-        // xml attributes
-        i=0;
-        for (AttributeInfo attr: selfAttributes) {
-            if (attr.checkLevel()) {
-                attr.makeHDF(data, "class.attrs." + i);
-                i++;
-            }
-        }
-
-        // inherited methods
-        Set<ClassInfo> interfaces = new TreeSet<ClassInfo>();
-        addInterfaces(interfaces(), interfaces);
-        ClassInfo cl = superclass();
-        i=0;
-        while (cl != null) {
-            addInterfaces(cl.interfaces(), interfaces);
-            makeInheritedHDF(data, i, cl);
-            cl = cl.superclass();
-            i++;
-        }
-        for (ClassInfo iface: interfaces) {
-            makeInheritedHDF(data, i, iface);
-            i++;
-        }
-    }
-
-    private static void addInterfaces(ClassInfo[] ifaces, Set<ClassInfo> out)
-    {
-        for (ClassInfo cl: ifaces) {
-            out.add(cl);
-            addInterfaces(cl.interfaces(), out);
-        }
-    }
-
-    private static void makeInheritedHDF(HDF data, int index, ClassInfo cl)
-    {
-        int i;
-
-        String base = "class.inherited." + index;
-        data.setValue(base + ".qualified", cl.qualifiedName());
-        if (cl.checkLevel()) {
-            data.setValue(base + ".link", cl.htmlPage());
-        }
-        String kind = cl.kind();
-        if (kind != null) {
-            data.setValue(base + ".kind", kind);
-        }
-
-        if (cl.mIsIncluded) {
-            data.setValue(base + ".included", "true");
-        }
-
-        // xml attributes
-        i=0;
-        for (AttributeInfo attr: cl.selfAttributes()) {
-            attr.makeHDF(data, base + ".attrs." + i);
-            i++;
-        }
-
-        // methods
-        i=0;
-        for (MethodInfo method: cl.selfMethods()) {
-            method.makeHDF(data, base + ".methods." + i);
-            i++;
-        }
-
-        // fields
-        i=0;
-        for (FieldInfo field: cl.selfFields()) {
-            if (!field.isConstant()) {
-                field.makeHDF(data, base + ".fields." + i);
-                i++;
-            }
-        }
-
-        // constants
-        i=0;
-        for (FieldInfo field: cl.selfFields()) {
-            if (field.isConstant()) {
-                field.makeHDF(data, base + ".constants." + i);
-                i++;
-            }
-        }
-    }
-
-    @Override
-    public boolean isHidden()
-    {
-        int val = mHidden;
-        if (val >= 0) {
-            return val != 0;
-        } else {
-            boolean v = isHiddenImpl();
-            mHidden = v ? 1 : 0;
-            return v;
-        }
-    }
-
-    public boolean isHiddenImpl()
-    {
-        ClassInfo cl = this;
-        while (cl != null) {
-            PackageInfo pkg = cl.containingPackage();
-            if (pkg != null && pkg.isHidden()) {
-                return true;
-            }
-            if (cl.comment().isHidden()) {
-                return true;
-            }
-            cl = cl.containingClass();
-        }
-        return false;
-    }
-
-    private MethodInfo matchMethod(MethodInfo[] methods, String name,
-                                    String[] params, String[] dimensions)
-    {
-        int len = methods.length;
-        for (int i=0; i<len; i++) {
-            MethodInfo method = methods[i];
-            if (method.name().equals(name)) {
-                if (params == null) {
-                    return method;
-                } else {
-                    if (method.matchesParams(params, dimensions)) {
-                        return method;
-                    }
-                }
-            }
-        }
-        return null;
-    }
-
-    public MethodInfo findMethod(String name,
-                                    String[] params, String[] dimensions)
-    {
-        // first look on our class, and our superclasses
-
-        // for methods
-        MethodInfo rv;
-        rv = matchMethod(methods(), name, params, dimensions);
-
-        if (rv != null) {
-            return rv;
-        }
-
-        // for constructors
-        rv = matchMethod(constructors(), name, params, dimensions);
-        if (rv != null) {
-            return rv;
-        }
-
-        // then recursively look at our containing class
-        ClassInfo containing = containingClass();
-        if (containing != null) {
-            return containing.findMethod(name, params, dimensions);
-        }
-
-        return null;
-    }
-
-    private ClassInfo searchInnerClasses(String[] nameParts, int index)
-    {
-        String part = nameParts[index];
-
-        ClassInfo[] inners = mInnerClasses;
-        for (ClassInfo in: inners) {
-            String[] innerParts = in.nameParts();
-            if (part.equals(innerParts[innerParts.length-1])) {
-                if (index == nameParts.length-1) {
-                    return in;
-                } else {
-                    return in.searchInnerClasses(nameParts, index+1);
-                }
-            }
-        }
-        return null;
-    }
-
-    public ClassInfo extendedFindClass(String className)
-    {
-        // ClassDoc.findClass has this bug that we're working around here:
-        // If you have a class PackageManager with an inner class PackageInfo
-        // and you call it with "PackageInfo" it doesn't find it.
-        return searchInnerClasses(className.split("\\."), 0);
-    }
-
-    public ClassInfo findClass(String className)
-    {
-        return Converter.obtainClass(mClass.findClass(className));
-    }
-
-    public ClassInfo findInnerClass(String className)
-    {
-        // ClassDoc.findClass won't find inner classes.  To deal with that,
-        // we try what they gave us first, but if that didn't work, then
-        // we see if there are any periods in className, and start searching
-        // from there.
-        String[] nodes = className.split("\\.");
-        ClassDoc cl = mClass;
-        for (String n: nodes) {
-            cl = cl.findClass(n);
-            if (cl == null) {
-                return null;
-            }
-        }
-        return Converter.obtainClass(cl);
-    }
-
-    public FieldInfo findField(String name)
-    {
-        // first look on our class, and our superclasses
-        for (FieldInfo f: fields()) {
-            if (f.name().equals(name)) {
-                return f;
-            }
-        }
-
-        // then look at our enum constants (these are really fields, maybe
-        // they should be mixed into fields().  not sure)
-        for (FieldInfo f: enumConstants()) {
-            if (f.name().equals(name)) {
-                return f;
-            }
-        }
-
-        // then recursively look at our containing class
-        ClassInfo containing = containingClass();
-        if (containing != null) {
-            return containing.findField(name);
-        }
-
-        return null;
-    }
-
-    public static ClassInfo[] sortByName(ClassInfo[] classes)
-    {
-        int i;
-        Sorter[] sorted = new Sorter[classes.length];
-        for (i=0; i<sorted.length; i++) {
-            ClassInfo cl = classes[i];
-            sorted[i] = new Sorter(cl.name(), cl);
-        }
-
-        Arrays.sort(sorted);
-
-        ClassInfo[] rv = new ClassInfo[classes.length];
-        for (i=0; i<rv.length; i++) {
-            rv[i] = (ClassInfo)sorted[i].data;
-        }
-
-        return rv;
-    }
-
-    public boolean equals(ClassInfo that)
-    {
-        if (that != null) {
-            return this.qualifiedName().equals(that.qualifiedName());
-        } else {
-            return false;
-        }
-    }
-
-    public void setNonWrittenConstructors(MethodInfo[] nonWritten) {
-        mNonWrittenConstructors = nonWritten;
-    }
-
-    public MethodInfo[] getNonWrittenConstructors() {
-        return mNonWrittenConstructors;
-    }
-
-    public String kind()
-    {
-        if (isOrdinaryClass()) {
-            return "class";
-        }
-        else if (isInterface()) {
-            return "interface";
-        }
-        else if (isEnum()) {
-            return "enum";
-        }
-        else if (isError()) {
-            return "class";
-        }
-        else if (isException()) {
-            return "class";
-        }
-        else if (isAnnotation()) {
-            return "@interface";
-        }
-        return null;
-    }
-
-    public void setHiddenMethods(MethodInfo[] mInfo){
-        mHiddenMethods = mInfo;
-    }
-    public MethodInfo[] getHiddenMethods(){
-        return mHiddenMethods;
-    }
-    @Override
-    public String toString(){
-        return this.qualifiedName();
-    }
-
-    public void setReasonIncluded(String reason) {
-        mReasonIncluded = reason;
-    }
-
-    public String getReasonIncluded() {
-        return mReasonIncluded;
-    }
-
-    private ClassDoc mClass;
-
-    // ctor
-    private boolean mIsPublic;
-    private boolean mIsProtected;
-    private boolean mIsPackagePrivate;
-    private boolean mIsPrivate;
-    private boolean mIsStatic;
-    private boolean mIsInterface;
-    private boolean mIsAbstract;
-    private boolean mIsOrdinaryClass;
-    private boolean mIsException;
-    private boolean mIsError;
-    private boolean mIsEnum;
-    private boolean mIsAnnotation;
-    private boolean mIsFinal;
-    private boolean mIsIncluded;
-    private String mName;
-    private String mQualifiedName;
-    private String mQualifiedTypeName;
-    private boolean mIsPrimitive;
-    private TypeInfo mTypeInfo;
-    private String[] mNameParts;
-
-    // init
-    private ClassInfo[] mRealInterfaces;
-    private ClassInfo[] mInterfaces;
-    private TypeInfo[] mRealInterfaceTypes;
-    private ClassInfo[] mInnerClasses;
-    private MethodInfo[] mAllConstructors;
-    private MethodInfo[] mAllSelfMethods;
-    private MethodInfo[] mAnnotationElements; // if this class is an annotation
-    private FieldInfo[] mAllSelfFields;
-    private FieldInfo[] mEnumConstants;
-    private PackageInfo mContainingPackage;
-    private ClassInfo mContainingClass;
-    private ClassInfo mRealSuperclass;
-    private TypeInfo mRealSuperclassType;
-    private ClassInfo mSuperclass;
-    private AnnotationInstanceInfo[] mAnnotations;
-    private boolean mSuperclassInit;
-    private boolean mDeprecatedKnown;
-
-    // lazy
-    private MethodInfo[] mConstructors;
-    private ClassInfo[] mRealInnerClasses;
-    private MethodInfo[] mSelfMethods;
-    private FieldInfo[] mSelfFields;
-    private AttributeInfo[] mSelfAttributes;
-    private MethodInfo[] mMethods;
-    private FieldInfo[] mFields;
-    private TypeInfo[] mTypeParameters;
-    private MethodInfo[] mHiddenMethods;
-    private int mHidden = -1;
-    private int mCheckLevel = -1;
-    private String mReasonIncluded;
-    private MethodInfo[] mNonWrittenConstructors;
-    private boolean mIsDeprecated;
-}
diff --git a/tools/droiddoc/src/ClearPage.java b/tools/droiddoc/src/ClearPage.java
deleted file mode 100644
index 016ca93..0000000
--- a/tools/droiddoc/src/ClearPage.java
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-import com.sun.javadoc.*;
-import org.clearsilver.HDF;
-import org.clearsilver.CS;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.OutputStreamWriter;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-public class ClearPage
-{
-    /*
-    public ClearPage()
-    {
-        String templ = "templates/index.cs";
-        String filename = "docs/index.html";
-
-        data.setValue("A.B.C", "1");
-        data.setValue("A.B.D", "2");
-    }
-    */
-
-    public static ArrayList<String> hdfFiles = new ArrayList<String>();
-
-    private static ArrayList<String> mTemplateDirs = new ArrayList<String>();
-    private static boolean mTemplateDirSet = false;
-
-    public static String outputDir = "docs";
-    public static List<String> htmlDirs = new ArrayList<String>();
-    public static String toroot = null;
-
-    public static void addTemplateDir(String dir)
-    {
-        mTemplateDirSet = true;
-        mTemplateDirs.add(dir);
-
-        File hdfFile = new File(dir, "data.hdf");
-        if (hdfFile.canRead()) {
-            hdfFiles.add(hdfFile.getPath());
-        }
-    }
-
-    private static int countSlashes(String s)
-    {
-        final int N = s.length();
-        int slashcount = 0;
-        for (int i=0; i<N; i++) {
-            if (s.charAt(i) == '/') {
-                slashcount++;
-            }
-        }
-        return slashcount;
-    }
-
-    public static void write(HDF data, String templ, String filename)
-    {
-        write(data, templ, filename, false);
-    }
-
-    public static void write(HDF data, String templ, String filename, boolean fullPath)
-    {
-        if (!htmlDirs.isEmpty()) {
-            data.setValue("hasindex", "true");
-        }
-
-        String toroot;
-        if (ClearPage.toroot != null) {
-            toroot = ClearPage.toroot;
-        } else {
-            int slashcount = countSlashes(filename);
-            if (slashcount > 0) {
-                toroot = "";
-                for (int i=0; i<slashcount; i++) {
-                    toroot += "../";
-                }
-            } else {
-                toroot = "./";
-            }
-        }
-        data.setValue("toroot", toroot);
-
-        data.setValue("filename", filename);
-
-        if (!fullPath) {
-            filename = outputDir + "/" + filename;
-        }
-
-        int i=0;
-        if (!htmlDirs.isEmpty()) {
-            for (String dir : htmlDirs) {
-                data.setValue("hdf.loadpaths." + i, dir);
-                i++;
-            }
-        }
-        if (mTemplateDirSet) {
-            for (String dir: mTemplateDirs) {
-                data.setValue("hdf.loadpaths." + i, dir);
-                i++;
-            }
-        } else {
-            data.setValue("hdf.loadpaths." + i, "templates");
-        }
-        
-        CS cs = new CS(data);
-        cs.parseFile(templ);
-
-        File file = new File(outputFilename(filename));
-        
-        ensureDirectory(file);
-
-        OutputStreamWriter stream = null;
-        try {
-            stream = new OutputStreamWriter(
-                            new FileOutputStream(file), "UTF-8");
-            String rendered = cs.render();
-            stream.write(rendered, 0, rendered.length());
-        }
-        catch (IOException e) {
-            System.out.println("error: " + e.getMessage() + "; when writing file: " + filename);
-        }
-        finally {
-            if (stream != null) {
-                try {
-                    stream.close();
-                }
-                catch (IOException e) {
-                }
-            }
-        }
-    }
-
-    // recursively create the directories to the output
-    public static void ensureDirectory(File f)
-    {
-        File parent = f.getParentFile();
-        if (parent != null) {
-            parent.mkdirs();
-        }
-    }
-
-    public static void copyFile(File from, String toPath)
-    {
-        File to = new File(outputDir + "/" + toPath);
-        FileInputStream in;
-        FileOutputStream out;
-        try {
-            if (!from.exists()) {
-                throw new IOException();
-            }
-            in = new FileInputStream(from);
-        }
-        catch (IOException e) {
-            System.err.println(from.getAbsolutePath() + ": Error opening file");
-            return ;
-        }
-        ensureDirectory(to);
-        try {
-            out = new FileOutputStream(to);
-        }
-        catch (IOException e) {
-            System.err.println(from.getAbsolutePath() + ": Error opening file");
-            return ;
-        }
-
-        long sizel = from.length();
-        final int maxsize = 64*1024;
-        int size = sizel > maxsize ? maxsize : (int)sizel;
-        byte[] buf = new byte[size];
-        while (true) {
-            try {
-                size = in.read(buf);
-            }
-            catch (IOException e) {
-                System.err.println(from.getAbsolutePath()
-                        + ": error reading file");
-                break;
-            }
-            if (size > 0) {
-                try {
-                    out.write(buf, 0, size);
-                }
-                catch (IOException e) {
-                    System.err.println(from.getAbsolutePath()
-                        + ": error writing file");
-                }
-            } else {
-                break;
-            }
-        }
-        try {
-            in.close();
-        }
-        catch (IOException e) {
-        }
-        try {
-            out.close();
-        }
-        catch (IOException e) {
-        }
-    }
-    
-    /** Takes a string that ends w/ .html and changes the .html to htmlExtension */
-    public static String outputFilename(String htmlFile) {
-        if (!DroidDoc.htmlExtension.equals(".html") && htmlFile.endsWith(".html")) {
-            return htmlFile.substring(0, htmlFile.length()-5) + DroidDoc.htmlExtension;
-        } else {
-            return htmlFile;
-        }
-    }
-
-}
diff --git a/tools/droiddoc/src/Comment.java b/tools/droiddoc/src/Comment.java
deleted file mode 100644
index 68b6d20..0000000
--- a/tools/droiddoc/src/Comment.java
+++ /dev/null
@@ -1,405 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-import java.util.regex.Pattern;
-import java.util.regex.Matcher;
-import java.util.ArrayList;
-
-public class Comment
-{
-    static final Pattern LEADING_WHITESPACE = Pattern.compile(
-                                "^[ \t\n\r]*(.*)$",
-                                Pattern.DOTALL);
-
-    static final Pattern TAG_BEGIN = Pattern.compile(
-                                "[\r\n][\r\n \t]*@",
-                                Pattern.DOTALL);
-
-    static final Pattern TAG = Pattern.compile(
-                                "(@[^ \t\r\n]+)[ \t\r\n]+(.*)",
-                                Pattern.DOTALL);
-
-    static final Pattern INLINE_TAG = Pattern.compile(
-                                "(.*?)\\{(@[^ \t\r\n\\}]+)[ \t\r\n]*(.*?)\\}",
-                                Pattern.DOTALL);
-
-    static final Pattern FIRST_SENTENCE = Pattern.compile(
-                                "((.*?)\\.)[ \t\r\n\\<](.*)",
-                                Pattern.DOTALL);
-
-    private static final String[] KNOWN_TAGS = new String[] {
-            "@author",
-            "@since",
-            "@version",
-            "@deprecated",
-            "@undeprecate",
-            "@docRoot",
-            "@sdkCurrent",
-            "@inheritDoc",
-            "@more",
-            "@code",
-            "@samplecode",
-            "@sample",
-            "@include",
-            "@serial",
-        };
-
-    public Comment(String text, ContainerInfo base, SourcePositionInfo sp)
-    {
-        mText = text;
-        mBase = base;
-        // sp now points to the end of the text, not the beginning!
-        mPosition = SourcePositionInfo.findBeginning(sp, text);
-    }
-
-    private void parseRegex(String text)
-    {
-        Matcher m;
-
-        m = LEADING_WHITESPACE.matcher(text);
-        m.matches();
-        text = m.group(1);
-
-        m = TAG_BEGIN.matcher(text);
-
-        int start = 0;
-        int end = 0;
-        while (m.find()) {
-            end = m.start();
-
-            tag(text, start, end);
-
-            start = m.end()-1; // -1 is the @
-        }
-        end = text.length();
-        tag(text, start, end);
-    }
-
-    private void tag(String text, int start, int end)
-    {
-        SourcePositionInfo pos = SourcePositionInfo.add(mPosition, mText, start);
-
-        if (start >= 0 && end > 0 && (end-start) > 0) {
-            text = text.substring(start, end);
-
-            Matcher m = TAG.matcher(text);
-            if (m.matches()) {
-                // out of line tag
-                tag(m.group(1), m.group(2), false, pos);
-            } else {
-                // look for inline tags
-                m = INLINE_TAG.matcher(text);
-                start = 0;
-                while (m.find()) {
-                    String str = m.group(1);
-                    String tagname = m.group(2);
-                    String tagvalue = m.group(3);
-                    tag(null, m.group(1), true, pos);
-                    tag(tagname, tagvalue, true, pos);
-                    start = m.end();
-                }
-                int len = text.length();
-                if (start != len) {
-                    tag(null, text.substring(start), true, pos);
-                }
-            }
-        }
-    }
-
-    private void tag(String name, String text, boolean isInline, SourcePositionInfo pos)
-    {
-        /*
-        String s = isInline ? "inline" : "outofline";
-        System.out.println("---> " + s
-                + " name=[" + name + "] text=[" + text + "]");
-        */
-        if (name == null) {
-            mInlineTagsList.add(new TextTagInfo("Text", "Text", text, pos));
-        }
-        else if (name.equals("@param")) {
-            mParamTagsList.add(new ParamTagInfo("@param", "@param", text, mBase, pos));
-        }
-        else if (name.equals("@see")) {
-            mSeeTagsList.add(new SeeTagInfo("@see", "@see", text, mBase, pos));
-        }
-        else if (name.equals("@link") || name.equals("@linkplain")) {
-            mInlineTagsList.add(new SeeTagInfo(name, "@see", text, mBase, pos));
-        }
-        else if (name.equals("@throws") || name.equals("@exception")) {
-            mThrowsTagsList.add(new ThrowsTagInfo("@throws", "@throws", text, mBase, pos));
-        }
-        else if (name.equals("@return")) {
-            mReturnTagsList.add(new ParsedTagInfo("@return", "@return", text, mBase, pos));
-        }
-        else if (name.equals("@deprecated")) {
-            if (text.length() == 0) {
-                Errors.error(Errors.MISSING_COMMENT, pos,
-                        "@deprecated tag with no explanatory comment");
-                text = "No replacement.";
-            }
-            mDeprecatedTagsList.add(new ParsedTagInfo("@deprecated", "@deprecated", text, mBase, pos));
-        }
-        else if (name.equals("@literal")) {
-            mInlineTagsList.add(new LiteralTagInfo(name, name, text, pos));
-        }
-        else if (name.equals("@hide") || name.equals("@pending") || name.equals("@doconly")) {
-            // nothing
-        }
-        else if (name.equals("@attr")) {
-            AttrTagInfo tag = new AttrTagInfo("@attr", "@attr", text, mBase, pos);
-            mAttrTagsList.add(tag);
-            Comment c = tag.description();
-            if (c != null) {
-                for (TagInfo t: c.tags()) {
-                    mInlineTagsList.add(t);
-                }
-            }
-        }
-        else if (name.equals("@undeprecate")) {
-            mUndeprecateTagsList.add(new TextTagInfo("@undeprecate", "@undeprecate", text, pos));
-        }
-        else if (name.equals("@include") || name.equals("@sample")) {
-            mInlineTagsList.add(new SampleTagInfo(name, "@include", text, mBase, pos));
-        }
-        else {
-            boolean known = false;
-            for (String s: KNOWN_TAGS) {
-                if (s.equals(name)) {
-                    known = true;
-                    break;
-                }
-            }
-            if (!known) {
-                known = DroidDoc.knownTags.contains(name);
-            }
-            if (!known) {
-                Errors.error(Errors.UNKNOWN_TAG, pos == null ? null : new SourcePositionInfo(pos),
-                        "Unknown tag: " + name);
-            }
-            TagInfo t = new TextTagInfo(name, name, text, pos);
-            if (isInline) {
-                mInlineTagsList.add(t);
-            } else {
-                mTagsList.add(t);
-            }
-        }
-    }
-
-    private void parseBriefTags()
-    {
-        int N = mInlineTagsList.size();
-
-        // look for "@more" tag, which means that we might go past the first sentence.
-        int more = -1;
-        for (int i=0; i<N; i++) {
-            if (mInlineTagsList.get(i).name().equals("@more")) {
-                more = i;
-            }
-        }
-          if (more >= 0) {
-            for (int i=0; i<more; i++) {
-                mBriefTagsList.add(mInlineTagsList.get(i));
-            }
-        } else {
-            for (int i=0; i<N; i++) {
-                TagInfo t = mInlineTagsList.get(i);
-                if (t.name().equals("Text")) {
-                    Matcher m = FIRST_SENTENCE.matcher(t.text());
-                    if (m.matches()) {
-                        String text = m.group(1);
-                        TagInfo firstSentenceTag = new TagInfo(t.name(), t.kind(), text, t.position());
-                        mBriefTagsList.add(firstSentenceTag);
-                        break;
-                    }
-                }
-                mBriefTagsList.add(t);
-
-            }
-        }
-    }
-
-    public TagInfo[] tags()
-    {
-        init();
-        return mInlineTags;
-    }
-
-    public TagInfo[] tags(String name)
-    {
-        init();
-        ArrayList<TagInfo> results = new ArrayList<TagInfo>();
-        int N = mInlineTagsList.size();
-        for (int i=0; i<N; i++) {
-            TagInfo t = mInlineTagsList.get(i);
-            if (t.name().equals(name)) {
-                results.add(t);
-            }
-        }
-        return results.toArray(new TagInfo[results.size()]);
-    }
-
-    public ParamTagInfo[] paramTags()
-    {
-        init();
-        return mParamTags;
-    }
-
-    public SeeTagInfo[] seeTags()
-    {
-        init();
-        return mSeeTags;
-    }
-
-    public ThrowsTagInfo[] throwsTags()
-    {
-        init();
-        return mThrowsTags;
-    }
-
-    public TagInfo[] returnTags()
-    {
-        init();
-        return mReturnTags;
-    }
-
-    public TagInfo[] deprecatedTags()
-    {
-        init();
-        return mDeprecatedTags;
-    }
-
-    public TagInfo[] undeprecateTags()
-    {
-        init();
-        return mUndeprecateTags;
-    }
-
-    public AttrTagInfo[] attrTags()
-    {
-        init();
-        return mAttrTags;
-    }
-
-    public TagInfo[] briefTags()
-    {
-        init();
-        return mBriefTags;
-    }
-
-    public boolean isHidden()
-    {
-        if (mHidden >= 0) {
-            return mHidden != 0;
-        } else {
-            if (DroidDoc.checkLevel(DroidDoc.SHOW_HIDDEN)) {
-                mHidden = 0;
-                return false;
-            }
-            boolean b = mText.indexOf("@hide") >= 0 || mText.indexOf("@pending") >= 0;
-            mHidden = b ? 1 : 0;
-            return b;
-        }
-    }
-
-    public boolean isDocOnly() {
-        if (mDocOnly >= 0) {
-            return mDocOnly != 0;
-        } else {
-            boolean b = (mText != null) && (mText.indexOf("@doconly") >= 0);
-            mDocOnly = b ? 1 : 0;
-            return b;
-        }
-    }
-
-    private void init()
-    {
-        if (!mInitialized) {
-            initImpl();
-        }
-    }
-
-    private void initImpl()
-    {
-        isHidden();
-        isDocOnly();
-
-        // Don't bother parsing text if we aren't generating documentation.
-        if (DroidDoc.parseComments()) {
-            parseRegex(mText);
-            parseBriefTags();
-        } else {
-          // Forces methods to be recognized by findOverriddenMethods in MethodInfo.
-          mInlineTagsList.add(new TextTagInfo("Text", "Text", mText,
-                  SourcePositionInfo.add(mPosition, mText, 0)));
-        }
-
-        mText = null;
-        mInitialized = true;
-
-        mInlineTags = mInlineTagsList.toArray(new TagInfo[mInlineTagsList.size()]);
-        mParamTags = mParamTagsList.toArray(new ParamTagInfo[mParamTagsList.size()]);
-        mSeeTags = mSeeTagsList.toArray(new SeeTagInfo[mSeeTagsList.size()]);
-        mThrowsTags = mThrowsTagsList.toArray(new ThrowsTagInfo[mThrowsTagsList.size()]);
-        mReturnTags = ParsedTagInfo.joinTags(mReturnTagsList.toArray(
-                                             new ParsedTagInfo[mReturnTagsList.size()]));
-        mDeprecatedTags = ParsedTagInfo.joinTags(mDeprecatedTagsList.toArray(
-                                        new ParsedTagInfo[mDeprecatedTagsList.size()]));
-        mUndeprecateTags = mUndeprecateTagsList.toArray(new TagInfo[mUndeprecateTagsList.size()]);
-        mAttrTags = mAttrTagsList.toArray(new AttrTagInfo[mAttrTagsList.size()]);
-        mBriefTags = mBriefTagsList.toArray(new TagInfo[mBriefTagsList.size()]);
-
-        mParamTagsList = null;
-        mSeeTagsList = null;
-        mThrowsTagsList = null;
-        mReturnTagsList = null;
-        mDeprecatedTagsList = null;
-        mUndeprecateTagsList = null;
-        mAttrTagsList = null;
-        mBriefTagsList = null;
-    }
-
-    boolean mInitialized;
-    int mHidden = -1;
-    int mDocOnly = -1;
-    String mText;
-    ContainerInfo mBase;
-    SourcePositionInfo mPosition;
-    int mLine = 1;
-
-    TagInfo[] mInlineTags;
-    TagInfo[] mTags;
-    ParamTagInfo[] mParamTags;
-    SeeTagInfo[] mSeeTags;
-    ThrowsTagInfo[] mThrowsTags;
-    TagInfo[] mBriefTags;
-    TagInfo[] mReturnTags;
-    TagInfo[] mDeprecatedTags;
-    TagInfo[] mUndeprecateTags;
-    AttrTagInfo[] mAttrTags;
-
-    ArrayList<TagInfo> mInlineTagsList = new ArrayList<TagInfo>();
-    ArrayList<TagInfo> mTagsList = new ArrayList<TagInfo>();
-    ArrayList<ParamTagInfo> mParamTagsList = new ArrayList<ParamTagInfo>();
-    ArrayList<SeeTagInfo> mSeeTagsList = new ArrayList<SeeTagInfo>();
-    ArrayList<ThrowsTagInfo> mThrowsTagsList = new ArrayList<ThrowsTagInfo>();
-    ArrayList<TagInfo> mBriefTagsList = new ArrayList<TagInfo>();
-    ArrayList<ParsedTagInfo> mReturnTagsList = new ArrayList<ParsedTagInfo>();
-    ArrayList<ParsedTagInfo> mDeprecatedTagsList = new ArrayList<ParsedTagInfo>();
-    ArrayList<TagInfo> mUndeprecateTagsList = new ArrayList<TagInfo>();
-    ArrayList<AttrTagInfo> mAttrTagsList = new ArrayList<AttrTagInfo>();
-
-
-}
diff --git a/tools/droiddoc/src/ContainerInfo.java b/tools/droiddoc/src/ContainerInfo.java
deleted file mode 100644
index b8a3e10..0000000
--- a/tools/droiddoc/src/ContainerInfo.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-public interface ContainerInfo
-{
-    public String qualifiedName();
-    public boolean checkLevel();
-}
diff --git a/tools/droiddoc/src/Converter.java b/tools/droiddoc/src/Converter.java
deleted file mode 100644
index ee911f4..0000000
--- a/tools/droiddoc/src/Converter.java
+++ /dev/null
@@ -1,755 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-import com.sun.javadoc.*;
-import com.sun.tools.doclets.*;
-import org.clearsilver.HDF;
-import org.clearsilver.CS;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-
-public class Converter
-{
-    private static RootDoc root;
-
-    public static void makeInfo(RootDoc r)
-    {
-        root = r;
-
-        int N, i;
-
-        // create the objects
-        ClassDoc[] classDocs = r.classes();
-        N = classDocs.length;
-        for (i=0; i<N; i++) {
-            Converter.obtainClass(classDocs[i]);
-        }
-        ArrayList<ClassInfo> classesNeedingInit2 = new ArrayList<ClassInfo>();
-        // fill in the fields that reference other classes
-        while (mClassesNeedingInit.size() > 0) {
-            i = mClassesNeedingInit.size()-1;
-            ClassNeedingInit clni = mClassesNeedingInit.get(i);
-            mClassesNeedingInit.remove(i);
-
-            initClass(clni.c, clni.cl);
-            classesNeedingInit2.add(clni.cl);
-        }
-        mClassesNeedingInit = null;
-        for (ClassInfo cl: classesNeedingInit2) {
-            cl.init2();
-        }
-
-        finishAnnotationValueInit();
-
-        // fill in the "root" stuff
-        mRootClasses = Converter.convertClasses(r.classes());
-    }
-
-    private static ClassInfo[] mRootClasses;
-    public static ClassInfo[] rootClasses()
-    {
-        return mRootClasses;
-    }
-
-    public static ClassInfo[] allClasses() {
-        return (ClassInfo[])mClasses.all();
-    }
-
-    private static void initClass(ClassDoc c, ClassInfo cl)
-    {
-        MethodDoc[] annotationElements;
-        if (c instanceof AnnotationTypeDoc) {
-            annotationElements = ((AnnotationTypeDoc)c).elements();
-        } else {
-            annotationElements = new MethodDoc[0];
-        }
-        cl.init(Converter.obtainType(c),
-                Converter.convertClasses(c.interfaces()),
-                Converter.convertTypes(c.interfaceTypes()),
-                Converter.convertClasses(c.innerClasses()),
-                Converter.convertMethods(c.constructors(false)),
-                Converter.convertMethods(c.methods(false)),
-                Converter.convertMethods(annotationElements),
-                Converter.convertFields(c.fields(false)),
-                Converter.convertFields(c.enumConstants()),
-                Converter.obtainPackage(c.containingPackage()),
-                Converter.obtainClass(c.containingClass()),
-                Converter.obtainClass(c.superclass()),
-                Converter.obtainType(c.superclassType()),
-                Converter.convertAnnotationInstances(c.annotations())
-                );
-          cl.setHiddenMethods(Converter.getHiddenMethods(c.methods(false)));
-          cl.setNonWrittenConstructors(Converter.convertNonWrittenConstructors(c.constructors(false)));
-          cl.init3(Converter.convertTypes(c.typeParameters()), Converter.convertClasses(c.innerClasses(false)));
-    }
-
-    public static ClassInfo obtainClass(String className)
-    {
-        return Converter.obtainClass(root.classNamed(className));
-    }
-
-    public static PackageInfo obtainPackage(String packageName)
-    {
-        return Converter.obtainPackage(root.packageNamed(packageName));
-    }
-
-    private static TagInfo convertTag(Tag tag)
-    {
-        return new TextTagInfo(tag.name(), tag.kind(), tag.text(),
-                                Converter.convertSourcePosition(tag.position()));
-    }
-
-    private static ThrowsTagInfo convertThrowsTag(ThrowsTag tag,
-                                                ContainerInfo base)
-    {
-        return new ThrowsTagInfo(tag.name(), tag.text(), tag.kind(),
-                              Converter.obtainClass(tag.exception()),
-                              tag.exceptionComment(), base,
-                              Converter.convertSourcePosition(tag.position()));
-    }
-
-    private static ParamTagInfo convertParamTag(ParamTag tag,
-                                                ContainerInfo base)
-    {
-        return new ParamTagInfo(tag.name(), tag.kind(), tag.text(),
-                              tag.isTypeParameter(), tag.parameterComment(),
-                              tag.parameterName(),
-                              base,
-                              Converter.convertSourcePosition(tag.position()));
-    }
-
-    private static SeeTagInfo convertSeeTag(SeeTag tag, ContainerInfo base)
-    {
-        return new SeeTagInfo(tag.name(), tag.kind(), tag.text(), base,
-                              Converter.convertSourcePosition(tag.position()));
-    }
-
-    private static SourcePositionInfo convertSourcePosition(SourcePosition sp)
-    {
-        if (sp == null) {
-            return null;
-        }
-        return new SourcePositionInfo(sp.file().toString(), sp.line(),
-                                        sp.column());
-    }
-
-    public static TagInfo[] convertTags(Tag[] tags, ContainerInfo base)
-    {
-        int len = tags.length;
-        TagInfo[] out = new TagInfo[len];
-        for (int i=0; i<len; i++) {
-            Tag t = tags[i];
-            /*
-            System.out.println("Tag name='" + t.name() + "' kind='"
-                    + t.kind() + "'");
-            */
-            if (t instanceof SeeTag) {
-                out[i] = Converter.convertSeeTag((SeeTag)t, base);
-            }
-            else if (t instanceof ThrowsTag) {
-                out[i] = Converter.convertThrowsTag((ThrowsTag)t, base);
-            }
-            else if (t instanceof ParamTag) {
-                out[i] = Converter.convertParamTag((ParamTag)t, base);
-            }
-            else {
-                out[i] = Converter.convertTag(t);
-            }
-        }
-        return out;
-    }
-
-    public static ClassInfo[] convertClasses(ClassDoc[] classes)
-    {
-        if (classes == null) return null;
-        int N = classes.length;
-        ClassInfo[] result = new ClassInfo[N];
-        for (int i=0; i<N; i++) {
-            result[i] = Converter.obtainClass(classes[i]);
-        }
-        return result;
-    }
-
-    private static ParameterInfo convertParameter(Parameter p, SourcePosition pos)
-    {
-        if (p == null) return null;
-        ParameterInfo pi = new ParameterInfo(p.name(), p.typeName(),
-                Converter.obtainType(p.type()),
-                Converter.convertSourcePosition(pos));
-        return pi;
-    }
-
-    private static ParameterInfo[] convertParameters(Parameter[] p, MemberDoc m)
-    {
-        SourcePosition pos = m.position();
-        int len = p.length;
-        ParameterInfo[] q = new ParameterInfo[len];
-        for (int i=0; i<len; i++) {
-            q[i] = Converter.convertParameter(p[i], pos);
-        }
-        return q;
-    }
-
-    private static TypeInfo[] convertTypes(Type[] p)
-    {
-        if (p == null) return null;
-        int len = p.length;
-        TypeInfo[] q = new TypeInfo[len];
-        for (int i=0; i<len; i++) {
-            q[i] = Converter.obtainType(p[i]);
-        }
-        return q;
-    }
-
-    private Converter()
-    {
-    }
-
-    private static class ClassNeedingInit
-    {
-        ClassNeedingInit(ClassDoc c, ClassInfo cl)
-        {
-            this.c = c;
-            this.cl = cl;
-        }
-        ClassDoc c;
-        ClassInfo cl;
-    };
-    private static ArrayList<ClassNeedingInit> mClassesNeedingInit
-                                            = new ArrayList<ClassNeedingInit>();
-
-    static ClassInfo obtainClass(ClassDoc o)
-    {
-        return (ClassInfo)mClasses.obtain(o);
-    }
-    private static Cache mClasses = new Cache()
-    {
-        @Override
-        protected Object make(Object o)
-        {
-            ClassDoc c = (ClassDoc)o;
-            ClassInfo cl = new ClassInfo(
-                    c,
-                    c.getRawCommentText(),
-                    Converter.convertSourcePosition(c.position()),
-                    c.isPublic(),
-                    c.isProtected(),
-                    c.isPackagePrivate(),
-                    c.isPrivate(),
-                    c.isStatic(),
-                    c.isInterface(),
-                    c.isAbstract(),
-                    c.isOrdinaryClass(),
-                    c.isException(),
-                    c.isError(),
-                    c.isEnum(),
-                    (c instanceof AnnotationTypeDoc),
-                    c.isFinal(),
-                    c.isIncluded(),
-                    c.name(),
-                    c.qualifiedName(),
-                    c.qualifiedTypeName(),
-                    c.isPrimitive());
-            if (mClassesNeedingInit != null) {
-                mClassesNeedingInit.add(new ClassNeedingInit(c, cl));
-            }
-            return cl;
-        }
-        @Override
-        protected void made(Object o, Object r)
-        {
-            if (mClassesNeedingInit == null) {
-                initClass((ClassDoc)o, (ClassInfo)r);
-                ((ClassInfo)r).init2();
-            }
-        }
-        @Override
-        ClassInfo[] all()
-        {
-            return (ClassInfo[])mCache.values().toArray(new ClassInfo[mCache.size()]);
-        }
-    };
-
-    private static MethodInfo[] getHiddenMethods(MethodDoc[] methods){
-      if (methods == null) return null;
-      ArrayList<MethodInfo> out = new ArrayList<MethodInfo>();
-      int N = methods.length;
-      for (int i=0; i<N; i++) {
-          MethodInfo m = Converter.obtainMethod(methods[i]);
-          //System.out.println(m.toString() + ": ");
-          //for (TypeInfo ti : m.getTypeParameters()){
-            //  if (ti.asClassInfo() != null){
-                //System.out.println(" " +ti.asClassInfo().toString());
-              //} else {
-                //System.out.println(" null");
-              //}
-            //}
-          if (m.isHidden()) {
-              out.add(m);
-          }
-      }
-      return out.toArray(new MethodInfo[out.size()]);
-    }
-
-    /**
-     * Convert MethodDoc[] into MethodInfo[].  Also filters according
-     * to the -private, -public option, because the filtering doesn't seem
-     * to be working in the ClassDoc.constructors(boolean) call.
-     */
-    private static MethodInfo[] convertMethods(MethodDoc[] methods)
-    {
-        if (methods == null) return null;
-        ArrayList<MethodInfo> out = new ArrayList<MethodInfo>();
-        int N = methods.length;
-        for (int i=0; i<N; i++) {
-            MethodInfo m = Converter.obtainMethod(methods[i]);
-            //System.out.println(m.toString() + ": ");
-            //for (TypeInfo ti : m.getTypeParameters()){
-              //  if (ti.asClassInfo() != null){
-                  //System.out.println(" " +ti.asClassInfo().toString());
-                //} else {
-                  //System.out.println(" null");
-                //}
-              //}
-            if (m.checkLevel()) {
-                out.add(m);
-            }
-        }
-        return out.toArray(new MethodInfo[out.size()]);
-    }
-
-    private static MethodInfo[] convertMethods(ConstructorDoc[] methods)
-    {
-        if (methods == null) return null;
-        ArrayList<MethodInfo> out = new ArrayList<MethodInfo>();
-        int N = methods.length;
-        for (int i=0; i<N; i++) {
-            MethodInfo m = Converter.obtainMethod(methods[i]);
-            if (m.checkLevel()) {
-                out.add(m);
-            }
-        }
-        return out.toArray(new MethodInfo[out.size()]);
-    }
-
-    private static MethodInfo[] convertNonWrittenConstructors(ConstructorDoc[] methods)
-    {
-        if (methods == null) return null;
-        ArrayList<MethodInfo> out = new ArrayList<MethodInfo>();
-        int N = methods.length;
-        for (int i=0; i<N; i++) {
-            MethodInfo m = Converter.obtainMethod(methods[i]);
-            if (!m.checkLevel()) {
-                out.add(m);
-            }
-        }
-        return out.toArray(new MethodInfo[out.size()]);
-    }
-
-    private static MethodInfo obtainMethod(MethodDoc o)
-    {
-        return (MethodInfo)mMethods.obtain(o);
-    }
-    private static MethodInfo obtainMethod(ConstructorDoc o)
-    {
-        return (MethodInfo)mMethods.obtain(o);
-    }
-    private static Cache mMethods = new Cache()
-    {
-        @Override
-        protected Object make(Object o)
-        {
-            if (o instanceof AnnotationTypeElementDoc) {
-                AnnotationTypeElementDoc m = (AnnotationTypeElementDoc)o;
-                MethodInfo result = new MethodInfo(
-                                m.getRawCommentText(),
-                                Converter.convertTypes(m.typeParameters()),
-                                m.name(), m.signature(),
-                                Converter.obtainClass(m.containingClass()),
-                                Converter.obtainClass(m.containingClass()),
-                                m.isPublic(), m.isProtected(),
-                                m.isPackagePrivate(), m.isPrivate(),
-                                m.isFinal(), m.isStatic(), m.isSynthetic(),
-                                m.isAbstract(), m.isSynchronized(), m.isNative(), true,
-                                "annotationElement",
-                                m.flatSignature(),
-                                Converter.obtainMethod(m.overriddenMethod()),
-                                Converter.obtainType(m.returnType()),
-                                Converter.convertParameters(m.parameters(), m),
-                                Converter.convertClasses(m.thrownExceptions()),
-                                Converter.convertSourcePosition(m.position()),
-                                Converter.convertAnnotationInstances(m.annotations())
-                            );
-                result.setVarargs(m.isVarArgs());
-                result.init(Converter.obtainAnnotationValue(m.defaultValue(), result));
-                return result;
-            }
-            else if (o instanceof MethodDoc) {
-                MethodDoc m = (MethodDoc)o;
-                MethodInfo result = new MethodInfo(
-                                m.getRawCommentText(),
-                                Converter.convertTypes(m.typeParameters()),
-                                m.name(), m.signature(),
-                                Converter.obtainClass(m.containingClass()),
-                                Converter.obtainClass(m.containingClass()),
-                                m.isPublic(), m.isProtected(),
-                                m.isPackagePrivate(), m.isPrivate(),
-                                m.isFinal(), m.isStatic(), m.isSynthetic(),
-                                m.isAbstract(), m.isSynchronized(), m.isNative(), false,
-                                "method",
-                                m.flatSignature(),
-                                Converter.obtainMethod(m.overriddenMethod()),
-                                Converter.obtainType(m.returnType()),
-                                Converter.convertParameters(m.parameters(), m),
-                                Converter.convertClasses(m.thrownExceptions()),
-                                Converter.convertSourcePosition(m.position()),
-                                Converter.convertAnnotationInstances(m.annotations())
-                           );
-                result.setVarargs(m.isVarArgs());
-                result.init(null);
-                return result;
-            }
-            else {
-                ConstructorDoc m = (ConstructorDoc)o;
-                MethodInfo result = new MethodInfo(
-                                m.getRawCommentText(),
-                                Converter.convertTypes(m.typeParameters()),
-                                m.name(), m.signature(),
-                                Converter.obtainClass(m.containingClass()),
-                                Converter.obtainClass(m.containingClass()),
-                                m.isPublic(), m.isProtected(),
-                                m.isPackagePrivate(), m.isPrivate(),
-                                m.isFinal(), m.isStatic(), m.isSynthetic(),
-                                false, m.isSynchronized(), m.isNative(), false,
-                                "constructor",
-                                m.flatSignature(),
-                                null,
-                                null,
-                                Converter.convertParameters(m.parameters(), m),
-                                Converter.convertClasses(m.thrownExceptions()),
-                                Converter.convertSourcePosition(m.position()),
-                                Converter.convertAnnotationInstances(m.annotations())
-                            );
-                result.setVarargs(m.isVarArgs());
-                result.init(null);
-                return result;
-            }
-        }
-    };
-
-
-    private static FieldInfo[] convertFields(FieldDoc[] fields)
-    {
-        if (fields == null) return null;
-        ArrayList<FieldInfo> out = new ArrayList<FieldInfo>();
-        int N = fields.length;
-        for (int i=0; i<N; i++) {
-            FieldInfo f = Converter.obtainField(fields[i]);
-            if (f.checkLevel()) {
-                out.add(f);
-            }
-        }
-        return out.toArray(new FieldInfo[out.size()]);
-    }
-
-    private static FieldInfo obtainField(FieldDoc o)
-    {
-        return (FieldInfo)mFields.obtain(o);
-    }
-    private static FieldInfo obtainField(ConstructorDoc o)
-    {
-        return (FieldInfo)mFields.obtain(o);
-    }
-    private static Cache mFields = new Cache()
-    {
-        @Override
-        protected Object make(Object o)
-        {
-            FieldDoc f = (FieldDoc)o;
-            return new FieldInfo(f.name(),
-                            Converter.obtainClass(f.containingClass()),
-                            Converter.obtainClass(f.containingClass()),
-                            f.isPublic(), f.isProtected(),
-                            f.isPackagePrivate(), f.isPrivate(),
-                            f.isFinal(), f.isStatic(), f.isTransient(), f.isVolatile(),
-                            f.isSynthetic(),
-                            Converter.obtainType(f.type()),
-                            f.getRawCommentText(), f.constantValue(),
-                            Converter.convertSourcePosition(f.position()),
-                            Converter.convertAnnotationInstances(f.annotations())
-                        );
-        }
-    };
-
-    private static PackageInfo obtainPackage(PackageDoc o)
-    {
-        return (PackageInfo)mPackagees.obtain(o);
-    }
-    private static Cache mPackagees = new Cache()
-    {
-        @Override
-        protected Object make(Object o)
-        {
-            PackageDoc p = (PackageDoc)o;
-            return new PackageInfo(p, p.name(),
-                    Converter.convertSourcePosition(p.position()));
-        }
-    };
-
-    private static TypeInfo obtainType(Type o)
-    {
-        return (TypeInfo)mTypes.obtain(o);
-    }
-    private static Cache mTypes = new Cache()
-    {
-       @Override
-    protected Object make(Object o)
-       {
-           Type t = (Type)o;
-           String simpleTypeName;
-           if (t instanceof ClassDoc) {
-               simpleTypeName = ((ClassDoc)t).name();
-           } else {
-               simpleTypeName = t.simpleTypeName();
-           }
-           TypeInfo ti = new TypeInfo(t.isPrimitive(), t.dimension(),
-                   simpleTypeName, t.qualifiedTypeName(),
-                   Converter.obtainClass(t.asClassDoc()));
-           return ti;
-       }
-        @Override
-        protected void made(Object o, Object r)
-        {
-            Type t = (Type)o;
-            TypeInfo ti = (TypeInfo)r;
-            if (t.asParameterizedType() != null) {
-                ti.setTypeArguments(Converter.convertTypes(
-                            t.asParameterizedType().typeArguments()));
-            }
-            else if (t instanceof ClassDoc) {
-                ti.setTypeArguments(Converter.convertTypes(((ClassDoc)t).typeParameters()));
-            }
-            else if (t.asTypeVariable() != null) {
-                ti.setBounds(null, Converter.convertTypes((t.asTypeVariable().bounds())));
-                ti.setIsTypeVariable(true);
-            }
-            else if (t.asWildcardType() != null) {
-                ti.setIsWildcard(true);
-                ti.setBounds(Converter.convertTypes(t.asWildcardType().superBounds()),
-                             Converter.convertTypes(t.asWildcardType().extendsBounds()));
-            }
-        }
-        @Override
-        protected Object keyFor(Object o)
-        {
-            Type t = (Type)o;
-            String keyString = o.getClass().getName() + "/" + o.toString() + "/";
-            if (t.asParameterizedType() != null){
-              keyString += t.asParameterizedType().toString() +"/";
-              if (t.asParameterizedType().typeArguments() != null){
-              for(Type ty : t.asParameterizedType().typeArguments()){
-                keyString += ty.toString() + "/";
-              }
-              }
-            }else{
-              keyString += "NoParameterizedType//";
-            }
-            if (t.asTypeVariable() != null){
-              keyString += t.asTypeVariable().toString() +"/";
-              if (t.asTypeVariable().bounds() != null){
-              for(Type ty : t.asTypeVariable().bounds()){
-                keyString += ty.toString() + "/";
-              }
-              }
-            }else{
-              keyString += "NoTypeVariable//";
-            }
-            if (t.asWildcardType() != null){
-              keyString += t.asWildcardType().toString() +"/";
-              if (t.asWildcardType().superBounds() != null){
-              for(Type ty : t.asWildcardType().superBounds()){
-                keyString += ty.toString() + "/";
-              }
-              }
-              if (t.asWildcardType().extendsBounds() != null){
-                for(Type ty : t.asWildcardType().extendsBounds()){
-                  keyString += ty.toString() + "/";
-                }
-                }
-            }else{
-              keyString += "NoWildCardType//";
-            }
-
-
-
-            return keyString;
-        }
-    };
-
-
-
-    private static MemberInfo obtainMember(MemberDoc o)
-    {
-        return (MemberInfo)mMembers.obtain(o);
-    }
-    private static Cache mMembers = new Cache()
-    {
-        @Override
-        protected Object make(Object o)
-        {
-            if (o instanceof MethodDoc) {
-                return Converter.obtainMethod((MethodDoc)o);
-            }
-            else if (o instanceof ConstructorDoc) {
-                return Converter.obtainMethod((ConstructorDoc)o);
-            }
-            else if (o instanceof FieldDoc) {
-                return Converter.obtainField((FieldDoc)o);
-            }
-            else {
-                return null;
-            }
-        }
-    };
-
-    private static AnnotationInstanceInfo[] convertAnnotationInstances(AnnotationDesc[] orig)
-    {
-        int len = orig.length;
-        AnnotationInstanceInfo[] out = new AnnotationInstanceInfo[len];
-        for (int i=0; i<len; i++) {
-            out[i] = Converter.obtainAnnotationInstance(orig[i]);
-        }
-        return out;
-    }
-
-
-    private static AnnotationInstanceInfo obtainAnnotationInstance(AnnotationDesc o)
-    {
-        return (AnnotationInstanceInfo)mAnnotationInstances.obtain(o);
-    }
-    private static Cache mAnnotationInstances = new Cache()
-    {
-        @Override
-        protected Object make(Object o)
-        {
-            AnnotationDesc a = (AnnotationDesc)o;
-            ClassInfo annotationType = Converter.obtainClass(a.annotationType());
-            AnnotationDesc.ElementValuePair[] ev = a.elementValues();
-            AnnotationValueInfo[] elementValues = new AnnotationValueInfo[ev.length];
-            for (int i=0; i<ev.length; i++) {
-                elementValues[i] = obtainAnnotationValue(ev[i].value(),
-                                            Converter.obtainMethod(ev[i].element()));
-            }
-            return new AnnotationInstanceInfo(annotationType, elementValues);
-        }
-    };
-
-
-    private abstract static class Cache
-    {
-        void put(Object key, Object value)
-        {
-            mCache.put(key, value);
-        }
-        Object obtain(Object o)
-        {
-            if (o == null ) {
-                return null;
-            }
-            Object k = keyFor(o);
-            Object r = mCache.get(k);
-            if (r == null) {
-                r = make(o);
-                mCache.put(k, r);
-                made(o, r);
-            }
-            return r;
-        }
-        protected HashMap<Object,Object> mCache = new HashMap<Object,Object>();
-        protected abstract Object make(Object o);
-        protected void made(Object o, Object r)
-        {
-        }
-        protected Object keyFor(Object o) { return o; }
-        Object[] all() { return null; }
-    }
-
-    // annotation values
-    private static HashMap<AnnotationValue,AnnotationValueInfo> mAnnotationValues = new HashMap();
-    private static HashSet<AnnotationValue> mAnnotationValuesNeedingInit = new HashSet();
-
-    private static AnnotationValueInfo obtainAnnotationValue(AnnotationValue o, MethodInfo element)
-    {
-        if (o == null) {
-            return null;
-        }
-        AnnotationValueInfo v = mAnnotationValues.get(o);
-        if (v != null) return v;
-        v = new AnnotationValueInfo(element);
-        mAnnotationValues.put(o, v);
-        if (mAnnotationValuesNeedingInit != null) {
-            mAnnotationValuesNeedingInit.add(o);
-        } else {
-            initAnnotationValue(o, v);
-        }
-        return v;
-    }
-
-    private static void initAnnotationValue(AnnotationValue o, AnnotationValueInfo v) {
-        Object orig = o.value();
-        Object converted;
-        if (orig instanceof Type) {
-            // class literal
-            converted = Converter.obtainType((Type)orig);
-        }
-        else if (orig instanceof FieldDoc) {
-            // enum constant
-            converted = Converter.obtainField((FieldDoc)orig);
-        }
-        else if (orig instanceof AnnotationDesc) {
-            // annotation instance
-            converted = Converter.obtainAnnotationInstance((AnnotationDesc)orig);
-        }
-        else if (orig instanceof AnnotationValue[]) {
-            AnnotationValue[] old = (AnnotationValue[])orig;
-            AnnotationValueInfo[] array = new AnnotationValueInfo[old.length];
-            for (int i=0; i<array.length; i++) {
-                array[i] = Converter.obtainAnnotationValue(old[i], null);
-            }
-            converted = array;
-        }
-        else {
-            converted = orig;
-        }
-        v.init(converted);
-    }
-
-    private static void finishAnnotationValueInit()
-    {
-        int depth = 0;
-        while (mAnnotationValuesNeedingInit.size() > 0) {
-            HashSet<AnnotationValue> set = mAnnotationValuesNeedingInit;
-            mAnnotationValuesNeedingInit = new HashSet();
-            for (AnnotationValue o: set) {
-                AnnotationValueInfo v = mAnnotationValues.get(o);
-                initAnnotationValue(o, v);
-            }
-            depth++;
-        }
-        mAnnotationValuesNeedingInit = null;
-    }
-}
diff --git a/tools/droiddoc/src/DocFile.java b/tools/droiddoc/src/DocFile.java
deleted file mode 100644
index 180fdcd..0000000
--- a/tools/droiddoc/src/DocFile.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-import org.clearsilver.HDF;
-import org.clearsilver.CS;
-import java.util.*;
-import java.io.*;
-import java.util.regex.Pattern;
-import java.util.regex.Matcher;
-
-
-public class DocFile
-{
-    private static final Pattern LINE = Pattern.compile("(.*)[\r]?\n",
-                                                        Pattern.MULTILINE);
-    private static final Pattern PROP = Pattern.compile("([^=]+)=(.*)");
-
-    public static String readFile(String filename)
-    {
-        try {
-            File f = new File(filename);
-            int length = (int)f.length();
-            FileInputStream is = new FileInputStream(f);
-            InputStreamReader reader = new InputStreamReader(is, "UTF-8");
-            char[] buf = new char[length];
-            int index = 0;
-            int amt;
-            while (true) {
-                amt = reader.read(buf, index, length-index);
-
-                if (amt < 1) {
-                    break;
-                }
-
-                index += amt;
-            }
-            return new String(buf, 0, index);
-        }
-        catch (IOException e) {
-            return null;
-        }
-    }
-
-    public static void writePage(String docfile, String relative,
-                                    String outfile)
-    {
-        HDF hdf = DroidDoc.makeHDF();
-
-        /*
-        System.out.println("docfile='" + docfile
-                            + "' relative='" + relative + "'"
-                            + "' outfile='" + outfile + "'");
-        */
-
-        String filedata = readFile(docfile);
-
-        // The document is properties up until the line "@jd:body".
-        // Any blank lines are ignored.
-        int start = -1;
-        int lineno = 1;
-        Matcher lines = LINE.matcher(filedata);
-        String line = null;
-        while (lines.find()) {
-            line = lines.group(1);
-            if (line.length() > 0) {
-                if (line.equals("@jd:body")) {
-                    start = lines.end();
-                    break;
-                }
-                Matcher prop = PROP.matcher(line);
-                if (prop.matches()) {
-                    String key = prop.group(1);
-                    String value = prop.group(2);
-                    hdf.setValue(key, value);
-                } else {
-                    break;
-                }
-            }
-            lineno++;
-        }
-        if (start < 0) {
-            System.err.println(docfile + ":" + lineno + ": error parsing docfile");
-            if (line != null) {
-                System.err.println(docfile + ":" + lineno + ":" + line);
-            }
-            System.exit(1);
-        }
-
-        // if they asked to only be for a certain template, maybe skip it
-        String fromTemplate = hdf.getValue("template.which", "");
-        String fromPage = hdf.getValue("page.onlyfortemplate", "");
-        if (!"".equals(fromPage) && !fromTemplate.equals(fromPage)) {
-            return;
-        }
-
-        // and the actual text after that
-        String commentText = filedata.substring(start);
-
-        Comment comment = new Comment(commentText, null,
-                                    new SourcePositionInfo(docfile, lineno, 1));
-        TagInfo[] tags = comment.tags();
-
-        TagInfo.makeHDF(hdf, "root.descr", tags);
-
-        hdf.setValue("commentText", commentText);
-
-        // write the page using the appropriate root template, based on the 
-        // whichdoc value supplied by build
-        String fromWhichmodule = hdf.getValue("android.whichmodule", "");
-        if (fromWhichmodule.equals("online-pdk")) {
-            //leaving this in just for temporary compatibility with pdk doc
-            hdf.setValue("online-pdk", "true");
-            // add any conditional login for root template here (such as 
-            // for custom left nav based on tab etc. 
-            ClearPage.write(hdf, "docpage.cs", outfile);
-        } else {
-            if (outfile.indexOf("sdk/") != -1) {
-                hdf.setValue("sdk", "true");
-                if ((outfile.indexOf("index.html") != -1) && (outfile.indexOf("preview/") == -1)) {
-                    ClearPage.write(hdf, "sdkpage.cs", outfile);
-                } else {
-                    ClearPage.write(hdf, "docpage.cs", outfile);
-                }
-            } else if (outfile.indexOf("guide/") != -1) {
-                hdf.setValue("guide", "true");
-                ClearPage.write(hdf, "docpage.cs", outfile);
-            } else if (outfile.indexOf("resources/") != -1) {
-                hdf.setValue("resources", "true");
-                ClearPage.write(hdf, "docpage.cs", outfile);
-            } else {
-                ClearPage.write(hdf, "nosidenavpage.cs", outfile);
-            }
-        }
-    } //writePage
-}
diff --git a/tools/droiddoc/src/DocInfo.java b/tools/droiddoc/src/DocInfo.java
deleted file mode 100644
index 3abb367..0000000
--- a/tools/droiddoc/src/DocInfo.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-public abstract class DocInfo
-{
-    public DocInfo(String rawCommentText, SourcePositionInfo sp)
-    {
-        mRawCommentText = rawCommentText;
-        mPosition = sp;
-    }
-
-    public boolean isHidden()
-    {
-        return comment().isHidden();
-    }
-
-    public boolean isDocOnly() {
-        return comment().isDocOnly();
-    }
-    
-    public String getRawCommentText()
-    {
-        return mRawCommentText;
-    }
-
-    public Comment comment()
-    {
-        if (mComment == null) {
-            mComment = new Comment(mRawCommentText, parent(), mPosition);
-        }
-        return mComment;
-    }
-
-    public SourcePositionInfo position()
-    {
-        return mPosition;
-    }
-
-    public abstract ContainerInfo parent();
-
-    public void setSince(String since) {
-        mSince = since;
-    }
-
-    public String getSince() {
-        return mSince;
-    }
-
-    private String mRawCommentText;
-    Comment mComment;
-    SourcePositionInfo mPosition;
-    private String mSince;
-}
-
diff --git a/tools/droiddoc/src/DroidDoc.java b/tools/droiddoc/src/DroidDoc.java
deleted file mode 100644
index dfdbda6..0000000
--- a/tools/droiddoc/src/DroidDoc.java
+++ /dev/null
@@ -1,1465 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-import com.sun.javadoc.*;
-
-import org.clearsilver.HDF;
-
-import java.util.*;
-import java.io.*;
-import java.lang.reflect.Proxy;
-import java.lang.reflect.Array;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-public class DroidDoc
-{
-    private static final String SDK_CONSTANT_ANNOTATION = "android.annotation.SdkConstant";
-    private static final String SDK_CONSTANT_TYPE_ACTIVITY_ACTION = "android.annotation.SdkConstant.SdkConstantType.ACTIVITY_INTENT_ACTION";
-    private static final String SDK_CONSTANT_TYPE_BROADCAST_ACTION = "android.annotation.SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION";
-    private static final String SDK_CONSTANT_TYPE_SERVICE_ACTION = "android.annotation.SdkConstant.SdkConstantType.SERVICE_INTENT_ACTION";
-    private static final String SDK_CONSTANT_TYPE_CATEGORY = "android.annotation.SdkConstant.SdkConstantType.INTENT_CATEGORY";
-    private static final String SDK_CONSTANT_TYPE_FEATURE = "android.annotation.SdkConstant.SdkConstantType.FEATURE";
-    private static final String SDK_WIDGET_ANNOTATION = "android.annotation.Widget";
-    private static final String SDK_LAYOUT_ANNOTATION = "android.annotation.Layout";
-
-    private static final int TYPE_NONE = 0;
-    private static final int TYPE_WIDGET = 1;
-    private static final int TYPE_LAYOUT = 2;
-    private static final int TYPE_LAYOUT_PARAM = 3;
-
-    public static final int SHOW_PUBLIC = 0x00000001;
-    public static final int SHOW_PROTECTED = 0x00000003;
-    public static final int SHOW_PACKAGE = 0x00000007;
-    public static final int SHOW_PRIVATE = 0x0000000f;
-    public static final int SHOW_HIDDEN = 0x0000001f;
-
-    public static int showLevel = SHOW_PROTECTED;
-
-    public static final String javadocDir = "reference/";
-    public static String htmlExtension;
-
-    public static RootDoc root;
-    public static ArrayList<String[]> mHDFData = new ArrayList<String[]>();
-    public static Map<Character,String> escapeChars = new HashMap<Character,String>();
-    public static String title = "";
-    public static SinceTagger sinceTagger = new SinceTagger();
-    public static HashSet<String> knownTags = new HashSet<String>();
-
-    private static boolean parseComments = false;
-    private static boolean generateDocs = true;
-    
-    /**
-    * Returns true if we should parse javadoc comments,
-    * reporting errors in the process.
-    */
-    public static boolean parseComments() {
-        return generateDocs || parseComments;
-    }
-
-    public static boolean checkLevel(int level)
-    {
-        return (showLevel & level) == level;
-    }
-
-    public static boolean checkLevel(boolean pub, boolean prot, boolean pkgp,
-            boolean priv, boolean hidden)
-    {
-        int level = 0;
-        if (hidden && !checkLevel(SHOW_HIDDEN)) {
-            return false;
-        }
-        if (pub && checkLevel(SHOW_PUBLIC)) {
-            return true;
-        }
-        if (prot && checkLevel(SHOW_PROTECTED)) {
-            return true;
-        }
-        if (pkgp && checkLevel(SHOW_PACKAGE)) {
-            return true;
-        }
-        if (priv && checkLevel(SHOW_PRIVATE)) {
-            return true;
-        }
-        return false;
-    }
-
-    public static boolean start(RootDoc r)
-    {
-        String keepListFile = null;
-        String proofreadFile = null;
-        String todoFile = null;
-        String sdkValuePath = null;
-        ArrayList<SampleCode> sampleCodes = new ArrayList<SampleCode>();
-        String stubsDir = null;
-        //Create the dependency graph for the stubs directory
-        boolean apiXML = false;
-        boolean offlineMode = false;
-        String apiFile = null;
-        String debugStubsFile = "";
-        HashSet<String> stubPackages = null;
-        ArrayList<String> knownTagsFiles = new ArrayList<String>();
-
-        root = r;
-
-        String[][] options = r.options();
-        for (String[] a: options) {
-            if (a[0].equals("-d")) {
-                ClearPage.outputDir = a[1];
-            }
-            else if (a[0].equals("-templatedir")) {
-                ClearPage.addTemplateDir(a[1]);
-            }
-            else if (a[0].equals("-hdf")) {
-                mHDFData.add(new String[] {a[1], a[2]});
-            }
-            else if (a[0].equals("-knowntags")) {
-                knownTagsFiles.add(a[1]);
-            }
-            else if (a[0].equals("-toroot")) {
-                ClearPage.toroot = a[1];
-            }
-            else if (a[0].equals("-samplecode")) {
-                sampleCodes.add(new SampleCode(a[1], a[2], a[3]));
-            }
-            else if (a[0].equals("-htmldir")) {
-                ClearPage.htmlDirs.add(a[1]);
-            }
-            else if (a[0].equals("-title")) {
-                DroidDoc.title = a[1];
-            }
-            else if (a[0].equals("-werror")) {
-                Errors.setWarningsAreErrors(true);
-            }
-            else if (a[0].equals("-error") || a[0].equals("-warning")
-                    || a[0].equals("-hide")) {
-                try {
-                    int level = -1;
-                    if (a[0].equals("-error")) {
-                        level = Errors.ERROR;
-                    }
-                    else if (a[0].equals("-warning")) {
-                        level = Errors.WARNING;
-                    }
-                    else if (a[0].equals("-hide")) {
-                        level = Errors.HIDDEN;
-                    }
-                    Errors.setErrorLevel(Integer.parseInt(a[1]), level);
-                }
-                catch (NumberFormatException e) {
-                    // already printed below
-                    return false;
-                }
-            }
-            else if (a[0].equals("-keeplist")) {
-                keepListFile = a[1];
-            }
-            else if (a[0].equals("-proofread")) {
-                proofreadFile = a[1];
-            }
-            else if (a[0].equals("-todo")) {
-                todoFile = a[1];
-            }
-            else if (a[0].equals("-public")) {
-                showLevel = SHOW_PUBLIC;
-            }
-            else if (a[0].equals("-protected")) {
-                showLevel = SHOW_PROTECTED;
-            }
-            else if (a[0].equals("-package")) {
-                showLevel = SHOW_PACKAGE;
-            }
-            else if (a[0].equals("-private")) {
-                showLevel = SHOW_PRIVATE;
-            }
-            else if (a[0].equals("-hidden")) {
-                showLevel = SHOW_HIDDEN;
-            }
-            else if (a[0].equals("-stubs")) {
-                stubsDir = a[1];
-            }
-            else if (a[0].equals("-stubpackages")) {
-                stubPackages = new HashSet();
-                for (String pkg: a[1].split(":")) {
-                    stubPackages.add(pkg);
-                }
-            }
-            else if (a[0].equals("-sdkvalues")) {
-                sdkValuePath = a[1];
-            }
-            else if (a[0].equals("-apixml")) {
-                apiXML = true;
-                apiFile = a[1];
-            }
-            else if (a[0].equals("-nodocs")) {
-                generateDocs = false;
-            }
-            else if (a[0].equals("-parsecomments")) {
-                parseComments = true;
-            }
-            else if (a[0].equals("-since")) {
-                sinceTagger.addVersion(a[1], a[2]);
-            }
-            else if (a[0].equals("-offlinemode")) {
-                offlineMode = true;
-            }
-        }
-
-        if (!readKnownTagsFiles(knownTags, knownTagsFiles)) {
-            return false;
-        }
-
-        // read some prefs from the template
-        if (!readTemplateSettings()) {
-            return false;
-        }
-
-        // Set up the data structures
-        Converter.makeInfo(r);
-
-        if (generateDocs) {
-            long startTime = System.nanoTime();
-
-            // Apply @since tags from the XML file
-            sinceTagger.tagAll(Converter.rootClasses());
-
-            // Files for proofreading
-            if (proofreadFile != null) {
-                Proofread.initProofread(proofreadFile);
-            }
-            if (todoFile != null) {
-                TodoFile.writeTodoFile(todoFile);
-            }
-
-            // HTML Pages
-            if (!ClearPage.htmlDirs.isEmpty()) {
-                writeHTMLPages();
-            }
-
-            // Navigation tree
-            NavTree.writeNavTree(javadocDir);
-
-            // Packages Pages
-            writePackages(javadocDir
-                            + (!ClearPage.htmlDirs.isEmpty()
-                                ? "packages" + htmlExtension
-                                : "index" + htmlExtension));
-
-            // Classes
-            writeClassLists();
-            writeClasses();
-            writeHierarchy();
-     //      writeKeywords();
-
-            // Lists for JavaScript
-            writeLists();
-            if (keepListFile != null) {
-                writeKeepList(keepListFile);
-            }
-
-            // Sample Code
-            for (SampleCode sc: sampleCodes) {
-                sc.write(offlineMode);
-            }
-
-            // Index page
-            writeIndex();
-
-            Proofread.finishProofread(proofreadFile);
-
-            if (sdkValuePath != null) {
-                writeSdkValues(sdkValuePath);
-            }
-
-            long time = System.nanoTime() - startTime;
-            System.out.println("DroidDoc took " + (time / 1000000000) + " sec. to write docs to "
-                    + ClearPage.outputDir);
-        }
-
-        // Stubs
-        if (stubsDir != null) {
-            Stubs.writeStubs(stubsDir, apiXML, apiFile, stubPackages);
-        }
-
-        Errors.printErrors();
-        return !Errors.hadError;
-    }
-
-    private static void writeIndex() {
-        HDF data = makeHDF();
-        ClearPage.write(data, "index.cs", javadocDir + "index" + htmlExtension);
-    }
-
-    private static boolean readTemplateSettings()
-    {
-        HDF data = makeHDF();
-        htmlExtension = data.getValue("template.extension", ".html");
-        int i=0;
-        while (true) {
-            String k = data.getValue("template.escape." + i + ".key", "");
-            String v = data.getValue("template.escape." + i + ".value", "");
-            if ("".equals(k)) {
-                break;
-            }
-            if (k.length() != 1) {
-                System.err.println("template.escape." + i + ".key must have a length of 1: " + k);
-                return false;
-            }
-            escapeChars.put(k.charAt(0), v);
-            i++;
-        }
-        return true;
-    }
-
-    private static boolean readKnownTagsFiles(HashSet<String> knownTags,
-            ArrayList<String> knownTagsFiles) {
-        for (String fn: knownTagsFiles) {
-            BufferedReader in = null;
-            try {
-                in = new BufferedReader(new FileReader(fn));
-                int lineno = 0;
-                boolean fail = false;
-                while (true) {
-                    lineno++;
-                    String line = in.readLine();
-                    if (line == null) {
-                        break;
-                    }
-                    line = line.trim();
-                    if (line.length() == 0) {
-                        continue;
-                    } else if (line.charAt(0) == '#') {
-                        continue;
-                    }
-                    String[] words = line.split("\\s+", 2);
-                    if (words.length == 2) {
-                        if (words[1].charAt(0) != '#') {
-                            System.err.println(fn + ":" + lineno
-                                    + ": Only one tag allowed per line: " + line);
-                            fail = true;
-                            continue;
-                        }
-                    }
-                    knownTags.add(words[0]);
-                }
-                if (fail) {
-                    return false;
-                }
-            } catch (IOException ex) {
-                System.err.println("Error reading file: " + fn + " (" + ex.getMessage() + ")");
-                return false;
-            } finally {
-                if (in != null) {
-                    try {
-                        in.close();
-                    } catch (IOException e) {
-                    }
-                }
-            }
-        }
-        return true;
-    }
-
-    public static String escape(String s) {
-        if (escapeChars.size() == 0) {
-            return s;
-        }
-        StringBuffer b = null;
-        int begin = 0;
-        final int N = s.length();
-        for (int i=0; i<N; i++) {
-            char c = s.charAt(i);
-            String mapped = escapeChars.get(c);
-            if (mapped != null) {
-                if (b == null) {
-                    b = new StringBuffer(s.length() + mapped.length());
-                }
-                if (begin != i) {
-                    b.append(s.substring(begin, i));
-                }
-                b.append(mapped);
-                begin = i+1;
-            }
-        }
-        if (b != null) {
-            if (begin != N) {
-                b.append(s.substring(begin, N));
-            }
-            return b.toString();
-        }
-        return s;
-    }
-
-    public static void setPageTitle(HDF data, String title)
-    {
-        String s = title;
-        if (DroidDoc.title.length() > 0) {
-            s += " - " + DroidDoc.title;
-        }
-        data.setValue("page.title", s);
-    }
-
-    public static LanguageVersion languageVersion()
-    {
-        return LanguageVersion.JAVA_1_5;
-    }
-
-    public static int optionLength(String option)
-    {
-        if (option.equals("-d")) {
-            return 2;
-        }
-        if (option.equals("-templatedir")) {
-            return 2;
-        }
-        if (option.equals("-hdf")) {
-            return 3;
-        }
-        if (option.equals("-knowntags")) {
-            return 2;
-        }
-        if (option.equals("-toroot")) {
-            return 2;
-        }
-        if (option.equals("-samplecode")) {
-            return 4;
-        }
-        if (option.equals("-htmldir")) {
-            return 2;
-        }
-        if (option.equals("-title")) {
-            return 2;
-        }
-        if (option.equals("-werror")) {
-            return 1;
-        }
-        if (option.equals("-hide")) {
-            return 2;
-        }
-        if (option.equals("-warning")) {
-            return 2;
-        }
-        if (option.equals("-error")) {
-            return 2;
-        }
-        if (option.equals("-keeplist")) {
-            return 2;
-        }
-        if (option.equals("-proofread")) {
-            return 2;
-        }
-        if (option.equals("-todo")) {
-            return 2;
-        }
-        if (option.equals("-public")) {
-            return 1;
-        }
-        if (option.equals("-protected")) {
-            return 1;
-        }
-        if (option.equals("-package")) {
-            return 1;
-        }
-        if (option.equals("-private")) {
-            return 1;
-        }
-        if (option.equals("-hidden")) {
-            return 1;
-        }
-        if (option.equals("-stubs")) {
-            return 2;
-        }
-        if (option.equals("-stubpackages")) {
-            return 2;
-        }
-        if (option.equals("-sdkvalues")) {
-            return 2;
-        }
-        if (option.equals("-apixml")) {
-            return 2;
-        }
-        if (option.equals("-nodocs")) {
-            return 1;
-        }
-        if (option.equals("-parsecomments")) {
-            return 1;
-        }
-        if (option.equals("-since")) {
-            return 3;
-        }
-        if (option.equals("-offlinemode")) {
-            return 1;
-        }
-        return 0;
-    }
-
-    public static boolean validOptions(String[][] options, DocErrorReporter r)
-    {
-        for (String[] a: options) {
-            if (a[0].equals("-error") || a[0].equals("-warning")
-                    || a[0].equals("-hide")) {
-                try {
-                    Integer.parseInt(a[1]);
-                }
-                catch (NumberFormatException e) {
-                    r.printError("bad -" + a[0] + " value must be a number: "
-                            + a[1]);
-                    return false;
-                }
-            }
-        }
-
-        return true;
-    }
-
-    public static HDF makeHDF()
-    {
-        HDF data = new HDF();
-
-        for (String[] p: mHDFData) {
-            data.setValue(p[0], p[1]);
-        }
-
-        try {
-            for (String p: ClearPage.hdfFiles) {
-                data.readFile(p);
-            }
-        }
-        catch (IOException e) {
-            throw new RuntimeException(e);
-        }
-
-        return data;
-    }
-
-    public static HDF makePackageHDF()
-    {
-        HDF data = makeHDF();
-        ClassInfo[] classes = Converter.rootClasses();
-
-        SortedMap<String, PackageInfo> sorted = new TreeMap<String, PackageInfo>();
-        for (ClassInfo cl: classes) {
-            PackageInfo pkg = cl.containingPackage();
-            String name;
-            if (pkg == null) {
-                name = "";
-            } else {
-                name = pkg.name();
-            }
-            sorted.put(name, pkg);
-        }
-
-        int i = 0;
-        for (String s: sorted.keySet()) {
-            PackageInfo pkg = sorted.get(s);
-
-            if (pkg.isHidden()) {
-                continue;
-            }
-            Boolean allHidden = true;
-            int pass = 0;
-            ClassInfo[] classesToCheck = null;
-            while (pass < 5 ) {
-                switch(pass) {
-                case 0:
-                    classesToCheck = pkg.ordinaryClasses();
-                    break;
-                case 1:
-                    classesToCheck = pkg.enums();
-                    break;
-                case 2:
-                    classesToCheck = pkg.errors();
-                    break;
-                case 3:
-                    classesToCheck = pkg.exceptions();
-                    break;
-                case 4:
-                    classesToCheck = pkg.interfaces();
-                    break;
-                default:
-                    System.err.println("Error reading package: " + pkg.name());
-                    break;
-                }
-                for (ClassInfo cl : classesToCheck) {
-                    if (!cl.isHidden()) {
-                        allHidden = false;
-                        break;
-                    }
-                }
-                if (!allHidden) {
-                    break;
-                }
-                pass++;
-            }
-            if (allHidden) {
-                continue;
-            }
-
-            data.setValue("reference", "true");
-            data.setValue("docs.packages." + i + ".name", s);
-            data.setValue("docs.packages." + i + ".link", pkg.htmlPage());
-            data.setValue("docs.packages." + i + ".since", pkg.getSince());
-            TagInfo.makeHDF(data, "docs.packages." + i + ".shortDescr",
-                                               pkg.firstSentenceTags());
-            i++;
-        }
-
-        sinceTagger.writeVersionNames(data);
-        return data;
-    }
-
-    public static void writeDirectory(File dir, String relative)
-    {
-        File[] files = dir.listFiles();
-        int i, count = files.length;
-        for (i=0; i<count; i++) {
-            File f = files[i];
-            if (f.isFile()) {
-                String templ = relative + f.getName();
-                int len = templ.length();
-                if (len > 3 && ".cs".equals(templ.substring(len-3))) {
-                    HDF data = makeHDF();
-                    String filename = templ.substring(0,len-3) + htmlExtension;
-                    ClearPage.write(data, templ, filename);
-                }
-                else if (len > 3 && ".jd".equals(templ.substring(len-3))) {
-                    String filename = templ.substring(0,len-3) + htmlExtension;
-                    DocFile.writePage(f.getAbsolutePath(), relative, filename);
-                }
-                else {
-                    ClearPage.copyFile(f, templ);
-                }
-            }
-            else if (f.isDirectory()) {
-                writeDirectory(f, relative + f.getName() + "/");
-            }
-        }
-    }
-
-    public static void writeHTMLPages()
-    {
-        for (String htmlDir : ClearPage.htmlDirs) {
-            File f = new File(htmlDir);
-            if (!f.isDirectory()) {
-                System.err.println("htmlDir not a directory: " + htmlDir);
-                continue;
-            }
-            writeDirectory(f, "");
-        }
-    }
-
-    public static void writeLists()
-    {
-        HDF data = makeHDF();
-
-        ClassInfo[] classes = Converter.rootClasses();
-
-        SortedMap<String, Object> sorted = new TreeMap<String, Object>();
-        for (ClassInfo cl: classes) {
-            if (cl.isHidden()) {
-                continue;
-            }
-            sorted.put(cl.qualifiedName(), cl);
-            PackageInfo pkg = cl.containingPackage();
-            String name;
-            if (pkg == null) {
-                name = "";
-            } else {
-                name = pkg.name();
-            }
-            sorted.put(name, pkg);
-        }
-
-        int i = 0;
-        for (String s: sorted.keySet()) {
-            data.setValue("docs.pages." + i + ".id" , ""+i);
-            data.setValue("docs.pages." + i + ".label" , s);
-
-            Object o = sorted.get(s);
-            if (o instanceof PackageInfo) {
-                PackageInfo pkg = (PackageInfo)o;
-                data.setValue("docs.pages." + i + ".link" , pkg.htmlPage());
-                data.setValue("docs.pages." + i + ".type" , "package");
-            }
-            else if (o instanceof ClassInfo) {
-                ClassInfo cl = (ClassInfo)o;
-                data.setValue("docs.pages." + i + ".link" , cl.htmlPage());
-                data.setValue("docs.pages." + i + ".type" , "class");
-            }
-            i++;
-        }
-
-        ClearPage.write(data, "lists.cs", javadocDir + "lists.js");
-    }
-
-    public static void cantStripThis(ClassInfo cl, HashSet<ClassInfo> notStrippable) {
-        if (!notStrippable.add(cl)) {
-            // slight optimization: if it already contains cl, it already contains
-            // all of cl's parents
-            return;
-        }
-        ClassInfo supr = cl.superclass();
-        if (supr != null) {
-            cantStripThis(supr, notStrippable);
-        }
-        for (ClassInfo iface: cl.interfaces()) {
-            cantStripThis(iface, notStrippable);
-        }
-    }
-
-    private static String getPrintableName(ClassInfo cl) {
-        ClassInfo containingClass = cl.containingClass();
-        if (containingClass != null) {
-            // This is an inner class.
-            String baseName = cl.name();
-            baseName = baseName.substring(baseName.lastIndexOf('.') + 1);
-            return getPrintableName(containingClass) + '$' + baseName;
-        }
-        return cl.qualifiedName();
-    }
-
-    /**
-     * Writes the list of classes that must be present in order to
-     * provide the non-hidden APIs known to javadoc.
-     *
-     * @param filename the path to the file to write the list to
-     */
-    public static void writeKeepList(String filename) {
-        HashSet<ClassInfo> notStrippable = new HashSet<ClassInfo>();
-        ClassInfo[] all = Converter.allClasses();
-        Arrays.sort(all); // just to make the file a little more readable
-
-        // If a class is public and not hidden, then it and everything it derives
-        // from cannot be stripped.  Otherwise we can strip it.
-        for (ClassInfo cl: all) {
-            if (cl.isPublic() && !cl.isHidden()) {
-                cantStripThis(cl, notStrippable);
-            }
-        }
-        PrintStream stream = null;
-        try {
-            stream = new PrintStream(filename);
-            for (ClassInfo cl: notStrippable) {
-                stream.println(getPrintableName(cl));
-            }
-        }
-        catch (FileNotFoundException e) {
-            System.err.println("error writing file: " + filename);
-        }
-        finally {
-            if (stream != null) {
-                stream.close();
-            }
-        }
-    }
-
-    private static PackageInfo[] sVisiblePackages = null;
-    public static PackageInfo[] choosePackages() {
-        if (sVisiblePackages != null) {
-            return sVisiblePackages;
-        }
-
-        ClassInfo[] classes = Converter.rootClasses();
-        SortedMap<String, PackageInfo> sorted = new TreeMap<String, PackageInfo>();
-        for (ClassInfo cl: classes) {
-            PackageInfo pkg = cl.containingPackage();
-            String name;
-            if (pkg == null) {
-                name = "";
-            } else {
-                name = pkg.name();
-            }
-            sorted.put(name, pkg);
-        }
-
-        ArrayList<PackageInfo> result = new ArrayList();
-
-        for (String s: sorted.keySet()) {
-            PackageInfo pkg = sorted.get(s);
-
-            if (pkg.isHidden()) {
-                continue;
-            }
-            Boolean allHidden = true;
-            int pass = 0;
-            ClassInfo[] classesToCheck = null;
-            while (pass < 5 ) {
-                switch(pass) {
-                case 0:
-                    classesToCheck = pkg.ordinaryClasses();
-                    break;
-                case 1:
-                    classesToCheck = pkg.enums();
-                    break;
-                case 2:
-                    classesToCheck = pkg.errors();
-                    break;
-                case 3:
-                    classesToCheck = pkg.exceptions();
-                    break;
-                case 4:
-                    classesToCheck = pkg.interfaces();
-                    break;
-                default:
-                    System.err.println("Error reading package: " + pkg.name());
-                    break;
-                }
-                for (ClassInfo cl : classesToCheck) {
-                    if (!cl.isHidden()) {
-                        allHidden = false;
-                        break;
-                    }
-                }
-                if (!allHidden) {
-                    break;
-                }
-                pass++;
-            }
-            if (allHidden) {
-                continue;
-            }
-
-            result.add(pkg);
-        }
-
-        sVisiblePackages = result.toArray(new PackageInfo[result.size()]);
-        return sVisiblePackages;
-    }
-
-    public static void writePackages(String filename)
-    {
-        HDF data = makePackageHDF();
-
-        int i = 0;
-        for (PackageInfo pkg: choosePackages()) {
-            writePackage(pkg);
-
-            data.setValue("docs.packages." + i + ".name", pkg.name());
-            data.setValue("docs.packages." + i + ".link", pkg.htmlPage());
-            TagInfo.makeHDF(data, "docs.packages." + i + ".shortDescr",
-                            pkg.firstSentenceTags());
-
-            i++;
-        }
-
-        setPageTitle(data, "Package Index");
-
-        TagInfo.makeHDF(data, "root.descr",
-                Converter.convertTags(root.inlineTags(), null));
-
-        ClearPage.write(data, "packages.cs", filename);
-        ClearPage.write(data, "package-list.cs", javadocDir + "package-list");
-
-        Proofread.writePackages(filename,
-                Converter.convertTags(root.inlineTags(), null));
-    }
-
-    public static void writePackage(PackageInfo pkg)
-    {
-        // these this and the description are in the same directory,
-        // so it's okay
-        HDF data = makePackageHDF();
-
-        String name = pkg.name();
-
-        data.setValue("package.name", name);
-        data.setValue("package.since", pkg.getSince());
-        data.setValue("package.descr", "...description...");
-
-        makeClassListHDF(data, "package.interfaces",
-                         ClassInfo.sortByName(pkg.interfaces()));
-        makeClassListHDF(data, "package.classes",
-                         ClassInfo.sortByName(pkg.ordinaryClasses()));
-        makeClassListHDF(data, "package.enums",
-                         ClassInfo.sortByName(pkg.enums()));
-        makeClassListHDF(data, "package.exceptions",
-                         ClassInfo.sortByName(pkg.exceptions()));
-        makeClassListHDF(data, "package.errors",
-                         ClassInfo.sortByName(pkg.errors()));
-        TagInfo.makeHDF(data, "package.shortDescr",
-                         pkg.firstSentenceTags());
-        TagInfo.makeHDF(data, "package.descr", pkg.inlineTags());
-
-        String filename = pkg.htmlPage();
-        setPageTitle(data, name);
-        ClearPage.write(data, "package.cs", filename);
-
-        filename = pkg.fullDescriptionHtmlPage();
-        setPageTitle(data, name + " Details");
-        ClearPage.write(data, "package-descr.cs", filename);
-
-        Proofread.writePackage(filename, pkg.inlineTags());
-    }
-
-    public static void writeClassLists()
-    {
-        int i;
-        HDF data = makePackageHDF();
-
-        ClassInfo[] classes = PackageInfo.filterHidden(
-                                    Converter.convertClasses(root.classes()));
-        if (classes.length == 0) {
-            return ;
-        }
-
-        Sorter[] sorted = new Sorter[classes.length];
-        for (i=0; i<sorted.length; i++) {
-            ClassInfo cl = classes[i];
-            String name = cl.name();
-            sorted[i] = new Sorter(name, cl);
-        }
-
-        Arrays.sort(sorted);
-
-        // make a pass and resolve ones that have the same name
-        int firstMatch = 0;
-        String lastName = sorted[0].label;
-        for (i=1; i<sorted.length; i++) {
-            String s = sorted[i].label;
-            if (!lastName.equals(s)) {
-                if (firstMatch != i-1) {
-                    // there were duplicates
-                    for (int j=firstMatch; j<i; j++) {
-                        PackageInfo pkg = ((ClassInfo)sorted[j].data).containingPackage();
-                        if (pkg != null) {
-                            sorted[j].label = sorted[j].label + " (" + pkg.name() + ")";
-                        }
-                    }
-                }
-                firstMatch = i;
-                lastName = s;
-            }
-        }
-
-        // and sort again
-        Arrays.sort(sorted);
-
-        for (i=0; i<sorted.length; i++) {
-            String s = sorted[i].label;
-            ClassInfo cl = (ClassInfo)sorted[i].data;
-            char first = Character.toUpperCase(s.charAt(0));
-            cl.makeShortDescrHDF(data, "docs.classes." + first + '.' + i);
-        }
-
-        setPageTitle(data, "Class Index");
-        ClearPage.write(data, "classes.cs", javadocDir + "classes" + htmlExtension);
-    }
-
-    // we use the word keywords because "index" means something else in html land
-    // the user only ever sees the word index
-/*    public static void writeKeywords()
-    {
-        ArrayList<KeywordEntry> keywords = new ArrayList<KeywordEntry>();
-
-        ClassInfo[] classes = PackageInfo.filterHidden(Converter.convertClasses(root.classes()));
-
-        for (ClassInfo cl: classes) {
-            cl.makeKeywordEntries(keywords);
-        }
-
-        HDF data = makeHDF();
-
-        Collections.sort(keywords);
-
-        int i=0;
-        for (KeywordEntry entry: keywords) {
-            String base = "keywords." + entry.firstChar() + "." + i;
-            entry.makeHDF(data, base);
-            i++;
-        }
-
-        setPageTitle(data, "Index");
-        ClearPage.write(data, "keywords.cs", javadocDir + "keywords" + htmlExtension);
-    } */
-
-    public static void writeHierarchy()
-    {
-        ClassInfo[] classes = Converter.rootClasses();
-        ArrayList<ClassInfo> info = new ArrayList<ClassInfo>();
-        for (ClassInfo cl: classes) {
-            if (!cl.isHidden()) {
-                info.add(cl);
-            }
-        }
-        HDF data = makePackageHDF();
-        Hierarchy.makeHierarchy(data, info.toArray(new ClassInfo[info.size()]));
-        setPageTitle(data, "Class Hierarchy");
-        ClearPage.write(data, "hierarchy.cs", javadocDir + "hierarchy" + htmlExtension);
-    }
-
-    public static void writeClasses()
-    {
-        ClassInfo[] classes = Converter.rootClasses();
-
-        for (ClassInfo cl: classes) {
-            HDF data = makePackageHDF();
-            if (!cl.isHidden()) {
-                writeClass(cl, data);
-            }
-        }
-    }
-
-    public static void writeClass(ClassInfo cl, HDF data)
-    {
-        cl.makeHDF(data);
-
-        setPageTitle(data, cl.name());
-        ClearPage.write(data, "class.cs", cl.htmlPage());
-
-        Proofread.writeClass(cl.htmlPage(), cl);
-    }
-
-    public static void makeClassListHDF(HDF data, String base,
-            ClassInfo[] classes)
-    {
-        for (int i=0; i<classes.length; i++) {
-            ClassInfo cl = classes[i];
-            if (!cl.isHidden()) {
-                cl.makeShortDescrHDF(data, base + "." + i);
-            }
-        }
-    }
-
-    public static String linkTarget(String source, String target)
-    {
-        String[] src = source.split("/");
-        String[] tgt = target.split("/");
-
-        int srclen = src.length;
-        int tgtlen = tgt.length;
-
-        int same = 0;
-        while (same < (srclen-1)
-                && same < (tgtlen-1)
-                && (src[same].equals(tgt[same]))) {
-            same++;
-        }
-
-        String s = "";
-
-        int up = srclen-same-1;
-        for (int i=0; i<up; i++) {
-            s += "../";
-        }
-
-
-        int N = tgtlen-1;
-        for (int i=same; i<N; i++) {
-            s += tgt[i] + '/';
-        }
-        s += tgt[tgtlen-1];
-
-        return s;
-    }
-
-    /**
-     * Returns true if the given element has an @hide or @pending annotation.
-     */
-    private static boolean hasHideAnnotation(Doc doc) {
-        String comment = doc.getRawCommentText();
-        return comment.indexOf("@hide") != -1 || comment.indexOf("@pending") != -1;
-    }
-
-    /**
-     * Returns true if the given element is hidden.
-     */
-    private static boolean isHidden(Doc doc) {
-        // Methods, fields, constructors.
-        if (doc instanceof MemberDoc) {
-            return hasHideAnnotation(doc);
-        }
-
-        // Classes, interfaces, enums, annotation types.
-        if (doc instanceof ClassDoc) {
-            ClassDoc classDoc = (ClassDoc) doc;
-
-            // Check the containing package.
-            if (hasHideAnnotation(classDoc.containingPackage())) {
-                return true;
-            }
-
-            // Check the class doc and containing class docs if this is a
-            // nested class.
-            ClassDoc current = classDoc;
-            do {
-                if (hasHideAnnotation(current)) {
-                    return true;
-                }
-
-                current = current.containingClass();
-            } while (current != null);
-        }
-
-        return false;
-    }
-
-    /**
-     * Filters out hidden elements.
-     */
-    private static Object filterHidden(Object o, Class<?> expected) {
-        if (o == null) {
-            return null;
-        }
-
-        Class type = o.getClass();
-        if (type.getName().startsWith("com.sun.")) {
-            // TODO: Implement interfaces from superclasses, too.
-            return Proxy.newProxyInstance(type.getClassLoader(),
-                    type.getInterfaces(), new HideHandler(o));
-        } else if (o instanceof Object[]) {
-            Class<?> componentType = expected.getComponentType();
-            Object[] array = (Object[]) o;
-            List<Object> list = new ArrayList<Object>(array.length);
-            for (Object entry : array) {
-                if ((entry instanceof Doc) && isHidden((Doc) entry)) {
-                    continue;
-                }
-                list.add(filterHidden(entry, componentType));
-            }
-            return list.toArray(
-                    (Object[]) Array.newInstance(componentType, list.size()));
-        } else {
-            return o;
-        }
-    }
-
-    /**
-     * Filters hidden elements out of method return values.
-     */
-    private static class HideHandler implements InvocationHandler {
-
-        private final Object target;
-
-        public HideHandler(Object target) {
-            this.target = target;
-        }
-
-        public Object invoke(Object proxy, Method method, Object[] args)
-                throws Throwable {
-            String methodName = method.getName();
-            if (args != null) {
-                if (methodName.equals("compareTo") ||
-                    methodName.equals("equals") ||
-                    methodName.equals("overrides") ||
-                    methodName.equals("subclassOf")) {
-                    args[0] = unwrap(args[0]);
-                }
-            }
-
-            if (methodName.equals("getRawCommentText")) {
-                return filterComment((String) method.invoke(target, args));
-            }
-
-            // escape "&" in disjunctive types.
-            if (proxy instanceof Type && methodName.equals("toString")) {
-                return ((String) method.invoke(target, args))
-                        .replace("&", "&amp;");
-            }
-
-            try {
-                return filterHidden(method.invoke(target, args),
-                        method.getReturnType());
-            } catch (InvocationTargetException e) {
-                throw e.getTargetException();
-            }
-        }
-
-        private String filterComment(String s) {
-            if (s == null) {
-                return null;
-            }
-
-            s = s.trim();
-
-            // Work around off by one error
-            while (s.length() >= 5
-                    && s.charAt(s.length() - 5) == '{') {
-                s += "&nbsp;";
-            }
-
-            return s;
-        }
-
-        private static Object unwrap(Object proxy) {
-            if (proxy instanceof Proxy)
-                return ((HideHandler)Proxy.getInvocationHandler(proxy)).target;
-            return proxy;
-        }
-    }
-
-    public static String scope(Scoped scoped) {
-        if (scoped.isPublic()) {
-            return "public";
-        }
-        else if (scoped.isProtected()) {
-            return "protected";
-        }
-        else if (scoped.isPackagePrivate()) {
-            return "";
-        }
-        else if (scoped.isPrivate()) {
-            return "private";
-        }
-        else {
-            throw new RuntimeException("invalid scope for object " + scoped);
-        }
-    }
-
-    /**
-     * Collect the values used by the Dev tools and write them in files packaged with the SDK
-     * @param output the ouput directory for the files.
-     */
-    private static void writeSdkValues(String output) {
-        ArrayList<String> activityActions = new ArrayList<String>();
-        ArrayList<String> broadcastActions = new ArrayList<String>();
-        ArrayList<String> serviceActions = new ArrayList<String>();
-        ArrayList<String> categories = new ArrayList<String>();
-        ArrayList<String> features = new ArrayList<String>();
-
-        ArrayList<ClassInfo> layouts = new ArrayList<ClassInfo>();
-        ArrayList<ClassInfo> widgets = new ArrayList<ClassInfo>();
-        ArrayList<ClassInfo> layoutParams = new ArrayList<ClassInfo>();
-
-        ClassInfo[] classes = Converter.allClasses();
-
-        // Go through all the fields of all the classes, looking SDK stuff.
-        for (ClassInfo clazz : classes) {
-
-            // first check constant fields for the SdkConstant annotation.
-            FieldInfo[] fields = clazz.allSelfFields();
-            for (FieldInfo field : fields) {
-                Object cValue = field.constantValue();
-                if (cValue != null) {
-                    AnnotationInstanceInfo[] annotations = field.annotations();
-                    if (annotations.length > 0) {
-                        for (AnnotationInstanceInfo annotation : annotations) {
-                            if (SDK_CONSTANT_ANNOTATION.equals(annotation.type().qualifiedName())) {
-                                AnnotationValueInfo[] values = annotation.elementValues();
-                                if (values.length > 0) {
-                                    String type = values[0].valueString();
-                                    if (SDK_CONSTANT_TYPE_ACTIVITY_ACTION.equals(type)) {
-                                        activityActions.add(cValue.toString());
-                                    } else if (SDK_CONSTANT_TYPE_BROADCAST_ACTION.equals(type)) {
-                                        broadcastActions.add(cValue.toString());
-                                    } else if (SDK_CONSTANT_TYPE_SERVICE_ACTION.equals(type)) {
-                                        serviceActions.add(cValue.toString());
-                                    } else if (SDK_CONSTANT_TYPE_CATEGORY.equals(type)) {
-                                        categories.add(cValue.toString());
-                                    } else if (SDK_CONSTANT_TYPE_FEATURE.equals(type)) {
-                                        features.add(cValue.toString());
-                                    }
-                                }
-                                break;
-                            }
-                        }
-                    }
-                }
-            }
-
-            // Now check the class for @Widget or if its in the android.widget package
-            // (unless the class is hidden or abstract, or non public)
-            if (clazz.isHidden() == false && clazz.isPublic() && clazz.isAbstract() == false) {
-                boolean annotated = false;
-                AnnotationInstanceInfo[] annotations = clazz.annotations();
-                if (annotations.length > 0) {
-                    for (AnnotationInstanceInfo annotation : annotations) {
-                        if (SDK_WIDGET_ANNOTATION.equals(annotation.type().qualifiedName())) {
-                            widgets.add(clazz);
-                            annotated = true;
-                            break;
-                        } else if (SDK_LAYOUT_ANNOTATION.equals(annotation.type().qualifiedName())) {
-                            layouts.add(clazz);
-                            annotated = true;
-                            break;
-                        }
-                    }
-                }
-
-                if (annotated == false) {
-                    // lets check if this is inside android.widget
-                    PackageInfo pckg = clazz.containingPackage();
-                    String packageName = pckg.name();
-                    if ("android.widget".equals(packageName) ||
-                            "android.view".equals(packageName)) {
-                        // now we check what this class inherits either from android.view.ViewGroup
-                        // or android.view.View, or android.view.ViewGroup.LayoutParams
-                        int type = checkInheritance(clazz);
-                        switch (type) {
-                            case TYPE_WIDGET:
-                                widgets.add(clazz);
-                                break;
-                            case TYPE_LAYOUT:
-                                layouts.add(clazz);
-                                break;
-                            case TYPE_LAYOUT_PARAM:
-                                layoutParams.add(clazz);
-                                break;
-                        }
-                    }
-                }
-            }
-        }
-
-        // now write the files, whether or not the list are empty.
-        // the SDK built requires those files to be present.
-
-        Collections.sort(activityActions);
-        writeValues(output + "/activity_actions.txt", activityActions);
-
-        Collections.sort(broadcastActions);
-        writeValues(output + "/broadcast_actions.txt", broadcastActions);
-
-        Collections.sort(serviceActions);
-        writeValues(output + "/service_actions.txt", serviceActions);
-
-        Collections.sort(categories);
-        writeValues(output + "/categories.txt", categories);
-
-        Collections.sort(features);
-        writeValues(output + "/features.txt", features);
-
-        // before writing the list of classes, we do some checks, to make sure the layout params
-        // are enclosed by a layout class (and not one that has been declared as a widget)
-        for (int i = 0 ; i < layoutParams.size();) {
-            ClassInfo layoutParamClass = layoutParams.get(i);
-            ClassInfo containingClass = layoutParamClass.containingClass();
-            if (containingClass == null || layouts.indexOf(containingClass) == -1) {
-                layoutParams.remove(i);
-            } else {
-                i++;
-            }
-        }
-
-        writeClasses(output + "/widgets.txt", widgets, layouts, layoutParams);
-    }
-
-    /**
-     * Writes a list of values into a text files.
-     * @param pathname the absolute os path of the output file.
-     * @param values the list of values to write.
-     */
-    private static void writeValues(String pathname, ArrayList<String> values) {
-        FileWriter fw = null;
-        BufferedWriter bw = null;
-        try {
-            fw = new FileWriter(pathname, false);
-            bw = new BufferedWriter(fw);
-
-            for (String value : values) {
-                bw.append(value).append('\n');
-            }
-        } catch (IOException e) {
-            // pass for now
-        } finally {
-            try {
-                if (bw != null) bw.close();
-            } catch (IOException e) {
-                // pass for now
-            }
-            try {
-                if (fw != null) fw.close();
-            } catch (IOException e) {
-                // pass for now
-            }
-        }
-    }
-
-    /**
-     * Writes the widget/layout/layout param classes into a text files.
-     * @param pathname the absolute os path of the output file.
-     * @param widgets the list of widget classes to write.
-     * @param layouts the list of layout classes to write.
-     * @param layoutParams the list of layout param classes to write.
-     */
-    private static void writeClasses(String pathname, ArrayList<ClassInfo> widgets,
-            ArrayList<ClassInfo> layouts, ArrayList<ClassInfo> layoutParams) {
-        FileWriter fw = null;
-        BufferedWriter bw = null;
-        try {
-            fw = new FileWriter(pathname, false);
-            bw = new BufferedWriter(fw);
-
-            // write the 3 types of classes.
-            for (ClassInfo clazz : widgets) {
-                writeClass(bw, clazz, 'W');
-            }
-            for (ClassInfo clazz : layoutParams) {
-                writeClass(bw, clazz, 'P');
-            }
-            for (ClassInfo clazz : layouts) {
-                writeClass(bw, clazz, 'L');
-            }
-        } catch (IOException e) {
-            // pass for now
-        } finally {
-            try {
-                if (bw != null) bw.close();
-            } catch (IOException e) {
-                // pass for now
-            }
-            try {
-                if (fw != null) fw.close();
-            } catch (IOException e) {
-                // pass for now
-            }
-        }
-    }
-
-    /**
-     * Writes a class name and its super class names into a {@link BufferedWriter}.
-     * @param writer the BufferedWriter to write into
-     * @param clazz the class to write
-     * @param prefix the prefix to put at the beginning of the line.
-     * @throws IOException
-     */
-    private static void writeClass(BufferedWriter writer, ClassInfo clazz, char prefix)
-            throws IOException {
-        writer.append(prefix).append(clazz.qualifiedName());
-        ClassInfo superClass = clazz;
-        while ((superClass = superClass.superclass()) != null) {
-            writer.append(' ').append(superClass.qualifiedName());
-        }
-        writer.append('\n');
-    }
-
-    /**
-     * Checks the inheritance of {@link ClassInfo} objects. This method return
-     * <ul>
-     * <li>{@link #TYPE_LAYOUT}: if the class extends <code>android.view.ViewGroup</code></li>
-     * <li>{@link #TYPE_WIDGET}: if the class extends <code>android.view.View</code></li>
-     * <li>{@link #TYPE_LAYOUT_PARAM}: if the class extends <code>android.view.ViewGroup$LayoutParams</code></li>
-     * <li>{@link #TYPE_NONE}: in all other cases</li>
-     * </ul>
-     * @param clazz the {@link ClassInfo} to check.
-     */
-    private static int checkInheritance(ClassInfo clazz) {
-        if ("android.view.ViewGroup".equals(clazz.qualifiedName())) {
-            return TYPE_LAYOUT;
-        } else if ("android.view.View".equals(clazz.qualifiedName())) {
-            return TYPE_WIDGET;
-        } else if ("android.view.ViewGroup.LayoutParams".equals(clazz.qualifiedName())) {
-            return TYPE_LAYOUT_PARAM;
-        }
-
-        ClassInfo parent = clazz.superclass();
-        if (parent != null) {
-            return checkInheritance(parent);
-        }
-
-        return TYPE_NONE;
-    }
-}
diff --git a/tools/droiddoc/src/Errors.java b/tools/droiddoc/src/Errors.java
deleted file mode 100644
index 0a91abc..0000000
--- a/tools/droiddoc/src/Errors.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-import java.util.SortedSet;
-import java.util.TreeSet;
-
-public class Errors
-{
-    public static boolean hadError = false;
-    private static boolean warningsAreErrors = false;
-    private static TreeSet<Message> allErrors = new TreeSet<Message>();
-
-    private static class Message implements Comparable {
-        SourcePositionInfo pos;
-        int level;
-        String msg;
-
-        Message(SourcePositionInfo p, int l, String m) {
-            pos = p;
-            level = l;
-            msg = m;
-        }
-
-        public int compareTo(Object o) {
-            Message that = (Message)o;
-            int r = this.pos.compareTo(that.pos);
-            if (r != 0) return r;
-            return this.msg.compareTo(that.msg);
-        }
-
-        @Override
-        public String toString() {
-            String whereText = this.pos == null ? "unknown: " : this.pos.toString() + ':';
-            return whereText + this.msg;
-        }
-    }
-
-    public static void error(Error error, SourcePositionInfo where, String text) {
-        if (error.level == HIDDEN) {
-            return;
-        }
-
-        int level = (!warningsAreErrors && error.level == WARNING) ? WARNING : ERROR;
-        String which = level == WARNING ? " warning " : " error ";
-        String message = which + error.code + ": " + text;
-
-        if (where == null) {
-            where = new SourcePositionInfo("unknown", 0, 0);
-        }
-
-        allErrors.add(new Message(where, level, message));
-
-        if (error.level == ERROR || (warningsAreErrors && error.level == WARNING)) {
-            hadError = true;
-        }
-    }
-
-    public static void printErrors() {
-        for (Message m: allErrors) {
-            if (m.level == WARNING) {
-                System.err.println(m.toString());
-            }
-        }
-        for (Message m: allErrors) {
-            if (m.level == ERROR) {
-                System.err.println(m.toString());
-            }
-        }
-    }
-
-    public static int HIDDEN = 0;
-    public static int WARNING = 1;
-    public static int ERROR = 2;
-
-    public static void setWarningsAreErrors(boolean val) {
-        warningsAreErrors = val;
-    }
-
-    public static class Error {
-        public int code;
-        public int level;
-
-        public Error(int code, int level)
-        {
-            this.code = code;
-            this.level = level;
-        }
-    }
-
-    public static Error UNRESOLVED_LINK = new Error(1, WARNING);
-    public static Error BAD_INCLUDE_TAG = new Error(2, WARNING);
-    public static Error UNKNOWN_TAG = new Error(3, WARNING);
-    public static Error UNKNOWN_PARAM_TAG_NAME = new Error(4, WARNING);
-    public static Error UNDOCUMENTED_PARAMETER = new Error(5, HIDDEN);
-    public static Error BAD_ATTR_TAG = new Error(6, ERROR);
-    public static Error BAD_INHERITDOC = new Error(7, HIDDEN);
-    public static Error HIDDEN_LINK = new Error(8, WARNING);
-    public static Error HIDDEN_CONSTRUCTOR = new Error(9, WARNING);
-    public static Error UNAVAILABLE_SYMBOL = new Error(10, ERROR);
-    public static Error HIDDEN_SUPERCLASS = new Error(11, WARNING);
-    public static Error DEPRECATED = new Error(12, HIDDEN);
-    public static Error DEPRECATION_MISMATCH = new Error(13, WARNING);
-    public static Error MISSING_COMMENT = new Error(14, WARNING);
-    public static Error IO_ERROR = new Error(15, HIDDEN);
-    public static Error NO_SINCE_DATA = new Error(16, HIDDEN);
-
-    public static Error[] ERRORS = {
-            UNRESOLVED_LINK,
-            BAD_INCLUDE_TAG,
-            UNKNOWN_TAG,
-            UNKNOWN_PARAM_TAG_NAME,
-            UNDOCUMENTED_PARAMETER,
-            BAD_ATTR_TAG,
-            BAD_INHERITDOC,
-            HIDDEN_LINK,
-            HIDDEN_CONSTRUCTOR,
-            UNAVAILABLE_SYMBOL,
-            HIDDEN_SUPERCLASS,
-            DEPRECATED,
-            DEPRECATION_MISMATCH,
-            MISSING_COMMENT,
-            IO_ERROR,
-            NO_SINCE_DATA,
-        };
-
-    public static boolean setErrorLevel(int code, int level) {
-        for (Error e: ERRORS) {
-            if (e.code == code) {
-                e.level = level;
-                return true;
-            }
-        }
-        return false;
-    }
-}
diff --git a/tools/droiddoc/src/FieldInfo.java b/tools/droiddoc/src/FieldInfo.java
deleted file mode 100644
index d9371e8..0000000
--- a/tools/droiddoc/src/FieldInfo.java
+++ /dev/null
@@ -1,317 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-import org.clearsilver.HDF;
-import org.clearsilver.CS;
-
-import java.util.Comparator;
-
-public class FieldInfo extends MemberInfo
-{
-    public static final Comparator<FieldInfo> comparator = new Comparator<FieldInfo>() {
-        public int compare(FieldInfo a, FieldInfo b) {
-            return a.name().compareTo(b.name());
-        }
-    };
-
-    public FieldInfo(String name, ClassInfo containingClass, ClassInfo realContainingClass,
-                        boolean isPublic, boolean isProtected,
-                        boolean isPackagePrivate, boolean isPrivate,
-                        boolean isFinal, boolean isStatic, boolean isTransient, boolean isVolatile,
-                        boolean isSynthetic, TypeInfo type, String rawCommentText,
-                        Object constantValue,
-                        SourcePositionInfo position,
-                        AnnotationInstanceInfo[] annotations)
-    {
-        super(rawCommentText, name, null, containingClass, realContainingClass,
-                isPublic, isProtected, isPackagePrivate, isPrivate,
-                isFinal, isStatic, isSynthetic, chooseKind(isFinal, isStatic), position,
-                annotations);
-        mIsTransient = isTransient;
-        mIsVolatile = isVolatile;
-        mType = type;
-        mConstantValue = constantValue;
-    }
-
-    public FieldInfo cloneForClass(ClassInfo newContainingClass) {
-        return new FieldInfo(name(), newContainingClass, realContainingClass(),
-                isPublic(), isProtected(), isPackagePrivate(),
-                isPrivate(), isFinal(), isStatic(), isTransient(), isVolatile(),
-                isSynthetic(), mType, getRawCommentText(), mConstantValue, position(),
-                annotations());
-    }
-
-    static String chooseKind(boolean isFinal, boolean isStatic)
-    {
-        if (isStatic && isFinal) {
-            return "constant";
-        } else {
-            return "field";
-        }
-    }
-
-    public TypeInfo type()
-    {
-        return mType;
-    }
-
-    public boolean isConstant()
-    {
-        return isStatic() && isFinal();
-    }
-
-    public TagInfo[] firstSentenceTags()
-    {
-        return comment().briefTags();
-    }
-
-    public TagInfo[] inlineTags()
-    {
-        return comment().tags();
-    }
-
-    public Object constantValue()
-    {
-        return mConstantValue;
-    }
-
-    public String constantLiteralValue()
-    {
-        return constantLiteralValue(mConstantValue);
-    }
-
-    public boolean isDeprecated() {
-        boolean deprecated = false;
-        if (!mDeprecatedKnown) {
-            boolean commentDeprecated = (comment().deprecatedTags().length > 0);
-            boolean annotationDeprecated = false;
-            for (AnnotationInstanceInfo annotation : annotations()) {
-                if (annotation.type().qualifiedName().equals("java.lang.Deprecated")) {
-                    annotationDeprecated = true;
-                    break;
-                }
-            }
-
-            if (commentDeprecated != annotationDeprecated) {
-                Errors.error(Errors.DEPRECATION_MISMATCH, position(),
-                        "Field " + mContainingClass.qualifiedName() + "." + name()
-                        + ": @Deprecated annotation and @deprecated comment do not match");
-            }
-
-            mIsDeprecated = commentDeprecated | annotationDeprecated;
-            mDeprecatedKnown = true;
-        }
-        return mIsDeprecated;
-    }
-
-    public static String constantLiteralValue(Object val)
-    {
-        String str = null;
-        if (val != null) {
-            if (val instanceof Boolean
-                    || val instanceof Byte
-                    || val instanceof Short
-                    || val instanceof Integer)
-            {
-                str = val.toString();
-            }
-            //catch all special values
-            else if (val instanceof Double){
-                Double dbl = (Double) val;
-                    if (dbl.toString().equals("Infinity")){
-                        str = "(1.0 / 0.0)";
-                    } else if (dbl.toString().equals("-Infinity")) {
-                        str = "(-1.0 / 0.0)";
-                    } else if (dbl.isNaN()) {
-                        str = "(0.0 / 0.0)";
-                    } else {
-                        str = dbl.toString();
-                    }
-            }
-            else if (val instanceof Long) {
-                str = val.toString() + "L";
-            }
-            else if (val instanceof Float) {
-                Float fl = (Float) val;
-                if (fl.toString().equals("Infinity")) {
-                    str = "(1.0f / 0.0f)";
-                } else if (fl.toString().equals("-Infinity")) {
-                    str = "(-1.0f / 0.0f)";
-                } else if (fl.isNaN()) {
-                    str = "(0.0f / 0.0f)";
-                } else {
-                    str = val.toString() + "f";
-                }
-            }
-            else if (val instanceof Character) {
-                str = String.format("\'\\u%04x\'", val);
-            }
-            else if (val instanceof String) {
-                str = "\"" + javaEscapeString((String)val) + "\"";
-            }
-            else {
-                str = "<<<<" +val.toString() + ">>>>";
-            }
-        }
-        if (str == null) {
-            str = "null";
-        }
-        return str;
-    }
-
-    public static String javaEscapeString(String str) {
-        String result = "";
-        final int N = str.length();
-        for (int i=0; i<N; i++) {
-            char c = str.charAt(i);
-            if (c == '\\') {
-                result += "\\\\";
-            }
-            else if (c == '\t') {
-                result += "\\t";
-            }
-            else if (c == '\b') {
-                result += "\\b";
-            }
-            else if (c == '\r') {
-                result += "\\r";
-            }
-            else if (c == '\n') {
-                result += "\\n";
-            }
-            else if (c == '\f') {
-                result += "\\f";
-            }
-            else if (c == '\'') {
-                result += "\\'";
-            }
-            else if (c == '\"') {
-                result += "\\\"";
-            }
-            else if (c >= ' ' && c <= '~') {
-                result += c;
-            }
-            else {
-                result += String.format("\\u%04x", new Integer((int)c));
-            }
-        }
-        return result;
-    }
-
-
-    public void makeHDF(HDF data, String base)
-    {
-        data.setValue(base + ".kind", kind());
-        type().makeHDF(data, base + ".type");
-        data.setValue(base + ".name", name());
-        data.setValue(base + ".href", htmlPage());
-        data.setValue(base + ".anchor", anchor());
-        TagInfo.makeHDF(data, base + ".shortDescr", firstSentenceTags());
-        TagInfo.makeHDF(data, base + ".descr", inlineTags());
-        TagInfo.makeHDF(data, base + ".deprecated", comment().deprecatedTags());
-        TagInfo.makeHDF(data, base + ".seeAlso", comment().seeTags());
-        data.setValue(base + ".since", getSince());
-        data.setValue(base + ".final", isFinal() ? "final" : "");
-        data.setValue(base + ".static", isStatic() ? "static" : "");
-        if (isPublic()) {
-            data.setValue(base + ".scope", "public");
-        }
-        else if (isProtected()) {
-            data.setValue(base + ".scope", "protected");
-        }
-        else if (isPackagePrivate()) {
-            data.setValue(base + ".scope", "");
-        }
-        else if (isPrivate()) {
-            data.setValue(base + ".scope", "private");
-        }
-        Object val = mConstantValue;
-        if (val != null) {
-            String dec = null;
-            String hex = null;
-            String str = null;
-
-            if (val instanceof Boolean) {
-                str = ((Boolean)val).toString();
-            }
-            else if (val instanceof Byte) {
-                dec = String.format("%d", val);
-                hex = String.format("0x%02x", val);
-            }
-            else if (val instanceof Character) {
-                dec = String.format("\'%c\'", val);
-                hex = String.format("0x%04x", val);
-            }
-            else if (val instanceof Double) {
-                str = ((Double)val).toString();
-            }
-            else if (val instanceof Float) {
-                str = ((Float)val).toString();
-            }
-            else if (val instanceof Integer) {
-                dec = String.format("%d", val);
-                hex = String.format("0x%08x", val);
-            }
-            else if (val instanceof Long) {
-                dec = String.format("%d", val);
-                hex = String.format("0x%016x", val);
-            }
-            else if (val instanceof Short) {
-                dec = String.format("%d", val);
-                hex = String.format("0x%04x", val);
-            }
-            else if (val instanceof String) {
-                str = "\"" + ((String)val) + "\"";
-            }
-            else {
-                str = "";
-            }
-
-            if (dec != null && hex != null) {
-                data.setValue(base + ".constantValue.dec", DroidDoc.escape(dec));
-                data.setValue(base + ".constantValue.hex", DroidDoc.escape(hex));
-            }
-            else {
-                data.setValue(base + ".constantValue.str", DroidDoc.escape(str));
-                data.setValue(base + ".constantValue.isString", "1");
-            }
-        }
-    }
-
-    @Override
-    public boolean isExecutable()
-    {
-        return false;
-    }
-
-    public boolean isTransient()
-    {
-        return mIsTransient;
-    }
-
-    public boolean isVolatile()
-    {
-        return mIsVolatile;
-    }
-
-    boolean mIsTransient;
-    boolean mIsVolatile;
-    boolean mDeprecatedKnown;
-    boolean mIsDeprecated;
-    TypeInfo mType;
-    Object mConstantValue;
-}
-
diff --git a/tools/droiddoc/src/Hierarchy.java b/tools/droiddoc/src/Hierarchy.java
deleted file mode 100755
index ac5e1dc..0000000
--- a/tools/droiddoc/src/Hierarchy.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-import java.util.HashMap;
-import java.util.TreeSet;
-import java.util.Set;
-import org.clearsilver.HDF;
-
-public class Hierarchy
-{
-    public static void makeHierarchy(HDF hdf, ClassInfo[] classes)
-    {
-        HashMap<String,TreeSet<String>> nodes
-                                    = new HashMap<String,TreeSet<String>>();
-
-        for (ClassInfo cl: classes) {
-            String name = cl.qualifiedName();
-
-            TreeSet<String> me = nodes.get(name);
-            if (me == null) {
-                me = new TreeSet<String>();
-                nodes.put(name, me);
-            }
-
-            ClassInfo superclass = cl.superclass();
-            String sname = superclass != null
-                                    ? superclass.qualifiedName() : null;
-            if (sname != null) {
-                TreeSet<String> s = nodes.get(sname);
-                if (s == null) {
-                    s = new TreeSet<String>();
-                    nodes.put(sname, s);
-                }
-                s.add(name);
-            }
-        }
-
-        /*
-        Set<String> keys = nodes.keySet();
-        for (String n: keys) {
-            System.out.println("class: " + n);
-
-            TreeSet<String> values = nodes.get(n);
-            for (String v: values) {
-                System.out.println("       - " + v);
-            }
-        }
-        */
-
-        int depth = depth(nodes, "java.lang.Object");
-
-        hdf.setValue("classes.0", "");
-        hdf.setValue("colspan", "" + depth);
-
-        recurse(nodes, "java.lang.Object", hdf.getObj("classes.0"),depth,depth);
-
-        if (false) {
-            Set<String> keys = nodes.keySet();
-            if (keys.size() > 0) {
-                System.err.println("The following classes are hidden but"
-                        + " are superclasses of not-hidden classes");
-                for (String n: keys) {
-                    System.err.println("  " + n);
-                }
-            }
-        }
-    }
-
-    private static int depth(HashMap<String,TreeSet<String>> nodes,
-                                String name)
-    {
-        int d = 0;
-        TreeSet<String> derived = nodes.get(name);
-        if (derived != null && derived.size() > 0) {
-            for (String s: derived) {
-                int n = depth(nodes, s);
-                if (n > d) {
-                    d = n;
-                }
-            }
-        }
-        return d + 1;
-    }
-
-    private static boolean exists(ClassInfo cl)
-    {
-        return cl != null && !cl.isHidden() && cl.isIncluded();
-    }
-
-    private static void recurse(HashMap<String,TreeSet<String>> nodes,
-                                String name, HDF hdf, 
-                                int totalDepth, int remainingDepth)
-    {
-        int i;
-
-        hdf.setValue("indent", "" + (totalDepth-remainingDepth-1));
-        hdf.setValue("colspan", "" + remainingDepth);
-
-        ClassInfo cl = Converter.obtainClass(name);
-
-        hdf.setValue("class.label", cl.name());
-        hdf.setValue("class.qualified", cl.qualifiedName());
-        if (cl.checkLevel()) {
-            hdf.setValue("class.link", cl.htmlPage());
-        }
-
-        if (exists(cl)) {
-            hdf.setValue("exists", "1");
-        }
-
-        i = 0;
-        for (ClassInfo iface: cl.interfaces()) {
-            hdf.setValue("interfaces." + i + ".class.label", iface.name());
-            hdf.setValue("interfaces." + i + ".class.qualified", iface.qualifiedName());
-            if (iface.checkLevel()) {
-                hdf.setValue("interfaces." + i + ".class.link", iface.htmlPage());
-            }
-            if (exists(cl)) {
-                hdf.setValue("interfaces." + i + ".exists", "1");
-            }
-            i++;
-        }
-
-        TreeSet<String> derived = nodes.get(name);
-        if (derived != null && derived.size() > 0) {
-            hdf.setValue("derived", "");
-            HDF children = hdf.getObj("derived");
-            i = 0;
-            remainingDepth--;
-            for (String s: derived) {
-                String index = "" + i;
-                children.setValue(index, "");
-                recurse(nodes, s, children.getObj(index), totalDepth,
-                        remainingDepth);
-                i++;
-            }
-        }
-
-        nodes.remove(name);
-    }
-}
-
diff --git a/tools/droiddoc/src/InheritedTags.java b/tools/droiddoc/src/InheritedTags.java
deleted file mode 100644
index 242170c..0000000
--- a/tools/droiddoc/src/InheritedTags.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-import org.clearsilver.HDF;
-import org.clearsilver.CS;
-import java.util.*;
-import java.io.*;
-
-public interface InheritedTags
-{
-    TagInfo[] tags();
-    InheritedTags inherited();
-}
-
diff --git a/tools/droiddoc/src/KeywordEntry.java b/tools/droiddoc/src/KeywordEntry.java
deleted file mode 100644
index 7e5e357..0000000
--- a/tools/droiddoc/src/KeywordEntry.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-import org.clearsilver.HDF;
-import org.clearsilver.CS;
-
-class KeywordEntry implements Comparable
-{
-    KeywordEntry(String label, String href, String comment)
-    {
-        this.label = label;
-        this.href = href;
-        this.comment = comment;
-    }
-
-    public void makeHDF(HDF data, String base)
-    {
-        data.setValue(base + ".label", this.label);
-        data.setValue(base + ".href", this.href);
-        data.setValue(base + ".comment", this.comment);
-    }
-
-    public char firstChar()
-    {
-        return Character.toUpperCase(this.label.charAt(0));
-    }
-
-    public int compareTo(Object that)
-    {
-        return this.label.compareToIgnoreCase(((KeywordEntry)that).label);
-    }
-
-    private String label;
-    private String href;
-    private String comment;
-}
-
-
diff --git a/tools/droiddoc/src/LinkReference.java b/tools/droiddoc/src/LinkReference.java
deleted file mode 100644
index b1f998a..0000000
--- a/tools/droiddoc/src/LinkReference.java
+++ /dev/null
@@ -1,446 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-import java.util.regex.Pattern;
-import java.util.regex.Matcher;
-import java.util.ArrayList;
-
-/**
- * Class that represents what you see in an link or see tag.  This is
- * factored out of SeeTagInfo so it can be used elsewhere (like AttrTagInfo).
- */
-public class LinkReference {
-
-    /** The original text. */
-    public String text;
-    
-    /** The kind of this tag, if we have a new suggestion after parsing. */
-    public String kind;
-
-    /** The user visible text. */
-    public String label;
-
-    /** The link. */
-    public String href;
-
-    /** The {@link PackageInfo} if any. */
-    public PackageInfo packageInfo;
-
-    /** The {@link ClassInfo} if any. */
-    public ClassInfo classInfo;
-
-    /** The {@link MemberInfo} if any. */
-    public MemberInfo memberInfo;
-
-    /** The name of the referenced member PackageInfo} if any. */
-    public String referencedMemberName;
-
-    /** Set to true if everything is a-ok */
-    public boolean good;
-
-    /**
-     * regex pattern to use when matching explicit "<a href" reference text
-     */
-    private static final Pattern HREF_PATTERN
-            = Pattern.compile("^<a href=\"([^\"]*)\">([^<]*)</a>[ \n\r\t]*$",
-                              Pattern.CASE_INSENSITIVE);
-
-    /**
-     * regex pattern to use when matching double-quoted reference text
-     */
-    private static final Pattern QUOTE_PATTERN
-            = Pattern.compile("^\"([^\"]*)\"[ \n\r\t]*$");
-
-    /**
-     * Parse and resolve a link string.
-     *
-     * @param text the original text
-     * @param base the class or whatever that this link is on
-     * @param pos the original position in the source document
-     * @return a new link reference.  It always returns something.  If there was an
-     *         error, it logs it and fills in href and label with error text.
-     */
-    public static LinkReference parse(String text, ContainerInfo base, SourcePositionInfo pos,
-                                        boolean printOnErrors) {
-        LinkReference result = new LinkReference();
-        result.text = text;
-
-        int index;
-        int len = text.length();
-        int pairs = 0;
-        int pound = -1;
-        // split the string
-        done: {
-            for (index=0; index<len; index++) {
-                char c = text.charAt(index);
-                switch (c)
-                {
-                    case '(':
-                        pairs++;
-                        break;
-                    case '[':
-                        pairs++;
-                        break;
-                    case ')':
-                        pairs--;
-                        break;
-                    case ']':
-                        pairs--;
-                        break;
-                    case ' ':
-                    case '\t':
-                    case '\r':
-                    case '\n':
-                        if (pairs == 0) {
-                            break done;
-                        }
-                        break;
-                    case '#':
-                        if (pound < 0) {
-                            pound = index;
-                        }
-                        break;
-                }
-            }
-        }
-        if (index == len && pairs != 0) {
-            Errors.error(Errors.UNRESOLVED_LINK, pos,
-                        "unable to parse link/see tag: " + text.trim());
-            return result;
-        }
-
-        int linkend = index;
-
-        for (; index<len; index++) {
-            char c = text.charAt(index);
-            if (!(c == ' ' || c == '\t' || c == '\r' || c == '\n')) {
-                break;
-            }
-        }
-
-        result.label = text.substring(index);
-
-        String ref;
-        String mem;
-        if (pound == 0) {
-            ref = null;
-            mem = text.substring(1, linkend);
-        }
-        else if (pound > 0) {
-            ref = text.substring(0, pound);
-            mem = text.substring(pound+1, linkend);
-        }
-        else {
-            ref = text.substring(0, linkend);
-            mem = null;
-        }
-
-        // parse parameters, if any
-        String[] params = null;
-        String[] paramDimensions = null;
-        if (mem != null) {
-            index = mem.indexOf('(');
-            if (index > 0) {
-                ArrayList<String> paramList = new ArrayList<String>();
-                ArrayList<String> paramDimensionList = new ArrayList<String>();
-                len = mem.length();
-                int start = index+1;
-                final int START = 0;
-                final int TYPE = 1;
-                final int NAME = 2;
-                int dimension = 0;
-                int arraypair = 0;
-                int state = START;
-                int typestart = 0;
-                int typeend = -1;
-                for (int i=start; i<len; i++) {
-                    char c = mem.charAt(i);
-                    switch (state)
-                    {
-                        case START:
-                            if (c!=' ' && c!='\t' && c!='\r' && c!='\n') {
-                                state = TYPE;
-                                typestart = i;
-                            }
-                            break;
-                        case TYPE:
-                            if (c == '[') {
-                                if (typeend < 0) {
-                                    typeend = i;
-                                }
-                                dimension++;
-                                arraypair++;
-                            }
-                            else if (c == ']') {
-                                arraypair--;
-                            }
-                            else if (c==' ' || c=='\t' || c=='\r' || c=='\n') {
-                                if (typeend < 0) {
-                                    typeend = i;
-                                }
-                            }
-                            else {
-                                if (typeend >= 0 || c == ')' || c == ',') {
-                                    if (typeend < 0) {
-                                        typeend = i;
-                                    }
-                                    String s = mem.substring(typestart, typeend);
-                                    paramList.add(s);
-                                    s = "";
-                                    for (int j=0; j<dimension; j++) {
-                                        s += "[]";
-                                    }
-                                    paramDimensionList.add(s);
-                                    state = START;
-                                    typeend = -1;
-                                    dimension = 0;
-                                    if (c == ',' || c == ')') {
-                                        state = START;
-                                    } else {
-                                        state = NAME;
-                                    }
-                                }
-                            }
-                            break;
-                        case NAME:
-                            if (c == ',' || c == ')') {
-                                state = START;
-                            }
-                            break;
-                    }
-
-                }
-                params = paramList.toArray(new String[paramList.size()]);
-                paramDimensions = paramDimensionList.toArray(new String[paramList.size()]);
-                mem = mem.substring(0, index);
-            }
-        }
-
-        ClassInfo cl = null;
-        if (base instanceof ClassInfo) {
-            cl = (ClassInfo)base;
-        }
-
-        if (ref == null) {
-            // no class or package was provided, assume it's this class
-            if (cl != null) {
-                result.classInfo = cl;
-            }
-        } else {
-            // they provided something, maybe it's a class or a package
-            if (cl != null) {
-                result.classInfo = cl.extendedFindClass(ref);
-                if (result.classInfo == null) {
-                    result.classInfo = cl.findClass(ref);
-                }
-                if (result.classInfo == null) {
-                    result.classInfo = cl.findInnerClass(ref);
-                }
-            }
-            if (result.classInfo == null) {
-                result.classInfo = Converter.obtainClass(ref);
-            }
-            if (result.classInfo == null) {
-                result.packageInfo = Converter.obtainPackage(ref);
-            }
-        }
-
-        if (result.classInfo != null && mem != null) {
-            // it's either a field or a method, prefer a field
-            if (params == null) {
-                FieldInfo field = result.classInfo.findField(mem);
-                // findField looks in containing classes, so it might actually
-                // be somewhere else; link to where it really is, not what they
-                // typed.
-                if (field != null) {
-                    result.classInfo = field.containingClass();
-                    result.memberInfo = field;
-                }
-            }
-            if (result.memberInfo == null) {
-                MethodInfo method = result.classInfo.findMethod(mem, params, paramDimensions);
-                if (method != null) {
-                    result.classInfo = method.containingClass();
-                    result.memberInfo = method;
-                }
-            }
-        }
-
-        result.referencedMemberName = mem;
-        if (params != null) {
-            result.referencedMemberName = result.referencedMemberName + '(';
-            len = params.length;
-            if (len > 0) {
-                len--;
-                for (int i=0; i<len; i++) {
-                    result.referencedMemberName = result.referencedMemberName + params[i]
-                            + paramDimensions[i] + ", ";
-                }
-                result.referencedMemberName = result.referencedMemberName + params[len]
-                        + paramDimensions[len];
-            }
-            result.referencedMemberName = result.referencedMemberName + ")";
-        }
-
-        // debugging spew
-        if (false) {
-            result.label = result.label + "/" + ref + "/" + mem + '/';
-            if (params != null) {
-                for (int i=0; i<params.length; i++) {
-                    result.label += params[i] + "|";
-                }
-            }
-
-            FieldInfo f = (result.memberInfo instanceof FieldInfo)
-                        ? (FieldInfo)result.memberInfo
-                        : null;
-            MethodInfo m = (result.memberInfo instanceof MethodInfo)
-                        ? (MethodInfo)result.memberInfo
-                        : null;
-            result.label = result.label
-                        + "/package=" + (result.packageInfo!=null?result.packageInfo.name():"")
-                        + "/class=" + (result.classInfo!=null?result.classInfo.qualifiedName():"")
-                        + "/field=" + (f!=null?f.name():"")
-                        + "/method=" + (m!=null?m.name():"");
-            
-        }
-
-        MethodInfo method = null;
-        boolean skipHref = false;
-
-        if (result.memberInfo != null && result.memberInfo.isExecutable()) {
-           method = (MethodInfo)result.memberInfo;
-        }
-
-        if (text.startsWith("\"")) {
-            // literal quoted reference (e.g., a book title)
-            Matcher matcher = QUOTE_PATTERN.matcher(text);
-            if (! matcher.matches()) {
-                Errors.error(Errors.UNRESOLVED_LINK, pos,
-                        "unbalanced quoted link/see tag: " + text.trim());
-                result.makeError();
-                return result;
-            }
-            skipHref = true;
-            result.label = matcher.group(1);
-            result.kind = "@seeJustLabel";
-        }
-        else if (text.startsWith("<")) {
-            // explicit "<a href" form
-            Matcher matcher = HREF_PATTERN.matcher(text);
-            if (! matcher.matches()) {
-                Errors.error(Errors.UNRESOLVED_LINK, pos,
-                        "invalid <a> link/see tag: " + text.trim());
-                result.makeError();
-                return result;
-            }
-            result.href = matcher.group(1);
-            result.label = matcher.group(2);
-            result.kind = "@seeHref";
-        }
-        else if (result.packageInfo != null) {
-            result.href = result.packageInfo.htmlPage();
-            if (result.label.length() == 0) {
-                result.href = result.packageInfo.htmlPage();
-                result.label = result.packageInfo.name();
-            }
-        }
-        else if (result.classInfo != null && result.referencedMemberName == null) {
-            // class reference
-            if (result.label.length() == 0) {
-                result.label = result.classInfo.name();
-            }
-            result.href = result.classInfo.htmlPage();
-        }
-        else if (result.memberInfo != null) {
-            // member reference
-            ClassInfo containing = result.memberInfo.containingClass();
-            if (result.memberInfo.isExecutable()) {
-                if (result.referencedMemberName.indexOf('(') < 0) {
-                    result.referencedMemberName += method.flatSignature();
-                }
-            } 
-            if (result.label.length() == 0) {
-                result.label = result.referencedMemberName;
-            }
-            result.href = containing.htmlPage() + '#' + result.memberInfo.anchor();
-        }
-
-        if (result.href == null && !skipHref) {
-            if (printOnErrors && (base == null || base.checkLevel())) {
-                Errors.error(Errors.UNRESOLVED_LINK, pos,
-                        "Unresolved link/see tag \"" + text.trim()
-                        + "\" in " + ((base != null) ? base.qualifiedName() : "[null]"));
-            }
-            result.makeError();
-        }
-        else if (result.memberInfo != null && !result.memberInfo.checkLevel()) {
-            if (printOnErrors && (base == null || base.checkLevel())) {
-                Errors.error(Errors.HIDDEN_LINK, pos,
-                        "Link to hidden member: " + text.trim());
-                result.href = null;
-            }
-            result.kind = "@seeJustLabel";
-        }
-        else if (result.classInfo != null && !result.classInfo.checkLevel()) {
-            if (printOnErrors && (base == null || base.checkLevel())) {
-                Errors.error(Errors.HIDDEN_LINK, pos,
-                        "Link to hidden class: " + text.trim() + " label=" + result.label);
-                result.href = null;
-            }
-            result.kind = "@seeJustLabel";
-        }
-        else if (result.packageInfo != null && !result.packageInfo.checkLevel()) {
-            if (printOnErrors && (base == null || base.checkLevel())) {
-                Errors.error(Errors.HIDDEN_LINK, pos,
-                        "Link to hidden package: " + text.trim());
-                result.href = null;
-            }
-            result.kind = "@seeJustLabel";
-        }
-
-        result.good = true;
-
-        return result;
-    }
-
-    public boolean checkLevel() {
-        if (memberInfo != null) {
-            return memberInfo.checkLevel();
-        }
-        if (classInfo != null) {
-            return classInfo.checkLevel();
-        }
-        if (packageInfo != null) {
-            return packageInfo.checkLevel();
-        }
-        return false;
-    }
-
-    /** turn this LinkReference into one with an error message */
-    private void makeError() {
-        //this.href = "ERROR(" + this.text.trim() + ")";
-        this.href = null;
-        if (this.label == null) {
-            this.label = "";
-        }
-        this.label = "ERROR(" + this.label + "/" + text.trim() + ")";
-    }
-
-    /** private. **/
-    private LinkReference() {
-    }
-}
diff --git a/tools/droiddoc/src/LiteralTagInfo.java b/tools/droiddoc/src/LiteralTagInfo.java
deleted file mode 100644
index b39490d..0000000
--- a/tools/droiddoc/src/LiteralTagInfo.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-public class LiteralTagInfo extends TagInfo
-{
-    private static String encode(String t)
-    {
-        t = t.replace("&", "&amp;");
-        t = t.replace("<", "&lt;");
-        t = t.replace(">", "&gt;");
-        return t;
-    }
-
-    public LiteralTagInfo(String n, String k, String t, SourcePositionInfo sp)
-    {
-        super("Text", "Text", encode(t), sp);
-    }
-}
diff --git a/tools/droiddoc/src/MemberInfo.java b/tools/droiddoc/src/MemberInfo.java
deleted file mode 100644
index 05da583..0000000
--- a/tools/droiddoc/src/MemberInfo.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-public abstract class MemberInfo extends DocInfo implements Comparable, Scoped
-{
-    public MemberInfo(String rawCommentText, String name, String signature,
-                        ClassInfo containingClass, ClassInfo realContainingClass,
-                        boolean isPublic, boolean isProtected,
-                        boolean isPackagePrivate, boolean isPrivate,
-                        boolean isFinal, boolean isStatic, boolean isSynthetic,
-                        String kind,
-                        SourcePositionInfo position,
-                        AnnotationInstanceInfo[] annotations)
-    {
-        super(rawCommentText, position);
-        mName = name;
-        mSignature = signature;
-        mContainingClass = containingClass;
-        mRealContainingClass = realContainingClass;
-        mIsPublic = isPublic;
-        mIsProtected = isProtected;
-        mIsPackagePrivate = isPackagePrivate;
-        mIsPrivate = isPrivate;
-        mIsFinal = isFinal;
-        mIsStatic = isStatic;
-        mIsSynthetic = isSynthetic;
-        mKind = kind;
-        mAnnotations = annotations;
-    }
-
-    public abstract boolean isExecutable();
-
-    public String anchor()
-    {
-        if (mSignature != null) {
-            return mName + mSignature;
-        } else {
-            return mName;
-        }
-    }
-
-    public String htmlPage() {
-        return mContainingClass.htmlPage() + "#" + anchor();
-    }
-
-    public int compareTo(Object that) {
-        return this.htmlPage().compareTo(((MemberInfo)that).htmlPage());
-    }
-
-    public String name()
-    {
-        return mName;
-    }
-
-    public String signature()
-    {
-        return mSignature;
-    }
-
-    public ClassInfo realContainingClass()
-    {
-        return mRealContainingClass;
-    }
-
-    public ClassInfo containingClass()
-    {
-        return mContainingClass;
-    }
-
-    public boolean isPublic()
-    {
-        return mIsPublic;
-    }
-
-    public boolean isProtected()
-    {
-        return mIsProtected;
-    }
-
-    public boolean isPackagePrivate()
-    {
-        return mIsPackagePrivate;
-    }
-
-    public boolean isPrivate()
-    {
-        return mIsPrivate;
-    }
-
-    public boolean isStatic()
-    {
-        return mIsStatic;
-    }
-
-    public boolean isFinal()
-    {
-        return mIsFinal;
-    }
-
-    public boolean isSynthetic()
-    {
-        return mIsSynthetic;
-    }
-
-    @Override
-    public ContainerInfo parent()
-    {
-        return mContainingClass;
-    }
-
-    public boolean checkLevel()
-    {
-        return DroidDoc.checkLevel(mIsPublic, mIsProtected,
-                mIsPackagePrivate, mIsPrivate, isHidden());
-    }
-
-    public String kind()
-    {
-        return mKind;
-    }
-
-    public AnnotationInstanceInfo[] annotations()
-    {
-        return mAnnotations;
-    }
-
-    ClassInfo mContainingClass;
-    ClassInfo mRealContainingClass;
-    String mName;
-    String mSignature;
-    boolean mIsPublic;
-    boolean mIsProtected;
-    boolean mIsPackagePrivate;
-    boolean mIsPrivate;
-    boolean mIsFinal;
-    boolean mIsStatic;
-    boolean mIsSynthetic;
-    String mKind;
-    private AnnotationInstanceInfo[] mAnnotations;
-
-}
-
diff --git a/tools/droiddoc/src/MethodInfo.java b/tools/droiddoc/src/MethodInfo.java
deleted file mode 100644
index 7f96b80..0000000
--- a/tools/droiddoc/src/MethodInfo.java
+++ /dev/null
@@ -1,670 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-import org.clearsilver.HDF;
-
-import java.util.*;
-
-public class MethodInfo extends MemberInfo
-{
-    public static final Comparator<MethodInfo> comparator = new Comparator<MethodInfo>() {
-        public int compare(MethodInfo a, MethodInfo b) {
-            return a.name().compareTo(b.name());
-        }
-    };
-
-    private class InlineTags implements InheritedTags
-    {
-        public TagInfo[] tags()
-        {
-            return comment().tags();
-        }
-        public InheritedTags inherited()
-        {
-            MethodInfo m = findOverriddenMethod(name(), signature());
-            if (m != null) {
-                return m.inlineTags();
-            } else {
-                return null;
-            }
-        }
-    }
-
-    private static void addInterfaces(ClassInfo[] ifaces, ArrayList<ClassInfo> queue)
-    {
-        for (ClassInfo i: ifaces) {
-            queue.add(i);
-        }
-        for (ClassInfo i: ifaces) {
-            addInterfaces(i.interfaces(), queue);
-        }
-    }
-
-    // first looks for a superclass, and then does a breadth first search to
-    // find the least far away match
-    public MethodInfo findOverriddenMethod(String name, String signature)
-    {
-        if (mReturnType == null) {
-            // ctor
-            return null;
-        }
-        if (mOverriddenMethod != null) {
-            return mOverriddenMethod;
-        }
-
-        ArrayList<ClassInfo> queue = new ArrayList<ClassInfo>();
-        addInterfaces(containingClass().interfaces(), queue);
-        for (ClassInfo iface: queue) {
-            for (MethodInfo me: iface.methods()) {
-                if (me.name().equals(name)
-                        && me.signature().equals(signature)
-                        && me.inlineTags().tags() != null
-                        && me.inlineTags().tags().length > 0) {
-                    return me;
-                }
-            }
-        }
-        return null;
-    }
-
-    private static void addRealInterfaces(ClassInfo[] ifaces, ArrayList<ClassInfo> queue)
-    {
-        for (ClassInfo i: ifaces) {
-            queue.add(i);
-            if (i.realSuperclass() != null &&  i.realSuperclass().isAbstract()) {
-                queue.add(i.superclass());
-            }
-        }
-        for (ClassInfo i: ifaces) {
-            addInterfaces(i.realInterfaces(), queue);
-        }
-    }
-
-    public MethodInfo findRealOverriddenMethod(String name, String signature, HashSet notStrippable) {
-        if (mReturnType == null) {
-        // ctor
-        return null;
-        }
-        if (mOverriddenMethod != null) {
-            return mOverriddenMethod;
-        }
-
-        ArrayList<ClassInfo> queue = new ArrayList<ClassInfo>();
-        if (containingClass().realSuperclass() != null &&
-            containingClass().realSuperclass().isAbstract()) {
-            queue.add(containingClass());
-        }
-        addInterfaces(containingClass().realInterfaces(), queue);
-        for (ClassInfo iface: queue) {
-            for (MethodInfo me: iface.methods()) {
-                if (me.name().equals(name)
-                    && me.signature().equals(signature)
-                    && me.inlineTags().tags() != null
-                    && me.inlineTags().tags().length > 0
-                    && notStrippable.contains(me.containingClass())) {
-                return me;
-                }
-            }
-        }
-        return null;
-    }
-
-    public MethodInfo findSuperclassImplementation(HashSet notStrippable) {
-        if (mReturnType == null) {
-            // ctor
-            return null;
-        }
-        if (mOverriddenMethod != null) {
-            // Even if we're told outright that this was the overridden method, we want to
-            // be conservative and ignore mismatches of parameter types -- they arise from
-            // extending generic specializations, and we want to consider the derived-class
-            // method to be a non-override.
-            if (this.signature().equals(mOverriddenMethod.signature())) {
-                return mOverriddenMethod;
-            }
-        }
-
-        ArrayList<ClassInfo> queue = new ArrayList<ClassInfo>();
-        if (containingClass().realSuperclass() != null &&
-                containingClass().realSuperclass().isAbstract()) {
-            queue.add(containingClass());
-        }
-        addInterfaces(containingClass().realInterfaces(), queue);
-        for (ClassInfo iface: queue) {
-            for (MethodInfo me: iface.methods()) {
-                if (me.name().equals(this.name())
-                        && me.signature().equals(this.signature())
-                        && notStrippable.contains(me.containingClass())) {
-                    return me;
-                }
-            }
-        }
-        return null;
-    }
-
-    public ClassInfo findRealOverriddenClass(String name, String signature) {
-        if (mReturnType == null) {
-        // ctor
-        return null;
-        }
-        if (mOverriddenMethod != null) {
-            return mOverriddenMethod.mRealContainingClass;
-        }
-
-        ArrayList<ClassInfo> queue = new ArrayList<ClassInfo>();
-        if (containingClass().realSuperclass() != null &&
-            containingClass().realSuperclass().isAbstract()) {
-            queue.add(containingClass());
-        }
-        addInterfaces(containingClass().realInterfaces(), queue);
-        for (ClassInfo iface: queue) {
-            for (MethodInfo me: iface.methods()) {
-                if (me.name().equals(name)
-                    && me.signature().equals(signature)
-                    && me.inlineTags().tags() != null
-                    && me.inlineTags().tags().length > 0) {
-                return iface;
-                }
-            }
-        }
-        return null;
-    }
-
-    private class FirstSentenceTags implements InheritedTags
-    {
-        public TagInfo[] tags()
-        {
-            return comment().briefTags();
-        }
-        public InheritedTags inherited()
-        {
-            MethodInfo m = findOverriddenMethod(name(), signature());
-            if (m != null) {
-                return m.firstSentenceTags();
-            } else {
-                return null;
-            }
-        }
-    }
-
-    private class ReturnTags implements InheritedTags {
-        public TagInfo[] tags() {
-            return comment().returnTags();
-        }
-        public InheritedTags inherited() {
-            MethodInfo m = findOverriddenMethod(name(), signature());
-            if (m != null) {
-                return m.returnTags();
-            } else {
-                return null;
-            }
-        }
-    }
-
-    public boolean isDeprecated() {
-        boolean deprecated = false;
-        if (!mDeprecatedKnown) {
-            boolean commentDeprecated = (comment().deprecatedTags().length > 0);
-            boolean annotationDeprecated = false;
-            for (AnnotationInstanceInfo annotation : annotations()) {
-                if (annotation.type().qualifiedName().equals("java.lang.Deprecated")) {
-                    annotationDeprecated = true;
-                    break;
-                }
-            }
-
-            if (commentDeprecated != annotationDeprecated) {
-                Errors.error(Errors.DEPRECATION_MISMATCH, position(),
-                        "Method " + mContainingClass.qualifiedName() + "." + name()
-                        + ": @Deprecated annotation and @deprecated doc tag do not match");
-            }
-
-            mIsDeprecated = commentDeprecated | annotationDeprecated;
-            mDeprecatedKnown = true;
-        }
-        return mIsDeprecated;
-    }
-
-    public TypeInfo[] getTypeParameters(){
-        return mTypeParameters;
-    }
-
-    public MethodInfo cloneForClass(ClassInfo newContainingClass) {
-        MethodInfo result =  new MethodInfo(getRawCommentText(), mTypeParameters,
-                name(), signature(), newContainingClass, realContainingClass(),
-                isPublic(), isProtected(), isPackagePrivate(), isPrivate(), isFinal(), isStatic(),
-                isSynthetic(), mIsAbstract, mIsSynchronized, mIsNative, mIsAnnotationElement,
-                kind(), mFlatSignature, mOverriddenMethod,
-                mReturnType, mParameters, mThrownExceptions, position(), annotations());
-        result.init(mDefaultAnnotationElementValue);
-        return result;
-    }
-
-    public MethodInfo(String rawCommentText, TypeInfo[] typeParameters, String name,
-                        String signature, ClassInfo containingClass, ClassInfo realContainingClass,
-                        boolean isPublic, boolean isProtected,
-                        boolean isPackagePrivate, boolean isPrivate,
-                        boolean isFinal, boolean isStatic, boolean isSynthetic,
-                        boolean isAbstract, boolean isSynchronized, boolean isNative,
-                        boolean isAnnotationElement, String kind,
-                        String flatSignature, MethodInfo overriddenMethod,
-                        TypeInfo returnType, ParameterInfo[] parameters,
-                        ClassInfo[] thrownExceptions, SourcePositionInfo position,
-                        AnnotationInstanceInfo[] annotations)
-    {
-        // Explicitly coerce 'final' state of Java6-compiled enum values() method, to match
-        // the Java5-emitted base API description.
-        super(rawCommentText, name, signature, containingClass, realContainingClass,
-                isPublic, isProtected, isPackagePrivate, isPrivate,
-                ((name.equals("values") && containingClass.isEnum()) ? true : isFinal),
-                isStatic, isSynthetic, kind, position, annotations);
-
-        // The underlying MethodDoc for an interface's declared methods winds up being marked
-        // non-abstract.  Correct that here by looking at the immediate-parent class, and marking
-        // this method abstract if it is an unimplemented interface method.
-        if (containingClass.isInterface()) {
-            isAbstract = true;
-        }
-
-        mReasonOpened = "0:0";
-        mIsAnnotationElement = isAnnotationElement;
-        mTypeParameters = typeParameters;
-        mIsAbstract = isAbstract;
-        mIsSynchronized = isSynchronized;
-        mIsNative = isNative;
-        mFlatSignature = flatSignature;
-        mOverriddenMethod = overriddenMethod;
-        mReturnType = returnType;
-        mParameters = parameters;
-        mThrownExceptions = thrownExceptions;
-    }
-
-    public void init(AnnotationValueInfo defaultAnnotationElementValue)
-    {
-        mDefaultAnnotationElementValue = defaultAnnotationElementValue;
-    }
-
-    public boolean isAbstract()
-    {
-        return mIsAbstract;
-    }
-
-    public boolean isSynchronized()
-    {
-        return mIsSynchronized;
-    }
-
-    public boolean isNative()
-    {
-        return mIsNative;
-    }
-
-    public String flatSignature()
-    {
-        return mFlatSignature;
-    }
-
-    public InheritedTags inlineTags()
-    {
-        return new InlineTags();
-    }
-
-    public InheritedTags firstSentenceTags()
-    {
-        return new FirstSentenceTags();
-    }
-
-    public InheritedTags returnTags() {
-        return new ReturnTags();
-    }
-
-    public TypeInfo returnType()
-    {
-        return mReturnType;
-    }
-
-    public String prettySignature()
-    {
-        String s = "(";
-        int N = mParameters.length;
-        for (int i=0; i<N; i++) {
-            ParameterInfo p = mParameters[i];
-            TypeInfo t = p.type();
-            if (t.isPrimitive()) {
-                s += t.simpleTypeName();
-            } else {
-                s += t.asClassInfo().name();
-            }
-            if (i != N-1) {
-                s += ',';
-            }
-        }
-        s += ')';
-        return s;
-    }
-
-    /**
-     * Returns a name consistent with the {@link
-     * com.android.apicheck.MethodInfo#getHashableName()}.
-     */
-    public String getHashableName() {
-        StringBuilder result = new StringBuilder();
-        result.append(name());
-        for (int p = 0; p < mParameters.length; p++) {
-            result.append(":");
-            if (p == mParameters.length - 1 && isVarArgs()) {
-                // TODO: note that this does not attempt to handle hypothetical
-                // vararg methods whose last parameter is a list of arrays, e.g.
-                // "Object[]...".
-                result.append(mParameters[p].type().fullNameNoDimension(typeVariables()))
-                        .append("...");
-            } else {
-                result.append(mParameters[p].type().fullName(typeVariables()));
-            }
-        }
-        return result.toString();
-    }
-
-    private boolean inList(ClassInfo item, ThrowsTagInfo[] list)
-    {
-        int len = list.length;
-        String qn = item.qualifiedName();
-        for (int i=0; i<len; i++) {
-            ClassInfo ex = list[i].exception();
-            if (ex != null && ex.qualifiedName().equals(qn)) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    public ThrowsTagInfo[] throwsTags()
-    {
-        if (mThrowsTags == null) {
-            ThrowsTagInfo[] documented = comment().throwsTags();
-            ArrayList<ThrowsTagInfo> rv = new ArrayList<ThrowsTagInfo>();
-
-            int len = documented.length;
-            for (int i=0; i<len; i++) {
-                rv.add(documented[i]);
-            }
-
-            ClassInfo[] all = mThrownExceptions;
-            len = all.length;
-            for (int i=0; i<len; i++) {
-                ClassInfo cl = all[i];
-                if (documented == null || !inList(cl, documented)) {
-                    rv.add(new ThrowsTagInfo("@throws", "@throws",
-                                        cl.qualifiedName(), cl, "",
-                                        containingClass(), position()));
-                }
-            }
-            mThrowsTags = rv.toArray(new ThrowsTagInfo[rv.size()]);
-        }
-        return mThrowsTags;
-    }
-
-    private static int indexOfParam(String name, String[] list)
-    {
-        final int N = list.length;
-        for (int i=0; i<N; i++) {
-            if (name.equals(list[i])) {
-                return i;
-            }
-        }
-        return -1;
-    }
-
-    public ParamTagInfo[] paramTags()
-    {
-        if (mParamTags == null) {
-            final int N = mParameters.length;
-
-            String[] names = new String[N];
-            String[] comments = new String[N];
-            SourcePositionInfo[] positions = new SourcePositionInfo[N];
-
-            // get the right names so we can handle our names being different from
-            // our parent's names.
-            for (int i=0; i<N; i++) {
-                names[i] = mParameters[i].name();
-                comments[i] = "";
-                positions[i] = mParameters[i].position();
-            }
-
-            // gather our comments, and complain about misnamed @param tags
-            for (ParamTagInfo tag: comment().paramTags()) {
-                int index = indexOfParam(tag.parameterName(), names);
-                if (index >= 0) {
-                    comments[index] = tag.parameterComment();
-                    positions[index] = tag.position();
-                } else {
-                    Errors.error(Errors.UNKNOWN_PARAM_TAG_NAME, tag.position(),
-                            "@param tag with name that doesn't match the parameter list: '"
-                            + tag.parameterName() + "'");
-                }
-            }
-
-            // get our parent's tags to fill in the blanks
-            MethodInfo overridden = this.findOverriddenMethod(name(), signature());
-            if (overridden != null) {
-                ParamTagInfo[] maternal = overridden.paramTags();
-                for (int i=0; i<N; i++) {
-                    if (comments[i].equals("")) {
-                        comments[i] = maternal[i].parameterComment();
-                        positions[i] = maternal[i].position();
-                    }
-                }
-            }
-
-            // construct the results, and cache them for next time
-            mParamTags = new ParamTagInfo[N];
-            for (int i=0; i<N; i++) {
-                mParamTags[i] = new ParamTagInfo("@param", "@param", names[i] + " " + comments[i],
-                        parent(), positions[i]);
-
-                // while we're here, if we find any parameters that are still undocumented at this
-                // point, complain. (this warning is off by default, because it's really, really
-                // common; but, it's good to be able to enforce it)
-                if (comments[i].equals("")) {
-                    Errors.error(Errors.UNDOCUMENTED_PARAMETER, positions[i],
-                            "Undocumented parameter '" + names[i] + "' on method '"
-                            + name() + "'");
-                }
-            }
-        }
-        return mParamTags;
-    }
-
-    public SeeTagInfo[] seeTags()
-    {
-        SeeTagInfo[] result = comment().seeTags();
-        if (result == null) {
-            if (mOverriddenMethod != null) {
-                result = mOverriddenMethod.seeTags();
-            }
-        }
-        return result;
-    }
-
-    public TagInfo[] deprecatedTags()
-    {
-        TagInfo[] result = comment().deprecatedTags();
-        if (result.length == 0) {
-            if (comment().undeprecateTags().length == 0) {
-                if (mOverriddenMethod != null) {
-                    result = mOverriddenMethod.deprecatedTags();
-                }
-            }
-        }
-        return result;
-    }
-
-    public ParameterInfo[] parameters()
-    {
-        return mParameters;
-    }
-
-
-    public boolean matchesParams(String[] params, String[] dimensions)
-    {
-        if (mParamStrings == null) {
-            ParameterInfo[] mine = mParameters;
-            int len = mine.length;
-            if (len != params.length) {
-                return false;
-            }
-            for (int i=0; i<len; i++) {
-                TypeInfo t = mine[i].type();
-                if (!t.dimension().equals(dimensions[i])) {
-                    return false;
-                }
-                String qn = t.qualifiedTypeName();
-                String s = params[i];
-                int slen = s.length();
-                int qnlen = qn.length();
-                if (!(qn.equals(s) ||
-                        ((slen+1)<qnlen && qn.charAt(qnlen-slen-1)=='.'
-                         && qn.endsWith(s)))) {
-                    return false;
-                }
-            }
-        }
-        return true;
-    }
-
-    public void makeHDF(HDF data, String base)
-    {
-        data.setValue(base + ".kind", kind());
-        data.setValue(base + ".name", name());
-        data.setValue(base + ".href", htmlPage());
-        data.setValue(base + ".anchor", anchor());
-
-        if (mReturnType != null) {
-            returnType().makeHDF(data, base + ".returnType", false, typeVariables());
-            data.setValue(base + ".abstract", mIsAbstract ? "abstract" : "");
-        }
-
-        data.setValue(base + ".synchronized", mIsSynchronized ? "synchronized" : "");
-        data.setValue(base + ".final", isFinal() ? "final" : "");
-        data.setValue(base + ".static", isStatic() ? "static" : "");
-
-        TagInfo.makeHDF(data, base + ".shortDescr", firstSentenceTags());
-        TagInfo.makeHDF(data, base + ".descr", inlineTags());
-        TagInfo.makeHDF(data, base + ".deprecated", deprecatedTags());
-        TagInfo.makeHDF(data, base + ".seeAlso", seeTags());
-        data.setValue(base + ".since", getSince());
-        ParamTagInfo.makeHDF(data, base + ".paramTags", paramTags());
-        AttrTagInfo.makeReferenceHDF(data, base + ".attrRefs", comment().attrTags());
-        ThrowsTagInfo.makeHDF(data, base + ".throws", throwsTags());
-        ParameterInfo.makeHDF(data, base + ".params", parameters(), isVarArgs(), typeVariables());
-        if (isProtected()) {
-            data.setValue(base + ".scope", "protected");
-        }
-        else if (isPublic()) {
-            data.setValue(base + ".scope", "public");
-        }
-        TagInfo.makeHDF(data, base + ".returns", returnTags());
-
-        if (mTypeParameters != null) {
-            TypeInfo.makeHDF(data, base + ".generic.typeArguments", mTypeParameters, false);
-        }
-    }
-
-    public HashSet<String> typeVariables()
-    {
-        HashSet<String> result = TypeInfo.typeVariables(mTypeParameters);
-        ClassInfo cl = containingClass();
-        while (cl != null) {
-            TypeInfo[] types = cl.asTypeInfo().typeArguments();
-            if (types != null) {
-                TypeInfo.typeVariables(types, result);
-            }
-            cl = cl.containingClass();
-        }
-        return result;
-    }
-
-    @Override
-    public boolean isExecutable()
-    {
-        return true;
-    }
-
-    public ClassInfo[] thrownExceptions()
-    {
-        return mThrownExceptions;
-    }
-
-    public String typeArgumentsName(HashSet<String> typeVars)
-    {
-        if (mTypeParameters == null || mTypeParameters.length == 0) {
-            return "";
-        } else {
-            return TypeInfo.typeArgumentsName(mTypeParameters, typeVars);
-        }
-    }
-
-    public boolean isAnnotationElement()
-    {
-        return mIsAnnotationElement;
-    }
-
-    public AnnotationValueInfo defaultAnnotationElementValue()
-    {
-        return mDefaultAnnotationElementValue;
-    }
-
-    public void setVarargs(boolean set){
-        mIsVarargs = set;
-    }
-    public boolean isVarArgs(){
-      return mIsVarargs;
-    }
-
-    @Override
-    public String toString(){
-      return this.name();
-    }
-
-    public void setReason(String reason) {
-        mReasonOpened = reason;
-    }
-
-    public String getReason() {
-        return mReasonOpened;
-    }
-
-    private String mFlatSignature;
-    private MethodInfo mOverriddenMethod;
-    private TypeInfo mReturnType;
-    private boolean mIsAnnotationElement;
-    private boolean mIsAbstract;
-    private boolean mIsSynchronized;
-    private boolean mIsNative;
-    private boolean mIsVarargs;
-    private boolean mDeprecatedKnown;
-    private boolean mIsDeprecated;
-    private ParameterInfo[] mParameters;
-    private ClassInfo[] mThrownExceptions;
-    private String[] mParamStrings;
-    ThrowsTagInfo[] mThrowsTags;
-    private ParamTagInfo[] mParamTags;
-    private TypeInfo[] mTypeParameters;
-    private AnnotationValueInfo mDefaultAnnotationElementValue;
-    private String mReasonOpened;
-}
-
diff --git a/tools/droiddoc/src/NavTree.java b/tools/droiddoc/src/NavTree.java
deleted file mode 100644
index 0469fdc..0000000
--- a/tools/droiddoc/src/NavTree.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-import org.clearsilver.HDF;
-
-import java.util.ArrayList;
-
-public class NavTree {
-
-    public static void writeNavTree(String dir) {
-        ArrayList<Node> children = new ArrayList();
-        for (PackageInfo pkg: DroidDoc.choosePackages()) {
-            children.add(makePackageNode(pkg));
-        }
-        Node node = new Node("Reference", dir + "packages.html", children, null);
-
-        StringBuilder buf = new StringBuilder();
-        if (false) {
-            // if you want a root node
-            buf.append("[");
-            node.render(buf);
-            buf.append("]");
-        } else {
-            // if you don't want a root node
-            node.renderChildren(buf);
-        }
-
-        HDF data = DroidDoc.makeHDF();
-        data.setValue("reference_tree", buf.toString());
-        ClearPage.write(data, "navtree_data.cs", "navtree_data.js");
-    }
-
-    private static Node makePackageNode(PackageInfo pkg) {
-        ArrayList<Node> children = new ArrayList();
-
-        children.add(new Node("Description", pkg.fullDescriptionHtmlPage(), null, null));
-
-        addClassNodes(children, "Interfaces", pkg.interfaces());
-        addClassNodes(children, "Classes", pkg.ordinaryClasses());
-        addClassNodes(children, "Enums", pkg.enums());
-        addClassNodes(children, "Exceptions", pkg.exceptions());
-        addClassNodes(children, "Errors", pkg.errors());
-
-        return new Node(pkg.name(), pkg.htmlPage(), children, pkg.getSince());
-    }
-
-    private static void addClassNodes(ArrayList<Node> parent, String label, ClassInfo[] classes) {
-        ArrayList<Node> children = new ArrayList();
-
-        for (ClassInfo cl: classes) {
-            if (cl.checkLevel()) {
-                children.add(new Node(cl.name(), cl.htmlPage(), null, cl.getSince()));
-            }
-        }
-
-        if (children.size() > 0) {
-            parent.add(new Node(label, null, children, null));
-        }
-    }
-
-    private static class Node {
-        private String mLabel;
-        private String mLink;
-        ArrayList<Node> mChildren;
-        private String mSince;
-
-        Node(String label, String link, ArrayList<Node> children, String since) {
-            mLabel = label;
-            mLink = link;
-            mChildren = children;
-            mSince = since;
-        }
-
-        static void renderString(StringBuilder buf, String s) {
-            if (s == null) {
-                buf.append("null");
-            } else {
-                buf.append('"');
-                final int N = s.length();
-                for (int i=0; i<N; i++) {
-                    char c = s.charAt(i);
-                    if (c >= ' ' && c <= '~' && c != '"' && c != '\\') {
-                        buf.append(c);
-                    } else {
-                        buf.append("\\u");
-                        for (int j=0; i<4; i++) {
-                            char x = (char)(c & 0x000f);
-                            if (x > 10) {
-                                x = (char)(x - 10 + 'a');
-                            } else {
-                                x = (char)(x + '0');
-                            }
-                            buf.append(x);
-                            c >>= 4;
-                        }
-                    }
-                }
-                buf.append('"');
-            }
-        }
-
-        void renderChildren(StringBuilder buf) {
-            ArrayList<Node> list = mChildren;
-            if (list == null || list.size() == 0) {
-                // We output null for no children.  That way empty lists here can just
-                // be a byproduct of how we generate the lists.
-                buf.append("null");
-            } else {
-                buf.append("[ ");
-                final int N = list.size();
-                for (int i=0; i<N; i++) {
-                    list.get(i).render(buf);
-                    if (i != N-1) {
-                        buf.append(", ");
-                    }
-                }
-                buf.append(" ]\n");
-            }
-        }
-
-        void render(StringBuilder buf) {
-            buf.append("[ ");
-            renderString(buf, mLabel);
-            buf.append(", ");
-            renderString(buf, mLink);
-            buf.append(", ");
-            renderChildren(buf);
-            buf.append(", ");
-            renderString(buf, mSince);
-            buf.append(" ]");
-        }
-    }
-}
diff --git a/tools/droiddoc/src/PackageInfo.java b/tools/droiddoc/src/PackageInfo.java
deleted file mode 100644
index 17ad1b7..0000000
--- a/tools/droiddoc/src/PackageInfo.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-import com.sun.javadoc.*;
-import com.sun.tools.doclets.*;
-import org.clearsilver.HDF;
-import org.clearsilver.CS;
-import java.util.*;
-import java.io.*;
-
-public class PackageInfo extends DocInfo implements ContainerInfo
-{
-    public static final Comparator<PackageInfo> comparator = new Comparator<PackageInfo>() {
-        public int compare(PackageInfo a, PackageInfo b) {
-            return a.name().compareTo(b.name());
-        }
-    };
-
-    public PackageInfo(PackageDoc pkg, String name, SourcePositionInfo position)
-    {
-        super(pkg.getRawCommentText(), position);
-        mName = name;
-
-        if (pkg == null) {
-            throw new RuntimeException("pkg is null");
-        }
-        mPackage = pkg;
-    }
-
-    public String htmlPage()
-    {
-        String s = mName;
-        s = s.replace('.', '/');
-        s += "/package-summary.html";
-        s = DroidDoc.javadocDir + s;
-        return s;
-    }
-
-    public String fullDescriptionHtmlPage() {
-        String s = mName;
-        s = s.replace('.', '/');
-        s += "/package-descr.html";
-        s = DroidDoc.javadocDir + s;
-        return s;
-    }
-
-    @Override
-    public ContainerInfo parent()
-    {
-        return null;
-    }
-
-    @Override
-    public boolean isHidden()
-    {
-        return comment().isHidden();
-    }
-
-    public boolean checkLevel() {
-        // TODO should return false if all classes are hidden but the package isn't.
-        // We don't have this so I'm not doing it now.
-        return !isHidden();
-    }
-
-    public String name()
-    {
-        return mName;
-    }
-
-    public String qualifiedName()
-    {
-        return mName;
-    }
-
-    public TagInfo[] inlineTags()
-    {
-        return comment().tags();
-    }
-
-    public TagInfo[] firstSentenceTags()
-    {
-        return comment().briefTags();
-    }
-
-    public static ClassInfo[] filterHidden(ClassInfo[] classes)
-    {
-        ArrayList<ClassInfo> out = new ArrayList<ClassInfo>();
-
-        for (ClassInfo cl: classes) {
-            if (!cl.isHidden()) {
-                out.add(cl);
-            }
-        }
-
-        return out.toArray(new ClassInfo[0]);
-    }
-
-    public void makeLink(HDF data, String base)
-    {
-        if (checkLevel()) {
-            data.setValue(base + ".link", htmlPage());
-        }
-        data.setValue(base + ".name", name());
-        data.setValue(base + ".since", getSince());
-    }
-
-    public void makeClassLinkListHDF(HDF data, String base)
-    {
-        makeLink(data, base);
-        ClassInfo.makeLinkListHDF(data, base + ".interfaces", interfaces());
-        ClassInfo.makeLinkListHDF(data, base + ".classes", ordinaryClasses());
-        ClassInfo.makeLinkListHDF(data, base + ".enums", enums());
-        ClassInfo.makeLinkListHDF(data, base + ".exceptions", exceptions());
-        ClassInfo.makeLinkListHDF(data, base + ".errors", errors());
-        data.setValue(base + ".since", getSince());
-    }
-
-    public ClassInfo[] interfaces()
-    {
-        if (mInterfaces == null) {
-            mInterfaces = ClassInfo.sortByName(filterHidden(Converter.convertClasses(
-                            mPackage.interfaces())));
-        }
-        return mInterfaces;
-    }
-
-    public ClassInfo[] ordinaryClasses()
-    {
-        if (mOrdinaryClasses == null) {
-            mOrdinaryClasses = ClassInfo.sortByName(filterHidden(Converter.convertClasses(
-                            mPackage.ordinaryClasses())));
-        }
-        return mOrdinaryClasses;
-    }
-
-    public ClassInfo[] enums()
-    {
-        if (mEnums == null) {
-            mEnums = ClassInfo.sortByName(filterHidden(Converter.convertClasses(mPackage.enums())));
-        }
-        return mEnums;
-    }
-
-    public ClassInfo[] exceptions()
-    {
-        if (mExceptions == null) {
-            mExceptions = ClassInfo.sortByName(filterHidden(Converter.convertClasses(
-                        mPackage.exceptions())));
-        }
-        return mExceptions;
-    }
-
-    public ClassInfo[] errors()
-    {
-        if (mErrors == null) {
-            mErrors = ClassInfo.sortByName(filterHidden(Converter.convertClasses(
-                        mPackage.errors())));
-        }
-        return mErrors;
-    }
-
-    // in hashed containers, treat the name as the key
-    @Override
-    public int hashCode() {
-        return mName.hashCode();
-    }
-
-    private String mName;
-    private PackageDoc mPackage;
-    private ClassInfo[] mInterfaces;
-    private ClassInfo[] mOrdinaryClasses;
-    private ClassInfo[] mEnums;
-    private ClassInfo[] mExceptions;
-    private ClassInfo[] mErrors;
-}
-
diff --git a/tools/droiddoc/src/ParamTagInfo.java b/tools/droiddoc/src/ParamTagInfo.java
deleted file mode 100644
index d6f2b6b..0000000
--- a/tools/droiddoc/src/ParamTagInfo.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-import java.util.regex.Pattern;
-import java.util.regex.Matcher;
-import org.clearsilver.HDF;
-import org.clearsilver.CS;
-
-public class ParamTagInfo extends ParsedTagInfo
-{
-    static final Pattern PATTERN = Pattern.compile(
-                                "([^ \t\r\n]+)[ \t\r\n]+(.*)",
-                                Pattern.DOTALL);
-
-    private boolean mIsTypeParameter;
-    private String mParameterComment;
-    private String mParameterName;
-
-    ParamTagInfo(String name, String kind, String text, ContainerInfo base,
-            SourcePositionInfo sp)
-    {
-        super(name, kind, text, base, sp);
-
-        Matcher m = PATTERN.matcher(text);
-        if (m.matches()) {
-            mParameterName = m.group(1);
-            mParameterComment = m.group(2);
-            int len = mParameterName.length();
-            mIsTypeParameter = len > 2
-                                && mParameterName.charAt(0) == '<'
-                                && mParameterName.charAt(len-1) == '>';
-        } else {
-            mParameterName = text.trim();
-            mParameterComment = "";
-            mIsTypeParameter = false;
-        }
-        setCommentText(mParameterComment);
-    }
-
-    ParamTagInfo(String name, String kind, String text,
-                            boolean isTypeParameter, String parameterComment,
-                            String parameterName, ContainerInfo base,
-                            SourcePositionInfo sp)
-    {
-        super(name, kind, text, base, sp);
-        mIsTypeParameter = isTypeParameter;
-        mParameterComment = parameterComment;
-        mParameterName = parameterName;
-    }
-
-    public boolean isTypeParameter()
-    {
-        return mIsTypeParameter;
-    }
-
-    public String parameterComment()
-    {
-        return mParameterComment;
-    }
-
-    public String parameterName()
-    {
-        return mParameterName;
-    }
-
-    @Override
-    public void makeHDF(HDF data, String base)
-    {
-        data.setValue(base + ".name", parameterName());
-        data.setValue(base + ".isTypeParameter", isTypeParameter() ? "1" : "0");
-        TagInfo.makeHDF(data, base + ".comment", commentTags());
-    }
-
-    public static void makeHDF(HDF data, String base, ParamTagInfo[] tags)
-    {
-        for (int i=0; i<tags.length; i++) {
-            // don't output if the comment is ""
-            if (!"".equals(tags[i].parameterComment())) {
-                tags[i].makeHDF(data, base + "." + i);
-            }
-        }
-    }
-}
diff --git a/tools/droiddoc/src/ParameterInfo.java b/tools/droiddoc/src/ParameterInfo.java
deleted file mode 100644
index 44608be..0000000
--- a/tools/droiddoc/src/ParameterInfo.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-import org.clearsilver.HDF;
-import org.clearsilver.CS;
-import java.util.HashSet;
-
-public class ParameterInfo
-{
-    ParameterInfo(String name, String typeName, TypeInfo type, SourcePositionInfo position)
-    {
-        mName = name;
-        mTypeName = typeName;
-        mType = type;
-        mPosition = position;
-    }
-
-    TypeInfo type()
-    {
-        return mType;
-    }
-
-    String name()
-    {
-        return mName;
-    }
-
-    String typeName()
-    {
-        return mTypeName;
-    }
-
-    SourcePositionInfo position()
-    {
-        return mPosition;
-    }
-
-    public void makeHDF(HDF data, String base, boolean isLastVararg,
-            HashSet<String> typeVariables)
-    {
-        data.setValue(base + ".name", this.name());
-        type().makeHDF(data, base + ".type", isLastVararg, typeVariables);
-    }
-
-    public static void makeHDF(HDF data, String base, ParameterInfo[] params,
-            boolean isVararg, HashSet<String> typeVariables)
-    {
-        for (int i=0; i<params.length; i++) {
-            params[i].makeHDF(data, base + "." + i,
-                    isVararg && (i == params.length - 1), typeVariables);
-        }
-    }
-    
-    String mName;
-    String mTypeName;
-    TypeInfo mType;
-    SourcePositionInfo mPosition;
-}
-
diff --git a/tools/droiddoc/src/ParsedTagInfo.java b/tools/droiddoc/src/ParsedTagInfo.java
deleted file mode 100755
index c2e4806..0000000
--- a/tools/droiddoc/src/ParsedTagInfo.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-import org.clearsilver.HDF;
-import org.clearsilver.CS;
-import java.util.ArrayList;
-
-public class ParsedTagInfo extends TagInfo
-{
-    private ContainerInfo mContainer;
-    private String mCommentText;
-    private Comment mComment;
-
-    ParsedTagInfo(String name, String kind, String text, ContainerInfo base, SourcePositionInfo sp)
-    {
-        super(name, kind, text, SourcePositionInfo.findBeginning(sp, text));
-        mContainer = base;
-        mCommentText = text;
-    }
-
-    public TagInfo[] commentTags()
-    {
-        if (mComment == null) {
-            mComment = new Comment(mCommentText, mContainer, position());
-        }
-        return mComment.tags();
-    }
-
-    protected void setCommentText(String comment)
-    {
-        mCommentText = comment;
-    }
-
-    public static <T extends ParsedTagInfo> TagInfo[]
-    joinTags(T[] tags)
-    {
-        ArrayList<TagInfo> list = new ArrayList<TagInfo>();
-        final int N = tags.length;
-        for (int i=0; i<N; i++) {
-            TagInfo[] t = tags[i].commentTags();
-            final int M = t.length;
-            for (int j=0; j<M; j++) {
-                list.add(t[j]);
-            }
-        }
-        return list.toArray(new TagInfo[list.size()]);
-    }
-}
diff --git a/tools/droiddoc/src/Proofread.java b/tools/droiddoc/src/Proofread.java
deleted file mode 100644
index ec9f523..0000000
--- a/tools/droiddoc/src/Proofread.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-import java.io.IOException;
-import java.io.FileWriter;
-import java.util.regex.Pattern;
-import java.util.regex.Matcher;
-
-public class Proofread
-{
-    static FileWriter out = null;
-    static final Pattern WHITESPACE = Pattern.compile("\\r?\\n");
-    static final String INDENT = "        ";
-    static final String NEWLINE = "\n" + INDENT;
-
-    public static void initProofread(String filename)
-    {
-        try {
-            out = new FileWriter(filename);
-            out.write("javadoc proofread file: " + filename + "\n");
-        }
-        catch (IOException e) {
-            if (out != null) {
-                try {
-                    out.close();
-                }
-                catch (IOException ex) {
-                }
-                out = null;
-            }
-            System.err.println("error opening file: " + filename);
-        }
-    }
-
-    public static void finishProofread(String filename)
-    {
-        if (out == null) {
-            return;
-        }
-
-        try {
-            out.close();
-        }
-        catch (IOException e) {
-        }
-    }
-
-    public static void write(String s)
-    {
-        if (out == null) {
-            return ;
-        }
-        try {
-            out.write(s);
-        }
-        catch (IOException e) {
-        }
-    }
-
-    public static void writeIndented(String s)
-    {
-        s = s.trim();
-        Matcher m = WHITESPACE.matcher(s);
-        s = m.replaceAll(NEWLINE);
-        write(INDENT);
-        write(s);
-        write("\n");
-    }
-
-    public static void writeFileHeader(String filename)
-    {
-        write("\n\n=== ");
-        write(filename);
-        write(" ===\n");
-    }
-
-    public static void writeTagList(TagInfo[] tags)
-    {
-        if (out == null) {
-            return;
-        }
-
-        for (TagInfo t: tags) {
-            String k = t.kind();
-            if ("Text".equals(t.name())) {
-                writeIndented(t.text());
-            }
-            else if ("@more".equals(k)) {
-                writeIndented("");
-            }
-            else if ("@see".equals(k)) {
-                SeeTagInfo see = (SeeTagInfo)t;
-                String label = see.label();
-                if (label == null) {
-                    label = "";
-                }
-                writeIndented("{" + see.name() + " ... " + label + "}");
-            }
-            else if ("@code".equals(k)) {
-                writeIndented(t.text());
-            }
-            else if ("@samplecode".equals(k)) {
-                writeIndented(t.text());
-            }
-            else {
-                writeIndented("{" + (t.name() != null ? t.name() : "") + "/" +
-                        t.text() + "}");
-            }
-        }
-    }
-
-    public static void writePackages(String filename, TagInfo[] tags)
-    {
-        if (out == null) {
-            return;
-        }
-
-        writeFileHeader(filename);
-        writeTagList(tags);
-    }
-
-    public static void writePackage(String filename, TagInfo[] tags)
-    {
-        if (out == null) {
-            return;
-        }
-
-        writeFileHeader(filename);
-        writeTagList(tags);
-    }
-
-    public static void writeClass(String filename, ClassInfo cl)
-    {
-        if (out == null) {
-            return;
-        }
-
-        writeFileHeader(filename);
-        writeTagList(cl.inlineTags());
-
-        // enum constants
-        for (FieldInfo f: cl.enumConstants()) {
-            write("ENUM: " + f.name() + "\n");
-            writeTagList(f.inlineTags());
-        }
-
-        // fields
-        for (FieldInfo f: cl.selfFields()) {
-            write("FIELD: " + f.name() + "\n");
-            writeTagList(f.inlineTags());
-        }
-
-        // constructors
-        for (MethodInfo m: cl.constructors()) {
-            write("CONSTRUCTOR: " + m.name() + "\n");
-            writeTagList(m.inlineTags().tags());
-        }
-
-        // methods
-        for (MethodInfo m: cl.selfMethods()) {
-            write("METHOD: " + m.name() + "\n");
-            writeTagList(m.inlineTags().tags());
-        }
-    }
-}
diff --git a/tools/droiddoc/src/SampleCode.java b/tools/droiddoc/src/SampleCode.java
deleted file mode 100644
index bf54445..0000000
--- a/tools/droiddoc/src/SampleCode.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-import org.clearsilver.HDF;
-import org.clearsilver.CS;
-import java.util.*;
-import java.io.*;
-import java.util.regex.Pattern;
-import java.util.regex.Matcher;
-
-
-public class SampleCode {
-    String mSource;
-    String mDest;
-    String mTitle;
-
-    public SampleCode(String source, String dest, String title) {
-        mSource = source;
-        mTitle = title;
-        int len = dest.length();
-        if (len > 1 && dest.charAt(len-1) != '/') {
-            mDest = dest + '/';
-        } else {
-            mDest = dest;
-        }
-    }
-
-    public void write(boolean offlineMode) {
-        File f = new File(mSource);
-        if (!f.isDirectory()) {
-            System.out.println("-samplecode not a directory: " + mSource);
-            return;
-        }
-        if (offlineMode) writeIndexOnly(f, mDest, offlineMode);
-        else writeDirectory(f, mDest);
-    }
-
-    public static String convertExtension(String s, String ext) {
-        return s.substring(0, s.lastIndexOf('.')) + ext;
-    }
-
-    public static String[] IMAGES = { ".png", ".jpg", ".gif" };
-    public static String[] TEMPLATED = { ".java", ".xml" };
-
-    public static boolean inList(String s, String[] list) {
-        for (String t: list) {
-            if (s.endsWith(t)) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    public void writeDirectory(File dir, String relative) {
-        TreeSet<String> dirs = new TreeSet<String>();
-        TreeSet<String> files = new TreeSet<String>();
-
-        String subdir = relative; //.substring(mDest.length());
-
-        for (File f: dir.listFiles()) {
-            String name = f.getName();
-            if (name.startsWith(".") || name.startsWith("_")) {
-                continue;
-            }
-            if (f.isFile()) {
-                String out = relative + name;
-
-                if (inList(out, IMAGES)) {
-                    // copied directly
-                    ClearPage.copyFile(f, out);
-                    writeImagePage(f, convertExtension(out, DroidDoc.htmlExtension), subdir);
-                    files.add(name);
-                }
-                if (inList(out, TEMPLATED)) {
-                    // copied and goes through the template
-                    ClearPage.copyFile(f, out);
-                    writePage(f, convertExtension(out, DroidDoc.htmlExtension), subdir);
-                    files.add(name);
-                }
-                // else ignored
-            }
-            else if (f.isDirectory()) {
-                writeDirectory(f, relative + name + "/");
-                dirs.add(name);
-            }
-        }
-
-        // write the index page
-        int i;
-
-        HDF hdf = writeIndex(dir);
-        hdf.setValue("subdir", subdir);
-        i=0;
-        for (String d: dirs) {
-            hdf.setValue("subdirs." + i + ".name", d);
-            i++;
-        }
-        i=0;
-        for (String f: files) {
-            hdf.setValue("files." + i + ".name", f);
-            hdf.setValue("files." + i + ".href", convertExtension(f, ".html"));
-            i++;
-        }
-        
-        ClearPage.write(hdf, "sampleindex.cs", relative + "/index" + DroidDoc.htmlExtension);
-    }
-
-    public void writeIndexOnly(File dir, String relative, Boolean offline) {
-        HDF hdf = writeIndex(dir);
-        if (!offline) relative = "/" + relative;
-        ClearPage.write(hdf, "sampleindex.cs", relative + "index" +
-                        DroidDoc.htmlExtension);
-    }
-
-    public HDF writeIndex(File dir) {
-        HDF hdf = DroidDoc.makeHDF();
-
-        hdf.setValue("page.title", dir.getName() + " - " + mTitle);
-        hdf.setValue("projectTitle", mTitle);
-
-        String filename = dir.getPath() + "/_index.html";
-        String summary = SampleTagInfo.readFile(new SourcePositionInfo(filename,
-                          -1,-1), filename, "sample code", true, false, true);
-
-        if (summary == null) {
-            summary = "";
-        }
-        hdf.setValue("summary", summary);
-
-        return hdf;
-    }
-
-    public void writePage(File f, String out, String subdir) {
-        String name = f.getName();
-
-        String filename = f.getPath();
-        String data = SampleTagInfo.readFile(new SourcePositionInfo(filename, -1,-1), filename,
-                                                "sample code", true, true, true);
-        data = DroidDoc.escape(data);
-        
-        HDF hdf = DroidDoc.makeHDF();
-
-        hdf.setValue("page.title", name);
-        hdf.setValue("subdir", subdir);
-        hdf.setValue("realFile", name);
-        hdf.setValue("fileContents", data);
-
-        ClearPage.write(hdf, "sample.cs", out);
-    }
-
-    public void writeImagePage(File f, String out, String subdir) {
-        String name = f.getName();
-
-        String data = "<img src=\"" + name + "\" title=\"" + name + "\" />";
-        
-        HDF hdf = DroidDoc.makeHDF();
-
-        hdf.setValue("page.title", name);
-        hdf.setValue("subdir", subdir);
-        hdf.setValue("realFile", name);
-        hdf.setValue("fileContents", data);
-
-        ClearPage.write(hdf, "sample.cs", out);
-    }
-}
diff --git a/tools/droiddoc/src/SampleTagInfo.java b/tools/droiddoc/src/SampleTagInfo.java
deleted file mode 100644
index c7ad1cc..0000000
--- a/tools/droiddoc/src/SampleTagInfo.java
+++ /dev/null
@@ -1,289 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-import org.clearsilver.HDF;
-import org.clearsilver.CS;
-
-import java.io.Reader;
-import java.io.IOException;
-import java.io.FileReader;
-import java.io.LineNumberReader;
-import java.util.regex.Pattern;
-import java.util.regex.Matcher;
-
-/*
- * SampleTagInfo copies text from a given file into the javadoc comment.
- *
- * The @include tag copies the text verbatim from the given file.
- *
- * The @sample tag copies the text from the given file, stripping leading and
- * trailing whitespace, and reducing the indent level of the text to the indent
- * level of the first non-whitespace line.
- *
- * Both tags accept either a filename and an id or just a filename.  If no id
- * is provided, the entire file is copied.  If an id is provided, the lines
- * in the given file between the first two lines containing BEGIN_INCLUDE(id)
- * and END_INCLUDE(id), for the given id, are copied.  The id may be only
- * letters, numbers and underscore (_).
- *
- * Four examples:
- * {@include samples/ApiDemos/src/com/google/app/Notification1.java}
- * {@sample samples/ApiDemos/src/com/google/app/Notification1.java}
- * {@include samples/ApiDemos/src/com/google/app/Notification1.java Bleh}
- * {@sample samples/ApiDemos/src/com/google/app/Notification1.java Bleh}
- *
- */
-public class SampleTagInfo extends TagInfo
-{
-    static final int STATE_BEGIN = 0;
-    static final int STATE_MATCHING = 1;
-
-    static final Pattern TEXT = Pattern.compile(
-                "[\r\n \t]*([^\r\n \t]*)[\r\n \t]*([0-9A-Za-z_]*)[\r\n \t]*",
-                Pattern.DOTALL);
-
-    private static final String BEGIN_INCLUDE = "BEGIN_INCLUDE";
-    private static final String END_INCLUDE = "END_INCLUDE";
-
-    private ContainerInfo mBase;
-    private String mIncluded;
-
-    public static String escapeHtml(String str) {
-        return str.replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;");
-    }
-
-    private static boolean isIncludeLine(String str) {
-        return str.indexOf(BEGIN_INCLUDE)>=0 || str.indexOf(END_INCLUDE)>=0;
-    }
-
-    SampleTagInfo(String name, String kind, String text, ContainerInfo base,
-            SourcePositionInfo position)
-    {
-        super(name, kind, text, position);
-        mBase = base;
-
-        Matcher m = TEXT.matcher(text);
-        if (!m.matches()) {
-            Errors.error(Errors.BAD_INCLUDE_TAG, position, "Bad @include tag: "
-                    + text);
-            return;
-        }
-        String filename = m.group(1);
-        String id = m.group(2);
-        boolean trim = "@sample".equals(name);
-
-        if (id == null || "".equals(id)) {
-            mIncluded = readFile(position, filename, id, trim, true, false);
-        } else {
-            mIncluded = loadInclude(position, filename, id, trim);
-        }
-
-        if (mIncluded == null) {
-            Errors.error(Errors.BAD_INCLUDE_TAG, position, "include tag '" + id
-                    + "' not found in file: " + filename);
-        }
-    }
-
-    static String getTrimString(String line)
-    {
-        int i = 0;
-        int len = line.length();
-        for (; i<len; i++) {
-            char c = line.charAt(i);
-            if (c != ' ' && c != '\t') {
-                break;
-            }
-        }
-        if (i == len) {
-            return null;
-        } else {
-            return line.substring(0, i);
-        }
-    }
-
-    static String loadInclude(SourcePositionInfo pos, String filename,
-                                String id, boolean trim)
-    {
-        Reader input = null;
-        StringBuilder result = new StringBuilder();
-
-        String begin = BEGIN_INCLUDE + "(" + id + ")";
-        String end = END_INCLUDE + "(" + id + ")";
-
-        try {
-            input = new FileReader(filename);
-            LineNumberReader lines = new LineNumberReader(input);
-
-            int state = STATE_BEGIN;
-
-            int trimLength = -1;
-            String trimString = null;
-            int trailing = 0;
-
-            while (true) {
-                String line = lines.readLine();
-                if (line == null) {
-                    return null;
-                }
-                switch (state) {
-                case STATE_BEGIN:
-                    if (line.indexOf(begin) >= 0) {
-                        state = STATE_MATCHING;
-                    }
-                    break;
-                case STATE_MATCHING:
-                    if (line.indexOf(end) >= 0) {
-                        return result.substring(0);
-                    } else {
-                        boolean empty = "".equals(line.trim());
-                        if (trim) {
-                            if (isIncludeLine(line)) {
-                                continue;
-                            }
-                            if (trimLength < 0 && !empty) {
-                                trimString = getTrimString(line);
-                                if (trimString != null) {
-                                    trimLength = trimString.length();
-                                }
-                            }
-                            if (trimLength >= 0 && line.length() > trimLength) {
-                                boolean trimThisLine = true;
-                                for (int i=0; i<trimLength; i++) {
-                                    if (line.charAt(i) != trimString.charAt(i)){
-                                        trimThisLine = false;
-                                        break;
-                                    }
-                                }
-                                if (trimThisLine) {
-                                    line = line.substring(trimLength);
-                                }
-                            }
-                            if (trimLength >= 0) {
-                                if (!empty) {
-                                    for (int i=0; i<trailing; i++) {
-                                        result.append('\n');
-                                    }
-                                    line = escapeHtml(line);
-                                    result.append(line);
-                                    trailing = 1;  // add \n next time, maybe
-                                } else {
-                                    trailing++;
-                                }
-                            }
-                        } else {
-                            result.append(line);
-                            result.append('\n');
-                        }
-                    }
-                    break;
-                }
-            }
-        }
-        catch (IOException e) {
-            Errors.error(Errors.BAD_INCLUDE_TAG, pos, "Error reading file for"
-                    + " include \"" + id + "\" " + filename);
-        }
-        finally {
-            if (input != null) {
-                try {
-                    input.close();
-                }
-                catch (IOException ex) {
-                }
-            }
-        }
-        Errors.error(Errors.BAD_INCLUDE_TAG, pos, "Did not find " + end
-                + " in file " + filename);
-        return null;
-    }
-
-    static String readFile(SourcePositionInfo pos, String filename,
-                                String id, boolean trim, boolean escape,
-                                boolean errorOk)
-    {
-        Reader input = null;
-        StringBuilder result = new StringBuilder();
-        int trailing = 0;
-        boolean started = false;
-        try {
-            input = new FileReader(filename);
-            LineNumberReader lines = new LineNumberReader(input);
-
-            while (true) {
-                String line = lines.readLine();
-                if (line == null) {
-                    break;
-                }
-                if (trim) {
-                    if (isIncludeLine(line)) {
-                        continue;
-                    }
-                    if (!"".equals(line.trim())) {
-                        if (started) {
-                            for (int i=0; i<trailing; i++) {
-                                result.append('\n');
-                            }
-                        }
-                        if (escape) {
-                            line = escapeHtml(line);
-                        }
-                        result.append(line);
-                        trailing = 1;  // add \n next time, maybe
-                        started = true;
-                    } else {
-                        if (started) {
-                            trailing++;
-                        }
-                    }
-                } else {
-                    result.append(line);
-                    result.append('\n');
-                }
-            }
-        }
-        catch (IOException e) {
-            if (errorOk) {
-                return null;
-            } else {
-                Errors.error(Errors.BAD_INCLUDE_TAG, pos, "Error reading file for"
-                        + " include \"" + id + "\" " + filename);
-            }
-        }
-        finally {
-            if (input != null) {
-                try {
-                    input.close();
-                }
-                catch (IOException ex) {
-                }
-            }
-        }
-        return result.substring(0);
-    }
-
-    @Override
-    public void makeHDF(HDF data, String base)
-    {
-        data.setValue(base + ".name", name());
-        data.setValue(base + ".kind", kind());
-        if (mIncluded != null) {
-            data.setValue(base + ".text", mIncluded);
-        } else {
-            data.setValue(base + ".text", "INCLUDE_ERROR");
-        }
-    }
-}
-
diff --git a/tools/droiddoc/src/Scoped.java b/tools/droiddoc/src/Scoped.java
deleted file mode 100644
index cca61ed..0000000
--- a/tools/droiddoc/src/Scoped.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-public interface Scoped {
-    boolean isPublic();
-    boolean isProtected();
-    boolean isPackagePrivate();
-    boolean isPrivate();
-    boolean isHidden();
-}
diff --git a/tools/droiddoc/src/SeeTagInfo.java b/tools/droiddoc/src/SeeTagInfo.java
deleted file mode 100644
index 8420ed3..0000000
--- a/tools/droiddoc/src/SeeTagInfo.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-import java.util.regex.Pattern;
-import java.util.regex.Matcher;
-import org.clearsilver.HDF;
-import org.clearsilver.CS;
-import java.util.ArrayList;
-
-public class SeeTagInfo extends TagInfo
-{
-    private ContainerInfo mBase;
-    LinkReference mLink;
-
-    SeeTagInfo(String name, String kind, String text, ContainerInfo base,
-            SourcePositionInfo position)
-    {
-        super(name, kind, text, position);
-        mBase = base;
-    }
-
-    protected LinkReference linkReference() {
-        if (mLink == null) {
-            mLink = LinkReference.parse(text(), mBase, position(),
-                           (!"@see".equals(name())) && (mBase != null ? mBase.checkLevel() : true));
-        }
-        return mLink;
-    }
-
-    public String label()
-    {
-        return linkReference().label;
-    }
-
-    @Override
-    public void makeHDF(HDF data, String base)
-    {
-        LinkReference linkRef = linkReference();
-        if (linkRef.kind != null) {
-            // if they have a better suggestion about "kind" use that.
-            // do this before super.makeHDF() so it picks it up
-            setKind(linkRef.kind);
-        }
-
-        super.makeHDF(data, base);
-
-        data.setValue(base + ".label", linkRef.label);
-        if (linkRef.href != null) {
-            data.setValue(base + ".href", linkRef.href);
-        }
-    }
-
-    public boolean checkLevel() {
-        return linkReference().checkLevel();
-    }
-
-    public static void makeHDF(HDF data, String base, SeeTagInfo[] tags)
-    {
-        int j=0;
-        for (SeeTagInfo tag: tags) {
-            if (tag.mBase.checkLevel() && tag.checkLevel()) {
-                tag.makeHDF(data, base + "." + j);
-                j++;
-            }
-        }
-    }
-}
diff --git a/tools/droiddoc/src/SinceTagger.java b/tools/droiddoc/src/SinceTagger.java
deleted file mode 100644
index a1bce55..0000000
--- a/tools/droiddoc/src/SinceTagger.java
+++ /dev/null
@@ -1,237 +0,0 @@
-// Copyright 2009 Google Inc. All Rights Reserved.
-
-import com.android.apicheck.ApiCheck;
-import com.android.apicheck.ApiInfo;
-
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Collections;
-
-import org.clearsilver.HDF;
-
-/**
- * Applies version information to the DroidDoc class model from apicheck XML
- * files. Sample usage:
- * <pre>
- *   ClassInfo[] classInfos = ...
- *
- *   SinceTagger sinceTagger = new SinceTagger()
- *   sinceTagger.addVersion("frameworks/base/api/1.xml", "Android 1.0")
- *   sinceTagger.addVersion("frameworks/base/api/2.xml", "Android 1.5")
- *   sinceTagger.tagAll(...);
- * </pre>
- */
-public class SinceTagger {
-
-    private final Map<String, String> xmlToName
-            = new LinkedHashMap<String, String>();
-
-    /**
-     * Specifies the apicheck XML file and the API version it holds. Calls to
-     * this method should be called in order from oldest version to newest.
-     */
-    public void addVersion(String file, String name) {
-        xmlToName.put(file, name);
-    }
-
-    public void tagAll(ClassInfo[] classDocs) {
-        // read through the XML files in order, applying their since information
-        // to the Javadoc models
-        for (Map.Entry<String, String> versionSpec : xmlToName.entrySet()) {
-            String xmlFile = versionSpec.getKey();
-            String versionName = versionSpec.getValue();
-            ApiInfo specApi = new ApiCheck().parseApi(xmlFile);
-
-            applyVersionsFromSpec(versionName, specApi, classDocs);
-        }
-
-        if (!xmlToName.isEmpty()) {
-            warnForMissingVersions(classDocs);
-        }
-    }
-
-    /**
-     * Writes an index of the version names to {@code data}. 
-     */
-    public void writeVersionNames(HDF data) {
-        int index = 1;
-        for (String version : xmlToName.values()) {
-            data.setValue("since." + index + ".name", version);
-            index++;
-        }
-    }
-
-    /**
-     * Applies the version information to {@code classDocs} where not already
-     * present.
-     *
-     * @param versionName the version name
-     * @param specApi the spec for this version. If a symbol is in this spec, it
-     *      was present in the named version
-     * @param classDocs the doc model to update
-     */
-    private void applyVersionsFromSpec(String versionName,
-            ApiInfo specApi, ClassInfo[] classDocs) {
-        for (ClassInfo classDoc : classDocs) {
-            com.android.apicheck.PackageInfo packageSpec
-                    = specApi.getPackages().get(classDoc.containingPackage().name());
-
-            if (packageSpec == null) {
-                continue;
-            }
-
-            com.android.apicheck.ClassInfo classSpec
-                    = packageSpec.allClasses().get(classDoc.name());
-
-            if (classSpec == null) {
-                continue;
-            }
-
-            versionPackage(versionName, classDoc.containingPackage());
-            versionClass(versionName, classDoc);
-            versionConstructors(versionName, classSpec, classDoc);
-            versionFields(versionName, classSpec, classDoc);
-            versionMethods(versionName, classSpec, classDoc);
-        }
-    }
-
-    /**
-     * Applies version information to {@code doc} where not already present.
-     */
-    private void versionPackage(String versionName, PackageInfo doc) {
-        if (doc.getSince() == null) {
-            doc.setSince(versionName);
-        }
-    }
-
-    /**
-     * Applies version information to {@code doc} where not already present.
-     */
-    private void versionClass(String versionName, ClassInfo doc) {
-        if (doc.getSince() == null) {
-            doc.setSince(versionName);
-        }
-    }
-
-    /**
-     * Applies version information from {@code spec} to {@code doc} where not
-     * already present.
-     */
-    private void versionConstructors(String versionName,
-            com.android.apicheck.ClassInfo spec, ClassInfo doc) {
-        for (MethodInfo constructor : doc.constructors()) {
-            if (constructor.getSince() == null
-                    && spec.allConstructors().containsKey(constructor.getHashableName())) {
-                constructor.setSince(versionName);
-            }
-        }
-    }
-
-    /**
-     * Applies version information from {@code spec} to {@code doc} where not
-     * already present.
-     */
-    private void versionFields(String versionName,
-            com.android.apicheck.ClassInfo spec, ClassInfo doc) {
-        for (FieldInfo field : doc.fields()) {
-            if (field.getSince() == null
-                    && spec.allFields().containsKey(field.name())) {
-                field.setSince(versionName);
-            }
-        }
-    }
-
-    /**
-     * Applies version information from {@code spec} to {@code doc} where not
-     * already present.
-     */
-    private void versionMethods(String versionName,
-            com.android.apicheck.ClassInfo spec, ClassInfo doc) {
-        for (MethodInfo method : doc.methods()) {
-            if (method.getSince() != null) {
-                continue;
-            }
-
-            for (com.android.apicheck.ClassInfo superclass : spec.hierarchy()) {
-                if (superclass.allMethods().containsKey(method.getHashableName())) {
-                    method.setSince(versionName);
-                    break;
-                }
-            }
-        }
-    }
-
-    /**
-     * Warns if any symbols are missing version information. When configured
-     * properly, this will yield zero warnings because {@code apicheck}
-     * guarantees that all symbols are present in the most recent API.
-     */
-    private void warnForMissingVersions(ClassInfo[] classDocs) {
-        for (ClassInfo claz : classDocs) {
-            if (!checkLevelRecursive(claz)) {
-                continue;
-            }
-
-            if (claz.getSince() == null) {
-                Errors.error(Errors.NO_SINCE_DATA, claz.position(),
-                        "XML missing class " + claz.qualifiedName());
-            }
-            
-            for (FieldInfo field : missingVersions(claz.fields())) {
-                Errors.error(Errors.NO_SINCE_DATA, field.position(),
-                        "XML missing field " + claz.qualifiedName()
-                                + "#" + field.name());
-            }
-
-            for (MethodInfo constructor : missingVersions(claz.constructors())) {
-                Errors.error(Errors.NO_SINCE_DATA, constructor.position(),
-                        "XML missing constructor " + claz.qualifiedName()
-                                + "#" + constructor.getHashableName());
-            }
-
-            for (MethodInfo method : missingVersions(claz.methods())) {
-                Errors.error(Errors.NO_SINCE_DATA, method.position(),
-                        "XML missing method " + claz.qualifiedName()
-                                + "#" + method.getHashableName());
-            }
-        }
-    }
-
-    /**
-     * Returns the DocInfos in {@code all} that are documented but do not have
-     * since tags.
-     */
-    private <T extends MemberInfo> Iterable<T> missingVersions(T[] all) {
-        List<T> result = Collections.emptyList();
-        for (T t : all) {
-            // if this member has version info or isn't documented, skip it
-            if (t.getSince() != null
-                    || t.isHidden()
-                    || !checkLevelRecursive(t.realContainingClass())) {
-                continue;
-            }
-
-            if (result.isEmpty()) {
-                result = new ArrayList<T>(); // lazily construct a mutable list
-            }
-            result.add(t);
-        }
-        return result;
-    }
-
-    /**
-     * Returns true if {@code claz} and all containing classes are documented.
-     * The result may be used to filter out members that exist in the API
-     * data structure but aren't a part of the API.
-     */
-    private boolean checkLevelRecursive(ClassInfo claz) {
-        for (ClassInfo c = claz; c != null; c = c.containingClass()) {
-            if (!c.checkLevel()) {
-                return false;
-            }
-        }
-        return true;
-    }
-}
diff --git a/tools/droiddoc/src/Sorter.java b/tools/droiddoc/src/Sorter.java
deleted file mode 100644
index 92039d4..0000000
--- a/tools/droiddoc/src/Sorter.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-public class Sorter implements Comparable
-{
-    public String label;
-    public Object data;
-
-    public Sorter(String l, Object d)
-    {
-        label = l;
-        data = d;
-    }
-
-    public int compareTo(Object other)
-    {
-        return label.compareToIgnoreCase(((Sorter)other).label);
-    }
-}
diff --git a/tools/droiddoc/src/SourcePositionInfo.java b/tools/droiddoc/src/SourcePositionInfo.java
deleted file mode 100644
index ac605ec..0000000
--- a/tools/droiddoc/src/SourcePositionInfo.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-public class SourcePositionInfo implements Comparable
-{
-    public SourcePositionInfo() {
-        this.file = "<unknown>";
-        this.line = 0;
-        this.column = 0;
-    }
-
-    public SourcePositionInfo(String file, int line, int column)
-    {
-        this.file = file;
-        this.line = line;
-        this.column = column;
-    }
-
-    public SourcePositionInfo(SourcePositionInfo that)
-    {
-        this.file = that.file;
-        this.line = that.line;
-        this.column = that.column;
-    }
-
-    /**
-     * Given this position and str which occurs at that position, as well as str an index into str,
-     * find the SourcePositionInfo.
-     *
-     * @throw StringIndexOutOfBoundsException if index &gt; str.length()
-     */
-    public static SourcePositionInfo add(SourcePositionInfo that, String str, int index)
-    {
-        if (that == null) {
-            return null;
-        }
-        int line = that.line;
-        char prev = 0;
-        for (int i=0; i<index; i++) {
-            char c = str.charAt(i);
-            if (c == '\r' || (c == '\n' && prev != '\r')) {
-                line++;
-            }
-            prev = c;
-        }
-        return new SourcePositionInfo(that.file, line, 0);
-    }
-
-    public static SourcePositionInfo findBeginning(SourcePositionInfo that, String str)
-    {
-        if (that == null) {
-            return null;
-        }
-        int line = that.line-1; // -1 because, well, it seems to work
-        int prev = 0;
-        for (int i=str.length()-1; i>=0; i--) {
-            char c = str.charAt(i);
-            if ((c == '\r' && prev != '\n') || (c == '\n')) {
-                line--;
-            }
-            prev = c;
-        }
-        return new SourcePositionInfo(that.file, line, 0);
-    }
-
-    @Override
-    public String toString()
-    {
-        return file + ':' + line;
-    }
-
-    public int compareTo(Object o) {
-        SourcePositionInfo that = (SourcePositionInfo)o;
-        int r = this.file.compareTo(that.file);
-        if (r != 0) return r;
-        return this.line - that.line;
-    }
-
-    public String file;
-    public int line;
-    public int column;
-}
diff --git a/tools/droiddoc/src/Stubs.java b/tools/droiddoc/src/Stubs.java
deleted file mode 100644
index b988ef5..0000000
--- a/tools/droiddoc/src/Stubs.java
+++ /dev/null
@@ -1,999 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Set;
-import java.util.Comparator;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.PrintStream;
-
-public class Stubs {
-    private static HashSet<ClassInfo> notStrippable;
-    public static void writeStubs(String stubsDir, Boolean writeXML, String xmlFile,
-            HashSet<String> stubPackages) {
-        // figure out which classes we need
-        notStrippable = new HashSet();
-        ClassInfo[] all = Converter.allClasses();
-        File  xml = new File(xmlFile);
-        xml.getParentFile().mkdirs();
-        PrintStream xmlWriter = null;
-        if (writeXML) {
-            try {
-                xmlWriter = new PrintStream(xml);
-            } catch (FileNotFoundException e) {
-                Errors.error(Errors.IO_ERROR, new SourcePositionInfo(xmlFile, 0, 0),
-                        "Cannot open file for write.");
-            }
-        }
-        // If a class is public or protected, not hidden, and marked as included,
-        // then we can't strip it
-        for (ClassInfo cl: all) {
-            if (cl.checkLevel() && cl.isIncluded()) {
-                cantStripThis(cl, notStrippable, "0:0");
-            }
-        }
-
-        // complain about anything that looks includeable but is not supposed to
-        // be written, e.g. hidden things
-        for (ClassInfo cl: notStrippable) {
-            if (!cl.isHidden()) {
-                MethodInfo[] methods = cl.selfMethods();
-                for (MethodInfo m: methods) {
-                    if (m.isHidden()) {
-                        Errors.error(Errors.UNAVAILABLE_SYMBOL,
-                                m.position(), "Reference to hidden method "
-                                + m.name());
-                    } else if (m.isDeprecated()) {
-                        // don't bother reporting deprecated methods
-                        // unless they are public
-                        Errors.error(Errors.DEPRECATED,
-                                m.position(), "Method "
-                                + cl.qualifiedName() + "." + m.name()
-                                + " is deprecated");
-                    }
-
-                    ClassInfo returnClass = m.returnType().asClassInfo();
-                    if (returnClass != null && returnClass.isHidden()) {
-                        Errors.error(Errors.UNAVAILABLE_SYMBOL, m.position(),
-                                "Method " + cl.qualifiedName() + "." + m.name()
-                                + " returns unavailable type " + returnClass.name());
-                    }
-
-                    ParameterInfo[] params = m.parameters();
-                    for (ParameterInfo p: params) {
-                        TypeInfo t = p.type();
-                        if (!t.isPrimitive()) {
-                            if (t.asClassInfo().isHidden()) {
-                                Errors.error(Errors.UNAVAILABLE_SYMBOL,
-                                        m.position(), "Parameter of hidden type "
-                                        + t.fullName() + " in "
-                                        + cl.qualifiedName() + "." + m.name() + "()");
-                            }
-                        }
-                    }
-                }
-
-                // annotations are handled like methods
-                methods = cl.annotationElements();
-                for (MethodInfo m: methods) {
-                    if (m.isHidden()) {
-                        Errors.error(Errors.UNAVAILABLE_SYMBOL,
-                                m.position(), "Reference to hidden annotation "
-                                + m.name());
-                    }
-
-                    ClassInfo returnClass = m.returnType().asClassInfo();
-                    if (returnClass != null && returnClass.isHidden()) {
-                        Errors.error(Errors.UNAVAILABLE_SYMBOL,
-                                m.position(), "Annotation '" + m.name()
-                                + "' returns unavailable type " + returnClass.name());
-                    }
-
-                    ParameterInfo[] params = m.parameters();
-                    for (ParameterInfo p: params) {
-                        TypeInfo t = p.type();
-                        if (!t.isPrimitive()) {
-                            if (t.asClassInfo().isHidden()) {
-                                Errors.error(Errors.UNAVAILABLE_SYMBOL,
-                                        p.position(), "Reference to unavailable annotation class "
-                                        + t.fullName());
-                            }
-                        }
-                    }
-                }
-            } else if (cl.isDeprecated()) {
-                // not hidden, but deprecated
-                Errors.error(Errors.DEPRECATED,
-                        cl.position(), "Class " + cl.qualifiedName()
-                        + " is deprecated");
-            }
-        }
-
-        // write out the stubs
-        HashMap<PackageInfo, List<ClassInfo>> packages = new HashMap<PackageInfo, List<ClassInfo>>();
-        for (ClassInfo cl: notStrippable) {
-            if (!cl.isDocOnly()) {
-                if (stubPackages == null || stubPackages.contains(cl.containingPackage().name())) {
-                    writeClassFile(stubsDir, cl);
-                    if (packages.containsKey(cl.containingPackage())) {
-                        packages.get(cl.containingPackage()).add(cl);
-                    } else {
-                        ArrayList<ClassInfo> classes = new ArrayList<ClassInfo>();
-                        classes.add(cl);
-                        packages.put(cl.containingPackage(), classes);
-                    }
-                }
-            }
-        }
-
-        // write out the XML
-        if (writeXML && xmlWriter != null) {
-            writeXML(xmlWriter, packages, notStrippable);
-        }
-
-        if (xmlWriter != null) {
-            xmlWriter.close();
-        }
-
-    }
-
-    public static void cantStripThis(ClassInfo cl, HashSet<ClassInfo> notStrippable, String why) {
-
-      if (!notStrippable.add(cl)) {
-        // slight optimization: if it already contains cl, it already contains
-        // all of cl's parents
-          return;
-      }
-      cl.setReasonIncluded(why);
-
-      // cant strip annotations
-      /*if (cl.annotations() != null){
-          for (AnnotationInstanceInfo ai : cl.annotations()){
-              if (ai.type() != null){
-                  cantStripThis(ai.type(), notStrippable, "1:" + cl.qualifiedName());
-              }
-          }
-      }*/
-      // cant strip any public fields or their generics
-      if (cl.allSelfFields() != null){
-          for (FieldInfo fInfo : cl.allSelfFields()){
-              if (fInfo.type() != null){
-                  if (fInfo.type().asClassInfo() != null){
-                      cantStripThis(fInfo.type().asClassInfo(), notStrippable,
-                          "2:" + cl.qualifiedName());
-                  }
-                  if (fInfo.type().typeArguments() != null){
-                      for (TypeInfo tTypeInfo : fInfo.type().typeArguments()){
-                          if (tTypeInfo.asClassInfo() != null){
-                              cantStripThis(tTypeInfo.asClassInfo(), notStrippable,
-                                  "3:" + cl.qualifiedName());
-                          }
-                      }
-                  }
-              }
-          }
-      }
-      //cant strip any of the type's generics
-      if (cl.asTypeInfo() != null){
-          if (cl.asTypeInfo().typeArguments() != null){
-              for (TypeInfo tInfo : cl.asTypeInfo().typeArguments()){
-                  if (tInfo.asClassInfo() != null){
-                      cantStripThis(tInfo.asClassInfo(), notStrippable, "4:" + cl.qualifiedName());
-                  }
-              }
-          }
-      }
-      //cant strip any of the annotation elements
-      //cantStripThis(cl.annotationElements(), notStrippable);
-      // take care of methods
-      cantStripThis(cl.allSelfMethods(), notStrippable);
-      cantStripThis(cl.allConstructors(), notStrippable);
-      // blow the outer class open if this is an inner class
-      if(cl.containingClass() != null){
-          cantStripThis(cl.containingClass(), notStrippable, "5:" + cl.qualifiedName());
-      }
-      // blow open super class and interfaces
-     ClassInfo supr = cl.realSuperclass();
-      if (supr != null) {
-          if (supr.isHidden()) {
-              // cl is a public class declared as extending a hidden superclass.
-              // this is not a desired practice but it's happened, so we deal
-              // with it by stripping off the superclass relation for purposes of
-              // generating the doc & stub information, and proceeding normally.
-              cl.init(cl.asTypeInfo(), cl.realInterfaces(), cl.realInterfaceTypes(),
-                      cl.innerClasses(), cl.allConstructors(), cl.allSelfMethods(),
-                      cl.annotationElements(), cl.allSelfFields(), cl.enumConstants(),
-                      cl.containingPackage(), cl.containingClass(),
-                      null, null, cl.annotations());
-              Errors.error(Errors.HIDDEN_SUPERCLASS,
-                      cl.position(), "Public class " + cl.qualifiedName()
-                      + " stripped of unavailable superclass "
-                      + supr.qualifiedName());
-          } else {
-              cantStripThis(supr, notStrippable, "6:" + cl.realSuperclass().name()
-                      + cl.qualifiedName());
-          }
-      }
-    }
-
-    private static void cantStripThis(MethodInfo[] mInfos , HashSet<ClassInfo> notStrippable) {
-      //for each method, blow open the parameters, throws and return types.  also blow open their generics
-      if (mInfos != null){
-          for (MethodInfo mInfo : mInfos){
-              if (mInfo.getTypeParameters() != null){
-                  for (TypeInfo tInfo : mInfo.getTypeParameters()){
-                      if (tInfo.asClassInfo() != null){
-                          cantStripThis(tInfo.asClassInfo(), notStrippable, "8:" +
-                                        mInfo.realContainingClass().qualifiedName() + ":" +
-                                        mInfo.name());
-                      }
-                  }
-              }
-              if (mInfo.parameters() != null){
-                  for (ParameterInfo pInfo : mInfo.parameters()){
-                      if (pInfo.type() != null && pInfo.type().asClassInfo() != null){
-                          cantStripThis(pInfo.type().asClassInfo(), notStrippable,
-                                        "9:"+  mInfo.realContainingClass().qualifiedName()
-                                        + ":" + mInfo.name());
-                          if (pInfo.type().typeArguments() != null){
-                              for (TypeInfo tInfoType : pInfo.type().typeArguments()){
-                                  if (tInfoType.asClassInfo() != null){
-                                      ClassInfo tcl = tInfoType.asClassInfo();
-                                      if (tcl.isHidden()) {
-                                          Errors.error(Errors.UNAVAILABLE_SYMBOL, mInfo.position(),
-                                                  "Parameter of hidden type "
-                                                  + tInfoType.fullName() + " in "
-                                                  + mInfo.containingClass().qualifiedName()
-                                                  + '.' + mInfo.name() + "()");
-                                      } else {
-                                          cantStripThis(tcl, notStrippable,
-                                                  "10:" +
-                                                  mInfo.realContainingClass().qualifiedName() + ":" +
-                                                  mInfo.name());
-                                      }
-                                  }
-                              }
-                          }
-                      }
-                  }
-              }
-              for (ClassInfo thrown : mInfo.thrownExceptions()){
-                  cantStripThis(thrown, notStrippable, "11:" +
-                                mInfo.realContainingClass().qualifiedName()
-                                +":" + mInfo.name());
-              }
-              if (mInfo.returnType() != null && mInfo.returnType().asClassInfo() != null){
-                  cantStripThis(mInfo.returnType().asClassInfo(), notStrippable,
-                                "12:" + mInfo.realContainingClass().qualifiedName() +
-                                ":" + mInfo.name());
-                  if (mInfo.returnType().typeArguments() != null){
-                      for (TypeInfo tyInfo: mInfo.returnType().typeArguments() ){
-                          if (tyInfo.asClassInfo() != null){
-                              cantStripThis(tyInfo.asClassInfo(), notStrippable,
-                                            "13:" +
-                                            mInfo.realContainingClass().qualifiedName()
-                                            + ":" + mInfo.name());
-                          }
-                      }
-                  }
-              }
-          }
-      }
-    }
-
-    static String javaFileName(ClassInfo cl) {
-        String dir = "";
-        PackageInfo pkg = cl.containingPackage();
-        if (pkg != null) {
-            dir = pkg.name();
-            dir = dir.replace('.', '/') + '/';
-        }
-        return dir + cl.name() + ".java";
-    }
-
-    static void writeClassFile(String stubsDir, ClassInfo cl) {
-        // inner classes are written by their containing class
-        if (cl.containingClass() != null) {
-            return;
-        }
-
-        // Work around the bogus "Array" class we invent for
-        // Arrays.copyOf's Class<? extends T[]> newType parameter. (http://b/2715505)
-        if (cl.containingPackage() != null && cl.containingPackage().name().equals("")) {
-            return;
-        }
-
-        String filename = stubsDir + '/' + javaFileName(cl);
-        File file = new File(filename);
-        ClearPage.ensureDirectory(file);
-
-        PrintStream stream = null;
-        try {
-            stream = new PrintStream(file);
-            writeClassFile(stream, cl);
-        }
-        catch (FileNotFoundException e) {
-            System.err.println("error writing file: " + filename);
-        }
-        finally {
-            if (stream != null) {
-                stream.close();
-            }
-        }
-    }
-
-    static void writeClassFile(PrintStream stream, ClassInfo cl) {
-        PackageInfo pkg = cl.containingPackage();
-        if (pkg != null) {
-            stream.println("package " + pkg.name() + ";");
-        }
-        writeClass(stream, cl);
-    }
-
-    static void writeClass(PrintStream stream, ClassInfo cl) {
-        writeAnnotations(stream, cl.annotations());
-
-        stream.print(DroidDoc.scope(cl) + " ");
-        if (cl.isAbstract() && !cl.isAnnotation() && !cl.isInterface()) {
-            stream.print("abstract ");
-        }
-        if (cl.isStatic()){
-            stream.print("static ");
-        }
-        if (cl.isFinal() && !cl.isEnum()) {
-            stream.print("final ");
-        }
-        if (false) {
-            stream.print("strictfp ");
-        }
-
-        HashSet<String> classDeclTypeVars = new HashSet();
-        String leafName = cl.asTypeInfo().fullName(classDeclTypeVars);
-        int bracket = leafName.indexOf('<');
-        if (bracket < 0) bracket = leafName.length() - 1;
-        int period = leafName.lastIndexOf('.', bracket);
-        if (period < 0) period = -1;
-        leafName = leafName.substring(period+1);
-
-        String kind = cl.kind();
-        stream.println(kind + " " + leafName);
-
-        TypeInfo base = cl.superclassType();
-
-        if (!"enum".equals(kind)) {
-            if (base != null && !"java.lang.Object".equals(base.qualifiedTypeName())) {
-                stream.println("  extends " + base.fullName(classDeclTypeVars));
-            }
-        }
-
-        TypeInfo[] interfaces = cl.realInterfaceTypes();
-        List<TypeInfo> usedInterfaces = new ArrayList<TypeInfo>();
-        for (TypeInfo iface : interfaces) {
-            if (notStrippable.contains(iface.asClassInfo())
-                    && !iface.asClassInfo().isDocOnly()) {
-                usedInterfaces.add(iface);
-            }
-        }
-        if (usedInterfaces.size() > 0 && !cl.isAnnotation()) {
-            // can java annotations extend other ones?
-            if (cl.isInterface() || cl.isAnnotation()) {
-                stream.print("  extends ");
-            } else {
-                stream.print("  implements ");
-            }
-            String comma = "";
-            for (TypeInfo iface: usedInterfaces) {
-                stream.print(comma + iface.fullName(classDeclTypeVars));
-                comma = ", ";
-            }
-            stream.println();
-        }
-
-        stream.println("{");
-
-        FieldInfo[] enumConstants = cl.enumConstants();
-        int N = enumConstants.length;
-        for (int i=0; i<N; i++) {
-            FieldInfo field = enumConstants[i];
-            if (!field.constantLiteralValue().equals("null")){
-            stream.println(field.name() + "(" + field.constantLiteralValue()
-                    + (i==N-1 ? ");" : "),"));
-            }else{
-              stream.println(field.name() + "(" + (i==N-1 ? ");" : "),"));
-            }
-        }
-
-        for (ClassInfo inner: cl.getRealInnerClasses()) {
-            if (notStrippable.contains(inner)
-                    && !inner.isDocOnly()){
-                writeClass(stream, inner);
-            }
-        }
-
-
-        for (MethodInfo method: cl.constructors()) {
-            if (!method.isDocOnly()) {
-                writeMethod(stream, method, true);
-            }
-        }
-
-        boolean fieldNeedsInitialization = false;
-        boolean staticFieldNeedsInitialization = false;
-        for (FieldInfo field: cl.allSelfFields()) {
-            if (!field.isDocOnly()) {
-                if (!field.isStatic() && field.isFinal() && !fieldIsInitialized(field)) {
-                    fieldNeedsInitialization = true;
-                }
-                if (field.isStatic() && field.isFinal() && !fieldIsInitialized(field)) {
-                    staticFieldNeedsInitialization = true;
-                }
-            }
-        }
-
-        // The compiler includes a default public constructor that calls the super classes
-        // default constructor in the case where there are no written constructors.
-        // So, if we hide all the constructors, java may put in a constructor
-        // that calls a nonexistent super class constructor.  So, if there are no constructors,
-        // and the super class doesn't have a default constructor, write in a private constructor
-        // that works.  TODO -- we generate this as protected, but we really should generate
-        // it as private unless it also exists in the real code.
-        if ((cl.constructors().length == 0 && (cl.getNonWrittenConstructors().length != 0
-                    || fieldNeedsInitialization))
-                && !cl.isAnnotation()
-                && !cl.isInterface()
-                && !cl.isEnum() ) {
-            //Errors.error(Errors.HIDDEN_CONSTRUCTOR,
-            //             cl.position(), "No constructors " +
-            //            "found and superclass has no parameterless constructor.  A constructor " +
-            //            "that calls an appropriate superclass constructor " +
-            //            "was automatically written to stubs.\n");
-            stream.println(cl.leafName()
-                    + "() { " + superCtorCall(cl,null)
-                    + "throw new" + " RuntimeException(\"Stub!\"); }");
-        }
-
-        for (MethodInfo method: cl.allSelfMethods()) {
-            if (cl.isEnum()) {
-                if (("values".equals(method.name())
-                            && "()".equals(method.signature()))
-                    || ("valueOf".equals(method.name())
-                            && "(java.lang.String)".equals(method.signature()))) {
-                    // skip these two methods on enums, because they're synthetic,
-                    // although for some reason javadoc doesn't mark them as synthetic,
-                    // maybe because they still want them documented
-                    continue;
-                }
-            }
-            if (!method.isDocOnly()) {
-                writeMethod(stream, method, false);
-            }
-        }
-        //Write all methods that are hidden, but override abstract methods or interface methods.
-        //These can't be hidden.
-        for (MethodInfo method : cl.getHiddenMethods()){
-            MethodInfo overriddenMethod = method.findRealOverriddenMethod(method.name(), method.signature(), notStrippable);
-            ClassInfo classContainingMethod = method.findRealOverriddenClass(method.name(),
-                                                                             method.signature());
-            if (overriddenMethod != null && !overriddenMethod.isHidden()
-                && !overriddenMethod.isDocOnly() &&
-                (overriddenMethod.isAbstract() ||
-                overriddenMethod.containingClass().isInterface())) {
-                method.setReason("1:" + classContainingMethod.qualifiedName());
-                cl.addMethod(method);
-                writeMethod(stream, method, false);
-            }
-        }
-
-        for (MethodInfo element: cl.annotationElements()) {
-            if (!element.isDocOnly()) {
-                writeAnnotationElement(stream, element);
-            }
-        }
-
-        for (FieldInfo field: cl.allSelfFields()) {
-            if (!field.isDocOnly()) {
-                writeField(stream, field);
-            }
-        }
-
-        if (staticFieldNeedsInitialization) {
-            stream.print("static { ");
-            for (FieldInfo field: cl.allSelfFields()) {
-                if (!field.isDocOnly() && field.isStatic() && field.isFinal()
-                        && !fieldIsInitialized(field) && field.constantValue() == null) {
-                    stream.print(field.name() + " = " + field.type().defaultValue()
-                            + "; ");
-                }
-            }
-            stream.println("}");
-        }
-
-        stream.println("}");
-    }
-
-
-    static void writeMethod(PrintStream stream, MethodInfo method, boolean isConstructor) {
-        String comma;
-
-        stream.print(DroidDoc.scope(method) + " ");
-        if (method.isStatic()) {
-            stream.print("static ");
-        }
-        if (method.isFinal()) {
-            stream.print("final ");
-        }
-        if (method.isAbstract()) {
-            stream.print("abstract ");
-        }
-        if (method.isSynchronized()) {
-            stream.print("synchronized ");
-        }
-        if (method.isNative()) {
-            stream.print("native ");
-        }
-        if (false /*method.isStictFP()*/) {
-            stream.print("strictfp ");
-        }
-
-        stream.print(method.typeArgumentsName(new HashSet()) + " ");
-
-        if (!isConstructor) {
-            stream.print(method.returnType().fullName(method.typeVariables()) + " ");
-        }
-        String n = method.name();
-        int pos = n.lastIndexOf('.');
-        if (pos >= 0) {
-            n = n.substring(pos + 1);
-        }
-        stream.print(n + "(");
-        comma = "";
-        int count = 1;
-        int size = method.parameters().length;
-        for (ParameterInfo param: method.parameters()) {
-            stream.print(comma + fullParameterTypeName(method, param.type(), count == size)
-                    + " " + param.name());
-            comma = ", ";
-            count++;
-        }
-        stream.print(")");
-
-        comma = "";
-        if (method.thrownExceptions().length > 0) {
-            stream.print(" throws ");
-            for (ClassInfo thrown: method.thrownExceptions()) {
-                stream.print(comma + thrown.qualifiedName());
-                comma = ", ";
-            }
-        }
-        if (method.isAbstract() || method.isNative() || method.containingClass().isInterface()) {
-            stream.println(";");
-        } else {
-            stream.print(" { ");
-            if (isConstructor) {
-                stream.print(superCtorCall(method.containingClass(), method.thrownExceptions()));
-            }
-            stream.println("throw new RuntimeException(\"Stub!\"); }");
-        }
-    }
-
-    static void writeField(PrintStream stream, FieldInfo field) {
-        stream.print(DroidDoc.scope(field) + " ");
-        if (field.isStatic()) {
-            stream.print("static ");
-        }
-        if (field.isFinal()) {
-            stream.print("final ");
-        }
-        if (field.isTransient()) {
-            stream.print("transient ");
-        }
-        if (field.isVolatile()) {
-            stream.print("volatile ");
-        }
-
-        stream.print(field.type().fullName());
-        stream.print(" ");
-        stream.print(field.name());
-
-        if (fieldIsInitialized(field)) {
-            stream.print(" = " + field.constantLiteralValue());
-        }
-
-        stream.println(";");
-    }
-
-    static boolean fieldIsInitialized(FieldInfo field) {
-        return (field.isFinal() && field.constantValue() != null)
-                || !field.type().dimension().equals("")
-                || field.containingClass().isInterface();
-    }
-
-    // Returns 'true' if the method is an @Override of a visible parent
-    // method implementation, and thus does not affect the API.
-    static boolean methodIsOverride(MethodInfo mi) {
-        // Abstract/static/final methods are always listed in the API description
-        if (mi.isAbstract() || mi.isStatic() || mi.isFinal()) {
-            return false;
-        }
-
-        // Find any relevant ancestor declaration and inspect it
-        MethodInfo om = mi.findSuperclassImplementation(notStrippable);
-        if (om != null) {
-            // Visibility mismatch is an API change, so check for it
-            if (mi.mIsPrivate == om.mIsPrivate
-                    && mi.mIsPublic == om.mIsPublic
-                    && mi.mIsProtected == om.mIsProtected) {
-                // Look only for overrides of an ancestor class implementation,
-                // not of e.g. an abstract or interface method declaration
-                if (!om.isAbstract()) {
-                    // If the parent is hidden, we can't rely on it to provide
-                    // the API
-                    if (!om.isHidden()) {
-                        // If the only "override" turns out to be in our own class
-                        // (which sometimes happens in concrete subclasses of
-                        // abstract base classes), it's not really an override
-                        if (!mi.mContainingClass.equals(om.mContainingClass)) {
-                            return true;
-                        }
-                    }
-                }
-            }
-        }
-        return false;
-    }
-
-    static boolean canCallMethod(ClassInfo from, MethodInfo m) {
-        if (m.isPublic() || m.isProtected()) {
-            return true;
-        }
-        if (m.isPackagePrivate()) {
-            String fromPkg = from.containingPackage().name();
-            String pkg = m.containingClass().containingPackage().name();
-            if (fromPkg.equals(pkg)) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    // call a constructor, any constructor on this class's superclass.
-    static String superCtorCall(ClassInfo cl, ClassInfo[] thrownExceptions) {
-        ClassInfo base = cl.realSuperclass();
-        if (base == null) {
-            return "";
-        }
-        HashSet<String> exceptionNames = new HashSet<String>();
-        if (thrownExceptions != null ){
-            for (ClassInfo thrown : thrownExceptions){
-              exceptionNames.add(thrown.name());
-            }
-        }
-        MethodInfo[] ctors = base.constructors();
-        MethodInfo ctor = null;
-        //bad exception indicates that the exceptions thrown by the super constructor
-        //are incompatible with the constructor we're using for the sub class.
-        Boolean badException = false;
-        for (MethodInfo m: ctors) {
-            if (canCallMethod(cl, m)) {
-                if (m.thrownExceptions() != null){
-                    for (ClassInfo thrown : m.thrownExceptions()){
-                        if (!exceptionNames.contains(thrown.name())){
-                            badException = true;
-                        }
-                    }
-                }
-                if (badException){
-                  badException = false;
-                  continue;
-                }
-                // if it has no args, we're done
-                if (m.parameters().length == 0) {
-                    return "";
-                }
-                ctor = m;
-            }
-        }
-        if (ctor != null) {
-            String result = "";
-            result+= "super(";
-            ParameterInfo[] params = ctor.parameters();
-            int N = params.length;
-            for (int i=0; i<N; i++) {
-                TypeInfo t = params[i].type();
-                if (t.isPrimitive() && t.dimension().equals("")) {
-                    String n = t.simpleTypeName();
-                    if (("byte".equals(n)
-                            || "short".equals(n)
-                            || "int".equals(n)
-                            || "long".equals(n)
-                            || "float".equals(n)
-                            || "double".equals(n)) && t.dimension().equals("")) {
-                        result += "0";
-                    }
-                    else if ("char".equals(n)) {
-                        result += "'\\0'";
-                    }
-                    else if ("boolean".equals(n)) {
-                        result += "false";
-                    }
-                    else {
-                        result += "<<unknown-" + n + ">>";
-                    }
-                } else {
-                    //put null in each super class method.  Cast null to the correct type
-                    //to avoid collisions with other constructors.  If the type is generic
-                    //don't cast it
-                    result += (!t.isTypeVariable() ? "(" + t.qualifiedTypeName() + t.dimension() +
-                              ")" : "") + "null";
-                }
-                if (i != N-1) {
-                    result += ",";
-                }
-            }
-            result += "); ";
-            return result;
-        } else {
-            return "";
-        }
-    }
-
-    static void writeAnnotations(PrintStream stream, AnnotationInstanceInfo[] annotations) {
-        for (AnnotationInstanceInfo ann: annotations) {
-            if (!ann.type().isHidden()) {
-                stream.println(ann.toString());
-            }
-        }
-    }
-
-    static void writeAnnotationElement(PrintStream stream, MethodInfo ann) {
-        stream.print(ann.returnType().fullName());
-        stream.print(" ");
-        stream.print(ann.name());
-        stream.print("()");
-        AnnotationValueInfo def = ann.defaultAnnotationElementValue();
-        if (def != null) {
-            stream.print(" default ");
-            stream.print(def.valueString());
-        }
-        stream.println(";");
-    }
-
-    static void writeXML(PrintStream xmlWriter, HashMap<PackageInfo, List<ClassInfo>> allClasses,
-                         HashSet notStrippable) {
-        // extract the set of packages, sort them by name, and write them out in that order
-        Set<PackageInfo> allClassKeys = allClasses.keySet();
-        PackageInfo[] allPackages = allClassKeys.toArray(new PackageInfo[allClassKeys.size()]);
-        Arrays.sort(allPackages, PackageInfo.comparator);
-
-        xmlWriter.println("<api>");
-        for (PackageInfo pack : allPackages) {
-            writePackageXML(xmlWriter, pack, allClasses.get(pack), notStrippable);
-        }
-        xmlWriter.println("</api>");
-    }
-
-    static void writePackageXML(PrintStream xmlWriter, PackageInfo pack, List<ClassInfo> classList,
-                                HashSet notStrippable) {
-        ClassInfo[] classes = classList.toArray(new ClassInfo[classList.size()]);
-        Arrays.sort(classes, ClassInfo.comparator);
-        // Work around the bogus "Array" class we invent for
-        // Arrays.copyOf's Class<? extends T[]> newType parameter. (http://b/2715505)
-        if (pack.name().equals("")) {
-            return;
-        }
-        xmlWriter.println("<package name=\"" + pack.name() + "\"\n"
-                //+ " source=\"" + pack.position() + "\"\n"
-                + ">");
-        for (ClassInfo cl : classes) {
-            writeClassXML(xmlWriter, cl, notStrippable);
-        }
-        xmlWriter.println("</package>");
-
-
-    }
-
-    static void writeClassXML(PrintStream xmlWriter, ClassInfo cl, HashSet notStrippable) {
-        String scope = DroidDoc.scope(cl);
-        String deprecatedString = "";
-        String declString = (cl.isInterface()) ? "interface" : "class";
-        if (cl.isDeprecated()) {
-            deprecatedString = "deprecated";
-        } else {
-            deprecatedString = "not deprecated";
-        }
-        xmlWriter.println("<" + declString + " name=\"" + cl.name() + "\"");
-        if (!cl.isInterface() && !cl.qualifiedName().equals("java.lang.Object")) {
-            xmlWriter.println(" extends=\"" + ((cl.realSuperclass() == null)
-                            ? "java.lang.Object"
-                            : cl.realSuperclass().qualifiedName()) + "\"");
-        }
-        xmlWriter.println(" abstract=\"" + cl.isAbstract() + "\"\n"
-                + " static=\"" + cl.isStatic() + "\"\n"
-                + " final=\"" + cl.isFinal() + "\"\n"
-                + " deprecated=\"" + deprecatedString + "\"\n"
-                + " visibility=\"" + scope + "\"\n"
-                //+ " source=\"" + cl.position() + "\"\n"
-                + ">");
-
-        ClassInfo[] interfaces = cl.realInterfaces();
-        Arrays.sort(interfaces, ClassInfo.comparator);
-        for (ClassInfo iface : interfaces) {
-            if (notStrippable.contains(iface)) {
-                xmlWriter.println("<implements name=\"" + iface.qualifiedName() + "\">");
-                xmlWriter.println("</implements>");
-            }
-        }
-
-        MethodInfo[] constructors = cl.constructors();
-        Arrays.sort(constructors, MethodInfo.comparator);
-        for (MethodInfo mi : constructors) {
-            writeConstructorXML(xmlWriter, mi);
-        }
-
-        MethodInfo[] methods = cl.allSelfMethods();
-        Arrays.sort(methods, MethodInfo.comparator);
-        for (MethodInfo mi : methods) {
-            if (!methodIsOverride(mi)) {
-                writeMethodXML(xmlWriter, mi);
-            }
-        }
-
-        FieldInfo[] fields = cl.allSelfFields();
-        Arrays.sort(fields, FieldInfo.comparator);
-        for (FieldInfo fi : fields) {
-            writeFieldXML(xmlWriter, fi);
-        }
-        xmlWriter.println("</" + declString + ">");
-
-    }
-
-    static void writeMethodXML(PrintStream xmlWriter, MethodInfo mi) {
-        String scope = DroidDoc.scope(mi);
-
-        String deprecatedString = "";
-        if (mi.isDeprecated()) {
-            deprecatedString = "deprecated";
-        } else {
-            deprecatedString = "not deprecated";
-        }
-        xmlWriter.println("<method name=\"" + mi.name() + "\"\n"
-                + ((mi.returnType() != null)
-                        ? " return=\"" + makeXMLcompliant(fullParameterTypeName(mi, mi.returnType(), false)) + "\"\n"
-                        : "")
-                + " abstract=\"" + mi.isAbstract() + "\"\n"
-                + " native=\"" + mi.isNative() + "\"\n"
-                + " synchronized=\"" + mi.isSynchronized() + "\"\n"
-                + " static=\"" + mi.isStatic() + "\"\n"
-                + " final=\"" + mi.isFinal() + "\"\n"
-                + " deprecated=\""+ deprecatedString + "\"\n"
-                + " visibility=\"" + scope + "\"\n"
-                //+ " source=\"" + mi.position() + "\"\n"
-                + ">");
-
-        // write parameters in declaration order
-        int numParameters = mi.parameters().length;
-        int count = 0;
-        for (ParameterInfo pi : mi.parameters()) {
-            count++;
-            writeParameterXML(xmlWriter, mi, pi, count == numParameters);
-        }
-
-        // but write exceptions in canonicalized order
-        ClassInfo[] exceptions = mi.thrownExceptions();
-        Arrays.sort(exceptions, ClassInfo.comparator);
-        for (ClassInfo pi : exceptions) {
-          xmlWriter.println("<exception name=\"" + pi.name() +"\" type=\"" + pi.qualifiedName()
-                            + "\">");
-          xmlWriter.println("</exception>");
-        }
-        xmlWriter.println("</method>");
-    }
-
-    static void writeConstructorXML(PrintStream xmlWriter, MethodInfo mi) {
-        String scope = DroidDoc.scope(mi);
-        String deprecatedString = "";
-        if (mi.isDeprecated()) {
-            deprecatedString = "deprecated";
-        } else {
-            deprecatedString = "not deprecated";
-        }
-        xmlWriter.println("<constructor name=\"" + mi.name() + "\"\n"
-                + " type=\"" + mi.containingClass().qualifiedName() + "\"\n"
-                + " static=\"" + mi.isStatic() + "\"\n"
-                + " final=\"" + mi.isFinal() + "\"\n"
-                + " deprecated=\"" + deprecatedString + "\"\n"
-                + " visibility=\"" + scope +"\"\n"
-                //+ " source=\"" + mi.position() + "\"\n"
-                + ">");
-
-        int numParameters = mi.parameters().length;
-        int count = 0;
-        for (ParameterInfo pi : mi.parameters()) {
-            count++;
-            writeParameterXML(xmlWriter, mi, pi, count == numParameters);
-        }
-
-        ClassInfo[] exceptions = mi.thrownExceptions();
-        Arrays.sort(exceptions, ClassInfo.comparator);
-        for (ClassInfo pi : exceptions) {
-            xmlWriter.println("<exception name=\"" + pi.name() +"\" type=\"" + pi.qualifiedName()
-                              + "\">");
-            xmlWriter.println("</exception>");
-        }
-        xmlWriter.println("</constructor>");
-  }
-
-    static void writeParameterXML(PrintStream xmlWriter, MethodInfo method,
-            ParameterInfo pi, boolean isLast) {
-        xmlWriter.println("<parameter name=\"" + pi.name() + "\" type=\"" +
-                makeXMLcompliant(fullParameterTypeName(method, pi.type(), isLast)) + "\">");
-        xmlWriter.println("</parameter>");
-    }
-
-    static void writeFieldXML(PrintStream xmlWriter, FieldInfo fi) {
-        String scope = DroidDoc.scope(fi);
-        String deprecatedString = "";
-        if (fi.isDeprecated()) {
-            deprecatedString = "deprecated";
-        } else {
-            deprecatedString = "not deprecated";
-        }
-        //need to make sure value is valid XML
-        String value  = makeXMLcompliant(fi.constantLiteralValue());
-
-        String fullTypeName = makeXMLcompliant(fi.type().qualifiedTypeName())
-                + fi.type().dimension();
-
-        xmlWriter.println("<field name=\"" + fi.name() +"\"\n"
-                          + " type=\"" + fullTypeName + "\"\n"
-                          + " transient=\"" + fi.isTransient() + "\"\n"
-                          + " volatile=\"" + fi.isVolatile() + "\"\n"
-                          + (fieldIsInitialized(fi) ? " value=\"" + value + "\"\n" : "")
-                          + " static=\"" + fi.isStatic() + "\"\n"
-                          + " final=\"" + fi.isFinal() + "\"\n"
-                          + " deprecated=\"" + deprecatedString + "\"\n"
-                          + " visibility=\"" + scope + "\"\n"
-                          //+ " source=\"" + fi.position() + "\"\n"
-                          + ">");
-        xmlWriter.println("</field>");
-    }
-
-    static String makeXMLcompliant(String s) {
-        String returnString = "";
-        returnString = s.replaceAll("&", "&amp;");
-        returnString = returnString.replaceAll("<", "&lt;");
-        returnString = returnString.replaceAll(">", "&gt;");
-        returnString = returnString.replaceAll("\"", "&quot;");
-        returnString = returnString.replaceAll("'", "&pos;");
-        return returnString;
-    }
-
-    static String fullParameterTypeName(MethodInfo method, TypeInfo type, boolean isLast) {
-        String fullTypeName = type.fullName(method.typeVariables());
-        if (isLast && method.isVarArgs()) {
-            // TODO: note that this does not attempt to handle hypothetical
-            // vararg methods whose last parameter is a list of arrays, e.g.
-            // "Object[]...".
-            fullTypeName = type.fullNameNoDimension(method.typeVariables()) + "...";
-        }
-        return fullTypeName;
-    }
-}
diff --git a/tools/droiddoc/src/TagInfo.java b/tools/droiddoc/src/TagInfo.java
deleted file mode 100644
index d25c500..0000000
--- a/tools/droiddoc/src/TagInfo.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-import org.clearsilver.HDF;
-import org.clearsilver.CS;
-
-public class TagInfo
-{
-    private String mName;
-    private String mText;
-    private String mKind;
-    private SourcePositionInfo mPosition;
-
-    TagInfo(String n, String k, String t, SourcePositionInfo sp)
-    {
-        mName = n;
-        mText = t;
-        mKind = k;
-        mPosition = sp;
-    }
-
-    String name()
-    {
-        return mName;
-    }
-
-    String text()
-    {
-        return mText;
-    }
-
-    String kind()
-    {
-        return mKind;
-    }
-    
-    SourcePositionInfo position() {
-        return mPosition;
-    }
-
-    void setKind(String kind) {
-        mKind = kind;
-    }
-
-    public void makeHDF(HDF data, String base)
-    {
-        data.setValue(base + ".name", name());
-        data.setValue(base + ".text", text());
-        data.setValue(base + ".kind", kind());
-    }
-
-    public static void makeHDF(HDF data, String base, TagInfo[] tags)
-    {
-        makeHDF(data, base, tags, null, 0, 0);
-    }
-
-    public static void makeHDF(HDF data, String base, InheritedTags tags)
-    {
-        makeHDF(data, base, tags.tags(), tags.inherited(), 0, 0);
-    }
-
-    private static int makeHDF(HDF data, String base, TagInfo[] tags,
-                                InheritedTags inherited, int j, int depth)
-    {
-        int i;
-        int len = tags.length;
-        if (len == 0 && inherited != null) {
-            j = makeHDF(data, base, inherited.tags(), inherited.inherited(), j, depth+1);
-        } else {
-            for (i=0; i<len; i++, j++) {
-                TagInfo t = tags[i];
-                if (inherited != null && t.name().equals("@inheritDoc")) {
-                    j = makeHDF(data, base, inherited.tags(),
-                                    inherited.inherited(), j, depth+1);
-                } else {
-                    if (t.name().equals("@inheritDoc")) {
-                        Errors.error(Errors.BAD_INHERITDOC, t.mPosition,
-                                "@inheritDoc on class/method that is not inherited");
-                    }
-                    t.makeHDF(data, base + "." + j);
-                }
-            }
-        }
-        return j;
-    }
-}
-
diff --git a/tools/droiddoc/src/TextTagInfo.java b/tools/droiddoc/src/TextTagInfo.java
deleted file mode 100644
index dcdfdd9..0000000
--- a/tools/droiddoc/src/TextTagInfo.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-public class TextTagInfo extends TagInfo {
-    TextTagInfo(String n, String k, String t, SourcePositionInfo p) {
-        super(n, k, DroidDoc.escape(t), p);
-    }
-}
diff --git a/tools/droiddoc/src/ThrowsTagInfo.java b/tools/droiddoc/src/ThrowsTagInfo.java
deleted file mode 100644
index 318a57d..0000000
--- a/tools/droiddoc/src/ThrowsTagInfo.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-import org.clearsilver.HDF;
-import org.clearsilver.CS;
-import java.util.regex.Pattern;
-import java.util.regex.Matcher;
-
-public class ThrowsTagInfo extends ParsedTagInfo
-{
-    static final Pattern PATTERN = Pattern.compile(
-                                "(\\S+)\\s+(.*)",
-                                Pattern.DOTALL);
-    private ClassInfo mException;
-
-    public ThrowsTagInfo(String name, String kind, String text,
-            ContainerInfo base, SourcePositionInfo sp)
-    {
-        super(name, kind, text, base, sp);
-
-        Matcher m = PATTERN.matcher(text);
-        if (m.matches()) {
-            setCommentText(m.group(2));
-            String className = m.group(1);
-            if (base instanceof ClassInfo) {
-                mException = ((ClassInfo)base).findClass(className);
-            }
-            if (mException == null) {
-                mException = Converter.obtainClass(className);
-            }
-        }
-    }
-
-    public ThrowsTagInfo(String name, String kind, String text,
-                            ClassInfo exception, String exceptionComment,
-                            ContainerInfo base, SourcePositionInfo sp)
-    {
-        super(name, kind, text, base, sp);
-        mException = exception;
-        setCommentText(exceptionComment);
-    }
-
-    public ClassInfo exception()
-    {
-        return mException;
-    }
-
-    public TypeInfo exceptionType()
-    {
-        if (mException != null) {
-            return mException.asTypeInfo();
-        } else {
-            return null;
-        }
-    }
-
-    public static void makeHDF(HDF data, String base, ThrowsTagInfo[] tags)
-    {
-        for (int i=0; i<tags.length; i++) {
-            TagInfo.makeHDF(data, base + '.' + i + ".comment",
-                    tags[i].commentTags());
-            if (tags[i].exceptionType() != null) {
-                tags[i].exceptionType().makeHDF(data, base + "." + i + ".type");
-            }
-        }
-    }
-
-    
-}
-
diff --git a/tools/droiddoc/src/TodoFile.java b/tools/droiddoc/src/TodoFile.java
deleted file mode 100644
index ebef27e..0000000
--- a/tools/droiddoc/src/TodoFile.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-import org.clearsilver.HDF;
-import org.clearsilver.CS;
-import java.util.*;
-import java.io.*;
-
-public class TodoFile {
-
-    public static final String MISSING = "No description text";
-
-    public static boolean areTagsUseful(InheritedTags tags) {
-        while (tags != null) {
-            if (areTagsUseful(tags.tags())) {
-                return true;
-            }
-            tags = tags.inherited();
-        }
-        return false;
-    }
-
-    public static boolean areTagsUseful(TagInfo[] tags) {
-        for (TagInfo t: tags) {
-            if ("Text".equals(t.name()) && t.text().trim().length() != 0) {
-                return true;
-            }
-            if ("@inheritDoc".equals(t.name())) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    public static void setHDF(HDF data, String base, SourcePositionInfo pos, String name,
-            String descr) {
-        data.setValue(base + ".pos", pos.toString());
-        data.setValue(base + ".name", name);
-        data.setValue(base + ".descr", descr);
-    }
-
-    static class PackageStats {
-        String name;
-        public int total;
-        public int errors;
-    }
-
-    public static String percent(int a, int b) {
-        return ""+Math.round((((b-a)/(float)b))*100) + "%";
-    }
-
-    public static void writeTodoFile(String filename) {
-        HDF data = DroidDoc.makeHDF();
-        DroidDoc.setPageTitle(data, "Missing Documentation");
-        TreeMap<String,PackageStats> packageStats = new TreeMap<String,PackageStats>();
-
-        ClassInfo[] classes = Converter.rootClasses();
-        Arrays.sort(classes);
-
-        int classIndex = 0;
-        
-        for (ClassInfo cl: classes) {
-            if (cl.isHidden()) {
-                continue;
-            }
-
-            String classBase = "classes." + classIndex;
-
-            String base = classBase + ".errors.";
-            int errors = 0;
-            int total = 1;
-
-            if (!areTagsUseful(cl.inlineTags())) {
-                setHDF(data, base + errors, cl.position(), "&lt;class comment&gt;", MISSING);
-                errors++;
-            }
-
-
-            for (MethodInfo m: cl.constructors()) {
-                boolean good = true;
-                total++;
-                if (m.checkLevel()) {
-                    if (!areTagsUseful(m.inlineTags())) {
-                        setHDF(data, base + errors, m.position(), m.name() + m.prettySignature(),
-                                MISSING);
-                        good = false;
-                    }
-                }
-                if (!good) {
-                    errors++;
-                }
-            }
-            
-            for (MethodInfo m: cl.selfMethods()) {
-                boolean good = true;
-                total++;
-                if (m.checkLevel()) {
-                    if (!areTagsUseful(m.inlineTags())) {
-                        setHDF(data, base + errors, m.position(), m.name() + m.prettySignature(),
-                                MISSING);
-                        good = false;
-                    }
-                }
-                if (!good) {
-                    errors++;
-                }
-            }
-            
-
-            for (FieldInfo f: cl.enumConstants()) {
-                boolean good = true;
-                total++;
-                if (f.checkLevel()) {
-                    if (!areTagsUseful(f.inlineTags())) {
-                        setHDF(data, base + errors, f.position(), f.name(), MISSING);
-                        good = false;
-                    }
-                }
-                if (!good) {
-                    errors++;
-                }
-            }
-            
-            for (FieldInfo f: cl.selfFields()) {
-                boolean good = true;
-                total++;
-                if (f.checkLevel()) {
-                    if (!areTagsUseful(f.inlineTags())) {
-                        setHDF(data, base + errors, f.position(), f.name(), MISSING);
-                        good = false;
-                    }
-                }
-                if (!good) {
-                    errors++;
-                }
-            }
-
-            if (errors > 0) {
-                data.setValue(classBase + ".qualified", cl.qualifiedName());
-                data.setValue(classBase + ".errorCount", ""+errors);
-                data.setValue(classBase + ".totalCount", ""+total);
-                data.setValue(classBase + ".percentGood", percent(errors, total));
-            }
-
-            PackageInfo pkg = cl.containingPackage();
-            String pkgName = pkg != null ? pkg.name() : "";
-            PackageStats ps = packageStats.get(pkgName);
-            if (ps == null) {
-                ps = new PackageStats();
-                ps.name = pkgName;
-                packageStats.put(pkgName, ps);
-            }
-            ps.total += total;
-            ps.errors += errors;
-
-            classIndex++;
-        }
-
-        int allTotal = 0;
-        int allErrors = 0;
-
-        int i = 0;
-        for (PackageStats ps: packageStats.values()) {
-            data.setValue("packages." + i + ".name", ""+ps.name);
-            data.setValue("packages." + i + ".errorCount", ""+ps.errors);
-            data.setValue("packages." + i + ".totalCount", ""+ps.total);
-            data.setValue("packages." + i + ".percentGood", percent(ps.errors, ps.total));
-
-            allTotal += ps.total;
-            allErrors += ps.errors;
-
-            i++;
-        }
-
-        data.setValue("all.errorCount", ""+allErrors);
-        data.setValue("all.totalCount", ""+allTotal);
-        data.setValue("all.percentGood", percent(allErrors, allTotal));
-
-        ClearPage.write(data, "todo.cs", filename, true);
-    }
-}
-
diff --git a/tools/droiddoc/src/TypeInfo.java b/tools/droiddoc/src/TypeInfo.java
deleted file mode 100644
index 45e9db9..0000000
--- a/tools/droiddoc/src/TypeInfo.java
+++ /dev/null
@@ -1,291 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-import org.clearsilver.HDF;
-import org.clearsilver.CS;
-import java.util.*;
-import java.io.*;
-
-public class TypeInfo
-{
-    public TypeInfo(boolean isPrimitive, String dimension,
-            String simpleTypeName, String qualifiedTypeName,
-            ClassInfo cl)
-    {
-        mIsPrimitive = isPrimitive;
-        mDimension = dimension;
-        mSimpleTypeName = simpleTypeName;
-        mQualifiedTypeName = qualifiedTypeName;
-        mClass = cl;
-    }
-
-    public ClassInfo asClassInfo()
-    {
-        return mClass;
-    }
-
-    public boolean isPrimitive()
-    {
-        return mIsPrimitive;
-    }
-
-    public String dimension()
-    {
-        return mDimension;
-    }
-
-    public String simpleTypeName()
-    {
-        return mSimpleTypeName;
-    }
-
-    public String qualifiedTypeName()
-    {
-        return mQualifiedTypeName;
-    }
-
-    public String fullName()
-    {
-        if (mFullName != null) {
-            return mFullName;
-        } else {
-            return fullName(new HashSet());
-        }
-    }
-
-    public static String typeArgumentsName(TypeInfo[] args, HashSet<String> typeVars)
-    {
-        String result = "<";
-        for (int i=0; i<args.length; i++) {
-            result += args[i].fullName(typeVars);
-            if (i != args.length-1) {
-                result += ", ";
-            }
-        }
-        result += ">";
-        return result;
-    }
-
-    public String fullName(HashSet<String> typeVars)
-    {
-        mFullName = fullNameNoDimension(typeVars) + mDimension;
-        return mFullName;
-    }
-
-    public String fullNameNoDimension(HashSet<String> typeVars)
-    {
-        String fullName = null;
-        if (mIsTypeVariable) {
-            if (typeVars.contains(mQualifiedTypeName)) {
-                // don't recurse forever with the parameters.  This handles
-                // Enum<K extends Enum<K>>
-                return mQualifiedTypeName;
-            }
-            typeVars.add(mQualifiedTypeName);
-        }
-/*
-        if (fullName != null) {
-            return fullName;
-        }
-*/
-        fullName = mQualifiedTypeName;
-        if (mTypeArguments != null && mTypeArguments.length > 0) {
-            fullName += typeArgumentsName(mTypeArguments, typeVars);
-        }
-        else if (mSuperBounds != null && mSuperBounds.length > 0) {
-            fullName += " super " + mSuperBounds[0].fullName(typeVars);
-            for (int i=1; i<mSuperBounds.length; i++) {
-                fullName += " & " + mSuperBounds[i].fullName(typeVars);
-            }
-        }
-        else if (mExtendsBounds != null && mExtendsBounds.length > 0) {
-            fullName += " extends " + mExtendsBounds[0].fullName(typeVars);
-            for (int i=1; i<mExtendsBounds.length; i++) {
-                fullName += " & " + mExtendsBounds[i].fullName(typeVars);
-            }
-        }
-        return fullName;
-    }
-
-    public TypeInfo[] typeArguments()
-    {
-        return mTypeArguments;
-    }
-
-    public void makeHDF(HDF data, String base)
-    {
-        makeHDFRecursive(data, base, false, false, new HashSet<String>());
-    }
-
-    public void makeQualifiedHDF(HDF data, String base)
-    {
-        makeHDFRecursive(data, base, true, false, new HashSet<String>());
-    }
-
-    public void makeHDF(HDF data, String base, boolean isLastVararg,
-            HashSet<String> typeVariables)
-    {
-        makeHDFRecursive(data, base, false, isLastVararg, typeVariables);
-    }
-
-    public void makeQualifiedHDF(HDF data, String base, HashSet<String> typeVariables)
-    {
-        makeHDFRecursive(data, base, true, false, typeVariables);
-    }
-
-    private void makeHDFRecursive(HDF data, String base, boolean qualified,
-            boolean isLastVararg, HashSet<String> typeVars)
-    {
-        String label = qualified ? qualifiedTypeName() : simpleTypeName();
-        label += (isLastVararg) ? "..." : dimension();
-        data.setValue(base + ".label", label);
-        ClassInfo cl = asClassInfo();
-        if (mIsTypeVariable || mIsWildcard) {
-            // could link to an @param tag on the class to describe this
-            // but for now, just don't make it a link
-        }
-        else if (!isPrimitive() && cl != null && cl.isIncluded()) {
-            data.setValue(base + ".link", cl.htmlPage());
-            data.setValue(base + ".since", cl.getSince());
-        }
-
-        if (mIsTypeVariable) {
-            if (typeVars.contains(qualifiedTypeName())) {
-                // don't recurse forever with the parameters.  This handles
-                // Enum<K extends Enum<K>>
-                return;
-            }
-            typeVars.add(qualifiedTypeName());
-        }
-        if (mTypeArguments != null) {
-            TypeInfo.makeHDF(data, base + ".typeArguments", mTypeArguments, qualified, typeVars);
-        }
-        if (mSuperBounds != null) {
-            TypeInfo.makeHDF(data, base + ".superBounds", mSuperBounds, qualified, typeVars);
-        }
-        if (mExtendsBounds != null) {
-            TypeInfo.makeHDF(data, base + ".extendsBounds", mExtendsBounds, qualified, typeVars);
-        }
-    }
-
-    public static void makeHDF(HDF data, String base, TypeInfo[] types, boolean qualified,
-            HashSet<String> typeVariables)
-    {
-        final int N = types.length;
-        for (int i=0; i<N; i++) {
-            types[i].makeHDFRecursive(data, base + "." + i, qualified, false, typeVariables);
-        }
-    }
-
-    public static void makeHDF(HDF data, String base, TypeInfo[] types, boolean qualified)
-    {
-        makeHDF(data, base, types, qualified, new HashSet<String>());
-    }
-
-    void setTypeArguments(TypeInfo[] args)
-    {
-        mTypeArguments = args;
-    }
-
-    void setBounds(TypeInfo[] superBounds, TypeInfo[] extendsBounds)
-    {
-        mSuperBounds = superBounds;
-        mExtendsBounds = extendsBounds;
-    }
-
-    void setIsTypeVariable(boolean b)
-    {
-        mIsTypeVariable = b;
-    }
-
-    void setIsWildcard(boolean b)
-    {
-        mIsWildcard = b;
-    }
-
-    static HashSet<String> typeVariables(TypeInfo[] params)
-    {
-        return typeVariables(params, new HashSet());
-    }
-
-    static HashSet<String> typeVariables(TypeInfo[] params, HashSet<String> result)
-    {
-        for (TypeInfo t: params) {
-            if (t.mIsTypeVariable) {
-                result.add(t.mQualifiedTypeName);
-            }
-        }
-        return result;
-    }
-
-
-    public boolean isTypeVariable()
-    {
-        return mIsTypeVariable;
-    }
-
-    public String defaultValue() {
-        if (mIsPrimitive) {
-            if ("boolean".equals(mSimpleTypeName)) {
-                return "false";
-            } else {
-                return "0";
-            }
-        } else {
-            return "null";
-        }
-    }
-
-    @Override
-    public String toString(){
-      String returnString = "";
-      returnString += "Primitive?: " + mIsPrimitive + " TypeVariable?: " +
-      mIsTypeVariable + " Wildcard?: " + mIsWildcard + " Dimension: " + mDimension
-      + " QualifedTypeName: " + mQualifiedTypeName;
-
-      if (mTypeArguments != null){
-        returnString += "\nTypeArguments: ";
-        for (TypeInfo tA : mTypeArguments){
-          returnString += tA.qualifiedTypeName() + "(" + tA + ") ";
-        }
-      }
-      if (mSuperBounds != null){
-        returnString += "\nSuperBounds: ";
-        for (TypeInfo tA : mSuperBounds){
-          returnString += tA.qualifiedTypeName() + "(" + tA + ") ";
-        }
-      }
-      if (mExtendsBounds != null){
-        returnString += "\nExtendsBounds: ";
-        for (TypeInfo tA : mExtendsBounds){
-          returnString += tA.qualifiedTypeName() + "(" + tA + ") ";
-        }
-      }
-      return returnString;
-    }
-
-    private boolean mIsPrimitive;
-    private boolean mIsTypeVariable;
-    private boolean mIsWildcard;
-    private String mDimension;
-    private String mSimpleTypeName;
-    private String mQualifiedTypeName;
-    private ClassInfo mClass;
-    private TypeInfo[] mTypeArguments;
-    private TypeInfo[] mSuperBounds;
-    private TypeInfo[] mExtendsBounds;
-    private String mFullName;
-}
diff --git a/tools/droiddoc/templates/assets/android-developer-docs-devguide.css b/tools/droiddoc/templates-pdk/assets/android-developer-docs-devguide.css
similarity index 100%
rename from tools/droiddoc/templates/assets/android-developer-docs-devguide.css
rename to tools/droiddoc/templates-pdk/assets/android-developer-docs-devguide.css
diff --git a/tools/droiddoc/templates/assets/android-developer-docs.css b/tools/droiddoc/templates-pdk/assets/android-developer-docs.css
similarity index 92%
copy from tools/droiddoc/templates/assets/android-developer-docs.css
copy to tools/droiddoc/templates-pdk/assets/android-developer-docs.css
index 1672c93..bc9e98b 100644
--- a/tools/droiddoc/templates/assets/android-developer-docs.css
+++ b/tools/droiddoc/templates-pdk/assets/android-developer-docs.css
@@ -34,6 +34,10 @@
   font-size:12px;
 }
 
+#side-nav.not-resizable {
+  background:url('images/sidenav-rule.png') no-repeat 243px 0;
+}
+
 #resize-packages-nav {
 /* keeps the resize handle below the h-scroll handle */
   height:270px;
@@ -726,36 +730,34 @@
   padding:0;
 }
 
-p.note, div.note,
-p.caution, div.caution,
-p.warning, div.warning {
+p.note, p.caution, p.warning {
   margin: 1em;
   padding: 0 0 0 .5em;
   border-left: 4px solid;
 }
 
-p.special-note,
-div.special-note {
+p.special-note {
   background-color:#EBF3DB;
   padding:10px 20px;
   margin:0 0 1em;
 }
 
-p.note,
-div.note {
+p.note {
  border-color: #99aacc;
 }
 
-p.warning,
-div.warning {
+p.warning {
   border-color: #aa0033;
 }
 
-p.caution,
-div.caution {
+p.caution {
   border-color: #ffcf00;
 }
 
+p.warning b, p.warning strong {
+  font-weight: bold;
+}
+
 li p.note, li p.warning {
   margin: .5em 0 0 0;
   padding: .2em .5em .2em .9em;
@@ -941,7 +943,7 @@
 }
 
 .sidebox p {
-  margin-bottom: .75em;
+  margin-bottom: .25em;
 }
 
 .sidebox ul {
@@ -1052,7 +1054,7 @@
   margin: 0;
   padding: 0;
 }
-
+  
 ol.toc li li {
   padding: 0;
   margin: 0 0 0 1em;
@@ -1179,76 +1181,6 @@
   float: right;
 }
 
-/* 200px */
-.g-tpl-200 .g-unit,
-.g-unit .g-tpl-200 .g-unit,
-.g-unit .g-unit .g-tpl-200 .g-unit {
-  display: block;
-  margin: 0 0 0 200px;
-  width: auto;
-  float: none;
-}
-.g-unit .g-unit .g-tpl-200 .g-first,
-.g-unit .g-tpl-200 .g-first,
-.g-tpl-200 .g-first {
-  display: block;
-  margin: 0;
-  width: 200px;
-  float: left;
-}
-/* 200px alt */
-.g-tpl-200-alt .g-unit,
-.g-unit .g-tpl-200-alt .g-unit,
-.g-unit .g-unit .g-tpl-200-alt .g-unit {
-  display: block;
-  margin: 0 200px 0 0;
-  width: auto;
-  float: none;
-}
-.g-unit .g-unit .g-tpl-200-alt .g-first,
-.g-unit .g-tpl-200-alt .g-first,
-.g-tpl-200-alt .g-first {
-  display: block;
-  margin: 0;
-  width: 200px;
-  float: right;
-}
-
-/* 190px */
-.g-tpl-190 .g-unit,
-.g-unit .g-tpl-190 .g-unit,
-.g-unit .g-unit .g-tpl-190 .g-unit {
-  display: block;
-  margin: 0 0 0 190px;
-  width: auto;
-  float: none;
-}
-.g-unit .g-unit .g-tpl-190 .g-first,
-.g-unit .g-tpl-190 .g-first,
-.g-tpl-190 .g-first {
-  display: block;
-  margin: 0;
-  width: 190px;
-  float: left;
-}
-/* 190px alt */
-.g-tpl-190-alt .g-unit,
-.g-unit .g-tpl-190-alt .g-unit,
-.g-unit .g-unit .g-tpl-190-alt .g-unit {
-  display: block;
-  margin: 0 190px 0 0;
-  width: auto;
-  float: none;
-}
-.g-unit .g-unit .g-tpl-190-alt .g-first,
-.g-unit .g-tpl-190-alt .g-first,
-.g-tpl-190-alt .g-first {
-  display: block;
-  margin: 0;
-  width: 190px;
-  float: right;
-}
-
 /* 180px */
 .g-tpl-180 .g-unit,
 .g-unit .g-tpl-180 .g-unit,
@@ -1284,7 +1216,7 @@
   float: right;
 }
 
-
+  
 /* JQUERY RESIZABLE STYLES */
 .ui-resizable { position: relative; }
 .ui-resizable-handle { position: absolute; display: none; font-size: 0.1px; z-index:1; }
@@ -1320,7 +1252,7 @@
   #body-content {
     position:inherit;
   }
-
+  
   #doc-content {
     margin-left:0 !important;
     height:auto !important;
diff --git a/tools/droiddoc/templates-pdk/assets/android-developer-reference.js b/tools/droiddoc/templates-pdk/assets/android-developer-reference.js
new file mode 100644
index 0000000..daddde0
--- /dev/null
+++ b/tools/droiddoc/templates-pdk/assets/android-developer-reference.js
@@ -0,0 +1,390 @@
+
+/* API LEVEL TOGGLE */
+addLoadEvent(changeApiLevel);
+
+var API_LEVEL_ENABLED_COOKIE = "api_level_enabled";
+var API_LEVEL_COOKIE = "api_level";
+var minLevel = 1;
+
+function toggleApiLevelSelector(checkbox) {
+  var date = new Date();
+  date.setTime(date.getTime()+(10*365*24*60*60*1000)); // keep this for 10 years
+  var expiration = date.toGMTString();
+  if (checkbox.checked) {
+    $("#apiLevelSelector").removeAttr("disabled");
+    $("#api-level-toggle label").removeClass("disabled");
+    writeCookie(API_LEVEL_ENABLED_COOKIE, 1, null, expiration);
+  } else {
+    $("#apiLevelSelector").attr("disabled","disabled");
+    $("#api-level-toggle label").addClass("disabled");
+    writeCookie(API_LEVEL_ENABLED_COOKIE, 0, null, expiration);
+  }
+  changeApiLevel();
+}
+
+function buildApiLevelSelector() {
+  var maxLevel = SINCE_DATA.length;
+  var userApiLevelEnabled = readCookie(API_LEVEL_ENABLED_COOKIE);
+  var userApiLevel = readCookie(API_LEVEL_COOKIE);
+  userApiLevel = userApiLevel == 0 ? maxLevel : userApiLevel; // If there's no cookie (zero), use the max by default
+
+  if (userApiLevelEnabled == 0) {
+    $("#apiLevelSelector").attr("disabled","disabled");
+  } else {
+    $("#apiLevelCheckbox").attr("checked","checked");
+    $("#api-level-toggle label").removeClass("disabled");
+  }
+  
+  minLevel = $("body").attr("class");
+  var select = $("#apiLevelSelector").html("").change(changeApiLevel);
+  for (var i = maxLevel-1; i >= 0; i--) {
+    var option = $("<option />").attr("value",""+SINCE_DATA[i]).append(""+SINCE_DATA[i]);
+  //  if (SINCE_DATA[i] < minLevel) option.addClass("absent"); // always false for strings (codenames)
+    select.append(option);
+  }
+  
+  // get the DOM element and use setAttribute cuz IE6 fails when using jquery .attr('selected',true)
+  var selectedLevelItem = $("#apiLevelSelector option[value='"+userApiLevel+"']").get(0);
+  selectedLevelItem.setAttribute('selected',true);
+}
+
+function changeApiLevel() {
+  var maxLevel = SINCE_DATA.length;
+  var userApiLevelEnabled = readCookie(API_LEVEL_ENABLED_COOKIE);
+  var selectedLevel = maxLevel;
+  
+  if (userApiLevelEnabled == 0) {
+    toggleVisisbleApis(selectedLevel, "body");
+  } else {
+    selectedLevel = $("#apiLevelSelector option:selected").val();
+    toggleVisisbleApis(selectedLevel, "body");
+    
+    var date = new Date();
+    date.setTime(date.getTime()+(10*365*24*60*60*1000)); // keep this for 10 years
+    var expiration = date.toGMTString();
+    writeCookie(API_LEVEL_COOKIE, selectedLevel, null, expiration);
+  }
+  
+  if (selectedLevel < minLevel) {
+    var thing = ($("#jd-header").html().indexOf("package") != -1) ? "package" : "class";
+    $("#naMessage").show().html("<div><p><strong>This " + thing + " is not available with API Level " + selectedLevel + ".</strong></p>"
+                              + "<p>To use this " + thing + ", your application must specify API Level " + minLevel + " or higher in its manifest "
+                              + "and be compiled against a version of the Android library that supports an equal or higher API Level. To reveal this "
+                              + "document, change the value of the API Level filter above.</p>"
+                              + "<p><a href='" +toRoot+ "guide/appendix/api-levels.html'>What is the API Level?</a></p></div>");
+  } else {
+    $("#naMessage").hide();
+  }
+}
+
+function toggleVisisbleApis(selectedLevel, context) {
+  var apis = $(".api",context);
+  apis.each(function(i) {
+    var obj = $(this);
+    var className = obj.attr("class");
+    var apiLevelIndex = className.lastIndexOf("-")+1;
+    var apiLevelEndIndex = className.indexOf(" ", apiLevelIndex);
+    apiLevelEndIndex = apiLevelEndIndex != -1 ? apiLevelEndIndex : className.length;
+    var apiLevel = className.substring(apiLevelIndex, apiLevelEndIndex);
+    if (apiLevel > selectedLevel) obj.addClass("absent").attr("title","Requires API Level "+apiLevel+" or higher");
+    else obj.removeClass("absent").removeAttr("title");
+  });
+}
+
+/* NAVTREE */
+
+function new_node(me, mom, text, link, children_data, api_level)
+{
+  var node = new Object();
+  node.children = Array();
+  node.children_data = children_data;
+  node.depth = mom.depth + 1;
+
+  node.li = document.createElement("li");
+  mom.get_children_ul().appendChild(node.li);
+
+  node.label_div = document.createElement("div");
+  node.label_div.className = "label";
+  if (api_level != null) {
+    $(node.label_div).addClass("api");
+    $(node.label_div).addClass("api-level-"+api_level);
+  }
+  node.li.appendChild(node.label_div);
+  node.label_div.style.paddingLeft = 10*node.depth + "px";
+
+  if (children_data == null) {
+    // 12 is the width of the triangle and padding extra space
+    node.label_div.style.paddingLeft = ((10*node.depth)+12) + "px";
+  } else {
+    node.label_div.style.paddingLeft = 10*node.depth + "px";
+    node.expand_toggle = document.createElement("a");
+    node.expand_toggle.href = "javascript:void(0)";
+    node.expand_toggle.onclick = function() {
+          if (node.expanded) {
+            $(node.get_children_ul()).slideUp("fast");
+            node.plus_img.src = me.toroot + "assets/images/triangle-closed-small.png";
+            node.expanded = false;
+          } else {
+            expand_node(me, node);
+          }
+       };
+    node.label_div.appendChild(node.expand_toggle);
+
+    node.plus_img = document.createElement("img");
+    node.plus_img.src = me.toroot + "assets/images/triangle-closed-small.png";
+    node.plus_img.className = "plus";
+    node.plus_img.border = "0";
+    node.expand_toggle.appendChild(node.plus_img);
+
+    node.expanded = false;
+  }
+
+  var a = document.createElement("a");
+  node.label_div.appendChild(a);
+  node.label = document.createTextNode(text);
+  a.appendChild(node.label);
+  if (link) {
+    a.href = me.toroot + link;
+  } else {
+    if (children_data != null) {
+      a.className = "nolink";
+      a.href = "javascript:void(0)";
+      a.onclick = node.expand_toggle.onclick;
+      // This next line shouldn't be necessary.  I'll buy a beer for the first
+      // person who figures out how to remove this line and have the link
+      // toggle shut on the first try. --joeo@android.com
+      node.expanded = false;
+    }
+  }
+  
+
+  node.children_ul = null;
+  node.get_children_ul = function() {
+      if (!node.children_ul) {
+        node.children_ul = document.createElement("ul");
+        node.children_ul.className = "children_ul";
+        node.children_ul.style.display = "none";
+        node.li.appendChild(node.children_ul);
+      }
+      return node.children_ul;
+    };
+
+  return node;
+}
+
+function expand_node(me, node)
+{
+  if (node.children_data && !node.expanded) {
+    if (node.children_visited) {
+      $(node.get_children_ul()).slideDown("fast");
+    } else {
+      get_node(me, node);
+      if ($(node.label_div).hasClass("absent")) $(node.get_children_ul()).addClass("absent");
+      $(node.get_children_ul()).slideDown("fast");
+    }
+    node.plus_img.src = me.toroot + "assets/images/triangle-opened-small.png";
+    node.expanded = true;
+    
+    // perform api level toggling because new nodes are new to the DOM
+    var selectedLevel = $("#apiLevelSelector option:selected").val();
+    toggleVisisbleApis(selectedLevel, "#side-nav");
+  }
+}
+
+function get_node(me, mom)
+{
+  mom.children_visited = true;
+  for (var i in mom.children_data) {
+    var node_data = mom.children_data[i];
+    mom.children[i] = new_node(me, mom, node_data[0], node_data[1],
+        node_data[2], node_data[3]);
+  }
+}
+
+function this_page_relative(toroot)
+{
+  var full = document.location.pathname;
+  var file = "";
+  if (toroot.substr(0, 1) == "/") {
+    if (full.substr(0, toroot.length) == toroot) {
+      return full.substr(toroot.length);
+    } else {
+      // the file isn't under toroot.  Fail.
+      return null;
+    }
+  } else {
+    if (toroot != "./") {
+      toroot = "./" + toroot;
+    }
+    do {
+      if (toroot.substr(toroot.length-3, 3) == "../" || toroot == "./") {
+        var pos = full.lastIndexOf("/");
+        file = full.substr(pos) + file;
+        full = full.substr(0, pos);
+        toroot = toroot.substr(0, toroot.length-3);
+      }
+    } while (toroot != "" && toroot != "/");
+    return file.substr(1);
+  }
+}
+
+function find_page(url, data)
+{
+  var nodes = data;
+  var result = null;
+  for (var i in nodes) {
+    var d = nodes[i];
+    if (d[1] == url) {
+      return new Array(i);
+    }
+    else if (d[2] != null) {
+      result = find_page(url, d[2]);
+      if (result != null) {
+        return (new Array(i).concat(result));
+      }
+    }
+  }
+  return null;
+}
+
+function load_navtree_data(toroot) {
+  var navtreeData = document.createElement("script");
+  navtreeData.setAttribute("type","text/javascript");
+  navtreeData.setAttribute("src", toroot+"navtree_data.js");
+  $("head").append($(navtreeData));
+}
+
+function init_default_navtree(toroot) {
+  init_navtree("nav-tree", toroot, NAVTREE_DATA);
+  
+  // perform api level toggling because because the whole tree is new to the DOM
+  var selectedLevel = $("#apiLevelSelector option:selected").val();
+  toggleVisisbleApis(selectedLevel, "#side-nav");
+}
+
+function init_navtree(navtree_id, toroot, root_nodes)
+{
+  var me = new Object();
+  me.toroot = toroot;
+  me.node = new Object();
+
+  me.node.li = document.getElementById(navtree_id);
+  me.node.children_data = root_nodes;
+  me.node.children = new Array();
+  me.node.children_ul = document.createElement("ul");
+  me.node.get_children_ul = function() { return me.node.children_ul; };
+  //me.node.children_ul.className = "children_ul";
+  me.node.li.appendChild(me.node.children_ul);
+  me.node.depth = 0;
+
+  get_node(me, me.node);
+
+  me.this_page = this_page_relative(toroot);
+  me.breadcrumbs = find_page(me.this_page, root_nodes);
+  if (me.breadcrumbs != null && me.breadcrumbs.length != 0) {
+    var mom = me.node;
+    for (var i in me.breadcrumbs) {
+      var j = me.breadcrumbs[i];
+      mom = mom.children[j];
+      expand_node(me, mom);
+    }
+    mom.label_div.className = mom.label_div.className + " selected";
+    addLoadEvent(function() {
+      scrollIntoView("nav-tree");
+      });
+  }
+}
+
+/* TOGGLE INHERITED MEMBERS */
+
+/* Toggle an inherited class (arrow toggle)
+ * @param linkObj  The link that was clicked.
+ * @param expand  'true' to ensure it's expanded. 'false' to ensure it's closed.
+ *                'null' to simply toggle.
+ */
+function toggleInherited(linkObj, expand) {
+    var base = linkObj.getAttribute("id");
+    var list = document.getElementById(base + "-list");
+    var summary = document.getElementById(base + "-summary");
+    var trigger = document.getElementById(base + "-trigger");
+    var a = $(linkObj);
+    if ( (expand == null && a.hasClass("closed")) || expand ) {
+        list.style.display = "none";
+        summary.style.display = "block";
+        trigger.src = toRoot + "assets/images/triangle-opened.png";
+        a.removeClass("closed");
+        a.addClass("opened");
+    } else if ( (expand == null && a.hasClass("opened")) || (expand == false) ) {
+        list.style.display = "block";
+        summary.style.display = "none";
+        trigger.src = toRoot + "assets/images/triangle-closed.png";
+        a.removeClass("opened");
+        a.addClass("closed");
+    }
+    return false;
+}
+
+/* Toggle all inherited classes in a single table (e.g. all inherited methods)
+ * @param linkObj  The link that was clicked.
+ * @param expand  'true' to ensure it's expanded. 'false' to ensure it's closed.
+ *                'null' to simply toggle.
+ */
+function toggleAllInherited(linkObj, expand) {
+  var a = $(linkObj);
+  var table = $(a.parent().parent().parent()); // ugly way to get table/tbody
+  var expandos = $(".jd-expando-trigger", table);
+  if ( (expand == null && a.text() == "[Expand]") || expand ) {
+    expandos.each(function(i) {
+      toggleInherited(this, true);
+    });
+    a.text("[Collapse]");
+  } else if ( (expand == null && a.text() == "[Collapse]") || (expand == false) ) {
+    expandos.each(function(i) {
+      toggleInherited(this, false);
+    });
+    a.text("[Expand]");
+  }
+  return false;
+}
+
+/* Toggle all inherited members in the class (link in the class title)
+ */
+function toggleAllClassInherited() {
+  var a = $("#toggleAllClassInherited"); // get toggle link from class title
+  var toggles = $(".toggle-all", $("#doc-content"));
+  if (a.text() == "[Expand All]") {
+    toggles.each(function(i) {
+      toggleAllInherited(this, true);
+    });
+    a.text("[Collapse All]");
+  } else {
+    toggles.each(function(i) {
+      toggleAllInherited(this, false);
+    });
+    a.text("[Expand All]");
+  }
+  return false;
+}
+
+/* Expand all inherited members in the class. Used when initiating page search */
+function ensureAllInheritedExpanded() {
+  var toggles = $(".toggle-all", $("#doc-content"));
+  toggles.each(function(i) {
+    toggleAllInherited(this, true);
+  });
+  $("#toggleAllClassInherited").text("[Collapse All]");
+}
+
+
+/* HANDLE KEY EVENTS
+ * - Listen for Ctrl+F (Cmd on Mac) and expand all inherited members (to aid page search)
+ */
+var agent = navigator['userAgent'].toLowerCase();
+var mac = agent.indexOf("macintosh") != -1;
+
+$(document).keydown( function(e) {
+var control = mac ? e.metaKey && !e.ctrlKey : e.ctrlKey; // get ctrl key
+  if (control && e.which == 70) {  // 70 is "F"
+    ensureAllInheritedExpanded();
+  }
+});
\ No newline at end of file
diff --git a/tools/droiddoc/templates/assets/carousel.js b/tools/droiddoc/templates-pdk/assets/carousel.js
similarity index 100%
rename from tools/droiddoc/templates/assets/carousel.js
rename to tools/droiddoc/templates-pdk/assets/carousel.js
diff --git a/tools/droiddoc/templates/assets/images/android-developers-logo.png b/tools/droiddoc/templates-pdk/assets/images/android-developers-logo.png
similarity index 100%
rename from tools/droiddoc/templates/assets/images/android-developers-logo.png
rename to tools/droiddoc/templates-pdk/assets/images/android-developers-logo.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/android_wrench.png b/tools/droiddoc/templates-pdk/assets/images/android_wrench.png
similarity index 100%
rename from tools/droiddoc/templates/assets/images/android_wrench.png
rename to tools/droiddoc/templates-pdk/assets/images/android_wrench.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/arrow_bluelink_down.png b/tools/droiddoc/templates-pdk/assets/images/arrow_bluelink_down.png
similarity index 100%
rename from tools/droiddoc/templates/assets/images/arrow_bluelink_down.png
rename to tools/droiddoc/templates-pdk/assets/images/arrow_bluelink_down.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/arrow_bluelink_up.png b/tools/droiddoc/templates-pdk/assets/images/arrow_bluelink_up.png
similarity index 100%
rename from tools/droiddoc/templates/assets/images/arrow_bluelink_up.png
rename to tools/droiddoc/templates-pdk/assets/images/arrow_bluelink_up.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/arrow_left_off.jpg b/tools/droiddoc/templates-pdk/assets/images/arrow_left_off.jpg
similarity index 100%
rename from tools/droiddoc/templates/assets/images/arrow_left_off.jpg
rename to tools/droiddoc/templates-pdk/assets/images/arrow_left_off.jpg
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/arrow_left_on.jpg b/tools/droiddoc/templates-pdk/assets/images/arrow_left_on.jpg
similarity index 100%
rename from tools/droiddoc/templates/assets/images/arrow_left_on.jpg
rename to tools/droiddoc/templates-pdk/assets/images/arrow_left_on.jpg
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/arrow_right_off.jpg b/tools/droiddoc/templates-pdk/assets/images/arrow_right_off.jpg
similarity index 100%
rename from tools/droiddoc/templates/assets/images/arrow_right_off.jpg
rename to tools/droiddoc/templates-pdk/assets/images/arrow_right_off.jpg
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/arrow_right_on.jpg b/tools/droiddoc/templates-pdk/assets/images/arrow_right_on.jpg
similarity index 100%
rename from tools/droiddoc/templates/assets/images/arrow_right_on.jpg
rename to tools/droiddoc/templates-pdk/assets/images/arrow_right_on.jpg
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/bg_community_leftDiv.jpg b/tools/droiddoc/templates-pdk/assets/images/bg_community_leftDiv.jpg
similarity index 100%
rename from tools/droiddoc/templates/assets/images/bg_community_leftDiv.jpg
rename to tools/droiddoc/templates-pdk/assets/images/bg_community_leftDiv.jpg
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/bg_fade.jpg b/tools/droiddoc/templates-pdk/assets/images/bg_fade.jpg
similarity index 100%
rename from tools/droiddoc/templates/assets/images/bg_fade.jpg
rename to tools/droiddoc/templates-pdk/assets/images/bg_fade.jpg
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/bg_images_sprite.png b/tools/droiddoc/templates-pdk/assets/images/bg_images_sprite.png
similarity index 100%
rename from tools/droiddoc/templates/assets/images/bg_images_sprite.png
rename to tools/droiddoc/templates-pdk/assets/images/bg_images_sprite.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/bg_logo.png b/tools/droiddoc/templates-pdk/assets/images/bg_logo.png
similarity index 100%
rename from tools/droiddoc/templates/assets/images/bg_logo.png
rename to tools/droiddoc/templates-pdk/assets/images/bg_logo.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/body-gradient-tab.png b/tools/droiddoc/templates-pdk/assets/images/body-gradient-tab.png
similarity index 100%
rename from tools/droiddoc/templates/assets/images/body-gradient-tab.png
rename to tools/droiddoc/templates-pdk/assets/images/body-gradient-tab.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/body-gradient.png b/tools/droiddoc/templates-pdk/assets/images/body-gradient.png
similarity index 100%
rename from tools/droiddoc/templates/assets/images/body-gradient.png
rename to tools/droiddoc/templates-pdk/assets/images/body-gradient.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/developers-logo.png b/tools/droiddoc/templates-pdk/assets/images/developers-logo.png
similarity index 100%
rename from tools/droiddoc/templates/assets/images/developers-logo.png
rename to tools/droiddoc/templates-pdk/assets/images/developers-logo.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/grad-rule-qv.png b/tools/droiddoc/templates-pdk/assets/images/grad-rule-qv.png
similarity index 100%
rename from tools/droiddoc/templates/assets/images/grad-rule-qv.png
rename to tools/droiddoc/templates-pdk/assets/images/grad-rule-qv.png
Binary files differ
diff --git a/tools/droiddoc/templates-pdk/assets/images/home/Android_Dev_Lab_l.png b/tools/droiddoc/templates-pdk/assets/images/home/Android_Dev_Lab_l.png
new file mode 100644
index 0000000..8259981
--- /dev/null
+++ b/tools/droiddoc/templates-pdk/assets/images/home/Android_Dev_Lab_l.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/home/IO-logo.png b/tools/droiddoc/templates-pdk/assets/images/home/IO-logo.png
similarity index 100%
rename from tools/droiddoc/templates/assets/images/home/IO-logo.png
rename to tools/droiddoc/templates-pdk/assets/images/home/IO-logo.png
Binary files differ
diff --git a/tools/droiddoc/templates-pdk/assets/images/home/adc2_l.png b/tools/droiddoc/templates-pdk/assets/images/home/adc2_l.png
new file mode 100644
index 0000000..ac51a1e
--- /dev/null
+++ b/tools/droiddoc/templates-pdk/assets/images/home/adc2_l.png
Binary files differ
diff --git a/tools/droiddoc/templates-pdk/assets/images/home/adc2_s.png b/tools/droiddoc/templates-pdk/assets/images/home/adc2_s.png
new file mode 100644
index 0000000..9cbfd4e
--- /dev/null
+++ b/tools/droiddoc/templates-pdk/assets/images/home/adc2_s.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/home/android_adc.png b/tools/droiddoc/templates-pdk/assets/images/home/android_adc.png
similarity index 100%
rename from tools/droiddoc/templates/assets/images/home/android_adc.png
rename to tools/droiddoc/templates-pdk/assets/images/home/android_adc.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/home/bg_home_announcement.png b/tools/droiddoc/templates-pdk/assets/images/home/bg_home_announcement.png
similarity index 100%
rename from tools/droiddoc/templates/assets/images/home/bg_home_announcement.png
rename to tools/droiddoc/templates-pdk/assets/images/home/bg_home_announcement.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/home/bg_home_bottom.jpg b/tools/droiddoc/templates-pdk/assets/images/home/bg_home_bottom.jpg
similarity index 100%
rename from tools/droiddoc/templates/assets/images/home/bg_home_bottom.jpg
rename to tools/droiddoc/templates-pdk/assets/images/home/bg_home_bottom.jpg
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/home/bg_home_carousel.png b/tools/droiddoc/templates-pdk/assets/images/home/bg_home_carousel.png
similarity index 100%
rename from tools/droiddoc/templates/assets/images/home/bg_home_carousel.png
rename to tools/droiddoc/templates-pdk/assets/images/home/bg_home_carousel.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/home/bg_home_carousel_board.png b/tools/droiddoc/templates-pdk/assets/images/home/bg_home_carousel_board.png
similarity index 100%
rename from tools/droiddoc/templates/assets/images/home/bg_home_carousel_board.png
rename to tools/droiddoc/templates-pdk/assets/images/home/bg_home_carousel_board.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/home/bg_home_carousel_wheel.png b/tools/droiddoc/templates-pdk/assets/images/home/bg_home_carousel_wheel.png
similarity index 100%
rename from tools/droiddoc/templates/assets/images/home/bg_home_carousel_wheel.png
rename to tools/droiddoc/templates-pdk/assets/images/home/bg_home_carousel_wheel.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/home/carousel_buttons_sprite.png b/tools/droiddoc/templates-pdk/assets/images/home/carousel_buttons_sprite.png
similarity index 100%
rename from tools/droiddoc/templates/assets/images/home/carousel_buttons_sprite.png
rename to tools/droiddoc/templates-pdk/assets/images/home/carousel_buttons_sprite.png
Binary files differ
diff --git a/tools/droiddoc/templates-pdk/assets/images/home/devphone-large.png b/tools/droiddoc/templates-pdk/assets/images/home/devphone-large.png
new file mode 100755
index 0000000..6221e0a
--- /dev/null
+++ b/tools/droiddoc/templates-pdk/assets/images/home/devphone-large.png
Binary files differ
diff --git a/tools/droiddoc/templates-pdk/assets/images/home/devphone-small.png b/tools/droiddoc/templates-pdk/assets/images/home/devphone-small.png
new file mode 100755
index 0000000..b8487f5
--- /dev/null
+++ b/tools/droiddoc/templates-pdk/assets/images/home/devphone-small.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/home/donut-android.png b/tools/droiddoc/templates-pdk/assets/images/home/donut-android.png
similarity index 100%
rename from tools/droiddoc/templates/assets/images/home/donut-android.png
rename to tools/droiddoc/templates-pdk/assets/images/home/donut-android.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/home/eclair-android.png b/tools/droiddoc/templates-pdk/assets/images/home/eclair-android.png
similarity index 100%
rename from tools/droiddoc/templates/assets/images/home/eclair-android.png
rename to tools/droiddoc/templates-pdk/assets/images/home/eclair-android.png
Binary files differ
diff --git a/tools/droiddoc/templates-pdk/assets/images/home/froyo-android.png b/tools/droiddoc/templates-pdk/assets/images/home/froyo-android.png
new file mode 100644
index 0000000..84ec5ec
--- /dev/null
+++ b/tools/droiddoc/templates-pdk/assets/images/home/froyo-android.png
Binary files differ
diff --git a/tools/droiddoc/templates-pdk/assets/images/home/gdc-logo.png b/tools/droiddoc/templates-pdk/assets/images/home/gdc-logo.png
new file mode 100644
index 0000000..85617b8
--- /dev/null
+++ b/tools/droiddoc/templates-pdk/assets/images/home/gdc-logo.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/home/io-large.png b/tools/droiddoc/templates-pdk/assets/images/home/io-large.png
similarity index 100%
rename from tools/droiddoc/templates/assets/images/home/io-large.png
rename to tools/droiddoc/templates-pdk/assets/images/home/io-large.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/home/io-small.png b/tools/droiddoc/templates-pdk/assets/images/home/io-small.png
similarity index 100%
rename from tools/droiddoc/templates/assets/images/home/io-small.png
rename to tools/droiddoc/templates-pdk/assets/images/home/io-small.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/home/maps-large.png b/tools/droiddoc/templates-pdk/assets/images/home/maps-large.png
similarity index 100%
rename from tools/droiddoc/templates/assets/images/home/maps-large.png
rename to tools/droiddoc/templates-pdk/assets/images/home/maps-large.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/home/maps-small.png b/tools/droiddoc/templates-pdk/assets/images/home/maps-small.png
similarity index 100%
rename from tools/droiddoc/templates/assets/images/home/maps-small.png
rename to tools/droiddoc/templates-pdk/assets/images/home/maps-small.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/home/market-large.png b/tools/droiddoc/templates-pdk/assets/images/home/market-large.png
similarity index 100%
rename from tools/droiddoc/templates/assets/images/home/market-large.png
rename to tools/droiddoc/templates-pdk/assets/images/home/market-large.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/home/market-small.png b/tools/droiddoc/templates-pdk/assets/images/home/market-small.png
similarity index 100%
rename from tools/droiddoc/templates/assets/images/home/market-small.png
rename to tools/droiddoc/templates-pdk/assets/images/home/market-small.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/home/sdk-large.png b/tools/droiddoc/templates-pdk/assets/images/home/sdk-large.png
similarity index 100%
rename from tools/droiddoc/templates/assets/images/home/sdk-large.png
rename to tools/droiddoc/templates-pdk/assets/images/home/sdk-large.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/home/sdk-small.png b/tools/droiddoc/templates-pdk/assets/images/home/sdk-small.png
similarity index 100%
rename from tools/droiddoc/templates/assets/images/home/sdk-small.png
rename to tools/droiddoc/templates-pdk/assets/images/home/sdk-small.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/hr_gray_main.jpg b/tools/droiddoc/templates-pdk/assets/images/hr_gray_main.jpg
similarity index 100%
rename from tools/droiddoc/templates/assets/images/hr_gray_main.jpg
rename to tools/droiddoc/templates-pdk/assets/images/hr_gray_main.jpg
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/hr_gray_side.jpg b/tools/droiddoc/templates-pdk/assets/images/hr_gray_side.jpg
similarity index 100%
rename from tools/droiddoc/templates/assets/images/hr_gray_side.jpg
rename to tools/droiddoc/templates-pdk/assets/images/hr_gray_side.jpg
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/icon_contribute.jpg b/tools/droiddoc/templates-pdk/assets/images/icon_contribute.jpg
similarity index 100%
rename from tools/droiddoc/templates/assets/images/icon_contribute.jpg
rename to tools/droiddoc/templates-pdk/assets/images/icon_contribute.jpg
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/icon_download.jpg b/tools/droiddoc/templates-pdk/assets/images/icon_download.jpg
similarity index 100%
rename from tools/droiddoc/templates/assets/images/icon_download.jpg
rename to tools/droiddoc/templates-pdk/assets/images/icon_download.jpg
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/icon_download2.jpg b/tools/droiddoc/templates-pdk/assets/images/icon_download2.jpg
similarity index 100%
rename from tools/droiddoc/templates/assets/images/icon_download2.jpg
rename to tools/droiddoc/templates-pdk/assets/images/icon_download2.jpg
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/icon_guidelines_logo.png b/tools/droiddoc/templates-pdk/assets/images/icon_guidelines_logo.png
similarity index 100%
rename from tools/droiddoc/templates/assets/images/icon_guidelines_logo.png
rename to tools/droiddoc/templates-pdk/assets/images/icon_guidelines_logo.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/icon_market.jpg b/tools/droiddoc/templates-pdk/assets/images/icon_market.jpg
similarity index 100%
rename from tools/droiddoc/templates/assets/images/icon_market.jpg
rename to tools/droiddoc/templates-pdk/assets/images/icon_market.jpg
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/icon_robot.jpg b/tools/droiddoc/templates-pdk/assets/images/icon_robot.jpg
similarity index 100%
rename from tools/droiddoc/templates/assets/images/icon_robot.jpg
rename to tools/droiddoc/templates-pdk/assets/images/icon_robot.jpg
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/icon_world.jpg b/tools/droiddoc/templates-pdk/assets/images/icon_world.jpg
similarity index 100%
rename from tools/droiddoc/templates/assets/images/icon_world.jpg
rename to tools/droiddoc/templates-pdk/assets/images/icon_world.jpg
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/left_off.jpg b/tools/droiddoc/templates-pdk/assets/images/left_off.jpg
similarity index 100%
rename from tools/droiddoc/templates/assets/images/left_off.jpg
rename to tools/droiddoc/templates-pdk/assets/images/left_off.jpg
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/left_on.jpg b/tools/droiddoc/templates-pdk/assets/images/left_on.jpg
similarity index 100%
rename from tools/droiddoc/templates/assets/images/left_on.jpg
rename to tools/droiddoc/templates-pdk/assets/images/left_on.jpg
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/logo_breadcrumbz.jpg b/tools/droiddoc/templates-pdk/assets/images/logo_breadcrumbz.jpg
similarity index 100%
rename from tools/droiddoc/templates/assets/images/logo_breadcrumbz.jpg
rename to tools/droiddoc/templates-pdk/assets/images/logo_breadcrumbz.jpg
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/open_source.png b/tools/droiddoc/templates-pdk/assets/images/open_source.png
similarity index 100%
rename from tools/droiddoc/templates/assets/images/open_source.png
rename to tools/droiddoc/templates-pdk/assets/images/open_source.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/preliminary.png b/tools/droiddoc/templates-pdk/assets/images/preliminary.png
similarity index 100%
rename from tools/droiddoc/templates/assets/images/preliminary.png
rename to tools/droiddoc/templates-pdk/assets/images/preliminary.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/resizable-e.gif b/tools/droiddoc/templates-pdk/assets/images/resizable-e.gif
similarity index 100%
rename from tools/droiddoc/templates/assets/images/resizable-e.gif
rename to tools/droiddoc/templates-pdk/assets/images/resizable-e.gif
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/resizable-e2.gif b/tools/droiddoc/templates-pdk/assets/images/resizable-e2.gif
similarity index 100%
rename from tools/droiddoc/templates/assets/images/resizable-e2.gif
rename to tools/droiddoc/templates-pdk/assets/images/resizable-e2.gif
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/resizable-eg.gif b/tools/droiddoc/templates-pdk/assets/images/resizable-eg.gif
similarity index 100%
rename from tools/droiddoc/templates/assets/images/resizable-eg.gif
rename to tools/droiddoc/templates-pdk/assets/images/resizable-eg.gif
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/resizable-s.gif b/tools/droiddoc/templates-pdk/assets/images/resizable-s.gif
similarity index 100%
rename from tools/droiddoc/templates/assets/images/resizable-s.gif
rename to tools/droiddoc/templates-pdk/assets/images/resizable-s.gif
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/resizable-s2.gif b/tools/droiddoc/templates-pdk/assets/images/resizable-s2.gif
similarity index 100%
rename from tools/droiddoc/templates/assets/images/resizable-s2.gif
rename to tools/droiddoc/templates-pdk/assets/images/resizable-s2.gif
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/resizable-sg.gif b/tools/droiddoc/templates-pdk/assets/images/resizable-sg.gif
similarity index 100%
rename from tools/droiddoc/templates/assets/images/resizable-sg.gif
rename to tools/droiddoc/templates-pdk/assets/images/resizable-sg.gif
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/sidenav-rule.png b/tools/droiddoc/templates-pdk/assets/images/sidenav-rule.png
similarity index 100%
rename from tools/droiddoc/templates/assets/images/sidenav-rule.png
rename to tools/droiddoc/templates-pdk/assets/images/sidenav-rule.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/slide_off.jpg b/tools/droiddoc/templates-pdk/assets/images/slide_off.jpg
similarity index 100%
rename from tools/droiddoc/templates/assets/images/slide_off.jpg
rename to tools/droiddoc/templates-pdk/assets/images/slide_off.jpg
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/slide_on.jpg b/tools/droiddoc/templates-pdk/assets/images/slide_on.jpg
similarity index 100%
rename from tools/droiddoc/templates/assets/images/slide_on.jpg
rename to tools/droiddoc/templates-pdk/assets/images/slide_on.jpg
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/spacer.gif b/tools/droiddoc/templates-pdk/assets/images/spacer.gif
similarity index 100%
rename from tools/droiddoc/templates/assets/images/spacer.gif
rename to tools/droiddoc/templates-pdk/assets/images/spacer.gif
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/triangle-closed-small.png b/tools/droiddoc/templates-pdk/assets/images/triangle-closed-small.png
similarity index 100%
rename from tools/droiddoc/templates/assets/images/triangle-closed-small.png
rename to tools/droiddoc/templates-pdk/assets/images/triangle-closed-small.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/triangle-closed.png b/tools/droiddoc/templates-pdk/assets/images/triangle-closed.png
similarity index 100%
rename from tools/droiddoc/templates/assets/images/triangle-closed.png
rename to tools/droiddoc/templates-pdk/assets/images/triangle-closed.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/triangle-opened-small.png b/tools/droiddoc/templates-pdk/assets/images/triangle-opened-small.png
similarity index 100%
rename from tools/droiddoc/templates/assets/images/triangle-opened-small.png
rename to tools/droiddoc/templates-pdk/assets/images/triangle-opened-small.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/triangle-opened.png b/tools/droiddoc/templates-pdk/assets/images/triangle-opened.png
similarity index 100%
rename from tools/droiddoc/templates/assets/images/triangle-opened.png
rename to tools/droiddoc/templates-pdk/assets/images/triangle-opened.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/uiguidelines1.png b/tools/droiddoc/templates-pdk/assets/images/uiguidelines1.png
similarity index 100%
rename from tools/droiddoc/templates/assets/images/uiguidelines1.png
rename to tools/droiddoc/templates-pdk/assets/images/uiguidelines1.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/video-droid.png b/tools/droiddoc/templates-pdk/assets/images/video-droid.png
similarity index 100%
rename from tools/droiddoc/templates/assets/images/video-droid.png
rename to tools/droiddoc/templates-pdk/assets/images/video-droid.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/jdiff_logo.gif b/tools/droiddoc/templates-pdk/assets/jdiff_logo.gif
similarity index 100%
rename from tools/droiddoc/templates/assets/jdiff_logo.gif
rename to tools/droiddoc/templates-pdk/assets/jdiff_logo.gif
Binary files differ
diff --git a/tools/droiddoc/templates/assets/jquery-history.js b/tools/droiddoc/templates-pdk/assets/jquery-history.js
similarity index 100%
rename from tools/droiddoc/templates/assets/jquery-history.js
rename to tools/droiddoc/templates-pdk/assets/jquery-history.js
diff --git a/tools/droiddoc/templates/assets/jquery-resizable.min.js b/tools/droiddoc/templates-pdk/assets/jquery-resizable.min.js
similarity index 100%
rename from tools/droiddoc/templates/assets/jquery-resizable.min.js
rename to tools/droiddoc/templates-pdk/assets/jquery-resizable.min.js
diff --git a/tools/droiddoc/templates/assets/prettify.js b/tools/droiddoc/templates-pdk/assets/prettify.js
similarity index 100%
rename from tools/droiddoc/templates/assets/prettify.js
rename to tools/droiddoc/templates-pdk/assets/prettify.js
diff --git a/tools/droiddoc/templates/assets/search_autocomplete.js b/tools/droiddoc/templates-pdk/assets/search_autocomplete.js
similarity index 100%
rename from tools/droiddoc/templates/assets/search_autocomplete.js
rename to tools/droiddoc/templates-pdk/assets/search_autocomplete.js
diff --git a/tools/droiddoc/templates/assets/style.css b/tools/droiddoc/templates-pdk/assets/style.css
similarity index 100%
rename from tools/droiddoc/templates/assets/style.css
rename to tools/droiddoc/templates-pdk/assets/style.css
diff --git a/tools/droiddoc/templates/assets/triangle-none.gif b/tools/droiddoc/templates-pdk/assets/triangle-none.gif
similarity index 100%
rename from tools/droiddoc/templates/assets/triangle-none.gif
rename to tools/droiddoc/templates-pdk/assets/triangle-none.gif
Binary files differ
diff --git a/tools/droiddoc/templates-pdk/components/left_nav.cs b/tools/droiddoc/templates-pdk/components/left_nav.cs
new file mode 100644
index 0000000..a6d0ae3
--- /dev/null
+++ b/tools/droiddoc/templates-pdk/components/left_nav.cs
@@ -0,0 +1,15 @@
+<?cs def:custom_left_nav() ?>
+  <?cs if:doc.hidenav != "true" ?>
+    <?cs if:doc.type == "source" ?>
+      <?cs call:source_nav() ?>
+    <?cs elif:doc.type == "porting" ?>
+      <?cs call:porting_nav() ?>
+    <?cs elif:doc.type == "compatibility" ?>
+      <?cs call:compatibility_nav() ?>
+    <?cs elif:doc.type == "community" ?>
+      <?cs call:community_nav() ?>
+    <?cs elif:doc.type == "about" ?>
+      <?cs call:about_nav() ?>
+    <?cs /if ?>
+  <?cs /if ?>
+<?cs /def ?>
diff --git a/tools/droiddoc/templates-pdk/components/masthead.cs b/tools/droiddoc/templates-pdk/components/masthead.cs
new file mode 100644
index 0000000..cab58d7
--- /dev/null
+++ b/tools/droiddoc/templates-pdk/components/masthead.cs
@@ -0,0 +1,36 @@
+<?cs 
+def:custom_masthead() ?>
+  <div id="header">
+      <div id="headerLeft">
+          <a href="<?cs var:toroot?>" tabindex="-1"><img
+              src="<?cs var:toroot ?>assets/images/open_source.png" alt="Android Open Source Project" /></a>
+          <ul class="<?cs if:home ?>home<?cs
+                      elif:doc.type == "source" ?>source<?cs
+                      elif:doc.type == "porting" ?>porting<?cs
+                      elif:doc.type == "compatibility" ?>compatibility<?cs
+                      elif:doc.type == "community" ?>community<?cs
+                      elif:doc.type == "about" ?>about<?cs /if ?>">
+              <li id="home-link"><a href="<?cs var:toroot ?>index.html"><span>Home</span></a></li>
+              <li id="source-link"><a href="<?cs var:toroot ?>source/index.html"
+                                  onClick="return loadLast('source')"><span>Source</span></a></li>
+              <li id="porting-link"><a href="<?cs var:toroot ?>porting/index.html"
+                                  onClick="return loadLast('porting')"><span>Porting</span></a></li>
+              <li id="compatibility-link"><a href="<?cs var:toroot ?>compatibility/index.html"
+                                  onClick="return loadLast('compatibility')"><span>Compatibility</span></a></li>
+              <li id="community-link"><a href="<?cs var:toroot ?>community/index.html"
+                                  onClick="return loadLast('community')"><span>Community</span></a></li>
+              <li id="about-link"><a href="<?cs var:toroot ?>about/index.html"
+                                  onClick="return loadLast('about')"><span>About</span></a></li>
+          </ul> 
+      </div>
+      <div id="headerRight">
+          <div id="headerLinks">
+            <!-- <img src="<?cs var:toroot ?>assets/images/icon_world.jpg" alt="" /> -->
+            <span class="text">
+              <!-- &nbsp;<a href="#">English</a> | -->
+              <a href="http://www.android.com">Android.com</a>
+            </span>
+          </div>
+      </div><!-- headerRight -->
+  </div><!-- header --><?cs 
+/def ?><?cs # custom_masthead ?>
diff --git a/tools/droiddoc/templates-pdk/customization.cs b/tools/droiddoc/templates-pdk/customization.cs
deleted file mode 100644
index 3e9be06..0000000
--- a/tools/droiddoc/templates-pdk/customization.cs
+++ /dev/null
@@ -1,182 +0,0 @@
-<?cs # This file defines custom definitions for the masthead (logo, searchbox, tabs, etc) and 
-left nav (toc) that gets placed on all pages, for the open source site?>
-
-<?cs 
-def:custom_masthead() ?>
-  <div id="header">
-      <div id="headerLeft">
-          <a href="<?cs var:toroot?>" tabindex="-1"><img
-              src="<?cs var:toroot ?>assets/images/open_source.png" alt="Android Open Source Project" /></a>
-          <ul class="<?cs if:home ?>home<?cs
-                      elif:doc.type == "source" ?>source<?cs
-                      elif:doc.type == "porting" ?>porting<?cs
-                      elif:doc.type == "compatibility" ?>compatibility<?cs
-                      elif:doc.type == "downloads" ?>downloads<?cs
-                      elif:doc.type == "community" ?>community<?cs
-                      elif:doc.type == "about" ?>about<?cs /if ?>">
-              <li id="home-link"><a href="<?cs var:toroot ?>index.html"><span>Home</span></a></li>
-              <li id="source-link"><a href="<?cs var:toroot ?>source/index.html"
-                                  onClick="return loadLast('source')"><span>Source</span></a></li>
-              <li id="porting-link"><a href="<?cs var:toroot ?>porting/index.html"
-                                  onClick="return loadLast('porting')"><span>Porting</span></a></li>
-              <li id="compatibility-link"><a href="<?cs var:toroot ?>compatibility/index.html"
-                                  onClick="return loadLast('compatibility')"><span>Compatibility</span></a></li>
-              <li id="community-link"><a href="<?cs var:toroot ?>community/index.html"
-                                  onClick="return loadLast('community')"><span>Community</span></a></li>
-              <li id="downloads-link"><a href="<?cs var:toroot ?>downloads/index.html"
-                                  onClick="return loadLast('downloads')"><span>Downloads</span></a></li>
-              <li id="about-link"><a href="<?cs var:toroot ?>about/index.html"
-                                  onClick="return loadLast('about')"><span>About</span></a></li>
-          </ul> 
-      </div>
-      <div id="headerRight">
-          <div id="headerLinks">
-            <!-- <img src="<?cs var:toroot ?>assets/images/icon_world.jpg" alt="" /> -->
-            <span class="text">
-              <!-- &nbsp;<a href="#">English</a> | -->
-              <a href="http://www.android.com">Android.com</a>
-            </span>
-          </div>
-      </div><!-- headerRight -->
-  </div><!-- header --><?cs 
-/def ?><?cs # custom_masthead ?>
-
-
-<?cs def:community_nav() ?>
-  <div class="g-section g-tpl-240" id="body-content">
-    <div class="g-unit g-first side-nav-resizable" id="side-nav">
-      <div id="devdoc-nav"><?cs 
-        include:"../../../../development/pdk/docs/community/community_toc.cs" ?>
-      </div>
-    </div> <!-- end side-nav -->
-    <script>
-      addLoadEvent(function() {
-        scrollIntoView("devdoc-nav");
-        });
-    </script>
-  </div>
-<?cs /def ?>
-
-<?cs def:about_nav() ?>
-  <div class="g-section g-tpl-240" id="body-content">
-    <div class="g-unit g-first side-nav-resizable" id="side-nav">
-      <div id="devdoc-nav"><?cs
-        include:"../../../../development/pdk/docs/about/about_toc.cs" ?>
-      </div>
-    </div> <!-- end side-nav -->
-    <script>
-      addLoadEvent(function() {
-        scrollIntoView("devdoc-nav");
-        });
-    </script>
-  </div>
-<?cs /def ?>
-
-<?cs def:porting_nav() ?>
-  <div class="g-section g-tpl-240" id="body-content">
-    <div class="g-unit g-first side-nav-resizable" id="side-nav">
-      <div id="devdoc-nav"><?cs
-        include:"../../../../development/pdk/docs/porting/porting_toc.cs" ?>
-      </div>
-    </div> <!-- end side-nav -->
-    <script>
-      addLoadEvent(function() {
-        scrollIntoView("devdoc-nav");
-        });
-    </script>
-  </div>
-<?cs /def ?>
-
-<?cs def:source_nav() ?>
-  <div class="g-section g-tpl-240" id="body-content">
-    <div class="g-unit g-first side-nav-resizable" id="side-nav">
-      <div id="devdoc-nav"><?cs
-        include:"../../../../development/pdk/docs/source/source_toc.cs" ?>
-      </div>
-    </div> <!-- end side-nav -->
-    <script>
-      addLoadEvent(function() {
-        scrollIntoView("devdoc-nav");
-        });
-    </script>
-  </div>
-<?cs /def ?>
-
-<?cs def:downloads_nav() ?>
-  <div class="g-section g-tpl-240" id="body-content">
-    <div class="g-unit g-first side-nav-resizable" id="side-nav">
-      <div id="devdoc-nav"><?cs
-        include:"../../../../development/pdk/docs/downloads/downloads_toc.cs" ?>
-      </div>
-    </div> <!-- end side-nav -->
-    <script>
-      addLoadEvent(function() {
-        scrollIntoView("devdoc-nav");
-        });
-    </script>
-  </div>
-<?cs /def ?>
-
-<?cs def:compatibility_nav() ?>
-  <div class="g-section g-tpl-240" id="body-content">
-    <div class="g-unit g-first side-nav-resizable" id="side-nav">
-      <div id="devdoc-nav"><?cs
-        include:"../../../../development/pdk/docs/compatibility/compatibility_toc.cs" ?>
-      </div>
-    </div> <!-- end side-nav -->
-    <script>
-      addLoadEvent(function() {
-        scrollIntoView("devdoc-nav");
-        });
-    </script>
-  </div>
-<?cs /def ?>
-
-<?cs def:custom_left_nav() ?>
-  <?cs if:doc.hidenav != "true" ?>
-    <?cs if:doc.type == "source" ?>
-      <?cs call:source_nav() ?>
-    <?cs elif:doc.type == "porting" ?>
-      <?cs call:porting_nav() ?>
-    <?cs elif:doc.type == "compatibility" ?>
-      <?cs call:compatibility_nav() ?>
-    <?cs elif:doc.type == "downloads" ?>
-      <?cs call:downloads_nav() ?>
-    <?cs elif:doc.type == "community" ?>
-      <?cs call:community_nav() ?>
-    <?cs elif:doc.type == "about" ?>
-      <?cs call:about_nav() ?>
-    <?cs /if ?>
-  <?cs /if ?>
-<?cs /def ?>
-
-<?cs # appears at the bottom of every page ?><?cs 
-def:custom_cc_copyright() ?>
-  Except as noted, this content is 
-  licensed under <a href="http://creativecommons.org/licenses/by/2.5/">
-  Creative Commons Attribution 2.5</a>. For details and 
-  restrictions, see the <a href="http://developer.android.com/license.html">Content 
-  License</a>.<?cs 
-/def ?>
-
-<?cs 
-def:custom_copyright() ?>
-  Except as noted, this content is licensed under <a
-  href="http://www.apache.org/licenses/LICENSE-2.0">Apache 2.0</a>. 
-  For details and restrictions, see the <a href="http://developer.android.com/license.html">
-  Content License</a>.<?cs 
-/def ?>
-
-<?cs 
-def:custom_footerlinks() ?>
-  <p>
-    <a href="http://www.android.com/terms.html">Site Terms of Service</a> -
-    <a href="http://www.android.com/privacy.html">Privacy Policy</a> -
-    <a href="http://www.android.com/branding.html">Brand Guidelines</a>
-  </p><?cs 
-/def ?>
-
-<?cs # appears on the right side of the blue bar at the bottom off every page ?><?cs 
-def:custom_buildinfo() ?>
-  Android <?cs var:sdk.platform.version ?>&nbsp;r<?cs var:sdk.rel.id ?> - <?cs var:page.now ?>
-<?cs /def ?>
diff --git a/tools/droiddoc/templates-pdk/customizations.cs b/tools/droiddoc/templates-pdk/customizations.cs
new file mode 100644
index 0000000..b0f90a7
--- /dev/null
+++ b/tools/droiddoc/templates-pdk/customizations.cs
@@ -0,0 +1,91 @@
+<?cs # This file defines custom definitions for the masthead (logo, searchbox, tabs, etc) and 
+left nav (toc) that gets placed on all pages, for the open source site. See also the components/
+directory. ?>
+
+<?cs def:community_nav() ?>
+  <div class="g-section g-tpl-240" id="body-content">
+    <div class="g-unit g-first side-nav-resizable" id="side-nav">
+      <div id="devdoc-nav"><?cs 
+        include:"../../../../development/pdk/docs/community/community_toc.cs" ?>
+      </div>
+    </div> <!-- end side-nav -->
+    <script>
+      addLoadEvent(function() {
+        scrollIntoView("devdoc-nav");
+        });
+    </script>
+  </div>
+<?cs /def ?>
+<?cs def:about_nav() ?>
+  <div class="g-section g-tpl-240" id="body-content">
+    <div class="g-unit g-first side-nav-resizable" id="side-nav">
+      <div id="devdoc-nav"><?cs
+        include:"../../../../development/pdk/docs/about/about_toc.cs" ?>
+      </div>
+    </div> <!-- end side-nav -->
+    <script>
+      addLoadEvent(function() {
+        scrollIntoView("devdoc-nav");
+        });
+    </script>
+  </div>
+<?cs /def ?>
+<?cs def:porting_nav() ?>
+  <div class="g-section g-tpl-240" id="body-content">
+    <div class="g-unit g-first side-nav-resizable" id="side-nav">
+      <div id="devdoc-nav"><?cs
+        include:"../../../../development/pdk/docs/porting/porting_toc.cs" ?>
+      </div>
+    </div> <!-- end side-nav -->
+    <script>
+      addLoadEvent(function() {
+        scrollIntoView("devdoc-nav");
+        });
+    </script>
+  </div>
+<?cs /def ?>
+<?cs def:source_nav() ?>
+  <div class="g-section g-tpl-240" id="body-content">
+    <div class="g-unit g-first side-nav-resizable" id="side-nav">
+      <div id="devdoc-nav"><?cs
+        include:"../../../../development/pdk/docs/source/source_toc.cs" ?>
+      </div>
+    </div> <!-- end side-nav -->
+    <script>
+      addLoadEvent(function() {
+        scrollIntoView("devdoc-nav");
+        });
+    </script>
+  </div>
+<?cs /def ?>
+<?cs def:compatibility_nav() ?>
+  <div class="g-section g-tpl-240" id="body-content">
+    <div class="g-unit g-first side-nav-resizable" id="side-nav">
+      <div id="devdoc-nav"><?cs
+        include:"../../../../development/pdk/docs/compatibility/compatibility_toc.cs" ?>
+      </div>
+    </div> <!-- end side-nav -->
+    <script>
+      addLoadEvent(function() {
+        scrollIntoView("devdoc-nav");
+        });
+    </script>
+  </div>
+<?cs /def ?>
+<?cs def:custom_cc_copyright() ?>
+<?cs /def ?>
+
+<?cs def:custom_copyright() ?>
+<?cs /def ?>
+
+<?cs 
+def:custom_footerlinks() ?>
+  <p>
+    <a href="http://www.android.com/terms.html">Site Terms of Service</a> -
+    <a href="http://www.android.com/privacy.html">Privacy Policy</a>
+  </p><?cs 
+/def ?>
+
+<?cs # appears on the right side of the blue bar at the bottom off every page ?>
+<?cs def:custom_buildinfo() ?>
+<?cs /def ?>
diff --git a/tools/droiddoc/templates/footer.cs b/tools/droiddoc/templates-pdk/footer.cs
similarity index 100%
rename from tools/droiddoc/templates/footer.cs
rename to tools/droiddoc/templates-pdk/footer.cs
diff --git a/tools/droiddoc/templates-pdk/head_tag.cs b/tools/droiddoc/templates-pdk/head_tag.cs
index 915dc0e..cccbb14 100644
--- a/tools/droiddoc/templates-pdk/head_tag.cs
+++ b/tools/droiddoc/templates-pdk/head_tag.cs
@@ -1,6 +1,6 @@
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
-<link rel="shortcut icon" type="image/x-icon" href="<?cs var:toroot ?>assets-pdk/favicon.ico" />
+<link rel="shortcut icon" type="image/x-icon" href="<?cs var:toroot ?>assets/favicon.ico" />
 <title><?cs 
   if:page.title ?><?cs 
     var:page.title ?><?cs
@@ -9,7 +9,7 @@
     /if ?> | <?cs
   /if ?>Android Open Source</title>
 <link href="<?cs var:toroot ?>assets/android-developer-docs-devguide.css" rel="stylesheet" type="text/css" />
-<link href="<?cs var:toroot ?>assets-pdk/pdk-local.css" rel="stylesheet" type="text/css" />
+<!-- <link href="<?cs var:toroot ?>assets-pdk/pdk-local.css" rel="stylesheet" type="text/css" /> -->
 <script src="<?cs var:toroot ?>assets/search_autocomplete.js" type="text/javascript"></script>
 <script src="<?cs var:toroot ?>assets/jquery-resizable.min.js" type="text/javascript"></script>
 <script src="<?cs var:toroot ?>assets/android-developer-docs.js" type="text/javascript"></script>
@@ -28,7 +28,7 @@
 	}
 }
 </script>
-<script type="text/javascript>
+<script type="text/javascript">
   jQuery(document).ready(function() {
         jQuery("pre").addClass("prettyprint");
   });
diff --git a/tools/droiddoc/templates/trailer.cs b/tools/droiddoc/templates-pdk/trailer.cs
similarity index 100%
rename from tools/droiddoc/templates/trailer.cs
rename to tools/droiddoc/templates-pdk/trailer.cs
diff --git a/tools/droiddoc/templates-sdk/assets-sdk/placeholder b/tools/droiddoc/templates-sdk/assets-sdk/placeholder
deleted file mode 100644
index e69de29..0000000
--- a/tools/droiddoc/templates-sdk/assets-sdk/placeholder
+++ /dev/null
diff --git a/tools/droiddoc/templates/assets/android-developer-core.css b/tools/droiddoc/templates-sdk/assets/android-developer-core.css
similarity index 99%
rename from tools/droiddoc/templates/assets/android-developer-core.css
rename to tools/droiddoc/templates-sdk/assets/android-developer-core.css
index 40ab2fd..565f173 100644
--- a/tools/droiddoc/templates/assets/android-developer-core.css
+++ b/tools/droiddoc/templates-sdk/assets/android-developer-core.css
@@ -59,7 +59,7 @@
   padding:0 4px;
 }
 
-p {
+p, form {
   padding:0;
   margin:0 0 1em;
 }
@@ -197,7 +197,7 @@
 
 #body-content {
   /* "Preliminary" watermark for preview releases and interim builds.
-  background:transparent url(images/preliminary.png) repeat scroll 0 0;  */
+  background:transparent url(images/preliminary.png) repeat scroll 0 0; */
   margin:0;
   position:relative;
   width:100%;
@@ -1139,6 +1139,7 @@
 #mainBodyRight ul.videoPreviews h3 {
   padding:0;
   margin:0;
+  font-size:100%;
 }
 
 #mainBodyRight ul.videoPreviews a {
diff --git a/tools/droiddoc/templates/assets/android-developer-docs-devguide.css b/tools/droiddoc/templates-sdk/assets/android-developer-docs-devguide.css
similarity index 100%
copy from tools/droiddoc/templates/assets/android-developer-docs-devguide.css
copy to tools/droiddoc/templates-sdk/assets/android-developer-docs-devguide.css
diff --git a/tools/droiddoc/templates/assets/android-developer-docs.css b/tools/droiddoc/templates-sdk/assets/android-developer-docs.css
similarity index 95%
rename from tools/droiddoc/templates/assets/android-developer-docs.css
rename to tools/droiddoc/templates-sdk/assets/android-developer-docs.css
index 1672c93..22d010a 100644
--- a/tools/droiddoc/templates/assets/android-developer-docs.css
+++ b/tools/droiddoc/templates-sdk/assets/android-developer-docs.css
@@ -61,7 +61,7 @@
 }
 
 #side-nav ul ul {
-  margin: .35em 0 0 0;
+  margin: .5em 0 0 0;
   padding: 0;
 }
 
@@ -517,16 +517,24 @@
 }
 
 #jd-content h3 {
-  font-size:1.2em;
-  color:#222;
-  padding: .75em 0 .65em 0;
-  margin:0;
+  font-size:1.3em;
+  color:#3a3a3a;
+  padding: 0;
+  margin: 1.5em 0 .65em 0;
 }
 
 #jd-content h4 {
   font-size:1.1em;
-  margin-bottom:.5em;
-  color:#222;
+  color:#3a3a3a;
+  padding: 0;
+  margin: 1.25em 0 .65em 0;
+}
+
+#jd-content h5 {
+  font-size:1.0em;
+  color:#3a3a3a;
+  padding: 0;
+  margin: 1em 0 .65em 0;
 }
 
 #jd-content .small-header {
@@ -688,22 +696,6 @@
   -webkit-border-radius:5px;
 }
 
-.toggle-content-toggleme {
-  display:none;
-}
-
-.toggle-content-button {
-  font-size:.9em;
-  line-height:.9em;
-  text-decoration:none;
-  position:relative;
-  top:5px;
-}
-
-.toggle-content-button:hover {
-  text-decoration:underline;
-}
-
 div.special p {
   margin: .5em 0 0 0;
 }
@@ -756,11 +748,21 @@
   border-color: #ffcf00;
 }
 
-li p.note, li p.warning {
+li .note,
+li .caution,
+li .warning {
   margin: .5em 0 0 0;
   padding: .2em .5em .2em .9em;
 }
 
+/* Makes sure the first paragraph does not add top-whitespace within the box*/
+li .note>p:first-child,
+li .caution>p:first-child,
+li .warning>p:first-child {
+  margin-top:0;
+  padding-top:0;
+}
+
 dl.xml dt {
   font-variant:small-caps;
   font-size:1.2em;
@@ -789,7 +791,8 @@
   padding-left:1em;
 }
 
-.new {
+.new,
+.new-child {
   font-size: .78em;
   font-weight: bold;
   color: #ff3d3d;
@@ -798,6 +801,10 @@
   line-height:.9em;
 }
 
+.toggle-list.open .new-child {
+  display:none;
+}
+
 pre.classic {
   background-color:transparent;
   border:none;
@@ -830,6 +837,27 @@
   margin: 0 0 0.5em 1em; /* matches default table left-margin */
 }
 
+
+/* toggle for misc content (such as long sample code) 
+   see toggleContent() script in android-developer-docs.js */
+.toggle-content.closed .toggle-content-toggleme {
+  display:none;
+}
+
+.toggle-content a[href="#"] {
+  text-decoration:none;
+  color:inherit;
+}
+
+.toggle-content-toggleme {
+  padding-bottom:1px; /* fixes animation bounce due to margins */
+}
+
+#jd-content .toggle-content img.toggle-content-img {
+  margin:0;
+}
+
+
 /* BEGIN quickview sidebar element styles */
 
 #qv-wrapper {
@@ -892,20 +920,6 @@
   padding:0 10px;
 }
 
-#qv-extra #rule {
-  padding: 0 10px;
-  margin: 0;
-}
-
-#qv-sub-rule {
-  padding: 6px 20px;
-  margin: 0;
-}
-
-#qv-sub-rule p {
-  margin: 0;
-}
-
 #jd-content #qv h2 {
   font-size:1.05em;
   font-weight:bold;
@@ -918,6 +932,21 @@
   z-index:1;
 }
 
+#qv-extra #rule {
+  padding: 0 10px;
+  margin: 0;
+}
+
+#qv-sub-rule {
+  padding: 5px 15px 10px;
+  margin: 0;
+}
+
+#jd-content
+#qv-sub-rule h2 {
+  margin: 0 0 .5em 0;
+}
+
 /* END quickview sidebar element styles */
 
 /* Begin sidebox sidebar element styles */
diff --git a/tools/droiddoc/templates/assets/android-developer-docs.js b/tools/droiddoc/templates-sdk/assets/android-developer-docs.js
similarity index 74%
rename from tools/droiddoc/templates/assets/android-developer-docs.js
rename to tools/droiddoc/templates-sdk/assets/android-developer-docs.js
index 5262bd8..728e015 100644
--- a/tools/droiddoc/templates/assets/android-developer-docs.js
+++ b/tools/droiddoc/templates-sdk/assets/android-developer-docs.js
@@ -27,10 +27,10 @@
 
 var agent = navigator['userAgent'].toLowerCase();
 // If a mobile phone, set flag and do mobile setup
-if ((agent.indexOf("mobile") != -1) ||      // android, iphone, ipod 
+if ((agent.indexOf("mobile") != -1) ||      // android, iphone, ipod
     (agent.indexOf("blackberry") != -1) ||
     (agent.indexOf("webos") != -1) ||
-    (agent.indexOf("mini") != -1)) {        // opera mini browsers 
+    (agent.indexOf("mini") != -1)) {        // opera mini browsers
   isMobile = true;
   addLoadEvent(mobileSetup);
 // If not a mobile browser, set the onresize event for IE6, and others
@@ -126,7 +126,7 @@
     expiration = date.toGMTString();
   }
   document.cookie = cookie_namespace + section + cookie + "=" + val + "; expires=" + expiration+"; path=/";
-} 
+}
 
 function init() {
   $("#side-nav").css({position:"absolute",left:0});
@@ -164,11 +164,84 @@
     }
   }
 
-  if (devdocNav.length) { // only dev guide and sdk 
-    highlightNav(location.href); 
+  if (devdocNav.length) { // only dev guide, resources, and sdk
+    tryPopulateResourcesNav();
+    highlightNav(location.href);
   }
 }
 
+function tryPopulateResourcesNav() {
+  var sampleList = $('#devdoc-nav-sample-list');
+  var articleList = $('#devdoc-nav-article-list');
+  var tutorialList = $('#devdoc-nav-tutorial-list');
+  var topicList = $('#devdoc-nav-topic-list');
+
+  if (!topicList.length || !ANDROID_TAGS || !ANDROID_RESOURCES)
+    return;
+
+  var topics = [];
+  for (var topic in ANDROID_TAGS['topic']) {
+    topics.push({name:topic,title:ANDROID_TAGS['topic'][topic]});
+  }
+  topics.sort(function(x,y){ return (x.title < y.title) ? -1 : 1; });
+  for (var i = 0; i < topics.length; i++) {
+    topicList.append(
+        $('<li>').append(
+          $('<a>')
+            .attr('href', toRoot + "resources/browser.html?tag=" + topics[i].name)
+            .append($('<span>')
+              .addClass('en')
+              .html(topics[i].title)
+            )
+          )
+        );
+  }
+
+  var _renderResourceList = function(tag, listNode) {
+    var resources = [];
+    var tags;
+    var resource;
+    var i, j;
+    for (i = 0; i < ANDROID_RESOURCES.length; i++) {
+      resource = ANDROID_RESOURCES[i];
+      tags = resource.tags || [];
+      var hasTag = false;
+      for (j = 0; j < tags.length; j++)
+        if (tags[j] == tag) {
+          hasTag = true;
+          break;
+        }
+      if (!hasTag)
+        continue;
+      resources.push(resource);
+    }
+    //resources.sort(function(x,y){ return (x.title.en < y.title.en) ? -1 : 1; });
+    for (i = 0; i < resources.length; i++) {
+      resource = resources[i];
+      var listItemNode = $('<li>').append(
+          $('<a>')
+            .attr('href', toRoot + "resources/" + resource.path)
+            .append($('<span>')
+              .addClass('en')
+              .html(resource.title.en)
+            )
+          );
+      tags = resource.tags || [];
+      for (j = 0; j < tags.length; j++) {
+        if (tags[j] == 'new') {
+          listItemNode.get(0).innerHTML += '&nbsp;<span class="new">new!</span>';
+          break;
+        }
+      }
+      listNode.append(listItemNode);
+    }
+  };
+
+  _renderResourceList('sample', sampleList);
+  _renderResourceList('article', articleList);
+  _renderResourceList('tutorial', tutorialList);
+}
+
 function highlightNav(fullPageName) {
   var lastSlashPos = fullPageName.lastIndexOf("/");
   var firstSlashPos;
@@ -182,17 +255,23 @@
   if (lastSlashPos == (fullPageName.length - 1)) { // if the url ends in slash (add 'index.html')
     fullPageName = fullPageName + "index.html";
   }
-  var htmlPos = fullPageName.lastIndexOf(".html", fullPageName.length);
-  var pathPageName = fullPageName.slice(firstSlashPos, htmlPos + 5);
+  // First check if the exact URL, with query string and all, is in the navigation menu
+  var pathPageName = fullPageName.substr(firstSlashPos);
   var link = $("#devdoc-nav a[href$='"+ pathPageName+"']");
-  if ((link.length == 0) && ((fullPageName.indexOf("/guide/") != -1) || (fullPageName.indexOf("/resources/") != -1))) { 
-// if there's no match, then let's backstep through the directory until we find an index.html page that matches our ancestor directories (only for dev guide and resources)
-    lastBackstep = pathPageName.lastIndexOf("/");
-    while (link.length == 0) {
-      backstepDirectory = pathPageName.lastIndexOf("/", lastBackstep);
-      link = $("#devdoc-nav a[href$='"+ pathPageName.slice(0, backstepDirectory + 1)+"index.html']");
-      lastBackstep = pathPageName.lastIndexOf("/", lastBackstep - 1);
-      if (lastBackstep == 0) break;
+  if (link.length == 0) {
+    var htmlPos = fullPageName.lastIndexOf(".html", fullPageName.length);
+    pathPageName = fullPageName.slice(firstSlashPos, htmlPos + 5); // +5 advances past ".html"
+    link = $("#devdoc-nav a[href$='"+ pathPageName+"']");
+    if ((link.length == 0) && ((fullPageName.indexOf("/guide/") != -1) || (fullPageName.indexOf("/resources/") != -1))) {
+      // if there's no match, then let's backstep through the directory until we find an index.html page
+      // that matches our ancestor directories (only for dev guide and resources)
+      lastBackstep = pathPageName.lastIndexOf("/");
+      while (link.length == 0) {
+        backstepDirectory = pathPageName.lastIndexOf("/", lastBackstep);
+        link = $("#devdoc-nav a[href$='"+ pathPageName.slice(0, backstepDirectory + 1)+"index.html']");
+        lastBackstep = pathPageName.lastIndexOf("/", lastBackstep - 1);
+        if (lastBackstep == 0) break;
+      }
     }
   }
 
@@ -423,26 +502,37 @@
   if (navObj.is(':visible')) {
     var selected = $(".selected", navObj);
     if (selected.length == 0) return;
-    if (selected.is("div")) selected = selected.parent();
+    if (selected.is("div")) selected = selected.parent(); // when the selected item is a parent
 
     var scrolling = document.getElementById(nav);
     var navHeight = navObj.height();
     var offsetTop = selected.position().top;
-    if (selected.parent().parent().is(".toggle-list")) offsetTop += selected.parent().parent().position().top;
-    if(offsetTop > navHeight - 92) {
-      scrolling.scrollTop = offsetTop - navHeight + 92;
+
+    // handle nested items
+    if (selected.parent().parent().is(".toggle-list")) {
+      selected = selected.parent().parent();
+      // handle second level nested items
+      if (selected.parent().parent().is(".toggle-list")) {
+        selected = selected.parent().parent();
+      }
+      offsetTop += selected.position().top;
+    }
+
+    // 180px from the bottom of the list is the threshold
+    if(offsetTop > navHeight - 180) {
+      scrolling.scrollTop = offsetTop - navHeight + 180;
     }
   }
 }
 
 function changeTabLang(lang) {
   var nodes = $("#header-tabs").find("."+lang);
-  for (i=0; i < nodes.length; i++) { // for each node in this language 
+  for (i=0; i < nodes.length; i++) { // for each node in this language
     var node = $(nodes[i]);
-    node.siblings().css("display","none"); // hide all siblings 
-    if (node.not(":empty").length != 0) { //if this languages node has a translation, show it 
+    node.siblings().css("display","none"); // hide all siblings
+    if (node.not(":empty").length != 0) { //if this languages node has a translation, show it
       node.css("display","inline");
-    } else { //otherwise, show English instead 
+    } else { //otherwise, show English instead
       node.css("display","none");
       node.siblings().filter(".en").css("display","inline");
     }
@@ -451,12 +541,12 @@
 
 function changeNavLang(lang) {
   var nodes = $("#side-nav").find("."+lang);
-  for (i=0; i < nodes.length; i++) { // for each node in this language 
+  for (i=0; i < nodes.length; i++) { // for each node in this language
     var node = $(nodes[i]);
-    node.siblings().css("display","none"); // hide all siblings 
-    if (node.not(":empty").length != 0) { // if this languages node has a translation, show it 
+    node.siblings().css("display","none"); // hide all siblings
+    if (node.not(":empty").length != 0) { // if this languages node has a translation, show it
       node.css("display","inline");
-    } else { // otherwise, show English instead 
+    } else { // otherwise, show English instead
       node.css("display","none");
       node.siblings().filter(".en").css("display","inline");
     }
@@ -496,16 +586,22 @@
 }
 
 
+/* Used to hide and reveal supplemental content, such as long code samples.
+   See the companion CSS in android-developer-docs.css */
 function toggleContent(obj) {
-  var button = $(obj);
-  var div = $(obj.parentNode);
+  var div = $(obj.parentNode.parentNode);
   var toggleMe = $(".toggle-content-toggleme",div);
-  if (button.hasClass("show")) {
+  if (div.hasClass("closed")) { // if it's closed, open it
     toggleMe.slideDown();
-    button.removeClass("show").addClass("hide");
-  } else {
-    toggleMe.slideUp();
-    button.removeClass("hide").addClass("show");
+    $(".toggle-content-text", obj).toggle();
+    div.removeClass("closed").addClass("open");
+    $(".toggle-content-img", div).attr("title", "hide").attr("src", toRoot + "assets/images/triangle-opened.png");
+  } else { // if it's open, close it
+    toggleMe.slideUp('fast', function() {  // Wait until the animation is done before closing arrow
+      $(".toggle-content-text", obj).toggle();
+      div.removeClass("open").addClass("closed");
+      $(".toggle-content-img", div).attr("title", "show").attr("src", toRoot + "assets/images/triangle-closed.png");
+    });
   }
-  $("span", button).toggle();
+  return false;
 }
diff --git a/tools/droiddoc/templates/assets/android-developer-reference.js b/tools/droiddoc/templates-sdk/assets/android-developer-reference.js
similarity index 100%
rename from tools/droiddoc/templates/assets/android-developer-reference.js
rename to tools/droiddoc/templates-sdk/assets/android-developer-reference.js
diff --git a/tools/droiddoc/templates-sdk/assets/android-developer-resource-browser.css b/tools/droiddoc/templates-sdk/assets/android-developer-resource-browser.css
new file mode 100644
index 0000000..a454caa
--- /dev/null
+++ b/tools/droiddoc/templates-sdk/assets/android-developer-resource-browser.css
@@ -0,0 +1,31 @@
+/* Resource Browser */
+
+#resource-browser-results .no-results {
+  font-style: italic;
+  display: none;
+}
+
+#resource-browser-results .result {
+  position: relative;
+  padding-left: 84px;
+  background: transparent none no-repeat scroll 4px 12px;
+  border-bottom: 1px solid #ddd;
+}
+
+#resource-browser-results .tagged-article {
+  background-image: url(images/resource-article.png);
+}
+
+#resource-browser-results .tagged-sample {
+  background-image: url(images/resource-sample.png);
+}
+
+#resource-browser-results .tagged-tutorial {
+  background-image: url(images/resource-tutorial.png);
+}
+
+#resource-browser-results .resource-meta {
+  margin-top: -1em;
+  font-size: 0.85em;
+  font-weight: normal;
+}
diff --git a/tools/droiddoc/templates-sdk/assets/android-developer-resource-browser.js b/tools/droiddoc/templates-sdk/assets/android-developer-resource-browser.js
new file mode 100644
index 0000000..dc65aa2
--- /dev/null
+++ b/tools/droiddoc/templates-sdk/assets/android-developer-resource-browser.js
@@ -0,0 +1,235 @@
+(function() { // anonymize
+
+var allTags = {};
+var loadedResults = [];
+
+/**
+ * Initialization code run upon the DOM being ready.
+ */
+$(document).ready(function() {
+  // Parse page query parameters.
+  var params = parseParams(document.location.search);
+  params.tag = params.tag ? makeArray(params.tag) : null;
+
+  // Load tag and resource dataset.
+  loadTags();
+  loadResources();
+
+  showResults(params);
+
+  // Watch for keypresses in the keyword filter textbox, and update
+  // search results to reflect the keyword filter.
+  $('#resource-browser-keyword-filter').keyup(function() {
+    // Filter results on screen by keyword.
+    var keywords = $(this).val().split(/\s+/g);
+    for (var i = 0; i < loadedResults.length; i++) {
+      var hide = false;
+      for (var j = 0; j < keywords.length; j++) {
+        if (!resultMatchesKeyword(loadedResults[i].result, keywords[j])) {
+          hide = true;
+          break;
+        }
+      }
+
+      loadedResults[i].node[hide ? 'hide' : 'show']();
+    }
+  });
+});
+
+/**
+ * Returns whether or not the given search result contains the given keyword.
+ */
+function resultMatchesKeyword(result, keyword) {
+  keyword = keyword.toLowerCase();
+  if (result.title &&
+      result.title.en.toLowerCase().indexOf(keyword) >= 0)
+    return true;
+  else if (result.description &&
+           result.description.en.toLowerCase().indexOf(keyword) >= 0)
+    return true;
+  else if (result.topicsHtml &&
+           result.topicsHtml.replace(/\<.*?\>/g,'').toLowerCase().indexOf(keyword) >= 0)
+    return true;
+  return false;
+}
+
+/**
+ * Populates the allTags array with tag data from the ANDROID_TAGS
+ * variable in the resource data JS file.
+ */
+function loadTags() {
+  for (var tagClass in ANDROID_TAGS) {
+    for (var tag in ANDROID_TAGS[tagClass]) {
+      allTags[tag] = {
+        displayTag: ANDROID_TAGS[tagClass][tag],
+        tagClass: tagClass
+      };
+    }
+  }
+}
+
+/**
+ * Massage the ANDROID_RESOURCES resource list in the resource data JS file.
+ */
+function loadResources() {
+  for (var i = 0; i < ANDROID_RESOURCES.length; i++) {
+    var resource = ANDROID_RESOURCES[i];
+
+    // Convert the tags array to a tags hash for easier querying.
+    resource.tagsHash = {};
+    for (var j = 0; j < resource.tags.length; j++)
+      resource.tagsHash[resource.tags[j]] = true;
+
+    // Determine the type and topics of the resource by inspecting its tags.
+    resource.topics = [];
+    for (tag in resource.tagsHash)
+      if (tag in allTags) {
+        if (allTags[tag].tagClass == 'type') {
+          resource.type = tag;
+        } else if (allTags[tag].tagClass == 'topic') {
+          resource.topics.push(tag);
+        }
+      }
+
+    // Add a humanized topics list string.
+    resource.topicsHtml = humanizeList(resource.topics, function(item) {
+      return '<strong>' + allTags[item].displayTag + '</strong>';
+    });
+  }
+}
+
+/**
+ * Loads resources for the given query parameters.
+ */
+function showResults(params) {
+  loadedResults = [];
+  $('#resource-browser-search-params').empty();
+  $('#resource-browser-results').empty();
+
+  var i, j;
+  var searchTags = [];
+  if (params.tag) {
+    for (i = 0; i < params.tag.length; i++) {
+      var tag = params.tag[i];
+      if (tag.toLowerCase() in allTags) {
+        searchTags.push(tag.toLowerCase());
+      }
+    }
+  }
+
+  if (searchTags.length) {
+    // Show query params.
+    var taggedWithHtml = ['Showing technical resources tagged with '];
+    taggedWithHtml.push(humanizeList(searchTags, function(item) {
+      return '<strong>' + allTags[item].displayTag + '</strong>';
+    }));
+    $('#resource-browser-search-params').html(taggedWithHtml.join('') + ':');
+  } else {
+    $('#resource-browser-search-params').html('Showing all technical resources:');
+  }
+
+  var results = [];
+
+  // Create the list of resources to show.
+  for (i = 0; i < ANDROID_RESOURCES.length; i++) {
+    var resource = ANDROID_RESOURCES[i];
+    var skip = false;
+
+    if (searchTags.length) {
+      for (j = 0; j < searchTags.length; j++)
+        if (!(searchTags[j] in resource.tagsHash)) {
+          skip = true;
+          break;
+        }
+
+      if (skip)
+        continue;
+
+      results.push(resource);
+      continue;
+    }
+
+    results.push(resource);
+  }
+
+  // Format and show the list of resource results.
+  if (results.length) {
+    $('#resource-browser-results .no-results').hide();
+    for (i = 0; i < results.length; i++) {
+      var result = results[i];
+      var resultJqNode = $(tmpl('tmpl_resource_browser_result', result));
+      for (tag in result.tagsHash)
+        resultJqNode.addClass('tagged-' + tag);
+      $('#resource-browser-results').append(resultJqNode);
+
+      loadedResults.push({ node: resultJqNode, result: result });
+    }
+  } else {
+    $('#resource-browser-results .no-results').show();
+  }
+}
+
+/**
+ * Formats the given array into a human readable, English string, ala
+ * 'a, b and c', with an optional item formatter/wrapper function.
+ */
+function humanizeList(arr, itemFormatter) {
+  itemFormatter = itemFormatter || function(o){ return o; };
+  arr = arr || [];
+
+  var out = [];
+  for (var i = 0; i < arr.length; i++) {
+    out.push(itemFormatter(arr[i]) +
+        ((i < arr.length - 2) ? ', ' : '') +
+        ((i == arr.length - 2) ? ' and ' : ''));
+  }
+
+  return out.join('');
+}
+
+/**
+ * Parses a parameter string, i.e. foo=1&bar=2 into
+ * a dictionary object.
+ */
+function parseParams(paramStr) {
+  var params = {};
+  paramStr = paramStr.replace(/^[?#]/, '');
+
+  var pairs = paramStr.split('&');
+  for (var i = 0; i < pairs.length; i++) {
+    var p = pairs[i].split('=');
+    var key = p[0] ? decodeURIComponent(p[0]) : p[0];
+    var val = p[1] ? decodeURIComponent(p[1]) : p[1];
+    if (val === '0')
+      val = 0;
+    if (val === '1')
+      val = 1;
+
+    if (key in params) {
+      // Handle array values.
+      params[key] = makeArray(params[key]);
+      params[key].push(val);
+    } else {
+      params[key] = val;
+    }
+  }
+
+  return params;
+}
+
+/**
+ * Returns the argument as a single-element array, or the argument itself
+ * if it's already an array.
+ */
+function makeArray(o) {
+  if (!o)
+    return [];
+
+  if (typeof o === 'object' && 'splice' in o) {
+    return o;
+  } else {
+    return [o];
+  }
+}
+
+})();
diff --git a/tools/droiddoc/templates/assets/carousel.js b/tools/droiddoc/templates-sdk/assets/carousel.js
similarity index 100%
copy from tools/droiddoc/templates/assets/carousel.js
copy to tools/droiddoc/templates-sdk/assets/carousel.js
diff --git a/tools/droiddoc/templates-sdk/assets/customizations.js b/tools/droiddoc/templates-sdk/assets/customizations.js
new file mode 100644
index 0000000..5258902
--- /dev/null
+++ b/tools/droiddoc/templates-sdk/assets/customizations.js
@@ -0,0 +1,14 @@
+function showApiWarning(thing, selectedLevel, minLevel) {
+  if (selectedLevel < minLevel) {
+	  $("#naMessage").show().html("<div><p><strong>This " + thing + " is not available with API Level " + selectedLevel + ".</strong></p>"
+	      + "<p>To use this " + thing + ", your application must specify API Level " + minLevel + " or higher in its manifest "
+	      + "and be compiled against a version of the Android library that supports an equal or higher API Level. To reveal this "
+	      + "document, change the value of the API Level filter above.</p>"
+	      + "<p><a href='" +toRoot+ "guide/appendix/api-levels.html'>What is the API Level?</a></p></div>");
+  } else {
+    $("#naMessage").hide();
+  }
+}
+
+// Direct searches to search.html
+HAS_SEARCH_PAGE = true;
diff --git a/tools/droiddoc/templates/assets/images/android-developers-logo.png b/tools/droiddoc/templates-sdk/assets/images/android-developers-logo.png
similarity index 100%
copy from tools/droiddoc/templates/assets/images/android-developers-logo.png
copy to tools/droiddoc/templates-sdk/assets/images/android-developers-logo.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/android_wrench.png b/tools/droiddoc/templates-sdk/assets/images/android_wrench.png
similarity index 100%
copy from tools/droiddoc/templates/assets/images/android_wrench.png
copy to tools/droiddoc/templates-sdk/assets/images/android_wrench.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/arrow_bluelink_down.png b/tools/droiddoc/templates-sdk/assets/images/arrow_bluelink_down.png
similarity index 100%
copy from tools/droiddoc/templates/assets/images/arrow_bluelink_down.png
copy to tools/droiddoc/templates-sdk/assets/images/arrow_bluelink_down.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/arrow_bluelink_up.png b/tools/droiddoc/templates-sdk/assets/images/arrow_bluelink_up.png
similarity index 100%
copy from tools/droiddoc/templates/assets/images/arrow_bluelink_up.png
copy to tools/droiddoc/templates-sdk/assets/images/arrow_bluelink_up.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/arrow_left_off.jpg b/tools/droiddoc/templates-sdk/assets/images/arrow_left_off.jpg
similarity index 100%
copy from tools/droiddoc/templates/assets/images/arrow_left_off.jpg
copy to tools/droiddoc/templates-sdk/assets/images/arrow_left_off.jpg
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/arrow_left_on.jpg b/tools/droiddoc/templates-sdk/assets/images/arrow_left_on.jpg
similarity index 100%
copy from tools/droiddoc/templates/assets/images/arrow_left_on.jpg
copy to tools/droiddoc/templates-sdk/assets/images/arrow_left_on.jpg
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/arrow_right_off.jpg b/tools/droiddoc/templates-sdk/assets/images/arrow_right_off.jpg
similarity index 100%
copy from tools/droiddoc/templates/assets/images/arrow_right_off.jpg
copy to tools/droiddoc/templates-sdk/assets/images/arrow_right_off.jpg
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/arrow_right_on.jpg b/tools/droiddoc/templates-sdk/assets/images/arrow_right_on.jpg
similarity index 100%
copy from tools/droiddoc/templates/assets/images/arrow_right_on.jpg
copy to tools/droiddoc/templates-sdk/assets/images/arrow_right_on.jpg
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/bg_community_leftDiv.jpg b/tools/droiddoc/templates-sdk/assets/images/bg_community_leftDiv.jpg
similarity index 100%
copy from tools/droiddoc/templates/assets/images/bg_community_leftDiv.jpg
copy to tools/droiddoc/templates-sdk/assets/images/bg_community_leftDiv.jpg
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/bg_fade.jpg b/tools/droiddoc/templates-sdk/assets/images/bg_fade.jpg
similarity index 100%
copy from tools/droiddoc/templates/assets/images/bg_fade.jpg
copy to tools/droiddoc/templates-sdk/assets/images/bg_fade.jpg
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/bg_images_sprite.png b/tools/droiddoc/templates-sdk/assets/images/bg_images_sprite.png
similarity index 100%
copy from tools/droiddoc/templates/assets/images/bg_images_sprite.png
copy to tools/droiddoc/templates-sdk/assets/images/bg_images_sprite.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/bg_logo.png b/tools/droiddoc/templates-sdk/assets/images/bg_logo.png
similarity index 100%
copy from tools/droiddoc/templates/assets/images/bg_logo.png
copy to tools/droiddoc/templates-sdk/assets/images/bg_logo.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/body-gradient-tab.png b/tools/droiddoc/templates-sdk/assets/images/body-gradient-tab.png
similarity index 100%
copy from tools/droiddoc/templates/assets/images/body-gradient-tab.png
copy to tools/droiddoc/templates-sdk/assets/images/body-gradient-tab.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/body-gradient.png b/tools/droiddoc/templates-sdk/assets/images/body-gradient.png
similarity index 100%
copy from tools/droiddoc/templates/assets/images/body-gradient.png
copy to tools/droiddoc/templates-sdk/assets/images/body-gradient.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/developers-logo.png b/tools/droiddoc/templates-sdk/assets/images/developers-logo.png
similarity index 100%
copy from tools/droiddoc/templates/assets/images/developers-logo.png
copy to tools/droiddoc/templates-sdk/assets/images/developers-logo.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/grad-rule-qv.png b/tools/droiddoc/templates-sdk/assets/images/grad-rule-qv.png
similarity index 100%
copy from tools/droiddoc/templates/assets/images/grad-rule-qv.png
copy to tools/droiddoc/templates-sdk/assets/images/grad-rule-qv.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/home/Android_Dev_Lab_l.png b/tools/droiddoc/templates-sdk/assets/images/home/Android_Dev_Lab_l.png
similarity index 100%
rename from tools/droiddoc/templates/assets/images/home/Android_Dev_Lab_l.png
rename to tools/droiddoc/templates-sdk/assets/images/home/Android_Dev_Lab_l.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/home/GDC2011.png b/tools/droiddoc/templates-sdk/assets/images/home/GDC2011.png
new file mode 100644
index 0000000..82ce918
--- /dev/null
+++ b/tools/droiddoc/templates-sdk/assets/images/home/GDC2011.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/home/IO-logo-2011.png b/tools/droiddoc/templates-sdk/assets/images/home/IO-logo-2011.png
new file mode 100644
index 0000000..4a28447
--- /dev/null
+++ b/tools/droiddoc/templates-sdk/assets/images/home/IO-logo-2011.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/home/IO-logo.png b/tools/droiddoc/templates-sdk/assets/images/home/IO-logo.png
similarity index 100%
copy from tools/droiddoc/templates/assets/images/home/IO-logo.png
copy to tools/droiddoc/templates-sdk/assets/images/home/IO-logo.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/home/adc2_l.png b/tools/droiddoc/templates-sdk/assets/images/home/adc2_l.png
similarity index 100%
rename from tools/droiddoc/templates/assets/images/home/adc2_l.png
rename to tools/droiddoc/templates-sdk/assets/images/home/adc2_l.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/home/adc2_s.png b/tools/droiddoc/templates-sdk/assets/images/home/adc2_s.png
similarity index 100%
rename from tools/droiddoc/templates/assets/images/home/adc2_s.png
rename to tools/droiddoc/templates-sdk/assets/images/home/adc2_s.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/home/android_adc.png b/tools/droiddoc/templates-sdk/assets/images/home/android_adc.png
similarity index 100%
copy from tools/droiddoc/templates/assets/images/home/android_adc.png
copy to tools/droiddoc/templates-sdk/assets/images/home/android_adc.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/home/bg_home_announcement.png b/tools/droiddoc/templates-sdk/assets/images/home/bg_home_announcement.png
similarity index 100%
copy from tools/droiddoc/templates/assets/images/home/bg_home_announcement.png
copy to tools/droiddoc/templates-sdk/assets/images/home/bg_home_announcement.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/home/bg_home_bottom.jpg b/tools/droiddoc/templates-sdk/assets/images/home/bg_home_bottom.jpg
similarity index 100%
copy from tools/droiddoc/templates/assets/images/home/bg_home_bottom.jpg
copy to tools/droiddoc/templates-sdk/assets/images/home/bg_home_bottom.jpg
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/home/bg_home_carousel.png b/tools/droiddoc/templates-sdk/assets/images/home/bg_home_carousel.png
similarity index 100%
copy from tools/droiddoc/templates/assets/images/home/bg_home_carousel.png
copy to tools/droiddoc/templates-sdk/assets/images/home/bg_home_carousel.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/home/bg_home_carousel_board.png b/tools/droiddoc/templates-sdk/assets/images/home/bg_home_carousel_board.png
similarity index 100%
copy from tools/droiddoc/templates/assets/images/home/bg_home_carousel_board.png
copy to tools/droiddoc/templates-sdk/assets/images/home/bg_home_carousel_board.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/home/bg_home_carousel_wheel.png b/tools/droiddoc/templates-sdk/assets/images/home/bg_home_carousel_wheel.png
similarity index 100%
copy from tools/droiddoc/templates/assets/images/home/bg_home_carousel_wheel.png
copy to tools/droiddoc/templates-sdk/assets/images/home/bg_home_carousel_wheel.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/home/carousel_buttons_sprite.png b/tools/droiddoc/templates-sdk/assets/images/home/carousel_buttons_sprite.png
similarity index 100%
copy from tools/droiddoc/templates/assets/images/home/carousel_buttons_sprite.png
copy to tools/droiddoc/templates-sdk/assets/images/home/carousel_buttons_sprite.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/home/devphone-large.png b/tools/droiddoc/templates-sdk/assets/images/home/devphone-large.png
similarity index 100%
rename from tools/droiddoc/templates/assets/images/home/devphone-large.png
rename to tools/droiddoc/templates-sdk/assets/images/home/devphone-large.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/home/devphone-small.png b/tools/droiddoc/templates-sdk/assets/images/home/devphone-small.png
similarity index 100%
rename from tools/droiddoc/templates/assets/images/home/devphone-small.png
rename to tools/droiddoc/templates-sdk/assets/images/home/devphone-small.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/home/donut-android.png b/tools/droiddoc/templates-sdk/assets/images/home/donut-android.png
similarity index 100%
copy from tools/droiddoc/templates/assets/images/home/donut-android.png
copy to tools/droiddoc/templates-sdk/assets/images/home/donut-android.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/home/eclair-android.png b/tools/droiddoc/templates-sdk/assets/images/home/eclair-android.png
similarity index 100%
copy from tools/droiddoc/templates/assets/images/home/eclair-android.png
copy to tools/droiddoc/templates-sdk/assets/images/home/eclair-android.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/home/froyo-android.png b/tools/droiddoc/templates-sdk/assets/images/home/froyo-android.png
similarity index 100%
rename from tools/droiddoc/templates/assets/images/home/froyo-android.png
rename to tools/droiddoc/templates-sdk/assets/images/home/froyo-android.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/home/gdc-logo.png b/tools/droiddoc/templates-sdk/assets/images/home/gdc-logo.png
similarity index 100%
rename from tools/droiddoc/templates/assets/images/home/gdc-logo.png
rename to tools/droiddoc/templates-sdk/assets/images/home/gdc-logo.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/home/gingerdroid.png b/tools/droiddoc/templates-sdk/assets/images/home/gingerdroid.png
similarity index 100%
rename from tools/droiddoc/templates/assets/images/home/gingerdroid.png
rename to tools/droiddoc/templates-sdk/assets/images/home/gingerdroid.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/home/honeycomb-android.png b/tools/droiddoc/templates-sdk/assets/images/home/honeycomb-android.png
new file mode 100644
index 0000000..6cc5031
--- /dev/null
+++ b/tools/droiddoc/templates-sdk/assets/images/home/honeycomb-android.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/home/io-large.png b/tools/droiddoc/templates-sdk/assets/images/home/io-large.png
similarity index 100%
copy from tools/droiddoc/templates/assets/images/home/io-large.png
copy to tools/droiddoc/templates-sdk/assets/images/home/io-large.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/home/io-small.png b/tools/droiddoc/templates-sdk/assets/images/home/io-small.png
similarity index 100%
copy from tools/droiddoc/templates/assets/images/home/io-small.png
copy to tools/droiddoc/templates-sdk/assets/images/home/io-small.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/home/maps-large.png b/tools/droiddoc/templates-sdk/assets/images/home/maps-large.png
similarity index 100%
copy from tools/droiddoc/templates/assets/images/home/maps-large.png
copy to tools/droiddoc/templates-sdk/assets/images/home/maps-large.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/home/maps-small.png b/tools/droiddoc/templates-sdk/assets/images/home/maps-small.png
similarity index 100%
copy from tools/droiddoc/templates/assets/images/home/maps-small.png
copy to tools/droiddoc/templates-sdk/assets/images/home/maps-small.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/home/market-large.png b/tools/droiddoc/templates-sdk/assets/images/home/market-large.png
similarity index 100%
copy from tools/droiddoc/templates/assets/images/home/market-large.png
copy to tools/droiddoc/templates-sdk/assets/images/home/market-large.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/home/market-small.png b/tools/droiddoc/templates-sdk/assets/images/home/market-small.png
similarity index 100%
copy from tools/droiddoc/templates/assets/images/home/market-small.png
copy to tools/droiddoc/templates-sdk/assets/images/home/market-small.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/home/sdk-large.png b/tools/droiddoc/templates-sdk/assets/images/home/sdk-large.png
similarity index 100%
copy from tools/droiddoc/templates/assets/images/home/sdk-large.png
copy to tools/droiddoc/templates-sdk/assets/images/home/sdk-large.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/home/sdk-small.png b/tools/droiddoc/templates-sdk/assets/images/home/sdk-small.png
similarity index 100%
copy from tools/droiddoc/templates/assets/images/home/sdk-small.png
copy to tools/droiddoc/templates-sdk/assets/images/home/sdk-small.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/home/tv_l.png b/tools/droiddoc/templates-sdk/assets/images/home/tv_l.png
similarity index 100%
rename from tools/droiddoc/templates/assets/images/home/tv_l.png
rename to tools/droiddoc/templates-sdk/assets/images/home/tv_l.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/home/tv_s.png b/tools/droiddoc/templates-sdk/assets/images/home/tv_s.png
similarity index 100%
rename from tools/droiddoc/templates/assets/images/home/tv_s.png
rename to tools/droiddoc/templates-sdk/assets/images/home/tv_s.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/hr_gray_main.jpg b/tools/droiddoc/templates-sdk/assets/images/hr_gray_main.jpg
similarity index 100%
copy from tools/droiddoc/templates/assets/images/hr_gray_main.jpg
copy to tools/droiddoc/templates-sdk/assets/images/hr_gray_main.jpg
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/hr_gray_side.jpg b/tools/droiddoc/templates-sdk/assets/images/hr_gray_side.jpg
similarity index 100%
copy from tools/droiddoc/templates/assets/images/hr_gray_side.jpg
copy to tools/droiddoc/templates-sdk/assets/images/hr_gray_side.jpg
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/icon_contribute.jpg b/tools/droiddoc/templates-sdk/assets/images/icon_contribute.jpg
similarity index 100%
copy from tools/droiddoc/templates/assets/images/icon_contribute.jpg
copy to tools/droiddoc/templates-sdk/assets/images/icon_contribute.jpg
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/icon_download.jpg b/tools/droiddoc/templates-sdk/assets/images/icon_download.jpg
similarity index 100%
copy from tools/droiddoc/templates/assets/images/icon_download.jpg
copy to tools/droiddoc/templates-sdk/assets/images/icon_download.jpg
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/icon_download2.jpg b/tools/droiddoc/templates-sdk/assets/images/icon_download2.jpg
similarity index 100%
copy from tools/droiddoc/templates/assets/images/icon_download2.jpg
copy to tools/droiddoc/templates-sdk/assets/images/icon_download2.jpg
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/icon_guidelines_logo.png b/tools/droiddoc/templates-sdk/assets/images/icon_guidelines_logo.png
similarity index 100%
copy from tools/droiddoc/templates/assets/images/icon_guidelines_logo.png
copy to tools/droiddoc/templates-sdk/assets/images/icon_guidelines_logo.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/icon_market.jpg b/tools/droiddoc/templates-sdk/assets/images/icon_market.jpg
new file mode 100644
index 0000000..cb1ff0b
--- /dev/null
+++ b/tools/droiddoc/templates-sdk/assets/images/icon_market.jpg
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/icon_robot.jpg b/tools/droiddoc/templates-sdk/assets/images/icon_robot.jpg
similarity index 100%
copy from tools/droiddoc/templates/assets/images/icon_robot.jpg
copy to tools/droiddoc/templates-sdk/assets/images/icon_robot.jpg
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/icon_world.jpg b/tools/droiddoc/templates-sdk/assets/images/icon_world.jpg
similarity index 100%
copy from tools/droiddoc/templates/assets/images/icon_world.jpg
copy to tools/droiddoc/templates-sdk/assets/images/icon_world.jpg
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/left_off.jpg b/tools/droiddoc/templates-sdk/assets/images/left_off.jpg
similarity index 100%
copy from tools/droiddoc/templates/assets/images/left_off.jpg
copy to tools/droiddoc/templates-sdk/assets/images/left_off.jpg
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/left_on.jpg b/tools/droiddoc/templates-sdk/assets/images/left_on.jpg
similarity index 100%
copy from tools/droiddoc/templates/assets/images/left_on.jpg
copy to tools/droiddoc/templates-sdk/assets/images/left_on.jpg
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/logo_breadcrumbz.jpg b/tools/droiddoc/templates-sdk/assets/images/logo_breadcrumbz.jpg
similarity index 100%
copy from tools/droiddoc/templates/assets/images/logo_breadcrumbz.jpg
copy to tools/droiddoc/templates-sdk/assets/images/logo_breadcrumbz.jpg
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/open_source.png b/tools/droiddoc/templates-sdk/assets/images/open_source.png
similarity index 100%
copy from tools/droiddoc/templates/assets/images/open_source.png
copy to tools/droiddoc/templates-sdk/assets/images/open_source.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/preliminary.png b/tools/droiddoc/templates-sdk/assets/images/preliminary.png
similarity index 100%
copy from tools/droiddoc/templates/assets/images/preliminary.png
copy to tools/droiddoc/templates-sdk/assets/images/preliminary.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/resizable-e.gif b/tools/droiddoc/templates-sdk/assets/images/resizable-e.gif
similarity index 100%
copy from tools/droiddoc/templates/assets/images/resizable-e.gif
copy to tools/droiddoc/templates-sdk/assets/images/resizable-e.gif
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/resizable-e2.gif b/tools/droiddoc/templates-sdk/assets/images/resizable-e2.gif
similarity index 100%
copy from tools/droiddoc/templates/assets/images/resizable-e2.gif
copy to tools/droiddoc/templates-sdk/assets/images/resizable-e2.gif
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/resizable-eg.gif b/tools/droiddoc/templates-sdk/assets/images/resizable-eg.gif
similarity index 100%
copy from tools/droiddoc/templates/assets/images/resizable-eg.gif
copy to tools/droiddoc/templates-sdk/assets/images/resizable-eg.gif
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/resizable-s.gif b/tools/droiddoc/templates-sdk/assets/images/resizable-s.gif
similarity index 100%
copy from tools/droiddoc/templates/assets/images/resizable-s.gif
copy to tools/droiddoc/templates-sdk/assets/images/resizable-s.gif
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/resizable-s2.gif b/tools/droiddoc/templates-sdk/assets/images/resizable-s2.gif
similarity index 100%
copy from tools/droiddoc/templates/assets/images/resizable-s2.gif
copy to tools/droiddoc/templates-sdk/assets/images/resizable-s2.gif
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/resizable-sg.gif b/tools/droiddoc/templates-sdk/assets/images/resizable-sg.gif
similarity index 100%
copy from tools/droiddoc/templates/assets/images/resizable-sg.gif
copy to tools/droiddoc/templates-sdk/assets/images/resizable-sg.gif
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/resource-article.png b/tools/droiddoc/templates-sdk/assets/images/resource-article.png
new file mode 100644
index 0000000..416493f
--- /dev/null
+++ b/tools/droiddoc/templates-sdk/assets/images/resource-article.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/resource-big-article.png b/tools/droiddoc/templates-sdk/assets/images/resource-big-article.png
new file mode 100644
index 0000000..7273275
--- /dev/null
+++ b/tools/droiddoc/templates-sdk/assets/images/resource-big-article.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/resource-big-sample.png b/tools/droiddoc/templates-sdk/assets/images/resource-big-sample.png
new file mode 100644
index 0000000..59b6b68
--- /dev/null
+++ b/tools/droiddoc/templates-sdk/assets/images/resource-big-sample.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/resource-big-tutorial.png b/tools/droiddoc/templates-sdk/assets/images/resource-big-tutorial.png
new file mode 100644
index 0000000..c32e89a
--- /dev/null
+++ b/tools/droiddoc/templates-sdk/assets/images/resource-big-tutorial.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/resource-big-video.png b/tools/droiddoc/templates-sdk/assets/images/resource-big-video.png
new file mode 100644
index 0000000..59d46a0
--- /dev/null
+++ b/tools/droiddoc/templates-sdk/assets/images/resource-big-video.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/resource-sample.png b/tools/droiddoc/templates-sdk/assets/images/resource-sample.png
new file mode 100644
index 0000000..f7a411c
--- /dev/null
+++ b/tools/droiddoc/templates-sdk/assets/images/resource-sample.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/resource-tutorial.png b/tools/droiddoc/templates-sdk/assets/images/resource-tutorial.png
new file mode 100644
index 0000000..10a14fe
--- /dev/null
+++ b/tools/droiddoc/templates-sdk/assets/images/resource-tutorial.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/resource-video.png b/tools/droiddoc/templates-sdk/assets/images/resource-video.png
new file mode 100644
index 0000000..8fd5cae
--- /dev/null
+++ b/tools/droiddoc/templates-sdk/assets/images/resource-video.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/right_off.jpg b/tools/droiddoc/templates-sdk/assets/images/right_off.jpg
similarity index 100%
rename from tools/droiddoc/templates/assets/images/right_off.jpg
rename to tools/droiddoc/templates-sdk/assets/images/right_off.jpg
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/right_on.jpg b/tools/droiddoc/templates-sdk/assets/images/right_on.jpg
similarity index 100%
rename from tools/droiddoc/templates/assets/images/right_on.jpg
rename to tools/droiddoc/templates-sdk/assets/images/right_on.jpg
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/sidenav-rule.png b/tools/droiddoc/templates-sdk/assets/images/sidenav-rule.png
similarity index 100%
copy from tools/droiddoc/templates/assets/images/sidenav-rule.png
copy to tools/droiddoc/templates-sdk/assets/images/sidenav-rule.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/slide_1.jpg b/tools/droiddoc/templates-sdk/assets/images/slide_1.jpg
similarity index 100%
rename from tools/droiddoc/templates/assets/images/slide_1.jpg
rename to tools/droiddoc/templates-sdk/assets/images/slide_1.jpg
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/slide_2.jpg b/tools/droiddoc/templates-sdk/assets/images/slide_2.jpg
similarity index 100%
rename from tools/droiddoc/templates/assets/images/slide_2.jpg
rename to tools/droiddoc/templates-sdk/assets/images/slide_2.jpg
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/slide_3.jpg b/tools/droiddoc/templates-sdk/assets/images/slide_3.jpg
similarity index 100%
rename from tools/droiddoc/templates/assets/images/slide_3.jpg
rename to tools/droiddoc/templates-sdk/assets/images/slide_3.jpg
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/slide_large_1.jpg b/tools/droiddoc/templates-sdk/assets/images/slide_large_1.jpg
similarity index 100%
rename from tools/droiddoc/templates/assets/images/slide_large_1.jpg
rename to tools/droiddoc/templates-sdk/assets/images/slide_large_1.jpg
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/slide_large_2.jpg b/tools/droiddoc/templates-sdk/assets/images/slide_large_2.jpg
similarity index 100%
rename from tools/droiddoc/templates/assets/images/slide_large_2.jpg
rename to tools/droiddoc/templates-sdk/assets/images/slide_large_2.jpg
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/slide_large_3.jpg b/tools/droiddoc/templates-sdk/assets/images/slide_large_3.jpg
similarity index 100%
rename from tools/droiddoc/templates/assets/images/slide_large_3.jpg
rename to tools/droiddoc/templates-sdk/assets/images/slide_large_3.jpg
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/slide_off.jpg b/tools/droiddoc/templates-sdk/assets/images/slide_off.jpg
similarity index 100%
copy from tools/droiddoc/templates/assets/images/slide_off.jpg
copy to tools/droiddoc/templates-sdk/assets/images/slide_off.jpg
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/slide_on.jpg b/tools/droiddoc/templates-sdk/assets/images/slide_on.jpg
similarity index 100%
copy from tools/droiddoc/templates/assets/images/slide_on.jpg
copy to tools/droiddoc/templates-sdk/assets/images/slide_on.jpg
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/spacer.gif b/tools/droiddoc/templates-sdk/assets/images/spacer.gif
similarity index 100%
copy from tools/droiddoc/templates/assets/images/spacer.gif
copy to tools/droiddoc/templates-sdk/assets/images/spacer.gif
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/triangle-closed-small.png b/tools/droiddoc/templates-sdk/assets/images/triangle-closed-small.png
similarity index 100%
copy from tools/droiddoc/templates/assets/images/triangle-closed-small.png
copy to tools/droiddoc/templates-sdk/assets/images/triangle-closed-small.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/triangle-closed.png b/tools/droiddoc/templates-sdk/assets/images/triangle-closed.png
similarity index 100%
copy from tools/droiddoc/templates/assets/images/triangle-closed.png
copy to tools/droiddoc/templates-sdk/assets/images/triangle-closed.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/triangle-opened-small.png b/tools/droiddoc/templates-sdk/assets/images/triangle-opened-small.png
similarity index 100%
copy from tools/droiddoc/templates/assets/images/triangle-opened-small.png
copy to tools/droiddoc/templates-sdk/assets/images/triangle-opened-small.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/triangle-opened.png b/tools/droiddoc/templates-sdk/assets/images/triangle-opened.png
similarity index 100%
copy from tools/droiddoc/templates/assets/images/triangle-opened.png
copy to tools/droiddoc/templates-sdk/assets/images/triangle-opened.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/uiguidelines1.png b/tools/droiddoc/templates-sdk/assets/images/uiguidelines1.png
similarity index 100%
copy from tools/droiddoc/templates/assets/images/uiguidelines1.png
copy to tools/droiddoc/templates-sdk/assets/images/uiguidelines1.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/images/video-droid.png b/tools/droiddoc/templates-sdk/assets/images/video-droid.png
similarity index 100%
copy from tools/droiddoc/templates/assets/images/video-droid.png
copy to tools/droiddoc/templates-sdk/assets/images/video-droid.png
Binary files differ
diff --git a/tools/droiddoc/templates/assets/jdiff_logo.gif b/tools/droiddoc/templates-sdk/assets/jdiff_logo.gif
similarity index 100%
copy from tools/droiddoc/templates/assets/jdiff_logo.gif
copy to tools/droiddoc/templates-sdk/assets/jdiff_logo.gif
Binary files differ
diff --git a/tools/droiddoc/templates/assets/jquery-history.js b/tools/droiddoc/templates-sdk/assets/jquery-history.js
similarity index 100%
copy from tools/droiddoc/templates/assets/jquery-history.js
copy to tools/droiddoc/templates-sdk/assets/jquery-history.js
diff --git a/tools/droiddoc/templates/assets/jquery-resizable.min.js b/tools/droiddoc/templates-sdk/assets/jquery-resizable.min.js
similarity index 100%
copy from tools/droiddoc/templates/assets/jquery-resizable.min.js
copy to tools/droiddoc/templates-sdk/assets/jquery-resizable.min.js
diff --git a/tools/droiddoc/templates-sdk/assets/microtemplate.js b/tools/droiddoc/templates-sdk/assets/microtemplate.js
new file mode 100644
index 0000000..ada1235
--- /dev/null
+++ b/tools/droiddoc/templates-sdk/assets/microtemplate.js
@@ -0,0 +1,35 @@
+// Simple JavaScript Templating
+// John Resig - http://ejohn.org/ - MIT Licensed
+(function(){
+  var cache = {};
+
+  this.tmpl = function tmpl(str, data){
+    // Figure out if we're getting a template, or if we need to
+    // load the template - and be sure to cache the result.
+    var fn = !/\W/.test(str) ?
+      cache[str] = cache[str] ||
+        tmpl(document.getElementById(str).innerHTML) :
+
+      // Generate a reusable function that will serve as a template
+      // generator (and which will be cached).
+      new Function("obj",
+        "var p=[],print=function(){p.push.apply(p,arguments);};" +
+
+        // Introduce the data as local variables using with(){}
+        "with(obj){p.push('" +
+
+        // Convert the template into pure JavaScript
+        str
+          .replace(/[\r\t\n]/g, " ")
+          .split("<%").join("\t")
+          .replace(/((^|%>)[^\t]*)'/g, "$1\r")
+          .replace(/\t=(.*?)%>/g, "',$1,'")
+          .split("\t").join("');")
+          .split("%>").join("p.push('")
+          .split("\r").join("\\'")
+      + "');}return p.join('');");
+
+    // Provide some basic currying to the user
+    return data ? fn( data ) : fn;
+  };
+})();
\ No newline at end of file
diff --git a/tools/droiddoc/templates/assets/prettify.js b/tools/droiddoc/templates-sdk/assets/prettify.js
similarity index 100%
copy from tools/droiddoc/templates/assets/prettify.js
copy to tools/droiddoc/templates-sdk/assets/prettify.js
diff --git a/tools/droiddoc/templates/assets/search_autocomplete.js b/tools/droiddoc/templates-sdk/assets/search_autocomplete.js
similarity index 100%
copy from tools/droiddoc/templates/assets/search_autocomplete.js
copy to tools/droiddoc/templates-sdk/assets/search_autocomplete.js
diff --git a/tools/droiddoc/templates/assets/style.css b/tools/droiddoc/templates-sdk/assets/style.css
similarity index 100%
copy from tools/droiddoc/templates/assets/style.css
copy to tools/droiddoc/templates-sdk/assets/style.css
diff --git a/tools/droiddoc/templates/assets/triangle-none.gif b/tools/droiddoc/templates-sdk/assets/triangle-none.gif
similarity index 100%
copy from tools/droiddoc/templates/assets/triangle-none.gif
copy to tools/droiddoc/templates-sdk/assets/triangle-none.gif
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/components/masthead.cs b/tools/droiddoc/templates-sdk/components/masthead.cs
new file mode 100644
index 0000000..e521489
--- /dev/null
+++ b/tools/droiddoc/templates-sdk/components/masthead.cs
@@ -0,0 +1,60 @@
+<?cs def:custom_masthead() ?>
+  <div id="header">
+      <div id="headerLeft">
+          <a href="<?cs var:toroot ?>index.html" tabindex="-1"><img
+              src="<?cs var:toroot ?>assets/images/bg_logo.png" alt="Android Developers" /></a>
+          <?cs include:"header_tabs.cs" ?>     <?cs # The links are extracted so we can better manage localization ?>
+      </div>
+      <div id="headerRight">
+          <div id="headerLinks">
+          <?cs if:template.showLanguageMenu ?>
+            <img src="<?cs var:toroot ?>assets/images/icon_world.jpg" alt="Language:" /> 
+            <span id="language">
+             	<select name="language" onChange="changeLangPref(this.value, true)">
+          			<option value="en">English&nbsp;&nbsp;&nbsp;</option>
+          			<option value="ja">日本語</option>
+          			<?cs # 
+      			    <option value="de">Deutsch</option> 
+          			<option value="es">Español</option>
+          			<option value="fr">Français</option>
+          			<option value="it">Italiano</option>
+          			<option value="zh-CN">中文 (简体)</option>
+          			<option value="zh-TW">中文 (繁體)</option>
+      			    ?>
+             	</select>	
+             	<script type="text/javascript">
+             	  <!--  
+                  loadLangPref();  
+             	   //-->
+             	</script>
+            </span>
+          <?cs /if ?>
+          <a href="http://www.android.com">Android.com</a>
+          </div><?cs 
+          call:default_search_box() ?><?cs 
+    	 	  if:reference ?>
+    			  <div id="api-level-toggle">
+    			    <input type="checkbox" id="apiLevelCheckbox" onclick="toggleApiLevelSelector(this)" />
+    			    <label for="apiLevelCheckbox" class="disabled">Filter by API Level: </label>
+    			    <select id="apiLevelSelector">
+    			      <!-- option elements added by buildApiLevelSelector() -->
+    			    </select>
+    			  </div>
+    	 	    <script>
+              var SINCE_DATA = [ <?cs 
+                each:since = since ?>'<?cs 
+                  var:since.name ?>'<?cs 
+                  if:!last(since) ?>, <?cs /if ?><?cs
+                /each 
+              ?> ];
+              buildApiLevelSelector();
+            </script><?cs 
+    			/if ?>
+      </div><!-- headerRight -->
+      <script type="text/javascript">
+        <!--  
+        changeTabLang(getLangPref());
+        //-->
+      </script>
+  </div><!-- header --><?cs 
+/def ?>
\ No newline at end of file
diff --git a/tools/droiddoc/templates-sdk/customization.cs b/tools/droiddoc/templates-sdk/customization.cs
deleted file mode 100644
index 907f0f7..0000000
--- a/tools/droiddoc/templates-sdk/customization.cs
+++ /dev/null
@@ -1,252 +0,0 @@
-<?cs # This default template file is meant to be replaced. ?>
-<?cs # Use the -tempatedir arg to javadoc to set your own directory with a replacement for this file in it. ?>
-
-
-<?cs # The default search box that goes in the header ?><?cs 
-def:default_search_box() ?>
-  <div id="search" >
-      <div id="searchForm">
-          <form accept-charset="utf-8" class="gsc-search-box" 
-                onsubmit="return submit_search()">
-            <table class="gsc-search-box" cellpadding="0" cellspacing="0"><tbody>
-                <tr>
-                  <td class="gsc-input">
-                    <input id="search_autocomplete" class="gsc-input" type="text" size="33" autocomplete="off"
-                      title="search developer docs" name="q"
-                      value="search developer docs"
-                      onFocus="search_focus_changed(this, true)"
-                      onBlur="search_focus_changed(this, false)"
-                      onkeydown="return search_changed(event, true, '<?cs var:toroot?>')"
-                      onkeyup="return search_changed(event, false, '<?cs var:toroot?>')" />
-                  <div id="search_filtered_div" class="no-display">
-                      <table id="search_filtered" cellspacing=0>
-                      </table>
-                  </div>
-                  </td>
-                  <td class="gsc-search-button">
-                    <input type="submit" value="Search" title="search" id="search-button" class="gsc-search-button" />
-                  </td>
-                  <td class="gsc-clear-button">
-                    <div title="clear results" class="gsc-clear-button">&nbsp;</div>
-                  </td>
-                </tr></tbody>
-              </table>
-          </form>
-      </div><!-- searchForm -->
-  </div><!-- search --><?cs 
-/def ?>
-
-<?cs 
-def:custom_masthead() ?>
-  <div id="header">
-      <div id="headerLeft">
-          <a href="<?cs var:toroot ?>index.html" tabindex="-1"><img
-              src="<?cs var:toroot ?>assets/images/bg_logo.png" alt="Android Developers" /></a>
-          <?cs include:"header_tabs.cs" ?>     <?cs # The links are extracted so we can better manage localization ?>
-      </div>
-      <div id="headerRight">
-          <div id="headerLinks">
-          <?cs if:template.showLanguageMenu ?>
-            <img src="<?cs var:toroot ?>assets/images/icon_world.jpg" alt="Language:" /> 
-            <span id="language">
-             	<select name="language" onChange="changeLangPref(this.value, true)">
-          			<option value="en">English&nbsp;&nbsp;&nbsp;</option>
-          			<option value="ja">日本語</option>
-          			<?cs # 
-      			    <option value="de">Deutsch</option> 
-          			<option value="es">Español</option>
-          			<option value="fr">Français</option>
-          			<option value="it">Italiano</option>
-          			<option value="zh-CN">中文 (简体)</option>
-          			<option value="zh-TW">中文 (繁體)</option>
-      			    ?>
-             	</select>	
-             	<script type="text/javascript">
-             	  <!--  
-                  loadLangPref();  
-             	   //-->
-             	</script>
-            </span>
-          <?cs /if ?>
-          <a href="http://www.android.com">Android.com</a>
-          </div><?cs 
-          call:default_search_box() ?><?cs 
-    	 	  if:reference ?>
-    			  <div id="api-level-toggle">
-    			    <input type="checkbox" id="apiLevelCheckbox" onclick="toggleApiLevelSelector(this)" />
-    			    <label for="apiLevelCheckbox" class="disabled">Filter by API Level: </label>
-    			    <select id="apiLevelSelector">
-    			      <!-- option elements added by buildApiLevelSelector() -->
-    			    </select>
-    			  </div>
-    	 	    <script>
-              var SINCE_DATA = [ <?cs 
-                each:since = since ?>'<?cs 
-                  var:since.name ?>'<?cs 
-                  if:!last(since) ?>, <?cs /if ?><?cs
-                /each 
-              ?> ];
-              buildApiLevelSelector();
-            </script><?cs 
-    			/if ?>
-      </div><!-- headerRight -->
-      <script type="text/javascript">
-        <!--  
-        changeTabLang(getLangPref());
-        //-->
-      </script>
-  </div><!-- header --><?cs 
-/def ?>
-
-<?cs 
-def:sdk_nav() ?>
-  <div class="g-section g-tpl-240" id="body-content">
-    <div class="g-unit g-first" id="side-nav">
-      <div id="devdoc-nav"><?cs 
-        include:"../../../../frameworks/base/docs/html/sdk/sdk_toc.cs" ?>
-      </div>
-    </div> <!-- end side-nav -->
-<?cs /def ?>
-
-<?cs 
-def:resources_tab_nav() ?>
-  <div class="g-section g-tpl-200" id="body-content">
-    <div class="g-unit g-first" id="side-nav">
-      <div id="devdoc-nav"><?cs 
-        include:"../../../../frameworks/base/docs/html/resources/resources_toc.cs" ?>
-      </div>
-    </div> <!-- end side-nav -->
-    <script>
-      addLoadEvent(function() {
-        scrollIntoView("devdoc-nav");
-        });
-    </script>
-<?cs /def ?>
-
-<?cs 
-def:guide_nav() ?>
-  <div class="g-section g-tpl-240" id="body-content">
-    <div class="g-unit g-first" id="side-nav">
-      <div id="devdoc-nav"><?cs 
-        include:"../../../../frameworks/base/docs/html/guide/guide_toc.cs" ?>
-      </div>
-    </div> <!-- end side-nav -->
-    <script>
-      addLoadEvent(function() {
-        scrollIntoView("devdoc-nav");
-        });
-    </script>
-<?cs /def ?>
-
-<?cs # The default side navigation for the reference docs ?><?cs 
-def:default_left_nav() ?>
-  <div class="g-section g-tpl-240" id="body-content">
-    <div class="g-unit g-first" id="side-nav">
-      <div id="swapper">
-        <div id="nav-panels">
-          <div id="resize-packages-nav">
-            <div id="packages-nav">
-              <div id="index-links"><nobr>
-                <a href="<?cs var:toroot ?>reference/packages.html" <?cs if:(page.title == "Package Index") ?>class="selected"<?cs /if ?> >Package Index</a> | 
-                <a href="<?cs var:toroot ?>reference/classes.html" <?cs if:(page.title == "Class Index") ?>class="selected"<?cs /if ?>>Class Index</a></nobr>
-              </div>
-              <ul>
-              	<?cs call:package_link_list(docs.packages) ?>
-              </ul><br/>
-            </div> <!-- end packages -->
-          </div> <!-- end resize-packages -->
-          <div id="classes-nav"><?cs 
-            if:subcount(class.package) ?>
-            <ul>
-              <?cs call:list("Interfaces", class.package.interfaces) ?>
-              <?cs call:list("Classes", class.package.classes) ?>
-              <?cs call:list("Enums", class.package.enums) ?>
-              <?cs call:list("Exceptions", class.package.exceptions) ?>
-              <?cs call:list("Errors", class.package.errors) ?>
-            </ul><?cs 
-            elif:subcount(package) ?>
-            <ul>
-              <?cs call:class_link_list("Interfaces", package.interfaces) ?>
-              <?cs call:class_link_list("Classes", package.classes) ?>
-              <?cs call:class_link_list("Enums", package.enums) ?>
-              <?cs call:class_link_list("Exceptions", package.exceptions) ?>
-              <?cs call:class_link_list("Errors", package.errors) ?>
-            </ul><?cs 
-            else ?>
-              <script>
-                /*addLoadEvent(maxPackageHeight);*/
-              </script>
-              <p style="padding:10px">Select a package to view its members</p><?cs 
-            /if ?><br/>
-          </div><!-- end classes -->
-        </div><!-- end nav-panels -->
-        <div id="nav-tree" style="display:none">
-          <div id="index-links"><nobr>
-            <a href="<?cs var:toroot ?>reference/packages.html" <?cs if:(page.title == "Package Index") ?>class="selected"<?cs /if ?> >Package Index</a> | 
-            <a href="<?cs var:toroot ?>reference/classes.html" <?cs if:(page.title == "Class Index") ?>class="selected"<?cs /if ?>>Class Index</a></nobr>
-          </div>
-        </div><!-- end nav-tree -->
-      </div><!-- end swapper -->
-    </div> <!-- end side-nav -->
-    <script>
-      if (!isMobile) {
-        $("<a href='#' id='nav-swap' onclick='swapNav();return false;' style='font-size:10px;line-height:9px;margin-left:1em;text-decoration:none;'><span id='tree-link'>Use Tree Navigation</span><span id='panel-link' style='display:none'>Use Panel Navigation</span></a>").appendTo("#side-nav");
-        chooseDefaultNav();
-        if ($("#nav-tree").is(':visible')) {
-          init_default_navtree("<?cs var:toroot ?>");
-        } else {
-          addLoadEvent(function() {
-            scrollIntoView("packages-nav");
-            scrollIntoView("classes-nav");
-          });
-        }
-        $("#swapper").css({borderBottom:"2px solid #aaa"});
-      } else {
-        swapNav(); // tree view should be used on mobile
-      }
-    </script><?cs 
-/def ?>
-
-<?cs 
-def:custom_left_nav() ?><?cs 
-  if:guide ?><?cs 
-    call:guide_nav() ?><?cs 
-  elif:resources ?><?cs 
-    call:resources_tab_nav() ?><?cs 
-  elif:sdk ?><?cs 
-    call:sdk_nav() ?><?cs 
-  else ?><?cs 
-    call:default_left_nav() ?><?cs 
-  /if ?><?cs 
-/def ?>
-
-<?cs # appears at the bottom of every page ?><?cs 
-def:custom_cc_copyright() ?>
-  Except as noted, this content is 
-  licensed under <a href="http://creativecommons.org/licenses/by/2.5/">
-  Creative Commons Attribution 2.5</a>. For details and 
-  restrictions, see the <a href="<?cs var:toroot ?>license.html">Content 
-  License</a>.<?cs 
-/def ?>
-
-<?cs 
-def:custom_copyright() ?>
-  Except as noted, this content is licensed under <a
-  href="http://www.apache.org/licenses/LICENSE-2.0">Apache 2.0</a>. 
-  For details and restrictions, see the <a href="<?cs var:toroot ?>license.html">
-  Content License</a>.<?cs 
-/def ?>
-
-<?cs 
-def:custom_footerlinks() ?>
-  <p>
-    <a href="http://www.android.com/terms.html">Site Terms of Service</a> -
-    <a href="http://www.android.com/privacy.html">Privacy Policy</a> -
-    <a href="http://www.android.com/branding.html">Brand Guidelines</a>
-  </p><?cs 
-/def ?>
-
-<?cs # appears on the right side of the blue bar at the bottom off every page ?><?cs 
-def:custom_buildinfo() ?>
-  Android <?cs var:sdk.version ?>&nbsp;r<?cs var:sdk.rel.id ?> - <?cs var:page.now ?>
-<?cs /def ?>
diff --git a/tools/droiddoc/templates-sdk/customizations.cs b/tools/droiddoc/templates-sdk/customizations.cs
new file mode 100644
index 0000000..cfeab16
--- /dev/null
+++ b/tools/droiddoc/templates-sdk/customizations.cs
@@ -0,0 +1,151 @@
+<?cs 
+def:sdk_nav() ?>
+  <div class="g-section g-tpl-240" id="body-content">
+    <div class="g-unit g-first" id="side-nav">
+      <div id="devdoc-nav"><?cs 
+        include:"../../../../frameworks/base/docs/html/sdk/sdk_toc.cs" ?>
+      </div>
+    </div> <!-- end side-nav -->
+<?cs /def ?>
+<?cs 
+def:resources_tab_nav() ?>
+  <div class="g-section g-tpl-200" id="body-content">
+    <div class="g-unit g-first" id="side-nav">
+      <div id="devdoc-nav"><?cs 
+        include:"../../../../frameworks/base/docs/html/resources/resources_toc.cs" ?>
+      </div>
+    </div> <!-- end side-nav -->
+    <script>
+      addLoadEvent(function() {
+        scrollIntoView("devdoc-nav");
+        });
+    </script>
+<?cs /def ?>
+<?cs 
+def:guide_nav() ?>
+  <div class="g-section g-tpl-240" id="body-content">
+    <div class="g-unit g-first" id="side-nav">
+      <div id="devdoc-nav"><?cs 
+        include:"../../../../frameworks/base/docs/html/guide/guide_toc.cs" ?>
+      </div>
+    </div> <!-- end side-nav -->
+    <script>
+      addLoadEvent(function() {
+        scrollIntoView("devdoc-nav");
+        });
+    </script>
+<?cs /def ?>
+
+<?cs # The default side navigation for the reference docs ?><?cs 
+def:default_left_nav() ?>
+  <div class="g-section g-tpl-240" id="body-content">
+    <div class="g-unit g-first" id="side-nav">
+      <div id="swapper">
+        <div id="nav-panels">
+          <div id="resize-packages-nav">
+            <div id="packages-nav">
+              <div id="index-links"><nobr>
+                <a href="<?cs var:toroot ?>reference/packages.html" <?cs if:(page.title == "Package Index") ?>class="selected"<?cs /if ?> >Package Index</a> | 
+                <a href="<?cs var:toroot ?>reference/classes.html" <?cs if:(page.title == "Class Index") ?>class="selected"<?cs /if ?>>Class Index</a></nobr>
+              </div>
+              <ul>
+              	<?cs call:package_link_list(docs.packages) ?>
+              </ul><br/>
+            </div> <!-- end packages -->
+          </div> <!-- end resize-packages -->
+          <div id="classes-nav"><?cs 
+            if:subcount(class.package) ?>
+            <ul>
+              <?cs call:list("Interfaces", class.package.interfaces) ?>
+              <?cs call:list("Classes", class.package.classes) ?>
+              <?cs call:list("Enums", class.package.enums) ?>
+              <?cs call:list("Exceptions", class.package.exceptions) ?>
+              <?cs call:list("Errors", class.package.errors) ?>
+            </ul><?cs 
+            elif:subcount(package) ?>
+            <ul>
+              <?cs call:class_link_list("Interfaces", package.interfaces) ?>
+              <?cs call:class_link_list("Classes", package.classes) ?>
+              <?cs call:class_link_list("Enums", package.enums) ?>
+              <?cs call:class_link_list("Exceptions", package.exceptions) ?>
+              <?cs call:class_link_list("Errors", package.errors) ?>
+            </ul><?cs 
+            else ?>
+              <script>
+                /*addLoadEvent(maxPackageHeight);*/
+              </script>
+              <p style="padding:10px">Select a package to view its members</p><?cs 
+            /if ?><br/>
+          </div><!-- end classes -->
+        </div><!-- end nav-panels -->
+        <div id="nav-tree" style="display:none">
+          <div id="index-links"><nobr>
+            <a href="<?cs var:toroot ?>reference/packages.html" <?cs if:(page.title == "Package Index") ?>class="selected"<?cs /if ?> >Package Index</a> | 
+            <a href="<?cs var:toroot ?>reference/classes.html" <?cs if:(page.title == "Class Index") ?>class="selected"<?cs /if ?>>Class Index</a></nobr>
+          </div>
+        </div><!-- end nav-tree -->
+      </div><!-- end swapper -->
+    </div> <!-- end side-nav -->
+    <script>
+      if (!isMobile) {
+        $("<a href='#' id='nav-swap' onclick='swapNav();return false;' style='font-size:10px;line-height:9px;margin-left:1em;text-decoration:none;'><span id='tree-link'>Use Tree Navigation</span><span id='panel-link' style='display:none'>Use Panel Navigation</span></a>").appendTo("#side-nav");
+        chooseDefaultNav();
+        if ($("#nav-tree").is(':visible')) {
+          init_default_navtree("<?cs var:toroot ?>");
+        } else {
+          addLoadEvent(function() {
+            scrollIntoView("packages-nav");
+            scrollIntoView("classes-nav");
+          });
+        }
+        $("#swapper").css({borderBottom:"2px solid #aaa"});
+      } else {
+        swapNav(); // tree view should be used on mobile
+      }
+    </script><?cs 
+/def ?>
+
+<?cs 
+def:custom_left_nav() ?><?cs 
+  if:guide ?><?cs 
+    call:guide_nav() ?><?cs 
+  elif:resources ?><?cs 
+    call:resources_tab_nav() ?><?cs 
+  elif:sdk ?><?cs 
+    call:sdk_nav() ?><?cs 
+  else ?><?cs 
+    call:default_left_nav() ?><?cs 
+  /if ?><?cs 
+/def ?>
+
+<?cs # appears at the bottom of every page ?><?cs 
+def:custom_cc_copyright() ?>
+  Except as noted, this content is 
+  licensed under <a href="http://creativecommons.org/licenses/by/2.5/">
+  Creative Commons Attribution 2.5</a>. For details and 
+  restrictions, see the <a href="<?cs var:toroot ?>license.html">Content 
+  License</a>.<?cs 
+/def ?>
+
+<?cs 
+def:custom_copyright() ?>
+  Except as noted, this content is licensed under <a
+  href="http://www.apache.org/licenses/LICENSE-2.0">Apache 2.0</a>. 
+  For details and restrictions, see the <a href="<?cs var:toroot ?>license.html">
+  Content License</a>.<?cs 
+/def ?>
+
+<?cs 
+def:custom_footerlinks() ?>
+  <p>
+    <a href="http://www.android.com/terms.html">Site Terms of Service</a> -
+    <a href="http://www.android.com/privacy.html">Privacy Policy</a> -
+    <a href="http://www.android.com/branding.html">Brand Guidelines</a>
+  </p><?cs 
+/def ?>
+
+<?cs # appears on the right side of the blue bar at the bottom off every page ?><?cs 
+def:custom_buildinfo() ?>
+  Android <?cs var:sdk.version ?>&nbsp;r<?cs var:sdk.rel.id ?> - <?cs var:page.now ?>
+<?cs /def ?>
+
diff --git a/tools/droiddoc/templates/footer.cs b/tools/droiddoc/templates-sdk/footer.cs
similarity index 100%
copy from tools/droiddoc/templates/footer.cs
copy to tools/droiddoc/templates-sdk/footer.cs
diff --git a/tools/droiddoc/templates/head_tag.cs b/tools/droiddoc/templates-sdk/head_tag.cs
similarity index 92%
rename from tools/droiddoc/templates/head_tag.cs
rename to tools/droiddoc/templates-sdk/head_tag.cs
index 5a7fd40..fd8aad6 100644
--- a/tools/droiddoc/templates/head_tag.cs
+++ b/tools/droiddoc/templates-sdk/head_tag.cs
@@ -20,6 +20,9 @@
 if:reference ?>
 <script src="<?cs var:toroot ?>assets/android-developer-reference.js" type="text/javascript"></script>
 <script src="<?cs var:toroot ?>navtree_data.js" type="text/javascript"></script><?cs 
+/if ?><?cs 
+if:resources ?>
+<script src="<?cs var:toroot ?>resources/resources-data.js" type="text/javascript"></script><?cs 
 /if ?>
 <noscript>
   <style type="text/css">
@@ -31,4 +34,4 @@
     #resize-packages-nav{border-bottom:3px solid #666;}
   </style>
 </noscript>
-</head>
+</head>
\ No newline at end of file
diff --git a/tools/droiddoc/templates/sampleindex.cs b/tools/droiddoc/templates-sdk/sampleindex.cs
similarity index 66%
rename from tools/droiddoc/templates/sampleindex.cs
rename to tools/droiddoc/templates-sdk/sampleindex.cs
index 8a75298..81ba68c 100644
--- a/tools/droiddoc/templates/sampleindex.cs
+++ b/tools/droiddoc/templates-sdk/sampleindex.cs
@@ -10,17 +10,17 @@
 <a name="top"></a>
 <div class="g-unit" id="doc-content">
  <div id="jd-header" class="guide-header">
-  <span class="crumb">&nbsp;</span>
+    <span class="crumb">
+      <a href="<?cs var:toroot ?>resources/browser.html?tag=sample">Sample Code</a> >
+    </span>
   <h1><?cs var:page.title ?></h1>
  </div>
 
 <div id="jd-content">
+<p><a href="../index.html">&larr; Back</a></p>
 
 <?cs var:summary ?>
 
-<?cs if:android.whichdoc == "online" ?><?cs
-  # If this is the online docs, build the src code navigation links ?>
-
   <?cs if:subcount(subdirs) ?>
       <h2>Subdirectories</h2>
       <ul class="nolist">
@@ -41,17 +41,6 @@
       </ul>
   <?cs /if ?>
 
-<?cs else ?><?cs
-  # else, this means it's offline docs,
-          so don't show src links (we don't have the pages!) ?>
-
-<p>You can find the source code for this sample in your SDK at:</p>
-<p style="margin-left:2em">
-<code><em>&lt;sdk&gt;</em>/platforms/android-<em>&lt;version&gt;</em>/samples/</code>
-</p>
-
-<?cs /if ?><?cs # end if/else online docs ?>
-
 </div><!-- end jd-content -->
 
 <?cs include:"footer.cs" ?>
diff --git a/tools/droiddoc/templates-sdk/sdkpage.cs b/tools/droiddoc/templates-sdk/sdkpage.cs
index 6c35b81..331411f 100644
--- a/tools/droiddoc/templates-sdk/sdkpage.cs
+++ b/tools/droiddoc/templates-sdk/sdkpage.cs
@@ -209,8 +209,29 @@
   $("#next-steps").show();
 }
 </script>
-  <?cs /if ?> <?cs # end if online ?>
+  <?cs else ?> <?cs # end if online ?>
 
+    <?cs if:sdk.preview ?><?cs # it's preview offline docs ?>
+      <p>Welcome developers! We are pleased to provide you with a preview SDK for the upcoming
+    Android 3.0 release, to give you a head-start on developing applications for it.
+    </p>
+    
+      <p>See the <a
+    href="<?cs var:toroot ?>sdk/preview/start.html">Getting Started</a> document for more information
+    about how to set up the preview SDK and get started.</p>
+    <style type="text/css">
+    .non-preview { display:none; }
+    </style>
+    
+    <?cs else ?><?cs # it's normal offline docs ?>
+      <style type="text/css">
+        p.offline-message { display:block; }
+        p.online-message { display:none; }
+      </style>
+    <?cs /if ?>
+    
+  <?cs /if ?> <?cs # end if/else online ?>
+  
 <?cs /if ?> <?cs # end if/else NDK ?>
 
 <?cs /if ?> <?cs # end if/else redirect ?>
diff --git a/tools/droiddoc/templates/trailer.cs b/tools/droiddoc/templates-sdk/trailer.cs
similarity index 100%
copy from tools/droiddoc/templates/trailer.cs
copy to tools/droiddoc/templates-sdk/trailer.cs
diff --git a/tools/droiddoc/templates/class.cs b/tools/droiddoc/templates/class.cs
deleted file mode 100644
index d2add18..0000000
--- a/tools/droiddoc/templates/class.cs
+++ /dev/null
@@ -1,623 +0,0 @@
-<?cs include:"doctype.cs" ?>
-<?cs include:"macros.cs" ?>
-<html>
-<?cs include:"head_tag.cs" ?>
-<body class="<?cs var:class.since ?>">
-<?cs include:"header.cs" ?>
-
-<div class="g-unit" id="doc-content">
-
-<div id="api-info-block">
-
-<?cs # are there inherited members ?>
-<?cs each:cl=class.inherited ?>
-  <?cs if:subcount(cl.methods) ?>
-   <?cs set:inhmethods = #1 ?>
-  <?cs /if ?>
-  <?cs if:subcount(cl.constants) ?>
-   <?cs set:inhconstants = #1 ?>
-  <?cs /if ?>
-  <?cs if:subcount(cl.fields) ?>
-   <?cs set:inhfields = #1 ?>
-  <?cs /if ?>
-  <?cs if:subcount(cl.attrs) ?>
-   <?cs set:inhattrs = #1 ?>
-  <?cs /if ?>
-<?cs /each ?>
-
-<div class="sum-details-links">
-Summary:
-<?cs if:subcount(class.inners) ?>
-  <a href="#nestedclasses">Nested Classes</a>
-  <?cs set:linkcount = #1 ?>
-<?cs /if ?>
-<?cs if:subcount(class.attrs) ?>
-  <?cs if:linkcount ?>&#124; <?cs /if ?><a href="#lattrs">XML Attrs</a>
-  <?cs set:linkcount = #1 ?>
-<?cs /if ?>
-<?cs if:inhattrs ?>
-  <?cs if:linkcount ?>&#124; <?cs /if ?><a href="#inhattrs">Inherited XML Attrs</a>
-  <?cs set:linkcount = #1 ?>
-<?cs /if ?>
-<?cs if:subcount(class.enumConstants) ?>
-  <?cs if:linkcount ?>&#124; <?cs /if ?><a href="#enumconstants">Enums</a>
-  <?cs set:linkcount = #1 ?>
-<?cs /if ?>
-<?cs if:subcount(class.constants) ?>
-  <?cs if:linkcount ?>&#124; <?cs /if ?><a href="#constants">Constants</a>
-  <?cs set:linkcount = #1 ?>
-<?cs /if ?>
-<?cs if:inhconstants ?>
-  <?cs if:linkcount ?>&#124; <?cs /if ?><a href="#inhconstants">Inherited Constants</a>
-  <?cs set:linkcount = #1 ?>
-<?cs /if ?>
-<?cs if:subcount(class.fields) ?>
-  <?cs if:linkcount ?>&#124; <?cs /if ?><a href="#lfields">Fields</a>
-  <?cs set:linkcount = #1 ?>
-<?cs /if ?>
-<?cs if:inhfields ?>
-  <?cs if:linkcount ?>&#124; <?cs /if ?><a href="#inhfields">Inherited Fields</a>
-  <?cs set:linkcount = #1 ?>
-<?cs /if ?>
-<?cs if:subcount(class.ctors.public) ?>
-  <?cs if:linkcount ?>&#124; <?cs /if ?><a href="#pubctors">Ctors</a>
-  <?cs set:linkcount = #1 ?>
-<?cs /if ?>
-<?cs if:subcount(class.ctors.protected) ?>
-  <?cs if:linkcount ?>&#124; <?cs /if ?><a href="#proctors">Protected Ctors</a>
-  <?cs set:linkcount = #1 ?>
-<?cs /if ?>
-<?cs if:subcount(class.methods.public) ?>
-  <?cs if:linkcount ?>&#124; <?cs /if ?><a href="#pubmethods">Methods</a>
-  <?cs set:linkcount = #1 ?>
-<?cs /if ?>
-<?cs if:subcount(class.methods.protected) ?>
-  <?cs if:linkcount ?>&#124; <?cs /if ?><a href="#promethods">Protected Methods</a>
-  <?cs set:linkcount = #1 ?>
-<?cs /if ?>
-<?cs if:inhmethods ?>
-  <?cs if:linkcount ?>&#124; <?cs /if ?><a href="#inhmethods">Inherited Methods</a>
-<?cs /if ?>
-<?cs if:inhattrs || inhconstants || inhfields || inhmethods || subcount(class.subclasses.direct) || subcount(class.subclasses.indirect) ?>
-&#124; <a href="#" onclick="return toggleAllClassInherited()" id="toggleAllClassInherited">[Expand All]</a>
-<?cs /if ?>
-</div><!-- end sum-details-links -->
-<div class="api-level">
-  <?cs call:since_tags(class) ?>
-</div>
-</div><!-- end api-info-block -->
-
-<?cs # this next line must be exactly like this to be parsed by eclipse ?>
-<!-- ======== START OF CLASS DATA ======== -->
-
-<div id="jd-header">
-    <?cs var:class.scope ?>
-    <?cs var:class.static ?> 
-    <?cs var:class.final ?> 
-    <?cs var:class.abstract ?>
-    <?cs var:class.kind ?>
-<h1><?cs var:class.name ?></h1>
-
-<?cs set:colspan = subcount(class.inheritance) ?>
-<?cs each:supr = class.inheritance ?>
-  <?cs if:colspan == 2 ?>
-    extends <?cs call:type_link(supr.short_class) ?><br/>
-  <?cs /if ?>
-  <?cs if:last(supr) && subcount(supr.interfaces) ?>
-      implements 
-      <?cs each:t=supr.interfaces ?>
-        <?cs call:type_link(t) ?> 
-      <?cs /each ?>
-  <?cs /if ?>
-  <?cs set:colspan = colspan-1 ?>
-<?cs /each ?>
-
-</div><!-- end header -->
-
-<div id="naMessage"></div>
-
-<div id="jd-content" class="api apilevel-<?cs var:class.since ?>">
-<table class="jd-inheritance-table">
-<?cs set:colspan = subcount(class.inheritance) ?>
-<?cs each:supr = class.inheritance ?>
-    <tr>
-        <?cs loop:i = 1, (subcount(class.inheritance)-colspan), 1 ?>
-            <td class="jd-inheritance-space">&nbsp;<?cs if:(subcount(class.inheritance)-colspan) == i ?>&nbsp;&nbsp;&#x21b3;<?cs /if ?></td>
-        <?cs /loop ?> 	
-        <td colspan="<?cs var:colspan ?>" class="jd-inheritance-class-cell"><?cs
-            if:colspan == 1
-                ?><?cs call:class_name(class.qualifiedType) ?><?cs 
-            else 
-                ?><?cs call:type_link(supr.class) ?><?cs
-            /if ?></td>
-    </tr>
-    <?cs set:colspan = colspan-1 ?>
-<?cs /each ?>
-</table>
-
-<?cs # this next line must be exactly like this to be parsed by eclipse ?>
-
-<?cs if:subcount(class.subclasses.direct) ?>
-<table class="jd-sumtable jd-sumtable-subclasses"><tr><td colspan="12" style="border:none;margin:0;padding:0;">
-<?cs call:expando_trigger("subclasses-direct", "closed") ?>Known Direct Subclasses
-<?cs call:expandable_class_list("subclasses-direct", class.subclasses.direct, "list") ?>
-</td></tr></table>
-<?cs /if ?>
-
-<?cs if:subcount(class.subclasses.indirect) ?>
-<table class="jd-sumtable jd-sumtable-subclasses"><tr><td colspan="12" style="border:none;margin:0;padding:0;">
-<?cs call:expando_trigger("subclasses-indirect", "closed") ?>Known Indirect Subclasses
-<?cs call:expandable_class_list("subclasses-indirect", class.subclasses.indirect, "list") ?>
-</td></tr></table>
-<?cs /if ?>
-
-<div class="jd-descr">
-<?cs call:deprecated_warning(class) ?>
-<?cs if:subcount(class.descr) ?>
-<h2>Class Overview</h2>
-<p><?cs call:tag_list(class.descr) ?></p>
-<?cs /if ?>
-
-<?cs call:see_also_tags(class.seeAlso) ?>
-
-</div><!-- jd-descr -->
-
-
-<?cs # summary macros ?>
-
-<?cs def:write_method_summary(methods, included) ?>
-<?cs set:count = #1 ?>
-<?cs each:method = methods ?>
-	 <?cs # The apilevel-N class MUST BE LAST in the sequence of class names ?>
-    <tr class="<?cs if:count % #2 ?>alt-color<?cs /if ?> api apilevel-<?cs var:method.since ?>" >
-        <td class="jd-typecol"><nobr>
-            <?cs var:method.abstract ?>
-            <?cs var:method.synchronized ?>
-            <?cs var:method.final ?>
-            <?cs var:method.static ?>
-            <?cs call:type_link(method.generic) ?>
-            <?cs call:type_link(method.returnType) ?></nobr>
-        </td>
-        <td class="jd-linkcol" width="100%"><nobr>
-        <span class="sympad"><?cs call:cond_link(method.name, toroot, method.href, included) ?></span>(<?cs call:parameter_list(method.params) ?>)</nobr>
-        <?cs if:subcount(method.shortDescr) || subcount(method.deprecated) ?>
-        <div class="jd-descrdiv"><?cs call:short_descr(method) ?></div>
-  <?cs /if ?>
-  </td></tr>
-<?cs set:count = count + #1 ?>
-<?cs /each ?>
-<?cs /def ?>
-
-<?cs def:write_field_summary(fields, included) ?>
-<?cs set:count = #1 ?>
-    <?cs each:field=fields ?>
-      <tr class="<?cs if:count % #2 ?>alt-color<?cs /if ?> api apilevel-<?cs var:field.since ?>" >
-          <td class="jd-typecol"><nobr>
-          <?cs var:field.scope ?>
-          <?cs var:field.static ?>
-          <?cs var:field.final ?>
-          <?cs call:type_link(field.type) ?></nobr></td>
-          <td class="jd-linkcol"><?cs call:cond_link(field.name, toroot, field.href, included) ?></td>
-          <td class="jd-descrcol" width="100%"><?cs call:short_descr(field) ?></td>
-      </tr>
-      <?cs set:count = count + #1 ?>
-    <?cs /each ?>
-<?cs /def ?>
-
-<?cs def:write_constant_summary(fields, included) ?>
-<?cs set:count = #1 ?>
-    <?cs each:field=fields ?>
-    <tr class="<?cs if:count % #2 ?>alt-color<?cs /if ?> api apilevel-<?cs var:field.since ?>" >
-        <td class="jd-typecol"><?cs call:type_link(field.type) ?></td>
-        <td class="jd-linkcol"><?cs call:cond_link(field.name, toroot, field.href, included) ?></td>
-        <td class="jd-descrcol" width="100%"><?cs call:short_descr(field) ?></td>
-    </tr>
-    <?cs set:count = count + #1 ?>
-    <?cs /each ?>
-<?cs /def ?>
-
-<?cs def:write_attr_summary(attrs, included) ?>
-<?cs set:count = #1 ?>
-    <tr>
-        <td><nobr><em>Attribute Name</em></nobr></td>
-        <td><nobr><em>Related Method</em></nobr></td>
-        <td><nobr><em>Description</em></nobr></td>
-    </tr>
-    <?cs each:attr=attrs ?>
-    <tr class="<?cs if:count % #2 ?>alt-color<?cs /if ?> api apilevel-<?cs var:attr.since ?>" >
-        <td class="jd-linkcol"><?cs if:included ?><a href="<?cs var:toroot ?><?cs var:attr.href ?>"><?cs /if ?><?cs var:attr.name ?><?cs if:included ?></a><?cs /if ?></td>
-        <td class="jd-linkcol"><?cs each:m=attr.methods ?>
-            <?cs call:cond_link(m.name, toroot, m.href, included) ?>
-            <?cs /each ?>
-        </td>
-        <td class="jd-descrcol" width="100%"><?cs call:short_descr(attr) ?>&nbsp;</td>
-    </tr>
-    <?cs set:count = count + #1 ?>
-    <?cs /each ?>
-<?cs /def ?>
-
-<?cs def:write_inners_summary(classes) ?>
-<?cs set:count = #1 ?>
-  <?cs each:cl=class.inners ?>
-    <tr class="<?cs if:count % #2 ?>alt-color<?cs /if ?> api apilevel-<?cs var:cl.since ?>" >
-      <td class="jd-typecol"><nobr>
-        <?cs var:cl.scope ?>
-        <?cs var:cl.static ?> 
-        <?cs var:cl.final ?> 
-        <?cs var:cl.abstract ?>
-        <?cs var:cl.kind ?></nobr></td>
-      <td class="jd-linkcol"><?cs call:type_link(cl.type) ?></td>
-      <td class="jd-descrcol" width="100%"><?cs call:short_descr(cl) ?>&nbsp;</td>
-    </tr>
-    <?cs set:count = count + #1 ?>
-    <?cs /each ?>
-<?cs /def ?>
-
-<?cs # end macros ?>
-
-<div class="jd-descr">
-<h2>Summary</h2>
-
-<?cs if:subcount(class.inners) ?>
-<?cs # this next line must be exactly like this to be parsed by eclipse ?>
-<!-- ======== NESTED CLASS SUMMARY ======== -->
-<table id="nestedclasses" class="jd-sumtable"><tr><th colspan="12">Nested Classes</th></tr>
-<?cs call:write_inners_summary(class.inners) ?>
-<?cs /if ?>
-
-<?cs # this next line must be exactly like this to be parsed by eclipse ?>
-<?cs if:subcount(class.attrs) ?>
-<!-- =========== FIELD SUMMARY =========== -->
-<table id="lattrs" class="jd-sumtable"><tr><th colspan="12">XML Attributes</th></tr>
-<?cs call:write_attr_summary(class.attrs, 1) ?>
-<?cs /if ?>
-
-<?cs # if there are inherited attrs, write the table ?>
-<?cs if:inhattrs ?>
-<?cs # this next line must be exactly like this to be parsed by eclipse ?>
-<!-- =========== FIELD SUMMARY =========== -->
-<table id="inhattrs" class="jd-sumtable"><tr><th>
-  <a href="#" class="toggle-all" onclick="return toggleAllInherited(this, null)">[Expand]</a>
-  <div style="clear:left;">Inherited XML Attributes</div></th></tr>
-<?cs each:cl=class.inherited ?>
-<?cs if:subcount(cl.attrs) ?>
-<tr class="api apilevel-<?cs var:cl.since ?>" >
-<td colspan="12">
-<?cs call:expando_trigger("inherited-attrs-"+cl.qualified, "closed") ?>From <?cs var:cl.kind ?>
-<?cs call:cond_link(cl.qualified, toroot, cl.link, cl.included) ?>
-<div id="inherited-attrs-<?cs var:cl.qualified ?>">
-  <div id="inherited-attrs-<?cs var:cl.qualified ?>-list"
-        class="jd-inheritedlinks">
-  </div>
-  <div id="inherited-attrs-<?cs var:cl.qualified ?>-summary" style="display: none;">
-    <table class="jd-sumtable-expando">
-    <?cs call:write_attr_summary(cl.attrs, cl.included) ?></table>
-  </div>
-</div>
-</td></tr>
-<?cs /if ?>
-<?cs /each ?>
-</table>
-<?cs /if ?>
-
-<?cs if:subcount(class.enumConstants) ?>
-<?cs # this next line must be exactly like this to be parsed by eclipse ?>
-<!-- =========== ENUM CONSTANT SUMMARY =========== -->
-<table id="enumconstants" class="jd-sumtable"><tr><th colspan="12">Enum Values</th></tr>
-<?cs set:count = #1 ?>
-    <?cs each:field=class.enumConstants ?>
-    <tr class="<?cs if:count % #2 ?>alt-color<?cs /if ?> api apilevel-<?cs var:field.since ?>" >
-        <td class="jd-descrcol"><?cs call:type_link(field.type) ?>&nbsp;</td>
-        <td class="jd-linkcol"><?cs call:cond_link(field.name, toroot, field.href, cl.included) ?>&nbsp;</td>
-        <td class="jd-descrcol" width="100%"><?cs call:short_descr(field) ?>&nbsp;</td>
-    </tr>
-    <?cs set:count = count + #1 ?>
-    <?cs /each ?>
-<?cs /if ?>
-
-<?cs if:subcount(class.constants) ?>
-<?cs # this next line must be exactly like this to be parsed by eclipse ?>
-<!-- =========== ENUM CONSTANT SUMMARY =========== -->
-<table id="constants" class="jd-sumtable"><tr><th colspan="12">Constants</th></tr>
-<?cs call:write_constant_summary(class.constants, 1) ?>
-</table>
-<?cs /if ?>
-
-<?cs # if there are inherited constants, write the table ?>
-<?cs if:inhconstants ?>
-<?cs # this next line must be exactly like this to be parsed by eclipse ?>
-<!-- =========== ENUM CONSTANT SUMMARY =========== -->
-<table id="inhconstants" class="jd-sumtable"><tr><th>
-  <a href="#" class="toggle-all" onclick="return toggleAllInherited(this, null)">[Expand]</a>
-  <div style="clear:left;">Inherited Constants</div></th></tr>
-<?cs each:cl=class.inherited ?>
-<?cs if:subcount(cl.constants) ?>
-<tr class="api apilevel-<?cs var:cl.since ?>" >
-<td colspan="12">
-<?cs call:expando_trigger("inherited-constants-"+cl.qualified, "closed") ?>From <?cs var:cl.kind ?>
-<?cs call:cond_link(cl.qualified, toroot, cl.link, cl.included) ?>
-<div id="inherited-constants-<?cs var:cl.qualified ?>">
-  <div id="inherited-constants-<?cs var:cl.qualified ?>-list"
-        class="jd-inheritedlinks">
-  </div>
-  <div id="inherited-constants-<?cs var:cl.qualified ?>-summary" style="display: none;">
-    <table class="jd-sumtable-expando">
-    <?cs call:write_constant_summary(cl.constants, cl.included) ?></table>
-  </div>
-</div>
-</td></tr>
-<?cs /if ?>
-<?cs /each ?>
-</table>
-<?cs /if ?>
-
-<?cs if:subcount(class.fields) ?>
-<?cs # this next line must be exactly like this to be parsed by eclipse ?>
-<!-- =========== FIELD SUMMARY =========== -->
-<table id="lfields" class="jd-sumtable"><tr><th colspan="12">Fields</th></tr>
-<?cs call:write_field_summary(class.fields, 1) ?>
-</table>
-<?cs /if ?>
-
-<?cs # if there are inherited fields, write the table ?>
-<?cs if:inhfields ?>
-<?cs # this next line must be exactly like this to be parsed by eclipse ?>
-<!-- =========== FIELD SUMMARY =========== -->
-<table id="inhfields" class="jd-sumtable"><tr><th>
-  <a href="#" class="toggle-all" onclick="return toggleAllInherited(this, null)">[Expand]</a>
-  <div style="clear:left;">Inherited Fields</div></th></tr>
-<?cs each:cl=class.inherited ?>
-<?cs if:subcount(cl.fields) ?>
-<tr class="api apilevel-<?cs var:cl.since ?>" >
-<td colspan="12">
-<?cs call:expando_trigger("inherited-fields-"+cl.qualified, "closed") ?>From <?cs var:cl.kind ?>
-<?cs call:cond_link(cl.qualified, toroot, cl.link, cl.included) ?>
-<div id="inherited-fields-<?cs var:cl.qualified ?>">
-  <div id="inherited-fields-<?cs var:cl.qualified ?>-list"
-        class="jd-inheritedlinks">
-  </div>
-  <div id="inherited-fields-<?cs var:cl.qualified ?>-summary" style="display: none;">
-    <table class="jd-sumtable-expando">
-    <?cs call:write_field_summary(cl.fields, cl.included) ?></table>
-  </div>
-</div>
-</td></tr>
-<?cs /if ?>
-<?cs /each ?>
-</table>
-<?cs /if ?>
-
-<?cs if:subcount(class.ctors.public) ?>
-<?cs # this next line must be exactly like this to be parsed by eclipse ?>
-<!-- ======== CONSTRUCTOR SUMMARY ======== -->
-<table id="pubctors" class="jd-sumtable"><tr><th colspan="12">Public Constructors</th></tr>
-<?cs call:write_method_summary(class.ctors.public, 1) ?>
-</table>
-<?cs /if ?>
-
-<?cs if:subcount(class.ctors.protected) ?>
-<?cs # this next line must be exactly like this to be parsed by eclipse ?>
-<!-- ======== CONSTRUCTOR SUMMARY ======== -->
-<table id="proctors" class="jd-sumtable"><tr><th colspan="12">Protected Constructors</th></tr>
-<?cs call:write_method_summary(class.ctors.protected, 1) ?>
-</table>
-<?cs /if ?>
-
-<?cs if:subcount(class.methods.public) ?>
-<?cs # this next line must be exactly like this to be parsed by eclipse ?>
-<!-- ========== METHOD SUMMARY =========== -->
-<table id="pubmethods" class="jd-sumtable"><tr><th colspan="12">Public Methods</th></tr>
-<?cs call:write_method_summary(class.methods.public, 1) ?>
-</table>
-<?cs /if ?>
-
-<?cs if:subcount(class.methods.protected) ?>
-<?cs # this next line must be exactly like this to be parsed by eclipse ?>
-<!-- ========== METHOD SUMMARY =========== -->
-<table id="promethods" class="jd-sumtable"><tr><th colspan="12">Protected Methods</th></tr>
-<?cs call:write_method_summary(class.methods.protected, 1) ?>
-</table>
-<?cs /if ?>
-
-<?cs # if there are inherited methods, write the table ?>
-<?cs if:inhmethods ?>
-<?cs # this next line must be exactly like this to be parsed by eclipse ?>
-<!-- ========== METHOD SUMMARY =========== -->
-<table id="inhmethods" class="jd-sumtable"><tr><th>
-  <a href="#" class="toggle-all" onclick="return toggleAllInherited(this, null)">[Expand]</a>
-  <div style="clear:left;">Inherited Methods</div></th></tr>
-<?cs each:cl=class.inherited ?>
-<?cs if:subcount(cl.methods) ?>
-<tr class="api apilevel-<?cs var:cl.since ?>" >
-<td colspan="12"><?cs call:expando_trigger("inherited-methods-"+cl.qualified, "closed") ?>
-From <?cs var:cl.kind ?> <?cs call:cond_link(cl.qualified, toroot, cl.link, cl.included) ?>
-<div id="inherited-methods-<?cs var:cl.qualified ?>">
-  <div id="inherited-methods-<?cs var:cl.qualified ?>-list"
-        class="jd-inheritedlinks">
-  </div>
-  <div id="inherited-methods-<?cs var:cl.qualified ?>-summary" style="display: none;">
-    <table class="jd-sumtable-expando">
-    <?cs call:write_method_summary(cl.methods, cl.included) ?></table>
-  </div>
-</div>
-</td></tr>
-<?cs /if ?>
-<?cs /each ?>
-</table>
-<?cs /if ?>
-
-</div><!-- jd-descr (summary) -->
-
-<!-- Details -->
-
-<?cs def:write_field_details(fields) ?>
-<?cs each:field=fields ?>
-<?cs # this next line must be exactly like this to be parsed by eclipse ?>
-<?cs # the A tag in the next line must remain where it is, so that Eclipse can parse the docs ?>
-<A NAME="<?cs var:field.anchor ?>"></A>
-<?cs # The apilevel-N class MUST BE LAST in the sequence of class names ?>
-<div class="jd-details api apilevel-<?cs var:field.since ?>"> 
-    <h4 class="jd-details-title">
-      <span class="normal">
-        <?cs var:field.scope ?> 
-        <?cs var:field.static ?> 
-        <?cs var:field.final ?> 
-        <?cs call:type_link(field.type) ?>
-      </span>
-        <?cs var:field.name ?>
-    </h4>
-      <div class="api-level">
-        <?cs call:since_tags(field) ?>
-      </div>
-    <div class="jd-details-descr">
-      <?cs call:description(field) ?>
-    <?cs if:subcount(field.constantValue) ?>
-        <div class="jd-tagdata">
-        <span class="jd-tagtitle">Constant Value: </span>
-        <span>
-            <?cs if:field.constantValue.isString ?>
-                <?cs var:field.constantValue.str ?>
-            <?cs else ?>
-                <?cs var:field.constantValue.dec ?>
-                (<?cs var:field.constantValue.hex ?>)
-            <?cs /if ?>
-        </span>
-        </div>
-    <?cs /if ?>
-    </div>
-</div>
-<?cs /each ?>
-<?cs /def ?>
-
-<?cs def:write_method_details(methods) ?>
-<?cs each:method=methods ?>
-<?cs # the A tag in the next line must remain where it is, so that Eclipse can parse the docs ?>
-<A NAME="<?cs var:method.anchor ?>"></A>
-<?cs # The apilevel-N class MUST BE LAST in the sequence of class names ?>
-<div class="jd-details api apilevel-<?cs var:method.since ?>"> 
-    <h4 class="jd-details-title">
-      <span class="normal">
-        <?cs var:method.scope ?> 
-        <?cs var:method.static ?> 
-        <?cs var:method.final ?> 
-        <?cs var:method.abstract ?> 
-        <?cs var:method.synchronized ?> 
-        <?cs call:type_link(method.returnType) ?>
-      </span>
-      <span class="sympad"><?cs var:method.name ?></span>
-      <span class="normal">(<?cs call:parameter_list(method.params) ?>)</span>
-    </h4>
-      <div class="api-level">
-        <?cs call:since_tags(method) ?>
-      </div>
-    <div class="jd-details-descr">
-      <?cs call:description(method) ?>
-    </div>
-</div>
-<?cs /each ?>
-<?cs /def ?>
-
-<?cs def:write_attr_details(attrs) ?>
-<?cs each:attr=attrs ?>
-<?cs # the A tag in the next line must remain where it is, so that Eclipse can parse the docs ?>
-<A NAME="<?cs var:attr.anchor ?>"></A>
-<?cs # The apilevel-N class MUST BE LAST in the sequence of class names ?>
-<div class="jd-details api apilevel-<?cs var:attr.since ?>"> 
-    <h4 class="jd-details-title"><?cs var:attr.name ?>
-    </h4>
-      <div class="api-level">
-        <?cs call:since_tags(attr) ?>
-      </div>
-    <div class="jd-details-descr">
-        <?cs call:description(attr) ?>
-
-        <div class="jd-tagdata">
-            <h5 class="jd-tagtitle">Related Methods</h5>
-            <ul class="nolist">
-            <?cs each:m=attr.methods ?>
-                <li><a href="<?cs var:toroot ?><?cs var:m.href ?>"><?cs var:m.name ?></a></li>
-            <?cs /each ?>
-            </ul>
-        </div>
-    </div>
-</div>
-<?cs /each ?>
-<?cs /def ?>
-
-
-<!-- XML Attributes -->
-<?cs if:subcount(class.attrs) ?>
-<?cs # this next line must be exactly like this to be parsed by eclipse ?>
-<!-- ========= FIELD DETAIL ======== -->
-<h2>XML Attributes</h2>
-<?cs call:write_attr_details(class.attrs) ?>
-<?cs /if ?>
-
-<!-- Enum Values -->
-<?cs if:subcount(class.enumConstants) ?>
-<?cs # this next line must be exactly like this to be parsed by eclipse ?>
-<!-- ========= ENUM CONSTANTS DETAIL ======== -->
-<h2>Enum Values</h2>
-<?cs call:write_field_details(class.enumConstants) ?>
-<?cs /if ?>
-
-<!-- Constants -->
-<?cs if:subcount(class.constants) ?>
-<?cs # this next line must be exactly like this to be parsed by eclipse ?>
-<!-- ========= ENUM CONSTANTS DETAIL ======== -->
-<h2>Constants</h2>
-<?cs call:write_field_details(class.constants) ?>
-<?cs /if ?>
-
-<!-- Fields -->
-<?cs if:subcount(class.fields) ?>
-<?cs # this next line must be exactly like this to be parsed by eclipse ?>
-<!-- ========= FIELD DETAIL ======== -->
-<h2>Fields</h2>
-<?cs call:write_field_details(class.fields) ?>
-<?cs /if ?>
-
-<!-- Public ctors -->
-<?cs if:subcount(class.ctors.public) ?>
-<?cs # this next line must be exactly like this to be parsed by eclipse ?>
-<!-- ========= CONSTRUCTOR DETAIL ======== -->
-<h2>Public Constructors</h2>
-<?cs call:write_method_details(class.ctors.public) ?>
-<?cs /if ?>
-
-<?cs # this next line must be exactly like this to be parsed by eclipse ?>
-<!-- ========= CONSTRUCTOR DETAIL ======== -->
-<!-- Protected ctors -->
-<?cs if:subcount(class.ctors.protected) ?>
-<h2>Protected Constructors</h2>
-<?cs call:write_method_details(class.ctors.protected) ?>
-<?cs /if ?>
-
-<?cs # this next line must be exactly like this to be parsed by eclipse ?>
-<!-- ========= METHOD DETAIL ======== -->
-<!-- Public methdos -->
-<?cs if:subcount(class.methods.public) ?>
-<h2>Public Methods</h2>
-<?cs call:write_method_details(class.methods.public) ?>
-<?cs /if ?>
-
-<?cs # this next line must be exactly like this to be parsed by eclipse ?>
-<!-- ========= METHOD DETAIL ======== -->
-<?cs if:subcount(class.methods.protected) ?>
-<h2>Protected Methods</h2>
-<?cs call:write_method_details(class.methods.protected) ?>
-<?cs /if ?>
-
-<?cs # the next two lines must be exactly like this to be parsed by eclipse ?>
-<!-- ========= END OF CLASS DATA ========= -->
-<A NAME="navbar_top"></A>
-
-<?cs include:"footer.cs" ?>
-</div> <!-- jd-content -->
-
-</div><!-- end doc-content -->
-
-<?cs include:"trailer.cs" ?>
-
-</body>
-</html>
diff --git a/tools/droiddoc/templates/classes.cs b/tools/droiddoc/templates/classes.cs
deleted file mode 100644
index 5a8315f..0000000
--- a/tools/droiddoc/templates/classes.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-<?cs include:"doctype.cs" ?>
-<?cs include:"macros.cs" ?>
-<html>
-<?cs include:"head_tag.cs" ?>
-<?cs include:"header.cs" ?>
-
-<div class="g-unit" id="doc-content">
-
-<div id="jd-header">
-<h1><?cs var:page.title ?></h1>
-</div>
-
-<div id="jd-content">
-
-<div class="jd-letterlist"><?cs each:letter=docs.classes ?>
-    <a href="#letter_<?cs name:letter ?>"><?cs name:letter ?></a><?cs /each?>
-</div>
-
-<?cs each:letter=docs.classes ?>
-<?cs set:count = #1 ?>
-<h2 id="letter_<?cs name:letter ?>"><?cs name:letter ?></h2>
-<table class="jd-sumtable">
-    <?cs set:cur_row = #0 ?>
-    <?cs each:cl = letter ?>
-        <tr class="<?cs if:count % #2 ?>alt-color<?cs /if ?> api apilevel-<?cs var:cl.since ?>" >
-            <td class="jd-linkcol"><?cs call:type_link(cl.type) ?></td>
-            <td class="jd-descrcol" width="100%"><?cs call:short_descr(cl) ?>&nbsp;</td>
-        </tr>
-    <?cs set:count = count + #1 ?>
-    <?cs /each ?>
-</table>
-<?cs /each ?>
-
-<?cs include:"footer.cs" ?>
-</div><!-- end jd-content -->
-</div><!-- end doc-content -->
-
-<?cs include:"trailer.cs" ?>
-
-</body>
-</html>
\ No newline at end of file
diff --git a/tools/droiddoc/templates/customization.cs b/tools/droiddoc/templates/customization.cs
deleted file mode 100644
index f6a5c1a..0000000
--- a/tools/droiddoc/templates/customization.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-<?cs # This default template file is meant to be replaced.                      ?>
-<?cs # Use the -templatedir arg to javadoc to set your own directory with a     ?>
-<?cs # replacement for this file in it. ?>
-
-
-<?cs def:default_search_box() ?><?cs /def ?>
-<?cs def:default_left_nav() ?><?cs /def ?>
-
-<?cs # appears at the top of every page ?><?cs 
-def:custom_masthead() ?>
-  <div id="header">
-      <div id="headerLeft">
-          <a href="<?cs var:toroot ?>index.html" tabindex="-1"><?cs var:page.title ?></a>
-      </div>
-      <div id="headerRight">
-          <?cs if:!online-pdk ?>
-            <?cs call:default_search_box() ?>
-          <?cs /if ?>
-      </div><!-- headerRight -->
-  </div><!-- header --><?cs 
-/def ?>
-
-<?cs # appear at the bottom of every page ?>
-<?cs def:custom_copyright() ?><?cs /def ?>
-<?cs def:custom_cc_copyright() ?><?cs /def ?>
-<?cs def:custom_footerlinks() ?><?cs /def ?>
-<?cs def:custom_buildinfo() ?>Build <?cs var:page.build ?> - <?cs var:page.now ?><?cs /def ?>
-
-<?cs # appears on the side of the page ?>
-<?cs def:custom_left_nav() ?><?cs call:default_left_nav() ?><?cs /def ?>
-
diff --git a/tools/droiddoc/templates/docpage.cs b/tools/droiddoc/templates/docpage.cs
deleted file mode 100644
index 9d85c6f..0000000
--- a/tools/droiddoc/templates/docpage.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-<?cs include:"doctype.cs" ?>
-<?cs include:"macros.cs" ?>
-<html>
-<?cs include:"head_tag.cs" ?>
-<body class="gc-documentation">
-<?cs include:"header.cs" ?>
-
-<div class="g-unit" id="doc-content"><a name="top"></a>
-
-<div id="jd-header" class="guide-header">
-  <span class="crumb">
-    <?cs if:parent.link ?>
-      <a href="<?cs var:parent.link ?>"><?cs var:parent.title ?></a> >
-    <?cs else ?>&nbsp;
-    <?cs /if ?>
-  </span>
-<h1><?cs var:page.title ?></h1>
-</div>
-
-  <div id="jd-content">
-
-    <div class="jd-descr">
-    <?cs call:tag_list(root.descr) ?>
-    </div>
-
-  <a href="#top" style="float:right">&uarr; Go to top</a>
-  <?cs if:parent.link ?>
-    <p><a href="<?cs var:parent.link ?>">&larr; Back to <?cs var:parent.title ?></a></p>
-  <?cs /if ?>
-  </div>
-
-<?cs include:"footer.cs" ?>
-</div><!-- end doc-content -->
-
-<?cs include:"trailer.cs" ?>
-
-</body>
-</html>
-
-
-
diff --git a/tools/droiddoc/templates/doctype.cs b/tools/droiddoc/templates/doctype.cs
deleted file mode 100644
index 763b073..0000000
--- a/tools/droiddoc/templates/doctype.cs
+++ /dev/null
@@ -1 +0,0 @@
-<!DOCTYPE html>
\ No newline at end of file
diff --git a/tools/droiddoc/templates/header.cs b/tools/droiddoc/templates/header.cs
deleted file mode 100644
index e8301be..0000000
--- a/tools/droiddoc/templates/header.cs
+++ /dev/null
@@ -1,3 +0,0 @@
-<?cs call:custom_masthead() ?>
-<?cs call:custom_left_nav() ?>
-
diff --git a/tools/droiddoc/templates/hierarchy.cs b/tools/droiddoc/templates/hierarchy.cs
deleted file mode 100644
index a607ffd..0000000
--- a/tools/droiddoc/templates/hierarchy.cs
+++ /dev/null
@@ -1,68 +0,0 @@
-<?cs include:"macros.cs" ?>
-<html>
-<style>
-    .jd-hierarchy-spacer {
-        width: 15px;
-    }
-    .jd-hierarchy-data {
-        text-align: left;
-        vertical-align: top;
-    }
-</style>
-<?cs include:"head_tag.cs" ?>
-<?cs include:"header.cs" ?>
-
-<div class="g-unit" id="doc-content">
-
-<div id="jd-header">
-<h1><?cs var:page.title ?></h1>
-</div>
-
-<div id="jd-content">
-
-<div style="margin-left: 20px; margin-right: 20px;">
-
-<?cs def:hierarchy_list(classes) ?>
-<?cs each:cl = classes ?>
-<tr>
-    <?cs loop:x=#0,cl.indent,#1 ?><td class="jd-hierarchy-spacer"></td><?cs /loop ?>
-    <td class="jd-hierarchy-data" colspan="<?cs var:cl.colspan ?>">
-    <?cs if:cl.exists ?>
-        <?cs call:type_link(cl.class) ?>
-    <?cs else ?>
-        <?cs var:cl.value ?>
-    <?cs /if ?>
-    </td>
-    <td class="jd-hierarchy-data">
-    <?cs each:iface = cl.interfaces ?>
-        <?cs if:iface.exists ?>
-            <?cs call:type_link(iface.class) ?>
-        <?cs else ?>
-            <?cs var:iface.value ?>
-        <?cs /if ?> &nbsp;&nbsp;
-    <?cs /each ?>
-    &nbsp;
-    </td>
-</tr>
-<?cs call:hierarchy_list(cl.derived) ?>
-<?cs /each ?>
-<?cs /def ?>
-
-
-<table border="0" cellpadding="0" cellspacing="1">
-<th class="jd-hierarchy-data" colspan="<?cs var:colspan ?>">Class</th>
-<th class="jd-hierarchy-data">Interfaces</th>
-<?cs call:hierarchy_list(classes) ?>
-</table>
-
-</div>
-
-<?cs include:"footer.cs" ?>
-</div><!-- end jd-content -->
-</div><!-- end doc-content -->
-
-<?cs include:"trailer.cs" ?>
-
-</body>
-</html>
-
diff --git a/tools/droiddoc/templates/index.cs b/tools/droiddoc/templates/index.cs
deleted file mode 100644
index 15a6a59..0000000
--- a/tools/droiddoc/templates/index.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-<html>
-<head>
-<meta http-equiv="refresh" content="0;url=packages.html">
-</head>
-<body>
-<?cs include:"analytics.cs" ?>
-</body>
-</html>
\ No newline at end of file
diff --git a/tools/droiddoc/templates/keywords.cs b/tools/droiddoc/templates/keywords.cs
deleted file mode 100644
index 0c8d4e3..0000000
--- a/tools/droiddoc/templates/keywords.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-<?cs include:"macros.cs" ?>
-<html>
-<?cs include:"head_tag.cs" ?>
-<?cs include:"header.cs" ?>
-
-<div class="g-unit" id="doc-content">
-
-<div id="jd-header">
-<h1><?cs var:page.title ?></h1>
-</div>
-
-<div id="jd-content">
-
-<div class="jd-letterlist"><?cs each:letter=keywords ?>
-    <a href="#letter_<?cs name:letter ?>"><?cs name:letter ?></a><?cs /each?>
-</div>
-
-<?cs each:letter=keywords ?>
-<a name="letter_<?cs name:letter ?>"></a>
-<h2><?cs name:letter ?></h2>
-<ul class="jd-letterentries">
-<?cs each:entry=letter
-?>  <li><a href="<?cs var:toroot ?><?cs var:entry.href ?>"><?cs var:entry.label
-        ?></a>&nbsp;<font class="jd-letterentrycomments">(<?cs var:entry.comment ?>)</font></li>
-<?cs /each
-?></ul>
-
-<?cs /each ?>
-
-<?cs include:"footer.cs" ?>
-</div><!-- end jd-content -->
-</div><!-- end doc-content -->
-
-<?cs include:"trailer.cs" ?>
-
-</body>
-</html>
diff --git a/tools/droiddoc/templates/lists.cs b/tools/droiddoc/templates/lists.cs
deleted file mode 100644
index 0af32b2..0000000
--- a/tools/droiddoc/templates/lists.cs
+++ /dev/null
@@ -1,5 +0,0 @@
-var DATA = [
-<?cs each:page = docs.pages
-?>      { id:<?cs var: page.id ?>, label:"<?cs var:page.label ?>", link:"<?cs var:page.link ?>", type:"<?cs var:page.type ?>" }<?cs if:!last(page) ?>,<?cs /if ?>
-<?cs /each ?>
-    ];
diff --git a/tools/droiddoc/templates/macros.cs b/tools/droiddoc/templates/macros.cs
deleted file mode 100644
index b5fd3f2..0000000
--- a/tools/droiddoc/templates/macros.cs
+++ /dev/null
@@ -1,266 +0,0 @@
-<?cs # A link to a package ?><?cs 
-def:package_link(pkg)) ?>
-  <a href="<?cs var:toroot ?><?cs var:pkg.link ?>"><?cs var:pkg.name ?></a><?cs 
-/def ?>
-
-<?cs # A link to a type, or not if it's a primitive type
-        link: whether to create a link at the top level, always creates links in
-              recursive invocations.
-        Expects the following fields:
-            .name
-            .link
-            .isPrimitive
-            .superBounds.N.(more links)   (... super ... & ...)
-            .extendsBounds.N.(more links) (... extends ... & ...)
-            .typeArguments.N.(more links) (< ... >)
-?><?cs 
-def:type_link_impl(type, link) ?><?cs
-  if:type.link && link=="true" ?><a href="<?cs var:toroot ?><?cs var:type.link ?>"><?cs /if
-      ?><?cs var:type.label ?><?cs if:type.link && link=="true" ?></a><?cs /if ?><?cs
-  if:subcount(type.extendsBounds) ?><?cs
-      each:t=type.extendsBounds ?><?cs
-          if:first(t) ?>&nbsp;extends&nbsp;<?cs else ?>&nbsp;&amp;&nbsp;<?cs /if ?><?cs
-          call:type_link_impl(t, "true") ?><?cs
-      /each ?><?cs
-  /if ?><?cs
-  if:subcount(type.superBounds) ?><?cs
-      each:t=type.superBounds ?><?cs
-          if:first(t) ?>&nbsp;super&nbsp;<?cs else ?>&nbsp;&amp;&nbsp;<?cs /if ?><?cs
-          call:type_link_impl(t, "true") ?><?cs
-      /each ?><?cs
-  /if ?><?cs
-  if:subcount(type.typeArguments)
-      ?>&lt;<?cs each:t=type.typeArguments ?><?cs call:type_link_impl(t, "true") ?><?cs
-          if:!last(t) ?>,&nbsp;<?cs /if ?><?cs
-      /each ?>&gt;<?cs
-  /if ?><?cs
-/def ?>
-
-<?cs def:class_name(type) ?><?cs call:type_link_impl(type, "false") ?><?cs /def ?>
-<?cs def:type_link(type) ?><?cs call:type_link_impl(type, "true") ?><?cs /def ?>
-
-<?cs # a conditional link.
-      if the "condition" parameter evals to true then the link is displayed
-      otherwise only the text is displayed
-?><?cs
-def:cond_link(text, root, path, condition) ?><?cs
-  if:condition ?><a href="<?cs var:root ?><?cs var:path ?>"><?cs /if ?><?cs var:text ?><?cs if:condition ?></a><?cs /if ?><?cs
-/def ?>
-
-
-<?cs # A comma separated parameter list ?><?cs 
-def:parameter_list(params) ?><?cs
-  each:param = params ?><?cs
-      call:type_link(param.type)?> <?cs
-      var:param.name ?><?cs
-      if: name(param)!=subcount(params)-1?>, <?cs /if ?><?cs
-  /each ?><?cs
-/def ?>
-
-<?cs # Print a list of tags (e.g. description text ?><?cs 
-def:tag_list(tags) ?><?cs
-  each:tag = tags ?><?cs
-      if:tag.name == "Text" ?><?cs var:tag.text?><?cs
-      elif:tag.kind == "@more" ?><p><?cs
-      elif:tag.kind == "@see" ?><code><a href="<?cs var:toroot ?><?cs var:tag.href ?>"><?cs var:tag.label ?></a></code><?cs
-      elif:tag.kind == "@seeHref" ?><a href="<?cs var:tag.href ?>"><?cs var:tag.label ?></a><?cs
-      elif:tag.kind == "@seeJustLabel" ?><?cs var:tag.label ?><?cs
-      elif:tag.kind == "@code" ?><code><?cs var:tag.text ?></code><?cs
-      elif:tag.kind == "@samplecode" ?><pre><?cs var:tag.text ?></pre><?cs
-      elif:tag.name == "@sample" ?><pre><?cs var:tag.text ?></pre><?cs
-      elif:tag.name == "@include" ?><?cs var:tag.text ?><?cs
-      elif:tag.kind == "@docRoot" ?><?cs var:toroot ?><?cs
-      elif:tag.kind == "@sdkCurrent" ?><?cs var:sdk.current ?><?cs
-      elif:tag.kind == "@sdkCurrentVersion" ?><?cs var:sdk.version ?><?cs
-      elif:tag.kind == "@sdkCurrentRelId" ?><?cs var:sdk.rel.id ?><?cs
-      elif:tag.kind == "@sdkPlatformVersion" ?><?cs var:sdk.platform.version ?><?cs
-      elif:tag.kind == "@sdkPlatformApiLevel" ?><?cs var:sdk.platform.apiLevel ?><?cs
-      elif:tag.kind == "@sdkPlatformMajorMinor" ?><?cs var:sdk.platform.majorMinor ?><?cs
-      elif:tag.kind == "@sdkPlatformReleaseDate" ?><?cs var:sdk.platform.releaseDate ?><?cs
-      elif:tag.kind == "@sdkPlatformDeployableDate" ?><?cs var:sdk.platform.deployableDate ?><?cs
-      elif:tag.kind == "@adtZipVersion" ?><?cs var:adt.zip.version ?><?cs
-      elif:tag.kind == "@adtZipDownload" ?><?cs var:adt.zip.download ?><?cs
-      elif:tag.kind == "@adtZipBytes" ?><?cs var:adt.zip.bytes ?><?cs
-      elif:tag.kind == "@adtZipChecksum" ?><?cs var:adt.zip.checksum ?><?cs
-      elif:tag.kind == "@inheritDoc" ?><?cs # This is the case when @inheritDoc is in something
-                                              that doesn't inherit from anything?><?cs
-      elif:tag.kind == "@attr" ?><?cs
-      else ?>{<?cs var:tag.name?> <?cs var:tag.text ?>}<?cs
-      /if ?><?cs
-  /each ?><?cs
-/def ?>
-
-<?cs # The message about This xxx is deprecated. ?><?cs 
-def:deprecated_text(kind) ?>
-  This <?cs var:kind ?> is deprecated.<?cs 
-/def ?>
-
-<?cs # Show the short-form description of something.  These come from shortDescr and deprecated ?><?cs 
-def:short_descr(obj) ?><?cs
-  if:subcount(obj.deprecated) ?>
-      <em><?cs call:deprecated_text(obj.kind) ?>
-      <?cs call:tag_list(obj.deprecated) ?></em><?cs
-  else ?><?cs call:tag_list(obj.shortDescr) ?><?cs
-  /if ?><?cs
-/def ?>
-
-<?cs # Show the red box with the deprecated warning ?><?cs 
-def:deprecated_warning(obj) ?><?cs 
-  if:subcount(obj.deprecated) ?><p>
-  <p class="caution">
-      <strong><?cs call:deprecated_text(obj.kind) ?></strong><br/> <?cs 
-      call:tag_list(obj.deprecated) ?>
-  </p><?cs 
-  /if ?><?cs 
-/def ?>
-
-<?cs # print the See Also: section ?><?cs 
-def:see_also_tags(also) ?><?cs 
-  if:subcount(also) ?>
-  <div class="jd-tagdata">
-      <h5 class="jd-tagtitle">See Also</h5>
-      <ul class="nolist"><?cs 
-        each:tag=also ?><li><?cs
-            if:tag.kind == "@see" ?><code><a href="<?cs var:toroot ?><?cs var:tag.href ?>"><?cs
-                    var:tag.label ?></a></code><?cs
-            elif:tag.kind == "@seeHref" ?><a href="<?cs var:tag.href ?>"><?cs var:tag.label ?></a><?cs
-            elif:tag.kind == "@seeJustLabel" ?><?cs var:tag.label ?><?cs
-            else ?>[ERROR: Unknown @see kind]<?cs
-            /if ?></li><?cs 
-        /each ?>
-      </ul>
-  </div><?cs 
-  /if ?>
-<?cs /def ?>
-
-<?cs # print the API Level ?><?cs
-def:since_tags(obj) ?>
-  Since: <a href="<?cs var:toroot ?>guide/appendix/api-levels.html#level<?cs var:obj.since ?>">API Level <?cs var:obj.since ?></a>
-<?cs /def ?>
-
-<?cs # Print the long-form description for something.
-       Uses the following fields: deprecated descr seeAlso since ?><?cs
-def:description(obj) ?><?cs 
-  call:deprecated_warning(obj) ?>
-  <div class="jd-tagdata jd-tagdescr"><p><?cs call:tag_list(obj.descr) ?></p></div><?cs 
-  if:subcount(obj.attrRefs) ?>
-  <div class="jd-tagdata">
-      <h5 class="jd-tagtitle">Related XML Attributes</h5>
-      <ul class="nolist"><?cs 
-        each:attr=obj.attrRefs ?>
-            <li><a href="<?cs var:toroot ?><?cs var:attr.href ?>"><?cs var:attr.name ?></a></li><?cs 
-        /each ?>
-      </ul>
-  </div><?cs 
-  /if ?><?cs 
-  if:subcount(obj.paramTags) ?>
-  <div class="jd-tagdata">
-      <h5 class="jd-tagtitle">Parameters</h5>
-      <table class="jd-tagtable"><?cs 
-      each:tag=obj.paramTags ?>
-        <tr>
-          <th><?cs if:tag.isTypeParameter ?>&lt;<?cs /if ?><?cs var:tag.name
-                  ?><?cs if:tag.isTypeParameter ?>&gt;<?cs /if ?></td>
-          <td><?cs call:tag_list(tag.comment) ?></td>
-        </tr><?cs 
-      /each ?>
-      </table>
-  </div><?cs 
-  /if ?><?cs 
-  if:subcount(obj.returns) ?>
-  <div class="jd-tagdata">
-      <h5 class="jd-tagtitle">Returns</h5>
-      <ul class="nolist"><li><?cs call:tag_list(obj.returns) ?></li></ul>
-  </div><?cs 
-  /if ?><?cs 
-  if:subcount(obj.throws) ?>
-  <div class="jd-tagdata">
-      <h5 class="jd-tagtitle">Throws</h5>
-      <table class="jd-tagtable"><?cs 
-      each:tag=obj.throws ?>  
-        <tr>
-            <th><?cs call:type_link(tag.type) ?></td>
-            <td><?cs call:tag_list(tag.comment) ?></td>
-        </tr><?cs 
-      /each ?>
-      </table>
-  </div><?cs 
-  /if ?><?cs 
-  call:see_also_tags(obj.seeAlso) ?><?cs
-/def ?>
-
-<?cs # A table of links to classes with descriptions, as in a package file or the nested classes ?><?cs
-def:class_link_table(classes) ?><?cs 
-  set:count = #1 ?>
-  <table class="jd-sumtable-expando"><?cs
-      each:cl=classes ?>
-        <tr class="<?cs if:count % #2 ?>alt-color<?cs /if ?> api apilevel-<?cs var:cl.type.since ?>" >
-              <td class="jd-linkcol"><?cs call:type_link(cl.type) ?></td>
-              <td class="jd-descrcol" width="100%"><?cs call:short_descr(cl) ?>&nbsp;</td>
-          </tr><?cs set:count = count + #1 ?><?cs
-      /each ?>
-  </table><?cs 
-/def ?>
-
-<?cs # A list of links to classes, for use in the side navigation of classes when viewing a package (panel nav) ?><?cs 
-def:class_link_list(label, classes) ?><?cs 
-  if:subcount(classes) ?>
-    <li><h2><?cs var:label ?></h2>
-      <ul><?cs 
-      each:cl=classes ?>
-        <li class="api apilevel-<?cs var:cl.type.since ?>"><?cs call:type_link(cl.type) ?></li><?cs 
-      /each ?>
-      </ul>
-    </li><?cs 
-  /if ?><?cs 
-/def ?>
-
-<?cs # A list of links to classes, for use in the side navigation of classes when viewing a class (panel nav) ?><?cs 
-def:list(label, classes) ?><?cs 
-  if:subcount(classes) ?>
-    <li><h2><?cs var:label ?></h2>
-      <ul><?cs 
-      each:cl=classes ?>
-          <li class="<?cs if:class.name == cl.label?>selected <?cs /if ?>api apilevel-<?cs var:cl.since ?>"><?cs call:type_link(cl) ?></li><?cs 
-      /each ?>
-      </ul>
-    </li><?cs 
-  /if ?><?cs 
-/def ?>
-
-<?cs # A list of links to packages, for use in the side navigation of packages (panel nav) ?><?cs 
-def:package_link_list(packages) ?><?cs 
-  each:pkg=packages ?>
-    <li class="<?cs if:(class.package.name == pkg.name) || (package.name == pkg.name)?>selected <?cs /if ?>api apilevel-<?cs var:pkg.since ?>"><?cs call:package_link(pkg) ?></li><?cs 
-  /each ?><?cs
-/def ?>
-
-<?cs # An expando trigger ?><?cs 
-def:expando_trigger(id, default) ?>
-  <a href="#" onclick="return toggleInherited(this, null)" id="<?cs var:id ?>" class="jd-expando-trigger closed"
-          ><img id="<?cs var:id ?>-trigger"
-          src="<?cs var:toroot ?>assets/images/triangle-<?cs var:default ?>.png"
-          class="jd-expando-trigger-img" /></a><?cs 
-/def ?>
-
-<?cs # An expandable list of classes ?><?cs 
-def:expandable_class_list(id, classes, default) ?>
-  <div id="<?cs var:id ?>">
-      <div id="<?cs var:id ?>-list"
-              class="jd-inheritedlinks"
-              <?cs if:default != "list" ?>style="display: none;"<?cs /if ?>
-              ><?cs 
-          each:cl=classes ?>
-              <?cs call:type_link(cl.type) ?><?cs if:!last(cl) ?>,<?cs /if ?><?cs 
-          /each ?>
-      </div>
-      <div id="<?cs var:id ?>-summary"
-              <?cs if:default != "summary" ?>style="display: none;"<?cs /if ?>
-              ><?cs 
-          call:class_link_table(classes) ?>
-      </div>
-  </div><?cs 
-/def ?>
-
-
-<?cs include:"customization.cs" ?>
diff --git a/tools/droiddoc/templates/navtree_data.cs b/tools/droiddoc/templates/navtree_data.cs
deleted file mode 100644
index c707232..0000000
--- a/tools/droiddoc/templates/navtree_data.cs
+++ /dev/null
@@ -1,4 +0,0 @@
-var NAVTREE_DATA =
-<?cs var:reference_tree ?>
-;
-
diff --git a/tools/droiddoc/templates/nosidenavpage.cs b/tools/droiddoc/templates/nosidenavpage.cs
deleted file mode 100644
index 1dec41e..0000000
--- a/tools/droiddoc/templates/nosidenavpage.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-<?cs include:"doctype.cs" ?>
-<?cs include:"macros.cs" ?>
-<html>
-<?cs include:"head_tag.cs" ?>
-<body class="gc-documentation">
-<a name="top"></a>
-<?cs call:custom_masthead() ?>
-
-<div id="body-content">
-<div id="doc-content" style="position:relative;">
-
-<?cs call:tag_list(root.descr) ?>
-
-<?cs include:"footer.cs" ?>
-</div><!-- end doc-content -->
-
-<?cs include:"trailer.cs" ?>
-
-</body>
-</html>
-
-
-
diff --git a/tools/droiddoc/templates/package-descr.cs b/tools/droiddoc/templates/package-descr.cs
deleted file mode 100644
index 08fee18..0000000
--- a/tools/droiddoc/templates/package-descr.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-<?cs include:"doctype.cs" ?>
-<?cs include:"macros.cs" ?>
-<html>
-<?cs include:"head_tag.cs" ?>
-<body class="<?cs var:package.since ?>">
-<?cs include:"header.cs" ?>
-
-<div class="g-unit" id="doc-content">
-
-<div id="api-info-block">
-<div class="api-level">
-  <?cs call:since_tags(package) ?>
-</div>
-</div>
-
-<div id="jd-header">
-  package
-  <h1><?cs var:package.name ?></b></h1>
-  <div class="jd-nav">
-      <a class="jd-navlink" href="package-summary.html">Classes</a> | Description
-  </div>
-</div><!-- end header -->
-
-<div id="naMessage"></div>
-
-<div id="jd-content" class="api apilevel-<?cs var:package.since ?>">
-<div class="jd-descr">
-<p><?cs call:tag_list(package.descr) ?></p>
-</div>
-
-<?cs include:"footer.cs" ?>
-</div><!-- end jd-content -->
-</div> <!-- end doc-content -->
-
-<?cs include:"trailer.cs" ?>
-
-</body>
-</html>
diff --git a/tools/droiddoc/templates/package-list.cs b/tools/droiddoc/templates/package-list.cs
deleted file mode 100644
index 7f0f889..0000000
--- a/tools/droiddoc/templates/package-list.cs
+++ /dev/null
@@ -1,2 +0,0 @@
-<?cs each:pkg=docs.packages ?><?cs var: pkg.name ?>
-<?cs /each ?>
diff --git a/tools/droiddoc/templates/package.cs b/tools/droiddoc/templates/package.cs
deleted file mode 100644
index b29bc77..0000000
--- a/tools/droiddoc/templates/package.cs
+++ /dev/null
@@ -1,59 +0,0 @@
-<?cs include:"doctype.cs" ?>
-<?cs include:"macros.cs" ?>
-<html>
-<?cs include:"head_tag.cs" ?>
-<body class="<?cs var:package.since ?>">
-<?cs include:"header.cs" ?>
-
-<div class="g-unit" id="doc-content">
-
-<div id="api-info-block">
-<div class="api-level">
-  <?cs call:since_tags(package) ?>
-</div>
-</div>
-
-<div id="jd-header">
-  package
-  <h1><?cs var:package.name ?></h1>
-  <div class="jd-nav">
-      <?cs if:subcount(package.shortDescr) ?>
-        Classes | <a class="jd-navlink" href="package-descr.html">Description</a>
-      <?cs /if ?>
-  </div>
-</div><!-- end header -->
-
-<div id="naMessage"></div>
-
-<div id="jd-content" class="api apilevel-<?cs var:package.since ?>">
-
-<?cs if:subcount(package.shortDescr) ?>
-  <div class="jd-descr">
-  <p><?cs call:tag_list(package.shortDescr) ?></p>
-  <p><span class="jd-more"><a href="package-descr.html">more...</a></span></p>
-  </div>
-<?cs /if ?>
-
-<?cs def:class_table(label, classes) ?>
-  <?cs if:subcount(classes) ?>
-    <h3><?cs var:label ?></h3>
-    <div class="jd-sumtable">
-    <?cs call:class_link_table(classes) ?>
-    </div>
-  <?cs /if ?>
-<?cs /def ?>
-
-<?cs call:class_table("Interfaces", package.interfaces) ?>
-<?cs call:class_table("Classes", package.classes) ?>
-<?cs call:class_table("Enums", package.enums) ?>
-<?cs call:class_table("Exceptions", package.exceptions) ?>
-<?cs call:class_table("Errors", package.errors) ?>
-
-<?cs include:"footer.cs" ?>
-</div><!-- end jd-content -->
-</div><!-- doc-content -->
-
-<?cs include:"trailer.cs" ?>
-
-</body>
-</html>
diff --git a/tools/droiddoc/templates/packages.cs b/tools/droiddoc/templates/packages.cs
deleted file mode 100644
index 8650ad1..0000000
--- a/tools/droiddoc/templates/packages.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-<?cs include:"doctype.cs" ?>
-<?cs include:"macros.cs" ?>
-<html>
-<?cs include:"head_tag.cs" ?>
-<body class="gc-documentation">
-<?cs include:"header.cs" ?>
-
-<div class="g-unit" id="doc-content">
-
-<div id="jd-header">
-<h1><?cs var:page.title ?></h1>
-</div>
-
-<div id="jd-content">
-
-<div class="jd-descr">
-<p><?cs call:tag_list(root.descr) ?></p>
-</div>
-
-<?cs set:count = #1 ?>
-<table class="jd-sumtable">
-<?cs each:pkg = docs.packages ?>
-    <tr class="<?cs if:count % #2 ?>alt-color<?cs /if ?> api apilevel-<?cs var:pkg.since ?>" >
-        <td class="jd-linkcol"><?cs call:package_link(pkg) ?></td>
-        <td class="jd-descrcol" width="100%"><?cs call:tag_list(pkg.shortDescr) ?></td>
-    </tr>
-<?cs set:count = count + #1 ?>
-<?cs /each ?>
-</table>
-
-<?cs include:"footer.cs" ?>
-</div><!-- end jd-content -->
-</div> <!-- end doc-content -->
-
-<?cs include:"trailer.cs" ?>
-
-</body>
-</html>
diff --git a/tools/droiddoc/templates/sample.cs b/tools/droiddoc/templates/sample.cs
deleted file mode 100644
index 7979b2a..0000000
--- a/tools/droiddoc/templates/sample.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-<?cs include:"doctype.cs" ?>
-<?cs include:"macros.cs" ?>
-<?cs set:resources="true" ?>
-<html>
-<?cs include:"head_tag.cs" ?>
-<?cs include:"header.cs" ?>
-<body class="gc-documentation">
-
-
-<a name="top"></a>
-<div class="g-unit" id="doc-content">
- <div id="jd-header" class="guide-header">
-  <span class="crumb">&nbsp;</span>
-  <h1><?cs var:page.title ?></h1>
- </div>
-
-<div id="jd-content">
-
-<p>The file containing the source code shown below is located in the corresponding directory in <code>&lt;sdk&gt;/platforms/android-&lt;version&gt;/samples/...</code></p>
-
-<!-- begin file contents -->
-<pre><?cs var:fileContents ?></pre>
-<!-- end file contents -->
-
-<?cs include:"footer.cs" ?>
-</div><!-- end jd-content -->
-</div> <!-- end doc-content -->
-
-<?cs include:"trailer.cs" ?>
-
-</body>
-</html>
diff --git a/tools/droiddoc/templates/todo.cs b/tools/droiddoc/templates/todo.cs
deleted file mode 100644
index e9f7237..0000000
--- a/tools/droiddoc/templates/todo.cs
+++ /dev/null
@@ -1,99 +0,0 @@
-<html>
-<head>
-    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
-    <title><?cs var:page.title ?></title>
-    <style type="text/css">
-    table {
-        border-width: 1px 1px 1px 1px;
-        border-spacing: 0px;
-        border-style: solid solid solid solid;
-        border-color: black black black black;
-        border-collapse: collapse;
-        background-color: white;
-    }
-    table th {
-        border-width: 1px 1px 1px 1px;
-        padding: 1px 4px 1px 3px;
-        border-style: inset inset inset inset;
-        border-color: gray gray gray gray;
-        background-color: white;
-    }
-    table td {
-        border-width: 1px 1px 1px 1px;
-        padding: 1px 4px 1px 3px;
-        border-style: inset inset inset inset;
-        border-color: gray gray gray gray;
-        background-color: white;
-    }
-    </style>
-</head>
-<body>
-<h1><?cs var:page.title ?></h1>
-
-<h2>Overall</h2>
-<table>
-<tr><th>Errors</th><td><?cs var:all.errorCount ?></td></tr>
-<tr><th>Percent Good</th><td><?cs var:all.percentGood ?></td></tr>
-<tr><th>Total Comments</th><td><?cs var:all.totalCount ?></td></tr>
-</table>
-
-<h2>Package Summary</h2>
-
-<table>
-<tr>
-    <th>Package</th>
-    <th>Errors</th>
-    <th>Percent Good</th>
-    <th>Total</th>
-</tr>
-<?cs each:pkg=packages ?>
-<tr>
-    <td><?cs var:pkg.name ?></td>
-    <td><?cs var:pkg.errorCount ?></td>
-    <td><?cs var:pkg.percentGood ?></td>
-    <td><?cs var:pkg.totalCount ?></td>
-</tr>
-<?cs /each ?>
-</table>
-
-
-<h2>Class Summary</h3>
-
-<table>
-<tr>
-    <th>Class</th>
-    <th>Errors</th>
-    <th>Percent Good</th>
-    <th>Total</th>
-</tr>
-<?cs each:cl=classes ?>
-<tr>
-    <td><a href="#class_<?cs var:cl.qualified ?>"><?cs var:cl.qualified ?></a></td>
-    <td><?cs var:cl.errorCount ?></td>
-    <td><?cs var:cl.percentGood ?></td>
-    <td><?cs var:cl.totalCount ?></td>
-</tr>
-<?cs /each ?>
-</table>
-
-<h2>Detail</h2>
-
-<?cs each:cl=classes ?>
-<h3><a name="class_<?cs var:cl.qualified ?>"><?cs var:cl.qualified ?></a></h3>
-<p>Errors: <?cs var:cl.errorCount ?><br/>
-Total: <?cs var:cl.totalCount ?><br/>
-Percent Good: <?cs var:cl.percentGood ?></p>
-<table>
-<?cs each:err=cl.errors ?>
-<tr>
-    <td><?cs var:err.pos ?></td>
-    <td><?cs var:err.name ?></td>
-    <td><?cs var:err.descr ?></td>
-</tr>
-<?cs /each ?>
-</table>
-
-<?cs /each ?>
-
-</body>
-</html>
diff --git a/tools/event_log_tags.py b/tools/event_log_tags.py
index 81e8b39..645839e 100644
--- a/tools/event_log_tags.py
+++ b/tools/event_log_tags.py
@@ -90,6 +90,14 @@
         else:
           description = None
 
+        if description:
+          # EventLog.java checks that the description field is
+          # surrounded by parens, so we should too (to avoid a runtime
+          # crash from badly-formatted descriptions).
+          if not re.match(r"\(.*\)\s*$", description):
+            self.AddError("tag \"%s\" has unparseable description" % (tagname,))
+            continue
+
         self.tags.append(Tag(tag, tagname, description,
                              self.filename, self.linenum))
     except (IOError, OSError), e:
diff --git a/tools/iself/Android.mk b/tools/iself/Android.mk
deleted file mode 100755
index 49fabff..0000000
--- a/tools/iself/Android.mk
+++ /dev/null
@@ -1,23 +0,0 @@
-# Copyright 2005 The Android Open Source Project
-#
-# Android.mk for iself
-#
-
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_CFLAGS += -O2 -g
-LOCAL_CFLAGS += -fno-function-sections -fno-data-sections -fno-inline
-LOCAL_CFLAGS += -Wall -Wno-unused-function #-Werror
-LOCAL_CFLAGS += -DDEBUG
-
-LOCAL_C_INCLUDES:= \
-	$(LOCAL_PATH)/
-
-LOCAL_SRC_FILES := \
-	iself.c
-
-LOCAL_MODULE := iself
-
-include $(BUILD_HOST_EXECUTABLE)
diff --git a/tools/iself/debug.h b/tools/iself/debug.h
deleted file mode 100644
index 9bbf47f..0000000
--- a/tools/iself/debug.h
+++ /dev/null
@@ -1,90 +0,0 @@
-#ifndef DEBUG_H
-#define DEBUG_H
-
-#include <stdlib.h>
-#include <stdio.h>
-
-#define unlikely(expr) __builtin_expect (expr, 0)
-#define likely(expr)   __builtin_expect (expr, 1)
-
-#ifdef DEBUG
-
-    #define FAILIF(cond, msg...) do {                        \
-	if (unlikely(cond)) {                                \
-        fprintf(stderr, "%s(%d): ", __FILE__, __LINE__); \
-		fprintf(stderr, ##msg);                          \
-		exit(1);                                         \
-	}                                                    \
-} while(0)
-
-/* Debug enabled */
-    #define ASSERT(x) do {                                \
-	if (unlikely(!(x))) {                             \
-		fprintf(stderr,                               \
-				"ASSERTION FAILURE %s:%d: [%s]\n",    \
-				__FILE__, __LINE__, #x);              \
-		exit(1);                                      \
-	}                                                 \
-} while(0)
-
-#else
-
-    #define FAILIF(cond, msg...) do { \
-	if (unlikely(cond)) {         \
-		fprintf(stderr, ##msg);   \
-		exit(1);                  \
-	}                             \
-} while(0)
-
-/* No debug */
-    #define ASSERT(x)   do { } while(0)
-
-#endif/* DEBUG */
-
-#define FAILIF_LIBELF(cond, function) \
-    FAILIF(cond, "%s(): %s\n", #function, elf_errmsg(elf_errno()));
-
-static inline void *MALLOC(unsigned int size) {
-    void *m = malloc(size);
-    FAILIF(NULL == m, "malloc(%d) failed!\n", size);
-    return m;
-}
-
-static inline void *CALLOC(unsigned int num_entries, unsigned int entry_size) {
-    void *m = calloc(num_entries, entry_size);
-    FAILIF(NULL == m, "calloc(%d, %d) failed!\n", num_entries, entry_size);
-    return m;
-}
-
-static inline void *REALLOC(void *ptr, unsigned int size) {
-    void *m = realloc(ptr, size);
-    FAILIF(NULL == m, "realloc(%p, %d) failed!\n", ptr, size);
-    return m;
-}
-
-static inline void FREE(void *ptr) {
-    free(ptr);
-}
-
-static inline void FREEIF(void *ptr) {
-    if (ptr) FREE(ptr);
-}
-
-#define PRINT(x...)  do {                             \
-    extern int quiet_flag;                            \
-    if(likely(!quiet_flag))                           \
-        fprintf(stdout, ##x);                         \
-} while(0)
-
-#define ERROR PRINT
-
-#define INFO(x...)  do {                              \
-    extern int verbose_flag;                          \
-    if(unlikely(verbose_flag))                        \
-        fprintf(stdout, ##x);                         \
-} while(0)
-
-/* Prints a hex and ASCII dump of the selected buffer to the selected stream. */
-int dump_hex_buffer(FILE *s, void *b, size_t l, size_t elsize);
-
-#endif/*DEBUG_H*/
diff --git a/tools/iself/iself.c b/tools/iself/iself.c
deleted file mode 100644
index e634a22..0000000
--- a/tools/iself/iself.c
+++ /dev/null
@@ -1,36 +0,0 @@
-#include <debug.h>
-#include <unistd.h>
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <string.h>
-#include <errno.h>
-
-int
-main(int argc, char **argv)
-{
-	char *fname;
-	int fd;
-	char magic[4];
-
-	argc--, argv++;
-	FAILIF(argc != 1, "Expecting a file name!\n");
-	fname = *argv;
-
-	fd = open(fname, O_RDONLY);
-	FAILIF(fd < 0, "Error opening %s for reading: %s (%d)!\n",
-           fname, strerror(errno), errno);
-
-	FAILIF(4 != read(fd, magic, 4),
-           "Could not read first 4 bytes from %s: %s (%d)!\n",
-           fname, strerror(errno), errno);
-
-    if (magic[0] != 0x7f) return 1;
-    if (magic[1] != 'E')  return 1;
-    if (magic[2] != 'L')  return 1;
-    if (magic[3] != 'F')  return 1;
-
-    return 0;
-}
diff --git a/tools/isprelinked/Android.mk b/tools/isprelinked/Android.mk
deleted file mode 100755
index e085f29..0000000
--- a/tools/isprelinked/Android.mk
+++ /dev/null
@@ -1,40 +0,0 @@
-# Copyright 2005 The Android Open Source Project
-#
-# Android.mk for apriori 
-#
-
-LOCAL_PATH:= $(call my-dir)
-
-ifeq ($(TARGET_ARCH),arm)
-include $(CLEAR_VARS)
-
-LOCAL_LDLIBS += -ldl
-LOCAL_CFLAGS += -O2 -g 
-LOCAL_CFLAGS += -fno-function-sections -fno-data-sections -fno-inline 
-LOCAL_CFLAGS += -Wall -Wno-unused-function #-Werror
-LOCAL_CFLAGS += -DSUPPORT_ANDROID_PRELINK_TAGS
-LOCAL_CFLAGS += -DARM_SPECIFIC_HACKS
-LOCAL_CFLAGS += -DDEBUG
-
-ifeq ($(HOST_OS),windows)
-LOCAL_LDLIBS += -lintl
-endif
-
-LOCAL_SRC_FILES := \
-	isprelinked.c \
-	debug.c \
-	prelink_info.c
-
-LOCAL_C_INCLUDES:= \
-	$(LOCAL_PATH)/ \
-	external/elfutils/lib/ \
-	external/elfutils/libelf/ \
-	external/elfutils/libebl/ \
-	external/elfcopy/
-
-LOCAL_STATIC_LIBRARIES := libelfcopy libelf libebl libebl_arm #dl
-
-LOCAL_MODULE := isprelinked
-
-include $(BUILD_HOST_EXECUTABLE)
-endif #TARGET_ARCH==arm
diff --git a/tools/isprelinked/common.h b/tools/isprelinked/common.h
deleted file mode 100644
index f5d9d2e..0000000
--- a/tools/isprelinked/common.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef COMMON_H
-#define COMMON_H
-
-#include <libelf.h>
-#include <elf.h>
-
-#define unlikely(expr) __builtin_expect (expr, 0)
-#define likely(expr)   __builtin_expect (expr, 1)
-
-#define MIN(a,b) ((a)<(b)?(a):(b)) /* no side effects in arguments allowed! */
-
-static inline int is_host_little(void)
-{
-    short val = 0x10;
-    return ((char *)&val)[0] != 0;
-}
-
-static inline long switch_endianness(long val)
-{
-	long newval;
-	((char *)&newval)[3] = ((char *)&val)[0];
-	((char *)&newval)[2] = ((char *)&val)[1];
-	((char *)&newval)[1] = ((char *)&val)[2];
-	((char *)&newval)[0] = ((char *)&val)[3];
-	return newval;
-}
-
-#endif/*COMMON_H*/
diff --git a/tools/isprelinked/debug.c b/tools/isprelinked/debug.c
deleted file mode 100644
index 6066543..0000000
--- a/tools/isprelinked/debug.c
+++ /dev/null
@@ -1,37 +0,0 @@
-#include <debug.h>
-#include <stdio.h>
-#include <ctype.h>
-
-#define NUM_COLS  (32)
-
-int dump_hex_buffer(FILE *s, void *b, size_t len, size_t elsize) {
-    int num_nonprintable = 0;
-    int i, last;
-    char *pchr = (char *)b;
-    fputc('\n', s);
-    for (i = last = 0; i < len; i++) {
-        if (!elsize) {
-            if (i && !(i % 4)) fprintf(s, " ");
-            if (i && !(i % 8)) fprintf(s, " ");
-        } else {
-            if (i && !(i % elsize)) fprintf(s, " ");
-        }
-
-        if (i && !(i % NUM_COLS)) {
-            while (last < i) {
-                if (isprint(pchr[last]))
-                    fputc(pchr[last], s);
-                else {
-                    fputc('.', s); 
-                    num_nonprintable++;
-                }
-                last++;
-            }
-            fprintf(s, " (%d)\n", i);
-        }
-        fprintf(s, "%02x", (unsigned char)pchr[i]);
-    }
-    if (i && (i % NUM_COLS)) fputs("\n", s);
-    return num_nonprintable;
-}
-
diff --git a/tools/isprelinked/debug.h b/tools/isprelinked/debug.h
deleted file mode 100644
index 3996898..0000000
--- a/tools/isprelinked/debug.h
+++ /dev/null
@@ -1,88 +0,0 @@
-#ifndef DEBUG_H
-#define DEBUG_H
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <common.h>
-
-#ifdef DEBUG
-
-    #define FAILIF(cond, msg...) do {                        \
-	if (unlikely(cond)) {                                \
-        fprintf(stderr, "%s(%d): ", __FILE__, __LINE__); \
-		fprintf(stderr, ##msg);                          \
-		exit(1);                                         \
-	}                                                    \
-} while(0)
-
-/* Debug enabled */
-    #define ASSERT(x) do {                                \
-	if (unlikely(!(x))) {                             \
-		fprintf(stderr,                               \
-				"ASSERTION FAILURE %s:%d: [%s]\n",    \
-				__FILE__, __LINE__, #x);              \
-		exit(1);                                      \
-	}                                                 \
-} while(0)
-
-#else
-
-    #define FAILIF(cond, msg...) do { \
-	if (unlikely(cond)) {         \
-		fprintf(stderr, ##msg);   \
-		exit(1);                  \
-	}                             \
-} while(0)
-
-/* No debug */
-    #define ASSERT(x)   do { } while(0)
-
-#endif/* DEBUG */
-
-#define FAILIF_LIBELF(cond, function) \
-    FAILIF(cond, "%s(): %s\n", #function, elf_errmsg(elf_errno()));
-
-static inline void *MALLOC(unsigned int size) {
-    void *m = malloc(size);
-    FAILIF(NULL == m, "malloc(%d) failed!\n", size);
-    return m;
-}
-
-static inline void *CALLOC(unsigned int num_entries, unsigned int entry_size) {
-    void *m = calloc(num_entries, entry_size);
-    FAILIF(NULL == m, "calloc(%d, %d) failed!\n", num_entries, entry_size);
-    return m;
-}
-
-static inline void *REALLOC(void *ptr, unsigned int size) {
-    void *m = realloc(ptr, size);
-    FAILIF(NULL == m, "realloc(%p, %d) failed!\n", ptr, size);
-    return m;
-}
-
-static inline void FREE(void *ptr) {
-    free(ptr);
-}
-
-static inline void FREEIF(void *ptr) {
-    if (ptr) FREE(ptr);
-}
-
-#define PRINT(x...)  do {                             \
-    extern int quiet_flag;                            \
-    if(likely(!quiet_flag))                           \
-        fprintf(stdout, ##x);                         \
-} while(0)
-
-#define ERROR PRINT
-
-#define INFO(x...)  do {                              \
-    extern int verbose_flag;                          \
-    if(unlikely(verbose_flag))                        \
-        fprintf(stdout, ##x);                         \
-} while(0)
-
-/* Prints a hex and ASCII dump of the selected buffer to the selected stream. */
-int dump_hex_buffer(FILE *s, void *b, size_t l, size_t elsize);
-
-#endif/*DEBUG_H*/
diff --git a/tools/isprelinked/isprelinked.c b/tools/isprelinked/isprelinked.c
deleted file mode 100644
index c677e39..0000000
--- a/tools/isprelinked/isprelinked.c
+++ /dev/null
@@ -1,89 +0,0 @@
-/* TODO:
-   1. check the ARM EABI version--this works for versions 1 and 2.
-   2. use a more-intelligent approach to finding the symbol table, symbol-string
-      table, and the .dynamic section.
-   3. fix the determination of the host and ELF-file endianness
-   4. write the help screen
-*/
-
-#include <stdio.h>
-#include <common.h>
-#include <debug.h>
-#include <libelf.h>
-#include <libebl.h>
-#ifdef ARM_SPECIFIC_HACKS
-    #include <libebl_arm.h>
-#endif/*ARM_SPECIFIC_HACKS*/
-#include <elf.h>
-#include <gelf.h>
-#include <string.h>
-#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <rangesort.h>
-#include <prelink_info.h>
-#include <libgen.h>
-
-
-/* Flag set by --verbose.  This variable is global as it is accessed by the
-   macro INFO() in multiple compilation unites. */
-int verbose_flag = 0;
-/* Flag set by --quiet.  This variable is global as it is accessed by the
-   macro PRINT() in multiple compilation unites. */
-int quiet_flag = 0;
-
-int main(int argc, char **argv) {
-
-    argc--, argv++;
-    if (!argc)
-        return 0;
-
-    /* Check to see whether the ELF library is current. */
-    FAILIF (elf_version(EV_CURRENT) == EV_NONE, "libelf is out of date!\n");
-
-    const char *filename;
-    for (; argc; argc--) {
-        filename = *argv++;
-
-        Elf *elf;
-        GElf_Ehdr elf_hdr;
-        int fd; 
-        int prelinked;
-        long prelink_addr = 0;
-
-        INFO("Processing file [%s]\n", filename);
-
-        fd = open(filename, O_RDONLY);
-        FAILIF(fd < 0, "open(%d): %s (%d).\n", 
-               filename,
-               strerror(errno),
-               errno);
-
-        elf = elf_begin(fd, ELF_C_READ_MMAP_PRIVATE, NULL);
-        FAILIF_LIBELF(elf == NULL, elf_begin);
-
-        FAILIF_LIBELF(0 == gelf_getehdr(elf, &elf_hdr), 
-                      gelf_getehdr);
-
-#ifdef SUPPORT_ANDROID_PRELINK_TAGS
-        prelinked = check_prelinked(filename, elf_hdr.e_ident[EI_DATA] == ELFDATA2LSB, 
-                                    &prelink_addr);
-#else
-        #error 'SUPPORT_ANDROID_PRELINK_TAGS is not defined!'
-#endif
-
-        if (prelinked)
-            PRINT("%s: 0x%08x\n", filename, prelink_addr);
-        else
-            PRINT("%s: not prelinked\n", filename);
-
-        FAILIF_LIBELF(elf_end(elf), elf_end);
-        close(fd);
-    }
-    
-    return 0;
-} 
-
diff --git a/tools/isprelinked/prelink_info.c b/tools/isprelinked/prelink_info.c
deleted file mode 100644
index 21b1519..0000000
--- a/tools/isprelinked/prelink_info.c
+++ /dev/null
@@ -1,71 +0,0 @@
-#ifdef SUPPORT_ANDROID_PRELINK_TAGS
-
-#include <sys/types.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-
-#include <prelink_info.h>
-#include <debug.h>
-#include <common.h>
-
-typedef struct {
-	long mmap_addr;
-	char tag[4]; /* 'P', 'R', 'E', ' ' */
-} prelink_info_t __attribute__((packed));
-
-static inline void set_prelink(long *prelink_addr, 
-							   int elf_little,
-							   prelink_info_t *info)
-{
-    FAILIF(sizeof(prelink_info_t) != 8, "Unexpected sizeof(prelink_info_t) == %d!\n", sizeof(prelink_info_t));
-	if (prelink_addr) {
-		if (!(elf_little ^ is_host_little())) {
-			/* Same endianness */
-			*prelink_addr = info->mmap_addr;
-		}
-		else {
-			/* Different endianness */
-			*prelink_addr = switch_endianness(info->mmap_addr);
-		}
-	}
-}
-
-int check_prelinked(const char *fname, int elf_little, long *prelink_addr)
-{
-    FAILIF(sizeof(prelink_info_t) != 8, "Unexpected sizeof(prelink_info_t) == %d!\n", sizeof(prelink_info_t));
-	int fd = open(fname, O_RDONLY);
-	FAILIF(fd < 0, "open(%s, O_RDONLY): %s (%d)!\n",
-		   fname, strerror(errno), errno);
-	off_t end = lseek(fd, 0, SEEK_END);
-
-    int nr = sizeof(prelink_info_t);
-
-    off_t sz = lseek(fd, -nr, SEEK_CUR);
-	ASSERT((long)(end - sz) == (long)nr);
-	FAILIF(sz == (off_t)-1, 
-		   "lseek(%d, 0, SEEK_END): %s (%d)!\n", 
-		   fd, strerror(errno), errno);
-
-	prelink_info_t info;
-	int num_read = read(fd, &info, nr);
-	FAILIF(num_read < 0, 
-		   "read(%d, &info, sizeof(prelink_info_t)): %s (%d)!\n",
-		   fd, strerror(errno), errno);
-	FAILIF(num_read != sizeof(info),
-		   "read(%d, &info, sizeof(prelink_info_t)): did not read %d bytes as "
-		   "expected (read %d)!\n",
-		   fd, sizeof(info), num_read);
-
-	int prelinked = 0;
-	if (!strncmp(info.tag, "PRE ", 4)) {
-		set_prelink(prelink_addr, elf_little, &info);
-		prelinked = 1;
-	}
-	FAILIF(close(fd) < 0, "close(%d): %s (%d)!\n", fd, strerror(errno), errno);
-	return prelinked;
-}
-
-#endif /*SUPPORT_ANDROID_PRELINK_TAGS*/
diff --git a/tools/isprelinked/prelink_info.h b/tools/isprelinked/prelink_info.h
deleted file mode 100644
index afc03e9..0000000
--- a/tools/isprelinked/prelink_info.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef PRELINK_INFO_H
-#define PRELINK_INFO_H
-#ifdef SUPPORT_ANDROID_PRELINK_TAGS
-
-int check_prelinked(const char *fname, int elf_little, long *prelink_addr);
-
-#endif
-#endif/*PRELINK_INFO_H*/
diff --git a/tools/kcm/Android.mk b/tools/kcm/Android.mk
deleted file mode 100644
index 130a13a..0000000
--- a/tools/kcm/Android.mk
+++ /dev/null
@@ -1,15 +0,0 @@
-# Copyright 2007 The Android Open Source Project
-#
-# Copies files into the directory structure described by a manifest
-
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
-	kcm.cpp
-
-LOCAL_MODULE := kcm
-
-include $(BUILD_HOST_EXECUTABLE)
-
-
diff --git a/tools/kcm/kcm.cpp b/tools/kcm/kcm.cpp
deleted file mode 100644
index 23ac377..0000000
--- a/tools/kcm/kcm.cpp
+++ /dev/null
@@ -1,421 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <ui/KeycodeLabels.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <map>
-#include <string>
-#include <utils/ByteOrder.h>
-
-using namespace std;
-
-enum {
-    LENDIAN,
-    BENDIAN
-};
-
-/*
- * 1: KeyEvent name
- * 2: display_label
- * 3: number
- * 4..7: base, shift, alt, shift-alt
- */
-#define COLUMNS (3+4)
-
-struct KeyRecord
-{
-    int lineno;
-    int values[COLUMNS];
-};
-
-struct PropValue
-{
-    PropValue() { lineno = -1; }
-    PropValue(const PropValue& that) { lineno=that.lineno; value=that.value; }
-    PropValue(int l, const string& v) { lineno = l; value = v; }
-
-    int lineno;
-    string value;
-};
-
-static int usage();
-
-//  0 -- ok
-// >0 -- error
-static int parse_key_line(const char* filename, int lineno, char* line,
-        KeyRecord* out);
-static int write_kr(int fd, const KeyRecord& kr);
-
-int g_endian;
-
-int
-main(int argc, char** argv)
-{
-    int err;
-    if (argc != 3) {
-        return usage();
-    }
-
-    const char* filename = argv[1];
-    const char* outfilename = argv[2];
-
-    int in = open(filename, O_RDONLY);
-    if (in == -1) {
-        fprintf(stderr, "kcm: error opening file for read: %s\n", filename);
-        return 1;
-    }
-
-    off_t size = lseek(in, 0, SEEK_END);
-    lseek(in, 0, SEEK_SET);
-
-    char* input = (char*)malloc(size+1);
-    read(in, input, size);
-    input[size] = '\0';
-
-    close(in);
-    in = -1;
-
-    map<string,PropValue> properties;
-    map<int,KeyRecord> keys;
-    int errorcount = 0;
-    int lineno = 1;
-    char *thisline = input;
-    while (*thisline) {
-        KeyRecord kr;
-        char *nextline = thisline;
-        
-        while (*nextline != '\0' && *nextline != '\n' && *nextline != '\r') {
-            nextline++;
-        }
-
-        // eat whitespace, but not newlines
-        while (*thisline != '\0' && (*thisline == ' ' || *thisline == '\t')) {
-            thisline++;
-        }
-
-        // find the end of the line
-        char lineend = *nextline;
-        *nextline = '\0';
-        if (lineend == '\r' && nextline[1] == '\n') {
-            nextline++;
-        }
-
-        if (*thisline == '\0' || *thisline == '\r' || *thisline == '\n'
-                 || *thisline == '#') {
-            // comment or blank line
-        }
-        else if (*thisline == '[') {
-            // property - syntax [name=value]
-            // look for =
-            char* prop = thisline+1;
-            char* end = prop;
-            while (*end != '\0' && *end != '=') {
-                end++;
-            }
-            if (*end != '=') {
-                fprintf(stderr, "%s:%d: invalid property line: %s\n",
-                        filename, lineno, thisline);
-                errorcount++;
-            } else {
-                *end = '\0';
-                char* value = end+1;
-                end = nextline;
-                while (end > prop && *end != ']') {
-                    end--;
-                }
-                if (*end != ']') {
-                    fprintf(stderr, "%s:%d: property missing closing ]: %s\n",
-                            filename, lineno, thisline);
-                    errorcount++;
-                } else {
-                    *end = '\0';
-                    properties[prop] = PropValue(lineno, value);
-                }
-            }
-        }
-        else {
-            // key
-            err = parse_key_line(filename, lineno, thisline, &kr);
-            if (err == 0) {
-                kr.lineno = lineno;
-
-                map<int,KeyRecord>::iterator old = keys.find(kr.values[0]);
-                if (old != keys.end()) {
-                    fprintf(stderr, "%s:%d: keycode %d already defined\n",
-                            filename, lineno, kr.values[0]);
-                    fprintf(stderr, "%s:%d: previously defined here\n",
-                            filename, old->second.lineno);
-                    errorcount++;
-                }
-
-                keys[kr.values[0]] = kr;
-            }
-            else if (err > 0) {
-                errorcount += err;
-            }
-        }
-        lineno++;
-
-        nextline++;
-        thisline = nextline;
-
-        if (errorcount > 20) {
-            fprintf(stderr, "%s:%d: too many errors.  stopping.\n", filename,
-                    lineno);
-            return 1;
-        }
-    }
-
-    free(input);
-
-    map<string,PropValue>::iterator sit = properties.find("type");
-    if (sit == properties.end()) {
-        fprintf(stderr, "%s: key character map must contain type property.\n",
-		argv[0]);
-        errorcount++;
-    }
-    PropValue pv = sit->second;
-    unsigned char kbdtype = 0;
-    if (pv.value == "NUMERIC") {
-        kbdtype = 1;
-    }
-    else if (pv.value == "Q14") {
-        kbdtype = 2;
-    }
-    else if (pv.value == "QWERTY") {
-        kbdtype = 3;
-    }
-    else {
-        fprintf(stderr, "%s:%d: keyboard type must be one of NUMERIC, Q14 "
-                " or QWERTY, not %s\n", filename, pv.lineno, pv.value.c_str());
-    }
-
-    if (errorcount != 0) {
-        return 1;
-    }
-
-    int out = open(outfilename, O_RDWR|O_CREAT|O_TRUNC, 0664);
-    if (out == -1) {
-        fprintf(stderr, "kcm: error opening file for write: %s\n", outfilename);
-        return 1;
-    }
-
-    int count = keys.size();
-    
-    map<int,KeyRecord>::iterator it;
-    int n;
-
-    /**
-     * File Format:
-     *    Offset    Description     Value
-     *    0         magic string    "keychar"
-     *    8         endian marker   0x12345678
-     *    12        version         0x00000002
-     *    16        key count       number of key entries
-     *    20        keyboard type   NUMERIC, Q14, QWERTY, etc.
-     *    21        padding         0
-     *    32        the keys
-     */
-    err = write(out, "keychar", 8);
-    if (err == -1) goto bad_write;
-
-    n = htodl(0x12345678);
-    err = write(out, &n, 4);
-    if (err == -1) goto bad_write;
-
-    n = htodl(0x00000002);
-    err = write(out, &n, 4);
-    if (err == -1) goto bad_write;
-
-    n = htodl(count);
-    err = write(out, &n, 4);
-    if (err == -1) goto bad_write;
-
-    err = write(out, &kbdtype, 1);
-    if (err == -1) goto bad_write;
-
-    char zero[11];
-    memset(zero, 0, 11);
-    err = write(out, zero, 11);
-    if (err == -1) goto bad_write;
-
-    for (it = keys.begin(); it != keys.end(); it++) {
-        const KeyRecord& kr = it->second;
-        /*
-        printf("%2d/ [%d] [%d] [%d] [%d] [%d] [%d] [%d]\n", kr.lineno,
-                kr.values[0], kr.values[1], kr.values[2], kr.values[3],
-                kr.values[4], kr.values[5], kr.values[6]);
-        */
-        err = write_kr(out, kr);
-        if (err == -1) goto bad_write;
-    }
-
-    close(out);
-    return 0;
-
-bad_write:
-    fprintf(stderr, "kcm: fatal error writing to file: %s\n", outfilename);
-    close(out);
-    unlink(outfilename);
-    return 1;
-}
-
-static int usage()
-{
-    fprintf(stderr,
-            "usage: kcm INPUT OUTPUT\n"
-            "\n"
-            "INPUT   keycharmap file\n"
-            "OUTPUT  compiled keycharmap file\n"
-        );
-    return 1;
-}
-
-static int
-is_whitespace(const char* p)
-{
-    while (*p) {
-        if (!isspace(*p)) {
-            return 0;
-        }
-        p++;
-    }
-    return 1;
-}
-
-
-static int
-parse_keycode(const char* filename, int lineno, char* str, int* value)
-{
-    const KeycodeLabel *list = KEYCODES;
-    while (list->literal) {
-        if (0 == strcmp(str, list->literal)) {
-            *value = list->value;
-            return 0;
-        }
-        list++;
-    }
-
-    char* endptr;
-    *value = strtol(str, &endptr, 0);
-    if (*endptr != '\0') {
-        fprintf(stderr, "%s:%d: expected keycode label or number near: "
-                "%s\n", filename, lineno, str);
-        return 1;
-    }
-
-    if (*value == 0) {
-        fprintf(stderr, "%s:%d: 0 is not a valid keycode.\n",
-                filename, lineno);
-        return 1;
-    }
-
-    return 0;
-}
-
-static int
-parse_number(const char* filename, int lineno, char* str, int* value)
-{
-    int len = strlen(str);
-
-    if (len == 3 && str[0] == '\'' && str[2] == '\'') {
-        if (str[1] > 0 && str[1] < 127) {
-            *value = (int)str[1];
-            return 0;
-        } else {
-            fprintf(stderr, "%s:%d: only low ascii characters are allowed in"
-                    " quotes near: %s\n", filename, lineno, str);
-            return 1;
-        }
-    }
-
-    char* endptr;
-    *value = strtol(str, &endptr, 0);
-    if (*endptr != '\0') {
-        fprintf(stderr, "%s:%d: expected number or quoted ascii but got: %s\n",
-                filename, lineno, str);
-        return 1;
-    }
-
-    if (*value >= 0xfffe || *value < 0) {
-        fprintf(stderr, "%s:%d: unicode char out of range (no negatives, "
-                "nothing larger than 0xfffe): %s\n", filename, lineno, str);
-        return 1;
-    }
-
-    return 0;
-}
-
-static int
-parse_key_line(const char* filename, int lineno, char* line, KeyRecord* out)
-{
-    char* p = line;
-
-    int len = strlen(line);
-    char* s[COLUMNS];
-    for (int i=0; i<COLUMNS; i++) {
-        s[i] = (char*)malloc(len+1);
-    }
-
-    for (int i = 0; i < COLUMNS; i++) {
-        while (*p != '\0' && isspace(*p)) {
-            p++;
-        }
-
-        if (*p == '\0') {
-            fprintf(stderr, "%s:%d: not enough on this line: %s\n", filename,
-                    lineno, line);
-            return 1;
-        }
-
-        char *p1 = p;
-        while (*p != '\0' && !isspace(*p)) {
-            p++;
-        }
-
-        memcpy(s[i], p1, p - p1);
-        s[i][p - p1] = '\0';
-    }
-
-    while (*p != '\0' && isspace(*p)) {
-        *p++;
-    }
-    if (*p != '\0') {
-        fprintf(stderr, "%s:%d: too much on one line near: %s\n", filename,
-                lineno, p);
-        fprintf(stderr, "%s:%d: -->%s<--\n", filename, lineno, line);
-        return 1;
-    }
-
-    int errorcount = parse_keycode(filename, lineno, s[0], &out->values[0]);
-    for (int i=1; i<COLUMNS && errorcount == 0; i++) {
-        errorcount += parse_number(filename, lineno, s[i], &out->values[i]);
-    }
-
-    return errorcount;
-}
-
-struct WrittenRecord
-{
-    unsigned int keycode;       // 4 bytes
-    unsigned short values[COLUMNS - 1];   // 6*2 bytes = 12
-                                // 16 bytes total 
-};
-
-static int
-write_kr(int fd, const KeyRecord& kr)
-{
-    WrittenRecord wr;
-
-    wr.keycode = htodl(kr.values[0]);
-    for (int i=0; i<COLUMNS - 1; i++) {
-        wr.values[i] = htods(kr.values[i+1]);
-    }
-
-    return write(fd, &wr, sizeof(WrittenRecord));
-}
-
diff --git a/tools/lsd/Android.mk b/tools/lsd/Android.mk
deleted file mode 100644
index a224741..0000000
--- a/tools/lsd/Android.mk
+++ /dev/null
@@ -1,43 +0,0 @@
-# Copyright 2005 The Android Open Source Project
-#
-# Android.mk for lsd 
-#
-
-LOCAL_PATH:= $(call my-dir)
-
-ifeq ($(TARGET_ARCH),arm)
-include $(CLEAR_VARS)
-
-LOCAL_LDLIBS += -ldl
-LOCAL_CFLAGS += -O2 -g 
-LOCAL_CFLAGS += -fno-function-sections -fno-data-sections -fno-inline 
-LOCAL_CFLAGS += -Wall -Wno-unused-function #-Werror
-LOCAL_CFLAGS += -DBIG_ENDIAN=1
-LOCAL_CFLAGS += -DARM_SPECIFIC_HACKS
-LOCAL_CFLAGS += -DSUPPORT_ANDROID_PRELINK_TAGS
-LOCAL_CFLAGS += -DDEBUG
-
-ifeq ($(HOST_OS),windows)
-LOCAL_LDLIBS += -lintl
-endif
-
-LOCAL_SRC_FILES := \
-        cmdline.c \
-        debug.c \
-        hash.c \
-        lsd.c \
-        main.c
-
-LOCAL_C_INCLUDES:= \
-	$(LOCAL_PATH)/ \
-	external/elfutils/lib/ \
-	external/elfutils/libelf/ \
-	external/elfutils/libebl/
-
-LOCAL_STATIC_LIBRARIES := libelf libebl libebl_arm #dl
-
-LOCAL_MODULE := lsd
-
-include $(BUILD_HOST_EXECUTABLE)
-endif #TARGET_ARCH==arm
-
diff --git a/tools/lsd/cmdline.c b/tools/lsd/cmdline.c
deleted file mode 100644
index a3445cd..0000000
--- a/tools/lsd/cmdline.c
+++ /dev/null
@@ -1,130 +0,0 @@
-#include <debug.h>
-#include <cmdline.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <getopt.h>
-#include <string.h>
-#include <ctype.h>
-
-extern char *optarg;
-extern int optind, opterr, optopt;
-
-static struct option long_options[] = {
-	{"verbose", no_argument, 0, 'V'},
-	{"help", no_argument, 0, 'h'},
-	{"print-info", no_argument, 0, 'p'},
-	{"list-needed-libs", no_argument, 0, 'n'},
-	{"lookup",     required_argument, 0, 'L'},
-	{0, 0, 0, 0},
-};
-
-/* This array must parallel long_options[] */
-static const char *descriptions[] = {
-	"print verbose output",
-	"print help screen",
-	"for each file, generate a listing of all dependencies that each symbol "
-	     "satisfies",
-	"print out a list of needed libraries",
-	"provide a directory for library lookup"
-};
-
-void print_help(void)
-{
-    fprintf(stdout, 
-			"invokation:\n"
-			"\tlsd file1 [file2 file3 ... fileN] [-Ldir1 -Ldir2 ... -LdirN] "
-			"[-Vpn]\n"
-			"or\n"
-			"\tlsd -h\n\n");
-	fprintf(stdout, "options:\n");
-	struct option *opt = long_options;
-	const char **desc = descriptions;
-	while (opt->name) {
-		fprintf(stdout, "\t-%c\n"
-						"\t--%-15s: %s\n",
-				opt->val,
-				opt->name,
-				*desc);
-		opt++;
-		desc++;
-	}
-}
-
-int get_options(int argc, char **argv,
-				int *list_needed_libs,
-				int *info,
-                char ***dirs,
-                int *num_dirs,
-                int *verbose)
-{
-    int c;
-
-	ASSERT(list_needed_libs);
-	*list_needed_libs = 0;
-	ASSERT(info);
-	*info = 0;
-    ASSERT(verbose);
-    *verbose = 0;
-    ASSERT(dirs);
-	*dirs = NULL;
-    ASSERT(num_dirs);
-    int size = 0;
-    *num_dirs = 0;
-
-    while (1) {
-        /* getopt_long stores the option index here. */
-        int option_index = 0;
-
-        c = getopt_long (argc, argv, 
-                         "VhpnL:",
-                         long_options, 
-                         &option_index);
-        /* Detect the end of the options. */
-        if (c == -1) break;
-
-        if (isgraph(c)) {
-            INFO ("option -%c with value `%s'\n", c, (optarg ?: "(null)"));
-        }
-
-#define SET_STRING_OPTION(name) do { \
-    ASSERT(optarg);                  \
-    (*name) = strdup(optarg);        \
-} while(0)
-
-        switch (c) {
-        case 0:
-            /* If this option set a flag, do nothing else now. */
-            if (long_options[option_index].flag != 0)
-                break;
-            INFO ("option %s", long_options[option_index].name);
-            if (optarg)
-                INFO (" with arg %s", optarg);
-            INFO ("\n");
-            break;
-        case 'h': print_help(); exit(1); break;
-		case 'V': *verbose = 1; break;
-		case 'p': *info = 1; break;
-		case 'n': *list_needed_libs = 1; break;
-        case 'L': 
-            {
-                if (*num_dirs == size) {
-                    size += 10;
-                    *dirs = (char **)REALLOC(*dirs, size * sizeof(char *));
-                }
-                SET_STRING_OPTION(((*dirs) + *num_dirs));
-                (*num_dirs)++;
-            }
-			break;
-        case '?':
-            /* getopt_long already printed an error message. */
-            break;
-
-#undef SET_STRING_OPTION
-
-        default:
-            FAILIF(1, "Unknown option");
-        }
-    }
-
-    return optind;
-}
diff --git a/tools/lsd/cmdline.h b/tools/lsd/cmdline.h
deleted file mode 100644
index fc3be3e..0000000
--- a/tools/lsd/cmdline.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef CMDLINE_H
-#define CMDLINE_H
-
-void print_help(void);
-
-int get_options(int argc, char **argv,
-				int *list_needed_libs,
-				int *info,
-                char ***dirs,
-                int *num_dirs,
-                int *verbose);
-
-#endif/*CMDLINE_H*/
diff --git a/tools/lsd/common.h b/tools/lsd/common.h
deleted file mode 100644
index 6447b10..0000000
--- a/tools/lsd/common.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef COMMON_H
-#define COMMON_H
-
-#include <libelf.h>
-#include <elf.h>
-
-#define unlikely(expr) __builtin_expect (expr, 0)
-#define likely(expr)   __builtin_expect (expr, 1)
-
-#define MIN(a,b) ((a)<(b)?(a):(b)) /* no side effects in arguments allowed! */
-
-#endif/*COMMON_H*/
diff --git a/tools/lsd/debug.c b/tools/lsd/debug.c
deleted file mode 100644
index 54b18df..0000000
--- a/tools/lsd/debug.c
+++ /dev/null
@@ -1,39 +0,0 @@
-#include <debug.h>
-#include <stdio.h>
-#include <ctype.h>
-
-#define NUM_COLS  (32)
-
-int dump_hex_buffer(FILE *s, void *b, size_t len, size_t elsize)
-{
-    int num_nonprintable = 0;
-    int i, last;
-    char *pchr = (char *)b;
-    fputc('\n', s);
-    for (i = last = 0; i < len; i++) {
-        if (!elsize) {
-            if (i && !(i % 4)) fprintf(s, " ");
-            if (i && !(i % 8)) fprintf(s, " ");
-        }
-        else {
-            if (i && !(i % elsize)) fprintf(s, " ");
-        }
-
-        if (i && !(i % NUM_COLS)) {
-            while (last < i) {
-                if (isprint(pchr[last]))
-                    fputc(pchr[last], s); 
-                else {
-                    fputc('.', s); 
-                    num_nonprintable++;
-                }
-                last++;
-            }
-            fprintf(s, " (%d)\n", i);
-        }
-        fprintf(s, "%02x", (unsigned char)pchr[i]);
-    }
-    if (i && (i % NUM_COLS)) fputs("\n", s);
-    return num_nonprintable;
-}
-
diff --git a/tools/lsd/debug.h b/tools/lsd/debug.h
deleted file mode 100644
index f7842f8..0000000
--- a/tools/lsd/debug.h
+++ /dev/null
@@ -1,93 +0,0 @@
-#ifndef DEBUG_H
-#define DEBUG_H
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <common.h>
-
-#ifdef DEBUG
-
-#define FAILIF(cond, msg...) do {                        \
-	if (unlikely(cond)) {                                \
-        fprintf(stderr, "%s(%d): ", __FILE__, __LINE__); \
-		fprintf(stderr, ##msg);                          \
-		exit(1);                                         \
-	}                                                    \
-} while(0)
-
-/* Debug enabled */
-#define ASSERT(x) do {                                \
-	if (unlikely(!(x))) {                             \
-		fprintf(stderr,                               \
-				"ASSERTION FAILURE %s:%d: [%s]\n",    \
-				__FILE__, __LINE__, #x);              \
-		exit(1);                                      \
-	}                                                 \
-} while(0)
-
-#else
-
-#define FAILIF(cond, msg...) do { \
-	if (unlikely(cond)) {         \
-		fprintf(stderr, ##msg);   \
-		exit(1);                  \
-	}                             \
-} while(0)
-
-/* No debug */
-#define ASSERT(x)   do { } while(0)
-
-#endif/* DEBUG */
-
-#define FAILIF_LIBELF(cond, function) \
-    FAILIF(cond, "%s(): %s\n", #function, elf_errmsg(elf_errno()));
-
-static inline void *MALLOC(unsigned int size) 
-{
-    void *m = malloc(size);
-    FAILIF(NULL == m, "malloc(%d) failed!\n", size);
-    return m;
-}
-
-static inline void *CALLOC(unsigned int num_entries, unsigned int entry_size) 
-{
-    void *m = calloc(num_entries, entry_size);
-    FAILIF(NULL == m, "calloc(%d, %d) failed!\n", num_entries, entry_size);
-    return m;
-}
-
-static inline void *REALLOC(void *ptr, unsigned int size) 
-{
-    void *m = realloc(ptr, size);
-    FAILIF(NULL == m, "realloc(%p, %d) failed!\n", ptr, size);
-    return m;
-}
-
-static inline void FREE(void *ptr)
-{
-    free(ptr);
-}
-
-static inline void FREEIF(void *ptr)
-{
-    if (ptr) FREE(ptr);
-}
-
-#define PRINT(x...)  do {                             \
-    extern int quiet_flag;                            \
-    if(likely(!quiet_flag))                           \
-        fprintf(stdout, ##x);                         \
-} while(0)
-
-#define ERROR(x...) fprintf(stderr, ##x)
-
-#define INFO(x...)  do {                              \
-    extern int verbose_flag;                          \
-    if(unlikely(verbose_flag))                        \
-        fprintf(stdout, ##x);                         \
-} while(0)
-
-/* Prints a hex and ASCII dump of the selected buffer to the selected stream. */
-int dump_hex_buffer(FILE *s, void *b, size_t l, size_t elsize);
-
-#endif/*DEBUG_H*/
diff --git a/tools/lsd/hash.c b/tools/lsd/hash.c
deleted file mode 100644
index bbac675..0000000
--- a/tools/lsd/hash.c
+++ /dev/null
@@ -1,29 +0,0 @@
-#include <common.h>
-#include <debug.h>
-#include <libelf.h>
-#include <hash.h>
-#include <string.h>
-
-int hash_lookup(Elf *elf, 
-                Elf_Data *hash,
-                Elf_Data *symtab,
-                Elf_Data *symstr,
-                const char *symname)
-{
-    Elf32_Word *hash_data = (Elf32_Word *)hash->d_buf;
-    Elf32_Word index;
-    Elf32_Word nbuckets = *hash_data++;
-    Elf32_Word *buckets = ++hash_data;
-    Elf32_Word *chains  = hash_data + nbuckets;
-
-    index = buckets[elf_hash(symname) % nbuckets];
-    while(index != STN_UNDEF &&
-          strcmp((char *)symstr->d_buf + 
-                 ((Elf32_Sym *)symtab->d_buf)[index].st_name,
-                 symname))
-    {
-        index = chains[index];
-    }
-
-    return index;
-}
diff --git a/tools/lsd/hash.h b/tools/lsd/hash.h
deleted file mode 100644
index af29b9e..0000000
--- a/tools/lsd/hash.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef HASH_H
-#define HASH_H
-
-#include <common.h>
-#include <libelf.h>
-#include <gelf.h>
-
-int hash_lookup(Elf *elf, 
-                Elf_Data *hash,
-                Elf_Data *symtab,
-                Elf_Data *symstr,
-                const char *symname);
-
-#endif/*HASH_H*/
diff --git a/tools/lsd/lsd.c b/tools/lsd/lsd.c
deleted file mode 100644
index 03c235b..0000000
--- a/tools/lsd/lsd.c
+++ /dev/null
@@ -1,777 +0,0 @@
-#include <stdio.h>
-#include <common.h>
-#include <debug.h>
-#include <libelf.h>
-#include <libebl.h>
-#include <elf.h>
-#include <gelf.h>
-#include <string.h>
-#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <hash.h>
-#include <lsd.h>
-
-extern int verbose_flag;
-
-typedef struct source_t source_t;
-
-typedef struct {
-    Elf_Scn *scn;
-    GElf_Shdr shdr;
-    Elf_Data *data;
-} section_info_t;
-
-typedef struct next_export_t { 
-    source_t *source;
-    int next_idx;
-} next_export_t;
-
-struct source_t {
-    source_t *next;
-    int visited;
-
-    char *name;  /* full path name of this executable file */
-    /* ELF-related information: */
-    Elf *elf;
-    int elf_fd;
-    GElf_Ehdr elf_hdr;
-    size_t shstrndx;
-    int shnum; /* number of sections */
-
-    section_info_t symtab;
-    section_info_t strtab;
-    section_info_t dynamic;
-    section_info_t hash;
-
-    section_info_t *relocations;
-    int num_relocations; /* number of relocs (<= relocations_size) */
-    int relocations_size; /* sice of array -- NOT number of relocs! */
-
-	/* satisfied_execs: array containing pointers to the libraries or 
-	   executables that this executable satisfies symbol references for. */
-	source_t **satisfied_execs;
-    int num_satisfied_execs;
-    int satisfied_execs_size;
-
-    /* satisfied: array is parallel to symbol table; for each undefined symbol 
-       in that array, we maintain a flag stating whether that symbol has been 
-       satisfied, and if so, by which library.  This applies both to executable
-       files and libraries.
-    */
-    source_t **satisfied;
-
-    /* exports: array is parallel to symbol table; for each global symbol 
-       in that array, we maintain a flag stating whether that symbol satisfies 
-       a dependency in some other file.  num_syms is the length of the exports
-       array, as well as the satisfied array. This applied to libraries only.
-
-       next_exports:  this is a bit tricky.  We use this field to maintain a 
-       linked list of source_t for each global symbol of a shared library. 
-       For a shared library's global symbol at index N has the property that
-       exports[N] is the head of a linked list (threaded through next_export)
-       of all source_t that this symbol resolves a reference to.  For example, 
-       if symbol printf has index 1000 in libc.so, and an executable A and 
-       library L use printf, then the source_t entry corresponding to libc.so
-       will have exports[1000] be a linked list that contains the nodes for 
-       application A and library L.
-    */
-
-    next_export_t *exports;
-    /* num_exported is the number of symbols in this file actually used by
-       somebody else;  it's not the size of the exports array. */
-    int num_exported;
-    next_export_t *next_export;
-    int num_next_export;
-    int next_export_size;
-
-    int num_syms; /* number of symbols in symbol table.  This is the length of
-                     both exports[] and satisfied[] arrays. */
-
-    /* This is an array that contains one element for each library dependency
-       listed in the executable or shared library. */
-    source_t **lib_deps; /* list of library dependencies */
-    int num_lib_deps; /* actual number of library dependencies */
-    int lib_deps_size; /* size of lib_deps array--NOT actual number of deps! */
-
-};
-
-static source_t *sources = NULL;
-
-static char * find_file(const char *libname, 
-                        char **lib_lookup_dirs, 
-                        int num_lib_lookup_dirs);
-
-static inline source_t* find_source(const char *name,
-                                    char **lib_lookup_dirs, 
-                                    int num_lib_lookup_dirs) {
-    source_t *trav = sources;
-	char *full = find_file(name, lib_lookup_dirs, num_lib_lookup_dirs);
-    FAILIF(full == NULL, "Cannot construct full path for file [%s]!\n", name);
-    while (trav) {
-        if (!strcmp(trav->name, full))
-            break;
-        trav = trav->next;
-    }
-	free(full);
-    return trav;
-}
-
-static inline void add_to_sources(source_t *src) {
-    src->next = sources;
-    sources = src;
-}
-
-static source_t* init_source(char *full_path) {
-    source_t *source = (source_t *)CALLOC(1, sizeof(source_t));
-
-    ASSERT(full_path);
-    source->name = full_path;
-    source->elf_fd = -1;
-
-    INFO("Opening %s...\n", full_path);
-    source->elf_fd = open(full_path, O_RDONLY);
-    FAILIF(source->elf_fd < 0, "open(%s): %s (%d)\n", 
-           full_path, 
-           strerror(errno), 
-           errno);
-    INFO("Calling elf_begin(%s)...\n", full_path);
-    source->elf = elf_begin(source->elf_fd, ELF_C_READ, NULL);
-    FAILIF_LIBELF(source->elf == NULL, elf_begin);
-
-    /* libelf can recognize COFF and A.OUT formats, but we handle only ELF. */
-    if (elf_kind(source->elf) != ELF_K_ELF) {
-        ERROR("Input file %s is not in ELF format!\n", full_path);
-        return NULL;
-    }
-
-    /* Make sure this is a shared library or an executable. */
-    {
-        INFO("Making sure %s is a shared library or an executable...\n", 
-             full_path);
-        FAILIF_LIBELF(0 == gelf_getehdr(source->elf, &source->elf_hdr), gelf_getehdr);
-        FAILIF(source->elf_hdr.e_type != ET_DYN && 
-               source->elf_hdr.e_type != ET_EXEC,
-               "%s must be a shared library (elf type is %d, expecting %d).\n", 
-               full_path,
-               source->elf_hdr.e_type, 
-               ET_DYN);
-    }
-
-    /* Get the index of the section-header-strings-table section. */
-    FAILIF_LIBELF(elf_getshstrndx (source->elf, &source->shstrndx) < 0, 
-                  elf_getshstrndx);
-
-    FAILIF_LIBELF(elf_getshnum (source->elf, &source->shnum) < 0, elf_getshnum);
-
-    /* Find various sections. */
-    size_t scnidx;
-    Elf_Scn *scn;
-    GElf_Shdr *shdr, shdr_mem;
-    INFO("Locating %d sections in %s...\n", source->shnum, full_path);
-    for (scnidx = 1; scnidx < source->shnum; scnidx++) {
-        scn = elf_getscn(source->elf, scnidx);
-        FAILIF_LIBELF(NULL == scn, elf_getscn);
-        shdr = gelf_getshdr(scn, &shdr_mem);
-        FAILIF_LIBELF(NULL == shdr, gelf_getshdr);
-        INFO("\tfound section [%s]...\n", elf_strptr(source->elf, source->shstrndx, shdr->sh_name));
-        if (shdr->sh_type == SHT_DYNSYM) {
-            source->symtab.scn = scn;
-            source->symtab.data = elf_getdata(scn, NULL);
-            FAILIF_LIBELF(NULL == source->symtab.data, elf_getdata);
-            memcpy(&source->symtab.shdr, shdr, sizeof(GElf_Shdr));
-
-            /* The sh_link field of the section header of the symbol table
-               contains the index of the associated strings table. */
-            source->strtab.scn = elf_getscn(source->elf, 
-                                            source->symtab.shdr.sh_link);
-            FAILIF_LIBELF(NULL == source->strtab.scn, elf_getscn);
-            FAILIF_LIBELF(NULL == gelf_getshdr(scn, &source->strtab.shdr),
-                          gelf_getshdr);
-            source->strtab.data = elf_getdata(source->strtab.scn, NULL);
-            FAILIF_LIBELF(NULL == source->strtab.data, elf_getdata);
-        }
-        else if (shdr->sh_type == SHT_DYNAMIC) {
-            source->dynamic.scn = scn;
-            source->dynamic.data = elf_getdata(scn, NULL);
-            FAILIF_LIBELF(NULL == source->symtab.data, elf_getdata);
-            memcpy(&source->dynamic.shdr, shdr, sizeof(GElf_Shdr));
-        }
-        else if (shdr->sh_type == SHT_HASH) {
-            source->hash.scn = scn;
-            source->hash.data = elf_getdata(scn, NULL);
-            FAILIF_LIBELF(NULL == source->hash.data, elf_getdata);
-            memcpy(&source->hash.shdr, shdr, sizeof(GElf_Shdr));
-        }
-        else if (shdr->sh_type == SHT_REL || shdr->sh_type == SHT_RELA) {
-            if (source->num_relocations == source->relocations_size) {
-                source->relocations_size += 5;
-                source->relocations = 
-                    (section_info_t *)REALLOC(source->relocations,
-                                              source->relocations_size *
-                                              sizeof(section_info_t));
-            }
-            section_info_t *reloc = 
-                source->relocations + source->num_relocations;
-            reloc->scn = scn;
-            reloc->data = elf_getdata(scn, NULL);
-            FAILIF_LIBELF(NULL == reloc->data, elf_getdata);
-            memcpy(&reloc->shdr, shdr, sizeof(GElf_Shdr));
-            source->num_relocations++;
-        }
-    }
-
-    if (source->dynamic.scn == NULL) {
-        INFO("File [%s] does not have a dynamic section!\n", full_path);
-        return 0;
-    }
-
-    FAILIF(source->symtab.scn == NULL, 
-           "File [%s] does not have a dynamic symbol table!\n",
-           full_path);
-
-    FAILIF(source->hash.scn == NULL, 
-           "File [%s] does not have a hash table!\n",
-           full_path);
-    FAILIF(source->hash.shdr.sh_link != elf_ndxscn(source->symtab.scn),
-           "Hash points to section %d, not to %d as expected!\n",
-           source->hash.shdr.sh_link,
-           elf_ndxscn(scn));
-
-    /* Now, find out how many symbols we have and allocate the array of 
-       satisfied symbols.
-
-       NOTE: We don't count the number of undefined symbols here; we will 
-       iterate over the symbol table later, and count them then, when it is 
-       more convenient. 
-    */
-    size_t symsize = gelf_fsize (source->elf, 
-                                 ELF_T_SYM, 
-                                 1, source->elf_hdr.e_version);
-    ASSERT(symsize);
-
-    source->num_syms = source->symtab.data->d_size / symsize;
-    source->satisfied = (source_t **)CALLOC(source->num_syms, 
-                                            sizeof(source_t *));
-    source->exports = (source_t **)CALLOC(source->num_syms, 
-                                          sizeof(next_export_t));
-
-    source->num_exported = 0;
-    source->satisfied_execs = NULL;
-    source->num_satisfied_execs = 0;
-    source->satisfied_execs_size = 0;
-
-    add_to_sources(source);
-    return source;
-}
-
-static void destroy_source(source_t *source) {
-    FREE(source->satisfied_execs);
-    FREE(source->satisfied);
-    FREE(source->exports);
-    FREE(source->next_export);    
-    FREE(source->lib_deps); /* list of library dependencies */
-    FAILIF_LIBELF(elf_end(source->elf), elf_end);
-    FAILIF(close(source->elf_fd) < 0, "Could not close file %s: %s (%d)!\n", 
-           source->name, strerror(errno), errno);
-    FREE(source->name);
-    FREE(source);
-}
-
-static void print_needed_libs(source_t *source)
-{
-	size_t idx;
-	for (idx = 0; idx < source->num_lib_deps; idx++) {
-		PRINT("%s:%s\n", 
-			  source->name, 
-			  source->lib_deps[idx]->name);
-	}
-}
-
-static int is_symbol_imported(source_t *source,
-                              GElf_Sym *sym, 
-                              size_t symidx)
-{
-    const char *symname = elf_strptr(source->elf,
-                                     elf_ndxscn(source->strtab.scn),
-                                     sym->st_name);
-
-    /* A symbol is imported by an executable or a library if it is undefined
-       and is either global or weak. There is an additional case for 
-       executables that we will check below. */
-    if (sym->st_shndx == SHN_UNDEF &&
-        (GELF_ST_BIND(sym->st_info) == STB_GLOBAL ||
-         GELF_ST_BIND(sym->st_info) == STB_WEAK)) {
-        INFO("*** symbol [%s:%s] is imported (UNDEFIEND).\n",
-             source->name,
-             symname);
-        return 1;
-    }
-
-#ifdef ARM_SPECIFIC_HACKS
-    /* A symbol is imported by an executable if is marked as an undefined 
-       symbol--this is standard to all ELF formats.  Alternatively, according 
-       to the ARM specifications, a symbol in a BSS section that is also marked
-       by an R_ARM_COPY relocation is also imported. */
-
-    if (source->elf_hdr.e_type != ET_EXEC) {
-        INFO("is_symbol_imported(): [%s] is a library, "
-             "no further checks.\n", source->name);
-        return 0;
-    }
-
-    /* Is the symbol in the BSS section, and is there a COPY relocation on 
-       that symbol? */
-    INFO("*** [%s:%s] checking further to see if symbol is imported.\n",
-         source->name, symname);
-    if (sym->st_shndx < source->shnum) {
-        /* Is it the .bss section? */
-        Elf_Scn *scn = elf_getscn(source->elf, sym->st_shndx);
-        FAILIF_LIBELF(NULL == scn, elf_getscn);
-        GElf_Shdr *shdr, shdr_mem;
-        shdr = gelf_getshdr(scn, &shdr_mem);
-        FAILIF_LIBELF(NULL == shdr, gelf_getshdr);
-        if (!strcmp(".bss", elf_strptr(source->elf,
-                                       source->shstrndx,
-                                       shdr->sh_name)))
-        {
-            /* Is there an R_ARM_COPY relocation on this symbol?  Iterate 
-               over the list of relocation sections and scan each section for
-               an entry that matches the symbol. */
-            size_t idx;
-            for (idx = 0; idx < source->num_relocations; idx++) {
-                section_info_t *reloc = source->relocations + idx;
-                /* Does the relocation section refer to the symbol table in
-                   which this symbol resides, and does it relocate the .bss
-                   section? */
-                if (reloc->shdr.sh_link == elf_ndxscn(source->symtab.scn) &&
-                    reloc->shdr.sh_info == sym->st_shndx)
-                {
-                    /* Go over the relocations and see if any of them matches
-                       our symbol. */
-                    size_t nrels = reloc->shdr.sh_size / reloc->shdr.sh_entsize;
-                    size_t relidx, newidx;
-                    if (reloc->shdr.sh_type == SHT_REL) {
-                        for (newidx = relidx = 0; relidx < nrels; ++relidx) {
-                            GElf_Rel rel_mem;
-                            FAILIF_LIBELF(gelf_getrel (reloc->data, 
-                                                       relidx, 
-                                                       &rel_mem) == NULL,
-                                          gelf_getrel);
-                            if (GELF_R_TYPE(rel_mem.r_info) == R_ARM_COPY &&
-                                GELF_R_SYM (rel_mem.r_info) == symidx)
-                            {
-                                INFO("*** symbol [%s:%s] is imported "
-                                     "(DEFINED, REL-COPY-RELOCATED).\n",
-                                     source->name,
-                                     symname);
-                                return 1;
-                            }
-                        } /* for each rel entry... */
-                    } else {
-                        for (newidx = relidx = 0; relidx < nrels; ++relidx) {
-                            GElf_Rela rel_mem;
-                            FAILIF_LIBELF(gelf_getrela (reloc->data, 
-                                                        relidx, 
-                                                        &rel_mem) == NULL,
-                                          gelf_getrela);
-                            if (GELF_R_TYPE(rel_mem.r_info) == R_ARM_COPY &&
-                                GELF_R_SYM (rel_mem.r_info) == symidx)
-                            {
-                                INFO("*** symbol [%s:%s] is imported "
-                                     "(DEFINED, RELA-COPY-RELOCATED).\n",
-                                     source->name,
-                                     symname);
-                                return 1;
-                            }
-                        } /* for each rela entry... */
-                    } /* if rel else rela */
-                }
-            }
-        }
-    }
-#endif/*ARM_SPECIFIC_HACKS*/
-
-    return 0;
-}
-
-static void resolve(source_t *source) {
-    /* Iterate the symbol table.  For each undefined symbol, scan the 
-       list of dependencies till we find a global symbol in one of them that 
-       satisfies the undefined reference.  At this point, we update both the 
-       satisfied[] array of the sources entry, as well as the exports array of 
-       the dependency where we found the match.
-    */
-
-    GElf_Sym *sym, sym_mem;
-    size_t symidx;
-    for (symidx = 0; symidx < source->num_syms; symidx++) {
-        sym = gelf_getsymshndx(source->symtab.data, 
-                               NULL,
-                               symidx,
-                               &sym_mem,
-                               NULL);
-        FAILIF_LIBELF(NULL == sym, gelf_getsymshndx);
-        if (is_symbol_imported(source, sym, symidx)) 
-		{
-            /* This is an undefined symbol.  Go over the list of libraries 
-               and look it up. */
-            size_t libidx;
-			int found = 0;
-			source_t *last_found = NULL;
-			const char *symname = elf_strptr(source->elf,
-											 elf_ndxscn(source->strtab.scn),
-											 sym->st_name);
-            for (libidx = 0; libidx < source->num_lib_deps; libidx++) {
-                source_t *lib = source->lib_deps[libidx];
-                int lib_symidx = hash_lookup(lib->elf,
-                                             lib->hash.data,
-                                             lib->symtab.data,
-                                             lib->strtab.data,
-                                             symname);
-                if (STN_UNDEF != lib_symidx)
-                {
-					/* We found the symbol--now check to see if it is global 
-					   or weak.  If this is the case, then the symbol satisfies
-					   the dependency. */
-					GElf_Sym *lib_sym, lib_sym_mem;
-					lib_sym = gelf_getsymshndx(lib->symtab.data, 
-											   NULL,
-											   lib_symidx,
-											   &lib_sym_mem,
-											   NULL);
-					FAILIF_LIBELF(NULL == lib_sym, gelf_getsymshndx);
-
-					if(lib_sym->st_shndx != STN_UNDEF &&
-					   (GELF_ST_BIND(lib_sym->st_info) == STB_GLOBAL ||
-						GELF_ST_BIND(lib_sym->st_info) == STB_WEAK))
-					{
-						/* We found the symbol! Update the satisfied array at this
-						   index location. */
-						source->satisfied[symidx] = lib;
-						/* Now, link this structure into the linked list 
-						   corresponding to the found symbol in the library's 
-						   global array. */
-                        if (source->num_next_export == source->next_export_size) {
-                            source->next_export_size += 30;
-                            source->next_export = 
-                                (source_t **)REALLOC(source->next_export,
-                                                     source->next_export_size *
-                                                     sizeof(struct next_export_t));
-                        }
-                        source->next_export[source->num_next_export] = lib->exports[lib_symidx];
-                        lib->exports[lib_symidx].source = source;
-                        lib->exports[lib_symidx].next_idx = source->num_next_export;
-
-                        source->num_next_export++;
-                        lib->num_exported++;
-
-                        INFO("[%s:%s (index %d)] satisfied by [%s] (index %d)\n",
-							 source->name,
-							 symname,
-							 symidx,
-							 lib->name,
-							 lib_symidx);
-						if (found) {
-							if (found == 1) {
-								found++;
-								ERROR("ERROR: multiple definitions found for [%s:%s]!\n",
-									  source->name, symname);
-								ERROR("\tthis definition     [%s]\n", lib->name);
-							}
-							ERROR("\tprevious definition [%s]\n", last_found->name);
-						}
-
-						last_found = lib;
-						if (!found) found = 1;
-					}
-                }
-            }
-			if(found == 0) {
-				ERROR("ERROR: could not find match for %s:%s.\n", 
-					  source->name, 
-					  symname);
-			}
-        } /* if we found the symbol... */
-    } /* for each symbol... */
-} /* resolve() */
-
-static void print_used_symbols(source_t *source) {
-
-    int name_len = strlen(source->name);
-    static const char ext[] = ".syms";
-    char *filter = (char *)MALLOC(name_len + sizeof(ext));
-    strcpy(filter, source->name);
-    strcpy(filter + name_len, ext);
-
-    FILE *fp = fopen(filter, "w+");
-    FAILIF(NULL == fp, 
-           "Can't open %s: %s (%d)\n", 
-           filter, 
-           strerror(errno), errno);
-    
-    /* Is anybody using the symbols defined in source? */
-
-    if (source->num_exported > 0) {
-        INFO("[%s] exports %d symbols to %d libraries and executables.\n",
-             source->name,
-             source->num_exported,
-             source->num_satisfied_execs);
-        size_t symidx;
-        for (symidx = 0; symidx < source->num_syms; symidx++) {
-            if (source->exports[symidx].source != NULL) {
-                GElf_Sym *sym, sym_mem;
-                sym = gelf_getsymshndx(source->symtab.data, 
-                                       NULL,
-                                       symidx,
-                                       &sym_mem,
-                                       NULL);
-                FAILIF_LIBELF(NULL == sym, gelf_getsymshndx);
-                fprintf(fp, "%s\n", elf_strptr(source->elf,
-                                               elf_ndxscn(source->strtab.scn),
-                                               sym->st_name));
-            }
-        }
-    }
-    else if (source->num_satisfied_execs > 0) {
-
-        /*  Is the source listed as a depenency on anyone?  If so, then the source exports no symbols
-            to anyone, but someone lists it as a dependency, which is unnecessary, so we print a warning.
-         */
-
-        ERROR("WARNING: [%s] is listed as a dependency in: ", source->name);
-        int i;
-        for (i = 0; i < source->num_satisfied_execs; i++) {
-            ERROR(" [%s],", source->satisfied_execs[i]->name);
-        }
-        ERROR(" but none of its symbols are used!.\n");
-    }
-#if 0 /* This is not really an error--a library's symbols may not be used anyone as specified in the ELF file,
-         but someone may still open a library via dlopen(). 
-      */
-    else {
-        ERROR("WARNING: None of [%s]'s symbols are used by any library or executable!\n", source->name);
-    }
-#endif
-
-	fclose(fp);
-    FREE(filter);
-}
-
-static void print_symbol_references(source_t *source) {
-
-    int name_len = strlen(source->name);
-    static const char ext[] = ".info";
-    char *filter = (char *)MALLOC(name_len + sizeof(ext));
-    strcpy(filter, source->name);
-    strcpy(filter + name_len, ext);
-
-    FILE *fp = fopen(filter, "w+");
-    FAILIF(NULL == fp, 
-           "Can't open %s: %s (%d)\n", 
-           filter, 
-           strerror(errno), errno);
-
-    if (source->num_exported > 0) {
-        size_t symidx;
-        for (symidx = 0; symidx < source->num_syms; symidx++) {
-            if (source->exports[symidx].source != NULL) {
-                const char *symname;
-                GElf_Sym *sym, sym_mem;
-                sym = gelf_getsymshndx(source->symtab.data, 
-                                       NULL,
-                                       symidx,
-                                       &sym_mem,
-                                       NULL);
-                FAILIF_LIBELF(NULL == sym, gelf_getsymshndx);
-                symname = elf_strptr(source->elf, 
-                                     elf_ndxscn(source->strtab.scn),
-                                     sym->st_name);
-                fprintf(fp, "%s\n", symname);
-                next_export_t *export = &source->exports[symidx];
-                while (export->source != NULL) {
-                    //fprintf(stderr, "%s:%s\n", symname, export->source->name);
-                    fprintf(fp, "\t%s\n", export->source->name);
-                    export = &export->source->next_export[export->next_idx];
-                }
-            }
-        }
-    }
-
-	fclose(fp);
-    FREE(filter);
-}
-
-static char * find_file(const char *libname, 
-                        char **lib_lookup_dirs, 
-                        int num_lib_lookup_dirs) {
-    if (libname[0] == '/') {
-        /* This is an absolute path name--just return it. */
-        INFO("ABSOLUTE PATH: [%s].\n", libname);
-        return strdup(libname);
-    } else {
-        /* First try the working directory. */
-        int fd;
-        if ((fd = open(libname, O_RDONLY)) > 0) {
-            close(fd);
-            INFO("FOUND IN CURRENT DIR: [%s].\n", libname);
-            return strdup(libname);
-        } else {
-            /* Iterate over all library paths.  For each path, append the file
-               name and see if there is a file at that place. If that fails, 
-               bail out. */
-
-            char *name;
-            while (num_lib_lookup_dirs--) {
-                size_t lib_len = strlen(*lib_lookup_dirs);
-                /* one extra character for the slash, and another for the 
-                   terminating NULL. */
-                name = (char *)MALLOC(lib_len + strlen(libname) + 2);
-                strcpy(name, *lib_lookup_dirs);
-                name[lib_len] = '/';
-                strcpy(name + lib_len + 1, libname);
-                if ((fd = open(name, O_RDONLY)) > 0) {
-                    close(fd);
-                    INFO("FOUND: [%s] in [%s].\n", libname, name);
-                    return name;
-                }
-                INFO("NOT FOUND: [%s] in [%s].\n", libname, name);
-                free(name);
-            }
-        }
-    }
-    return NULL;
-}
-
-static source_t* process_library(const char *libname,
-                                 char **lib_lookup_dirs, 
-                                 int num_lib_lookup_dirs) {
-    source_t *source = find_source(libname, lib_lookup_dirs, num_lib_lookup_dirs);
-    if (NULL == source) {
-        INFO("Processing [%s].\n", libname);
-        char *full = find_file(libname, lib_lookup_dirs, num_lib_lookup_dirs);
-        FAILIF(NULL == full, 
-               "Could not find [%s] in the current directory or in any of "
-               "the search paths!\n", libname);
-        source = init_source(full);
-        if (source) {
-            GElf_Dyn *dyn, dyn_mem;
-            size_t dynidx;
-            size_t numdyn =
-            source->dynamic.shdr.sh_size / 
-            source->dynamic.shdr.sh_entsize;
-
-            for (dynidx = 0; dynidx < numdyn; dynidx++) {
-                dyn = gelf_getdyn (source->dynamic.data, 
-                                   dynidx, 
-                                   &dyn_mem);
-                FAILIF_LIBELF(NULL == dyn, gelf_getdyn);
-                if (dyn->d_tag == DT_NEEDED) {
-                    /* Process the needed library recursively. */
-                    const char *dep_lib =
-                    elf_strptr (source->elf, 
-                                source->dynamic.shdr.sh_link, 
-                                dyn->d_un.d_val);
-                    INFO("[%s] depends on [%s].\n", libname, dep_lib);
-                    source_t *dep = process_library(dep_lib, 
-                                                    lib_lookup_dirs,
-                                                    num_lib_lookup_dirs);
-
-                    /* Tell dep that source depends on it. */
-                    if (dep->num_satisfied_execs == dep->satisfied_execs_size) {
-                        dep->satisfied_execs_size += 10;
-                        dep->satisfied_execs = 
-                            REALLOC(dep->satisfied_execs,
-                                    dep->satisfied_execs_size *
-                                    sizeof(source_t *));
-                    }
-                    dep->satisfied_execs[dep->num_satisfied_execs++] = source;
-
-                    /* Add the library to the dependency list. */
-                    if (source->num_lib_deps == source->lib_deps_size) {
-                        source->lib_deps_size += 10;
-                        source->lib_deps = REALLOC(source->lib_deps, 
-                                                   source->lib_deps_size *
-                                                   sizeof(source_t *));
-                    }
-                    source->lib_deps[source->num_lib_deps++] = dep;
-                }
-            } /* for each dynamic entry... */
-        }
-    } else INFO("[%s] has been processed already.\n", libname);
-
-    return source;
-}
-
-void lsd(char **execs, int num_execs,
-		 int list_needed_libs,
-		 int print_info,
-         char **lib_lookup_dirs, int num_lib_lookup_dirs) {
-
-    source_t *source; /* for general usage */
-    int input_idx;
-
-    for (input_idx = 0; input_idx < num_execs; input_idx++) {
-        INFO("executable: [%s]\n", execs[input_idx]);
-        /* Here process library is actually processing the top-level executable
-           files. */
-        process_library(execs[input_idx], lib_lookup_dirs, num_lib_lookup_dirs);
-        /* if source is NULL, then the respective executable is static */
-        /* Mark the source as an executable */
-    } /* for each input executable... */
-
-	if (list_needed_libs) {
-		source = sources;
-		while (source) {
-			print_needed_libs(source);
-			source = source->next;
-		}
-	}
-
-    /* Now, for each entry in the sources array, iterate its symbol table.  For
-       each undefined symbol, scan the list of dependencies till we find a 
-       global symbol in one of them that satisfies the undefined reference.  
-       At this point, we update both the satisfied[] array of the sources entry, 
-       as well as the exports array of the dependency where we found the match.
-    */
-
-    source = sources;
-    while (source) {
-        resolve(source);
-        source = source->next;
-    }
-
-    /* We are done!  Since the end result of our calculations is a set of 
-       symbols for each library that other libraries or executables link 
-       against, we iterate over the set of libraries one last time, and for
-       each symbol that is marked as satisfying some dependence, we emit 
-       a line with the symbol's name to a text file derived from the library's
-       name by appending the suffix .syms to it. */
-
-    source = sources;
-    while (source) {
-        /* If it's a library, print the results. */
-        if (source->elf_hdr.e_type == ET_DYN) {
-			print_used_symbols(source);
-			if (print_info) 
-				print_symbol_references(source);
-		}
-        source = source->next;
-    }
-
-	/* Free the resources--you can't do it in the loop above because function 
-	   print_symbol_references() accesses nodes other than the one being 
-	   iterated over.
-	 */
-	source = sources;
-	while (source) {
-		source_t *old = source;
-		source = source->next;
-		/* Destroy the evidence. */
-		destroy_source(old);
-	}
-}
-
diff --git a/tools/lsd/lsd.h b/tools/lsd/lsd.h
deleted file mode 100644
index 883c423..0000000
--- a/tools/lsd/lsd.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef LSD_H
-#define LSD_H
-
-void lsd(char **execs, int num_execs,
-		 int list_needed_libs,
-		 int print_info,
-         char **lib_lookup_dirs, 
-         int num_lib_lookup_dirs);
-
-#endif
diff --git a/tools/lsd/main.c b/tools/lsd/main.c
deleted file mode 100644
index f29157a..0000000
--- a/tools/lsd/main.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/* TODO:
-   1. check the ARM EABI version--this works for versions 1 and 2.
-   2. use a more-intelligent approach to finding the symbol table, symbol-string
-      table, and the .dynamic section.
-   3. fix the determination of the host and ELF-file endianness
-   4. write the help screen
-*/
-
-#include <stdio.h>
-#include <common.h>
-#include <debug.h>
-#include <libelf.h>
-#include <elf.h>
-#include <gelf.h>
-#include <cmdline.h>
-#include <string.h>
-#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <lsd.h>
-
-/* Flag set by --verbose.  This variable is global as it is accessed by the
-   macro INFO() in multiple compilation unites. */
-int verbose_flag = 0;
-/* Flag set by --quiet.  This variable is global as it is accessed by the
-   macro PRINT() in multiple compilation unites. */
-int quiet_flag = 0;
-
-int main(int argc, char **argv)
-{
-    char **lookup_dirs = NULL;
-    int num_lookup_dirs;
-	int print_info;
-	int list_needed_libs;
-
-    /* Do not issue INFO() statements before you call get_options() to set 
-       the verbose flag as necessary.
-    */
-
-    int first = get_options(argc, argv,
-							&list_needed_libs,
-							&print_info,
-                            &lookup_dirs,
-                            &num_lookup_dirs,
-                            &verbose_flag);
-
-    if (first == argc) {
-        print_help();
-        FAILIF(1,  "You must specify at least one input ELF file!\n");
-    }
-
-    /* Check to see whether the ELF library is current. */
-    FAILIF (elf_version(EV_CURRENT) == EV_NONE, "libelf is out of date!\n");
-
-    /* List symbol dependencies... */
-    lsd(&argv[first], argc - first, 
-		list_needed_libs, print_info, 
-		lookup_dirs, num_lookup_dirs);
-
-    FREE(lookup_dirs);
-
-    return 0;
-} 
-
diff --git a/tools/mktarball.sh b/tools/mktarball.sh
index ea1a8ed..3e32006 100755
--- a/tools/mktarball.sh
+++ b/tools/mktarball.sh
@@ -39,7 +39,14 @@
 done
 
 if [ $? -eq 0 ] ; then
-    bzip2 -c ${target_tar} > ${target_tarball}
+    case "${target_tarball}" in
+    *.bz2 )
+        bzip2 -c ${target_tar} > ${target_tarball}
+        ;;
+    *.gz )
+        gzip -c ${target_tar} > ${target_tarball}
+        ;;
+    esac
     success=$?
     [ $success -eq 0 ] || rm -f ${target_tarball}
     rm -f ${target_tar}
diff --git a/tools/post_process_props.py b/tools/post_process_props.py
new file mode 100755
index 0000000..01f9128
--- /dev/null
+++ b/tools/post_process_props.py
@@ -0,0 +1,82 @@
+#!/usr/bin/env python
+#
+# 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.
+
+import sys
+
+# Put the modifications that you need to make into the /system/build.prop into this
+# function. The prop object has get(name) and put(name,value) methods.
+def mangle_build_prop(prop):
+  pass
+
+
+# Put the modifications that you need to make into the /system/build.prop into this
+# function. The prop object has get(name) and put(name,value) methods.
+def mangle_default_prop(prop):
+  # If ro.debuggable is 1, then enable adb on USB by default
+  # (this is for userdebug builds)
+  if prop.get("ro.debuggable") == "1":
+    val = prop.get("persist.sys.usb.config")
+    if val == "":
+      val = "adb"
+    else:
+      val = val + ",adb"
+    prop.put("persist.sys.usb.config", val)
+
+
+class PropFile:
+  def __init__(self, lines):
+    self.lines = [s[:-1] for s in lines]
+
+  def get(self, name):
+    key = name + "="
+    for line in self.lines:
+      if line.startswith(key):
+        return line[len(key):]
+    return ""
+
+  def put(self, name, value):
+    key = name + "="
+    for i in range(0,len(self.lines)):
+      if self.lines[i].startswith(key):
+        self.lines[i] = key + value
+        return
+    self.lines.append(key + value)
+
+  def write(self, f):
+    f.write("\n".join(self.lines))
+    f.write("\n")
+
+def main(argv):
+  filename = argv[1]
+  f = open(filename)
+  lines = f.readlines()
+  f.close()
+
+  properties = PropFile(lines)
+  if filename.endswith("/build.prop"):
+    mangle_build_prop(properties)
+  elif filename.endswith("/default.prop"):
+    mangle_default_prop(properties)
+  else:
+    sys.stderr.write("bad command line: " + str(argv) + "\n")
+    sys.exit(1)
+
+  f = open(filename, 'w+')
+  properties.write(f)
+  f.close()
+
+if __name__ == "__main__":
+  main(sys.argv)
diff --git a/tools/releasetools/check_target_files_signatures b/tools/releasetools/check_target_files_signatures
index 17aebdc..2c97e2e 100755
--- a/tools/releasetools/check_target_files_signatures
+++ b/tools/releasetools/check_target_files_signatures
@@ -47,7 +47,6 @@
 
 import os
 import re
-import sha
 import shutil
 import subprocess
 import tempfile
@@ -112,7 +111,7 @@
         self.certs[cert] = self.certs[cert] + "," + name
     else:
       if name is None:
-        name = "unknown cert %s (%s)" % (sha.sha(cert).hexdigest()[:12],
+        name = "unknown cert %s (%s)" % (common.sha1(cert).hexdigest()[:12],
                                          GetCertSubject(cert))
       self.certs[cert] = name
 
@@ -245,7 +244,7 @@
     self.max_fn_len = 20
 
   def LoadZipFile(self, filename):
-    d = common.UnzipTemp(filename, '*.apk')
+    d, z = common.UnzipTemp(filename, '*.apk')
     try:
       self.apks = {}
       self.apks_by_basename = {}
@@ -263,7 +262,6 @@
     finally:
       shutil.rmtree(d)
 
-    z = zipfile.ZipFile(open(filename, "rb"))
     self.certmap = common.ReadApkCerts(z)
     z.close()
 
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py
index 52e7aed..40da73a 100644
--- a/tools/releasetools/common.py
+++ b/tools/releasetools/common.py
@@ -20,7 +20,6 @@
 import os
 import platform
 import re
-import sha
 import shutil
 import subprocess
 import sys
@@ -29,6 +28,13 @@
 import time
 import zipfile
 
+try:
+  import hashlib
+  sha1 = hashlib.sha1
+except ImportError:
+  import sha
+  sha1 = sha.sha
+
 # missing in Python 2.4 and before
 if not hasattr(os, "SEEK_SET"):
   os.SEEK_SET = 0
@@ -161,11 +167,27 @@
     p.mount_point = pieces[0]
     p.fs_type = pieces[1]
     p.device = pieces[2]
-    if len(pieces) == 4:
-      p.device2 = pieces[3]
+    p.length = 0
+    options = None
+    if len(pieces) >= 4:
+      if pieces[3].startswith("/"):
+        p.device2 = pieces[3]
+        if len(pieces) >= 5:
+          options = pieces[4]
+      else:
+        p.device2 = None
+        options = pieces[3]
     else:
       p.device2 = None
 
+    if options:
+      options = options.split(",")
+      for i in options:
+        if i.startswith("length="):
+          p.length = int(i[7:])
+        else:
+          print "%s: unknown option \"%s\"" % (p.mount_point, i)
+
     d[p.mount_point] = p
   return d
 
@@ -174,23 +196,6 @@
   for k, v in sorted(d.items()):
     print "%-25s = (%s) %s" % (k, type(v).__name__, v)
 
-def BuildAndAddBootableImage(sourcedir, targetname, output_zip, info_dict):
-  """Take a kernel, cmdline, and ramdisk directory from the input (in
-  'sourcedir'), and turn them into a boot image.  Put the boot image
-  into the output zip file under the name 'targetname'.  Returns
-  targetname on success or None on failure (if sourcedir does not
-  appear to contain files for the requested image)."""
-
-  print "creating %s..." % (targetname,)
-
-  img = BuildBootableImage(sourcedir)
-  if img is None:
-    return None
-
-  CheckSize(img, targetname, info_dict)
-  ZipWriteStr(output_zip, targetname, img)
-  return targetname
-
 def BuildBootableImage(sourcedir):
   """Take a kernel, cmdline, and ramdisk directory from the input (in
   'sourcedir'), and turn them into a boot image.  Return the image
@@ -248,28 +253,53 @@
   return data
 
 
-def AddRecovery(output_zip, info_dict):
-  BuildAndAddBootableImage(os.path.join(OPTIONS.input_tmp, "RECOVERY"),
-                           "recovery.img", output_zip, info_dict)
+def GetBootableImage(name, prebuilt_name, unpack_dir, tree_subdir):
+  """Return a File object (with name 'name') with the desired bootable
+  image.  Look for it in 'unpack_dir'/BOOTABLE_IMAGES under the name
+  'prebuilt_name', otherwise construct it from the source files in
+  'unpack_dir'/'tree_subdir'."""
 
-def AddBoot(output_zip, info_dict):
-  BuildAndAddBootableImage(os.path.join(OPTIONS.input_tmp, "BOOT"),
-                           "boot.img", output_zip, info_dict)
+  prebuilt_path = os.path.join(unpack_dir, "BOOTABLE_IMAGES", prebuilt_name)
+  if os.path.exists(prebuilt_path):
+    print "using prebuilt %s..." % (prebuilt_name,)
+    return File.FromLocalFile(name, prebuilt_path)
+  else:
+    print "building image from target_files %s..." % (tree_subdir,)
+    return File(name, BuildBootableImage(os.path.join(unpack_dir, tree_subdir)))
+
 
 def UnzipTemp(filename, pattern=None):
-  """Unzip the given archive into a temporary directory and return the name."""
+  """Unzip the given archive into a temporary directory and return the name.
+
+  If filename is of the form "foo.zip+bar.zip", unzip foo.zip into a
+  temp dir, then unzip bar.zip into that_dir/BOOTABLE_IMAGES.
+
+  Returns (tempdir, zipobj) where zipobj is a zipfile.ZipFile (of the
+  main file), open for reading.
+  """
 
   tmp = tempfile.mkdtemp(prefix="targetfiles-")
   OPTIONS.tempfiles.append(tmp)
-  cmd = ["unzip", "-o", "-q", filename, "-d", tmp]
-  if pattern is not None:
-    cmd.append(pattern)
-  p = Run(cmd, stdout=subprocess.PIPE)
-  p.communicate()
-  if p.returncode != 0:
-    raise ExternalError("failed to unzip input target-files \"%s\"" %
-                        (filename,))
-  return tmp
+
+  def unzip_to_dir(filename, dirname):
+    cmd = ["unzip", "-o", "-q", filename, "-d", dirname]
+    if pattern is not None:
+      cmd.append(pattern)
+    p = Run(cmd, stdout=subprocess.PIPE)
+    p.communicate()
+    if p.returncode != 0:
+      raise ExternalError("failed to unzip input target-files \"%s\"" %
+                          (filename,))
+
+  m = re.match(r"^(.*[.]zip)\+(.*[.]zip)$", filename, re.IGNORECASE)
+  if m:
+    unzip_to_dir(m.group(1), tmp)
+    unzip_to_dir(m.group(2), os.path.join(tmp, "BOOTABLE_IMAGES"))
+    filename = m.group(1)
+  else:
+    unzip_to_dir(filename, tmp)
+
+  return tmp, zipfile.ZipFile(filename, "r")
 
 
 def GetKeyPasswords(keylist):
@@ -326,7 +356,7 @@
   else:
     sign_name = output_name
 
-  cmd = ["java", "-Xmx512m", "-jar",
+  cmd = ["java", "-Xmx2048m", "-jar",
            os.path.join(OPTIONS.search_path, "framework", "signapk.jar")]
   if whole_file:
     cmd.append("-w")
@@ -367,18 +397,17 @@
     # image size should be increased by 1/64th to account for the
     # spare area (64 bytes per 2k page)
     limit = limit / 2048 * (2048+64)
-
-  size = len(data)
-  pct = float(size) * 100.0 / limit
-  msg = "%s size (%d) is %.2f%% of limit (%d)" % (target, size, pct, limit)
-  if pct >= 99.0:
-    raise ExternalError(msg)
-  elif pct >= 95.0:
-    print
-    print "  WARNING: ", msg
-    print
-  elif OPTIONS.verbose:
-    print "  ", msg
+    size = len(data)
+    pct = float(size) * 100.0 / limit
+    msg = "%s size (%d) is %.2f%% of limit (%d)" % (target, size, pct, limit)
+    if pct >= 99.0:
+      raise ExternalError(msg)
+    elif pct >= 95.0:
+      print
+      print "  WARNING: ", msg
+      print
+    elif OPTIONS.verbose:
+      print "  ", msg
 
 
 def ReadApkCerts(tf_zip):
@@ -659,7 +688,14 @@
     self.name = name
     self.data = data
     self.size = len(data)
-    self.sha1 = sha.sha(data).hexdigest()
+    self.sha1 = sha1(data).hexdigest()
+
+  @classmethod
+  def FromLocalFile(cls, name, diskname):
+    f = open(diskname, "rb")
+    data = f.read()
+    f.close()
+    return File(name, data)
 
   def WriteToTemp(self):
     t = tempfile.NamedTemporaryFile()
diff --git a/tools/releasetools/edify_generator.py b/tools/releasetools/edify_generator.py
index a7c8e32..d7b924b 100644
--- a/tools/releasetools/edify_generator.py
+++ b/tools/releasetools/edify_generator.py
@@ -161,11 +161,13 @@
     """Format the given partition, specified by its mount point (eg,
     "/system")."""
 
+    reserve_size = 0
     fstab = self.info.get("fstab", None)
     if fstab:
       p = fstab[partition]
-      self.script.append('format("%s", "%s", "%s");' %
-                         (p.fs_type, common.PARTITION_TYPES[p.fs_type], p.device))
+      self.script.append('format("%s", "%s", "%s", "%s");' %
+                         (p.fs_type, common.PARTITION_TYPES[p.fs_type],
+                          p.device, p.length))
 
   def DeleteFiles(self, file_list):
     """Delete all files in file_list."""
@@ -187,18 +189,6 @@
     cmd = "".join(cmd)
     self.script.append(self._WordWrap(cmd))
 
-  def WriteFirmwareImage(self, kind, fn):
-    """Arrange to update the given firmware image (kind must be
-    "hboot" or "radio") when recovery finishes."""
-    if self.version == 1:
-      self.script.append(
-          ('assert(package_extract_file("%(fn)s", "/tmp/%(kind)s.img"),\n'
-           '       write_firmware_image("/tmp/%(kind)s.img", "%(kind)s"));')
-          % {'kind': kind, 'fn': fn})
-    else:
-      self.script.append(
-          'write_firmware_image("PACKAGE:%s", "%s");' % (fn, kind))
-
   def WriteRawImage(self, mount_point, fn):
     """Write the given package file into the partition for the given
     mount point."""
@@ -210,9 +200,8 @@
       args = {'device': p.device, 'fn': fn}
       if partition_type == "MTD":
         self.script.append(
-            ('assert(package_extract_file("%(fn)s", "/tmp/%(device)s.img"),\n'
-             '       write_raw_image("/tmp/%(device)s.img", "%(device)s"),\n'
-             '       delete("/tmp/%(device)s.img"));') % args)
+            'write_raw_image(package_extract_file("%(fn)s"), "%(device)s");'
+            % args)
       elif partition_type == "EMMC":
         self.script.append(
             'package_extract_file("%(fn)s", "%(device)s");' % args)
@@ -239,6 +228,20 @@
              ",\0".join(['"' + i + '"' for i in sorted(links)]) + ");")
       self.script.append(self._WordWrap(cmd))
 
+  def RetouchBinaries(self, file_list):
+    """Execute the retouch instructions in files listed."""
+    cmd = ('retouch_binaries(' +
+           ', '.join(['"' + i[0] + '", "' + i[1] + '"' for i in file_list]) +
+           ');')
+    self.script.append(self._WordWrap(cmd))
+
+  def UndoRetouchBinaries(self, file_list):
+    """Undo the retouching (retouch to zero offset)."""
+    cmd = ('undo_retouch_binaries(' +
+           ', '.join(['"' + i[0] + '", "' + i[1] + '"' for i in file_list]) +
+           ');')
+    self.script.append(self._WordWrap(cmd))
+
   def AppendExtra(self, extra):
     """Append text verbatim to the output script."""
     self.script.append(extra)
diff --git a/tools/releasetools/img_from_target_files b/tools/releasetools/img_from_target_files
index 78fd141..c5b9886 100755
--- a/tools/releasetools/img_from_target_files
+++ b/tools/releasetools/img_from_target_files
@@ -23,6 +23,10 @@
   -b  (--board_config)  <file>
       Deprecated.
 
+  -z  (--bootable_zip)
+      Include only the bootable images (eg 'boot' and 'recovery') in
+      the output.
+
 """
 
 import sys
@@ -61,10 +65,13 @@
   img = tempfile.NamedTemporaryFile()
 
   build_command = []
-  if OPTIONS.info_dict["fstab"]["/data"].fs_type.startswith("ext"):
-    build_command = ["mkuserimg.sh",
-                     user_dir, img.name,
-                     OPTIONS.info_dict["fstab"]["/data"].fs_type, "data"]
+  fstab = OPTIONS.info_dict["fstab"]
+  if fstab and fstab["/data"].fs_type.startswith("ext"):
+    build_command = ["mkuserimg.sh"]
+    if "extfs_sparse_flag" in OPTIONS.info_dict:
+      build_command.append(OPTIONS.info_dict["extfs_sparse_flag"])
+    build_command.extend([user_dir, img.name,
+                     fstab["/data"].fs_type, "data"])
     if "userdata_size" in OPTIONS.info_dict:
       build_command.append(str(OPTIONS.info_dict["userdata_size"]))
   else:
@@ -75,7 +82,7 @@
     build_command.append(user_dir)
     build_command.append(img.name)
 
-  p = common.Run(build_command)
+  p = common.Run(build_command);
   p.communicate()
   assert p.returncode == 0, "build userdata.img image failed"
 
@@ -109,10 +116,14 @@
       pass
 
   build_command = []
-  if OPTIONS.info_dict["fstab"]["/system"].fs_type.startswith("ext"):
-    build_command = ["mkuserimg.sh",
-                     os.path.join(OPTIONS.input_tmp, "system"), img.name,
-                     OPTIONS.info_dict["fstab"]["/system"].fs_type, "system"]
+  fstab = OPTIONS.info_dict["fstab"]
+  if fstab and fstab["/system"].fs_type.startswith("ext"):
+
+    build_command = ["mkuserimg.sh"]
+    if "extfs_sparse_flag" in OPTIONS.info_dict:
+      build_command.append(OPTIONS.info_dict["extfs_sparse_flag"])
+    build_command.extend([os.path.join(OPTIONS.input_tmp, "system"), img.name,
+                     fstab["/system"].fs_type, "system"])
     if "system_size" in OPTIONS.info_dict:
       build_command.append(str(OPTIONS.info_dict["system_size"]))
   else:
@@ -142,35 +153,44 @@
 
 
 def main(argv):
+  bootable_only = [False]
 
   def option_handler(o, a):
     if o in ("-b", "--board_config"):
       pass       # deprecated
+    if o in ("-z", "--bootable_zip"):
+      bootable_only[0] = True
     else:
       return False
     return True
 
   args = common.ParseOptions(argv, __doc__,
-                             extra_opts="b:",
-                             extra_long_opts=["board_config="],
+                             extra_opts="b:z",
+                             extra_long_opts=["board_config=",
+                                              "bootable_zip"],
                              extra_option_handler=option_handler)
 
+  bootable_only = bootable_only[0]
+
   if len(args) != 2:
     common.Usage(__doc__)
     sys.exit(1)
 
-  OPTIONS.input_tmp = common.UnzipTemp(args[0])
-
-  input_zip = zipfile.ZipFile(args[0], "r")
+  OPTIONS.input_tmp, input_zip = common.UnzipTemp(args[0])
   OPTIONS.info_dict = common.LoadInfoDict(input_zip)
 
   output_zip = zipfile.ZipFile(args[1], "w", compression=zipfile.ZIP_DEFLATED)
 
-  common.AddBoot(output_zip, OPTIONS.info_dict)
-  common.AddRecovery(output_zip, OPTIONS.info_dict)
-  AddSystem(output_zip)
-  AddUserdata(output_zip)
-  CopyInfo(output_zip)
+  common.GetBootableImage(
+      "boot.img", "boot.img", OPTIONS.input_tmp, "BOOT").AddToZip(output_zip)
+  common.GetBootableImage(
+      "recovery.img", "recovery.img", OPTIONS.input_tmp,
+      "RECOVERY").AddToZip(output_zip)
+
+  if not bootable_only:
+    AddSystem(output_zip)
+    AddUserdata(output_zip)
+    CopyInfo(output_zip)
 
   print "cleaning up..."
   output_zip.close()
diff --git a/tools/releasetools/ota_from_target_files b/tools/releasetools/ota_from_target_files
index cd10d7c..8f5c3fe 100755
--- a/tools/releasetools/ota_from_target_files
+++ b/tools/releasetools/ota_from_target_files
@@ -44,6 +44,8 @@
   -e  (--extra_script)  <file>
       Insert the contents of file at the end of the update script.
 
+  -a  (--aslr_mode)  <on|off>
+      Specify whether to turn on ASLR for the package (on by default).
 """
 
 import sys
@@ -56,7 +58,6 @@
 import errno
 import os
 import re
-import sha
 import subprocess
 import tempfile
 import time
@@ -74,6 +75,7 @@
 OPTIONS.wipe_user_data = False
 OPTIONS.omit_prereq = False
 OPTIONS.extra_script = None
+OPTIONS.aslr_mode = True
 OPTIONS.worker_threads = 3
 
 def MostPopularKey(d, default):
@@ -90,6 +92,10 @@
   symlink."""
   return (info.external_attr >> 16) == 0120777
 
+def IsRegular(info):
+  """Return true if the zipfile.ZipInfo object passed in represents a
+  symlink."""
+  return (info.external_attr >> 28) == 010
 
 class Item:
   """Items represent the metadata (user, group, mode) of files and
@@ -244,13 +250,15 @@
                     substitute=None):
   """Copies files underneath system/ in the input zip to the output
   zip.  Populates the Item class with their metadata, and returns a
-  list of symlinks.  output_zip may be None, in which case the copy is
-  skipped (but the other side effects still happen).  substitute is an
-  optional dict of {output filename: contents} to be output instead of
-  certain input files.
+  list of symlinks as well as a list of files that will be retouched.
+  output_zip may be None, in which case the copy is skipped (but the
+  other side effects still happen).  substitute is an optional dict
+  of {output filename: contents} to be output instead of certain input
+  files.
   """
 
   symlinks = []
+  retouch_files = []
 
   for info in input_zip.infolist():
     if info.filename.startswith("SYSTEM/"):
@@ -268,6 +276,9 @@
             data = substitute[fn]
           else:
             data = input_zip.read(info.filename)
+          if info.filename.startswith("SYSTEM/lib/") and IsRegular(info):
+            retouch_files.append(("/system/" + basefilename,
+                                  common.sha1(data).hexdigest()))
           output_zip.writestr(info2, data)
         if fn.endswith("/"):
           Item.Get(fn[:-1], dir=True)
@@ -275,7 +286,7 @@
           Item.Get(fn, dir=False)
 
   symlinks.sort()
-  return symlinks
+  return (symlinks, retouch_files)
 
 
 def SignOutput(temp_zip_name, output_zip_name):
@@ -300,7 +311,8 @@
   patching and install the new recovery image.
 
   recovery_img and boot_img should be File objects for the
-  corresponding images.
+  corresponding images.  info should be the dictionary returned by
+  common.LoadInfoDict() on the input target_files.
 
   Returns an Item for the shell script, which must be made
   executable.
@@ -318,7 +330,7 @@
   # we check to see if this recovery has already been installed by
   # testing just the first 2k.
   HEADER_SIZE = 2048
-  header_sha1 = sha.sha(recovery_img.data[:HEADER_SIZE]).hexdigest()
+  header_sha1 = common.sha1(recovery_img.data[:HEADER_SIZE]).hexdigest()
   sh = """#!/system/bin/sh
 if ! applypatch -c %(recovery_type)s:%(recovery_device)s:%(header_size)d:%(header_sha1)s; then
   log -t recovery "Installing new recovery image"
@@ -378,13 +390,17 @@
   script.UnpackPackageDir("recovery", "/system")
   script.UnpackPackageDir("system", "/system")
 
-  symlinks = CopySystemFiles(input_zip, output_zip)
+  (symlinks, retouch_files) = CopySystemFiles(input_zip, output_zip)
   script.MakeSymlinks(symlinks)
+  if OPTIONS.aslr_mode:
+    script.RetouchBinaries(retouch_files)
+  else:
+    script.UndoRetouchBinaries(retouch_files)
 
-  boot_img = common.File("boot.img", common.BuildBootableImage(
-      os.path.join(OPTIONS.input_tmp, "BOOT")))
-  recovery_img = common.File("recovery.img", common.BuildBootableImage(
-      os.path.join(OPTIONS.input_tmp, "RECOVERY")))
+  boot_img = common.GetBootableImage("boot.img", "boot.img",
+                                     OPTIONS.input_tmp, "BOOT")
+  recovery_img = common.GetBootableImage("recovery.img", "recovery.img",
+                                         OPTIONS.input_tmp, "RECOVERY")
   MakeRecoveryPatch(output_zip, recovery_img, boot_img)
 
   Item.GetMetadata(input_zip)
@@ -420,12 +436,17 @@
   """Load all the files from SYSTEM/... in a given target-files
   ZipFile, and return a dict of {filename: File object}."""
   out = {}
+  retouch_files = []
   for info in z.infolist():
     if info.filename.startswith("SYSTEM/") and not IsSymlink(info):
-      fn = "system/" + info.filename[7:]
+      basefilename = info.filename[7:]
+      fn = "system/" + basefilename
       data = z.read(info.filename)
       out[fn] = common.File(fn, data)
-  return out
+      if info.filename.startswith("SYSTEM/lib/") and IsRegular(info):
+        retouch_files.append(("/system/" + basefilename,
+                              out[fn].sha1))
+  return (out, retouch_files)
 
 
 def GetBuildProp(property, z):
@@ -447,7 +468,7 @@
   if source_version == 0:
     print ("WARNING: generating edify script for a source that "
            "can't install it.")
-  script = edify_generator.EdifyGenerator(source_version, OPTIONS.info_dict)
+  script = edify_generator.EdifyGenerator(source_version, OPTIONS.target_info_dict)
 
   metadata = {"pre-device": GetBuildProp("ro.product.device", source_zip),
               "post-timestamp": GetBuildProp("ro.build.date.utc", target_zip),
@@ -464,9 +485,9 @@
       info_dict=OPTIONS.info_dict)
 
   print "Loading target..."
-  target_data = LoadSystemFiles(target_zip)
+  (target_data, target_retouch_files) = LoadSystemFiles(target_zip)
   print "Loading source..."
-  source_data = LoadSystemFiles(source_zip)
+  (source_data, source_retouch_files) = LoadSystemFiles(source_zip)
 
   verbatim_targets = []
   patch_list = []
@@ -501,7 +522,7 @@
       verbatim_targets.append((tf.name, tf.size))
     else:
       common.ZipWriteStr(output_zip, "patch/" + tf.name + ".p", d)
-      patch_list.append((tf.name, tf, sf, tf.size, sha.sha(d).hexdigest()))
+      patch_list.append((tf.name, tf, sf, tf.size, common.sha1(d).hexdigest()))
       largest_source_size = max(largest_source_size, sf.size)
 
   source_fp = GetBuildProp("ro.build.fingerprint", source_zip)
@@ -512,20 +533,16 @@
   script.Mount("/system")
   script.AssertSomeFingerprint(source_fp, target_fp)
 
-  source_boot = common.File("/tmp/boot.img",
-                            common.BuildBootableImage(
-                                os.path.join(OPTIONS.source_tmp, "BOOT")))
-  target_boot = common.File("/tmp/boot.img",
-                            common.BuildBootableImage(
-                                os.path.join(OPTIONS.target_tmp, "BOOT")))
+  source_boot = common.GetBootableImage(
+      "/tmp/boot.img", "boot.img", OPTIONS.source_tmp, "BOOT")
+  target_boot = common.GetBootableImage(
+      "/tmp/boot.img", "boot.img", OPTIONS.target_tmp, "BOOT")
   updating_boot = (source_boot.data != target_boot.data)
 
-  source_recovery = common.File("system/recovery.img",
-                                common.BuildBootableImage(
-                                    os.path.join(OPTIONS.source_tmp, "RECOVERY")))
-  target_recovery = common.File("system/recovery.img",
-                                common.BuildBootableImage(
-                                    os.path.join(OPTIONS.target_tmp, "RECOVERY")))
+  source_recovery = common.GetBootableImage(
+      "/tmp/recovery.img", "recovery.img", OPTIONS.source_tmp, "RECOVERY")
+  target_recovery = common.GetBootableImage(
+      "/tmp/recovery.img", "recovery.img", OPTIONS.target_tmp, "RECOVERY")
   updating_recovery = (source_recovery.data != target_recovery.data)
 
   # Here's how we divide up the progress bar:
@@ -635,7 +652,7 @@
 
   script.ShowProgress(0.1, 10)
 
-  target_symlinks = CopySystemFiles(target_zip, None)
+  (target_symlinks, target_retouch_dummies) = CopySystemFiles(target_zip, None)
 
   target_symlinks_d = dict([(i[1], i[0]) for i in target_symlinks])
   temp_script = script.MakeTemporary()
@@ -644,7 +661,7 @@
 
   # Note that this call will mess up the tree of Items, so make sure
   # we're done with it.
-  source_symlinks = CopySystemFiles(source_zip, None)
+  (source_symlinks, source_retouch_dummies) = CopySystemFiles(source_zip, None)
   source_symlinks_d = dict([(i[1], i[0]) for i in source_symlinks])
 
   # Delete all the symlinks in source that aren't in target.  This
@@ -678,6 +695,10 @@
       to_create.append((dest, link))
   script.DeleteFiles([i[1] for i in to_create])
   script.MakeSymlinks(to_create)
+  if OPTIONS.aslr_mode:
+    script.RetouchBinaries(target_retouch_files)
+  else:
+    script.UndoRetouchBinaries(target_retouch_files)
 
   # Now that the symlinks are created, we can set all the
   # permissions.
@@ -687,7 +708,7 @@
   device_specific.IncrementalOTA_InstallEnd()
 
   if OPTIONS.extra_script is not None:
-    scirpt.AppendExtra(OPTIONS.extra_script)
+    script.AppendExtra(OPTIONS.extra_script)
 
   script.AddToZip(target_zip, output_zip)
   WriteMetadata(metadata, output_zip)
@@ -708,6 +729,11 @@
       OPTIONS.omit_prereq = True
     elif o in ("-e", "--extra_script"):
       OPTIONS.extra_script = a
+    elif o in ("-a", "--aslr_mode"):
+      if a in ("on", "On", "true", "True", "yes", "Yes"):
+        OPTIONS.aslr_mode = True
+      else:
+        OPTIONS.aslr_mode = False
     elif o in ("--worker_threads"):
       OPTIONS.worker_threads = int(a)
     else:
@@ -715,14 +741,16 @@
     return True
 
   args = common.ParseOptions(argv, __doc__,
-                             extra_opts="b:k:i:d:wne:",
+                             extra_opts="b:k:i:d:wne:a:",
                              extra_long_opts=["board_config=",
                                               "package_key=",
                                               "incremental_from=",
                                               "wipe_user_data",
                                               "no_prereq",
                                               "extra_script=",
-                                              "worker_threads="],
+                                              "worker_threads=",
+                                              "aslr_mode=",
+                                              ],
                              extra_option_handler=option_handler)
 
   if len(args) != 2:
@@ -733,10 +761,9 @@
     OPTIONS.extra_script = open(OPTIONS.extra_script).read()
 
   print "unzipping target target-files..."
-  OPTIONS.input_tmp = common.UnzipTemp(args[0])
+  OPTIONS.input_tmp, input_zip = common.UnzipTemp(args[0])
 
   OPTIONS.target_tmp = OPTIONS.input_tmp
-  input_zip = zipfile.ZipFile(args[0], "r")
   OPTIONS.info_dict = common.LoadInfoDict(input_zip)
   if OPTIONS.verbose:
     print "--- target info ---"
@@ -760,8 +787,7 @@
     WriteFullOTAPackage(input_zip, output_zip)
   else:
     print "unzipping source target-files..."
-    OPTIONS.source_tmp = common.UnzipTemp(OPTIONS.incremental_source)
-    source_zip = zipfile.ZipFile(OPTIONS.incremental_source, "r")
+    OPTIONS.source_tmp, source_zip = common.UnzipTemp(OPTIONS.incremental_source)
     OPTIONS.target_info_dict = OPTIONS.info_dict
     OPTIONS.source_info_dict = common.LoadInfoDict(source_zip)
     if OPTIONS.verbose:
diff --git a/tools/releasetools/sign_target_files_apks b/tools/releasetools/sign_target_files_apks
index 5fca691..5353063 100755
--- a/tools/releasetools/sign_target_files_apks
+++ b/tools/releasetools/sign_target_files_apks
@@ -204,6 +204,17 @@
   except KeyError:
     raise ExternalError("can't read META/otakeys.txt from input")
 
+  misc_info = common.LoadInfoDict(input_tf_zip)
+
+  extra_recovery_keys = misc_info.get("extra_recovery_keys", None)
+  if extra_recovery_keys:
+    extra_recovery_keys = [OPTIONS.key_map.get(k, k) + ".x509.pem"
+                           for k in extra_recovery_keys.split()]
+    if extra_recovery_keys:
+      print "extra recovery-only key(s): " + ", ".join(extra_recovery_keys)
+  else:
+    extra_recovery_keys = []
+
   mapped_keys = []
   for k in keylist:
     m = re.match(r"^(.*)\.x509\.pem$", k)
@@ -217,15 +228,18 @@
     print "for OTA package verification"
   else:
     mapped_keys.append(
-        OPTIONS.key_map["build/target/product/security/testkey"] + ".x509.pem")
+        OPTIONS.key_map.get("build/target/product/security/testkey",
+                            "build/target/product/security/testkey")
+        + ".x509.pem")
     print "META/otakeys.txt has no keys; using", mapped_keys[0]
 
   # recovery uses a version of the key that has been slightly
   # predigested (by DumpPublicKey.java) and put in res/keys.
+  # extra_recovery_keys are used only in recovery.
 
   p = common.Run(["java", "-jar",
                   os.path.join(OPTIONS.search_path, "framework", "dumpkey.jar")]
-                 + mapped_keys,
+                 + mapped_keys + extra_recovery_keys,
                  stdout=subprocess.PIPE)
   data, _ = p.communicate()
   if p.returncode != 0:
@@ -234,6 +248,7 @@
 
   # SystemUpdateActivity uses the x509.pem version of the keys, but
   # put into a zipfile system/etc/security/otacerts.zip.
+  # We DO NOT include the extra_recovery_keys (if any) here.
 
   tempfile = cStringIO.StringIO()
   certs_zip = zipfile.ZipFile(tempfile, "w")
diff --git a/tools/soslim/Android.mk b/tools/soslim/Android.mk
deleted file mode 100644
index 60a860a..0000000
--- a/tools/soslim/Android.mk
+++ /dev/null
@@ -1,49 +0,0 @@
-# Copyright 2005 The Android Open Source Project
-#
-# Android.mk for soslim
-#
-
-LOCAL_PATH:= $(call my-dir)
-
-ifeq ($(TARGET_ARCH),arm)
-include $(CLEAR_VARS)
-
-LOCAL_LDLIBS += -ldl
-LOCAL_CFLAGS += -O2 -g
-LOCAL_CFLAGS += -fno-function-sections -fno-data-sections -fno-inline
-LOCAL_CFLAGS += -Wall -Wno-unused-function #-Werror
-LOCAL_CFLAGS += -DBIG_ENDIAN=1
-LOCAL_CFLAGS += -DARM_SPECIFIC_HACKS
-LOCAL_CFLAGS += -DSUPPORT_ANDROID_PRELINK_TAGS
-LOCAL_CFLAGS += -DDEBUG
-LOCAL_CFLAGS += -DSTRIP_STATIC_SYMBOLS
-LOCAL_CFLAGS += -DMOVE_SECTIONS_IN_RANGES
-
-ifeq ($(HOST_OS),windows)
-# Cygwin stat does not support ACCESSPERMS bitmask
-LOCAL_CFLAGS += -DACCESSPERMS=0777
-LOCAL_LDLIBS += -lintl
-endif
-
-LOCAL_SRC_FILES := \
-        cmdline.c \
-        common.c \
-        debug.c \
-        soslim.c \
-        main.c \
-        prelink_info.c \
-        symfilter.c
-
-LOCAL_C_INCLUDES:= \
-	$(LOCAL_PATH)/ \
-	external/elfutils/lib/ \
-	external/elfutils/libelf/ \
-	external/elfutils/libebl/ \
-	external/elfcopy/
-
-LOCAL_STATIC_LIBRARIES := libelfcopy libelf libebl libebl_arm #dl
-
-LOCAL_MODULE := soslim
-
-include $(BUILD_HOST_EXECUTABLE)
-endif #TARGET_ARCH==arm
diff --git a/tools/soslim/cmdline.c b/tools/soslim/cmdline.c
deleted file mode 100644
index c2d5e71..0000000
--- a/tools/soslim/cmdline.c
+++ /dev/null
@@ -1,141 +0,0 @@
-#include <debug.h>
-#include <cmdline.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <getopt.h>
-#include <string.h>
-#include <ctype.h>
-
-extern char *optarg;
-extern int optind, opterr, optopt;
-
-static struct option long_options[] =
-{
-    {"verbose",  no_argument,       0, 'V'},
-    {"quiet",    no_argument,       0, 'Q'},
-    {"shady",    no_argument,       0, 'S'},
-    {"print",    no_argument,       0, 'p'},
-    {"help",     no_argument,       0, 'h'},
-    {"outfile",  required_argument, 0, 'o'},
-    {"filter",   required_argument, 0, 'f'},
-    {"dry",      no_argument,       0, 'n'},
-    {"strip",    no_argument,       0, 's'},
-    {0, 0, 0, 0},
-};
-
-/* This array must parallel long_options[] */
-static
-const char *descriptions[sizeof(long_options)/sizeof(long_options[0])] = {
-	"print verbose output",
-    "suppress errors and warnings",
-    "patch ABS symbols whose values coincide with section starts and ends",
-    "print the symbol table (if specified, only -V is allowed)",
-    "this help screen",
-    "specify an output file (if not provided, input file is modified)",
-    "specify a symbol-filter file",
-    "dry run (perform all calculations but do not modify the ELF file)",
-    "strip debug sections, if they are present"
-};
-
-void print_help(void)
-{
-    fprintf(stdout,
-			"invokation:\n"
-			"\tsoslim file1 [file2 file3 ... fileN] [-Ldir1 -Ldir2 ... -LdirN] "
-			"[-Vpn]\n"
-			"or\n"
-			"\tsoslim -h\n\n");
-	fprintf(stdout, "options:\n");
-	struct option *opt = long_options;
-	const char **desc = descriptions;
-	while (opt->name) {
-		fprintf(stdout, "\t-%c/--%-15s %s\n",
-				opt->val,
-				opt->name,
-				*desc);
-		opt++;
-		desc++;
-	}
-}
-
-int get_options(int argc, char **argv,
-                char **outfile,
-                char **symsfile,
-                int *print_symtab,
-                int *verbose,
-                int *quiet,
-                int *shady,
-                int *dry_run,
-                int *strip_debug)
-{
-    int c;
-
-    ASSERT(outfile);
-    *outfile = NULL;
-    ASSERT(symsfile);
-    *symsfile = NULL;
-    ASSERT(print_symtab);
-    *print_symtab = 0;
-    ASSERT(verbose);
-    *verbose = 0;
-    ASSERT(quiet);
-    *quiet = 0;
-    ASSERT(shady);
-    *shady = 0;
-    ASSERT(dry_run);
-    *dry_run = 0;
-    ASSERT(strip_debug);
-    *strip_debug = 0;
-
-    while (1) {
-        /* getopt_long stores the option index here. */
-        int option_index = 0;
-
-        c = getopt_long (argc, argv,
-                         "QVSphi:o:y:Y:f:ns",
-                         long_options,
-                         &option_index);
-        /* Detect the end of the options. */
-        if (c == -1) break;
-
-        if (isgraph(c)) {
-            INFO ("option -%c with value `%s'\n", c, (optarg ?: "(null)"));
-        }
-
-#define SET_STRING_OPTION(name) do { \
-    ASSERT(optarg);                  \
-    *name = strdup(optarg);          \
-} while(0)
-
-        switch (c) {
-        case 0:
-            /* If this option set a flag, do nothing else now. */
-            if (long_options[option_index].flag != 0)
-                break;
-            INFO ("option %s", long_options[option_index].name);
-            if (optarg)
-                INFO (" with arg %s", optarg);
-            INFO ("\n");
-            break;
-        case 'p': *print_symtab = 1; break;
-        case 'h': print_help(); exit(1); break;
-        case 'V': *verbose = 1; break;
-        case 'Q': *quiet = 1; break;
-        case 'S': *shady = 1; break;
-        case 'n': *dry_run = 1; break;
-        case 's': *strip_debug = 1; break;
-        case 'o': SET_STRING_OPTION(outfile); break;
-        case 'f': SET_STRING_OPTION(symsfile); break;
-        case '?':
-            /* getopt_long already printed an error message. */
-            break;
-
-#undef SET_STRING_OPTION
-
-        default:
-            FAILIF(1, "Unknown option");
-        }
-    }
-
-    return optind;
-}
diff --git a/tools/soslim/cmdline.h b/tools/soslim/cmdline.h
deleted file mode 100644
index bfc431e..0000000
--- a/tools/soslim/cmdline.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef CMDLINE_H
-#define CMDLINE_H
-
-void print_help(void);
-
-int get_options(int argc, char **argv,
-                char **outfile,
-                char **symsfile,
-                int *print_symtab,
-                int *verbose,
-                int *quiet,
-                int *shady,
-                int *dry_run,
-                int *strip_debug);
-
-#endif/*CMDLINE_H*/
diff --git a/tools/soslim/common.c b/tools/soslim/common.c
deleted file mode 100644
index b90cf41..0000000
--- a/tools/soslim/common.c
+++ /dev/null
@@ -1,35 +0,0 @@
-#include <stdlib.h>
-#include <common.h>
-#include <debug.h>
-
-void map_over_sections(Elf *elf, 
-                       section_match_fn_t match,
-                       void *user_data)
-{
-    Elf_Scn* section = NULL;
-    while ((section = elf_nextscn(elf, section)) != NULL) {
-        if (match(elf, section, user_data))
-            return;
-    }
-}   
-
-void map_over_segments(Elf *elf, 
-                       segment_match_fn_t match, 
-                       void *user_data)
-{
-    Elf32_Ehdr *ehdr; 
-    Elf32_Phdr *phdr; 
-    int index;
-
-    ehdr = elf32_getehdr(elf);
-    phdr = elf32_getphdr(elf);
-
-    INFO("Scanning over %d program segments...\n", 
-         ehdr->e_phnum);
-
-    for (index = ehdr->e_phnum; index; index--) {
-        if (match(elf, phdr++, user_data))
-            return;
-    }
-}
-
diff --git a/tools/soslim/common.h b/tools/soslim/common.h
deleted file mode 100644
index dacf930..0000000
--- a/tools/soslim/common.h
+++ /dev/null
@@ -1,49 +0,0 @@
-#ifndef COMMON_H
-#define COMMON_H
-
-#include <libelf.h>
-#include <elf.h>
-
-#define unlikely(expr) __builtin_expect (expr, 0)
-#define likely(expr)   __builtin_expect (expr, 1)
-
-#define MIN(a,b) ((a)<(b)?(a):(b)) /* no side effects in arguments allowed! */
-
-typedef int (*section_match_fn_t)(Elf *, Elf_Scn *, void *);
-void map_over_sections(Elf *, section_match_fn_t, void *);
-
-typedef int (*segment_match_fn_t)(Elf *, Elf32_Phdr *, void *);
-void map_over_segments(Elf *, segment_match_fn_t, void *);
-
-typedef struct {
-    Elf_Scn *sect;
-    Elf32_Shdr *hdr;
-    Elf_Data *data;
-    size_t index;
-} section_info_t;
-
-static inline void get_section_info(Elf_Scn *sect, section_info_t *info)
-{
-    info->sect = sect;
-    info->data = elf_getdata(sect, 0);
-    info->hdr = elf32_getshdr(sect);
-    info->index = elf_ndxscn(sect);
-}
-
-static inline int is_host_little(void)
-{
-    short val = 0x10;
-    return ((char *)&val)[0] != 0;
-}
-
-static inline long switch_endianness(long val)
-{
-	long newval;
-	((char *)&newval)[3] = ((char *)&val)[0];
-	((char *)&newval)[2] = ((char *)&val)[1];
-	((char *)&newval)[1] = ((char *)&val)[2];
-	((char *)&newval)[0] = ((char *)&val)[3];
-	return newval;
-}
-
-#endif/*COMMON_H*/
diff --git a/tools/soslim/debug.c b/tools/soslim/debug.c
deleted file mode 100644
index b8365af..0000000
--- a/tools/soslim/debug.c
+++ /dev/null
@@ -1,40 +0,0 @@
-#include <debug.h>
-#include <stdio.h>
-#include <ctype.h>
-
-#if 0
-
-#define NUM_COLS  (32)
-
-int dump_hex_buffer(FILE *s, void *b, size_t len, size_t elsize) {
-    int num_nonprintable = 0;
-    int i, last;
-    char *pchr = (char *)b;
-    fputc('\n', s);
-    for (i = last = 0; i < len; i++) {
-        if (!elsize) {
-            if (i && !(i % 4)) fprintf(s, " ");
-            if (i && !(i % 8)) fprintf(s, " ");
-        } else {
-            if (i && !(i % elsize)) fprintf(s, " ");
-        }
-
-        if (i && !(i % NUM_COLS)) {
-            while (last < i) {
-                if (isprint(pchr[last]))
-                    fputc(pchr[last], s);
-                else {
-                    fputc('.', s);
-                    num_nonprintable++;
-                }
-                last++;
-            }
-            fprintf(s, " (%d)\n", i);
-        }
-        fprintf(s, "%02x", (unsigned char)pchr[i]);
-    }
-    if (i && (i % NUM_COLS)) fputs("\n", s);
-    return num_nonprintable;
-}
-
-#endif
diff --git a/tools/soslim/debug.h b/tools/soslim/debug.h
deleted file mode 100644
index e7a2f9a..0000000
--- a/tools/soslim/debug.h
+++ /dev/null
@@ -1,88 +0,0 @@
-#ifndef DEBUG_H
-#define DEBUG_H
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <common.h>
-
-#ifdef DEBUG
-
-    #define FAILIF(cond, msg...) do {                        \
-	if (unlikely(cond)) {                                \
-        fprintf(stderr, "%s(%d): ", __FILE__, __LINE__); \
-		fprintf(stderr, ##msg);                          \
-		exit(1);                                         \
-	}                                                    \
-} while(0)
-
-/* Debug enabled */
-    #define ASSERT(x) do {                                \
-	if (unlikely(!(x))) {                             \
-		fprintf(stderr,                               \
-				"ASSERTION FAILURE %s:%d: [%s]\n",    \
-				__FILE__, __LINE__, #x);              \
-		exit(1);                                      \
-	}                                                 \
-} while(0)
-
-#else
-
-    #define FAILIF(cond, msg...) do { \
-	if (unlikely(cond)) {         \
-		fprintf(stderr, ##msg);   \
-		exit(1);                  \
-	}                             \
-} while(0)
-
-/* No debug */
-    #define ASSERT(x)   do { } while(0)
-
-#endif/* DEBUG */
-
-#define FAILIF_LIBELF(cond, function) \
-    FAILIF(cond, "%s(): %s\n", #function, elf_errmsg(elf_errno()));
-
-static inline void *MALLOC(unsigned int size) {
-    void *m = malloc(size);
-    FAILIF(NULL == m, "malloc(%d) failed!\n", size);
-    return m;
-}
-
-static inline void *CALLOC(unsigned int num_entries, unsigned int entry_size) {
-    void *m = calloc(num_entries, entry_size);
-    FAILIF(NULL == m, "calloc(%d, %d) failed!\n", num_entries, entry_size);
-    return m;
-}
-
-static inline void *REALLOC(void *ptr, unsigned int size) {
-    void *m = realloc(ptr, size);
-    FAILIF(NULL == m, "realloc(%p, %d) failed!\n", ptr, size);
-    return m;
-}
-
-static inline void FREE(void *ptr) {
-    free(ptr);
-}
-
-static inline void FREEIF(void *ptr) {
-    if (ptr) FREE(ptr);
-}
-
-#define PRINT(x...)  do {                             \
-    extern int quiet_flag;                            \
-    if(likely(!quiet_flag))                           \
-        fprintf(stdout, ##x);                         \
-} while(0)
-
-#define ERROR(x...) fprintf(stderr, ##x)
-
-#define INFO(x...)  do {                              \
-    extern int verbose_flag;                          \
-    if(unlikely(verbose_flag))                        \
-        fprintf(stdout, ##x);                         \
-} while(0)
-
-/* Prints a hex and ASCII dump of the selected buffer to the selected stream. */
-int dump_hex_buffer(FILE *s, void *b, size_t l, size_t elsize);
-
-#endif/*DEBUG_H*/
diff --git a/tools/soslim/main.c b/tools/soslim/main.c
deleted file mode 100644
index dd8a60b..0000000
--- a/tools/soslim/main.c
+++ /dev/null
@@ -1,360 +0,0 @@
-/* TODO:
-   1. check the ARM EABI version--this works for versions 1 and 2.
-   2. use a more-intelligent approach to finding the symbol table, symbol-string
-      table, and the .dynamic section.
-   3. fix the determination of the host and ELF-file endianness
-   4. write the help screen
-*/
-
-#include <stdio.h>
-#include <common.h>
-#include <debug.h>
-#include <hash.h>
-#include <libelf.h>
-#include <elf.h>
-#include <gelf.h>
-#include <cmdline.h>
-#include <string.h>
-#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <soslim.h>
-#include <symfilter.h>
-#ifdef SUPPORT_ANDROID_PRELINK_TAGS
-#include <prelink_info.h>
-#endif
-
-/* Flag set by --verbose.  This variable is global as it is accessed by the
-   macro INFO() in multiple compilation unites. */
-int verbose_flag = 0;
-/* Flag set by --quiet.  This variable is global as it is accessed by the
-   macro PRINT() in multiple compilation unites. */
-int quiet_flag = 0;
-static void print_dynamic_symbols(Elf *elf, const char *symtab_name);
-
-int main(int argc, char **argv)
-{
-    int elf_fd = -1, newelf_fd = -1;
-    Elf *elf = NULL, *newelf = NULL;
-    char *infile = NULL;
-    char *outfile = NULL;
-    char *symsfile_name = NULL;
-    int print_symtab = 0;
-    int shady = 0;
-    int dry_run = 0;
-    int strip_debug = 0;
-
-    /* Do not issue INFO() statements before you call get_options() to set
-       the verbose flag as necessary.
-    */
-
-    int first = get_options(argc, argv,
-                            &outfile,
-                            &symsfile_name,
-                            &print_symtab,
-                            &verbose_flag,
-                            &quiet_flag,
-                            &shady,
-                            &dry_run,
-                            &strip_debug);
-
-    if ((print_symtab && (first == argc)) ||
-        (!print_symtab && first + 1 != argc)) {
-        print_help();
-        FAILIF(1,  "You must specify an input ELF file!\n");
-    }
-    FAILIF(print_symtab && (outfile || symsfile_name || shady),
-           "You cannot provide --print and --outfile, --filter options, or "
-           "--shady simultaneously!\n");
-    FAILIF(dry_run && outfile,
-           "You cannot have a dry run and output a file at the same time.");
-
-    /* Check to see whether the ELF library is current. */
-    FAILIF (elf_version(EV_CURRENT) == EV_NONE, "libelf is out of date!\n");
-
-    if (print_symtab) {
-
-        while (first < argc) {
-            infile = argv[first++];
-
-            INFO("Opening %s...\n", infile);
-            elf_fd = open(infile, O_RDONLY);
-            FAILIF(elf_fd < 0, "open(%s): %s (%d)\n",
-                   infile,
-                   strerror(errno),
-                   errno);
-            INFO("Calling elf_begin(%s)...\n", infile);
-            elf = elf_begin(elf_fd, ELF_C_READ, NULL);
-            FAILIF_LIBELF(elf == NULL, elf_begin);
-
-            /* libelf can recognize COFF and A.OUT formats, but we handle only
-               ELF. */
-            FAILIF(elf_kind(elf) != ELF_K_ELF,
-                   "Input file %s is not in ELF format!\n",
-                   infile);
-
-            /* Make sure this is a shared library or an executable. */
-            {
-                GElf_Ehdr elf_hdr;
-                INFO("Making sure %s is a shared library or an executable.\n",
-                     infile);
-                FAILIF_LIBELF(0 == gelf_getehdr(elf, &elf_hdr), gelf_getehdr);
-                FAILIF(elf_hdr.e_type != ET_DYN &&
-                       elf_hdr.e_type != ET_EXEC,
-                       "%s must be a shared library or an executable "
-                       "(elf type is %d).\n",
-                       infile,
-                       elf_hdr.e_type);
-            }
-
-            print_dynamic_symbols(elf, infile);
-
-            FAILIF_LIBELF(elf_end(elf), elf_end);
-            FAILIF(close(elf_fd) < 0, "Could not close file %s: %s (%d)!\n",
-                   infile, strerror(errno), errno);
-        }
-    }
-    else {
-        int elf_fd = -1;
-        Elf *elf = NULL;
-        infile = argv[first];
-
-        INFO("Opening %s...\n", infile);
-        elf_fd = open(infile, ((outfile == NULL && dry_run == 0) ? O_RDWR : O_RDONLY));
-        FAILIF(elf_fd < 0, "open(%s): %s (%d)\n",
-               infile,
-               strerror(errno),
-               errno);
-        INFO("Calling elf_begin(%s)...\n", infile);
-        elf = elf_begin(elf_fd,
-                        ((outfile == NULL && dry_run == 0) ? ELF_C_RDWR : ELF_C_READ),
-                        NULL);
-        FAILIF_LIBELF(elf == NULL, elf_begin);
-
-        /* libelf can recognize COFF and A.OUT formats, but we handle only ELF. */
-        FAILIF(elf_kind(elf) != ELF_K_ELF,
-               "Input file %s is not in ELF format!\n",
-               infile);
-
-        /* We run a better check in adjust_elf() itself.  It is permissible to call adjust_elf()
-           on an executable if we are only stripping sections from the executable, not rearranging
-           or moving sections.
-        */
-        if (0) {
-            /* Make sure this is a shared library. */
-            GElf_Ehdr elf_hdr;
-            INFO("Making sure %s is a shared library...\n", infile);
-            FAILIF_LIBELF(0 == gelf_getehdr(elf, &elf_hdr), gelf_getehdr);
-            FAILIF(elf_hdr.e_type != ET_DYN,
-                   "%s must be a shared library (elf type is %d, expecting %d).\n",
-                   infile,
-                   elf_hdr.e_type,
-                   ET_DYN);
-        }
-
-        if (outfile != NULL) {
-            ASSERT(!dry_run);
-            struct stat st;
-            FAILIF(fstat (elf_fd, &st) != 0,
-                   "Cannot stat input file %s: %s (%d)!\n",
-                   infile, strerror(errno), errno);
-            newelf_fd = open (outfile, O_RDWR | O_CREAT | O_TRUNC,
-                    st.st_mode & ACCESSPERMS);
-            FAILIF(newelf_fd < 0, "Cannot create file %s: %s (%d)!\n",
-                   outfile, strerror(errno), errno);
-            INFO("Output file is [%s].\n", outfile);
-            newelf = elf_begin(newelf_fd, ELF_C_WRITE_MMAP, NULL);
-        } else {
-            INFO("Modifying [%s] in-place.\n", infile);
-            newelf = elf_clone(elf, ELF_C_EMPTY);
-        }
-
-        symfilter_t symfilter;
-
-        symfilter.symbols_to_keep = NULL;
-        symfilter.num_symbols_to_keep = 0;
-        if (symsfile_name) {
-            /* Make sure that the file is not empty. */
-            struct stat s;
-            FAILIF(stat(symsfile_name, &s) < 0,
-                   "Cannot stat file %s.\n", symsfile_name);
-            if (s.st_size) {
-                INFO("Building symbol filter.\n");
-                build_symfilter(symsfile_name, elf, &symfilter, s.st_size);
-            }
-            else INFO("Not building symbol filter, filter file is empty.\n");
-        }
-#ifdef SUPPORT_ANDROID_PRELINK_TAGS
-        int prelinked = 0;
-        int elf_little; /* valid if prelinked != 0 */
-        long prelink_addr; /* valid if prelinked != 0 */
-#endif
-        clone_elf(elf, newelf,
-                  infile, outfile,
-                  symfilter.symbols_to_keep,
-                  symfilter.num_symbols_to_keep,
-                  shady
-#ifdef SUPPORT_ANDROID_PRELINK_TAGS
-                  , &prelinked,
-                  &elf_little,
-                  &prelink_addr
-#endif
-                  ,
-                  true, /* rebuild the section-header-strings table */
-                  strip_debug,
-                  dry_run);
-
-        if (symsfile_name && symfilter.symbols_to_keep != NULL) {
-            destroy_symfilter(&symfilter);
-        }
-
-        if (outfile != NULL) INFO("Closing %s...\n", outfile);
-        FAILIF_LIBELF(elf_end (newelf) != 0, elf_end);
-        FAILIF(newelf_fd >= 0 && close(newelf_fd) < 0,
-               "Could not close file %s: %s (%d)!\n",
-               outfile, strerror(errno), errno);
-
-        INFO("Closing %s...\n", infile);
-        FAILIF_LIBELF(elf_end(elf), elf_end);
-        FAILIF(close(elf_fd) < 0, "Could not close file %s: %s (%d)!\n",
-               infile, strerror(errno), errno);
-
-#ifdef SUPPORT_ANDROID_PRELINK_TAGS
-        if (prelinked) {
-            INFO("File is prelinked, putting prelink TAG back in place.\n");
-            setup_prelink_info(outfile != NULL ? outfile : infile,
-                               elf_little,
-                               prelink_addr);
-        }
-#endif
-    }
-
-    FREEIF(outfile);
-    return 0;
-}
-
-static void print_dynamic_symbols(Elf *elf, const char *file)
-{
-    Elf_Scn *scn = NULL;
-    GElf_Shdr shdr;
-
-    GElf_Ehdr ehdr;
-    FAILIF_LIBELF(0 == gelf_getehdr(elf, &ehdr), gelf_getehdr);
-    while ((scn = elf_nextscn (elf, scn)) != NULL) {
-        FAILIF_LIBELF(NULL == gelf_getshdr(scn, &shdr), gelf_getshdr);
-        if (SHT_DYNSYM == shdr.sh_type) {
-            /* This failure is too restrictive.  There is no reason why
-               the symbol table couldn't be called something else, but
-               there is a standard name, and chances are that if we don't
-               see it, there's something wrong.
-            */
-            size_t shstrndx;
-            FAILIF_LIBELF(elf_getshstrndx(elf, &shstrndx) < 0,
-                          elf_getshstrndx);
-            /* Now print the symbols. */
-            {
-                Elf_Data *symdata;
-                size_t elsize;
-                symdata = elf_getdata (scn, NULL); /* get the symbol data */
-                FAILIF_LIBELF(NULL == symdata, elf_getdata);
-                /* Get the number of section.  We need to compare agains this
-                   value for symbols that have special info in their section
-                   references */
-                size_t shnum;
-                FAILIF_LIBELF(elf_getshnum (elf, &shnum) < 0, elf_getshnum);
-                /* Retrieve the size of a symbol entry */
-                elsize = gelf_fsize(elf, ELF_T_SYM, 1, ehdr.e_version);
-
-                size_t index;
-                for (index = 0; index < symdata->d_size / elsize; index++) {
-                    GElf_Sym sym_mem;
-                    GElf_Sym *sym;
-                    /* Get the symbol. */
-                    sym = gelf_getsymshndx (symdata, NULL,
-                                            index, &sym_mem, NULL);
-                    FAILIF_LIBELF(sym == NULL, gelf_getsymshndx);
-                    /* Print the symbol. */
-                    char bind = '?';
-                    switch(ELF32_ST_BIND(sym->st_info))
-                    {
-                    case STB_LOCAL: bind = 'l'; break;
-                    case STB_GLOBAL: bind = 'g'; break;
-                    case STB_WEAK: bind = 'w'; break;
-                    default: break;
-                    }
-                    char type = '?';
-                    switch(ELF32_ST_TYPE(sym->st_info))
-                    {
-                    case STT_NOTYPE: /* Symbol type is unspecified */
-                        type = '?';
-                        break;
-                    case STT_OBJECT: /* Symbol is a data object */
-                        type = 'o';
-                        break;
-                    case STT_FUNC: /* Symbol is a code object */
-                        type = 'f';
-                        break;
-                    case STT_SECTION:/* Symbol associated with a section */
-                        type = 's';
-                        break;
-                    case STT_FILE: /* Symbol's name is file name */
-                        type = 'f';
-                        break;
-                    case STT_COMMON: /* Symbol is a common data object */
-                        type = 'c';
-                        break;
-                    case STT_TLS: /* Symbol is thread-local data object*/
-                        type = 't';
-                        break;
-                    }
-                    {
-                        int till_lineno;
-                        int lineno;
-                        const char *section_name = "(unknown)";
-                        FAILIF(sym->st_shndx == SHN_XINDEX,
-                               "Can't handle symbol's st_shndx == SHN_XINDEX!\n");
-                        if (sym->st_shndx != SHN_UNDEF &&
-                            sym->st_shndx < shnum) {
-                            Elf_Scn *symscn = elf_getscn(elf, sym->st_shndx);
-                            FAILIF_LIBELF(NULL == symscn, elf_getscn);
-                            GElf_Shdr symscn_shdr;
-                            FAILIF_LIBELF(NULL == gelf_getshdr(symscn,
-                                                               &symscn_shdr),
-                                          gelf_getshdr);
-                            section_name = elf_strptr(elf, shstrndx,
-                                                      symscn_shdr.sh_name);
-                        }
-                        else if (sym->st_shndx == SHN_ABS) {
-                            section_name = "SHN_ABS";
-                        }
-                        else if (sym->st_shndx == SHN_COMMON) {
-                            section_name = "SHN_COMMON";
-                        }
-                        else if (sym->st_shndx == SHN_UNDEF) {
-                            section_name = "(undefined)";
-                        }
-                        /* value size binding type section symname */
-                        PRINT("%-15s %8zd: %08llx %08llx %c%c %5d %n%s%n",
-                              file,
-                              index,
-                              sym->st_value, sym->st_size, bind, type,
-                              sym->st_shndx,
-                              &till_lineno,
-                              section_name,
-                              &lineno);
-                        lineno -= till_lineno;
-                        /* Create padding for section names of 15 chars.
-                           This limit is somewhat arbitratry. */
-                        while (lineno++ < 15) PRINT(" ");
-                        PRINT("(%d) %s\n",
-                              sym->st_name,
-                              elf_strptr(elf, shdr.sh_link, sym->st_name));
-                    }
-                }
-            }
-        } /* if (shdr.sh_type = SHT_DYNSYM) */
-    } /* while ((scn = elf_nextscn (elf, scn)) != NULL) */
-}
diff --git a/tools/soslim/prelink_info.c b/tools/soslim/prelink_info.c
deleted file mode 100644
index 81d5de3..0000000
--- a/tools/soslim/prelink_info.c
+++ /dev/null
@@ -1,109 +0,0 @@
-#ifdef SUPPORT_ANDROID_PRELINK_TAGS
-
-#include <sys/types.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-
-#include <prelink_info.h>
-#include <debug.h>
-#include <common.h>
-
-typedef struct {
-	uint32_t mmap_addr;
-	char tag[4]; /* 'P', 'R', 'E', ' ' */
-} __attribute__((packed)) prelink_info_t;
-
-static inline void set_prelink(long *prelink_addr, 
-							   int elf_little,
-							   prelink_info_t *info)
-{
-    FAILIF(sizeof(prelink_info_t) != 8, "Unexpected sizeof(prelink_info_t) == %zd!\n", sizeof(prelink_info_t));
-	if (prelink_addr) {
-		if (!(elf_little ^ is_host_little())) {
-			/* Same endianness */
-			*prelink_addr = info->mmap_addr;
-		}
-		else {
-			/* Different endianness */
-			*prelink_addr = switch_endianness(info->mmap_addr);
-		}
-	}
-}
-
-int check_prelinked(const char *fname, int elf_little, long *prelink_addr)
-{
-    FAILIF(sizeof(prelink_info_t) != 8, "Unexpected sizeof(prelink_info_t) == %zd!\n", sizeof(prelink_info_t));
-	int fd = open(fname, O_RDONLY);
-	FAILIF(fd < 0, "open(%s, O_RDONLY): %s (%d)!\n",
-		   fname, strerror(errno), errno);
-	off_t end = lseek(fd, 0, SEEK_END);
-#ifndef DEBUG
-	(void)end;
-#endif
-
-    int nr = sizeof(prelink_info_t);
-
-    off_t sz = lseek(fd, -nr, SEEK_CUR);
-	ASSERT((long)(end - sz) == (long)nr);
-	FAILIF(sz == (off_t)-1, 
-		   "lseek(%d, 0, SEEK_END): %s (%d)!\n", 
-		   fd, strerror(errno), errno);
-
-	prelink_info_t info;
-	ssize_t num_read = read(fd, &info, nr);
-	FAILIF(num_read < 0, 
-		   "read(%d, &info, sizeof(prelink_info_t)): %s (%d)!\n",
-		   fd, strerror(errno), errno);
-	FAILIF((size_t)num_read != sizeof(info),
-		   "read(%d, &info, sizeof(prelink_info_t)): did not read %zd bytes as "
-		   "expected (read %zd)!\n",
-		   fd, sizeof(info), (size_t)num_read);
-
-	int prelinked = 0;
-	if (!strncmp(info.tag, "PRE ", 4)) {
-		set_prelink(prelink_addr, elf_little, &info);
-		prelinked = 1;
-	}
-	FAILIF(close(fd) < 0, "close(%d): %s (%d)!\n", fd, strerror(errno), errno);
-	return prelinked;
-}
-
-void setup_prelink_info(const char *fname, int elf_little, long base)
-{
-    FAILIF(sizeof(prelink_info_t) != 8, "Unexpected sizeof(prelink_info_t) == %zd!\n", sizeof(prelink_info_t));
-    int fd = open(fname, O_WRONLY);
-    FAILIF(fd < 0, 
-           "open(%s, O_WRONLY): %s (%d)\n" ,
-           fname, strerror(errno), errno);
-    prelink_info_t info;
-    off_t sz = lseek(fd, 0, SEEK_END);
-    FAILIF(sz == (off_t)-1, 
-           "lseek(%d, 0, SEEK_END): %s (%d)!\n", 
-           fd, strerror(errno), errno);
-
-    if (!(elf_little ^ is_host_little())) {
-        /* Same endianness */
-        INFO("Host and ELF file [%s] have same endianness.\n", fname);
-        info.mmap_addr = base;
-    }
-    else {
-        /* Different endianness */
-        INFO("Host and ELF file [%s] have different endianness.\n", fname);
-		info.mmap_addr = switch_endianness(base);
-    }
-    strncpy(info.tag, "PRE ", 4);
-
-    ssize_t num_written = write(fd, &info, sizeof(info));
-    FAILIF(num_written < 0, 
-           "write(%d, &info, sizeof(info)): %s (%d)\n",
-           fd, strerror(errno), errno);
-    FAILIF(sizeof(info) != (size_t)num_written,
-           "Could not write %zd bytes (wrote only %zd bytes) as expected!\n",
-           sizeof(info), (size_t)num_written);
-    FAILIF(close(fd) < 0, "close(%d): %s (%d)!\n", fd, strerror(errno), errno);
-}
-
-#endif /*SUPPORT_ANDROID_PRELINK_TAGS*/
diff --git a/tools/soslim/prelink_info.h b/tools/soslim/prelink_info.h
deleted file mode 100644
index e2787cb..0000000
--- a/tools/soslim/prelink_info.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef PRELINK_INFO_H
-#define PRELINK_INFO_H
-#ifdef SUPPORT_ANDROID_PRELINK_TAGS
-
-int check_prelinked(const char *fname, int elf_little, long *prelink_addr);
-void setup_prelink_info(const char *fname, int elf_little, long base);
-
-#endif
-#endif/*PRELINK_INFO_H*/
diff --git a/tools/soslim/soslim.c b/tools/soslim/soslim.c
deleted file mode 100644
index 125e29e..0000000
--- a/tools/soslim/soslim.c
+++ /dev/null
@@ -1,528 +0,0 @@
-#include <stdio.h>
-//#include <common.h>
-#include <debug.h>
-#include <libelf.h>
-#include <libebl.h>
-#include <libebl_arm.h>
-#include <elf.h>
-#include <gelf.h>
-#include <string.h>
-#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#ifdef SUPPORT_ANDROID_PRELINK_TAGS
-#include <prelink_info.h>
-#endif
-
-#include <elfcopy.h>
-
-void clone_elf(Elf *elf, Elf *newelf,
-               const char *elf_name,
-               const char *newelf_name,
-               bool *sym_filter, int num_symbols,
-               int shady
-#ifdef SUPPORT_ANDROID_PRELINK_TAGS
-               , int *prelinked,
-               int *elf_little,
-               long *prelink_addr
-#endif
-               , bool rebuild_shstrtab,
-               bool strip_debug,
-               bool dry_run)
-{
-	GElf_Ehdr ehdr_mem, *ehdr; /* store ELF header of original library */
-	size_t shstrndx; /* section-strings-section index */
-	size_t shnum; /* number of sections in the original file */
-	/* string table for section headers in new file */
-	struct Ebl_Strtab *shst = NULL;
-    int dynamic_idx = -1; /* index in shdr_info[] of .dynamic section */
-    int dynsym_idx = -1; /* index in shdr_info[] of dynamic symbol table
-                            section */
-
-    unsigned int cnt;	  /* general-purpose counter */
-    /* This flag is true when at least one section is dropped or when the
-       relative order of sections has changed, so that section indices in
-       the resulting file will be different from those in the original. */
-    bool sections_dropped_or_rearranged;
-	Elf_Scn *scn; /* general-purpose section */
-	size_t idx;	  /* general-purporse section index */
-
-	shdr_info_t *shdr_info = NULL;
-    unsigned int shdr_info_len = 0;
-    GElf_Phdr *phdr_info = NULL;
-
-	/* Get the information from the old file. */
-	ehdr = gelf_getehdr (elf, &ehdr_mem);
-	FAILIF_LIBELF(NULL == ehdr, gelf_getehdr);
-
-	/* Create new program header for the elf file */
-	FAILIF(gelf_newehdr (newelf, gelf_getclass (elf)) == 0 ||
-		   (ehdr->e_type != ET_REL && gelf_newphdr (newelf,
-													ehdr->e_phnum) == 0),
-		   "Cannot create new file: %s", elf_errmsg (-1));
-
-#ifdef SUPPORT_ANDROID_PRELINK_TAGS
-    ASSERT(prelinked);
-    ASSERT(prelink_addr);
-    ASSERT(elf_little);
-    *elf_little = (ehdr->e_ident[EI_DATA] == ELFDATA2LSB);
-    *prelinked = check_prelinked(elf_name, *elf_little, prelink_addr);
-#endif
-
-    INFO("\n\nCALCULATING MODIFICATIONS\n\n");
-
-	/* Copy out the old program header: notice that if the ELF file does not
-	   have a program header, this loop won't execute.
-	*/
-	INFO("Copying ELF program header...\n");
-    phdr_info = (GElf_Phdr *)CALLOC(ehdr->e_phnum, sizeof(GElf_Phdr));
-	for (cnt = 0; cnt < ehdr->e_phnum; ++cnt) {
-		INFO("\tRetrieving entry %d\n", cnt);
-		FAILIF_LIBELF(NULL == gelf_getphdr(elf, cnt, phdr_info + cnt),
-                      gelf_getphdr);
-        /* -- we update the header at the end
-        FAILIF_LIBELF(gelf_update_phdr (newelf, cnt, phdr_info + cnt) == 0,
-                      gelf_update_phdr);
-        */
-	}
-
-    /* Get the section-header strings section.  This section contains the
-	   strings used to name the other sections. */
-	FAILIF_LIBELF(elf_getshstrndx(elf, &shstrndx) < 0, elf_getshstrndx);
-
-	/* Get the number of sections. */
-	FAILIF_LIBELF(elf_getshnum (elf, &shnum) < 0, elf_getshnum);
-	INFO("Original ELF file has %zd sections.\n", shnum);
-
-	/* Allocate the section-header-info buffer.  We allocate one more entry
-       for the section-strings section because we regenerate that one and
-       place it at the very end of the file.  Note that just because we create
-       an extra entry in the shdr_info array, it does not mean that we create
-       one more section the header.  We just mark the old section for removal
-       and create one as the last section.
-    */
-	INFO("Allocating section-header info structure (%zd) bytes...\n",
-		 shnum*sizeof (shdr_info_t));
-    shdr_info_len = rebuild_shstrtab ? shnum + 1 : shnum;
-	shdr_info = (shdr_info_t *)CALLOC(shdr_info_len, sizeof (shdr_info_t));
-
-	/* Iterate over all the sections and initialize the internal section-info
-	   array...
-	*/
-	INFO("Initializing section-header info structure...\n");
-	/* Gather information about the sections in this file. */
-	scn = NULL;
-	cnt = 1;
-	while ((scn = elf_nextscn (elf, scn)) != NULL) {
-		ASSERT(elf_ndxscn(scn) == cnt);
-		shdr_info[cnt].scn = scn;
-		FAILIF_LIBELF(NULL == gelf_getshdr(scn, &shdr_info[cnt].shdr),
-					  gelf_getshdr);
-
-		/* Get the name of the section. */
-		shdr_info[cnt].name = elf_strptr (elf, shstrndx,
-										  shdr_info[cnt].shdr.sh_name);
-
-		INFO("\tname: %s\n", shdr_info[cnt].name);
-		FAILIF(shdr_info[cnt].name == NULL,
-			   "Malformed file: section %d name is null\n",
-			   cnt);
-
-		/* Mark them as present but not yet investigated.  By "investigating"
-		   sections, we mean that we check to see if by stripping other
-		   sections, the sections under investigation will be compromised.  For
-		   example, if we are removing a section of code, then we want to make
-		   sure that the symbol table does not contain symbols that refer to
-		   this code, so we investigate the symbol table.  If we do find such
-		   symbols, we will not strip the code section.
-		*/
-		shdr_info[cnt].idx = 1;
-
-		/* Remember the shdr.sh_link value.  We need to remember this value
-		   for those sections that refer to other sections.  For example,
-		   we need to remember it for relocation-entry sections, because if
-		   we modify the symbol table that a relocation-entry section is
-		   relative to, then we need to patch the relocation section.  By the
-		   time we get to deciding whether we need to patch the relocation
-		   section, we will have overwritten its header's sh_link field with
-		   a new value.
-		*/
-		shdr_info[cnt].old_shdr = shdr_info[cnt].shdr;
-        INFO("\t\toriginal sh_link: %08d\n", shdr_info[cnt].old_shdr.sh_link);
-        INFO("\t\toriginal sh_addr: %lld\n", shdr_info[cnt].old_shdr.sh_addr);
-        INFO("\t\toriginal sh_offset: %lld\n",
-             shdr_info[cnt].old_shdr.sh_offset);
-        INFO("\t\toriginal sh_size: %lld\n", shdr_info[cnt].old_shdr.sh_size);
-
-        if (shdr_info[cnt].shdr.sh_type == SHT_DYNAMIC) {
-            INFO("\t\tthis is the SHT_DYNAMIC section [%s] at index %d\n",
-                 shdr_info[cnt].name,
-                 cnt);
-            dynamic_idx = cnt;
-        }
-        else if (shdr_info[cnt].shdr.sh_type == SHT_DYNSYM) {
-            INFO("\t\tthis is the SHT_DYNSYM section [%s] at index %d\n",
-                 shdr_info[cnt].name,
-                 cnt);
-            dynsym_idx = cnt;
-        }
-
-		FAILIF(shdr_info[cnt].shdr.sh_type == SHT_SYMTAB_SHNDX,
-			   "Cannot handle sh_type SHT_SYMTAB_SHNDX!\n");
-		FAILIF(shdr_info[cnt].shdr.sh_type == SHT_GROUP,
-			   "Cannot handle sh_type SHT_GROUP!\n");
-		FAILIF(shdr_info[cnt].shdr.sh_type == SHT_GNU_versym,
-			   "Cannot handle sh_type SHT_GNU_versym!\n");
-
-		/* Increment the counter. */
-		++cnt;
-	} /* while */
-
-	/* Get the EBL handling. */
-	Ebl *ebl = ebl_openbackend (elf);
-	FAILIF_LIBELF(NULL == ebl, ebl_openbackend);
-    FAILIF_LIBELF(0 != arm_init(elf, ehdr->e_machine, ebl, sizeof(Ebl)),
-                  arm_init);
-
-    if (strip_debug) {
-
-      /* This will actually strip more than just sections.  It will strip
-         anything not essential to running the image.
-      */
-
-      INFO("Finding debug sections to strip.\n");
-
-      /* Now determine which sections can go away.  The general rule is that
-         all sections which are not used at runtime are stripped out.  But
-         there are a few exceptions:
-
-         - special sections named ".comment" and ".note" are kept
-         - OS or architecture specific sections are kept since we might not
-		 know how to handle them
-         - if a section is referred to from a section which is not removed
-		 in the sh_link or sh_info element it cannot be removed either
-      */
-      for (cnt = 1; cnt < shnum; ++cnt) {
-		/* Check whether the section can be removed.  */
-		if (SECTION_STRIP_P (ebl, elf, ehdr, &shdr_info[cnt].shdr,
-							 shdr_info[cnt].name,
-							 1,	 /* remove .comment sections */
-							 1	 /* remove all debug sections */) ||
-            /* The macro above is broken--check for .comment explicitly */
-            !strcmp(".comment", shdr_info[cnt].name)
-#ifdef ARM_SPECIFIC_HACKS
-            ||
-            /* We ignore this section, that's why we can remove it. */
-            !strcmp(".stack", shdr_info[cnt].name)
-#endif
-            )
-        {
-          /* For now assume this section will be removed.  */
-          INFO("Section [%s] will be stripped from image.\n",
-               shdr_info[cnt].name);
-          shdr_info[cnt].idx = 0;
-		}
-#ifdef STRIP_STATIC_SYMBOLS
-		else if (shdr_info[cnt].shdr.sh_type == SHT_SYMTAB) {
-          /* Mark the static symbol table for removal */
-          INFO("Section [%s] (static symbol table) will be stripped from image.\n",
-               shdr_info[cnt].name);
-          shdr_info[cnt].idx = 0;
-          if (shdr_info[shdr_info[cnt].shdr.sh_link].shdr.sh_type ==
-              SHT_STRTAB)
-          {
-            /* Mark the symbol table's string table for removal. */
-            INFO("Section [%s] (static symbol-string table) will be stripped from image.\n",
-                 shdr_info[shdr_info[cnt].shdr.sh_link].name);
-            shdr_info[shdr_info[cnt].shdr.sh_link].idx = 0;
-          }
-          else {
-            ERROR("Expecting the sh_link field of a symbol table to point to"
-                  " associated symbol-strings table!  This is not mandated by"
-                  " the standard, but is a common practice and the only way "
-                  " to know for sure which strings table corresponds to which"
-                  " symbol table!\n");
-          }
-		}
-#endif
-      }
-
-      /* Mark the SHT_NULL section as handled. */
-      shdr_info[0].idx = 2;
-
-      /* Handle exceptions: section groups and cross-references.  We might have
-         to repeat this a few times since the resetting of the flag might
-         propagate.
-      */
-      int exceptions_pass = 0;
-      bool changes;
-      do {
-        changes = false;
-		INFO("\nHandling exceptions, pass %d\n\n", exceptions_pass++);
-		for (cnt = 1; cnt < shnum; ++cnt) {
-          if (shdr_info[cnt].idx == 0) {
-            /* If a relocation section is marked as being removed but the
-               section it is relocating is not, then do not remove the
-               relocation section.
-            */
-            if ((shdr_info[cnt].shdr.sh_type == SHT_REL
-                 || shdr_info[cnt].shdr.sh_type == SHT_RELA)
-                && shdr_info[shdr_info[cnt].shdr.sh_info].idx != 0) {
-              PRINT("\tSection [%s] will not be removed because the "
-                    "section it is relocating (%s) stays.\n",
-                    shdr_info[cnt].name,
-                    shdr_info[shdr_info[cnt].shdr.sh_info].name);
-            }
-          }
-          if (shdr_info[cnt].idx == 1) {
-            INFO("Processing section [%s]...\n", shdr_info[cnt].name);
-
-            /* The content of symbol tables we don't remove must not
-               reference any section which we do remove.  Otherwise
-               we cannot remove the referred section.
-            */
-            if (shdr_info[cnt].shdr.sh_type == SHT_DYNSYM ||
-                shdr_info[cnt].shdr.sh_type == SHT_SYMTAB)
-            {
-              Elf_Data *symdata;
-              size_t elsize;
-
-              INFO("\tSection [%s] is a symbol table that's not being"
-                   " removed.\n\tChecking to make sure that no symbols"
-                   " refer to sections that are being removed.\n",
-                   shdr_info[cnt].name);
-
-              /* Make sure the data is loaded.  */
-              symdata = elf_getdata (shdr_info[cnt].scn, NULL);
-              FAILIF_LIBELF(NULL == symdata, elf_getdata);
-
-              /* Go through all symbols and make sure the section they
-                 reference is not removed.  */
-              elsize = gelf_fsize (elf, ELF_T_SYM, 1, ehdr->e_version);
-
-              /* Check the length of the dynamic-symbol filter. */
-              FAILIF(sym_filter != NULL &&
-                     (size_t)num_symbols != symdata->d_size / elsize,
-                     "Length of dynsym filter (%d) must equal the number"
-                     " of dynamic symbols (%zd)!\n",
-                     num_symbols,
-                     symdata->d_size / elsize);
-
-              size_t inner;
-              for (inner = 0;
-                   inner < symdata->d_size / elsize;
-                   ++inner)
-              {
-                GElf_Sym sym_mem;
-                GElf_Sym *sym;
-                size_t scnidx;
-
-                sym = gelf_getsymshndx (symdata, NULL,
-                                        inner, &sym_mem, NULL);
-                FAILIF_LIBELF(sym == NULL, gelf_getsymshndx);
-
-                scnidx = sym->st_shndx;
-                FAILIF(scnidx == SHN_XINDEX,
-                       "Can't handle SHN_XINDEX!\n");
-                if (scnidx == SHN_UNDEF ||
-                    scnidx >= shnum ||
-                    (scnidx >= SHN_LORESERVE &&
-                     scnidx <= SHN_HIRESERVE) ||
-                    GELF_ST_TYPE (sym->st_info) == STT_SECTION)
-                {
-                  continue;
-                }
-
-                /* If the symbol is going to be thrown and it is a
-                   global or weak symbol that is defined (not imported),
-                   then continue.  Since the symbol is going away, we
-                   do not care  whether it refers to a section that is
-                   also going away.
-                */
-                if (sym_filter && !sym_filter[inner])
-                {
-                  bool global_or_weak =
-                      ELF32_ST_BIND(sym->st_info) == STB_GLOBAL ||
-                      ELF32_ST_BIND(sym->st_info) == STB_WEAK;
-                  if (!global_or_weak && sym->st_shndx != SHN_UNDEF)
-                    continue;
-                }
-
-                /* -- far too much output
-                   INFO("\t\t\tSymbol [%s] (%d)\n",
-                   elf_strptr(elf,
-                   shdr_info[cnt].shdr.sh_link,
-                   sym->st_name),
-                   shdr_info[cnt].shdr.sh_info);
-                */
-
-                if (shdr_info[scnidx].idx == 0)
-                {
-                  PRINT("\t\t\tSymbol [%s] refers to section [%s], "
-                        "which is being removed.  Will keep that "
-                        "section.\n",
-                        elf_strptr(elf,
-                                   shdr_info[cnt].shdr.sh_link,
-                                   sym->st_name),
-                        shdr_info[scnidx].name);
-                  /* Mark this section as used.  */
-                  shdr_info[scnidx].idx = 1;
-                  changes |= scnidx < cnt;
-                }
-              } /* for each symbol */
-            } /* section type is SHT_DYNSYM or SHT_SYMTAB */
-            /* Cross referencing happens:
-			   - for the cases the ELF specification says.  That are
-			   + SHT_DYNAMIC in sh_link to string table
-			   + SHT_HASH in sh_link to symbol table
-			   + SHT_REL and SHT_RELA in sh_link to symbol table
-			   + SHT_SYMTAB and SHT_DYNSYM in sh_link to string table
-			   + SHT_GROUP in sh_link to symbol table
-			   + SHT_SYMTAB_SHNDX in sh_link to symbol table
-			   Other (OS or architecture-specific) sections might as
-			   well use this field so we process it unconditionally.
-			   - references inside section groups
-			   - specially marked references in sh_info if the SHF_INFO_LINK
-			   flag is set
-            */
-
-            if (shdr_info[shdr_info[cnt].shdr.sh_link].idx == 0) {
-              shdr_info[shdr_info[cnt].shdr.sh_link].idx = 1;
-              changes |= shdr_info[cnt].shdr.sh_link < cnt;
-            }
-
-            /* Handle references through sh_info.  */
-            if (SH_INFO_LINK_P (&shdr_info[cnt].shdr) &&
-                shdr_info[shdr_info[cnt].shdr.sh_info].idx == 0) {
-              PRINT("\tSection [%s] links to section [%s], which was "
-                    "marked for removal--it will not be removed.\n",
-                    shdr_info[cnt].name,
-                    shdr_info[shdr_info[cnt].shdr.sh_info].name);
-
-              shdr_info[shdr_info[cnt].shdr.sh_info].idx = 1;
-              changes |= shdr_info[cnt].shdr.sh_info < cnt;
-            }
-
-            /* Mark the section as investigated.  */
-            shdr_info[cnt].idx = 2;
-          } /* if (shdr_info[cnt].idx == 1) */
-		} /* for (cnt = 1; cnt < shnum; ++cnt) */
-      } while (changes);
-    }
-    else {
-      INFO("Not stripping sections.\n");
-      /* Mark the SHT_NULL section as handled. */
-      shdr_info[0].idx = 2;
-    }
-
-	/* Mark the section header string table as unused, we will create
-	   a new one as the very last section in the new ELF file.
-	*/
-	shdr_info[shstrndx].idx = rebuild_shstrtab ? 0 : 2;
-
-	/* We need a string table for the section headers. */
-	FAILIF_LIBELF((shst = ebl_strtabinit (1	/* null-terminated */)) == NULL,
-				  ebl_strtabinit);
-
-	/* Assign new section numbers. */
-	INFO("Creating new sections...\n");
-	//shdr_info[0].idx = 0;
-	for (cnt = idx = 1; cnt < shnum; ++cnt) {
-		if (shdr_info[cnt].idx > 0) {
-			shdr_info[cnt].idx = idx++;
-
-			/* Create a new section. */
-			FAILIF_LIBELF((shdr_info[cnt].newscn =
-						   elf_newscn(newelf)) == NULL, elf_newscn);
-			ASSERT(elf_ndxscn (shdr_info[cnt].newscn) == shdr_info[cnt].idx);
-
-			/* Add this name to the section header string table. */
-			shdr_info[cnt].se = ebl_strtabadd (shst, shdr_info[cnt].name, 0);
-
-			INFO("\tsection [%s]  (old offset %lld, old size %lld) will have index %d "
-				 "(was %zd).\n",
-				 shdr_info[cnt].name,
-				 shdr_info[cnt].old_shdr.sh_offset,
-				 shdr_info[cnt].old_shdr.sh_size,
-				 shdr_info[cnt].idx,
-				 elf_ndxscn(shdr_info[cnt].scn));
-		} else {
-			INFO("\tIgnoring section [%s] (offset %lld, size %lld, index %zd), "
-				 "it will be discarded.\n",
-				 shdr_info[cnt].name,
-				 shdr_info[cnt].shdr.sh_offset,
-				 shdr_info[cnt].shdr.sh_size,
-				 elf_ndxscn(shdr_info[cnt].scn));
-		}
-	} /* for */
-
-    sections_dropped_or_rearranged = idx != cnt;
-
-    Elf_Data *shstrtab_data = NULL;
-
-#if 0
-    /* Fail if sections are being dropped or rearranged (except for moving shstrtab) or the
-       symbol filter is not empty, AND the file is an executable.
-    */
-    FAILIF(((idx != cnt && !(cnt - idx == 1 && rebuild_shstrtab)) || sym_filter != NULL) &&
-           ehdr->e_type != ET_DYN,
-           "You may not rearrange sections or strip symbols on an executable file!\n");
-#endif
-
-    INFO("\n\nADJUSTING ELF FILE\n\n");
-
-    adjust_elf(elf, elf_name,
-               newelf, newelf_name,
-               ebl,
-               ehdr, /* store ELF header of original library */
-               sym_filter, num_symbols,
-               shdr_info, shdr_info_len,
-               phdr_info,
-               idx, /* highest_scn_num */
-               shnum,
-               shstrndx,
-               shst,
-               sections_dropped_or_rearranged,
-               dynamic_idx, /* index in shdr_info[] of .dynamic section */
-               dynsym_idx, /* index in shdr_info[] of dynamic symbol table */
-               shady,
-               &shstrtab_data,
-               ehdr->e_type == ET_DYN, /* adjust section ofsets only when the file is a shared library */
-               rebuild_shstrtab);
-
-    /* We have everything from the old file. */
-	FAILIF_LIBELF(elf_cntl(elf, ELF_C_FDDONE) != 0, elf_cntl);
-
-	/* The ELF library better follows our layout when this is not a
-	   relocatable object file. */
-	elf_flagelf (newelf,
-				 ELF_C_SET,
-				 (ehdr->e_type != ET_REL ? ELF_F_LAYOUT : 0));
-
-	/* Finally write the file. */
-    FAILIF_LIBELF(!dry_run && elf_update(newelf, ELF_C_WRITE) == -1, elf_update);
-
-	if (shdr_info != NULL) {
-		/* For some sections we might have created an table to map symbol
-           table indices. */
-       for (cnt = 1; cnt < shdr_info_len; ++cnt) {
-            FREEIF(shdr_info[cnt].newsymidx);
-            FREEIF(shdr_info[cnt].symse);
-            if(shdr_info[cnt].dynsymst != NULL)
-                ebl_strtabfree (shdr_info[cnt].dynsymst);
-        }
-		/* Free the memory. */
-		FREE (shdr_info);
-	}
-    FREEIF(phdr_info);
-
-    ebl_closebackend(ebl);
-
-	/* Free other resources. */
-	if (shst != NULL) ebl_strtabfree (shst);
-    if (shstrtab_data != NULL)
-        FREEIF(shstrtab_data->d_buf);
-}
diff --git a/tools/soslim/soslim.h b/tools/soslim/soslim.h
deleted file mode 100644
index dfcb085..0000000
--- a/tools/soslim/soslim.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef ELFCOPY_H
-#define ELFCOPY_H
-
-#include <libelf.h>
-#include <libebl.h>
-#include <elf.h>
-#include <gelf.h>
-
-/*
-symbol_filter:
-	On input: symbol_filter[i] indicates whether to keep a symbol (1) or to
-	          remove it from the symbol table.
-    On output: symbol_filter[i] indicates whether a symbol was removed (0) or
-	           kept (1) in the symbol table.
-*/
-
-void clone_elf(Elf *elf, Elf *newelf,
-			   const char *elf_name,
-			   const char *newelf_name,
-			   bool *symbol_filter,
-			   int num_symbols,
-               int shady
-#ifdef SUPPORT_ANDROID_PRELINK_TAGS
-			   , int *prelinked,
-			   int *elf_little,
-			   long *prelink_addr
-#endif
-               , bool rebuild_shstrtab,
-               bool strip_debug,
-               bool dry_run);
-
-#endif/*ELFCOPY_H*/
diff --git a/tools/soslim/symfilter.c b/tools/soslim/symfilter.c
deleted file mode 100644
index b59e68a..0000000
--- a/tools/soslim/symfilter.c
+++ /dev/null
@@ -1,246 +0,0 @@
-#include <debug.h>
-#include <common.h>
-#include <symfilter.h>
-#include <hash.h>
-#include <stdio.h>
-#include <errno.h>
-#include <string.h>
-#include <unistd.h>
-#include <libelf.h>
-#include <gelf.h>
-#include <ctype.h>
-
-#include <sys/mman.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-
-static int match_hash_table_section(Elf *elf, Elf_Scn *sect, void *data);
-static int match_dynsym_section(Elf *elf, Elf_Scn *sect, void *data);
-
-void build_symfilter(const char *name, Elf *elf, symfilter_t *filter, 
-                     off_t fsize)
-{
-    char *line = NULL;
-    symfilter_list_t *symbol;
-
-    FAILIF(NULL == name,
-           "You must provide a list of symbols to filter on!\n");
-
-    filter->num_symbols = 0;
-    filter->total_name_length = 0;
-
-    /* Open the file. */
-    INFO("Opening symbol-filter file %s...\n", name);
-    filter->fd = open(name, O_RDONLY);
-    FAILIF(filter->fd < 0, "open(%s): %s (%d)\n",
-           name, 
-           strerror(errno),
-           errno);
-
-    INFO("Symbol-filter file %s is %zd bytes long...\n",
-         name,
-         (size_t)fsize);
-    filter->fsize = fsize;
-
-    /* mmap the symbols file */
-    filter->mmap = mmap(NULL, fsize, 
-                        PROT_READ | PROT_WRITE, MAP_PRIVATE, 
-                        filter->fd, 0);
-    FAILIF(MAP_FAILED == filter->mmap, 
-           "mmap(NULL, %zd, PROT_READ, MAP_PRIVATE, %d, 0): %s (%d)\n",
-           (size_t)fsize,
-           filter->fd,
-           strerror(errno),
-           errno);
-    INFO("Memory-mapped symbol-filter file at %p\n", filter->mmap);
-
-    /* Make sure that the ELF file has a hash table.  We will use the hash 
-       table to look up symbols quickly.  If the library does not have a hash-
-       table section, we can still do a linear scan, but the code for that is
-       not written, as practically every shared library has a hash table.
-    */
-
-    filter->symtab.sect = NULL;
-    map_over_sections(elf, match_dynsym_section, filter);
-    FAILIF(NULL == filter->symtab.sect, 
-           "There is no dynamic-symbol table in this library.\n");
-    filter->hash.sect = NULL;
-    map_over_sections(elf, match_hash_table_section, filter);
-    FAILIF(NULL == filter->hash.sect, 
-           "There is no hash table in this library.\n");
-    INFO("Hash table size 0x%lx, data size 0x%lx.\n",
-         (unsigned long)filter->hash.hdr->sh_size,
-         (unsigned long)filter->hash.data->d_size);
-
-    INFO("Hash table file offset: 0x%x\n", filter->hash.hdr->sh_offset);
-
-    GElf_Ehdr *ehdr, ehdr_mem;
-    ehdr = gelf_getehdr(elf, &ehdr_mem);
-    size_t symsize = gelf_fsize (elf, ELF_T_SYM, 1, ehdr->e_version);
-    ASSERT(symsize);
-    filter->num_symbols_to_keep = filter->symtab.data->d_size / symsize;
-    filter->symbols_to_keep = (bool *)CALLOC(filter->num_symbols_to_keep, 
-                                             sizeof(bool));
-
-    /* Build the symbol-name chain. */
-    INFO("Building symbol list...\n");
-    
-    line = (char *)filter->mmap;
-
-    filter->symbols = NULL;
-#define NOT_DONE ((off_t)(line - (char *)filter->mmap) < fsize)
-    do {
-        char *name = line;
-
-        /* Advance to the next line.  We seek out spaces or new lines.  At the
-           first space or newline character we find, we place a '\0', and 
-           continue till we've consumed the line.  For new lines, we scan both
-           '\r' and '\n'.  For spaces, we look for ' ', '\t', and '\f'
-        */
-
-        while (NOT_DONE && !isspace(*line)) line++;
-        if (likely(NOT_DONE)) {
-            *line++ = '\0';
-            if (line - name > 1) {
-                /* Add the entry to the symbol-filter list */
-                symbol = (symfilter_list_t *)MALLOC(sizeof(symfilter_list_t));
-                symbol->next = filter->symbols;
-                symbol->name = name;
-                filter->symbols = symbol;
-
-#if 0 
-                /* SLOW!  For debugging only! */
-                {
-                    size_t idx;
-                    size_t elsize = gelf_fsize(elf, ELF_T_SYM, 1, 
-                                               ehdr->e_version);
-                    symbol->index = SHN_UNDEF;
-                    for (idx = 0; idx < filter->symtab.data->d_size / elsize;
-                         idx++) {
-                        GElf_Sym sym_mem;
-                        GElf_Sym *sym;
-                        const char *symname;
-                        sym = gelf_getsymshndx (filter->symtab.data, NULL, 
-                                                idx, &sym_mem, NULL);
-                        ASSERT(sym);
-
-                        symname = elf_strptr(elf, 
-                                             filter->symtab.hdr->sh_link,
-                                             sym->st_name);
-                        if(!strcmp(symname, symbol->name)) {
-                            symbol->index = idx;
-                            break;
-                        }
-                    }
-                }
-#else
-                /* Look up the symbol in the ELF file and associate it with the
-                   entry in the filter. */
-                symbol->index = hash_lookup(elf,
-                                            &filter->hash,
-                                            &filter->symtab,
-                                            symbol->name,
-                                            &symbol->symbol);
-#endif                                            
-                symbol->len = line - name - 1;
-                ASSERT(symbol->len == strlen(symbol->name));
-
-                /* If we didn't find the symbol, then it's not in the library. 
-                 */
-
-                if(STN_UNDEF == symbol->index) {
-                    PRINT("%s: symbol was not found!\n", symbol->name);
-                }
-                else {
-                    /* If we found the symbol but it's an undefined symbol, then
-                       it's not in the library as well. */
-                    GElf_Sym sym_mem;
-                    GElf_Sym *sym;
-                    sym = gelf_getsymshndx (filter->symtab.data, NULL, 
-                                            symbol->index, &sym_mem, NULL);
-                    FAILIF_LIBELF(NULL == sym, gelf_getsymshndx);
-                    /* Make sure the hash lookup worked. */
-                    ASSERT(!strcmp(elf_strptr(elf, 
-                                              filter->symtab.hdr->sh_link,
-                                              sym->st_name),
-                                   symbol->name));
-                    if (sym->st_shndx == SHN_UNDEF) {
-                        PRINT("%s: symbol was not found (undefined)!\n", symbol->name);
-                    }
-                    else {
-                        filter->num_symbols++;
-                        /* Total count includes null terminators */
-                        filter->total_name_length += symbol->len + 1; 
-
-                        /* Set the flag in the symbols_to_keep[] array.  This indicates
-                           to function copy_elf() that we want to keep the symbol.
-                        */
-                        filter->symbols_to_keep[symbol->index] = true;
-                        INFO("FILTER-SYMBOL: [%s] [%d bytes]\n", 
-                             symbol->name, 
-                             symbol->len);
-                    }
-                }
-            }
-        }
-    } while (NOT_DONE);
-#undef NOT_DONE
-}
-
-void destroy_symfilter(symfilter_t *filter)
-{
-    symfilter_list_t *old;
-    INFO("Destroying symbol list...\n");
-    while ((old = filter->symbols)) {
-        filter->symbols = old->next;
-        FREE(old);
-    }
-    munmap(filter->mmap, filter->fsize);
-    close(filter->fd);
-}
-
-static int match_hash_table_section(Elf *elf, Elf_Scn *sect, void *data)
-{
-    (void)elf; // unused argument
-
-    symfilter_t *filter = (symfilter_t *)data;
-    Elf32_Shdr *shdr;
-
-    ASSERT(filter);
-    ASSERT(sect);
-    shdr = elf32_getshdr(sect);
-
-    /* The section must be marked both as a SHT_HASH, and it's sh_link field 
-       must contain the index of our symbol table (per ELF-file spec).
-    */
-    if (shdr->sh_type == SHT_HASH)
-    {
-        FAILIF(filter->hash.sect != NULL, 
-               "There is more than one hash table!\n");
-        get_section_info(sect, &filter->hash);
-    }
-
-    return 0; /* keep looking */
-}
-
-static int match_dynsym_section(Elf *elf, Elf_Scn *sect, void *data)
-{
-    (void)elf; // unused argument
-
-    symfilter_t *filter = (symfilter_t *)data;
-    Elf32_Shdr *shdr;
-
-    ASSERT(filter);
-    ASSERT(sect);
-    shdr = elf32_getshdr(sect);
-
-    if (shdr->sh_type == SHT_DYNSYM)
-    {
-        FAILIF(filter->symtab.sect != NULL, 
-               "There is more than one dynamic symbol table!\n");
-        get_section_info(sect, &filter->symtab);
-    }
-
-    return 0; /* keep looking */
-}
diff --git a/tools/soslim/symfilter.h b/tools/soslim/symfilter.h
deleted file mode 100644
index f73fd50..0000000
--- a/tools/soslim/symfilter.h
+++ /dev/null
@@ -1,50 +0,0 @@
-#ifndef SYMFILTER_H
-#define SYMFILTER_H
-
-/* This file describes the interface for parsing the list of symbols. Currently,
-   this is just a text file with each symbol on a separate line.  We build an
-   in-memory linked list of symbols out of this image.
-*/
-
-#include <stdio.h>
-#include <libelf.h>
-#include <gelf.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <libebl.h> /* defines bool */
-
-typedef struct symfilter_list_t symfilter_list_t;
-struct symfilter_list_t {
-    symfilter_list_t *next;
-    const char *name;
-    unsigned int len; /* strlen(name) */
-    Elf32_Word index;
-    GElf_Sym symbol;
-};
-
-typedef struct symfilter_t {
-
-    int fd; /* symbol-filter-file descriptor */
-    off_t fsize; /* size of file */
-    void *mmap; /* symbol-fiter-file memory mapping */
-
-    section_info_t symtab;
-    section_info_t hash;
-    symfilter_list_t *symbols;
-
-    /* The total number of symbols in the symfilter. */
-    unsigned int num_symbols;
-    /* The total number of bytes occupied by the names of the symbols, including
-       the terminating null characters.
-    */
-    unsigned int total_name_length;
-
-    bool *symbols_to_keep;
-    /* must be the same as the number of symbols in the dynamic table! */
-    int num_symbols_to_keep;
-} symfilter_t;
-
-void build_symfilter(const char *name, Elf *elf, symfilter_t *filter, off_t);
-void destroy_symfilter(symfilter_t *);
-
-#endif/*SYMFILTER_H*/