Merge "Show annotation information for fields, enums, etc. and in the class list" into lmp-dev
diff --git a/core/Makefile b/core/Makefile
index d39ac9c..11ae7f5 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -1220,12 +1220,6 @@
 endif # BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
 
 # -----------------------------------------------------------------
-# bring in the installer image generation defines if necessary
-ifeq ($(TARGET_USE_DISKINSTALLER),true)
-include bootable/diskinstaller/config.mk
-endif
-
-# -----------------------------------------------------------------
 # host tools needed to build dist and OTA packages
 
 DISTTOOLS :=  $(HOST_OUT_EXECUTABLES)/minigzip \
diff --git a/core/product.mk b/core/product.mk
index 90d5851..0075acd 100644
--- a/core/product.mk
+++ b/core/product.mk
@@ -91,6 +91,7 @@
     PRODUCT_SDK_ADDON_COPY_FILES \
     PRODUCT_SDK_ADDON_COPY_MODULES \
     PRODUCT_SDK_ADDON_DOC_MODULES \
+    PRODUCT_SDK_ADDON_SYS_IMG_SOURCE_PROP \
     PRODUCT_DEFAULT_WIFI_CHANNELS \
     PRODUCT_DEFAULT_DEV_CERTIFICATE \
     PRODUCT_RESTRICT_VENDOR_FILES \
