Merge "Add shim app for CTS testing" into nyc-dev
diff --git a/core/Makefile b/core/Makefile
index 7950501..f377051 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -785,7 +785,7 @@
 $(if $(BOARD_HAS_EXT4_RESERVED_BLOCKS),$(hide) echo "has_ext4_reserved_blocks=$(BOARD_HAS_EXT4_RESERVED_BLOCKS)" >> $(1))
 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "system_squashfs_compressor=$(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
 $(if $(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "system_squashfs_compressor_opt=$(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
-$(if $(INTERNAL_SYSTEM_BASE_FS_PATH),$(hide) echo "system_base_fs_file=$(INTERNAL_SYSTEM_BASE_FS_PATH)" >> $(1))
+$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_BASE_FS_PATH),$(hide) echo "system_base_fs_file=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_BASE_FS_PATH)" >> $(1))
 $(if $(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "userdata_fs_type=$(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
 $(if $(BOARD_USERDATAIMAGE_PARTITION_SIZE),$(hide) echo "userdata_size=$(BOARD_USERDATAIMAGE_PARTITION_SIZE)" >> $(1))
 $(if $(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "cache_fs_type=$(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
@@ -795,7 +795,7 @@
 $(if $(BOARD_VENDORIMAGE_JOURNAL_SIZE),$(hide) echo "vendor_journal_size=$(BOARD_VENDORIMAGE_JOURNAL_SIZE)" >> $(1))
 $(if $(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "vendor_squashfs_compressor=$(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
 $(if $(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "vendor_squashfs_compressor_opt=$(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1))
-$(if $(INTERNAL_VENDOR_BASE_FS_PATH),$(hide) echo "vendor_base_fs_file=$(INTERNAL_VENDOR_BASE_FS_PATH)" >> $(1))
+$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_BASE_FS_PATH),$(hide) echo "vendor_base_fs_file=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_BASE_FS_PATH)" >> $(1))
 $(if $(BOARD_OEMIMAGE_PARTITION_SIZE),$(hide) echo "oem_size=$(BOARD_OEMIMAGE_PARTITION_SIZE)" >> $(1))
 $(if $(BOARD_OEMIMAGE_JOURNAL_SIZE),$(hide) echo "oem_journal_size=$(BOARD_OEMIMAGE_JOURNAL_SIZE)" >> $(1))
 $(if $(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG),$(hide) echo "extfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG)" >> $(1))
@@ -1501,7 +1501,8 @@
   $(HOST_OUT_EXECUTABLES)/fec \
   $(HOST_OUT_EXECUTABLES)/brillo_update_payload \
   $(HOST_OUT_EXECUTABLES)/lib/shflags/shflags \
-  $(HOST_OUT_EXECUTABLES)/delta_generator
+  $(HOST_OUT_EXECUTABLES)/delta_generator \
+  $(BLK_ALLOC_TO_BASE_FS)
 
 # Shared libraries.
 OTATOOLS += \
@@ -1754,6 +1755,14 @@
 	# OTA scripts are only interested in fingerprint related properties
 	$(hide) echo "oem_fingerprint_properties=$(OEM_THUMBPRINT_PROPERTIES)" >> $(zip_root)/META/misc_info.txt
 endif
+ifneq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_BASE_FS_PATH),)
+	$(hide) $(ACP) $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_BASE_FS_PATH) \
+	  $(zip_root)/META/$(notdir $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_BASE_FS_PATH))
+endif
+ifneq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_BASE_FS_PATH),)
+	$(hide) $(ACP) $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_BASE_FS_PATH) \
+	  $(zip_root)/META/$(notdir $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_BASE_FS_PATH))
+endif
 ifneq ($(strip $(SANITIZE_TARGET)),)
 	# We need to create userdata.img with real data because the instrumented libraries are in userdata.img.
 	$(hide) echo "userdata_img_with_data=true" >> $(zip_root)/META/misc_info.txt
diff --git a/core/definitions.mk b/core/definitions.mk
index 34b9385..5c01bc2 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -425,7 +425,7 @@
 
 define find-subdir-assets
 $(sort $(if $(1),$(patsubst ./%,%, \
-	$(shell if [ -d $(1) ] ; then cd $(1) ; find ./ -not -name '.*' -and -type f -and -not -type l ; fi)), \
+	$(shell if [ -d $(1) ] ; then cd $(1) ; find -L ./ -not -name '.*' -and -type f -and -not -type l ; fi)), \
 	$(warning Empty argument supplied to find-subdir-assets) \
 ))
 endef
@@ -1926,6 +1926,8 @@
 endef
 
 define aapt2-link
