merge in lmp-mr1-nova-release history after reset to lmp-mr1-release
diff --git a/CleanSpec.mk b/CleanSpec.mk
index a4a44ca..6e7c9b0 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -304,6 +304,11 @@
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
 
+# 5.1!
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
+
 # ************************************************
 # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
 # ************************************************
diff --git a/core/Makefile b/core/Makefile
index eb3b1c3..15c7f02 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -200,6 +200,7 @@
 		echo "import /oem/oem.prop $(prop)" >> $@;)
 endif
 	$(hide) TARGET_BUILD_TYPE="$(TARGET_BUILD_VARIANT)" \
+			TARGET_BUILD_FLAVOR="$(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT)" \
 			TARGET_DEVICE="$(TARGET_DEVICE)" \
 			PRODUCT_NAME="$(TARGET_PRODUCT)" \
 			PRODUCT_BRAND="$(PRODUCT_BRAND)" \
diff --git a/core/build_id.mk b/core/build_id.mk
index 6d7d59f..b6a235c 100644
--- a/core/build_id.mk
+++ b/core/build_id.mk
@@ -18,4 +18,4 @@
 # (like "CRB01").  It must be a single word, and is
 # capitalized by convention.
 
-export BUILD_ID=LVX65I
+export BUILD_ID=LMX72F
diff --git a/core/prebuilt_internal.mk b/core/prebuilt_internal.mk
index 5c02f8d..e7a66f0 100644
--- a/core/prebuilt_internal.mk
+++ b/core/prebuilt_internal.mk
@@ -116,7 +116,7 @@
 
 # Select dpi-specific source
 ifdef LOCAL_DPI_VARIANTS
-my_dpi := $(filter $(LOCAL_DPI_VARIANTS),$(PRODUCT_AAPT_PREF_CONFIG))
+my_dpi := $(firstword $(filter $(LOCAL_DPI_VARIANTS),$(PRODUCT_AAPT_PREF_CONFIG) $(PRODUCT_AAPT_PREBUILT_DPI)))
 ifdef my_dpi
 ifdef LOCAL_DPI_FILE_STEM
 my_prebuilt_dpi_file_stem := $(LOCAL_DPI_FILE_STEM)
diff --git a/core/product.mk b/core/product.mk
index ed906cb..f0fc921 100644
--- a/core/product.mk
+++ b/core/product.mk
@@ -70,6 +70,7 @@
     PRODUCT_LOCALES \
     PRODUCT_AAPT_CONFIG \
     PRODUCT_AAPT_PREF_CONFIG \
+    PRODUCT_AAPT_PREBUILT_DPI \
     PRODUCT_PACKAGES \
     PRODUCT_PACKAGES_DEBUG \
     PRODUCT_PACKAGES_ENG \
diff --git a/core/product_config.mk b/core/product_config.mk
index 1efff2f..e7fa75e 100644
--- a/core/product_config.mk
+++ b/core/product_config.mk
@@ -306,6 +306,7 @@
 # Add PRODUCT_LOCALES to PRODUCT_AAPT_CONFIG
 PRODUCT_AAPT_CONFIG := $(strip $(PRODUCT_LOCALES) $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_AAPT_CONFIG))
 PRODUCT_AAPT_PREF_CONFIG := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_AAPT_PREF_CONFIG))
+PRODUCT_AAPT_PREBUILT_DPI := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_AAPT_PREBUILT_DPI))
 
 # Keep a copy of the space-separated config
 PRODUCT_AAPT_CONFIG_SP := $(PRODUCT_AAPT_CONFIG)
diff --git a/core/version_defaults.mk b/core/version_defaults.mk
index 1acc320..d87a032 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 := LollipopMR1
+  PLATFORM_VERSION := 5.1
 endif
 
 ifeq "" "$(PLATFORM_SDK_VERSION)"
diff --git a/target/board/generic_arm64/BoardConfig.mk b/target/board/generic_arm64/BoardConfig.mk
index 818f857..8afd5a8 100644
--- a/target/board/generic_arm64/BoardConfig.mk
+++ b/target/board/generic_arm64/BoardConfig.mk
@@ -76,7 +76,7 @@
 USE_OPENGL_RENDERER := true
 
 TARGET_USERIMAGES_USE_EXT4 := true