diff --git a/core/tasks/boot_jars_package_check.mk b/core/tasks/boot_jars_package_check.mk
new file mode 100644
index 0000000..188c267
--- /dev/null
+++ b/core/tasks/boot_jars_package_check.mk
@@ -0,0 +1,46 @@
+# Copyright (C) 2014 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.
+
+#
+# Rules to check if classes in the boot jars are from the whitelisted packages.
+#
+
+ifneq ($(SKIP_BOOT_JARS_CHECK),true)
+ifneq ($(TARGET_BUILD_PDK),true)
+ifdef PRODUCT_BOOT_JARS
+
+intermediates := $(call intermediates-dir-for, PACKAGING, boot-jars-package-check,,COMMON)
+stamp := $(intermediates)/stamp
+built_boot_jars := $(foreach j, $(PRODUCT_BOOT_JARS), \
+  $(call intermediates-dir-for, JAVA_LIBRARIES, $(j),,COMMON)/classes.jar)
+script := build/core/tasks/check_boot_jars/check_boot_jars.py
+whitelist_file := build/core/tasks/check_boot_jars/package_whitelist.txt
+
+$(stamp): PRIVATE_BOOT_JARS := $(built_boot_jars)
+$(stamp): PRIVATE_SCRIPT := $(script)
+$(stamp): PRIVATE_WHITELIST := $(whitelist_file)
+$(stamp) : $(built_boot_jars) $(script) $(whitelist_file)
+	@echo "Check package name for $(PRIVATE_BOOT_JARS)"
+	$(hide) $(PRIVATE_SCRIPT) $(PRIVATE_WHITELIST) $(PRIVATE_BOOT_JARS)
+	$(hide) mkdir -p $(dir $@) && touch $@
+
+.PHONY: check-boot-jars
+check-boot-jars : $(stamp)
+
+# Run check-boot-jars by default
+droidcore : check-boot-jars
+
+endif  # PRODUCT_BOOT_JARS
+endif  # TARGET_BUILD_PDK not true
+endif  # SKIP_BOOT_JARS_CHECK not true
diff --git a/core/tasks/check_boot_jars/check_boot_jars.py b/core/tasks/check_boot_jars/check_boot_jars.py
new file mode 100755
index 0000000..89d9ee8
--- /dev/null
+++ b/core/tasks/check_boot_jars/check_boot_jars.py
@@ -0,0 +1,83 @@
+#!/usr/bin/env python
+
+"""
+Check boot jars.
+
+Usage: check_boot_jars.py <package_whitelist_file> <jar1> <jar2> ...
+"""
+import logging
+import os.path
+import re
+import subprocess
+import sys
+
+
+# The compiled whitelist RE.
+whitelist_re = None
+
+
+def LoadWhitelist(filename):
+  """ Load and compile whitelist regular expressions from filename.
+  """
+  lines = []
+  with open(filename, 'r') as f:
+    for line in f:
+      line = line.strip()
+      if not line or line.startswith('#'):
+        continue
+      lines.append(line)
+  combined_re = r'^(%s)$' % '|'.join(lines)
+  global whitelist_re
+  try:
+    whitelist_re = re.compile(combined_re)
+  except re.error:
+    logging.exception(
+        'Cannot compile package whitelist regular expression: %r',
+        combined_re)
+    whitelist_re = None
+    return False
+  return True
+
+
+def CheckJar(jar):
+  """Check a jar file.
+  """
+  # Get the list of files inside the jar file.
+  p = subprocess.Popen(args='jar tf %s' % jar,
+      stdout=subprocess.PIPE, shell=True)
+  stdout, _ = p.communicate()
+  if p.returncode != 0:
+    return False
+  items = stdout.split()
+  for f in items:
+    if f.endswith('.class'):
+      package_name = os.path.dirname(f)
+      package_name = package_name.replace('/', '.')
+      # Skip class without a package name
+      if package_name and not whitelist_re.match(package_name):
+        print >> sys.stderr, ('Error: %s: unknown package name of class file %s'
+                              % (jar, f))
+        return False
+  return True
+
+
+def main(argv):
+  if len(argv) < 2:
+    print __doc__
+    sys.exit(1)
+
+  if not LoadWhitelist(argv[0]):
+    sys.exit(1)
+
+  passed = True
+  for jar in argv[1:]:
+    if not CheckJar(jar):
+      passed = False
+  if not passed:
+    return 1
+
+  return 0
+
+
+if __name__ == '__main__':
+  main(sys.argv[1:])
diff --git a/core/tasks/check_boot_jars/package_whitelist.txt b/core/tasks/check_boot_jars/package_whitelist.txt
new file mode 100644
index 0000000..4d62615
--- /dev/null
+++ b/core/tasks/check_boot_jars/package_whitelist.txt
@@ -0,0 +1,214 @@
+# Boot jar package name whitelist.
+# Each line is interpreted as a regular expression.
+
+###################################################
+# core-libart.jar
+java\.awt\.font
+java\.beans
+java\.io
+java\.lang
+java\.lang\.annotation
+java\.lang\.ref
+java\.lang\.reflect
+java\.math
+java\.net
+java\.nio
+java\.nio\.channels
+java\.nio\.channels\.spi
+java\.nio\.charset
+java\.nio\.charset\.spi
+java\.security
+java\.security\.acl
+java\.security\.cert
+java\.security\.interfaces
+java\.security\.spec
+java\.sql
+java\.text
+java\.util
+java\.util\.concurrent
+java\.util\.concurrent\.atomic
+java\.util\.concurrent\.locks
+java\.util\.jar
+java\.util\.logging
+java\.util\.prefs
+java\.util\.regex
+java\.util\.zip
+javax\.crypto
+javax\.crypto\.interfaces
+javax\.crypto\.spec
+javax\.net
+javax\.net\.ssl
+javax\.security\.auth
+javax\.security\.auth\.callback
+javax\.security\.auth\.login
+javax\.security\.auth\.x500
+javax\.security\.cert
+javax\.sql
+javax\.xml
+javax\.xml\.datatype
+javax\.xml\.namespace
+javax\.xml\.parsers
+javax\.xml\.transform
+javax\.xml\.transform\.dom
+javax\.xml\.transform\.sax
+javax\.xml\.transform\.stream
+javax\.xml\.validation
+javax\.xml\.xpath
+sun\.misc
+org\.w3c\.dom
+org\.w3c\.dom\.ls
+org\.w3c\.dom\.traversal
+
+# TODO: Move these internal org.apache.harmony classes to libcore.*
+org\.apache\.harmony\.crypto\.internal
+org\.apache\.harmony\.dalvik
+org\.apache\.harmony\.dalvik\.ddmc
+org\.apache\.harmony\.luni\.internal\.util
+org\.apache\.harmony\.security
+org\.apache\.harmony\.security\.asn1
+org\.apache\.harmony\.security\.fortress
+org\.apache\.harmony\.security\.pkcs10
+org\.apache\.harmony\.security\.pkcs7
+org\.apache\.harmony\.security\.pkcs8
+org\.apache\.harmony\.security\.provider\.crypto
+org\.apache\.harmony\.security\.utils
+org\.apache\.harmony\.security\.x501
+org\.apache\.harmony\.security\.x509
+org\.apache\.harmony\.security\.x509\.tsp
+org\.apache\.harmony\.xml
+org\.apache\.harmony\.xml\.dom
+org\.apache\.harmony\.xml\.parsers
+
+org\.json
+org\.xmlpull\.v1
+org\.xmlpull\.v1\.sax2
+
+# TODO:  jarjar org.kxml2.io to com.android org\.kxml2\.io
+org\.kxml2\.io
+org\.xml
+org\.xml\.sax
+org\.xml\.sax\.ext
+org\.xml\.sax\.helpers
+
+dalvik\..*
+libcore\..*
+android\..*
+com\.android\..*
+
+
+###################################################
+# core-junit.jar
+junit\.extensions
+junit\.framework
+
+
+###################################################
+# ext.jar
+# TODO: jarjar javax.sip to com.android
+javax\.sip
+javax\.sip\.address
+javax\.sip\.header
+javax\.sip\.message
+
+# TODO: jarjar org.apache.commons to com.android
+org\.apache\.commons\.codec
+org\.apache\.commons\.codec\.binary
+org\.apache\.commons\.codec\.language
+org\.apache\.commons\.codec\.net
+org\.apache\.commons\.logging
+org\.apache\.commons\.logging\.impl
+org\.apache\.http
+org\.apache\.http\.auth
+org\.apache\.http\.auth\.params
+org\.apache\.http\.client
+org\.apache\.http\.client\.entity
+org\.apache\.http\.client\.methods
+org\.apache\.http\.client\.params
+org\.apache\.http\.client\.protocol
+org\.apache\.http\.client\.utils
+org\.apache\.http\.conn
+org\.apache\.http\.conn\.params
+org\.apache\.http\.conn\.routing
+org\.apache\.http\.conn\.scheme
+org\.apache\.http\.conn\.ssl
+org\.apache\.http\.conn\.util
+org\.apache\.http\.cookie
+org\.apache\.http\.cookie\.params
+org\.apache\.http\.entity
+org\.apache\.http\.impl
+org\.apache\.http\.impl\.auth
+org\.apache\.http\.impl\.client
+org\.apache\.http\.impl\.client
+org\.apache\.http\.impl\.conn
+org\.apache\.http\.impl\.conn\.tsccm
+org\.apache\.http\.impl\.cookie
+org\.apache\.http\.impl\.entity
+org\.apache\.http\.impl\.io
+org\.apache\.http\.impl\.io
+org\.apache\.http\.io
+org\.apache\.http\.message
+org\.apache\.http\.params
+org\.apache\.http\.protocol
+org\.apache\.http\.util
+
+# TODO: jarjar gov.nist to com.android
+gov\.nist\.core
+gov\.nist\.core\.net
+gov\.nist\.javax\.sip
+gov\.nist\.javax\.sip\.address
+gov\.nist\.javax\.sip\.clientauthutils
+gov\.nist\.javax\.sip\.header
+gov\.nist\.javax\.sip\.header\.extensions
+gov\.nist\.javax\.sip\.header\.ims
+gov\.nist\.javax\.sip\.message
+gov\.nist\.javax\.sip\.parser
+gov\.nist\.javax\.sip\.parser\.extensions
+gov\.nist\.javax\.sip\.parser\.ims
+gov\.nist\.javax\.sip\.stack
+
+org\.ccil\.cowan\.tagsoup
+org\.ccil\.cowan\.tagsoup\.jaxp
+
+###################################################
+# framework.jar
+javax\.microedition\.khronos\.opengles
+javax\.microedition\.khronos\.egl
+
+android
+
+
+###################################################
+# telephony-common.jar
+com\.google\..*
+
+
+###################################################
+# apache-xml.jar
+org\.apache\.xml\.res
+org\.apache\.xml\.utils
+org\.apache\.xml\.utils\.res
+org\.apache\.xml\.dtm
+org\.apache\.xml\.dtm\.ref
+org\.apache\.xml\.dtm\.ref\.dom2dtm
+org\.apache\.xml\.dtm\.ref\.sax2dtm
+org\.apache\.xml\.serializer
+org\.apache\.xml\.serializer\.utils
+org\.apache\.xml\.serializer\.dom3
+org\.apache\.xpath
+org\.apache\.xpath\.operations
+org\.apache\.xpath\.domapi
+org\.apache\.xpath\.functions
+org\.apache\.xpath\.res
+org\.apache\.xpath\.axes
+org\.apache\.xpath\.objects
+org\.apache\.xpath\.patterns
+org\.apache\.xpath\.jaxp
+org\.apache\.xpath\.compiler
+org\.apache\.xalan
+org\.apache\.xalan\.res
+org\.apache\.xalan\.templates
+org\.apache\.xalan\.serialize
+org\.apache\.xalan\.extensions
+org\.apache\.xalan\.processor
+org\.apache\.xalan\.transformer
+org\.apache\.xalan\.xslt
diff --git a/core/tasks/sdk-addon.mk b/core/tasks/sdk-addon.mk
index 5a24a00..b32536c 100644
--- a/core/tasks/sdk-addon.mk
+++ b/core/tasks/sdk-addon.mk
@@ -18,11 +18,12 @@
 addon_name := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SDK_ADDON_NAME))
 ifneq ($(addon_name),)
 