+@mkdir -p $(dir $@)
+$(call dump-words-to-file,$(PRIVATE_RES_FLAT),$(dir $@)aapt2-flat-list)
 $(hide) $(AAPT2) link -o $@ \
   $(PRIVATE_AAPT_FLAGS) \
   $(addprefix --manifest ,$(PRIVATE_ANDROID_MANIFEST)) \
@@ -1943,7 +1945,7 @@
   $(addprefix --rename-manifest-package ,$(PRIVATE_MANIFEST_PACKAGE_NAME)) \
   $(addprefix --rename-instrumentation-target-package ,$(PRIVATE_MANIFEST_INSTRUMENTATION_FOR)) \
   $(addprefix -R , $(PRIVATE_OVERLAY_FLAT)) \
-  $(PRIVATE_RES_FLAT)
+  \@$(dir $@)aapt2-flat-list
 endef
 
 ###########################################################
@@ -1958,34 +1960,34 @@
 define dump-words-to-file
         @rm -f $(2)
         @touch $(2)
-        @$(call emit-line,$(wordlist 1,200,$(1)),$(2))
-        @$(call emit-line,$(wordlist 201,400,$(1)),$(2))
-        @$(call emit-line,$(wordlist 401,600,$(1)),$(2))
-        @$(call emit-line,$(wordlist 601,800,$(1)),$(2))
-        @$(call emit-line,$(wordlist 801,1000,$(1)),$(2))
-        @$(call emit-line,$(wordlist 1001,1200,$(1)),$(2))
-        @$(call emit-line,$(wordlist 1201,1400,$(1)),$(2))
-        @$(call emit-line,$(wordlist 1401,1600,$(1)),$(2))
-        @$(call emit-line,$(wordlist 1601,1800,$(1)),$(2))
-        @$(call emit-line,$(wordlist 1801,2000,$(1)),$(2))
-        @$(call emit-line,$(wordlist 2001,2200,$(1)),$(2))
-        @$(call emit-line,$(wordlist 2201,2400,$(1)),$(2))
-        @$(call emit-line,$(wordlist 2401,2600,$(1)),$(2))
-        @$(call emit-line,$(wordlist 2601,2800,$(1)),$(2))
-        @$(call emit-line,$(wordlist 2801,3000,$(1)),$(2))
-        @$(call emit-line,$(wordlist 3001,3200,$(1)),$(2))
-        @$(call emit-line,$(wordlist 3201,3400,$(1)),$(2))
-        @$(call emit-line,$(wordlist 3401,3600,$(1)),$(2))
-        @$(call emit-line,$(wordlist 3601,3800,$(1)),$(2))
-        @$(call emit-line,$(wordlist 3801,4000,$(1)),$(2))
-        @$(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))
-        @$(call emit-line,$(wordlist 5001,5200,$(1)),$(2))
-        @$(call emit-line,$(wordlist 5201,5400,$(1)),$(2))
-        @$(if $(wordlist 5401,5402,$(1)),$(error Too many words ($(words $(1)))))
+        @$(call emit-line,$(wordlist 1,500,$(1)),$(2))
+        @$(call emit-line,$(wordlist 501,1000,$(1)),$(2))
+        @$(call emit-line,$(wordlist 1001,1500,$(1)),$(2))
+        @$(call emit-line,$(wordlist 1501,2000,$(1)),$(2))
+        @$(call emit-line,$(wordlist 2001,2500,$(1)),$(2))
+        @$(call emit-line,$(wordlist 2501,3000,$(1)),$(2))
+        @$(call emit-line,$(wordlist 3001,3500,$(1)),$(2))
+        @$(call emit-line,$(wordlist 3501,4000,$(1)),$(2))
+        @$(call emit-line,$(wordlist 4001,4500,$(1)),$(2))
+        @$(call emit-line,$(wordlist 4501,5000,$(1)),$(2))
+        @$(call emit-line,$(wordlist 5001,5500,$(1)),$(2))
+        @$(call emit-line,$(wordlist 5501,6000,$(1)),$(2))
+        @$(call emit-line,$(wordlist 6001,6500,$(1)),$(2))
+        @$(call emit-line,$(wordlist 6501,7000,$(1)),$(2))
+        @$(call emit-line,$(wordlist 7001,7500,$(1)),$(2))
+        @$(call emit-line,$(wordlist 7501,8000,$(1)),$(2))
+        @$(call emit-line,$(wordlist 8001,8500,$(1)),$(2))
+        @$(call emit-line,$(wordlist 8501,9000,$(1)),$(2))
+        @$(call emit-line,$(wordlist 9001,9500,$(1)),$(2))
+        @$(call emit-line,$(wordlist 9501,10000,$(1)),$(2))
+        @$(call emit-line,$(wordlist 10001,10500,$(1)),$(2))
+        @$(call emit-line,$(wordlist 10501,11000,$(1)),$(2))
+        @$(call emit-line,$(wordlist 11001,11500,$(1)),$(2))
+        @$(call emit-line,$(wordlist 11501,12000,$(1)),$(2))
+        @$(call emit-line,$(wordlist 12001,12500,$(1)),$(2))
+        @$(call emit-line,$(wordlist 12501,13000,$(1)),$(2))
+        @$(call emit-line,$(wordlist 13001,13500,$(1)),$(2))
+        @$(if $(wordlist 13501,13502,$(1)),$(error Too many words ($(words $(1)))))
 endef
 
 # For a list of jar files, unzip them to a specified directory,
