Merge "Revert "Call aapt2 link with argument-list"" into nyc-dev
diff --git a/core/Makefile b/core/Makefile
index 7950501..ccd17e3 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))
diff --git a/core/binary.mk b/core/binary.mk
index 491d94c..918a28d 100644
--- a/core/binary.mk
+++ b/core/binary.mk
@@ -791,6 +791,38 @@
 endif  # $(aidl_src) non-empty
 
 ###########################################################
+## Compile the .vts files to .cc (or .c) and then to .o
+###########################################################
+
+vts_src := $(strip $(filter %.vts,$(my_src_files)))
+vts_gen_cpp :=
+ifneq ($(vts_src),)
+
+# Use the intermediates directory to avoid writing our own .cpp -> .o rules.
+vts_gen_cpp_root := $(intermediates)/vts-generated/src
+vts_gen_include_root := $(intermediates)/vts-generated/include
+
+# Multi-architecture builds have distinct intermediates directories.
+# Thus we'll actually generate source for each architecture.
+$(foreach s,$(vts_src),\
+    $(eval $(call define-vts-cpp-rule,$(s),$(vts_gen_cpp_root),vts_gen_cpp)))
+$(foreach cpp,$(vts_gen_cpp), \
+    $(call include-depfile,$(addsuffix .vts.P,$(basename $(cpp))),$(cpp)))
+$(call track-src-file-gen,$(vts_src),$(vts_gen_cpp))
+
+$(vts_gen_cpp) : PRIVATE_MODULE := $(LOCAL_MODULE)
+$(vts_gen_cpp) : PRIVATE_HEADER_OUTPUT_DIR := $(vts_gen_include_root)
+$(vts_gen_cpp) : PRIVATE_VTS_FLAGS := $(addprefix -I,$(LOCAL_VTS_INCLUDES))
+
+# Add generated headers to include paths.
+my_c_includes += $(vts_gen_include_root)
+my_export_c_include_dirs += $(vts_gen_include_root)
+# Pick up the generated C++ files later for transformation to .o files.
+my_generated_sources += $(vts_gen_cpp)
+
+endif  # $(vts_src) non-empty
+
+###########################################################
 ## YACC: Compile .y/.yy files to .c/.cpp and then to .o.
 ###########################################################
 
@@ -1392,7 +1424,7 @@
 # Similarly, the generated DBus headers need to exist before we export their location.
 # People are not going to consume the aidl generated cpp file, but the cpp file is
 # generated after the headers, so this is a convenient way to ensure the headers exist.
-$(export_includes) : $(LOCAL_MODULE_MAKEFILE_DEP) $(proto_generated_headers) $(dbus_generated_headers) $(aidl_gen_cpp)
+$(export_includes) : $(LOCAL_MODULE_MAKEFILE_DEP) $(proto_generated_headers) $(dbus_generated_headers) $(aidl_gen_cpp) $(vts_gen_cpp)
 	@echo Export includes file: $< -- $@
 	$(hide) mkdir -p $(dir $@) && rm -f $@.tmp
 ifdef my_export_c_include_dirs
diff --git a/core/clear_vars.mk b/core/clear_vars.mk
index 7473a73..59e907b 100644
--- a/core/clear_vars.mk
+++ b/core/clear_vars.mk
@@ -105,6 +105,7 @@
 LOCAL_RES_LIBRARIES:=
 LOCAL_MANIFEST_INSTRUMENTATION_FOR:=
 LOCAL_AIDL_INCLUDES:=
+LOCAL_VTS_INCLUDES:=
 LOCAL_JARJAR_RULES:=
 LOCAL_ADDITIONAL_JAVA_DIR:=
 LOCAL_ALLOW_UNDEFINED_SYMBOLS:=
@@ -142,6 +143,7 @@
 LOCAL_PROTOC_OPTIMIZE_TYPE:= # lite(default),micro,nano,full,nanopb-c,nanopb-c-enable_malloc
 LOCAL_PROTOC_FLAGS:=
 LOCAL_PROTO_JAVA_OUTPUT_PARAMS:=