-BOARD_SYSTEMIMAGE_PARTITION_SIZE := 845427200
+BOARD_SYSTEMIMAGE_PARTITION_SIZE := 943718400
 BOARD_USERDATAIMAGE_PARTITION_SIZE := 576716800
 BOARD_CACHEIMAGE_PARTITION_SIZE := 69206016
 BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE := ext4
diff --git a/tools/buildinfo.sh b/tools/buildinfo.sh
index ed6bd87..a80b2db 100755
--- a/tools/buildinfo.sh
+++ b/tools/buildinfo.sh
@@ -16,6 +16,7 @@
 echo "ro.build.user=$USER"
 echo "ro.build.host=`hostname`"
 echo "ro.build.tags=$BUILD_VERSION_TAGS"
+echo "ro.build.flavor=$TARGET_BUILD_FLAVOR"
 echo "ro.product.model=$PRODUCT_MODEL"
 echo "ro.product.brand=$PRODUCT_BRAND"
 echo "ro.product.name=$PRODUCT_NAME"
diff --git a/tools/droiddoc/templates-sdk/assets/css/default.css b/tools/droiddoc/templates-sdk/assets/css/default.css
index 98bfaf8..0e437bc 100644
--- a/tools/droiddoc/templates-sdk/assets/css/default.css
+++ b/tools/droiddoc/templates-sdk/assets/css/default.css
@@ -3065,15 +3065,15 @@
   font-size:16px;
   font-weight:500;
 }
-/* hide all except eclipse by default */
-.select-ide.studio,
+/* hide all except studio by default */
+.select-ide.eclipse,
 .select-ide.other {
   display:none;
 }