@@ -2469,13 +2471,15 @@
 # Align STORED entries of a package on 4-byte boundaries to make them easier to mmap.
 #
 define align-package
-$(hide) mv $@ $@.unaligned
-$(hide) $(ZIPALIGN) \
+$(hide) if ! $(ZIPALIGN) -c $(ZIPALIGN_PAGE_ALIGN_FLAGS) 4 $@ >/dev/null ; then \
+  mv $@ $@.unaligned; \
+  $(ZIPALIGN) \
     -f \
     $(ZIPALIGN_PAGE_ALIGN_FLAGS) \
     4 \
-    $@.unaligned $@.aligned
-$(hide) mv $@.aligned $@
+    $@.unaligned $@.aligned; \
+  mv $@.aligned $@; \
+  fi
 endef
 
 # Remove dynamic timestamps from packages
diff --git a/core/product.mk b/core/product.mk
index 7043cff..5b6a86c 100644
--- a/core/product.mk
+++ b/core/product.mk
@@ -120,6 +120,9 @@
     PRODUCT_DEX_PREOPT_MODULE_CONFIGS \
     PRODUCT_DEX_PREOPT_DEFAULT_FLAGS \
     PRODUCT_DEX_PREOPT_BOOT_FLAGS \
+    PRODUCT_SYSTEM_BASE_FS_PATH \
+    PRODUCT_VENDOR_BASE_FS_PATH \
+
 
 
 define dump-product
diff --git a/core/version_defaults.mk b/core/version_defaults.mk
index 27ae53d..318abd3 100644
--- a/core/version_defaults.mk
+++ b/core/version_defaults.mk
@@ -110,7 +110,7 @@
 
 ifeq "" "$(PLATFORM_SECURITY_PATCH)"
   # Used to indicate the security patch that has been applied to the device.
-  # Can be an arbitrary string, but must be a single word.
+  # Must be of the form "YYYY-MM-DD" on production devices.
   #
   # If there is no $PLATFORM_SECURITY_PATCH set, keep it empty.
   PLATFORM_SECURITY_PATCH := 2016-06-01
diff --git a/target/product/base.mk b/target/product/base.mk
index d0d65e2..4d70664 100644
--- a/target/product/base.mk
+++ b/target/product/base.mk
@@ -30,6 +30,7 @@
     blkid \
     bmgr \
     bugreport \
+    bugreportz \
     cameraserver \
     content \
     dnsmasq \
diff --git a/tools/droiddoc/templates-sdk-dev/head_tag.cs b/tools/droiddoc/templates-sdk-dev/head_tag.cs
index 549311d..c3ae93d 100644
--- a/tools/droiddoc/templates-sdk-dev/head_tag.cs
+++ b/tools/droiddoc/templates-sdk-dev/head_tag.cs
@@ -5,11 +5,11 @@
     if:devsite ?>
     <meta name="top_category" value="<?cs
       if:ndk ?>ndk<?cs
-      elif:(guide||develop||training||reference||tools||sdk||google||reference.gms||reference.gcm||samples) ?>develop<?cs
+      elif:(guide||develop||training||reference||tools||sdk||google||reference.gms||reference.gcm||samples||preview) ?>develop<?cs
+      elif:(go||libraries) ?>develop<?cs
       elif:(distribute||googleplay||essentials||users||engage||monetize||disttools||stories||analyze) ?>distribute<?cs
       elif:(design||vision||material||patterns||devices||designdownloads) ?>design<?cs
       elif:(about||versions||wear||tv||auto) ?>about<?cs
-      elif:preview ?>preview<?cs
       else ?>none<?cs
       /if ?>" />
     <?cs set:dac_subcategory_set = #1 ?>
@@ -34,6 +34,9 @@
             if:(samplesDocPage&&!samplesProjectIndex) ?> samples-docpage<?cs /if ?><?cs
           else ?>none<?cs set:dac_subcategory_set = #0 ?><?cs /if ?><?cs
         elif:(google||reference.gms||reference.gcm) ?>google<?cs