+LOCAL_VTSC_FLAGS:=
 LOCAL_NO_CRT:=
 LOCAL_NO_LIBGCC:=
 LOCAL_PROPRIETARY_MODULE:=
diff --git a/core/config.mk b/core/config.mk
index c892995..94c880f 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -519,6 +519,7 @@
 BREAKPAD_GENERATE_SYMBOLS := false
 endif
 PROTOC := $(HOST_OUT_EXECUTABLES)/aprotoc$(HOST_EXECUTABLE_SUFFIX)
+VTSC := $(HOST_OUT_EXECUTABLES)/vtsc$(HOST_EXECUTABLE_SUFFIX)
 DBUS_GENERATOR := $(HOST_OUT_EXECUTABLES)/dbus-binding-generator
 MKBOOTFS := $(HOST_OUT_EXECUTABLES)/mkbootfs$(HOST_EXECUTABLE_SUFFIX)
 MINIGZIP := $(HOST_OUT_EXECUTABLES)/minigzip$(HOST_EXECUTABLE_SUFFIX)
diff --git a/core/definitions.mk b/core/definitions.mk
index 9aca9fd..34b9385 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -320,6 +320,24 @@
 endef
 
 ###########################################################
+## Find all files named "*.vts" under the named directories,
+## which must be relative to $(LOCAL_PATH).  The returned list
+## is relative to $(LOCAL_PATH).
+###########################################################
+
+define all-vts-files-under
+$(call all-named-files-under,*.vts,$(1))
+endef
+
+###########################################################
+## Find all of the "*.vts" files under $(LOCAL_PATH).
+###########################################################
+
+define all-subdir-vts-files
+$(call all-vts-files-under,.)
+endef
+
+###########################################################
 ## Find all of the logtags files under the named directories.
 ## Meant to be used like:
 ##    SRC_FILES := $(call all-logtags-files-under,src)
@@ -1087,6 +1105,31 @@
 endef
 
 ###########################################################
+## Commands for running vts
+###########################################################
+
+define transform-vts-to-cpp
+@mkdir -p $(dir $@)
+@mkdir -p $(PRIVATE_HEADER_OUTPUT_DIR)
+@echo "Generating C++ from VTS: $(PRIVATE_MODULE) <= $<"
+$(hide) $(VTSC) -d$(basename $@).vts.P $(PRIVATE_VTS_FLAGS) \
+    $< $(PRIVATE_HEADER_OUTPUT_DIR) $@
+endef
+
+## Given a .vts file path generate the rule to compile it a .cpp file.
+# $(1): a .vts source file
+# $(2): a directory to place the generated .cpp files in
+# $(3): name of a variable to add the path to the generated source file to
+#
+# You must call this with $(eval).
+define define-vts-cpp-rule
+define-vts-cpp-rule-src := $(patsubst %.vts,%$(LOCAL_CPP_EXTENSION),$(subst ../,dotdot/,$(addprefix $(2)/,$(1))))
+$$(define-vts-cpp-rule-src) : $(LOCAL_PATH)/$(1) $(VTSC)
+	$$(transform-vts-to-cpp)
+$(3) += $$(define-vts-cpp-rule-src)
+endef
+
+###########################################################
 ## Commands for running java-event-log-tags.py
 ###########################################################
 
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/tasks/old-cts.mk b/core/tasks/old-cts.mk
index 904f5b2..70a6394 100644
--- a/core/tasks/old-cts.mk
+++ b/core/tasks/old-cts.mk
@@ -65,7 +65,9 @@
 
 CTS_TEST_JAR_LIST := \
 	cts-junit \
-	CtsJdwp
+	CtsJdwp \
+	cts-testng \
+	CtsLibcoreOj
 
 # Depend on the full package paths rather than the phony targets to avoid
 # rebuilding the packages every time.
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/envsetup.sh b/envsetup.sh
index 8153224..35df2d5 100644
--- a/envsetup.sh
+++ b/envsetup.sh
@@ -1132,7 +1132,7 @@
     Darwin)
         function sgrep()
         {
-            find -E . -name .repo -prune -o -name .git -prune -o  -type f -iregex '.*\.(c|h|cc|cpp|S|java|xml|sh|mk|aidl)' \
+            find -E . -name .repo -prune -o -name .git -prune -o  -type f -iregex '.*\.(c|h|cc|cpp|S|java|xml|sh|mk|aidl|vts)' \
                 -exec grep --color -n "$@" {} +
         }
 
