merge in master-release history after reset to master
diff --git a/core/build_id.mk b/core/build_id.mk
index 223b419..40bb35d 100644
--- a/core/build_id.mk
+++ b/core/build_id.mk
@@ -1,4 +1,3 @@
-
 #
 # Copyright (C) 2008 The Android Open Source Project
 #
@@ -14,9 +13,20 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
+
+#
+# Defines branch-specific values.
+#
+
 # BUILD_ID is usually used to specify the branch name
 # (like "MAIN") or a branch name and a release candidate
-# (like "CRB01").  It must be a single word, and is
+# (like "TC1-RC5").  It must be a single word, and is
 # capitalized by convention.
+#
+BUILD_ID := MASTER
 
-export BUILD_ID=AAP47
+# 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/definitions.mk b/core/definitions.mk
index 8926b2b..319b63e 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -2078,6 +2078,29 @@
 endef
 
 ###########################################################
+## API Check
+###########################################################
+
+# eval this to define a rule that runs apicheck.
+#
+# Args:
+#    $(1)  target
+#    $(2)  stable api file
+#    $(3)  api file to be tested
+#    $(4)  arguments for apicheck
+#    $(5)  command to run if apicheck failed
+#    $(6)  target dependent on this api check
+#    $(7)  additional dependencies
+define check-api
+$(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/$(strip $(1))-timestamp: $(2) $(3) $(APICHECK) $(7)
+	@echo "Checking API:" $(1)
+	$(hide) ( $(APICHECK_COMMAND) $(4) $(2) $(3) || ( $(5) ; exit 38 ) )
+	$(hide) mkdir -p $$(dir $$@)
+	$(hide) touch $$@
+$(6): $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/$(strip $(1))-timestamp
+endef
+
+###########################################################
 ## Other includes
 ###########################################################
 
diff --git a/core/dumpvar.mk b/core/dumpvar.mk
index c47aa0f..47ac9e2 100644
--- a/core/dumpvar.mk
+++ b/core/dumpvar.mk
@@ -15,6 +15,10 @@
         # this should be copied to HOST_OUT_EXECUTABLES instead
         ABP:=$(ABP):$(PWD)/prebuilts/gcc/$(HOST_PREBUILT_TAG)/arm/arm-linux-androideabi-$(TARGET_GCC_VERSION)/bin
     endif
+    ifneq ($(wildcard $(PWD)/prebuilts/gcc/$(HOST_PREBUILT_TAG)/arm/arm-eabi-$(TARGET_GCC_VERSION)/bin),)
+        # this should be copied to HOST_OUT_EXECUTABLES instead
+        ABP:=$(ABP):$(PWD)/prebuilts/gcc/$(HOST_PREBUILT_TAG)/arm/arm-eabi-$(TARGET_GCC_VERSION)/bin
+    endif
 else ifeq ($(TARGET_ARCH),x86)
 
 # Add the x86 toolchain bin dir if it actually exists
diff --git a/core/tasks/apicheck.mk b/core/tasks/apicheck.mk
index 63fd4d4..24b3428 100644
--- a/core/tasks/apicheck.mk
+++ b/core/tasks/apicheck.mk
@@ -22,58 +22,48 @@
 
 .PHONY: checkapi
 
-# eval this to define a rule that runs apicheck.
-#
-# Args:
-#    $(1)  target
-#    $(2)  stable api file
-#    $(3)  api file to be tested
-#    $(4)  arguments for apicheck
-#    $(5)  command to run if apicheck failed
-define check-api
-$(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/$(strip $(1))-timestamp: $(2) $(3) $(APICHECK)
-	@echo "Checking API:" $(1)
-	$(hide) ( $(APICHECK_COMMAND) $(4) $(2) $(3) || ( $(5) ; exit 38 ) )
-	$(hide) mkdir -p $$(dir $$@)
-	$(hide) touch $$@
-checkapi: $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/$(strip $(1))-timestamp
-endef
-
 # Run the checkapi rules by default.
 droidcore: checkapi
 
 last_released_sdk_version := $(lastword $(call numerically_sort, \
-            $(filter-out $(SRC_API_DIR)/current, \
+            $(filter-out current, \
                 $(patsubst $(SRC_API_DIR)/%.txt,%, $(wildcard $(SRC_API_DIR)/*.txt)) \
              )\
         ))
 
 # INTERNAL_PLATFORM_API_FILE is the one build by droiddoc.
+# Note that since INTERNAL_PLATFORM_API_FILE is the byproduct of api-stubs module,
+# (See frameworks/base/Android.mk)
+# we need to add api-stubs as additional dependency of the api check.
 
 # Check that the API we're building hasn't broken the last-released
 # SDK version.
 $(eval $(call check-api, \
-	checkapi-last, \
-	$(SRC_API_DIR)/$(last_released_sdk_version).txt, \
-	$(INTERNAL_PLATFORM_API_FILE), \
-	-hide 2 -hide 3 -hide 4 -hide 5 -hide 6 -hide 24 -hide 25 \
-	-error 7 -error 8 -error 9 -error 10 -error 11 -error 12 -error 13 -error 14 -error 15 \
-	-error 16 -error 17 -error 18 , \
-	cat $(BUILD_SYSTEM)/apicheck_msg_last.txt \
-	))
+    checkapi-last, \
+    $(SRC_API_DIR)/$(last_released_sdk_version).txt, \
+    $(INTERNAL_PLATFORM_API_FILE), \
+    -hide 2 -hide 3 -hide 4 -hide 5 -hide 6 -hide 24 -hide 25 \
+    -error 7 -error 8 -error 9 -error 10 -error 11 -error 12 -error 13 -error 14 -error 15 \
+    -error 16 -error 17 -error 18 , \
+    cat $(BUILD_SYSTEM)/apicheck_msg_last.txt, \
+    checkapi, \
+    $(call doc-timestamp-for,api-stubs) \
+    ))
 
 # Check that the API we're building hasn't changed from the not-yet-released
 # SDK version.
 $(eval $(call check-api, \
-	checkapi-current, \
-	$(SRC_API_DIR)/current.txt, \
-	$(INTERNAL_PLATFORM_API_FILE), \
-	-error 2 -error 3 -error 4 -error 5 -error 6 \
-	-error 7 -error 8 -error 9 -error 10 -error 11 -error 12 -error 13 -error 14 -error 15 \
-	-error 16 -error 17 -error 18 -error 19 -error 20 -error 21 -error 23 -error 24 \
-	-error 25 , \
-	cat $(BUILD_SYSTEM)/apicheck_msg_current.txt \
-	))
+    checkapi-current, \
+    $(SRC_API_DIR)/current.txt, \
+    $(INTERNAL_PLATFORM_API_FILE), \
+    -error 2 -error 3 -error 4 -error 5 -error 6 \
+    -error 7 -error 8 -error 9 -error 10 -error 11 -error 12 -error 13 -error 14 -error 15 \
+    -error 16 -error 17 -error 18 -error 19 -error 20 -error 21 -error 23 -error 24 \
+    -error 25 , \
+    cat $(BUILD_SYSTEM)/apicheck_msg_current.txt, \
+    checkapi, \
+    $(call doc-timestamp-for,api-stubs) \
+    ))
 
 .PHONY: update-api
 update-api: $(INTERNAL_PLATFORM_API_FILE) | $(ACP)
diff --git a/envsetup.sh b/envsetup.sh
index 47dab37..e4f66bd 100644
--- a/envsetup.sh
+++ b/envsetup.sh
@@ -116,13 +116,16 @@
     prebuiltdir=$(getprebuilt)
     gccprebuiltdir=$(get_abs_build_var ANDROID_GCC_PREBUILTS)
 
+    # defined in core/config.mk
+    targetgccversion=$(get_build_var TARGET_GCC_VERSION)
+
     # The gcc toolchain does not exists for windows/cygwin. In this case, do not reference it.
     export ANDROID_EABI_TOOLCHAIN=
     local ARCH=$(get_build_var TARGET_ARCH)
     case $ARCH in
         x86) toolchaindir=x86/i686-linux-android-4.6/bin
             ;;
-        arm) toolchaindir=arm/arm-linux-androideabi-4.6/bin
+        arm) toolchaindir=arm/arm-linux-androideabi-$targetgccversion/bin
             ;;
         mips) toolchaindir=mips/mipsel-linux-android-4.6/bin
             ;;
@@ -138,7 +141,7 @@
     unset ARM_EABI_TOOLCHAIN ARM_EABI_TOOLCHAIN_PATH
     case $ARCH in
         arm)
-            toolchaindir=arm/arm-eabi-4.6/bin
+            toolchaindir=arm/arm-eabi-$targetgccversion/bin
             if [ -d "$gccprebuiltdir/$toolchaindir" ]; then
                  export ARM_EABI_TOOLCHAIN="$gccprebuiltdir/$toolchaindir"
                  ARM_EABI_TOOLCHAIN_PATH=":$gccprebuiltdir/$toolchaindir"
diff --git a/target/product/core.mk b/target/product/core.mk
index 38ea4d2..9a19b3b 100644
--- a/target/product/core.mk
+++ b/target/product/core.mk
@@ -110,6 +110,7 @@
     libstagefright_soft_amrwbenc \
     libstagefright_soft_flacenc \
     libstagefright_soft_g711dec \
+    libstagefright_soft_gsmdec \
     libstagefright_soft_h264dec \
     libstagefright_soft_h264enc \
     libstagefright_soft_mp3dec \
diff --git a/target/product/mini.mk b/target/product/mini.mk
index 299069d..169ba6e 100644
--- a/target/product/mini.mk
+++ b/target/product/mini.mk
@@ -128,6 +128,7 @@
     libstagefright_soft_amrwbenc \
     libstagefright_soft_flacenc \
     libstagefright_soft_g711dec \
+    libstagefright_soft_gsmdec \
     libstagefright_soft_h264dec \
     libstagefright_soft_h264enc \
     libstagefright_soft_mp3dec \
diff --git a/tools/droiddoc/templates-sdk/assets/css/default.css b/tools/droiddoc/templates-sdk/assets/css/default.css
index 89b6c88..4c4cdee 100644
--- a/tools/droiddoc/templates-sdk/assets/css/default.css
+++ b/tools/droiddoc/templates-sdk/assets/css/default.css
@@ -448,21 +448,23 @@
     border:1px solid #DADADA;
     border-bottom:0;
   }
-      
+
   .training-nav-top a.next-page-link {
     border-left:0;
     width:123px;
   }
       
+  .paging-links a.disabled,
   .training-nav-top a.disabled,
   .content-footer a.disabled {
-    color:#999;
+    color:#bbb;
   }
       
+  .paging-links a.disabled:hover,
   .training-nav-top a.disabled:hover,
   .content-footer a.disabled:hover {
     cursor:default;
-    color:#999 !important;
+    color:#bbb !important;
   }
       
   .training-nav-top a.start-class-link,
@@ -470,6 +472,78 @@
     width:262px;
   }
   
+  /* list of classes on course landing page */
+  ol.class-list {
+    list-style:none;
+    margin-left:0;
+  }
+  ol.class-list>li {
+    margin:0 0 15px;
+    padding:5px 0 0;
+    overflow:hidden;
+    border-top:1px solid #ccc;
+  }
+  ol.class-list li a.title {
+    font-size:16px;
+    margin:0;
+    clear:left;
+    display:block;
+    height:32px;
+    padding:0 4px;
+  }
+  ol.class-list li a.title h2 {
+    color:inherit;
+    margin:0 0 10px;
+    display:block;
+    float:left;
+    width:675px;
+  }
+  ol.class-list li a.title span {
+    display:none;
+    float:left;
+    font-size:18px;
+    font-weight:bold;
+    background: transparent url(../images/styles/disclosure_right.png) no-repeat scroll 50% 50%;
+    width: 10px;
+    height: 32px;
+  }
+  ol.class-list li a.title:hover {
+    background:#ddd;
+    color:#258AAF !important;
+  }
+  ol.class-list li a.title:hover span {
+    display:block;
+  }
+  
+  #jd-content
+  ol.class-list li img {
+    float:left;
+    clear:left;
+    width:64px;
+    margin:0 20px 0 0;
+  }
+  ol.class-list li p.description {
+    float:left;
+    display:block;
+    width:250px;
+    margin:0;
+  }
+  ol.class-list li p.description.article {
+    width: 550px;
+  }
+  ol.class-list ol {
+    float:left;
+    width:320px;
+    margin:0 0 0 30px;
+    list-style:none;
+    margin:0 0 0 20px;
+  }
+  ol.class-list div.lessons li {
+    margin:0 0 6px;
+    line-height:16px;
+  }
+  
+  
   .hide {
     display:none !important;
   }
@@ -1921,7 +1995,7 @@
   padding:0 0 0 10px;
 }
 
-div#sdk-terms-form input#agree {
+div#sdk-terms-form input {
   display:inline;
   margin:4px 4px 4px 0;
 }
diff --git a/tools/droiddoc/templates-sdk/assets/js/docs.js b/tools/droiddoc/templates-sdk/assets/js/docs.js
index 3cdfe1e..f1fbfff 100644
--- a/tools/droiddoc/templates-sdk/assets/js/docs.js
+++ b/tools/droiddoc/templates-sdk/assets/js/docs.js
@@ -135,6 +135,7 @@
 
   // select current page in sidenav and set up prev/next links if they exist
   var $selNavLink = $('#nav').find('a[href="' + pagePath + '"]');
+  var $selListItem;
   if ($selNavLink.length) {
     $selListItem = $selNavLink.closest('li');
 
@@ -156,11 +157,9 @@
 false; // navigate across topic boundaries only in design docs
     if ($prevListItem.length) {
       if ($prevListItem.hasClass('nav-section')) {
-        if (crossBoundaries) {
-          // jump to last topic of previous section
-          $prevLink = $prevListItem.find('a:last');
-        }
-      } else {
+        // jump to last topic of previous section
+        $prevLink = $prevListItem.find('a:last');
+      } else if (!$selListItem.hasClass('nav-section')) {
         // jump to previous topic in this section
         $prevLink = $prevListItem.find('a:eq(0)');
       }
@@ -177,18 +176,8 @@
       }
     }
 
-    if ($prevLink.length) {
-      var prevHref = $prevLink.attr('href');
-      if (prevHref == SITE_ROOT + 'index.html') {
-        // Don't show Previous when it leads to the homepage
-      } else {
-        $('.prev-page-link').attr('href', $prevLink.attr('href')).removeClass("hide");
-      }
-    } 
-
     // set up next links
     var $nextLink = [];
-    var startCourse = false;
     var startClass = false;
     var training = $(".next-class-link").length; // decides whether to provide "next class" link
     var isCrossingBoundary = false;
@@ -206,53 +195,103 @@
         $('.topic-start-link').text($nextLink.text().toUpperCase());
       }
       
-      // Handle some Training specialties
-      if ($selListItem.parent().is("#nav") && $(".start-course-link").length) {
-        // this means we're at the very top of the TOC hierarchy
-        startCourse = true;
-      } else if ($(".start-class-link").length) {
-        // this means this page has children but is not at the top (it's a class, not a course)
+      // 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
         startClass = true;
       }
     } else {
       // jump to the next topic in this section (if it exists)
       $nextLink = $selListItem.next('li').find('a:eq(0)');
       if (!$nextLink.length) {
-        if (crossBoundaries || training) {
-          // no more topics in this section, jump to the first topic in the next section
-          $nextLink = $selListItem.parents('li:eq(0)').next('li.nav-section').find('a:eq(0)');
-          isCrossingBoundary = true;
+        isCrossingBoundary = true;
+        // no more topics in this section, jump to the first topic in the next section
+        $nextLink = $selListItem.parents('li:eq(0)').next('li.nav-section').find('a:eq(0)');
+        if (!$nextLink.length) {  // Go up another layer to look for next page (lesson > class > course)
+          $nextLink = $selListItem.parents('li:eq(1)').next('li.nav-section').find('a:eq(0)');
         }
       }
     }
-    if ($nextLink.length) {
-      if (startCourse || startClass) {
-        if (startCourse) {
-          $('.start-course-link').attr('href', $nextLink.attr('href')).removeClass("hide");
-        } else {
-          $('.start-class-link').attr('href', $nextLink.attr('href')).removeClass("hide");
-        }
-        // if there's no training bar (below the start button), 
-        // then we need to add a bottom border to button
-        if (!$("#tb").length) {
-          $('.start-course-link').css({'border-bottom':'1px solid #DADADA'});
-          $('.start-class-link').css({'border-bottom':'1px solid #DADADA'});
-        }
-      } else if (training && isCrossingBoundary) {
-        $('.content-footer.next-class').show();
-        $('.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();
-      } else {
-        $('.next-page-link').attr('href', $nextLink.attr('href')).removeClass("hide");
+
+    if (startClass) {
+      $('.start-class-link').attr('href', $nextLink.attr('href')).removeClass("hide");
+
+      // 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'});
       }
+    } else if (isCrossingBoundary && !$('body.design').length) {  // Design always crosses boundaries
+      $('.content-footer.next-class').show();
+      $('.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();
+    } else {
+      $('.next-page-link').attr('href', $nextLink.attr('href')).removeClass("hide");
+    }
+
+    if (!startClass && $prevLink.length) {
+      var prevHref = $prevLink.attr('href');
+      if (prevHref == SITE_ROOT + 'index.html') {
+        // Don't show Previous when it leads to the homepage
+      } 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...
+    if (training && $selListItem.parents('ul').eq(1).is('[id="nav"]') &&
+        !$selListItem.find('li').length) {
+      $('.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;
+    var $h2Title;
+    var $pSummary;
+    var $olLessons;
+    var $liLesson;
+    $classLinks.each(function(index) {
+      $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=""/>');
+        $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=""/>');
+        $pSummary.addClass('article');
+      }
+
+      $liClass.append($h2Title).append($imgIcon).append($pSummary).append($olLessons);
+      $olClasses.append($liClass);
+    });
+    $('.jd-descr').append($olClasses);
+  }
+
 
 
 
@@ -1899,11 +1938,18 @@
 
   if (selectedLevel < minLevel) {
     var thing = ($("#jd-header").html().indexOf("package") != -1) ? "package" : "class";
-    $("#naMessage").show().html("<div><p><strong>This " + thing + " is not available with API level " + selectedLevel + ".</strong></p>"
-                              + "<p>To use this " + thing + ", you must develop your app using a build target "
-                              + "that supports API level " + $("#doc-api-level").attr("class") + " or higher. To read these "
-                              + "APIs, change the value of the API level filter above.</p>"
-                              + "<p><a href='" +toRoot+ "guide/appendix/api-levels.html'>What is the API level?</a></p></div>");
+    $("#naMessage").show().html("<div><p><strong>This " + thing
+              + " requires API level " + minLevel + " or higher.</strong></p>"
+              + "<p>This document is hidden because your selected API level for the documentation is "
+              + selectedLevel + ". You can change the documentation API level with the selector "
+              + "above the left navigation.</p>"
+              + "<p>For more information about specifying the API level your app requires, "
+              + "read <a href='" + toRoot + "training/basics/supporting-devices/platforms.html'"
+              + ">Supporting Different Platform Versions</a>.</p>"
+              + "<input type='button' value='OK, make this page visible' "
+              + "title='Change the API level to " + minLevel + "' "
+              + "onclick='$(\"#apiLevelSelector\").val(\"" + minLevel + "\");changeApiLevel();' />"
+              + "</div>");
   } else {
     $("#naMessage").hide();
   }
diff --git a/tools/droiddoc/templates-sdk/docpage.cs b/tools/droiddoc/templates-sdk/docpage.cs
index 3f1cfcf..3feb00f 100644
--- a/tools/droiddoc/templates-sdk/docpage.cs
+++ b/tools/droiddoc/templates-sdk/docpage.cs
@@ -7,7 +7,8 @@
   elif:about ?>about<?cs
   elif:design ?>design<?cs
   elif:distribute ?>distribute<?cs
-  /if ?>" itemscope itemtype="http://schema.org/Article">
+  /if ?><?cs
+  if:page.trainingcourse ?> trainingcourse<?cs /if ?>" itemscope itemtype="http://schema.org/Article">
 <a name="top"></a>
 <?cs include:"header.cs" ?>
 
@@ -16,7 +17,7 @@
 ?>class="col-13" id="doc-col"<?cs else 
 ?>class="col-12" id="doc-col"<?cs /if ?> >
 
-<?cs if:(design||training||walkthru) ?><?cs # header logic for docs that provide previous/next buttons ?>
+<?cs if:(design||training||walkthru) && !page.trainingcourse ?><?cs # header logic for docs that provide previous/next buttons ?>
   <?cs if:header.hide ?>
   <?cs else ?>
   <div class="layout-content-row content-header <?cs if:header.justLinks ?>just-links<?cs /if ?>">
@@ -51,16 +52,8 @@
             ja-lang="開始する"
             es-lang="Empezar"               
             >Get started</a>
-        <a href="#" class="start-course-link hide"
-            zh-TW-lang="第一堂課"
-            zh-CN-lang="第一课"
-            ru-lang="Первый урок"
-            ko-lang="첫 번째 강의"
-            ja-lang="最初のクラス"
-            es-lang="Primera clase"               
-            >First class</a>
       </div>
-    <?cs else ?>
+    <?cs elif:!page.trainingcourse ?>
       <div class="paging-links layout-content-col span-4" itemscope itemtype="http://schema.org/SiteNavigationElement">
         <a href="#" class="prev-page-link hide"
             zh-TW-lang="上一堂課"
@@ -138,7 +131,7 @@
         </div>
         <?cs if:!fullscreen ?>
         <div class="paging-links layout-content-col col-4">
-          <?cs if:(design||training||guide||walkthru) && !page.landing && !footer.hide ?>
+          <?cs if:(design||training||guide||walkthru) && !page.landing && !page.trainingcourse && !footer.hide ?>
             <a href="#" class="prev-page-link hide"
                 zh-TW-lang="上一堂課"
                 zh-CN-lang="上一课"
diff --git a/tools/droiddoc/templates-sdk/package.cs b/tools/droiddoc/templates-sdk/package.cs
index e246e31..ea676b9 100644
--- a/tools/droiddoc/templates-sdk/package.cs
+++ b/tools/droiddoc/templates-sdk/package.cs
@@ -8,7 +8,7 @@
   elif:design ?>design<?cs
   elif:distribute ?>distribute<?cs
   /if ?>">
-  <div id="doc-api-level" class="<?cs var:class.since ?>" style="display:none"></div>
+  <div id="doc-api-level" class="<?cs var:package.since ?>" style="display:none"></div>
   <a name="top"></a>
 <?cs include:"header.cs" ?>
 
diff --git a/tools/droiddoc/templates-sdk/sdkpage.cs b/tools/droiddoc/templates-sdk/sdkpage.cs
index 1e3a728..170231f 100644
--- a/tools/droiddoc/templates-sdk/sdkpage.cs
+++ b/tools/droiddoc/templates-sdk/sdkpage.cs
@@ -92,7 +92,7 @@
     <td><?cs var:ndk.win_bytes ?> bytes</td>
     <td><?cs var:ndk.win_checksum ?></td>
   </tr>
-  <tr class="alt-color">
+  <tr>
     <td>Mac OS X (intel)</td>
     <td>
   <a onClick="return onDownload(this)"
@@ -207,31 +207,49 @@
       <th>MD5 Checksum</th>
   </tr>
   <tr>
-    <td>Windows</td>
+    <td>Windows 32-bit</td>
     <td>
-  <a onClick="return onDownload(this)" id="win-bundle"
-     href="http://dl.google.com/android/<?cs var:sdk.win_bundle_download ?>"><?cs var:sdk.win_bundle_download ?></a>
+  <a onClick="return onDownload(this)" id="win-bundle32"
+     href="http://dl.google.com/android/adt/<?cs var:sdk.win32_bundle_download ?>"><?cs var:sdk.win32_bundle_download ?></a>
     </td>
-    <td><?cs var:sdk.win_bundle_bytes ?> bytes</td>
-    <td><?cs var:sdk.win_bundle_checksum ?></td>
-  </tr>
-  <tr class="alt-color">
-    <td>Mac OS X (intel)</td>
-    <td>
-  <a onClick="return onDownload(this)" id="mac-bundle"
-     href="http://dl.google.com/android/<?cs var:sdk.mac_bundle_download ?>"><?cs var:sdk.mac_bundle_download ?></a>
-    </td>
-    <td><?cs var:sdk.mac_bundle_bytes ?> bytes</td>
-    <td><?cs var:sdk.mac_bundle_checksum ?></td>
+    <td><?cs var:sdk.win32_bundle_bytes ?> bytes</td>
+    <td><?cs var:sdk.win32_bundle_checksum ?></td>
   </tr>
   <tr>
-    <td>Linux 32/64-bit (x86)</td>
+    <td>Windows 64-bit</td>
     <td>
-  <a onClick="return onDownload(this)" id="linux-bundle"
-     href="http://dl.google.com/android/<?cs var:sdk.linux_bundle_download ?>"><?cs var:sdk.linux_bundle_download ?></a>
+  <a onClick="return onDownload(this)" id="win-bundle64"
+     href="http://dl.google.com/android/adt/<?cs var:sdk.win64_bundle_download ?>"><?cs var:sdk.win64_bundle_download ?></a>
     </td>
-    <td><?cs var:sdk.linux_bundle_bytes ?> bytes</td>
-    <td><?cs var:sdk.linux_bundle_checksum ?></td>
+    <td><?cs var:sdk.win64_bundle_bytes ?> bytes</td>
+    <td><?cs var:sdk.win64_bundle_checksum ?></td>
+  </tr>
+  <tr>
+    <td><nobr>Mac OS X 64-bit</nobr></td>
+    <td>
+  <a onClick="return onDownload(this)" id="mac-bundle64"
+     href="http://dl.google.com/android/adt/<?cs var:sdk.mac64_bundle_download ?>"><?cs var:sdk.mac64_bundle_download ?></a>
+    </td>
+    <td><?cs var:sdk.mac64_bundle_bytes ?> bytes</td>
+    <td><?cs var:sdk.mac64_bundle_checksum ?></td>
+  </tr>
+  <tr>
+    <td>Linux 32-bit</td>
+    <td>
+  <a onClick="return onDownload(this)" id="linux-bundle32"
+     href="http://dl.google.com/android/adt/<?cs var:sdk.linux32_bundle_download ?>"><?cs var:sdk.linux32_bundle_download ?></a>
+    </td>
+    <td><?cs var:sdk.linux32_bundle_bytes ?> bytes</td>
+    <td><?cs var:sdk.linux32_bundle_checksum ?></td>
+  </tr>
+  <tr>
+    <td>Linux 64-bit</td>
+    <td>
+  <a onClick="return onDownload(this)" id="linux-bundle64"
+     href="http://dl.google.com/android/adt/<?cs var:sdk.linux64_bundle_download ?>"><?cs var:sdk.linux64_bundle_download ?></a>
+    </td>
+    <td><?cs var:sdk.linux64_bundle_bytes ?> bytes</td>
+    <td><?cs var:sdk.linux64_bundle_checksum ?></td>
   </tr>
   </table>
 
@@ -263,8 +281,8 @@
     <td><?cs var:sdk.win_installer_bytes ?> bytes</td>
     <td><?cs var:sdk.win_installer_checksum ?></td>
   </tr>
-  <tr class="alt-color">
-    <td>Mac OS X (intel)</td>
+  <tr>
+    <td>Mac OS X</td>
     <td>
   <a onclick="return onDownload(this)" id="mac-tools" href="http://dl.google.com/android/<?cs
 var:sdk.mac_download
@@ -274,7 +292,7 @@
     <td><?cs var:sdk.mac_checksum ?></td>
   </tr>
   <tr>
-    <td>Linux (i386)</td>
+    <td>Linux</td>
     <td>
   <a onclick="return onDownload(this)" id="linux-tools" href="http://dl.google.com/android/<?cs
 var:sdk.linux_download
@@ -302,20 +320,20 @@
   }
 
   var os;
-  var $bundlelink;
+  var bundlename;
   var $toolslink;
 
   if (navigator.appVersion.indexOf("Win")!=-1) {
     os = "Windows";
-    $bundlelink = $('#win-bundle');
+    bundlename = '#win-bundle';
     $toolslink = $('#win-tools');
   } else if (navigator.appVersion.indexOf("Mac")!=-1) {
     os = "Mac";
-    $bundlelink = $('#mac-bundle');
+    bundlename = '#mac-bundle';
     $toolslink = $('#mac-tools');
   } else if (navigator.appVersion.indexOf("Linux")!=-1) {
     os = "Linux";
-    $bundlelink = $('#linux-bundle');
+    bundlename = '#linux-bundle';
     $toolslink = $('#linux-tools');
   }
 
@@ -325,47 +343,45 @@
     /* set up primary adt download button */
     $('#download-bundle-button').show();
     $('#download-bundle-button').append("Download the SDK <br/><span class='small'>ADT Bundle for " + os + "</span>");
-    $('#download-bundle-button').click(function() {return onDownloadBouncer(this,true);}).attr('href', $bundlelink.attr('href'));
+    $('#download-bundle-button').click(function() {return onDownload(this,true,true);}).attr('href', bundlename);
 
     /* set up sdk tools only button */
     $('#download-tools-button').show();
     $('#download-tools-button').append("Download the SDK Tools for " + os);
-    $('#download-tools-button').click(function() {return onDownload(this,false);}).attr('href', $toolslink.attr('href'));
+    $('#download-tools-button').click(function() {return onDownload(this,true);}).attr('href', $toolslink.attr('href'));
   } else {
     $('.pax').show();
   }
-
-
-  function onDownloadBouncer(link, button) {
-  
-    if (navigator.userAgent.indexOf("WOW64") != -1 || 
-        navigator.userAgent.indexOf("Win64") != -1 ) {
-
-        $("#naMessage").show();
-        $("#warningCancel").click(function() {
-          $('#naMessage').hide();
-          onDownload(link,button);
-        });
-        $("#warningOk").click(function() {
-          $('#naMessage').hide();
-          onDownload($("#download-tools-button").get(),false);
-        });
-        return false;
-      } else {
-        return onDownload(link,button);      
-      }
-  }
   
   
-  function onDownload(link, button) {
-
+  function onDownload(link, button, bundle) {
+  
+    /* set text for download button */
     if (button) {
       $("#downloadForRealz").html($(link).text());
     } else {
       $("#downloadForRealz").html("Download " + $(link).text());
+    }
+    
+    /* if it's a bundle, show the 32/64-bit picker */
+    if (bundle) {
+      $("#downloadForRealz").attr('bundle','true');
+      if ($("#downloadForRealz").text().indexOf("Mac") == -1) {
+        $("p#bitpicker").show();
+      } else {
+        /* mac is always 64 bit, so set it checked */
+        $("p#bitpicker input[value=64]").attr('checked', true);
+      }
+      /* save link name until the bit version is chosen */
+      $("#downloadForRealz").attr('name',$(link).attr('href'));
+    } else {
+      /* if not using bundle, set download button to ignore bitpicker and set url */
+      $("#downloadForRealz").attr('bundle','false');
+      $("#downloadForRealz").attr('href',$(link).attr('href'));
+      /* set picker checked as a fake default */
+      $("p#bitpicker input[value=64]").attr('checked', true);
       $("a#next-link").html("Setting Up an Existing IDE").attr('href',toRoot + 'sdk/installing/index.html');
     }
-    $("#downloadForRealz").attr('href',$(link).attr('href'));
 
     $("#tos").fadeIn('fast');
     $("#landing").fadeOut('fast');
@@ -376,7 +392,18 @@
 
 
   function onAgreeChecked() {
-    if ($("input#agree").is(":checked")) {
+    /* verify that the TOS is agreed and a bit version is chosen */
+    if ($("input#agree").is(":checked") && $("#bitpicker input:checked").length) {
+      
+      /* if downloading the bundle */
+      if ($("#downloadForRealz").attr('bundle')) {
+        /* construct the name of the link we want based on the bit version */
+        linkId = $("a#downloadForRealz").attr("name") + $("#bitpicker input:checked").val();
+        /* set the real url for download */
+        $("a#downloadForRealz").attr("href", $(linkId).attr("href"));
+      }
+      
+      /* reveal the download button */
       $("a#downloadForRealz").removeClass('disabled');
     } else {
       $("a#downloadForRealz").addClass('disabled');
@@ -384,15 +411,15 @@
   }
 
   function onDownloadForRealz(link) {
-    if ($("input#agree").is(':checked')) {
+    if ($("input#agree").is(':checked') && $("#bitpicker input:checked").length) {
       $("div.sdk-terms").slideUp();
       $("#sdk-terms-form,.sdk-terms-intro").fadeOut('slow');
       $("#next-steps").fadeIn('slow');
       $("h1#tos-header").text('Get Ready to Code!');
       return true;
     } else {
-      $("label#agreeLabel").parent().stop().animate({color: "#258AAF"}, 200,
-        function() {$("label#agreeLabel").parent().stop().animate({color: "#222"}, 200)}
+      $("label#agreeLabel,#bitpicker input").parent().stop().animate({color: "#258AAF"}, 200,
+        function() {$("label#agreeLabel,#bitpicker input").parent().stop().animate({color: "#222"}, 200)}
       );
       return false;
     }