+        elif:(go||libraries) ?><?cs
+          if:libraries ?>libraries<?cs
+          else ?>none<?cs set:dac_subcategory_set = #0 ?><?cs /if ?><?cs
         elif:(distribute||googleplay||essentials||users||engage||monetize||disttools||stories||analyze) ?><?cs
           if:googleplay ?>googleplay<?cs
           elif:essentials ?>essentials<?cs
@@ -69,6 +72,8 @@
             elif:sdk ?>/tools<?cs
             elif:samples ?>/samples<?cs /if ?><?cs
           elif:(google||reference.gms||reference.gcm) ?>/google<?cs
+          elif:(go||libraries) ?>/go<?cs
+            if:libraries ?>/libraries<?cs /if ?><?cs
           elif:(distribute||googleplay||essentials||users||engage||monetize||disttools||stories||analyze) ?>/distribute<?cs
             if:googleplay ?>/googleplay<?cs
             elif:essentials ?>/essentials<?cs
diff --git a/tools/droiddoc/templates-sdk-dev/sdkpage.cs b/tools/droiddoc/templates-sdk-dev/sdkpage.cs
index b0c4d39..fcf42cc 100644
--- a/tools/droiddoc/templates-sdk-dev/sdkpage.cs
+++ b/tools/droiddoc/templates-sdk-dev/sdkpage.cs
@@ -256,168 +256,7 @@
 <?cs call:tag_list(root.descr) ?>
 
 