-addon_dir_leaf := $(addon_name)-$(FILE_NAME_TAG)-$(INTERNAL_SDK_HOST_OS_NAME)
-
-intermediates := $(HOST_OUT_INTERMEDIATES)/SDK_ADDON/$(addon_name)_intermediates
-full_target := $(HOST_OUT_SDK_ADDON)/$(addon_dir_leaf).zip
-staging := $(intermediates)/$(addon_dir_leaf)
+addon_dir_leaf  := $(addon_name)-$(FILE_NAME_TAG)-$(INTERNAL_SDK_HOST_OS_NAME)
+addon_dir_img   := $(addon_dir_leaf)-img
+intermediates   := $(HOST_OUT_INTERMEDIATES)/SDK_ADDON/$(addon_name)_intermediates
+full_target     := $(HOST_OUT_SDK_ADDON)/$(addon_dir_leaf).zip
+full_target_img := $(HOST_OUT_SDK_ADDON)/$(addon_dir_img).zip
+staging         := $(intermediates)
 
 sdk_addon_deps :=
 files_to_copy :=
@@ -46,29 +47,54 @@
   $(eval _src := $(call stub-addon-jar-file,$(_src))) \
   $(if $(_src),,$(eval $(error Unknown or unlinkable module: $(call word-colon,1,$(cf)). Requested by $(INTERNAL_PRODUCT)))) \
   $(eval _dest := $(call word-colon,2,$(cf))) \