-/* ... unless eclipse also includes one of the others */
-.select-ide.eclipse.studio,
-.select-ide.eclipse.other {
-  display:block;
+/* ... unless studio also includes one of the others */
+.select-ide.studio.eclipse,
+.select-ide.studio.other {
+  display:none;
 }
 
 
diff --git a/tools/droiddoc/templates-sdk/sdkpage.cs b/tools/droiddoc/templates-sdk/sdkpage.cs
index bbe6e97..e794307 100644
--- a/tools/droiddoc/templates-sdk/sdkpage.cs
+++ b/tools/droiddoc/templates-sdk/sdkpage.cs
@@ -264,15 +264,16 @@
 
 
 
-<h4><a href='' class="expandable"
-  onclick="toggleExpandable(this,'.pax');hideExpandable('.myide,.reqs');return false;"
-  >VIEW ALL DOWNLOADS AND SIZES</a></h4>
+<div class="pax col-13 online" style="margin:0;">
 
 
-<div class="pax col-13 online" style="display:none;margin:0;">
+<h3>SDK Tools Only</h3>
 
+<p>If you prefer to use a different IDE or run the tools from the
+command line or with build scripts, you can instead download the stand-alone Android SDK Tools.
+These packages provide the basic SDK tools for app development, without an IDE.
+Also see the <a href="<?cs var:toroot ?>tools/sdk/tools-notes.html">SDK tools release notes</a>.</p>
 
-<p class="table-caption"><strong>ADT Bundle</strong></p>
   <table class="download">
     <tr>
       <th>Platform</th>
@@ -281,72 +282,7 @@
       <th>MD5 Checksum</th>
   </tr>
   <tr>
-    <td>Windows 32-bit</td>
-    <td>
-  <a onClick="return onDownload(this)" id="win-bundle32"
-     href="https://dl.google.com/android/adt/<?cs var:sdk.win32_bundle_download ?>"><?cs var:sdk.win32_bundle_download ?></a>
-    </td>
-    <td><?cs var:sdk.win32_bundle_bytes ?> bytes</td>
-    <td><?cs var:sdk.win32_bundle_checksum ?></td>
-  </tr>
-  <tr>
-    <td>Windows 64-bit</td>
-    <td>
-  <a onClick="return onDownload(this)" id="win-bundle64"
-     href="https://dl.google.com/android/adt/<?cs var:sdk.win64_bundle_download ?>"><?cs var:sdk.win64_bundle_download ?></a>
-    </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="https://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="https://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="https://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>
-
-
-<p class="table-caption"><strong>SDK Tools Only</strong></p>
-  <table class="download">
-    <tr>
-      <th>Platform</th>
-      <th>Package</th>
-      <th>Size</th>
-      <th>MD5 Checksum</th>
-  </tr>
-  <tr>
-    <td rowspan="2">Windows<br>32 &amp; 64-bit</td>
-    <td>
-  <a onclick="return onDownload(this)" href="http://dl.google.com/android/<?cs var:sdk.win_download
-?>"><?cs var:sdk.win_download ?></a>
-    </td>
-    <td><?cs var:sdk.win_bytes ?> bytes</td>
-    <td><?cs var:sdk.win_checksum ?></td>
-  </tr>
-  <tr>
-    <!-- blank TD from Windows rowspan -->
+    <td rowspan="2">Windows</td>
     <td>
   <a onclick="return onDownload(this)" id="win-tools" href="http://dl.google.com/android/<?cs
 var:sdk.win_installer
@@ -356,7 +292,16 @@
     <td><?cs var:sdk.win_installer_checksum ?></td>
   </tr>
   <tr>
-    <td><nobr>Mac OS X</nobr><br>32 &amp; 64-bit</td>
+    <!-- blank TD from Windows rowspan -->
+    <td>
+  <a onclick="return onDownload(this)" href="http://dl.google.com/android/<?cs var:sdk.win_download
+?>"><?cs var:sdk.win_download ?></a>
+    </td>
+    <td><?cs var:sdk.win_bytes ?> bytes</td>
+    <td><?cs var:sdk.win_checksum ?></td>
+  </tr>
+  <tr>
+    <td><nobr>Mac OS X</nobr></td>
     <td>
   <a onclick="return onDownload(this)" id="mac-tools" href="http://dl.google.com/android/<?cs
 var:sdk.mac_download
@@ -366,7 +311,7 @@
     <td><?cs var:sdk.mac_checksum ?></td>
   </tr>
   <tr>
-    <td>Linux<br>32 &amp; 64-bit</td>
+    <td>Linux</td>
     <td>
   <a onclick="return onDownload(this)" id="linux-tools" href="http://dl.google.com/android/<?cs
 var:sdk.linux_download
@@ -377,6 +322,79 @@
   </tr>
   </table>
 
+
+
+<h3>All Android Studio Packages</h3>
+
+<p>Select a specific Android Studio package for your platform. Also see the
+<a href="<?cs var:toroot ?>tools/revisions/studio.html">Android Studio release notes</a>.</p>
+
+  <table class="download">
+    <tr>
+      <th>Platform</th>
+      <th>Package</th>
+      <th>Size</th>
+      <th>SHA Sum</th>
+  </tr>
+
+  <tr>
+    <td rowspan="3">Windows</td>
+    <td>
+  <a onclick="return onDownload(this)" id="win-bundle"
+    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>(Recommended)
+    </td>
+    <td><?cs var:studio.win_bundle_exe_bytes ?> bytes</td>
+    <td><?cs var:studio.win_bundle_exe_checksum ?></td>
+  </tr>
+
+  <tr>
+    <!-- blank TD from Windows rowspan -->
+    <td>
+  <a onclick="return onDownload(this)"
+    href="https://dl.google.com/dl/android/studio/install/<?cs var:studio.version ?>/<?cs var:studio.win_notools_exe_download ?>"
+    ><?cs var:studio.win_notools_exe_download ?></a><br>(No SDK tools included)
+    </td>
+    <td><?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)"
+    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>
+    </td>
+    <td><?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)" id="mac-bundle"
+    href="https://dl.google.com/dl/android/studio/install/<?cs var:studio.version ?>/<?cs var:studio.mac_bundle_download ?>"
+    ><?cs var:studio.mac_bundle_download ?></a>
+    </td>
+    <td><?cs var:studio.mac_bundle_bytes ?> bytes</td>
+    <td><?cs var:studio.mac_bundle_checksum ?></td>
+  </tr>
+
+  <tr>
+    <td>Linux</td>
+    <td>
+  <a onclick="return onDownload(this)" id="linux-bundle"
+    href="https://dl.google.com/dl/android/studio/ide-zips/<?cs var:studio.version ?>/<?cs var:studio.linux_bundle_download ?>"
+    ><?cs var:studio.linux_bundle_download ?></a>
+    </td>
+    <td><?cs var:studio.linux_bundle_bytes ?> bytes</td>
+    <td><?cs var:studio.linux_bundle_checksum ?></td>
+  </tr>
+  </table>
+
+
+
 </div><!-- end pax -->
 
 
@@ -397,7 +415,9 @@
   var bundlename;
   var $toolslink;
 