-<section id="downloads" class="dac-section dac-small">
-<div class="wrap">
-
-<h2 class="norule">Start using Android Studio today</h2>
-
-<p>Android Studio includes all the tools you need to build apps for Android.</p>
-
-<div style="float:left;margin-right:40px;width:auto;">
-<p>
-  <a class="landing-button green download-bundle-button"
-    data-modal-toggle="studio_tos">Download Android Studio 2.0<br>
-  <span class="small"></span></a>
-</p>
-</div>
-
-<div style="float:left;width:auto;margin-bottom:40px">
-<ul class="nolist" style="text-transform: uppercase;margin:8px 0">
-<li>Version: <?cs var:studio.version ?></li>
-<li>Release date: <?cs var:studio.release.date ?></li>
-</ul>
-</div>
-
-
-
-<h4 style="clear:left;margin-top:40px">Select a different platform</h4>
-
-  <table class="download">
-    <tr>
-      <th>Platform</th>
-      <th>Android Studio package</th>
-      <th>Size</th>
-      <th>SHA-1 checksum</th>
-  </tr>
-  <tr>
-    <td rowspan="3">Windows</td>
-    <td>
-  <a onclick="return onDownload(this,false,true)" id="win-bundle" data-modal-toggle="studio_tos"
-    href="https://dl.google.com/dl/android/studio/install/<?cs var:studio.version ?>/<?cs var:studio.win_bundle_exe_download ?>"
-    ><?cs var:studio.win_bundle_exe_download ?></a><br>
-    Includes Android SDK <b>(recommended)</b>
-    </td>
-    <td id="win-bundle-size"><?cs call:size_in_mb(studio.win_bundle_exe_bytes) ?> MB
-      <br>(<?cs var:studio.win_bundle_exe_bytes ?> bytes)</td>
-    <td><?cs var:studio.win_bundle_exe_checksum ?></td>
-  </tr>
-  <tr>
-    <!-- blank TD from Windows rowspan -->
-    <td>
-  <a onclick="return onDownload(this,false,true)" id="win-bundle-notools" data-modal-toggle="studio_tos"
-    href="https://dl.google.com/dl/android/studio/install/<?cs var:studio.version ?>/<?cs var:studio.win_notools_exe_download ?>"
-    ><?cs var:studio.win_notools_exe_download ?></a><br>
-    No Android SDK
-    </td>
-    <td><?cs call:size_in_mb(studio.win_notools_exe_bytes) ?> MB
-      <br>(<?cs var:studio.win_notools_exe_bytes ?> bytes)</td>
-    <td><?cs var:studio.win_notools_exe_checksum ?></td>
-  </tr>
-  <tr>
-    <!-- blank TD from Windows rowspan -->
-    <td>
-  <a onclick="return onDownload(this,false,true)" id="win-bundle-zip" data-modal-toggle="studio_tos"
-    href="https://dl.google.com/dl/android/studio/ide-zips/<?cs var:studio.version ?>/<?cs var:studio.win_bundle_download ?>"
-    ><?cs var:studio.win_bundle_download ?></a><br>
-    No Android SDK, no installer
-    </td>
-    <td><?cs call:size_in_mb(studio.win_bundle_bytes) ?> MB
-      <br>(<?cs var:studio.win_bundle_bytes ?> bytes)</td>
-    <td><?cs var:studio.win_bundle_checksum ?></td>
-  </tr>
-  <tr>
-    <td><nobr>Mac OS X</nobr></td>
-    <td>
-  <a onclick="return onDownload(this,false,true)" id="mac-bundle" data-modal-toggle="studio_tos"
-    href="https://dl.google.com/dl/android/studio/install/<?cs var:studio.version ?>/<?cs var:studio.mac_bundle_download ?>"
-    ><?cs var:studio.mac_bundle_download ?></a>
-    </td>
-    <td id="mac-bundle-size"><?cs call:size_in_mb(studio.mac_bundle_bytes) ?> MB
-      <br>(<?cs var:studio.mac_bundle_bytes ?> bytes)</td>
-    <td><?cs var:studio.mac_bundle_checksum ?></td>
-  </tr>
-  <tr>
-    <td>Linux</td>
-    <td>
-  <a onclick="return onDownload(this,false,true)" id="linux-bundle" data-modal-toggle="studio_tos"
-    href="https://dl.google.com/dl/android/studio/ide-zips/<?cs var:studio.version ?>/<?cs var:studio.linux_bundle_download ?>"
-    ><?cs var:studio.linux_bundle_download ?></a>
-    </td>
-    <td id="linux-bundle-size"><?cs call:size_in_mb(studio.linux_bundle_bytes) ?> MB
-      <br>(<?cs var:studio.linux_bundle_bytes ?> bytes)</td>
-    <td><?cs var:studio.linux_bundle_checksum ?></td>
-  </tr>
-  </table>
-
-
-
-<h4 class="norule" style="margin-top:40px">Get just the command line tools</h4>
-
-<p>If you do not need Android Studio, you can download the basic Android
-command line tools below.</p>
-
-  <table class="download">
-    <tr>
-      <th>Platform</th>
-      <th>SDK tools package</th>
-      <th>Size</th>
-      <th>SHA-1 checksum</th>
-  </tr>
-  <tr>
-    <td rowspan="2">Windows</td>
-    <td>
-  <a onclick="return onDownload(this)" id="win-tools" data-modal-toggle="studio_tos"
-    href="//dl.google.com/android/<?cs
-var:sdk.win_installer
-?>"><?cs var:sdk.win_installer ?></a><br>
-    </td>
-    <td><?cs call:size_in_mb(sdk.win_installer_bytes) ?> MB
-      <br>(<?cs var:sdk.win_installer_bytes ?> bytes)</td>
-    <td><?cs var:sdk.win_installer_checksum ?></td>
-  </tr>
-  <tr>
-    <!-- blank TD from Windows rowspan -->
-    <td>
-  <a onclick="return onDownload(this)" id="win-tools2" data-modal-toggle="studio_tos"
-    href="//dl.google.com/android/<?cs var:sdk.win_download
-?>"><?cs var:sdk.win_download ?></a><br>
-    No installer
-    </td>
-    <td><?cs call:size_in_mb(sdk.win_bytes) ?> MB
-      <br>(<?cs var:sdk.win_bytes ?> bytes)</td>
-    <td><?cs var:sdk.win_checksum ?></td>
-  </tr>
-  <tr>
-    <td><nobr>Mac OS X</nobr></td>
-    <td>
-  <a onclick="return onDownload(this)" id="mac-tools" data-modal-toggle="studio_tos"
-    href="//dl.google.com/android/<?cs
-var:sdk.mac_download
-?>"><?cs var:sdk.mac_download ?></a>
-    </td>
-    <td><?cs call:size_in_mb(sdk.mac_bytes) ?> MB
-      <br>(<?cs var:sdk.mac_bytes ?> bytes)</td>
-    <td><?cs var:sdk.mac_checksum ?></td>
-  </tr>
-  <tr>
-    <td>Linux</td>
-    <td>
-  <a onclick="return onDownload(this)" id="linux-tools" data-modal-toggle="studio_tos"
-    href="//dl.google.com/android/<?cs
-var:sdk.linux_download
-?>"><?cs var:sdk.linux_download ?></a>
-    </td>
-    <td><?cs call:size_in_mb(sdk.linux_bytes) ?> MB
-      <br>(<?cs var:sdk.linux_bytes ?> bytes)</td>
-    <td><?cs var:sdk.linux_checksum ?></td>
-  </tr>
-  </table>
-  <p>
-Also see the <a href="<?cs var:toroot ?>tools/sdk/tools-notes.html">SDK
-tools release notes</a>.</p>
-
-  </div><!-- end wrap -->
-  </section>
+<?cs #######  TODO: Remove this whole file from processing. ######## ?>
 
 
 <?cs ########  The Android Studio version of the download script ######### ?>