-  $(eval files_to_copy += $(_src):$(_dest)) \
+  $(eval files_to_copy += $(addon_dir_leaf):$(_src):$(_dest)) \
  )
 endif
 
 # Files that are copied directly into the sdk-addon
-files_to_copy += $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SDK_ADDON_COPY_FILES)
+ifneq ($(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SDK_ADDON_COPY_FILES)),)
+$(foreach cf,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SDK_ADDON_COPY_FILES), \
+  $(eval _src  := $(call word-colon,1,$(cf))) \
+  $(eval _dest := $(call word-colon,2,$(cf))) \
+  $(if $(findstring images/,$(_dest)), $(eval _root := $(addon_dir_img)), $(eval _root := $(addon_dir_leaf))) \
+  $(eval files_to_copy += $(_root):$(_src):$(_dest)) \
+ )
+endif
 
-# All SDK add-ons have these files
+# Files copied in the system-image directory
 files_to_copy += \
-        $(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 \
-        $(PRODUCT_OUT)/system/build.prop:images/$(TARGET_CPU_ABI)/build.prop \
-        $(target_notice_file_txt):images/$(TARGET_CPU_ABI)/NOTICE.txt
+	$(addon_dir_img):$(BUILT_SYSTEMIMAGE):images/$(TARGET_CPU_ABI)/system.img \
+	$(addon_dir_img):$(BUILT_USERDATAIMAGE_TARGET):images/$(TARGET_CPU_ABI)/userdata.img \
+	$(addon_dir_img):$(BUILT_RAMDISK_TARGET):images/$(TARGET_CPU_ABI)/ramdisk.img \
+	$(addon_dir_img):$(PRODUCT_OUT)/system/build.prop:images/$(TARGET_CPU_ABI)/build.prop \
+	$(addon_dir_img):$(target_notice_file_txt):images/$(TARGET_CPU_ABI)/NOTICE.txt \
+	$(addon_dir_img):$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SDK_ADDON_SYS_IMG_SOURCE_PROP):images/source.properties
 
 # Generate rules to copy the requested files
 $(foreach cf,$(files_to_copy), \
-  $(eval _src := $(call word-colon,1,$(cf))) \
-  $(eval _dest := $(call append-path,$(staging),$(call word-colon,2,$(cf)))) \
+  $(eval _root := $(call word-colon,1,$(cf))) \
+  $(eval _src  := $(call word-colon,2,$(cf))) \
+  $(eval _dest := $(call append-path,$(call append-path,$(staging),$(_root)),$(call word-colon,3,$(cf)))) \
   $(eval $(call copy-one-file,$(_src),$(_dest))) \
   $(eval sdk_addon_deps += $(_dest)) \
  )
 