-  if (navigator.appVersion.indexOf("Win")!=-1) {
+  if (navigator.appVersion.indexOf("Mobile")!=-1) {
+    // Do nothing for any "mobile" user agent
+  } else if (navigator.appVersion.indexOf("Win")!=-1) {
     os = "Windows";
     bundlename = '#win-bundle';
     $toolslink = $('#win-tools');
@@ -405,26 +425,18 @@
     os = "Mac";
     bundlename = '#mac-bundle';
     $toolslink = $('#mac-tools');
-  } else if (navigator.appVersion.indexOf("Linux")!=-1) {
+  } else if (navigator.appVersion.indexOf("Linux")!=-1 && navigator.appVersion.indexOf("Android")==-1) {
     os = "Linux";
     bundlename = '#linux-bundle';
     $toolslink = $('#linux-tools');
   }
 
-  if (os) {
+  if (os != undefined) {
     $('#not-supported').hide();
 
-    /* set up primary adt download button */
-    $('#download-bundle-button').show();
-    $('#download-bundle-button').append("Download Eclipse ADT <br/><span class='small'>with the Android SDK for " + os + "</span>");
-    $('#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 stand-alone Android SDK Tools for " + os);
-    $('#download-tools-button').click(function() {return onDownload(this,true);}).attr('href', $toolslink.attr('href'));
-  } else {
-    $('.pax').show();
+    /* set up primary Android Studio download button */
+    $('.download-bundle-button').append(" <br/><span class='small'>for " + os + "</span>");
+    $('.download-bundle-button').click(function() {return onDownload(this,true,true);}).attr('href', bundlename);
   }
 
 
@@ -437,44 +449,29 @@
       $("#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('bundle', bundle);
+    $("a#downloadForRealz").attr("name", $(link).attr('href'));
 
-    $("#tos").fadeIn('fast');
-    $("#landing").fadeOut('fast');
+    $("#tos").show();
+    $("#landing").hide();
 
-    location.hash = "download";
+    location.hash = "top";
     return false;
   }
 
 
   function onAgreeChecked() {
-    /* verify that the TOS is agreed and a bit version is chosen */
-    if ($("input#agree").is(":checked") && $("#bitpicker input:checked").length) {
+    /* verify that the TOS is agreed */
+    if ($("input#agree").is(":checked")) {
 
       /* 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();
+        /* construct the name of the link we want */
+        linkId = $("a#downloadForRealz").attr("name");
         /* set the real url for download */
         $("a#downloadForRealz").attr("href", $(linkId).attr("href"));
+      } else {
+        $("a#downloadForRealz").attr("href", $("a#downloadForRealz").attr("name"));
       }
 
       /* reveal the download button */
@@ -485,25 +482,28 @@
   }
 
   function onDownloadForRealz(link) {
-    if ($("input#agree").is(':checked') && $("#bitpicker input:checked").length) {
+    if ($("input#agree").is(':checked')) {
+      location.hash = "";
+      location.hash = "top";
       $("div.sdk-terms").slideUp();
-      $("h1#tos-header").text('Now redirecting to the install instructions...');
-      $("#sdk-terms-form,.sdk-terms-intro").fadeOut('slow', function() {
+      $("h1#tos-header").text('Now downloading...');
+      $(".sdk-terms-intro").text('You\'ll be redirected to the install instructions in a moment.');
+      $("#sdk-terms-form").fadeOut('slow', function() {
         setTimeout(function() {
           if ($("#downloadForRealz").attr('bundle') == 'true') {
-            // User downloaded the ADT Bundle
-            window.location = "/sdk/installing/index.html?pkg=adt";
+            // User downloaded the studio Bundle
+            window.location = "/sdk/installing/index.html?pkg=studio";
           } else {
             // User downloaded the SDK Tools
             window.location = "/sdk/installing/index.html?pkg=tools";
           }
-        }, 500);
+        }, 3000);
       });
       ga('send', 'event', 'SDK', 'IDE and Tools', $("#downloadForRealz").html());
       return true;
     } else {
-      $("label#agreeLabel,#bitpicker input").parent().stop().animate({color: "#258AAF"}, 200,
-        function() {$("label#agreeLabel,#bitpicker input").parent().stop().animate({color: "#222"}, 200)}
+      $("label#agreeLabel").parent().stop().animate({color: "#258AAF"}, 200,
+        function() {$("label#agreeLabel").parent().stop().animate({color: "#222"}, 200)}
       );
       return false;
     }