@@ -449,7 +288,7 @@
     idname = bundlename + "-size";
     sizeMB = $(idname).text().split(' MB')[0];
     $('.download-bundle-button > .small').html(" for " + os + " <em>(" + sizeMB + " MB)</em>");
-    $('.download-bundle-button').click(function() {return onDownload(this,true,true);}).attr('href', bundlename);
+    $('.download-bundle-button').click(function() { onDownload(this,true,true);}).attr('href', bundlename);
   }
 
 
@@ -581,11 +420,14 @@
 </div><!-- end g-unit -->
 
 <?cs include:"trailer.cs" ?>
+<?cs if:!devsite ?>
 <script src="https://developer.android.com/ytblogger_lists_unified.js?v=17" type="text/javascript"></script>
 <script src="/jd_lists_unified.js?v=17" type="text/javascript"></script>
 <script src="/jd_extras.js?v=17" type="text/javascript"></script>
 <script src="/jd_collections.js?v=17" type="text/javascript"></script>
 <script src="/jd_tag_helpers.js?v=17" type="text/javascript"></script>
+<?cs /if ?><!--end !devsite -->
+
 
 <!-- Start of Tag -->
 <script type="text/javascript">
diff --git a/tools/droiddoc/templates-sdk-dev/yaml_navtree.cs b/tools/droiddoc/templates-sdk-dev/yaml_navtree.cs
new file mode 100644
index 0000000..b4a6406
--- /dev/null
+++ b/tools/droiddoc/templates-sdk-dev/yaml_navtree.cs
@@ -0,0 +1,14 @@
+<?cs
+
+# print out the yaml nav for the reference docs, only printing the title,
+path, and status_text (API level) for each package.
+
+?>
+reference:<?cs
+each:page = docs.pages?><?cs
+  if:page.type == "package"?>
+- title: <?cs var:page.label ?>
+  path: <?cs var:page.link ?>
+  status_text: apilevel-<?cs var:page.apilevel ?><?cs
+  /if?><?cs
+/each ?>
diff --git a/tools/droiddoc/templates-sdk/assets/js/docs.js b/tools/droiddoc/templates-sdk/assets/js/docs.js
index ee3ebee..d6aa351 100644
--- a/tools/droiddoc/templates-sdk/assets/js/docs.js
+++ b/tools/droiddoc/templates-sdk/assets/js/docs.js
@@ -21,6 +21,8 @@
 
 $(document).ready(function() {
 
+  showStudioSurveyButton();
+
   // show lang dialog if the URL includes /intl/
   //if (location.pathname.substring(0,6) == "/intl/") {
   //  var lang = location.pathname.split('/')[2];
@@ -5375,3 +5377,17 @@
   $(document)
     .on('click.toggle', '[data-toggle="section"]', Toggle.prototype.toggle);
 })(jQuery);
+
+
+var STUDIO_SURVEY_CLICKED = 'studio-survey-20160429-clicked';
+
+function onClickStudioSurvey() {
+  localStorage.setItem(STUDIO_SURVEY_CLICKED, 'true');
+  $("#studio-survey-button").fadeOut();
+}
+
+function showStudioSurveyButton() {
+  if (localStorage.getItem(STUDIO_SURVEY_CLICKED) == null) {
+    $("#studio-survey-button").show();
+  }
+}
\ No newline at end of file
diff --git a/tools/droiddoc/templates-sdk/components/masthead.cs b/tools/droiddoc/templates-sdk/components/masthead.cs
index e17612d..63dc829 100644
--- a/tools/droiddoc/templates-sdk/components/masthead.cs
+++ b/tools/droiddoc/templates-sdk/components/masthead.cs
@@ -86,7 +86,13 @@
           <span class="dac-sprite dac-google-play"></span>
           <span class="dac-visible-desktop-inline">Developer</span>
           Console
-        </a><?cs /if ?>
+        </a>
+        <a class="dac-header-console-btn" id="studio-survey-button"
+          href="http://goo.gl/forms/dOQUuzwBsX"
+          onclick="onClickStudioSurvey()"
+          target="_blank" style="background:#FFE0B2;display:none"
+        >Take a 1 min survey</a>
+        <?cs /if ?>
 
       </div><!-- end header-wrap.wrap -->
     </div><!-- end header -->
diff --git a/tools/droiddoc/templates-sdk/sdkpage.cs b/tools/droiddoc/templates-sdk/sdkpage.cs
index 646eeda..c6679a6 100644
--- a/tools/droiddoc/templates-sdk/sdkpage.cs
+++ b/tools/droiddoc/templates-sdk/sdkpage.cs
@@ -256,168 +256,7 @@
 <?cs call:tag_list(root.descr) ?>
 
 