@@ -1140,7 +1140,7 @@
     *)
         function sgrep()
         {
-            find . -name .repo -prune -o -name .git -prune -o  -type f -iregex '.*\.\(c\|h\|cc\|cpp\|S\|java\|xml\|sh\|mk\|aidl\)' \
+            find . -name .repo -prune -o -name .git -prune -o  -type f -iregex '.*\.\(c\|h\|cc\|cpp\|S\|java\|xml\|sh\|mk\|aidl\|vts\)' \
                 -exec grep --color -n "$@" {} +
         }
         ;;
diff --git a/target/product/runtime_libart.mk b/target/product/runtime_libart.mk
index ffc698d..5fd4d7e 100644
--- a/target/product/runtime_libart.mk
+++ b/target/product/runtime_libart.mk
@@ -35,6 +35,7 @@
     ext \
     hprof-conv \
     libart \
+    libart_fake \
     libcrypto \
     libexpat \
     libicui18n \
diff --git a/tools/droiddoc/templates-sdk-dev/assets/css/default.css b/tools/droiddoc/templates-sdk-dev/assets/css/default.css
index 6fef241..43449d4 100644
--- a/tools/droiddoc/templates-sdk-dev/assets/css/default.css
+++ b/tools/droiddoc/templates-sdk-dev/assets/css/default.css
@@ -6632,15 +6632,18 @@
   transition: opacity 200ms linear 200ms;
 }
 
-@media (min-width: 720px) and (max-width: 979px) {
+@media (min-width: 720px) {
   .dac-header-tabs {
     display: inline-block;
   }
-}
 
-@media (min-width: 980px) {
-  .dac-header-tabs {
-    display: inline-block;
+  /* Do not show nav toggle and up-nav button for left nav
+     in Studio docs, when header tabs are visible */
+  body.studio .dac-nav-back-button {
+    display:none;
+  }
+  body.studio .dac-nav-sub {
+    top: 0 !important;
   }
 }
 
@@ -6754,6 +6757,10 @@
   display: inline-block;
 }
 
+body.studio .dac-header-crumbs {
+  display:none;
+}
+
 .dac-header-crumbs.dac-has-content {
   opacity: 1;
 }
@@ -7398,6 +7405,21 @@
   .dac-nav-open #body-content {
     padding-left: 250px;
   }