+# The system-image source.properties is a template that we directly expand in-place
+addon_img_source_prop := $(call append-path,$(staging),$(addon_dir_img))/images/source.properties
+sdk_addon_deps += $(addon_img_source_prop)
+
+$(addon_img_source_prop): $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SDK_ADDON_SYS_IMG_SOURCE_PROP)
+	@echo Generate $@
+	$(hide) mkdir -p $(dir $@)
+	$(hide) sed \
+		-e 's/$${PLATFORM_VERSION}/$(PLATFORM_VERSION)/' \
+		-e 's/$${PLATFORM_SDK_VERSION}/$(PLATFORM_SDK_VERSION)/' \
+		-e 's/$${PLATFORM_VERSION_CODENAME}/$(subst REL,,$(PLATFORM_VERSION_CODENAME))/' \
+		-e 's/$${TARGET_ARCH}/$(TARGET_ARCH)/' \
+		-e 's/$${TARGET_CPU_ABI}/$(TARGET_CPU_ABI)/' \
+		$< > $@ && sed -i -e '/^AndroidVersion.CodeName=\s*$$/d' $@
+
+
 # We don't know about all of the docs files, so depend on the timestamps for
 # them, and record the directories, and the packaging rule will just copy the
 # whole thing.
@@ -76,7 +102,7 @@
 sdk_addon_deps += $(foreach dm, $(doc_modules), $(call doc-timestamp-for, $(dm)))
 $(full_target): PRIVATE_DOCS_DIRS := $(addprefix $(OUT_DOCS)/, $(doc_modules))
 
-$(full_target): PRIVATE_STAGING_DIR := $(staging)
+$(full_target): PRIVATE_STAGING_DIR := $(call append-path,$(staging),$(addon_dir_leaf))
 
 $(full_target): $(sdk_addon_deps) | $(ACP)
 	@echo Packaging SDK Addon: $@
@@ -85,16 +111,24 @@
 	    $(ACP) -r $$d $(PRIVATE_STAGING_DIR)/docs ;\
 	  done
 	$(hide) mkdir -p $(dir $@)