-<section id="downloads" class="dac-section dac-small">
-<div class="wrap">
-
-<h2 class="norule">Start using Android Studio today</h2>
-
-<p>Android Studio includes all the tools you need to build apps for Android.</p>
-
-<div style="float:left;margin-right:40px;width:auto;">
-<p>
-  <a class="landing-button green download-bundle-button"
-    data-modal-toggle="studio_tos">Download Android Studio<br>
-  <span class="small"></span></a>
-</p>
-</div>
-
-<div style="float:left;width:auto;margin-bottom:40px">
-<ul class="nolist" style="text-transform: uppercase;margin:8px 0">
-<li>Version: <?cs var:studio.version ?></li>
-<li>Release date: <?cs var:studio.release.date ?></li>
-</ul>
-</div>
-
-
-
-<h4 style="clear:left;margin-top:40px">Select a different platform</h4>
-
-  <table class="download">
-    <tr>
-      <th>Platform</th>
-      <th>Android Studio package</th>
-      <th>Size</th>
-      <th>SHA-1 checksum</th>
-  </tr>
-  <tr>
-    <td rowspan="3">Windows</td>
-    <td>
-  <a onclick="return onDownload(this,false,true)" id="win-bundle" data-modal-toggle="studio_tos"
-    href="//dl.google.com/dl/android/studio/install/<?cs var:studio.version ?>/<?cs var:studio.win_bundle_exe_download ?>"
-    ><?cs var:studio.win_bundle_exe_download ?></a><br>
-    Includes Android SDK <b>(recommended)</b>
-    </td>
-    <td id="win-bundle-size"><?cs call:size_in_mb(studio.win_bundle_exe_bytes) ?> MB
-      <br>(<?cs var:studio.win_bundle_exe_bytes ?> bytes)</td>
-    <td><?cs var:studio.win_bundle_exe_checksum ?></td>
-  </tr>
-  <tr>
-    <!-- blank TD from Windows rowspan -->
-    <td>
-  <a onclick="return onDownload(this,false,true)" id="win-bundle-notools" data-modal-toggle="studio_tos"
-    href="https://dl.google.com/dl/android/studio/install/<?cs var:studio.version ?>/<?cs var:studio.win_notools_exe_download ?>"
-    ><?cs var:studio.win_notools_exe_download ?></a><br>
-    No Android SDK
-    </td>
-    <td><?cs call:size_in_mb(studio.win_notools_exe_bytes) ?> MB
-      <br>(<?cs var:studio.win_notools_exe_bytes ?> bytes)</td>
-    <td><?cs var:studio.win_notools_exe_checksum ?></td>
-  </tr>
-  <tr>
-    <!-- blank TD from Windows rowspan -->
-    <td>
-  <a onclick="return onDownload(this,false,true)" id="win-bundle-zip" data-modal-toggle="studio_tos"
-    href="https://dl.google.com/dl/android/studio/ide-zips/<?cs var:studio.version ?>/<?cs var:studio.win_bundle_download ?>"
-    ><?cs var:studio.win_bundle_download ?></a><br>
-    No Android SDK, no installer
-    </td>
-    <td><?cs call:size_in_mb(studio.win_bundle_bytes) ?> MB
-      <br>(<?cs var:studio.win_bundle_bytes ?> bytes)</td>
-    <td><?cs var:studio.win_bundle_checksum ?></td>
-  </tr>
-  <tr>
-    <td><nobr>Mac OS X</nobr></td>
-    <td>
-  <a onclick="return onDownload(this,false,true)" id="mac-bundle" data-modal-toggle="studio_tos"
-    href="//dl.google.com/dl/android/studio/install/<?cs var:studio.version ?>/<?cs var:studio.mac_bundle_download ?>"
-    ><?cs var:studio.mac_bundle_download ?></a>
-    </td>
-    <td id="mac-bundle-size"><?cs call:size_in_mb(studio.mac_bundle_bytes) ?> MB
-      <br>(<?cs var:studio.mac_bundle_bytes ?> bytes)</td>
-    <td><?cs var:studio.mac_bundle_checksum ?></td>
-  </tr>
-  <tr>
-    <td>Linux</td>
-    <td>
-  <a onclick="return onDownload(this,false,true)" id="linux-bundle" data-modal-toggle="studio_tos"
-    href="//dl.google.com/dl/android/studio/ide-zips/<?cs var:studio.version ?>/<?cs var:studio.linux_bundle_download ?>"
-    ><?cs var:studio.linux_bundle_download ?></a>
-    </td>
-    <td id="linux-bundle-size"><?cs call:size_in_mb(studio.linux_bundle_bytes) ?> MB
-      <br>(<?cs var:studio.linux_bundle_bytes ?> bytes)</td>
-    <td><?cs var:studio.linux_bundle_checksum ?></td>
-  </tr>
-  </table>
-
-
-
-<h4 class="norule" style="margin-top:40px">Get just the command line tools</h4>
-
-<p>If you do not need Android Studio, you can download the basic Android
-command line tools below.</p>
-
-  <table class="download">
-    <tr>
-      <th>Platform</th>
-      <th>SDK tools package</th>
-      <th>Size</th>
-      <th>SHA-1 checksum</th>
-  </tr>
-  <tr>
-    <td rowspan="2">Windows</td>
-    <td>
-  <a onclick="return onDownload(this)" id="win-tools" data-modal-toggle="studio_tos"
-    href="//dl.google.com/android/<?cs
-var:sdk.win_installer
-?>"><?cs var:sdk.win_installer ?></a><br>
-    </td>
-    <td><?cs call:size_in_mb(sdk.win_installer_bytes) ?> MB
-      <br>(<?cs var:sdk.win_installer_bytes ?> bytes)</td>
-    <td><?cs var:sdk.win_installer_checksum ?></td>
-  </tr>
-  <tr>
-    <!-- blank TD from Windows rowspan -->
-    <td>
-  <a onclick="return onDownload(this)" id="win-tools2" data-modal-toggle="studio_tos"
-    href="//dl.google.com/android/<?cs var:sdk.win_download
-?>"><?cs var:sdk.win_download ?></a><br>
-    No installer
-    </td>
-    <td><?cs call:size_in_mb(sdk.win_bytes) ?> MB
-      <br>(<?cs var:sdk.win_bytes ?> bytes)</td>
-    <td><?cs var:sdk.win_checksum ?></td>
-  </tr>
-  <tr>
-    <td><nobr>Mac OS X</nobr></td>
-    <td>
-  <a onclick="return onDownload(this)" id="mac-tools" data-modal-toggle="studio_tos"
-    href="//dl.google.com/android/<?cs
-var:sdk.mac_download
-?>"><?cs var:sdk.mac_download ?></a>
-    </td>
-    <td><?cs call:size_in_mb(sdk.mac_bytes) ?> MB
-      <br>(<?cs var:sdk.mac_bytes ?> bytes)</td>
-    <td><?cs var:sdk.mac_checksum ?></td>
-  </tr>
-  <tr>
-    <td>Linux</td>
-    <td>
-  <a onclick="return onDownload(this)" id="linux-tools" data-modal-toggle="studio_tos"
-    href="//dl.google.com/android/<?cs
-var:sdk.linux_download
-?>"><?cs var:sdk.linux_download ?></a>
-    </td>
-    <td><?cs call:size_in_mb(sdk.linux_bytes) ?> MB
-      <br>(<?cs var:sdk.linux_bytes ?> bytes)</td>
-    <td><?cs var:sdk.linux_checksum ?></td>
-  </tr>
-  </table>
-  <p>
-Also see the <a href="<?cs var:toroot ?>tools/sdk/tools-notes.html">SDK
-tools release notes</a>.</p>
-
-  </div><!-- end wrap -->
-  </section>
+<?cs #######  TODO: Remove this whole file from processing. ######## ?>
 
 
 <?cs ########  The Android Studio version of the download script ######### ?>
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py
index 9a866f5..1dc048f 100644
--- a/tools/releasetools/common.py
+++ b/tools/releasetools/common.py
@@ -182,6 +182,21 @@
       d["ramdisk_fs_config"] = os.path.join(
           input_dir, "META", "root_filesystem_config.txt")
 
+    # Redirect {system,vendor}_base_fs_file.
+    if "system_base_fs_file" in d:
+      basename = os.path.basename(d["system_base_fs_file"])
+      system_base_fs_file = os.path.join(input_dir, "META", basename)
+      assert os.path.exists(system_base_fs_file), \
+          "failed to find system base fs file: %s" % (system_base_fs_file,)
+      d["system_base_fs_file"] = system_base_fs_file
+
+    if "vendor_base_fs_file" in d:
+      basename = os.path.basename(d["vendor_base_fs_file"])
+      vendor_base_fs_file = os.path.join(input_dir, "META", basename)
+      assert os.path.exists(vendor_base_fs_file), \
+          "failed to find vendor base fs file: %s" % (vendor_base_fs_file,)
+      d["vendor_base_fs_file"] = vendor_base_fs_file
+
   try:
     data = read_helper("META/imagesizes.txt")
     for line in data.split("\n"):