Reconcile with jb-mr2-release jb-mr2-zeroday-release jb-mr2-zeroday-deb-release - do not merge

Change-Id: I80fa0805a168773ba273726fb4827b6cc24bfb08
diff --git a/core/Makefile b/core/Makefile
index 55ab6a5..eb02ff4 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -190,9 +190,14 @@
 			TARGET_CPU_ABI2="$(TARGET_CPU_ABI2)" \
 			TARGET_AAPT_CHARACTERISTICS="$(TARGET_AAPT_CHARACTERISTICS)" \
 	        bash $(BUILDINFO_SH) > $@
-	$(hide) if [ -f "$(system_prop_file)" ]; then \
-	          cat $(system_prop_file) >> $@; \
-	        fi
+	$(hide) $(foreach file,$(system_prop_file), \
+		if [ -f "$(file)" ]; then \
+			echo "#" >> $@; \
+			echo Target buildinfo from: "$(file)"; \
+			echo "# from $(file)" >> $@; \
+			echo "#" >> $@; \
+			cat $(file) >> $@; \
+		fi;)
 	$(if $(ADDITIONAL_BUILD_PROPERTIES), \
 		$(hide) echo >> $@; \
 		        echo "#" >> $@; \
diff --git a/core/base_rules.mk b/core/base_rules.mk
index 188c352..f6497da 100644
--- a/core/base_rules.mk
+++ b/core/base_rules.mk
@@ -264,6 +264,7 @@
   endif
 endif
 $(proto_java_sources_file_stamp): PRIVATE_PROTOC_FLAGS := $(LOCAL_PROTOC_FLAGS)
+$(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_PARAMS := $(LOCAL_PROTO_JAVA_OUTPUT_PARAMS)
 $(proto_java_sources_file_stamp) : $(proto_sources_fullpath) $(PROTOC)
 	$(call transform-proto-to-java)
 
@@ -529,7 +530,7 @@
 ifdef LOCAL_DEX_PREOPT
 installed_odex := $(basename $(LOCAL_INSTALLED_MODULE)).odex
 built_odex := $(basename $(LOCAL_BUILT_MODULE)).odex
-$(installed_odex) : $(built_odex) | $(ACP)
+$(installed_odex) : $(built_odex) $(LOCAL_BUILT_MODULE) | $(ACP)
 	@echo "Install: $@"
 	$(copy-file-to-target)
 
diff --git a/core/build_id.mk b/core/build_id.mk
index 61186ed..e954794 100644
--- a/core/build_id.mk
+++ b/core/build_id.mk
@@ -13,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 := OPENMASTER
 
-export BUILD_ID=JLS36B
+# DISPLAY_BUILD_NUMBER should only be set for development branches,
+# If set, the BUILD_NUMBER (cl) is appended to the BUILD_ID for
+# a more descriptive BUILD_ID_DISPLAY, otherwise BUILD_ID_DISPLAY
+# is the same as BUILD_ID
+DISPLAY_BUILD_NUMBER := true
diff --git a/core/clear_vars.mk b/core/clear_vars.mk
index 8d84814..7ad58b2 100644
--- a/core/clear_vars.mk
+++ b/core/clear_vars.mk
@@ -120,6 +120,7 @@
 LOCAL_DEX_PREOPT:= # '',true,false,nostripping
 LOCAL_PROTOC_OPTIMIZE_TYPE:= # lite(default),micro,nano,full
 LOCAL_PROTOC_FLAGS:=
+LOCAL_PROTO_JAVA_OUTPUT_PARAMS:=
 LOCAL_NO_CRT:=
 LOCAL_PROPRIETARY_MODULE:=
 LOCAL_MODULE_OWNER:=
diff --git a/core/combo/TARGET_linux-arm.mk b/core/combo/TARGET_linux-arm.mk
index 371ba96..8fc39e9 100644
--- a/core/combo/TARGET_linux-arm.mk
+++ b/core/combo/TARGET_linux-arm.mk
@@ -101,7 +101,7 @@
 			-fstack-protector \
 			-Wa,--noexecstack \
 			-Werror=format-security \
-			-D_FORTIFY_SOURCE=1 \
+			-D_FORTIFY_SOURCE=2 \
 			-fno-short-enums \
 			$(arch_variant_cflags)
 
diff --git a/core/combo/TARGET_linux-mips.mk b/core/combo/TARGET_linux-mips.mk
index 83fe657..c878ae5 100644
--- a/core/combo/TARGET_linux-mips.mk
+++ b/core/combo/TARGET_linux-mips.mk
@@ -89,7 +89,7 @@
 			-funwind-tables \
 			-Wa,--noexecstack \
 			-Werror=format-security \
-			-D_FORTIFY_SOURCE=1 \
+			-D_FORTIFY_SOURCE=2 \
 			$(arch_variant_cflags)
 
 android_config_h := $(call select-android-config-h,linux-mips)
diff --git a/core/combo/TARGET_linux-x86.mk b/core/combo/TARGET_linux-x86.mk
index 04531b2..5c9a76b 100644
--- a/core/combo/TARGET_linux-x86.mk
+++ b/core/combo/TARGET_linux-x86.mk
@@ -90,7 +90,7 @@
 			-Ulinux \
 			-Wa,--noexecstack \
 			-Werror=format-security \
-			-D_FORTIFY_SOURCE=1 \
+			-D_FORTIFY_SOURCE=2 \
 			-Wstrict-aliasing=2 \
 			-fPIC -fPIE \
 			-ffunction-sections \
diff --git a/core/combo/arch/mips/mips32r2-fp-xburst.mk b/core/combo/arch/mips/mips32r2-fp-xburst.mk
new file mode 100644
index 0000000..fee9cb3
--- /dev/null
+++ b/core/combo/arch/mips/mips32r2-fp-xburst.mk
@@ -0,0 +1,16 @@
+# Configuration for Android on Ingenic xb4780/Xburst MIPS CPU.
+# Generating binaries for MIPS32R2/hard-float/little-endian without
+# support for the Madd family of instructions.
+
+ARCH_MIPS_HAS_FPU :=true
+ARCH_HAVE_ALIGNED_DOUBLES :=true
+arch_variant_cflags := \
+    -EL \
+    -march=mips32r2 \
+    -mtune=mips32r2 \
+    -mips32r2 \
+    -mhard-float \
+    -mno-fused-madd
+
+arch_variant_ldflags := \
+    -EL
diff --git a/core/config.mk b/core/config.mk
index e7ee49f..8872ea9 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -143,8 +143,8 @@
 board_config_mk := \
 	$(strip $(wildcard \
 		$(SRC_TARGET_DIR)/board/$(TARGET_DEVICE)/BoardConfig.mk \
-		device/*/$(TARGET_DEVICE)/BoardConfig.mk \
-		vendor/*/$(TARGET_DEVICE)/BoardConfig.mk \
+		$(shell test -d device && find device -maxdepth 4 -path '*/$(TARGET_DEVICE)/BoardConfig.mk') \
+		$(shell test -d vendor && find vendor -maxdepth 4 -path '*/$(TARGET_DEVICE)/BoardConfig.mk') \
 	))
 ifeq ($(board_config_mk),)
   $(error No config file found for TARGET_DEVICE $(TARGET_DEVICE))
diff --git a/core/definitions.mk b/core/definitions.mk
index 06437f7..3d19e72 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -892,7 +892,7 @@
 $(hide) for f in $(PRIVATE_PROTO_SRC_FILES); do \
         $(PROTOC) \
         $(addprefix --proto_path=, $(PRIVATE_PROTO_INCLUDES)) \
-        $(PRIVATE_PROTO_JAVA_OUTPUT_OPTION)=$(PRIVATE_PROTO_JAVA_OUTPUT_DIR) \
+        $(PRIVATE_PROTO_JAVA_OUTPUT_OPTION)="$(PRIVATE_PROTO_JAVA_OUTPUT_PARAMS):$(PRIVATE_PROTO_JAVA_OUTPUT_DIR)" \
         $(PRIVATE_PROTOC_FLAGS) \
         $$f || exit 33; \
         done
@@ -2151,6 +2151,9 @@
 # when requested.
 include $(BUILD_SYSTEM)/distdir.mk
 
+# Include any vendor specific definitions.mk file
+-include $(TOPDIR)vendor/*/build/core/definitions.mk
+
 # broken:
 #	$(foreach file,$^,$(if $(findstring,.a,$(suffix $file)),-l$(file),$(file)))
 
diff --git a/core/dex_preopt.mk b/core/dex_preopt.mk
index 82dd153..0c9904a 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:core-junit:bouncycastle:ext:framework:telephony-common:voip-common:mms-common:android.policy:services:apache-xml
+DEXPREOPT_BOOT_JARS := core:conscrypt:okhttp:core-junit:bouncycastle:ext:framework:telephony-common:voip-common:mms-common:android.policy:services:apache-xml
 DEXPREOPT_BOOT_JARS_MODULES := $(subst :, ,$(DEXPREOPT_BOOT_JARS))
 
 DEXPREOPT_BUILD_DIR := $(OUT_DIR)
diff --git a/core/host_java_library.mk b/core/host_java_library.mk
index cda6e10..02274e4 100644
--- a/core/host_java_library.mk
+++ b/core/host_java_library.mk
@@ -95,7 +95,7 @@
 	$(transform-classes.jar-to-dex)
 
 $(LOCAL_BUILT_MODULE): PRIVATE_DEX_FILE := $(built_dex)
-$(LOCAL_BUILT_MODULE): $(built_dex) $(java_resource_sources) | $(AAPT)
+$(LOCAL_BUILT_MODULE): $(built_dex) $(java_resource_sources)
 	@echo "Host Jar: $(PRIVATE_MODULE) ($@)"
 	$(create-empty-package)
 	$(add-dex-to-package)
diff --git a/core/llvm_config.mk b/core/llvm_config.mk
index c4b4af4..18e689e 100644
--- a/core/llvm_config.mk
+++ b/core/llvm_config.mk
@@ -64,7 +64,8 @@
     -mtune=mips32r2 \
     -march=mips32 \
     -mtune=mips32 \
-    -msynci
+    -msynci \
+    -mno-fused-madd
 endif
 ifeq ($(TARGET_ARCH),x86)
   RS_TRIPLE := i686-unknown-linux
diff --git a/core/pathmap.mk b/core/pathmap.mk
index 09f912e..7024e3e 100644
--- a/core/pathmap.mk
+++ b/core/pathmap.mk
@@ -115,7 +115,6 @@
         v7/gridlayout \
         v7/appcompat \
         v7/mediarouter \
-        v8/renderscript \
         v13
 
 #
diff --git a/core/tasks/cts.mk b/core/tasks/cts.mk
index 5b041d6..9154f32 100644
--- a/core/tasks/cts.mk
+++ b/core/tasks/cts.mk
@@ -81,13 +81,15 @@
 endef
 
 CORE_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core,,COMMON)
+CONSCRYPT_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,conscrypt,,COMMON)
 BOUNCYCASTLE_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,bouncycastle,,COMMON)
 APACHEXML_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,apache-xml,,COMMON)
+OKHTTP_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,okhttp,,COMMON)
 SQLITEJDBC_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,sqlite-jdbc,,COMMON)
 JUNIT_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-junit,,COMMON)
 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
+GEN_CLASSPATH := $(CORE_INTERMEDIATES)/classes.jar:$(CONSCRYPT_INTERMEDIATES)/classes.jar:$(BOUNCYCASTLE_INTERMEDIATES)/classes.jar:$(APACHEXML_INTERMEDIATES)/classes.jar:$(OKHTTP_INTERMEDIATES)/classes.jar:$(JUNIT_INTERMEDIATES)/classes.jar:$(SQLITEJDBC_INTERMEDIATES)/javalib.jar:$(CORETESTS_INTERMEDIATES)/javalib.jar
 
 CTS_CORE_XMLS := \
 	$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.dalvik.xml \
@@ -103,7 +105,7 @@
 # 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_CORE_XMLS): $(CTS_CORE_CASES) $(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 | $(ACP)
+$(CTS_CORE_XMLS): $(CTS_CORE_CASES) $(HOST_OUT_JAVA_LIBRARIES)/descGen.jar $(CORE_INTERMEDIATES)/javalib.jar $(BOUNCYCASTLE_INTERMEDIATES)/javalib.jar $(APACHEXML_INTERMEDIATES)/javalib.jar $(OKHTTP_INTERMEDIATES)/javalib.jar $(SQLITEJDBC_INTERMEDIATES)/javalib.jar $(JUNIT_INTERMEDIATES)/javalib.jar $(CORETESTS_INTERMEDIATES)/javalib.jar | $(ACP)
 	$(hide) mkdir -p $(CTS_TESTCASES_OUT)
 	$(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.dalvik,\
 		cts/tests/core/libcore/dalvik/AndroidManifest.xml,\
diff --git a/core/version_defaults.mk b/core/version_defaults.mk
index 5812da0..b9e1456 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 := 4.3
+  PLATFORM_VERSION := 4.3.2.1.000.000
 endif
 
 ifeq "" "$(PLATFORM_SDK_VERSION)"
diff --git a/envsetup.sh b/envsetup.sh
index 2de2375..d64bd29 100644
--- a/envsetup.sh
+++ b/envsetup.sh
@@ -1270,7 +1270,8 @@
 fi
 
 # Execute the contents of any vendorsetup.sh files we can find.
-for f in `/bin/ls vendor/*/vendorsetup.sh vendor/*/*/vendorsetup.sh device/*/*/vendorsetup.sh 2> /dev/null`
+for f in `test -d device && find device -maxdepth 4 -name 'vendorsetup.sh' 2> /dev/null` \
+         `test -d vendor && find vendor -maxdepth 4 -name 'vendorsetup.sh' 2> /dev/null`
 do
     echo "including $f"
     . $f
diff --git a/target/board/generic/BoardConfig.mk b/target/board/generic/BoardConfig.mk
index 35cbd27..3bd4f31 100644
--- a/target/board/generic/BoardConfig.mk
+++ b/target/board/generic/BoardConfig.mk
@@ -44,3 +44,11 @@
 # Build and enable the OpenGL ES View renderer. When running on the emulator,
 # the GLES renderer disables itself if host GL acceleration isn't available.
 USE_OPENGL_RENDERER := true
+
+TARGET_USERIMAGES_USE_EXT4 := true
+BOARD_SYSTEMIMAGE_PARTITION_SIZE := 576716800
+BOARD_USERDATAIMAGE_PARTITION_SIZE := 209715200
+BOARD_CACHEIMAGE_PARTITION_SIZE := 69206016
+BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE := ext4
+BOARD_FLASH_BLOCK_SIZE := 512
+TARGET_USERIMAGES_SPARSE_EXT_DISABLED := true
diff --git a/target/board/generic_mips/BoardConfig.mk b/target/board/generic_mips/BoardConfig.mk
index c3881b4..e6f43af 100644
--- a/target/board/generic_mips/BoardConfig.mk
+++ b/target/board/generic_mips/BoardConfig.mk
@@ -48,3 +48,11 @@
 # Build and enable the OpenGL ES View renderer. When running on the emulator,
 # the GLES renderer disables itself if host GL acceleration isn't available.
 USE_OPENGL_RENDERER := true
+
+TARGET_USERIMAGES_USE_EXT4 := true
+BOARD_SYSTEMIMAGE_PARTITION_SIZE := 576716800
+BOARD_USERDATAIMAGE_PARTITION_SIZE := 209715200
+BOARD_CACHEIMAGE_PARTITION_SIZE := 69206016
+BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE := ext4
+BOARD_FLASH_BLOCK_SIZE := 512
+TARGET_USERIMAGES_SPARSE_EXT_DISABLED := true
diff --git a/target/board/generic_x86/BoardConfig.mk b/target/board/generic_x86/BoardConfig.mk
index 4a9e5fe..ed7da38 100644
--- a/target/board/generic_x86/BoardConfig.mk
+++ b/target/board/generic_x86/BoardConfig.mk
@@ -33,3 +33,11 @@
 # Build and enable the OpenGL ES View renderer. When running on the emulator,
 # the GLES renderer disables itself if host GL acceleration isn't available.
 USE_OPENGL_RENDERER := true
+
+TARGET_USERIMAGES_USE_EXT4 := true
+BOARD_SYSTEMIMAGE_PARTITION_SIZE := 576716800
+BOARD_USERDATAIMAGE_PARTITION_SIZE := 209715200
+BOARD_CACHEIMAGE_PARTITION_SIZE := 69206016
+BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE := ext4
+BOARD_FLASH_BLOCK_SIZE := 512
+TARGET_USERIMAGES_SPARSE_EXT_DISABLED := true
diff --git a/target/product/base.mk b/target/product/base.mk
index 129fb2a..ebb341c 100644
--- a/target/product/base.mk
+++ b/target/product/base.mk
@@ -87,6 +87,7 @@
     netcfg \
     netd \
     ping \
+    ping6 \
     platform.xml \
     pppd \
     pm \
diff --git a/target/product/core.mk b/target/product/core.mk
index 93667fb..d503ddc 100644
--- a/target/product/core.mk
+++ b/target/product/core.mk
@@ -71,6 +71,7 @@
     libwebrtc_audio_preprocessing \
     mdnsd \
     mms-common \
+    okhttp \
     requestsync \
     telephony-common \
     voip-common
@@ -80,7 +81,9 @@
     PRODUCT_PACKAGES += \
         apache-xml-hostdex \
         bouncycastle-hostdex \
+        conscrypt-hostdex \
         core-hostdex \
+        okhttp-hostdex \
         libcrypto \
         libexpat \
         libicui18n \
diff --git a/target/product/core_minimal.mk b/target/product/core_minimal.mk
index 96a8592..4c2cdfb 100644
--- a/target/product/core_minimal.mk
+++ b/target/product/core_minimal.mk
@@ -38,6 +38,7 @@
     cacerts \
     com.android.location.provider \
     com.android.location.provider.xml \
+    conscrypt \
     core \
     core-junit \
     dalvikvm \
@@ -51,7 +52,6 @@
     ext \
     framework-res \
     hprof-conv \
-    icu.dat \
     installd \
     ip \
     ip-up-vpn \
diff --git a/target/product/generic_no_telephony.mk b/target/product/generic_no_telephony.mk
index 18991b0..2c71ed5 100644
--- a/target/product/generic_no_telephony.mk
+++ b/target/product/generic_no_telephony.mk
@@ -58,9 +58,6 @@
     wpa_supplicant
 
 PRODUCT_PACKAGES += \
-    icu.dat
-
-PRODUCT_PACKAGES += \
     librs_jni \
     libvideoeditor_jni \
     libvideoeditor_core \
diff --git a/target/product/mini.mk b/target/product/mini.mk
index 67ef4fd..c1074f7 100644
--- a/target/product/mini.mk
+++ b/target/product/mini.mk
@@ -71,6 +71,7 @@
     cacerts \
     com.android.location.provider \
     com.android.location.provider.xml \
+    conscrypt \
     core \
     core-junit \
     dalvikvm \
@@ -84,7 +85,6 @@
     ext \
     framework-res \
     hprof-conv \
-    icu.dat \
     installd \
     ip \
     ip-up-vpn \
@@ -143,6 +143,7 @@
     libz \
     mdnsd \
     network \
+    okhttp \
     pand \
     requestsync \
     screencap \
@@ -168,10 +169,6 @@
     hostapd \
     wpa_supplicant.conf
 
-
-PRODUCT_PACKAGES += \
-    icu.dat
-
 PRODUCT_PACKAGES += \
     librs_jni \
     libvideoeditor_jni \
diff --git a/tools/droiddoc/templates-sdk/assets/css/default.css b/tools/droiddoc/templates-sdk/assets/css/default.css
index 0c12340..3bfb687 100644
--- a/tools/droiddoc/templates-sdk/assets/css/default.css
+++ b/tools/droiddoc/templates-sdk/assets/css/default.css
@@ -2664,6 +2664,10 @@
   margin:0 0 20px 20px;
   border:1px solid #ddd;
 }
+a.notice-developers.wide,
+a.notice-designers.wide {
+  width:278px;
+}
 a.notice-developers div,
 a.notice-designers div {
   min-height:40px;
diff --git a/tools/droiddoc/templates-sdk/assets/js/docs.js b/tools/droiddoc/templates-sdk/assets/js/docs.js
index ba65e44..fa7554b 100644
--- a/tools/droiddoc/templates-sdk/assets/js/docs.js
+++ b/tools/droiddoc/templates-sdk/assets/js/docs.js
@@ -11,7 +11,7 @@
 var basePath = getBaseUri(location.pathname);
 var SITE_ROOT = toRoot + basePath.substring(1,basePath.indexOf("/",1));
 var GOOGLE_DATA; // combined data for google service apis, used for search suggest
-  
+
 // Ensure that all ajax getScript() requests allow caching
 $.ajaxSetup({
   cache: true
@@ -59,10 +59,10 @@
       toggleFullscreen(false);
     }
   });
-  
+
   // initialize the divs with custom scrollbars
   $('.scroll-pane').jScrollPane( {verticalGutter:0} );
-  
+
   // add HRs below all H2s (except for a few other h2 variants)
   $('h2').not('#qv h2').not('#tb h2').not('.sidebox h2').not('#devdoc-nav h2').not('h2.norule').css({marginBottom:0}).after('<hr/>');
 
@@ -78,7 +78,7 @@
   });
 
   // Set up quicknav
-  var quicknav_open = false;  
+  var quicknav_open = false;
   $("#btn-quicknav").click(function() {
     if (quicknav_open) {
       $(this).removeClass('active');
@@ -90,20 +90,20 @@
       expand();
     }
   })
-  
+
   var expand = function() {
    $('#header-wrap').addClass('quicknav');
    $('#quicknav').stop().show().animate({opacity:'1'});
   }
-  
+
   var collapse = function() {
     $('#quicknav').stop().animate({opacity:'0'}, 100, function() {
       $(this).hide();
       $('#header-wrap').removeClass('quicknav');
     });
   }
-  
-  
+
+
   //Set up search
   $("#search_autocomplete").focus(function() {
     $("#search-container").addClass('active');
@@ -127,7 +127,7 @@
     }
   })
 
-    
+
   // prep nav expandos
   var pagePath = document.location.pathname;
   // account for intl docs by removing the intl/*/ path
@@ -183,6 +183,7 @@
         $("#nav-x li.google a").addClass("selected");
       } else {
         $("#nav-x li.reference a").addClass("selected");
+        changeApiLevel();  // turn things grey
       }
     } else if ((rootDir == "tools") || (rootDir == "sdk")) {
       $("#nav-x li.tools a").addClass("selected");
@@ -209,7 +210,7 @@
     // set up prev links
     var $prevLink = [];
     var $prevListItem = $selListItem.prev('li');
-    
+
     var crossBoundaries = ($("body.design").length > 0) || ($("body.guide").length > 0) ? true :
 false; // navigate across topic boundaries only in design docs
     if ($prevListItem.length) {
@@ -224,10 +225,10 @@
       // jump to this section's index page (if it exists)
       var $parentListItem = $selListItem.parents('li');
       $prevLink = $selListItem.parents('li').find('a');
-      
+
       // except if cross boundaries aren't allowed, and we're at the top of a section already
       // (and there's another parent)
-      if (!crossBoundaries && $parentListItem.hasClass('nav-section') 
+      if (!crossBoundaries && $parentListItem.hasClass('nav-section')
                            && $selListItem.hasClass('nav-section')) {
         $prevLink = [];
       }
@@ -238,7 +239,7 @@
     var startClass = false;
     var training = $(".next-class-link").length; // decides whether to provide "next class" link
     var isCrossingBoundary = false;
-    
+
     if ($selListItem.hasClass('nav-section')) {
       // we're on an index page, jump to the first topic
       $nextLink = $selListItem.find('ul:eq(0)').find('a:eq(0)');
@@ -251,7 +252,7 @@
         // then set the landing page "start link" text to be the first doc title
         $('.topic-start-link').text($nextLink.text().toUpperCase());
       }
-      
+
       // If the selected page has a description, then it's a class or article homepage
       if ($selListItem.find('a[description]').length) {
         // this means we're on a class landing page
@@ -273,7 +274,7 @@
     if (startClass) {
       $('.start-class-link').attr('href', $nextLink.attr('href')).removeClass("hide");
 
-      // if there's no training bar (below the start button), 
+      // if there's no training bar (below the start button),
       // then we need to add a bottom border to button
       if (!$("#tb").length) {
         $('.start-class-link').css({'border-bottom':'1px solid #DADADA'});
@@ -283,7 +284,7 @@
       $('.next-page-link').attr('href','')
                           .removeClass("hide").addClass("disabled")
                           .click(function() { return false; });
-     
+
       $('.next-class-link').attr('href',$nextLink.attr('href'))
                           .removeClass("hide").append($nextLink.html());
       $('.next-class-link').find('.new').empty();
@@ -298,7 +299,7 @@
       } else {
         $('.prev-page-link').attr('href', $prevLink.attr('href')).removeClass("hide");
       }
-    } 
+    }
 
     // If this is a training 'article', there should be no prev/next nav
     // ... if the grandparent is the "nav" ... and it has no child list items...
@@ -307,16 +308,16 @@
       $('.next-page-link,.prev-page-link').attr('href','').addClass("disabled")
                           .click(function() { return false; });
     }
-    
+
   }
-  
-  
-  
+
+
+
   // Set up the course landing pages for Training with class names and descriptions
   if ($('body.trainingcourse').length) {
     var $classLinks = $selListItem.find('ul li a').not('#nav .nav-section .nav-section ul a');
     var $classDescriptions = $classLinks.attr('description');
-    
+
     var $olClasses  = $('<ol class="class-list"></ol>');
     var $liClass;
     var $imgIcon;
@@ -328,18 +329,20 @@
       $liClass  = $('<li></li>');
       $h2Title  = $('<a class="title" href="'+$(this).attr('href')+'"><h2>' + $(this).html()+'</h2><span></span></a>');
       $pSummary = $('<p class="description">' + $(this).attr('description') + '</p>');
-      
+
       $olLessons  = $('<ol class="lesson-list"></ol>');
-      
+
       $lessons = $(this).closest('li').find('ul li a');
-      
+
       if ($lessons.length) {
-        $imgIcon = $('<img src="'+toRoot+'assets/images/resource-tutorial.png" alt=""/>');
+        $imgIcon = $('<img src="'+toRoot+'assets/images/resource-tutorial.png" '
+            + ' width="64" height="64" alt=""/>');
         $lessons.each(function(index) {
           $olLessons.append('<li><a href="'+$(this).attr('href')+'">' + $(this).html()+'</a></li>');
         });
       } else {
-        $imgIcon = $('<img src="'+toRoot+'assets/images/resource-article.png" alt=""/>');
+        $imgIcon = $('<img src="'+toRoot+'assets/images/resource-article.png" '
+            + ' width="64" height="64" alt=""/>');
         $pSummary.addClass('article');
       }
 
@@ -370,7 +373,7 @@
       // first hide all other siblings
       var $others = $('li.nav-section.expanded', $(this).closest('ul'));
       $others.removeClass('expanded').children('ul').slideUp(250);
-      
+
       // now expand me
       section.closest('li').addClass('expanded');
       section.children('ul').slideDown(250, function() {
@@ -378,7 +381,7 @@
       });
     }
   });
-  
+
   $(".scroll-pane").scroll(function(event) {
       event.preventDefault();
       return false;
@@ -410,10 +413,10 @@
       // from a scrollable div and so there's no need to make adjustments to our layout
       return;
     }
-    var scrollTop = $(window).scrollTop();    
+    var scrollTop = $(window).scrollTop();
     var headerHeight = $('#header').outerHeight();
     var subheaderHeight = $('#nav-x').outerHeight();
-    var searchResultHeight = $('#searchResults').is(":visible") ? 
+    var searchResultHeight = $('#searchResults').is(":visible") ?
                              $('#searchResults').outerHeight() : 0;
     var totalHeaderHeight = headerHeight + subheaderHeight + searchResultHeight;
     // we set the navbar fixed when the scroll position is beyond the height of the site header...
@@ -423,20 +426,20 @@
     if ($("#doc-col").height() < $("#side-nav").height()) {
       navBarShouldBeFixed = false;
     }
-   
+
     var scrollLeft = $(window).scrollLeft();
     // When the sidenav is fixed and user scrolls horizontally, reposition the sidenav to match
     if (navBarIsFixed && (scrollLeft != prevScrollLeft)) {
       updateSideNavPosition();
       prevScrollLeft = scrollLeft;
     }
-    
-    // Don't continue if the header is sufficently far away 
+
+    // Don't continue if the header is sufficently far away
     // (to avoid intensive resizing that slows scrolling)
     if (navBarIsFixed && navBarShouldBeFixed) {
       return;
     }
-    
+
     if (navBarIsFixed != navBarShouldBeFixed) {
       if (navBarShouldBeFixed) {
         // make it fixed
@@ -447,7 +450,7 @@
             .prependTo('#body-content');
         // add neato "back to top" button
         $('#devdoc-nav a.totop').css({'display':'block','width':$("#nav").innerWidth()+'px'});
-        
+
         // update the sidenaav position for side scrolling
         updateSideNavPosition();
       } else {
@@ -459,12 +462,12 @@
         $('#devdoc-nav a.totop').hide();
       }
       navBarIsFixed = navBarShouldBeFixed;
-    } 
-    
+    }
+
     resizeNav(250); // pass true in order to delay the scrollbar re-initialization for performance
   });
 
-  
+
   var navBarLeftPos;
   if ($('#devdoc-nav').length) {
     setNavBarLeftPos();
@@ -527,16 +530,16 @@
   var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
 
 
-  // Revise the sidenav widths to make room for the scrollbar 
+  // Revise the sidenav widths to make room for the scrollbar
   // which avoids the visible width from changing each time the bar appears
   var $sidenav = $("#side-nav");
   var sidenav_width = parseInt($sidenav.innerWidth());
-    
+
   $("#devdoc-nav  #nav").css("width", sidenav_width - 4 + "px"); // 4px is scrollbar width
 
 
   $(".scroll-pane").removeAttr("tabindex"); // get rid of tabindex added by jscroller
-  
+
   if ($(".scroll-pane").length > 1) {
     // Check if there's a user preference for the panel heights
     var cookieHeight = readCookie("reference_height");
@@ -544,7 +547,7 @@
       restoreHeight(cookieHeight);
     }
   }
-  
+
   resizeNav();
 
   /* init the language selector based on user cookie for lang */
@@ -591,7 +594,7 @@
     // Find this page's <li> in sidenav and set selected
     $selListItem = $selNavLink.closest('li');
     $selListItem.addClass('selected');
-    
+
     // Traverse up the tree and expand all parent nav-sections
     $selNavLink.parents('li.nav-section').each(function() {
       $(this).addClass('expanded');
@@ -637,7 +640,7 @@
   $('#devdoc-nav').css({left: -newLeft});
   $('#devdoc-nav .totop').css({left: -(newLeft - parseInt($('#side-nav').css('margin-left')))});
 }
-  
+
 
 
 
@@ -682,7 +685,7 @@
   var $nav = $("#devdoc-nav");
   var $window = $(window);
   var navHeight;
-  
+
   // Get the height of entire window and the total header height.
   // Then figure out based on scroll position whether the header is visible
   var windowHeight = $window.height();
@@ -690,12 +693,12 @@
   var headerHeight = $('#header').outerHeight();
   var subheaderHeight = $('#nav-x').outerHeight();
   var headerVisible = (scrollTop < (headerHeight + subheaderHeight));
-  
-  // get the height of space between nav and top of window. 
+
+  // get the height of space between nav and top of window.
   // Could be either margin or top position, depending on whether the nav is fixed.
-  var topMargin = (parseInt($nav.css('margin-top')) || parseInt($nav.css('top'))) + 1; 
+  var topMargin = (parseInt($nav.css('margin-top')) || parseInt($nav.css('top'))) + 1;
   // add 1 for the #side-nav bottom margin
-  
+
   // Depending on whether the header is visible, set the side nav's height.
   if (headerVisible) {
     // The sidenav height grows as the header goes off screen
@@ -704,44 +707,44 @@
     // Once header is off screen, the nav height is almost full window height
     navHeight = windowHeight - topMargin;
   }
-  
-  
-  
+
+
+
   $scrollPanes = $(".scroll-pane");
   if ($scrollPanes.length > 1) {
     // subtract the height of the api level widget and nav swapper from the available nav height
     navHeight -= ($('#api-nav-header').outerHeight(true) + $('#nav-swap').outerHeight(true));
-    
+
     $("#swapper").css({height:navHeight + "px"});
     if ($("#nav-tree").is(":visible")) {
       $("#nav-tree").css({height:navHeight});
     }
-    
-    var classesHeight = navHeight - parseInt($("#resize-packages-nav").css("height")) - 10 + "px"; 
+
+    var classesHeight = navHeight - parseInt($("#resize-packages-nav").css("height")) - 10 + "px";
     //subtract 10px to account for drag bar
-    
-    // if the window becomes small enough to make the class panel height 0, 
+
+    // if the window becomes small enough to make the class panel height 0,
     // then the package panel should begin to shrink
     if (parseInt(classesHeight) <= 0) {
       $("#resize-packages-nav").css({height:navHeight - 10}); //subtract 10px for drag bar
       $("#packages-nav").css({height:navHeight - 10});
     }
-    
+
     $("#classes-nav").css({'height':classesHeight, 'margin-top':'10px'});
     $("#classes-nav .jspContainer").css({height:classesHeight});
-    
-    
+
+
   } else {
     $nav.height(navHeight);
   }
-  
+
   if (delay) {
     updateFromResize = true;
     delayedReInitScrollbars(delay);
   } else {
     reInitScrollbars();
   }
-  
+
 }
 
 var updateScrollbars = false;
@@ -760,7 +763,7 @@
     updateFromResize = false;
     return;
   }
-  
+
   // We're scheduled for an update and the update request came from this method's setTimeout
   if (updateScrollbars && !updateFromResize) {
     reInitScrollbars();
@@ -778,7 +781,7 @@
     var api = $(this).data('jsp');
     if (!api) { setTimeout(reInitScrollbars,300); return;}
     api.reinitialise( {verticalGutter:0} );
-  });  
+  });
   $(".scroll-pane").removeAttr("tabindex"); // get rid of tabindex added by jscroller
 }
 
@@ -809,7 +812,7 @@
 
 
 
-/** Scroll the jScrollPane to make the currently selected item visible 
+/** Scroll the jScrollPane to make the currently selected item visible
     This is called when the page finished loading. */
 function scrollIntoView(nav) {
   var $nav = $("#"+nav);
@@ -818,13 +821,18 @@
 
   if ($nav.is(':visible')) {
     var $selected = $(".selected", $nav);
-    if ($selected.length == 0) return;
-    
-    var selectedOffset = $selected.position().top;
-    if (selectedOffset + 90 > $nav.height()) {  // add 90 so that we scroll up even 
-                                                // if the current item is close to the bottom
-      api.scrollTo(0, selectedOffset - ($nav.height() / 4), false); // scroll the item into view
-                                                              // to be 1/4 of the way from the top
+    if ($selected.length == 0) {
+      // If no selected item found, exit
+      return;
+    }
+
+    var selectedOffset = $selected.offset().top; // measure offset from top, relative to entire page
+    if (selectedOffset > $nav.height() * .8) { // multiply nav height by .8 so we move up any
+                                               // items more than 80% down the nav
+      // scroll the item up by an amount 125px less than the window height (account for site header)
+      // and then multiply nav height by .8 to match the 80% threshold used above
+      api.scrollTo(0, selectedOffset - 125 - ($nav.height() * .8), false);
+
     }
   }
 }
@@ -873,7 +881,7 @@
     date.setTime(date.getTime()+(10*365*24*60*60*1000)); // default expiration is one week
     expiration = date.toGMTString();
   }
-  var cookieValue = cookie_namespace + section + cookie + "=" + val 
+  var cookieValue = cookie_namespace + section + cookie + "=" + val
                     + "; expires=" + expiration+"; path=/";
   document.cookie = cookieValue;
 }
@@ -1012,7 +1020,7 @@
   $("#panel-link").toggle();
   $("#nav-tree").toggle();
   $("#tree-link").toggle();
-  
+
   resizeNav();
 
   // Gross nasty hack to make tree view show up upon first swap by setting height manually
@@ -1020,7 +1028,7 @@
       .css({'height':$("#nav-tree .jspContainer .jspPane").height() +'px'});
   // Another nasty hack to make the scrollbar appear now that we have height
   resizeNav();
-  
+
   if ($("#nav-tree").is(':visible')) {
     scrollIntoView("nav-tree");
   } else {
@@ -1075,7 +1083,7 @@
 
 function changeLangPref(lang, submit) {
   var date = new Date();
-  expires = date.toGMTString(date.setTime(date.getTime()+(10*365*24*60*60*1000))); 
+  expires = date.toGMTString(date.setTime(date.getTime()+(10*365*24*60*60*1000)));
   // keep this for 50 years
   //alert("expires: " + expires)
   writeCookie("pref_lang", lang, null, expires);
@@ -1126,13 +1134,13 @@
     toggleMe.slideDown();
     $(".toggle-content-text", obj).toggle();
     div.removeClass("closed").addClass("open");
-    $(".toggle-content-img", div).attr("title", "hide").attr("src", toRoot 
+    $(".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 
+      $(".toggle-content-img", div).attr("title", "show").attr("src", toRoot
                   + "assets/images/triangle-closed.png");
     });
   }
@@ -1160,7 +1168,7 @@
 
 
 
-/*    
+/*
  *  Slideshow 1.0
  *  Used on /index.html and /develop/index.html for carousel
  *
@@ -1201,7 +1209,7 @@
 
  (function($) {
  $.fn.dacSlideshow = function(o) {
-     
+
      //Options - see above
      o = $.extend({
          btnPrev:   null,
@@ -1216,8 +1224,8 @@
          pagination: true
 
      }, o || {});
-     
-     //Set up a carousel for each 
+
+     //Set up a carousel for each
      return this.each(function() {
 
          var running = false;
@@ -1226,7 +1234,7 @@
          var div = $(this);
          var ul = $("ul", div);
          var tLi = $("li", ul);
-         var tl = tLi.size(); 
+         var tl = tLi.size();
          var timer = null;
 
          var li = $("li", ul);
@@ -1245,7 +1253,7 @@
          ul.css(sizeCss, ulSize+"px").css(animCss, -(curr*liSize));
 
          div.css(sizeCss, divSize+"px");
-         
+
          //Pagination
          if (o.pagination) {
              var pagination = $("<div class='pagination'></div>");
@@ -1263,7 +1271,7 @@
                 div.append(pagination);
              }
          }
-         
+
          //Previous button
          if(o.btnPrev)
              $(o.btnPrev).click(function(e) {
@@ -1288,18 +1296,18 @@
                      pauseRotateTimer();
                  }
              });
-         
+
          //Auto rotation
          if(o.auto) startRotateTimer();
-             
+
          function startRotateTimer() {
              clearInterval(timer);
              timer = setInterval(function() {
                   if (curr == tl-1) {
                     go(0);
                   } else {
-                    go(curr+o.scroll);  
-                  } 
+                    go(curr+o.scroll);
+                  }
               }, o.autoTime);
              $(o.btnPause).removeClass('paused');
          }
@@ -1337,11 +1345,11 @@
                     []
                   ).addClass("disabled");
 
-                 
+
                  var nav_items = $('li', pagination);
                  nav_items.removeClass('active');
                  nav_items.eq(to).addClass('active');
-                 
+
 
              }
              if(o.auto) startRotateTimer();
@@ -1363,7 +1371,7 @@
  })(jQuery);
 
 
-/*  
+/*
  *  dacSlideshow 1.0
  *  Used on develop/index.html for side-sliding tabs
  *
@@ -1402,7 +1410,7 @@
  */
  (function($) {
  $.fn.dacTabbedList = function(o) {
-     
+
      //Options - see above
      o = $.extend({
          speed : 250,
@@ -1410,8 +1418,8 @@
          nav_id: null,
          frame_id: null
      }, o || {});
-     
-     //Set up a carousel for each 
+
+     //Set up a carousel for each
      return this.each(function() {
 
          var curr = 0;
@@ -1419,17 +1427,17 @@
          var animCss = "margin-left";
          var sizeCss = "width";
          var div = $(this);
-         
+
          var nav = $(o.nav_id, div);
          var nav_li = $("li", nav);
-         var nav_size = nav_li.size(); 
+         var nav_size = nav_li.size();
          var frame = div.find(o.frame_id);
          var content_width = $(frame).find('ul').width();
          //Buttons
          $(nav_li).click(function(e) {
            go($(nav_li).index($(this)));
          })
-         
+
          //Go to an item
          function go(to) {
              if(!running) {
@@ -1442,10 +1450,10 @@
                      }
                  );
 
-                 
+
                  nav_li.removeClass('active');
                  nav_li.eq(to).addClass('active');
-                 
+
 
              }
              return false;
@@ -1652,7 +1660,7 @@
   * otherwise invokes search suggestions on key-up event.
   * @param e       The JS event
   * @param kd      True if the event is key-down
-  * @param toroot  A string for the site's root path 
+  * @param toroot  A string for the site's root path
   * @returns       True if the event should bubble up
   */
 function search_changed(e, kd, toroot)
@@ -1746,7 +1754,7 @@
         if ($($("li", $selectedUl)[gSelectedIndex]).hasClass("header")) {
           gSelectedIndex++;
         }
-        // set item selected       
+        // set item selected
         $('li:nth-child('+(gSelectedIndex+1)+')', $selectedUl).addClass('jd-selected');
         return false;
       }
@@ -1764,7 +1772,7 @@
         if ($($("li", $selectedUl)[gSelectedIndex]).hasClass("header")) {
           gSelectedIndex++;
         }
-        // set item selected       
+        // set item selected
         $('li:nth-child('+(gSelectedIndex+1)+')', $selectedUl).addClass('jd-selected');
         return false;
       }
@@ -1995,7 +2003,7 @@
 
 function search_focus_changed(obj, focused)
 {
-    if (!focused) {     
+    if (!focused) {
         if(obj.value == ""){
           $(".search .close").addClass("hide");
         }
@@ -2016,9 +2024,9 @@
   $("#searchResults").slideUp();
   $(".search .close").addClass("hide");
   location.hash = '';
-  
+
   $("#search_autocomplete").val("").blur();
-  
+
   // reset the ajax search callback to nothing, so results don't appear unless ENTER
   searchControl.setSearchStartingCallback(this, function(control, searcher, query) {});
 
@@ -2176,10 +2184,10 @@
       setTimeout(function() {
         // remove any residual page numbers
         $('#searchResults .gsc-tabsArea .gsc-cursor-box.gs-bidi-start-align').remove();
-        // move the page numbers to the left position; make a clone, 
+        // move the page numbers to the left position; make a clone,
         // because the element is drawn to the DOM only once
-        // and because we're going to remove it (previous line), 
-        // we need it to be available to move again as the user navigates 
+        // and because we're going to remove it (previous line),
+        // we need it to be available to move again as the user navigates
         $('#searchResults .gsc-webResult .gsc-cursor-box.gs-bidi-start-align:visible')
                         .clone().appendTo('#searchResults .gsc-tabsArea');
         }, 200);
@@ -2241,22 +2249,22 @@
 var maxLevel = 1;
 
 /******* SIDENAV DIMENSIONS ************/
-  
+
   function initSidenavHeightResize() {
     // Change the drag bar size to nicely fit the scrollbar positions
     var $dragBar = $(".ui-resizable-s");
     $dragBar.css({'width': $dragBar.parent().width() - 5 + "px"});
-    
-    $( "#resize-packages-nav" ).resizable({ 
+
+    $( "#resize-packages-nav" ).resizable({
       containment: "#nav-panels",
       handles: "s",
       alsoResize: "#packages-nav",
       resize: function(event, ui) { resizeNav(); }, /* resize the nav while dragging */
       stop: function(event, ui) { saveNavPanels(); } /* once stopped, save the sizes to cookie  */
       });
-          
+
   }
-  
+
 function updateSidenavFixedWidth() {
   if (!navBarIsFixed) return;
   $('#devdoc-nav').css({
@@ -2264,7 +2272,7 @@
     'margin' : $('#side-nav').css('margin')
   });
   $('#devdoc-nav a.totop').css({'display':'block','width':$("#nav").innerWidth()+'px'});
-  
+
   initSidenavHeightResize();
 }
 
@@ -2275,7 +2283,7 @@
     'margin' : $('#side-nav').css('margin')
   });
   $('#devdoc-nav .totop').css({'left': 'inherit'});
-  
+
   initSidenavHeightResize();
 }
 
@@ -2359,7 +2367,7 @@
     if (apiLevelNum > selectedLevelNum) {
       obj.addClass("absent").attr("title","Requires API Level \""
             + apiLevel + "\" or higher");
-    } 
+    }
     else obj.removeClass("absent").removeAttr("title");
   });
 }
@@ -2428,7 +2436,7 @@
       node.expanded = false;
     }
   }
-  
+
 
   node.children_ul = null;
   node.get_children_ul = function() {
@@ -2456,7 +2464,7 @@
       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";
@@ -2532,7 +2540,7 @@
           init_navtree("tree-list", 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");
@@ -2599,8 +2607,8 @@
   node.depth = mom.depth + 1;
   node.get_children_ul = function() {
       if (!node.children_ul) {
-        node.children_ul = document.createElement("ul"); 
-        node.children_ul.className = "tree-list-children"; 
+        node.children_ul = document.createElement("ul");
+        node.children_ul.className = "tree-list-children";
         node.li.appendChild(node.children_ul);
       }
       return node.children_ul;
@@ -2608,8 +2616,8 @@
   node.li = document.createElement("li");
 
   mom.get_children_ul().appendChild(node.li);
-  
-  
+
+
   if(link) {
     child = document.createElement("a");
 
@@ -2622,7 +2630,7 @@
   if (children_data != null) {
     node.li.className="nav-section";
     node.label_div = document.createElement("div");
-    node.label_div.className = "nav-section-header-ref";  
+    node.label_div.className = "nav-section-header-ref";
     node.li.appendChild(node.label_div);
     get_google_node(me, node);
     node.label_div.appendChild(child);
diff --git a/tools/droiddoc/templates-sdk/sdkpage.cs b/tools/droiddoc/templates-sdk/sdkpage.cs
index 3ebf697..ecc26f5 100644
--- a/tools/droiddoc/templates-sdk/sdkpage.cs
+++ b/tools/droiddoc/templates-sdk/sdkpage.cs
@@ -79,63 +79,112 @@
     <tr>
       <th>Platform</th>
       <th>Package</th>
-      <th>Size</th>
+      <th style="white-space:nowrap">Size (Bytes)</th>
       <th>MD5 Checksum</th>
   </tr>
   <tr>
-    <td>Windows 32-bit</td>
+    <td rowspan="2" style="white-space:nowrap">Windows 32-bit</td>
     <td>
   <a onClick="return onDownload(this)"
      href="http://dl.google.com/android/ndk/<?cs var:ndk.win32_download ?>"><?cs var:ndk.win32_download ?></a>
     </td>
-    <td><?cs var:ndk.win32_bytes ?> bytes</td>
+    <td><?cs var:ndk.win32_bytes ?></td>
     <td><?cs var:ndk.win32_checksum ?></td>
   </tr>
   <tr>
-    <td>Windows 64-bit</td>
+    <td>
+  <a onClick="return onDownload(this)"
+     href="http://dl.google.com/android/ndk/<?cs var:ndk.win32.legacy_download ?>"><?cs var:ndk.win32.legacy_download ?></a>
+    </td>
+    <td><?cs var:ndk.win32.legacy_bytes ?></td>
+    <td><?cs var:ndk.win32.legacy_checksum ?></td>
+  </tr>
+  <tr>
+    <td rowspan="2" style="white-space:nowrap">Windows 64-bit</td>
     <td>
   <a onClick="return onDownload(this)"
      href="http://dl.google.com/android/ndk/<?cs var:ndk.win64_download ?>"><?cs var:ndk.win64_download ?></a>
     </td>
-    <td><?cs var:ndk.win64_bytes ?> bytes</td>
+    <td><?cs var:ndk.win64_bytes ?></td>
     <td><?cs var:ndk.win64_checksum ?></td>
   </tr>
   <tr>
-    <td>Mac OS X 32-bit</td>
+    <td>
+  <a onClick="return onDownload(this)"
+     href="http://dl.google.com/android/ndk/<?cs var:ndk.win64.legacy_download ?>"><?cs var:ndk.win64.legacy_download ?></a>
+    </td>
+    <td><?cs var:ndk.win64.legacy_bytes ?></td>
+    <td><?cs var:ndk.win64.legacy_checksum ?></td>
+  </tr>
+  <tr>
+    <td rowspan="2" style="white-space:nowrap">Mac OS X 32-bit</td>
     <td>
   <a onClick="return onDownload(this)"
      href="http://dl.google.com/android/ndk/<?cs var:ndk.mac32_download ?>"><?cs var:ndk.mac32_download ?></a>
     </td>
-    <td><?cs var:ndk.mac32_bytes ?> bytes</td>
+    <td><?cs var:ndk.mac32_bytes ?></td>
     <td><?cs var:ndk.mac32_checksum ?></td>
   </tr>
   <tr>
-    <td>Mac OS X 64-bit</td>
+    <td>
+  <a onClick="return onDownload(this)"
+     href="http://dl.google.com/android/ndk/<?cs var:ndk.mac32.legacy_download ?>"><?cs var:ndk.mac32.legacy_download ?></a>
+    </td>
+    <td><?cs var:ndk.mac32.legacy_bytes ?></td>
+    <td><?cs var:ndk.mac32.legacy_checksum ?></td>
+  </tr>
+  <tr>
+    <td rowspan="2"  style="white-space:nowrap">Mac OS X 64-bit</td>
     <td>
   <a onClick="return onDownload(this)"
      href="http://dl.google.com/android/ndk/<?cs var:ndk.mac64_download ?>"><?cs var:ndk.mac64_download ?></a>
     </td>
-    <td><?cs var:ndk.mac64_bytes ?> bytes</td>
+    <td><?cs var:ndk.mac64_bytes ?></td>
     <td><?cs var:ndk.mac64_checksum ?></td>
   </tr>
   <tr>
-    <td>Linux 32-bit (x86)</td>
+    <td>
+  <a onClick="return onDownload(this)"
+     href="http://dl.google.com/android/ndk/<?cs var:ndk.mac64.legacy_download ?>"><?cs var:ndk.mac64.legacy_download ?></a>
+    </td>
+    <td><?cs var:ndk.mac64.legacy_bytes ?></td>
+    <td><?cs var:ndk.mac64.legacy_checksum ?></td>
+  </tr>
+
+  <tr>
+    <td rowspan="2" style="white-space:nowrap">Linux 32-bit (x86)</td>
     <td>
   <a onClick="return onDownload(this)"
      href="http://dl.google.com/android/ndk/<?cs var:ndk.linux32_download ?>"><?cs var:ndk.linux32_download ?></a>
     </td>
-    <td><?cs var:ndk.linux32_bytes ?> bytes</td>
+    <td><?cs var:ndk.linux32_bytes ?></td>
     <td><?cs var:ndk.linux32_checksum ?></td>
   </tr>
   <tr>
-    <td>Linux 64-bit (x86)</td>
+    <td>
+  <a onClick="return onDownload(this)"
+     href="http://dl.google.com/android/ndk/<?cs var:ndk.linux32.legacy_download ?>"><?cs var:ndk.linux32.legacy_download ?></a>
+    </td>
+    <td><?cs var:ndk.linux32.legacy_bytes ?></td>
+    <td><?cs var:ndk.linux32.legacy_checksum ?></td>
+  </tr>
+  <tr>
+    <td rowspan="2" style="white-space:nowrap">Linux 64-bit (x86)</td>
     <td>
   <a onClick="return onDownload(this)"
      href="http://dl.google.com/android/ndk/<?cs var:ndk.linux64_download ?>"><?cs var:ndk.linux64_download ?></a>
     </td>
-    <td><?cs var:ndk.linux64_bytes ?> bytes</td>
+    <td><?cs var:ndk.linux64_bytes ?></td>
     <td><?cs var:ndk.linux64_checksum ?></td>
   </tr>
+  <tr>
+    <td>
+  <a onClick="return onDownload(this)"
+     href="http://dl.google.com/android/ndk/<?cs var:ndk.linux64.legacy_download ?>"><?cs var:ndk.linux64.legacy_download ?></a>
+    </td>
+    <td><?cs var:ndk.linux64.legacy_bytes ?></td>
+    <td><?cs var:ndk.linux64.legacy_checksum ?></td>
+  </tr>
   </table>
   
   <?cs ########  HERE IS THE JD DOC CONTENT ######### ?>