Merge "docs: update Android docs build to include API 22, Android 5.1" into lmp-mr1-dev
diff --git a/docs/html/about/about_toc.cs b/docs/html/about/about_toc.cs
index b1357f2..62d37c5 100644
--- a/docs/html/about/about_toc.cs
+++ b/docs/html/about/about_toc.cs
@@ -16,6 +16,7 @@
               es-lang="Lollipop">
       <span class="en">Lollipop</span></a></div>
       <ul>
+        <li><a href="<?cs var:toroot ?>about/versions/android-5.1.html">Android 5.1 APIs</a></li>
         <li><a href="<?cs var:toroot ?>about/versions/android-5.0.html"
               zh-tw-lang="Android 5.0 API"
               zh-cn-lang="Android 5.0 API"
diff --git a/docs/html/about/versions/android-5.1.jd b/docs/html/about/versions/android-5.1.jd
new file mode 100644
index 0000000..12386805
--- /dev/null
+++ b/docs/html/about/versions/android-5.1.jd
@@ -0,0 +1,124 @@
+page.title=Android 5.1 APIs
+excludeFromSuggestions=true
+sdk.platform.version=5.1
+sdk.platform.apiLevel=22
+@jd:body
+
+
+<div id="qv-wrapper">
+<div id="qv">
+
+<h2>In this document
+    <a href="#" onclick="hideNestedItems('#toc44',this);return false;" class="header-toggle">
+        <span class="more">show more</span>
+        <span class="less" style="display:none">show less</span></a></h2>
+
+<ol id="toc44" class="hide-nested">
+  <li><a href="#ApiLevel">Update your target API level</a></li>
+
+  <li><a href="#multisim">Multiple SIM Card Support</a></li>
+  <li><a href="#http">Deprecated HTTP Classes</a></li>
+  <li><a href="#carrier">Carrier Services</a></li>
+</ol>
+
+<h2>API Differences</h2>
+<ol>
+<li><a href="{@docRoot}sdk/api_diff/22/changes.html">API level 21 to 22 &raquo;</a> </li>
+</ol>
+
+<h2>See Also</h2>
+<ol>
+<li><a href="{@docRoot}about/versions/lollipop.html">Android Lollipop Highlights</a> </li>
+</ol>
+
+
+</div>
+</div>
+
+<p>API Level: {@sdkPlatformApiLevel}</p>
+
+<p>
+  Android 5.1
+  (<a href="{@docRoot}reference/android/os/Build.VERSION_CODES.html#LOLLIPOP_MR1">LOLLIPOP_MR1</a>)
+  is an update to the Lollipop release that offers new features for users and app developers.
+  This document provides an introduction to the most notable new APIs.
+</p>
+
+<p>
+  For a high-level look at the new platform features, see the <a href=
+  "{@docRoot}about/versions/lollipop.html">Android Lollipop highlights</a>.
+</p>
+
+
+<h3 id="ApiLevel">Update your target API level</h3>
+
+<p>
+  To start building apps for Android 5.1, use the
+  <a href="{@docRoot}tools/help/sdk-manager.html">SDK Manager</a> to download the Android 5.1 SDK
+  Platform and System Images. Then set your app development project to use a
+  <a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#target">{@code targetSdkVersion}</a>
+  of <code>"{@sdkPlatformApiLevel}"</code>. Install your app on an Android {@sdkPlatformVersion}
+  system image, test it, then publish the updated app with this change.
+</p>
+
+<p>
+  You can use Android {@sdkPlatformVersion} APIs while also supporting older versions by adding
+  conditions to your code that check for the system API level before executing APIs not supported
+  by your <a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#min">{@code
+  minSdkVersion}</a>. To learn more about maintaining backward compatibility, read <a href=
+  "{@docRoot}training/basics/supporting-devices/platforms.html">Supporting Different Platform
+  Versions</a>.
+</p>
+
+<p>
+  For more information about how API levels work, read <a href=
+  "{@docRoot}guide/topics/manifest/uses-sdk-element.html#ApiLevels">What is API Level?</a>
+</p>
+
+<h2 id="multisim">Multiple SIM Card Support</h2>
+
+<p>
+  Android 5.1 adds support for using more than one cellular carrier SIM card at a time. This
+  feature lets users activate and use additional SIMs on devices that have two or more SIM card
+  slots.
+</p>
+
+<p>
+  You can access information about the currently active SIM through the {@link
+  android.telephony.SubscriptionManager} class, including whether or not the device is considered
+  to be roaming on the current network. This information is useful for developers who want to
+  throttle their apps' data access down or off for device users who are sensitive to data access
+  charges. Your app can be alerted to changes in a device's current network connection by
+  requesting the {@link android.Manifest.permission#READ_PHONE_STATE} permission and setting {@link
+  android.telephony.SubscriptionManager.OnSubscriptionsChangedListener} on the {@link
+  android.telephony.SubscriptionManager} object.
+</p>
+
+
+<h2 id="http">Deprecated HTTP Classes</h2>
+
+<p>
+  The {@code org.apache.http} classes and the {@link android.net.http.AndroidHttpClient} class
+  have been deprecated in Android 5.1. These classes are no longer being maintained and you should
+  migrate any app code using these APIs to the {@link java.net.URLConnection} classes as soon as
+  possible.
+</p>
+
+
+<h2 id="carrier">Carrier Services</h2>
+
+<p>
+  Android 5.1 provides support for telecommunication service providers to create apps that can
+  perform carrier provisioning tasks on an Android device. These APIs provide a secure and flexible
+  way for carrier-developed apps to perform these tasks and be distributed through Google Play. Apps
+  that use these functions must be signed by a certificate that matches the certificate in the
+  device's Universal Integrated Circuit Card (UICC).
+</p>
+
+<p>
+  The carrier service APIs have been added to the {@link android.telephony.TelephonyManager} class,
+  the {@link android.telephony.SmsManager} class, and the new {@link
+  android.service.carrier.CarrierMessagingService} class. Apps can check for access to these APIs
+  by calling the {@link android.telephony.TelephonyManager#hasCarrierPrivileges} method. Apps that
+  call these APIs without access receive a {@link java.lang.SecurityException}.
+</p>
diff --git a/docs/html/about/versions/lollipop.jd b/docs/html/about/versions/lollipop.jd
index 1ad5d24..8bc7200 100644
--- a/docs/html/about/versions/lollipop.jd
+++ b/docs/html/about/versions/lollipop.jd
@@ -55,6 +55,11 @@
 <a href="http://www.android.com/versions/lollipop-5-0/"
 >www.android.com</a>.</p>
 
+<p class="note">
+  <strong>Note:</strong> The Android 5.1 Lollipop MR1 update is available with additional features
+  and fixes. For more information, see the
+  <a href="{@docRoot}about/versions/android-5.1.html">Android 5.1 API Overview</a>.
+</p>
 
 
 <h2 id="Material">Material design</h2>
diff --git a/docs/html/guide/topics/manifest/uses-sdk-element.jd b/docs/html/guide/topics/manifest/uses-sdk-element.jd
index e5e64e5..3ac87ef 100644
--- a/docs/html/guide/topics/manifest/uses-sdk-element.jd
+++ b/docs/html/guide/topics/manifest/uses-sdk-element.jd
@@ -227,11 +227,16 @@
 <table>
   <tr><th>Platform Version</th><th>API Level</th><th>VERSION_CODE</th><th>Notes</th></tr>
 
+    <tr><td><a href="{@docRoot}about/versions/android-5.1.html">Android 5.1</a></td>
+    <td><a href="{@docRoot}sdk/api_diff/22/changes.html" title="Diff Report">22</a></td>
+    <td>{@link android.os.Build.VERSION_CODES#LOLLIPOP_MR1}</td>
+    <td rowspan="2"><a href="{@docRoot}about/versions/lollipop.html">Platform
+Highlights</a></td></tr>
+
     <tr><td><a href="{@docRoot}about/versions/android-5.0.html">Android 5.0</a></td>
     <td><a href="{@docRoot}sdk/api_diff/21/changes.html" title="Diff Report">21</a></td>
     <td>{@link android.os.Build.VERSION_CODES#LOLLIPOP}</td>
-    <td><a href="{@docRoot}about/versions/lollipop.html">Platform
-Highlights</a></td></tr>
+    </tr>
 
     <tr><td style="color:#bbb">Android 4.4W</td>
     <td><a href="{@docRoot}sdk/api_diff/20/changes.html" title="Diff Report">20</a></td>
diff --git a/docs/html/tools/sdk/tools-notes.jd b/docs/html/tools/sdk/tools-notes.jd
index e50b7ac..b5a6477 100644
--- a/docs/html/tools/sdk/tools-notes.jd
+++ b/docs/html/tools/sdk/tools-notes.jd
@@ -21,10 +21,38 @@
 <p>For a summary of all known issues in SDK Tools, see <a
 href="http://tools.android.com/knownissues">http://tools.android.com/knownissues</a>.</p>
 
-
 <div class="toggle-content opened">
   <p><a href="#" onclick="return toggleContent(this)">
     <img src="{@docRoot}assets/images/triangle-opened.png" class="toggle-content-img"
+      alt=""/>SDK Tools, Revision 24.1.2</a> <em>(February 2014)</em>
+  </p>
+
+  <div class="toggle-content-toggleme">
+
+    <dl>
+    <dt>Dependencies:</dt>
+
+    <dd>
+      <ul>
+        <li>Android SDK Platform-tools revision 19 or later.</li>
+      </ul>
+    </dd>
+
+    <dt>General Notes:</dt>
+    <dd>
+      <ul>
+        <li>Fixed boot failures of MIPS system images on Mac OS X.</li>
+        <li>Fixed AVD screen capture issues when using GPU emulation.</li>
+        <li>Fixed memory leaks in emulator system.</li>
+      </ul>
+    </dd>
+  </div>
+</div>
+
+
+<div class="toggle-content closed">
+  <p><a href="#" onclick="return toggleContent(this)">
+    <img src="{@docRoot}assets/images/triangle-closed.png" class="toggle-content-img"
       alt=""/>SDK Tools, Revision 24.0.2</a> <em>(December 2014)</em>
   </p>
 
@@ -96,7 +124,7 @@
     <dt>General Notes:</dt>
     <dd>
       <ul>
-        <li>Added support for Andriod Studio 1.0 and emulator enhancements.</li>
+        <li>Added support for Android Studio 1.0 and emulator enhancements.</li>
       </ul>
     </dd>
   </div>
diff --git a/services/core/java/com/android/server/TelephonyRegistry.java b/services/core/java/com/android/server/TelephonyRegistry.java
index 8d7a182..4fbf23b 100644
--- a/services/core/java/com/android/server/TelephonyRegistry.java
+++ b/services/core/java/com/android/server/TelephonyRegistry.java
@@ -259,7 +259,7 @@
                         + newDefaultSubIdObj + " newDefaultPhoneId=" + newDefaultPhoneId);
                 }
 
-                if(validatePhoneId(newDefaultPhoneId) && (newDefaultSubIdObj.equals(mDefaultSubId)
+                if(validatePhoneId(newDefaultPhoneId) && (!newDefaultSubIdObj.equals(mDefaultSubId)
                         || (newDefaultPhoneId != mDefaultPhoneId))) {
                     mHandler.sendMessage(mHandler.obtainMessage(MSG_UPDATE_DEFAULT_SUB,
                             newDefaultPhoneId, 0, newDefaultSubIdObj));