-	$(hide) ( F=$$(pwd)/$@ ; cd $(PRIVATE_STAGING_DIR)/.. && zip -rq $$F * )
+	$(hide) ( F=$$(pwd)/$@ ; cd $(PRIVATE_STAGING_DIR)/.. && zip -rq $$F $(notdir $(PRIVATE_STAGING_DIR)) )
+
+$(full_target_img): PRIVATE_STAGING_DIR := $(call append-path,$(staging),$(addon_dir_img))
+$(full_target_img): $(full_target) $(addon_img_source_prop)
+	@echo Packaging SDK Addon System-Image: $@
+	$(hide) mkdir -p $(dir $@)
+	$(hide) ( F=$$(pwd)/$@ ; cd $(PRIVATE_STAGING_DIR)/.. && zip -rq $$F $(notdir $(PRIVATE_STAGING_DIR)) )
+
 
 .PHONY: sdk_addon
-sdk_addon: $(full_target)
+sdk_addon: $(full_target) $(full_target_img)
 
 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)
+ADDON_SDK_ZIP        := $(full_target)
+ADDON_SDK_IMG_ZIP    := $(full_target_img)
 else
 # When not building an sdk_repo, just dist the addon zip file
 # as-is.
diff --git a/envsetup.sh b/envsetup.sh
index 2c74b2d..79230b1 100644
--- a/envsetup.sh
+++ b/envsetup.sh
@@ -476,7 +476,6 @@
 add_lunch_combo aosp_mips64-eng
 add_lunch_combo aosp_x86-eng
 add_lunch_combo aosp_x86_64-eng