+
+  /* Do not show nav toggle for Studio on large screens */
+  body.studio .dac-nav-toggle {
+    display:none;
+  }
+  body.studio .dac-header-logo {
+    padding-left:20px;
+  }
+  /* And if the page has no subcomponent, don't show left nav at all */
+  body.studio.None .dac-nav {
+    display: none;
+  }
+  body.studio.None #body-content {
+    padding-left:0;
+  }
 }
 
 .dac-nav-open {
diff --git a/tools/droiddoc/templates-sdk-dev/head_tag.cs b/tools/droiddoc/templates-sdk-dev/head_tag.cs
index 4088a57..549311d 100644
--- a/tools/droiddoc/templates-sdk-dev/head_tag.cs
+++ b/tools/droiddoc/templates-sdk-dev/head_tag.cs
@@ -17,6 +17,7 @@
       if:ndk ?><?cs
         if:guide ?>guide<?cs
         elif:samples ?>samples<?cs
+          if:(samplesDocPage&&!samplesProjectIndex) ?> samples-docpage<?cs /if ?><?cs
         elif:reference ?>reference<?cs
         elif:downloads ?>downloads<?cs
         else ?>none<?cs set:dac_subcategory_set = #0 ?><?cs /if ?><?cs
@@ -30,6 +31,7 @@
           elif:tools ?>tools<?cs
           elif:sdk ?>sdk<?cs
           elif:samples ?>samples<?cs
+            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:(distribute||googleplay||essentials||users||engage||monetize||disttools||stories||analyze) ?><?cs
@@ -127,7 +129,7 @@
 <title><?cs
 if:devsite ?><?cs
   if:page.title ?><?cs
-    var:page.title ?><?cs
+    var:html_strip(page.title) ?><?cs
   else ?>Android Developers<?cs
   /if ?><?cs
 else ?><?cs
diff --git a/tools/droiddoc/templates-sdk-dev/samples_navtree_data.cs b/tools/droiddoc/templates-sdk-dev/samples_navtree_data.cs
index 24ac7b7..b9b4214 100644
--- a/tools/droiddoc/templates-sdk-dev/samples_navtree_data.cs
+++ b/tools/droiddoc/templates-sdk-dev/samples_navtree_data.cs
@@ -1,3 +1,8 @@
-var SAMPLES_NAVTREE_DATA =
-<?cs var:reference_tree ?>
-;
+toc:
+- title: About the Samples
+  path: /samples/index.html
+
+- title: What's New
+  path: /samples/new/index.html
+
+<?cs var:samples_toc_tree ?>
\ No newline at end of file
diff --git a/tools/droiddoc/templates-sdk-dev/sdkpage.cs b/tools/droiddoc/templates-sdk-dev/sdkpage.cs
index 30d6d04..b0c4d39 100644
--- a/tools/droiddoc/templates-sdk-dev/sdkpage.cs
+++ b/tools/droiddoc/templates-sdk-dev/sdkpage.cs
@@ -46,7 +46,7 @@
 #
 ?>
 
-<?cs if:header.hide ?><?cs else ?>
+<?cs if:(header.hide||devsite)?><?cs else ?>
 <h1 itemprop="name"><?cs var:page.title ?></h1>
 <?cs /if ?>
   <div id="jd-content" itemprop="description">
@@ -295,7 +295,7 @@
   <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 Windows installer (recommended)
+    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>
@@ -304,28 +304,28 @@
   <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 Windows 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>
-    <!-- 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>
-    Includes Windows installer but no SDK tools
+    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"
@@ -351,10 +351,10 @@
 
 
 
-<h4 class="norule" style="margin-top:40px">Get just the SDK tools</h4>
+<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 SDK tools below.</p>
+<p>If you do not need Android Studio, you can download the basic Android
+command line tools below.</p>
 
   <table class="download">
     <tr>
@@ -370,7 +370,6 @@
     href="//dl.google.com/android/<?cs
 var:sdk.win_installer
 ?>"><?cs var:sdk.win_installer ?></a><br>
-    Includes Windows installer
     </td>
     <td><?cs call:size_in_mb(sdk.win_installer_bytes) ?> MB
       <br>(<?cs var:sdk.win_installer_bytes ?> bytes)</td>
@@ -382,7 +381,7 @@
   <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 Windows installer
+    No installer
     </td>
     <td><?cs call:size_in_mb(sdk.win_bytes) ?> MB
       <br>(<?cs var:sdk.win_bytes ?> bytes)</td>
@@ -575,7 +574,7 @@
 
 </div><!-- end jd-content -->
 
-<?cs if:!sdk.redirect ?>
+<?cs if:!sdk.redirect && !devsite ?>
 <?cs include:"footer.cs" ?>
 <?cs /if ?>
 
@@ -600,6 +599,3 @@
 <!-- End of Tag -->
 </body>
 </html>
-
-
-
diff --git a/tools/droiddoc/templates-sdk/assets/js/docs.js b/tools/droiddoc/templates-sdk/assets/js/docs.js
index c4a8150..ee3ebee 100644
--- a/tools/droiddoc/templates-sdk/assets/js/docs.js
+++ b/tools/droiddoc/templates-sdk/assets/js/docs.js
@@ -2546,7 +2546,7 @@
 }
 
 function submit_search() {
-  var query = document.getElementById('search_autocomplete').value;
+  var query = escapeHTML(document.getElementById('search_autocomplete').value);
   location.hash = 'q=' + query;
   searchControl.query = query;
   searchControl.init();
@@ -2617,7 +2617,7 @@
   this.searchInputEl_.keyup(this.debounce_(function(e) {
     var code = e.which;
     if (code != 13) {
-      this.query = this.searchInputEl_.val();
+      this.query = escapeHTML(this.searchInputEl_.val());
       location.hash = 'q=' + encodeURI(this.query);
       this.searchResultEl_.empty();
       this.getResults_();
@@ -2800,7 +2800,7 @@
     return;
   } else {
     // first time loading search results for this page
-    searchControl.query = decodeURI(location.hash.split('q=')[1]);
+    searchControl.query = escapeHTML(decodeURI(location.hash.split('q=')[1]));
     searchControl.init();
     searchControl.trackSearchRequest(searchControl.query);
     $('#searchResults').slideDown('slow', setStickyTop);
diff --git a/tools/droiddoc/templates-sdk/sdkpage.cs b/tools/droiddoc/templates-sdk/sdkpage.cs
index d4b0af2..646eeda 100644
--- a/tools/droiddoc/templates-sdk/sdkpage.cs
+++ b/tools/droiddoc/templates-sdk/sdkpage.cs
@@ -266,7 +266,7 @@
 <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>
+    data-modal-toggle="studio_tos">Download Android Studio<br>
   <span class="small"></span></a>
 </p>
 </div>
@@ -295,7 +295,7 @@
   <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 Windows installer (recommended)
+    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>
@@ -304,28 +304,28 @@
   <tr>
     <!-- blank TD from Windows rowspan -->
     <td>
-  <a onclick="return onDownload(this,false,true)" id="win-bundle-zip" data-modal-toggle="studio_tos"
-    href="//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 Windows 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>
-    <!-- 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>
-    Includes Windows installer but no SDK tools
+    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"
@@ -351,10 +351,10 @@
 
 
 
-<h4 class="norule" style="margin-top:40px">Get just the SDK tools</h4>
+<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 SDK tools below.</p>
+<p>If you do not need Android Studio, you can download the basic Android
+command line tools below.</p>
 
   <table class="download">
     <tr>
@@ -370,7 +370,6 @@
     href="//dl.google.com/android/<?cs
 var:sdk.win_installer
 ?>"><?cs var:sdk.win_installer ?></a><br>
-    Includes Windows installer
     </td>
     <td><?cs call:size_in_mb(sdk.win_installer_bytes) ?> MB
       <br>(<?cs var:sdk.win_installer_bytes ?> bytes)</td>
@@ -382,7 +381,7 @@
   <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 Windows installer
+    No installer
     </td>
     <td><?cs call:size_in_mb(sdk.win_bytes) ?> MB
       <br>(<?cs var:sdk.win_bytes ?> bytes)</td>
diff --git a/tools/releasetools/target_files_diff.py b/tools/releasetools/target_files_diff.py
index 196d2e8..0f717e0 100755
--- a/tools/releasetools/target_files_diff.py
+++ b/tools/releasetools/target_files_diff.py
@@ -172,17 +172,16 @@
       continue
 
     if entry in list2:
-      if os.path.islink(name1):
-        if os.path.islink(name2):
-          link1 = os.readlink(name1)
-          link2 = os.readlink(name2)
-          if link1 != link2:
-            print("%s: Symlinks differ: %s vs %s" % (name, link1, link2),
-                  file=out_file)
-        else:
-          print("%s: File types differ, skipping compare" % name,
+      if os.path.islink(name1) and os.path.islink(name2):
+        link1 = os.readlink(name1)
+        link2 = os.readlink(name2)
+        if link1 != link2:
+          print("%s: Symlinks differ: %s vs %s" % (name, link1, link2),
                 file=out_file)
         continue
+      elif os.path.islink(name1) or os.path.islink(name2):
+        print("%s: File types differ, skipping compare" % name, file=out_file)
+        continue
 
       stat1 = os.stat(name1)
       stat2 = os.stat(name2)