-add_lunch_combo vbox_x86-eng
 
 function print_lunch_menu()
 {
@@ -629,7 +628,8 @@
 {
     local TOPFILE=build/core/envsetup.mk
     if [ -n "$TOP" -a -f "$TOP/$TOPFILE" ] ; then
-        echo $TOP
+        # The following circumlocution ensures we remove symlinks from TOP.
+        (cd $TOP; PWD= /bin/pwd)
     else
         if [ -f $TOPFILE ] ; then
             # The following circumlocution (repeated below as well) ensures
diff --git a/target/board/vbox_x86/AndroidBoard.mk b/target/board/vbox_x86/AndroidBoard.mk
deleted file mode 100644
index 8b13789..0000000
--- a/target/board/vbox_x86/AndroidBoard.mk
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/target/board/vbox_x86/BoardConfig.mk b/target/board/vbox_x86/BoardConfig.mk
deleted file mode 100644
index e5a1d3e..0000000
--- a/target/board/vbox_x86/BoardConfig.mk
+++ /dev/null
@@ -1,40 +0,0 @@
-#
-# IA target for VitualBox
-#
-
-TARGET_ARCH=x86
-TARGET_COMPRESS_MODULE_SYMBOLS := false
-TARGET_NO_RECOVERY := true
-TARGET_HARDWARE_3D := false
-BOARD_USES_GENERIC_AUDIO := true
-USE_CAMERA_STUB := true
-TARGET_CPU_ABI := x86
-TARGET_USERIMAGES_USE_EXT4 := true
-TARGET_BOOTIMAGE_USE_EXT2 := true
-BOARD_CACHEIMAGE_PARTITION_SIZE := 268435456
-BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE := ext4
-
-# 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=tty0 vga=788 verbose androidboot.hardware=vbox_x86 androidboot.console=tty0 android.qemud=tty0
-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
-
-WITH_DEXPREOPT := false
-
-# The eth0 device should be started with dhcp on boot.
-# Useful for emulators that don't provide a wifi connection.
-NET_ETH0_STARTONBOOT := true
-
-ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.heapsize=32m
diff --git a/target/board/vbox_x86/README.txt b/target/board/vbox_x86/README.txt
deleted file mode 100644
index 568dc5f..0000000
--- a/target/board/vbox_x86/README.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-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
deleted file mode 100644
index b51f801..0000000
--- a/target/board/vbox_x86/device.mk
+++ /dev/null
@@ -1,39 +0,0 @@
-#
-# 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 \
-    ro.adb.qemud=1
-
-LOCAL_KERNEL := prebuilts/qemu-kernel/x86/kernel-vbox
-
-PRODUCT_COPY_FILES := \
-    device/generic/goldfish/data/etc/apns-conf.xml:system/etc/apns-conf.xml \
-    device/generic/goldfish/camera/media_profiles.xml:system/etc/media_profiles.xml \
-    frameworks/av/media/libstagefright/data/media_codecs_google_audio.xml:system/etc/media_codecs_google_audio.xml \
-    frameworks/av/media/libstagefright/data/media_codecs_google_telephony.xml:system/etc/media_codecs_google_telephony.xml \
-    frameworks/av/media/libstagefright/data/media_codecs_google_video.xml:system/etc/media_codecs_google_video.xml \
-    device/generic/goldfish/camera/media_codecs.xml:system/etc/media_codecs.xml \
-    build/target/board/vbox_x86/init.vbox_x86.rc:root/init.vbox_x86.rc \
-    $(LOCAL_KERNEL):kernel
-
-$(call inherit-product, frameworks/native/build/phone-xhdpi-1024-dalvik-heap.mk)
diff --git a/target/board/vbox_x86/disk_layout.conf b/target/board/vbox_x86/disk_layout.conf
deleted file mode 100644
index 12241ab..0000000
--- a/target/board/vbox_x86/disk_layout.conf
+++ /dev/null
@@ -1,76 +0,0 @@
-# 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.vbox_x86.rc b/target/board/vbox_x86/init.vbox_x86.rc
deleted file mode 100644
index 15ca572..0000000
--- a/target/board/vbox_x86/init.vbox_x86.rc
+++ /dev/null
@@ -1,90 +0,0 @@
-on early-init
-    export EXTERNAL_STORAGE /mnt/sdcard
-    mkdir /mnt/sdcard 0000 system system
-    # for backwards compatibility
-    symlink /mnt/sdcard /sdcard
-
-on boot
-    setprop ARGH ARGH
-    setprop net.eth0.gw 10.0.2.2
-    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
-
-# start essential services
-    start qemud
-    start goldfish-logcat
-#   start goldfish-setup
-    start netcfg
-
-    setprop ro.setupwizard.mode EMULATOR
-
-on fs
-# mount sda (system) and sdb (data) partitions
-    mount ext4 /dev/block/sda6 /system
-    mount ext4 /dev/block/sda6 /system ro remount
-    mount ext4 /dev/block/sdb6 /data nosuid nodev
-    mount ext4 /dev/block/sdb7 /cache nosuid nodev
-
-# 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
-    user root
-    group root
-    oneshot
-
-# The qemu-props program is used to set various system
-# properties on boot. It must be run early during the boot
-# process to avoid race conditions with other daemons that
-# might read them (e.g. surface flinger), so define it in
-# class 'core'
-#
-service qemu-props /system/bin/qemu-props
-    class core
-    user root
-    group root
-    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, it simply exits immediately
-
-service goldfish-logcat /system/bin/logcat -Q
-    oneshot
-
-# Enable networking so that adb can connect
-service netcfg /system/bin/netcfg eth0 dhcp
-    oneshot
diff --git a/target/board/vbox_x86/system.prop b/target/board/vbox_x86/system.prop
deleted file mode 100644
index 137a0f9..0000000
--- a/target/board/vbox_x86/system.prop
+++ /dev/null
@@ -1,6 +0,0 @@
-#
-# 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 abb4d8c..ac5902c 100644
--- a/target/product/AndroidProducts.mk
+++ b/target/product/AndroidProducts.mk
@@ -60,7 +60,6 @@
     $(LOCAL_DIR)/aosp_mips64.mk \
     $(LOCAL_DIR)/aosp_x86_64.mk \
     $(LOCAL_DIR)/full_x86_64.mk \
-    $(LOCAL_DIR)/vbox_x86.mk \
     $(LOCAL_DIR)/sdk_phone_armv7.mk \
     $(LOCAL_DIR)/sdk_phone_x86.mk \
     $(LOCAL_DIR)/sdk_phone_mips.mk \
diff --git a/target/product/base.mk b/target/product/base.mk
index 6c495e3..4df10c4 100644
--- a/target/product/base.mk
+++ b/target/product/base.mk
@@ -31,6 +31,7 @@
     dhcpcd \
     dhcpcd-run-hooks \
     dnsmasq \
+    dpm \
     framework \
     fsck_msdos \
     ime \
diff --git a/target/product/vbox_x86.mk b/target/product/vbox_x86.mk
deleted file mode 100644
index a7d1b65..0000000
--- a/target/product/vbox_x86.mk
+++ /dev/null
@@ -1,36 +0,0 @@
-#
-# 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/aosp_base.mk)
-$(call inherit-product, $(SRC_TARGET_DIR)/board/vbox_x86/device.mk)
-
-PRODUCT_PACKAGES += \
-       camera.vbox_x86 \
-       lights.vbox_x86 \
-       gps.vbox_x86 \
-       sensors.vbox_x86
-
-PRODUCT_NAME := vbox_x86
-PRODUCT_DEVICE := vbox_x86
-PRODUCT_MODEL := Full Android on x86 VirtualBox
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py
index 92d912b..815c76c 100644
--- a/tools/releasetools/common.py
+++ b/tools/releasetools/common.py
@@ -30,6 +30,7 @@
 import zipfile
 
 import blockimgdiff
+from rangelib import *
 
 try:
   from hashlib import sha1 as sha1
@@ -1023,10 +1024,11 @@
 
 
 class BlockDifference:
-  def __init__(self, partition, tgt, src=None):
+  def __init__(self, partition, tgt, src=None, check_first_block=False):
     self.tgt = tgt
     self.src = src
     self.partition = partition
+    self.check_first_block = check_first_block
 
     b = blockimgdiff.BlockImageDiff(tgt, src, threads=OPTIONS.worker_threads)
     tmpdir = tempfile.mkdtemp()
@@ -1043,6 +1045,9 @@
       self._WriteUpdate(script, output_zip)
 
     else:
+      if self.check_first_block:
+        self._CheckFirstBlock(script)
+
       script.AppendExtra('if range_sha1("%s", "%s") == "%s" then' %
                          (self.device, self.src.care_map.to_string_raw(),
                           self.src.TotalSha1()))
@@ -1072,6 +1077,18 @@
             (self.device, partition, partition, partition))
     script.AppendExtra(script._WordWrap(call))
 
+  def _CheckFirstBlock(self, script):
+    r = RangeSet((0, 1))
+    h = sha1()
+    for data in self.src.ReadRangeSet(r):
+      h.update(data)
+    h = h.hexdigest()
+
+    script.AppendExtra(('(range_sha1("%s", "%s") == "%s") || '
+                        'abort("%s has been remounted R/W; '
+                        'reflash device to reenable OTA updates");')
+                       % (self.device, r.to_string_raw(), h, self.device))
+
 
 DataImage = blockimgdiff.DataImage
 
diff --git a/tools/releasetools/ota_from_target_files b/tools/releasetools/ota_from_target_files
index 8b7342b..6f34450 100755
--- a/tools/releasetools/ota_from_target_files
+++ b/tools/releasetools/ota_from_target_files
@@ -731,14 +731,16 @@
 
   system_src = GetImage("system", OPTIONS.source_tmp, OPTIONS.source_info_dict)
   system_tgt = GetImage("system", OPTIONS.target_tmp, OPTIONS.target_info_dict)
-  system_diff = common.BlockDifference("system", system_tgt, system_src)
+  system_diff = common.BlockDifference("system", system_tgt, system_src,
+                                       check_first_block=True)
 
   if HasVendorPartition(target_zip):
     if not HasVendorPartition(source_zip):
       raise RuntimeError("can't generate incremental that adds /vendor")
     vendor_src = GetImage("vendor", OPTIONS.source_tmp, OPTIONS.source_info_dict)
     vendor_tgt = GetImage("vendor", OPTIONS.target_tmp, OPTIONS.target_info_dict)
-    vendor_diff = common.BlockDifference("vendor", vendor_tgt, vendor_src)
+    vendor_diff = common.BlockDifference("vendor", vendor_tgt, vendor_src,
+                                         check_first_block=True)
   else:
     vendor_diff = None