Merge "Support icons in the FloatingToolbar" into mnc-dev
diff --git a/api/current.txt b/api/current.txt
index 41acac5..15c4a9b 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -28383,7 +28383,6 @@
   }
 
   public final deprecated class KeyStoreParameter implements java.security.KeyStore.ProtectionParameter {
-    method public android.content.Context getContext();
     method public boolean isEncryptionRequired();
   }
 
diff --git a/api/system-current.txt b/api/system-current.txt
index 0f6bd2a..e7032c3 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -30409,7 +30409,6 @@
   }
 
   public final deprecated class KeyStoreParameter implements java.security.KeyStore.ProtectionParameter {
-    method public android.content.Context getContext();
     method public boolean isEncryptionRequired();
   }
 
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java
index 43678cc..62a1617 100644
--- a/core/java/android/content/Intent.java
+++ b/core/java/android/content/Intent.java
@@ -1560,6 +1560,42 @@
     public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
 
     /**
+     * Broadcast action that requests current permission granted information.  It will respond
+     * to the request by sending a broadcast with action defined by
+     * {@link #EXTRA_GET_PERMISSIONS_RESPONSE_INTENT}. The response will contain
+     * {@link #EXTRA_GET_PERMISSIONS_COUNT_RESULT} with contents described below or a null upon
+     * failure.
+     *
+     * <p>If {@link #EXTRA_PACKAGE_NAME} is included then the number of permissions granted and the
+     * number of permissions requested by that package will be calculated and included as the first
+     * and second elements respectively of an int[] in the response as
+     * {@link #EXTRA_GET_PERMISSIONS_COUNT_RESULT}.
+     *
+     * <p>If {@link #EXTRA_PACKAGE_NAME} is not included then the number of apps granted any runtime
+     * permissions and the total number of apps requesting runtime permissions will be the first
+     * and second elements respectively of an int[] in the response as
+     * {@link #EXTRA_GET_PERMISSIONS_COUNT_RESULT}.
+     *
+     * @hide
+     */
+    public static final String ACTION_GET_PERMISSIONS_COUNT
+            = "android.intent.action.GET_PERMISSIONS_COUNT";
+
+    /**
+     * Extra included in response to {@link #ACTION_GET_PERMISSIONS_COUNT}.
+     * @hide
+     */
+    public static final String EXTRA_GET_PERMISSIONS_COUNT_RESULT
+            = "android.intent.extra.GET_PERMISSIONS_COUNT_RESULT";
+
+    /**
+     * Required extra to be sent with {@link #ACTION_GET_PERMISSIONS_COUNT} broadcast.
+     * @hide
+     */
+    public static final String EXTRA_GET_PERMISSIONS_RESPONSE_INTENT
+            = "android.intent.extra.GET_PERMISSIONS_RESONSE_INTENT";
+
+    /**
      * Activity action: Launch UI to manage which apps have a given permission.
      * <p>
      * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission access
diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java
index acc27c3..596c0e4 100644
--- a/core/java/android/content/pm/PackageParser.java
+++ b/core/java/android/content/pm/PackageParser.java
@@ -2047,8 +2047,9 @@
             String tagName = parser.getName();
             if (tagName.equals("key-set")) {
                 if (currentKeySet != null) {
-                    Slog.w(TAG, "Improperly nested 'key-set' tag at "
-                            + parser.getPositionDescription());
+                    outError[0] = "Improperly nested 'key-set' tag at "
+                            + parser.getPositionDescription();
+                    mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
                     return false;
                 }
                 final TypedArray sa = res.obtainAttributes(attrs,
@@ -2061,8 +2062,9 @@
                 sa.recycle();
             } else if (tagName.equals("public-key")) {
                 if (currentKeySet == null) {
-                    Slog.w(TAG, "Improperly nested 'public-key' tag at "
-                            + parser.getPositionDescription());
+                    outError[0] = "Improperly nested 'key-set' tag at "
+                            + parser.getPositionDescription();
+                    mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
                     return false;
                 }
                 final TypedArray sa = res.obtainAttributes(attrs,
@@ -2072,8 +2074,9 @@
                 final String encodedKey = sa.getNonResourceString(
                             com.android.internal.R.styleable.AndroidManifestPublicKey_value);
                 if (encodedKey == null && publicKeys.get(publicKeyName) == null) {
-                    Slog.w(TAG, "'public-key' " + publicKeyName + " must define a public-key value"
-                            + " on first use at " + parser.getPositionDescription());
+                    outError[0] = "'public-key' " + publicKeyName + " must define a public-key value"
+                            + " on first use at " + parser.getPositionDescription();
+                    mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
                     sa.recycle();
                     return false;
                 } else if (encodedKey != null) {
@@ -2093,9 +2096,10 @@
                         /* public-key first definition, or matches old definition */
                         publicKeys.put(publicKeyName, currentKey);
                     } else {
-                        Slog.w(TAG, "Value of 'public-key' " + publicKeyName
+                        outError[0] = "Value of 'public-key' " + publicKeyName
                                + " conflicts with previously defined value at "
-                               + parser.getPositionDescription());
+                               + parser.getPositionDescription();
+                        mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
                         sa.recycle();
                         return false;
                     }
@@ -2112,9 +2116,10 @@
                 sa.recycle();
                 XmlUtils.skipCurrentTag(parser);
             } else if (RIGID_PARSER) {
-                Slog.w(TAG, "Bad element under <key-sets>: " + parser.getName()
+                outError[0] = "Bad element under <key-sets>: " + parser.getName()
                         + " at " + mArchiveSourcePath + " "
-                        + parser.getPositionDescription());
+                        + parser.getPositionDescription();
+                mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
                 return false;
             } else {
                 Slog.w(TAG, "Unknown element under <key-sets>: " + parser.getName()
@@ -2126,8 +2131,9 @@
         }
         Set<String> publicKeyNames = publicKeys.keySet();
         if (publicKeyNames.removeAll(definedKeySets.keySet())) {
-            Slog.w(TAG, "Package" + owner.packageName + " AndroidManifext.xml "
-                   + "'key-set' and 'public-key' names must be distinct.");
+            outError[0] = "Package" + owner.packageName + " AndroidManifext.xml "
+                    + "'key-set' and 'public-key' names must be distinct.";
+            mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
             return false;
         }
         owner.mKeySetMapping = new ArrayMap<String, ArraySet<PublicKey>>();
@@ -2152,8 +2158,9 @@
         if (owner.mKeySetMapping.keySet().containsAll(upgradeKeySets)) {
             owner.mUpgradeKeySets = upgradeKeySets;
         } else {
-            Slog.w(TAG, "Package" + owner.packageName + " AndroidManifext.xml "
-                   + "does not define all 'upgrade-key-set's .");
+            outError[0] ="Package" + owner.packageName + " AndroidManifext.xml "
+                   + "does not define all 'upgrade-key-set's .";
+            mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
             return false;
         }
         return true;
diff --git a/core/java/android/net/ConnectivityManager.java b/core/java/android/net/ConnectivityManager.java
index e175e9a..3a3c47d 100644
--- a/core/java/android/net/ConnectivityManager.java
+++ b/core/java/android/net/ConnectivityManager.java
@@ -611,11 +611,11 @@
 
     /**
      * Retrieves the current preferred network type.
+     * <p>This method requires the caller to hold the permission
+     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
      *
      * @return an integer representing the preferred network type
      *
-     * <p>This method requires the caller to hold the permission
-     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
      * @deprecated Functionality has been removed as it no longer makes sense,
      *             with many more than two networks - we'd need an array to express
      *             preference.  Instead we use dynamic network properties of
@@ -631,12 +631,11 @@
      * You should always check {@link NetworkInfo#isConnected()} before initiating
      * network traffic. This may return {@code null} when there is no default
      * network.
+     * <p>This method requires the caller to hold the permission
+     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
      *
      * @return a {@link NetworkInfo} object for the current default network
      *        or {@code null} if no default network is currently active
-     *
-     * <p>This method requires the caller to hold the permission
-     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
      */
     public NetworkInfo getActiveNetworkInfo() {
         try {
@@ -652,12 +651,11 @@
      * network disconnects, the returned {@code Network} object will no longer
      * be usable.  This will return {@code null} when there is no default
      * network.
+     * <p>This method requires the caller to hold the permission
+     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
      *
      * @return a {@link Network} object for the current default network or
      *        {@code null} if no default network is currently active
-     *
-     * <p>This method requires the caller to hold the permission
-     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
      */
     public Network getActiveNetwork() {
         try {
@@ -671,13 +669,13 @@
      * Returns details about the currently active default data network
      * for a given uid.  This is for internal use only to avoid spying
      * other apps.
+     * <p>This method requires the caller to hold the permission
+     * {@link android.Manifest.permission#CONNECTIVITY_INTERNAL}
      *
      * @return a {@link NetworkInfo} object for the current default network
      *        for the given uid or {@code null} if no default network is
      *        available for the specified uid.
      *
-     * <p>This method requires the caller to hold the permission
-     * {@link android.Manifest.permission#CONNECTIVITY_INTERNAL}
      * {@hide}
      */
     public NetworkInfo getActiveNetworkInfoForUid(int uid) {
@@ -691,6 +689,8 @@
     /**
      * Returns connection status information about a particular
      * network type.
+     * <p>This method requires the caller to hold the permission
+     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
      *
      * @param networkType integer specifying which networkType in
      *        which you're interested.
@@ -698,9 +698,6 @@
      *        network type or {@code null} if the type is not
      *        supported by the device.
      *
-     * <p>This method requires the caller to hold the permission
-     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
-     *
      * @deprecated This method does not support multiple connected networks
      *             of the same type. Use {@link #getAllNetworks} and
      *             {@link #getNetworkInfo(android.net.Network)} instead.
@@ -716,15 +713,14 @@
     /**
      * Returns connection status information about a particular
      * Network.
+     * <p>This method requires the caller to hold the permission
+     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
      *
      * @param network {@link Network} specifying which network
      *        in which you're interested.
      * @return a {@link NetworkInfo} object for the requested
      *        network or {@code null} if the {@code Network}
      *        is not valid.
-     *
-     * <p>This method requires the caller to hold the permission
-     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
      */
     public NetworkInfo getNetworkInfo(Network network) {
         try {
@@ -737,13 +733,12 @@
     /**
      * Returns connection status information about all network
      * types supported by the device.
+     * <p>This method requires the caller to hold the permission
+     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
      *
      * @return an array of {@link NetworkInfo} objects.  Check each
      * {@link NetworkInfo#getType} for which type each applies.
      *
-     * <p>This method requires the caller to hold the permission
-     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
-     *
      * @deprecated This method does not support multiple connected networks
      *             of the same type. Use {@link #getAllNetworks} and
      *             {@link #getNetworkInfo(android.net.Network)} instead.
@@ -779,11 +774,10 @@
     /**
      * Returns an array of all {@link Network} currently tracked by the
      * framework.
-     *
-     * @return an array of {@link Network} objects.
-     *
      * <p>This method requires the caller to hold the permission
      * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
+     *
+     * @return an array of {@link Network} objects.
      */
     public Network[] getAllNetworks() {
         try {
@@ -812,13 +806,12 @@
      * You should always check {@link NetworkInfo#isConnected()} before initiating
      * network traffic. This may return {@code null} when there is no default
      * network.
+     * <p>This method requires the caller to hold the permission
+     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
      *
      * @return a {@link NetworkInfo} object for the current default network
      *        or {@code null} if no default network is currently active
      *
-     * <p>This method requires the caller to hold the permission
-     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
-     *
      * {@hide}
      */
     public NetworkInfo getProvisioningOrActiveNetworkInfo() {
@@ -831,13 +824,13 @@
 
     /**
      * Returns the IP information for the current default network.
+     * <p>This method requires the caller to hold the permission
+     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
      *
      * @return a {@link LinkProperties} object describing the IP info
      *        for the current default network, or {@code null} if there
      *        is no current default network.
      *
-     * <p>This method requires the caller to hold the permission
-     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
      * {@hide}
      */
     public LinkProperties getActiveLinkProperties() {
@@ -850,14 +843,14 @@
 
     /**
      * Returns the IP information for a given network type.
+     * <p>This method requires the caller to hold the permission
+     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
      *
      * @param networkType the network type of interest.
      * @return a {@link LinkProperties} object describing the IP info
      *        for the given networkType, or {@code null} if there is
      *        no current default network.
      *
-     * <p>This method requires the caller to hold the permission
-     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
      * {@hide}
      * @deprecated This method does not support multiple connected networks
      *             of the same type. Use {@link #getAllNetworks},
@@ -875,10 +868,12 @@
     /**
      * Get the {@link LinkProperties} for the given {@link Network}.  This
      * will return {@code null} if the network is unknown.
+     * <p>This method requires the caller to hold the permission
+     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
      *
      * @param network The {@link Network} object identifying the network in question.
      * @return The {@link LinkProperties} for the network, or {@code null}.
-     **/
+     */
     public LinkProperties getLinkProperties(Network network) {
         try {
             return mService.getLinkProperties(network);
@@ -890,6 +885,8 @@
     /**
      * Get the {@link android.net.NetworkCapabilities} for the given {@link Network}.  This
      * will return {@code null} if the network is unknown.
+     * <p>This method requires the caller to hold the permission
+     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
      *
      * @param network The {@link Network} object identifying the network in question.
      * @return The {@link android.net.NetworkCapabilities} for the network, or {@code null}.
@@ -1493,11 +1490,11 @@
     /**
      * Get the set of tetherable, available interfaces.  This list is limited by
      * device configuration and current interface existence.
+     * <p>This method requires the caller to hold the permission
+     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
      *
      * @return an array of 0 or more Strings of tetherable interface names.
      *
-     * <p>This method requires the caller to hold the permission
-     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
      * {@hide}
      */
     public String[] getTetherableIfaces() {
@@ -1510,11 +1507,11 @@
 
     /**
      * Get the set of tethered interfaces.
+     * <p>This method requires the caller to hold the permission
+     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
      *
      * @return an array of 0 or more String of currently tethered interface names.
      *
-     * <p>This method requires the caller to hold the permission
-     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
      * {@hide}
      */
     public String[] getTetheredIfaces() {
@@ -1532,12 +1529,12 @@
      * may cause them to reset to the available state.
      * {@link ConnectivityManager#getLastTetherError} can be used to get more
      * information on the cause of the errors.
+     * <p>This method requires the caller to hold the permission
+     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
      *
      * @return an array of 0 or more String indicating the interface names
      *        which failed to tether.
      *
-     * <p>This method requires the caller to hold the permission
-     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
      * {@hide}
      */
     public String[] getTetheringErroredIfaces() {
@@ -1570,12 +1567,12 @@
      * allowed between the tethered devices and this device, though upstream net
      * access will of course fail until an upstream network interface becomes
      * active.
+     * <p>This method requires the caller to hold the permission
+     * {@link android.Manifest.permission#CHANGE_NETWORK_STATE}.
      *
      * @param iface the interface name to tether.
      * @return error a {@code TETHER_ERROR} value indicating success or failure type
      *
-     * <p>This method requires the caller to hold the permission
-     * {@link android.Manifest.permission#CHANGE_NETWORK_STATE}.
      * {@hide}
      */
     public int tether(String iface) {
@@ -1588,12 +1585,12 @@
 
     /**
      * Stop tethering the named interface.
+     * <p>This method requires the caller to hold the permission
+     * {@link android.Manifest.permission#CHANGE_NETWORK_STATE}.
      *
      * @param iface the interface name to untether.
      * @return error a {@code TETHER_ERROR} value indicating success or failure type
      *
-     * <p>This method requires the caller to hold the permission
-     * {@link android.Manifest.permission#CHANGE_NETWORK_STATE}.
      * {@hide}
      */
     public int untether(String iface) {
@@ -1608,11 +1605,11 @@
      * Check if the device allows for tethering.  It may be disabled via
      * {@code ro.tether.denied} system property, Settings.TETHER_SUPPORTED or
      * due to device configuration.
+     * <p>This method requires the caller to hold the permission
+     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
      *
      * @return a boolean - {@code true} indicating Tethering is supported.
      *
-     * <p>This method requires the caller to hold the permission
-     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
      * {@hide}
      */
     public boolean isTetheringSupported() {
@@ -1627,12 +1624,12 @@
      * Get the list of regular expressions that define any tetherable
      * USB network interfaces.  If USB tethering is not supported by the
      * device, this list should be empty.
+     * <p>This method requires the caller to hold the permission
+     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
      *
      * @return an array of 0 or more regular expression Strings defining
      *        what interfaces are considered tetherable usb interfaces.
      *
-     * <p>This method requires the caller to hold the permission
-     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
      * {@hide}
      */
     public String[] getTetherableUsbRegexs() {
@@ -1647,12 +1644,12 @@
      * Get the list of regular expressions that define any tetherable
      * Wifi network interfaces.  If Wifi tethering is not supported by the
      * device, this list should be empty.
+     * <p>This method requires the caller to hold the permission
+     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
      *
      * @return an array of 0 or more regular expression Strings defining
      *        what interfaces are considered tetherable wifi interfaces.
      *
-     * <p>This method requires the caller to hold the permission
-     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
      * {@hide}
      */
     public String[] getTetherableWifiRegexs() {
@@ -1667,12 +1664,12 @@
      * Get the list of regular expressions that define any tetherable
      * Bluetooth network interfaces.  If Bluetooth tethering is not supported by the
      * device, this list should be empty.
+     * <p>This method requires the caller to hold the permission
+     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
      *
      * @return an array of 0 or more regular expression Strings defining
      *        what interfaces are considered tetherable bluetooth interfaces.
      *
-     * <p>This method requires the caller to hold the permission
-     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
      * {@hide}
      */
     public String[] getTetherableBluetoothRegexs() {
@@ -1689,12 +1686,12 @@
      * attempt to switch to Rndis and subsequently tether the resulting
      * interface on {@code true} or turn off tethering and switch off
      * Rndis on {@code false}.
+     * <p>This method requires the caller to hold the permission
+     * {@link android.Manifest.permission#CHANGE_NETWORK_STATE}.
      *
      * @param enable a boolean - {@code true} to enable tethering
      * @return error a {@code TETHER_ERROR} value indicating success or failure type
      *
-     * <p>This method requires the caller to hold the permission
-     * {@link android.Manifest.permission#CHANGE_NETWORK_STATE}.
      * {@hide}
      */
     public int setUsbTethering(boolean enable) {
@@ -1731,13 +1728,13 @@
     /**
      * Get a more detailed error code after a Tethering or Untethering
      * request asynchronously failed.
+     * <p>This method requires the caller to hold the permission
+     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
      *
      * @param iface The name of the interface of interest
      * @return error The error code of the last error tethering or untethering the named
      *               interface
      *
-     * <p>This method requires the caller to hold the permission
-     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
      * {@hide}
      */
     public int getLastTetherError(String iface) {
@@ -1751,12 +1748,11 @@
     /**
      * Report network connectivity status.  This is currently used only
      * to alter status bar UI.
+     * <p>This method requires the caller to hold the permission
+     * {@link android.Manifest.permission#STATUS_BAR}.
      *
      * @param networkType The type of network you want to report on
      * @param percentage The quality of the connection 0 is bad, 100 is good
-     *
-     * <p>This method requires the caller to hold the permission
-     * {@link android.Manifest.permission#STATUS_BAR}.
      * {@hide}
      */
     public void reportInetCondition(int networkType, int percentage) {
@@ -1886,12 +1882,11 @@
      * for typical HTTP proxies - they are general network dependent.  However if you're
      * doing something unusual like general internal filtering this may be useful.  On
      * a private network where the proxy is not accessible, you may break HTTP using this.
-     *
-     * @param p The a {@link ProxyInfo} object defining the new global
-     *        HTTP proxy.  A {@code null} value will clear the global HTTP proxy.
-     *
      * <p>This method requires the caller to hold the permission
      * android.Manifest.permission#CONNECTIVITY_INTERNAL.
+     *
+     * @param p A {@link ProxyInfo} object defining the new global
+     *        HTTP proxy.  A {@code null} value will clear the global HTTP proxy.
      * @hide
      */
     public void setGlobalProxy(ProxyInfo p) {
@@ -1958,12 +1953,12 @@
      * hardware supports it.  For example a GSM phone without a SIM
      * should still return {@code true} for mobile data, but a wifi only
      * tablet would return {@code false}.
+     * <p>This method requires the caller to hold the permission
+     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
      *
      * @param networkType The network type we'd like to check
      * @return {@code true} if supported, else {@code false}
      *
-     * <p>This method requires the caller to hold the permission
-     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
      * @hide
      */
     public boolean isNetworkSupported(int networkType) {
@@ -1980,12 +1975,11 @@
      * battery/performance issues. You should check this before doing large
      * data transfers, and warn the user or delay the operation until another
      * network is available.
+     * <p>This method requires the caller to hold the permission
+     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
      *
      * @return {@code true} if large transfers should be avoided, otherwise
      *        {@code false}.
-     *
-     * <p>This method requires the caller to hold the permission
-     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
      */
     public boolean isActiveNetworkMetered() {
         try {
@@ -2015,13 +2009,12 @@
     /**
      * Signal that the captive portal check on the indicated network
      * is complete and whether its a captive portal or not.
+     * <p>This method requires the caller to hold the permission
+     * {@link android.Manifest.permission#CONNECTIVITY_INTERNAL}.
      *
      * @param info the {@link NetworkInfo} object for the networkType
      *        in question.
      * @param isCaptivePortal true/false.
-     *
-     * <p>This method requires the caller to hold the permission
-     * {@link android.Manifest.permission#CONNECTIVITY_INTERNAL}.
      * {@hide}
      */
     public void captivePortalCheckCompleted(NetworkInfo info, boolean isCaptivePortal) {
@@ -2093,11 +2086,11 @@
 
     /**
      * Set the value for enabling/disabling airplane mode
+     * <p>This method requires the caller to hold the permission
+     * {@link android.Manifest.permission#CONNECTIVITY_INTERNAL}.
      *
      * @param enable whether to enable airplane mode or not
      *
-     * <p>This method requires the caller to hold the permission
-     * {@link android.Manifest.permission#CONNECTIVITY_INTERNAL}.
      * @hide
      */
     public void setAirplaneMode(boolean enable) {
@@ -2438,6 +2431,8 @@
      * Status of the request can be followed by listening to the various
      * callbacks described in {@link NetworkCallback}.  The {@link Network}
      * can be used to direct traffic to the network.
+     * <p>This method requires the caller to hold the permission
+     * {@link android.Manifest.permission#CHANGE_NETWORK_STATE}.
      *
      * @param request {@link NetworkRequest} describing this request.
      * @param networkCallback The {@link NetworkCallback} to be utilized for this
@@ -2457,6 +2452,8 @@
      * network is not found within the given time (in milliseconds) the
      * {@link NetworkCallback#unavailable} callback is called.  The request must
      * still be released normally by calling {@link releaseNetworkRequest}.
+     * <p>This method requires the caller to hold the permission
+     * {@link android.Manifest.permission#CHANGE_NETWORK_STATE}.
      * @param request {@link NetworkRequest} describing this request.
      * @param networkCallback The callbacks to be utilized for this request.  Note
      *                        the callbacks must not be shared - they uniquely specify
@@ -2522,7 +2519,8 @@
      * <p>
      * The request may be released normally by calling
      * {@link #releaseNetworkRequest(android.app.PendingIntent)}.
-     *
+     * <p>This method requires the caller to hold the permission
+     * {@link android.Manifest.permission#CHANGE_NETWORK_STATE}.
      * @param request {@link NetworkRequest} describing this request.
      * @param operation Action to perform when the network is available (corresponds
      *                  to the {@link NetworkCallback#onAvailable} call.  Typically
@@ -2563,6 +2561,8 @@
      * Registers to receive notifications about all networks which satisfy the given
      * {@link NetworkRequest}.  The callbacks will continue to be called until
      * either the application exits or {@link #unregisterNetworkCallback} is called
+     * <p>This method requires the caller to hold the permission
+     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
      *
      * @param request {@link NetworkRequest} describing this request.
      * @param networkCallback The {@link NetworkCallback} that the system will call as suitable
diff --git a/core/java/android/preference/RingtonePreference.java b/core/java/android/preference/RingtonePreference.java
index 488a0c4..a76bb09 100644
--- a/core/java/android/preference/RingtonePreference.java
+++ b/core/java/android/preference/RingtonePreference.java
@@ -19,6 +19,7 @@
 import android.content.Context;
 import android.content.Intent;
 import android.content.res.TypedArray;
+import android.media.AudioAttributes;
 import android.media.RingtoneManager;
 import android.net.Uri;
 import android.provider.Settings.System;
@@ -169,6 +170,8 @@
         ringtonePickerIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, mShowSilent);
         ringtonePickerIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, mRingtoneType);
         ringtonePickerIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, getTitle());
+        ringtonePickerIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_AUDIO_ATTRIBUTES_FLAGS,
+                AudioAttributes.FLAG_BYPASS_INTERRUPTION_POLICY);
     }
     
     /**
diff --git a/core/java/android/service/chooser/ChooserTargetService.java b/core/java/android/service/chooser/ChooserTargetService.java
index 0d1834a..a3bfece 100644
--- a/core/java/android/service/chooser/ChooserTargetService.java
+++ b/core/java/android/service/chooser/ChooserTargetService.java
@@ -44,7 +44,7 @@
  * the {@link android.Manifest.permission#BIND_CHOOSER_TARGET_SERVICE} permission
  * and include an intent filter with the {@link #SERVICE_INTERFACE} action. For example:</p>
  * <pre>
- *     &lt;service android:name=".ChooserTargetService"
+ *     &lt;service android:name=".MyChooserTargetService"
  *             android:label="&#64;string/service_name"
  *             android:permission="android.permission.BIND_CHOOSER_TARGET_SERVICE">
  *         &lt;intent-filter>
@@ -69,7 +69,7 @@
  *             &lt;action android:name="android.intent.action.SEND" />
  *         &lt;/intent-filter>
  *         &lt;meta-data android:name="android.service.chooser.chooser_target_service"
- *                 android:value=".ChooserTargetService" />
+ *                 android:value=".MyChooserTargetService" />
  *     &lt;/activity>
  * </pre>
  */
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 41f906a..e59560f 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -66,6 +66,7 @@
 import android.view.accessibility.AccessibilityManager.AccessibilityStateChangeListener;
 import android.view.accessibility.AccessibilityManager.HighTextContrastChangeListener;
 import android.view.accessibility.AccessibilityNodeInfo;
+import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction;
 import android.view.accessibility.AccessibilityNodeProvider;
 import android.view.accessibility.IAccessibilityInteractionConnection;
 import android.view.accessibility.IAccessibilityInteractionConnectionCallback;
@@ -6354,16 +6355,18 @@
      *              {@link AccessibilityEvent#TYPE_WINDOW_CONTENT_CHANGED}
      */
     private void handleWindowContentChangedEvent(AccessibilityEvent event) {
-        // No virtual view focused, nothing to do here.
-        if (mAccessibilityFocusedHost == null || mAccessibilityFocusedVirtualView == null) {
+        final View focusedHost = mAccessibilityFocusedHost;
+        if (focusedHost == null || mAccessibilityFocusedVirtualView == null) {
+            // No virtual view focused, nothing to do here.
             return;
         }
 
-        // If we have a node but no provider, abort.
-        final AccessibilityNodeProvider provider =
-                mAccessibilityFocusedHost.getAccessibilityNodeProvider();
+        final AccessibilityNodeProvider provider = focusedHost.getAccessibilityNodeProvider();
         if (provider == null) {
-            // TODO: Should we clear the focused virtual view?
+            // Error state: virtual view with no provider. Clear focus.
+            mAccessibilityFocusedHost = null;
+            mAccessibilityFocusedVirtualView = null;
+            focusedHost.clearAccessibilityFocusNoCallbacks();
             return;
         }
 
@@ -6410,10 +6413,23 @@
         final Rect oldBounds = mTempRect;
         mAccessibilityFocusedVirtualView.getBoundsInScreen(oldBounds);
         mAccessibilityFocusedVirtualView = provider.createAccessibilityNodeInfo(focusedChildId);
-        final Rect newBounds = mAccessibilityFocusedVirtualView.getBoundsInScreen();
-        if (!oldBounds.equals(newBounds)) {
-            oldBounds.union(newBounds);
+        if (mAccessibilityFocusedVirtualView == null) {
+            // Error state: The node no longer exists. Clear focus.
+            mAccessibilityFocusedHost = null;
+            focusedHost.clearAccessibilityFocusNoCallbacks();
+
+            // This will probably fail, but try to keep the provider's internal
+            // state consistent by clearing focus.
+            provider.performAction(focusedChildId,
+                    AccessibilityAction.ACTION_CLEAR_ACCESSIBILITY_FOCUS.getId(), null);
             invalidateRectOnScreen(oldBounds);
+        } else {
+            // The node was refreshed, invalidate bounds if necessary.
+            final Rect newBounds = mAccessibilityFocusedVirtualView.getBoundsInScreen();
+            if (!oldBounds.equals(newBounds)) {
+                oldBounds.union(newBounds);
+                invalidateRectOnScreen(oldBounds);
+            }
         }
     }
 
diff --git a/docs/html/tools/support-library/features.jd b/docs/html/tools/support-library/features.jd
index 573baad..926578a 100644
--- a/docs/html/tools/support-library/features.jd
+++ b/docs/html/tools/support-library/features.jd
@@ -22,6 +22,8 @@
       <li><a href="#v8">v8 Support Library</a></li>
       <li><a href="#v13">v13 Support Library</a></li>
       <li><a href="#v17-leanback">v17 Leanback Library</a></li>
+      <li><a href="#annotations">Annotations Support Library</a></li>
+      <li><a href="#design">Design Support Library</a></li>
     </ol>
 
     <h2>See also</h2>
@@ -131,11 +133,11 @@
   API reference.
 </p>
 
-<p>This library is located in the {@code &lt;sdk&gt;/extras/android/support/v4/} directory after
-  you download the Android Support Libraries. The library does not contain user interface
-  resources. To include it in your application project, follow the instructions for
-  <a href="{@docRoot}tools/support-library/setup.html#libs-without-res">Adding libraries without
-  resources</a>.</p>
+<p>After you download the Android Support Libraries, this library is located in the
+{@code &lt;sdk&gt;/extras/android/support/v4/} directory. The library does not contain user
+interface resources. To include it in your application project, follow the instructions for
+<a href="{@docRoot}tools/support-library/setup.html#libs-without-res">Adding libraries without
+resources</a>.</p>
 
 <p class="caution"><strong>Caution:</strong> Using dynamic dependencies, especially for higher version
 numbers, can cause unexpected version updates and regression incompatibilities.</p>
@@ -158,10 +160,11 @@
 </p>
 
 <p>
-  This library is located in the {@code &lt;sdk&gt;/extras/android/support/multidex/} directory
-  after you download the Android Support Libraries. The library does not contain user interface
-  resources. To include it in your application project, follow the instructions for <a href=
-  "{@docRoot}tools/support-library/setup.html#libs-without-res">Adding libraries without
+  After you download the Android Support Libraries, this library is located in the
+  {@code &lt;sdk&gt;/extras/android/support/multidex/} directory. The library does not contain
+  user interface resources. To include it in your application project, follow the instructions
+  for
+  <a href= "{@docRoot}tools/support-library/setup.html#libs-without-res">Adding libraries without
   resources</a>.
 </p>
 
@@ -218,11 +221,11 @@
   </li>
 </ul>
 
-<p>This library is located in the {@code &lt;sdk&gt;/extras/android/support/v7/appcompat/}
-  directory after you download the Android Support Libraries. The library contains user
-  interface resources. To include it in your application project, follow the instructions for
-  <a href="{@docRoot}tools/support-library/setup.html#libs-with-res">Adding libraries with
-  resources</a>.</p>
+<p>After you download the Android Support Libraries, this library is located in the
+{@code &lt;sdk&gt;/extras/android/support/v7/appcompat/} directory. The library contains user
+interface resources. To include it in your application project, follow the instructions for
+<a href="{@docRoot}tools/support-library/setup.html#libs-with-res">Adding libraries with
+resources</a>.</p>
 
 <p>The Gradle build script dependency identifier for this library is as follows:</p>
 
@@ -239,9 +242,8 @@
 on any app. These cards are useful for material design
 implementations, and are used extensively in layouts for TV apps.</p>
 
-<p>This library is located in the
-{@code &lt;sdk&gt;/extras/android/support/v7/cardview/} directory after you
-download the Android Support Libraries. The library contains user interface
+<p>After you download the Android Support Libraries, this library is located in the
+{@code &lt;sdk&gt;/extras/android/support/v7/cardview/} directory. The library contains user interface
 resources. To include it in your application project, follow the instructions
 for <a href="{@docRoot}tools/support-library/setup.html#libs-with-res">Adding
 libraries with resources</a>.</p>
@@ -256,13 +258,14 @@
 
 <h3 id="v7-gridlayout">v7 gridlayout library</h3>
 
-<p>This library adds support for the {@link android.support.v7.widget.GridLayout} class, which
-  allows you to arrange user interface elements using a grid of rectangular cells.
-  For detailed information about the v7 gridlayout library APIs, see the
-  {@link android.support.v7.widget android.support.v7.widget} package in the API reference.</p>
+<p>After you download the Android Support Libraries, this library adds support for the
+{@link android.support.v7.widget.GridLayout} class, which
+allows you to arrange user interface elements using a grid of rectangular cells.
+For detailed information about the v7 gridlayout library APIs, see the
+{@link android.support.v7.widget android.support.v7.widget} package in the API reference.</p>
 
 <p>This library is located in the {@code &lt;sdk&gt;/extras/android/support/v7/gridlayout/}
-  directory after you download the Android Support Libraries. The library contains user
+  directory . The library contains user
   interface resources. To include it in your application project, follow the instructions for
   <a href="{@docRoot}tools/support-library/setup.html#libs-with-res">Adding libraries with
   resources</a>.</p>
@@ -323,12 +326,11 @@
 from an album cover, and use those colors to build a color-coordinated song
 title card.</p>
 
-<p>This library is located in the
-{@code &lt;sdk&gt;/extras/android/support/v7/palette/} directory after
-  you download the Android Support Libraries. The library does not contain user interface
-  resources. To include it in your application project, follow the instructions for
-  <a href="{@docRoot}tools/support-library/setup.html#libs-without-res">Adding libraries without
-  resources</a>.</p>
+<p>After you download the Android Support Libraries, this library is located in the
+{@code &lt;sdk&gt;/extras/android/support/v7/palette/} directory. The library does not contain
+user interface resources. To include it in your application project, follow the instructions for
+<a href="{@docRoot}tools/support-library/setup.html#libs-without-res">Adding libraries without
+resources</a>.</p>
 
 <p>The Gradle build script dependency identifier for this library is as follows:</p>
 
@@ -346,10 +348,9 @@
 widget</a>, a view for efficiently displaying large data sets by providing a
 limited window of data items.</p>
 
-<p>This library is located in the
-{@code &lt;sdk&gt;/extras/android/support/v7/recyclerview/} directory after you
-download the Android Support Libraries. The library contains user interface
-resources. To include it in your application project, follow the instructions
+<p>After you download the Android Support Libraries, this library is located in the
+{@code &lt;sdk&gt;/extras/android/support/v7/recyclerview/} directory. The library contains
+user interface resources. To include it in your application project, follow the instructions
 for <a href="{@docRoot}tools/support-library/setup.html#libs-with-res">Adding
 libraries with resources</a>.</p>
 
@@ -363,6 +364,12 @@
 
 <h2 id="v8">v8 Support Library</h2>
 
+<p>This library is designed to be used with Android 2.2 (API level 8) and higher.
+  This library provides specific feature sets and can be included in your application
+  independently from other libraries.</p>
+
+<h3 id="v8-renderscript">v8 renderscript library</h3>
+
 <p>This library is designed to be used with Android (API level 8) and higher. It adds support for
   the <a href="{@docRoot}guide/topics/renderscript/compute.html">RenderScript</a> computation
   framework. These APIs are included in the {@link android.support.v8.renderscript} package. You
@@ -374,9 +381,20 @@
 
 <p class="note">
   <strong>Note:</strong> Use of RenderScript with the support library is supported with Android
-  Studio and Gradle-based builds, as well as the Eclipse plugin and Ant build tools.
+  Studio and Gradle-based builds, as well as the Eclipse plugin and Ant build tools. The
+  renderscript library is located in the <code>build-tools/$VERSION/renderscript/</code> folder. 
 </p>
 
+<p>The following example shows the Gradle build script properties for this library:</p>
+
+<pre>
+defaultConfig {
+    renderscriptTargetApi 18
+    renderscriptSupportModeEnabled true
+}
+</pre>
+
+
 
 <h2 id="v13">v13 Support Library</h2>
 
@@ -389,11 +407,11 @@
   android.support.v13} package in the API reference.
 </p>
 
-<p>This library is located in the {@code &lt;sdk&gt;/extras/android/support/v13/} directory after
-  you download the Android Support Libraries. The library does not contain user interface
-  resources. To include it in your application project, follow the instructions for
-  <a href="{@docRoot}tools/support-library/setup.html#libs-without-res">Adding libraries without
-  resources</a>.</p>
+<p>After you download the Android Support Libraries, this library is located in the
+{@code &lt;sdk&gt;/extras/android/support/v13/} directory. The library does not contain user
+interface resources. To include it in your application project, follow the instructions for
+<a href="{@docRoot}tools/support-library/setup.html#libs-without-res">Adding libraries without
+resources</a>.</p>
 
 <p>The Gradle build script dependency identifier for this library is as follows:</p>
 
@@ -429,9 +447,8 @@
     into a {@link android.support.v17.leanback.app.RowsFragment}.</li>
 </ul>
 
-<p>This library is located in the
-{@code &lt;sdk&gt;/extras/android/support/v17/leanback} directory after
-you download the Android Support Libraries. For more information
+<p>After you download the Android Support Libraries, this library is located in the
+{@code &lt;sdk&gt;/extras/android/support/v17/leanback} directory. For more information
 on how to set up your project, follow the instructions in <a
 href="{@docRoot}tools/support-library/setup.html#libs-with-res">Adding libraries
 with resources</a>. </p>
@@ -444,3 +461,48 @@
 
 
 
+<h2 id="annotations">Annotations Support Library</h2>
+
+<p>The <a href="{@docRoot}reference/android/support/annotation/package-summary.html">Annotation</a>
+package provides APIs to support adding annotation metadata to your apps. </p>
+
+<p></p>
+
+<p>After you download the Android Support Libraries, this library is located in the
+{@code &lt;sdk&gt;/extras/android/support/annotations} directory. For more information
+on how to set up your project, follow the instructions in <a
+href="{@docRoot}tools/support-library/setup.html#libs-with-res">Adding libraries
+with resources</a>. </p>
+
+<p>The Gradle build script dependency identifier for this library is as follows:</p>
+
+<pre>
+com.android.support:support-annotations:22.0.0
+</pre>
+
+
+
+<h2 id="design">Design Support Library</h2>
+
+<p>The
+<a href="{@docRoot}reference/android/support/design/package-summary.html">Design</a> package
+provides APIs to support adding material design components and patterns to your apps. </p>
+
+<p>The Design Support library adds support for various material design components and patterns for
+app developers to build upon, such as navigation drawers, floating action buttons (<i>FAB</i>),
+snackbars, and <a href="{@docRoot}design/building-blocks/tabs.html">tabs</a>.  </p>
+
+
+<p>After you download the Android Support Libraries, this library is located in the
+{@code &lt;sdk&gt;/extras/android/support/design} directory. For more information
+on how to set up your project, follow the instructions in <a
+href="{@docRoot}tools/support-library/setup.html#libs-with-res">Adding libraries
+with resources</a>. </p>
+
+<p>The Gradle build script dependency identifier for this library is as follows:</p>
+
+<pre>
+com.android.support:support-design:22.0.0
+</pre>
+
+
diff --git a/docs/html/tools/support-library/index.jd b/docs/html/tools/support-library/index.jd
index 98c9ad5..1dad6b8 100644
--- a/docs/html/tools/support-library/index.jd
+++ b/docs/html/tools/support-library/index.jd
@@ -59,13 +59,187 @@
 <p>This section provides details about the Support Library package releases.</p>
 
 
-<div class="toggle-content opened">
+<div class="toggle-content open">
   <p id="rev21"><a href="#" onclick="return toggleContent(this)">
-    <img src="{@docRoot}assets/images/triangle-opened.png" class="toggle-content-img" alt=""
-/>Android Support Library, revision 22.1.0</a> <em>(April 2015)</em>
+    <img src="{@docRoot}assets/images/triangle-open.png" class="toggle-content-img" alt=""
+/>Android Support Library, revision 22.2.0</a> <em>(May 2015)</em>
   </p>
   <div class="toggle-content-toggleme">
     <dl>
+      <dt>Added <a href="features.html#design">Design Support library:</a></dt>
+      <dd>
+        <ul>
+          <li>Added {@link android.support.design.widget.TextInputLayout} for showing
+            {@link android.widget.EditText} hint and error text as floating labels.
+          </li>
+          <li>Added {@link android.support.design.widget.FloatingActionButton} for implementing a
+            primary action on your interface as a
+            floating action button, supporting either default or mini sizes.
+          </li>
+          <li>Added {@link android.support.design.widget.Snackbar} for providing lightweight
+            feedback with an optional action in an animated snackbar.
+          </li>
+          <li>Added {@link android.support.design.widget.TabLayout} for implementing fixed and
+            scrollable
+           <a href="{@docRoot}design/building-blocks/tabs.html">tabs</a> as well as easy
+             integration with
+             {@link android.support.v4.view.ViewPager}.
+          </li>
+          <li>Added {@link android.support.design.widget.NavigationView} for implementing
+            <a href="{@docRoot}design/patterns/navigation-drawer.html">navigation drawer</a>
+             contents, including the ability to inflate menu items via a
+             <a href="{@docRoot}guide/topics/resources/menu-resource.html">Menu Resource</a>.
+          </li>
+          <li>Added {@link android.support.design.widget.CoordinatorLayout}, a general purpose
+            layout, used for building dependencies between
+            sibling views and allowing easy scrolling reactions between components via
+            {@link android.support.design.widget.CoordinatorLayout.Behavior}. Many of the Design
+            Library components rely on being a child of a
+            {@link android.support.design.widget.CoordinatorLayout}.
+          </li>
+          <li>Added {@link android.support.design.widget.AppBarLayout}, a container for a
+            {@link android.widget.Toolbar}
+            and other views (such as {@link android.support.design.widget.TabLayout}) for
+            reacting to scrolling events by scrolling off the screen, becoming visible in reaction
+            to a downward scroll, or collapsing/uncollapsing before scrolling off/onto the screen.
+          </li>
+          <li>Added {@link android.support.design.widget.CollapsingToolbarLayout} for controlling
+            how a {@link android.widget.Toolbar} collapses. A toolbar may collapse by:
+            pinning components to the top of the screen while it collapses, introducing
+            parallax scrolling of components such as an {@link android.widget.ImageView},
+            or adding a content scrim color when the view is partially collapsed.
+          </li>
+       </ul>
+      </dt>
+
+
+
+      <dt>Changes for <a href="features.html#v4">v4 support library:</a></dt>
+      <dd>
+         <ul>
+
+          <li>Added the
+{@link android.support.v4.view.accessibility.AccessibilityEventCompat#getContentChangeTypes getContentChangeTypes()}
+            and
+{@link android.support.v4.view.accessibility.AccessibilityEventCompat#setContentChangeTypes setContentChangeTypes()}
+            methods and related change type
+            fields to the
+            {@link android.support.v4.view.accessibility.AccessibilityEventCompat}
+            class for accessibility event handling.
+          </li>
+          <li>Added the
+{@link android.support.v4.media.session.PlaybackStateCompat#getActiveQueueItemId getActiveQueueItemId()},
+{@link android.support.v4.media.session.PlaybackStateCompat#getCustomActions getCustomActions()},
+            and
+            {@link android.support.v4.media.session.PlaybackStateCompat#getExtras getExtras()}
+            methods with related state fields to the
+            {@link android.support.v4.media.session.PlaybackStateCompat} class for
+            getting custom actions from the queue.
+          </li>
+          <li>Added the
+{@link android.support.v4.media.session.PlaybackStateCompat.Builder#addCustomAction addCustomAction()},
+{@link android.support.v4.media.session.PlaybackStateCompat.Builder#addCustomAction addCustomAction()},
+{@link android.support.v4.media.session.PlaybackStateCompat.Builder#setActiveQueueItemId setActiveQueueItemId()},
+            and
+            {@link android.support.v4.media.session.PlaybackStateCompat.Builder#setExtras setExtras()}
+            methods to the
+            {@link android.support.v4.media.session.PlaybackStateCompat.Builder} class for adding
+            adding custom actions to a playback state.
+          </li>
+          <li>Added the
+{@link android.support.v4.media.session.PlaybackStateCompat.CustomAction#fromCustomAction fromCustomAction()} and
+{@link android.support.v4.media.session.PlaybackStateCompat.CustomAction#getCustomAction getCustomAction()} methods
+            to the
+            {@link android.support.v4.media.session.PlaybackStateCompat.CustomAction} class
+            for getting custom actions from the queue.
+          </li>
+          <li>Added the {@link android.support.v4.view.ViewCompat#isAttachedToWindow isAttachedToWindow()},
+            {@link android.support.v4.view.ViewCompat#offsetLeftAndRight offsetLeftAndRight()}, and
+            {@link android.support.v4.view.ViewCompat#offsetTopAndBottom offsetTopAndBottom()}
+            methods to the {@link android.support.v4.view.ViewCompat} class for working with views.
+          </li>
+          <li>Added the {@link android.support.v4.view.ViewPager#addOnPageChangeListener addOnPageChangeListener()},
+            {@link android.support.v4.view.ViewPager#clearOnPageChangeListeners clearOnPageChangeListeners()}, and
+            {@link android.support.v4.view.ViewPager#removeOnPageChangeListener removeOnPageChangeListener()}
+            methods to the {@link android.support.v4.view.ViewPager} class for responding to page
+            changes.
+            <p>Deprecated the
+            {@link android.support.v4.view.ViewPager#setOnPageChangeListener setOnPageChangeListener()} method.</p>
+          </li>
+          <li>Added the
+{@link android.support.v4.view.ViewParentCompat#notifySubtreeAccessibilityStateChanged notifySubtreeAccessibilityStateChanged()} method to
+            the {@link android.support.v4.view.ViewParentCompat} class for notifying a view parent
+            that the accessibility state of one of its descendants has changed.
+          </li>
+          <li>Added the {@link android.support.v4.view.ViewPropertyAnimatorCompat#translationZ translationZ()},
+            {@link android.support.v4.view.ViewPropertyAnimatorCompat#translationZBy translationZBy()},
+            {@link android.support.v4.view.ViewPropertyAnimatorCompat#z z()}, and
+            {@link android.support.v4.view.ViewPropertyAnimatorCompat#zBy zBy()}
+            methods to the {@link android.support.v4.view.ViewPropertyAnimatorCompat} class for
+            adding animation.
+          </li>
+       </ul>
+      </dd>
+
+
+
+<dt>Changes for <a href="features.html#v7-appcompat">v7 appcompat library</a>:</dt>
+      <dd>
+<ul>
+          <li>Added the
+            {@link android.support.v7.app.AppCompatActivity#onWindowStartingSupportActionMode onWindowStartingSupportActionMode()}
+            method to the
+            {@link android.support.v7.app.AppCompatActivity},
+            {@link android.support.v7.app.AppCompatCallback}, and
+            {@link android.support.v7.app.AppCompatDialog} classes for handling action modes
+            started from the current window.
+          </li>
+
+          <li>Added the
+{@link android.support.v7.app.AppCompatDelegate#isHandleNativeActionModesEnabled isHandleNativeActionModesEnabled()} and
+{@link android.support.v7.app.AppCompatDelegate#setHandleNativeActionModesEnabled setHandleNativeActionModesEnabled()}
+           methods to the
+           {@link android.support.v7.app.AppCompatDelegate} class for handling native action modes.
+          </li>
+       </ul>
+      </dd>
+
+
+    </dl>
+
+  </div>
+</div> <!-- end of collapsible section -->
+
+
+
+
+
+<div class="toggle-content closed">
+  <p id="rev21"><a href="#" onclick="return toggleContent(this)">
+    <img src="{@docRoot}assets/images/triangle-closed.png" class="toggle-content-img" alt=""
+/>Android Support Library, revision 22.1.0</a> <em>(April 2015)</em>
+  </p>
+
+
+
+  <div class="toggle-content-toggleme">
+    <dl>
+
+
+  <div class="toggle-content-toggleme">
+    <dl>
+      <dt>Changes for <a href="features.html#annotations">annotations library:</a></dt>
+      <dd>
+        <ul>
+          <li>Added the Annotations library to provide support for enhanced code inspections.
+            Annotations are added as metadata tags that you attach to variables, parameters,
+            and return values to inspect method return values, passed parameters, and local
+            variables and fields.
+          </li>
+        </ul>
+      </dd>
+
+
       <dt>Changes for <a href="features.html#v4">v4 support library:</a></dt>
       <dd>
         <ul>
@@ -132,7 +306,7 @@
          <li>Updated the {@link android.support.v4.view.accessibility.AccessibilityNodeInfoCompat}
           class to add methods for errors, content invalidation and labels.
          </li>
-         <li>Added the following interpolation classses for animation:
+         <li>Added the following interpolation classes for animation:
            {@link android.support.v4.view.animation.FastOutLinearInInterpolator},
            {@link android.support.v4.view.animation.FastOutSlowInInterpolator},
            {@link android.support.v4.view.animation.LinearOutSlowInInterpolator},
@@ -245,7 +419,7 @@
       </dd>
 
 
-      <dt>Changes for v8 renderscript library:</dt>
+      <dt>Changes for <a href="features.html#v8-renderscript">v8 renderscript library</a>:</dt>
       <dd>
         <ul>
           <li>Added the {@link android.support.v8.renderscript.ScriptIntrinsicHistogram} class for
@@ -643,7 +817,7 @@
         </ul>
       </dd>
 
-      <dt>Changes for v8 renderscript library:</dt>
+      <dt>Changes for <a href="features.html#v8-renderscript">v8 renderscript library</a></dt>
       <dd>
         <ul>
           <li>Added error propagation for the RenderScript thunking layer.</li>
diff --git a/keystore/java/android/security/KeyStoreParameter.java b/keystore/java/android/security/KeyStoreParameter.java
index 174e03f..66c87ed 100644
--- a/keystore/java/android/security/KeyStoreParameter.java
+++ b/keystore/java/android/security/KeyStoreParameter.java
@@ -19,7 +19,6 @@
 import android.annotation.NonNull;
 import android.app.KeyguardManager;
 import android.content.Context;
-import android.security.keystore.KeyGenParameterSpec;
 import android.security.keystore.KeyProtection;
 
 import java.security.KeyPairGenerator;
@@ -49,28 +48,14 @@
  */
 @Deprecated
 public final class KeyStoreParameter implements ProtectionParameter {
-    private final Context mContext;
     private final int mFlags;
 
     private KeyStoreParameter(
-            Context context,
             int flags) {
-        if (context == null) {
-            throw new IllegalArgumentException("context == null");
-        }
-
-        mContext = context;
         mFlags = flags;
     }
 
     /**
-     * Gets the Android context used for operations with this instance.
-     */
-    public Context getContext() {
-        return mContext;
-    }
-
-    /**
      * @hide
      */
     public int getFlags() {
@@ -115,7 +100,6 @@
      */
     @Deprecated
     public final static class Builder {
-        private final Context mContext;
         private int mFlags;
 
         /**
@@ -128,7 +112,6 @@
             if (context == null) {
                 throw new NullPointerException("context == null");
             }
-            mContext = context;
         }
 
         /**
@@ -163,7 +146,6 @@
         @NonNull
         public KeyStoreParameter build() {
             return new KeyStoreParameter(
-                    mContext,
                     mFlags);
         }
     }
diff --git a/libs/hwui/LayerRenderer.cpp b/libs/hwui/LayerRenderer.cpp
index 223bdf0..d9b40ae 100644
--- a/libs/hwui/LayerRenderer.cpp
+++ b/libs/hwui/LayerRenderer.cpp
@@ -439,13 +439,6 @@
             renderer.translate(0.0f, bitmap->height());
             renderer.scale(1.0f, -1.0f);
 
-            mat4 texTransform(layer->getTexTransform());
-
-            mat4 invert;
-            invert.translate(0.0f, 1.0f);
-            invert.scale(1.0f, -1.0f, 1.0f);
-            layer->getTexTransform().multiply(invert);
-
             if ((error = glGetError()) != GL_NO_ERROR) goto error;
 
             {
@@ -459,7 +452,6 @@
                 if ((error = glGetError()) != GL_NO_ERROR) goto error;
             }
 
-            layer->getTexTransform().load(texTransform);
             status = true;
         }
 
diff --git a/packages/StatementService/src/com/android/statementservice/retriever/Relation.java b/packages/StatementService/src/com/android/statementservice/retriever/Relation.java
index 91218c6..124f46d 100644
--- a/packages/StatementService/src/com/android/statementservice/retriever/Relation.java
+++ b/packages/StatementService/src/com/android/statementservice/retriever/Relation.java
@@ -30,16 +30,12 @@
  * <p> We may add other kinds in the future.
  *
  * <p> The detail field is a lowercase alphanumeric string with underscores and periods allowed
- * (matching the regex [a-z0-9_.]+), but otherwise unstructured. It is also possible to specify '*'
- * (the wildcard character) as the detail if the relation applies to any detail in the specified
- * kind.
+ * (matching the regex [a-z0-9_.]+), but otherwise unstructured.
  */
 public final class Relation {
 
     private static final Pattern KIND_PATTERN = Pattern.compile("^[a-z0-9_.]+$");
-    private static final Pattern DETAIL_PATTERN = Pattern.compile("^([a-z0-9_.]+|[*])$");
-
-    private static final String MATCH_ALL_DETAILS = "*";
+    private static final Pattern DETAIL_PATTERN = Pattern.compile("^([a-z0-9_.]+)$");
 
     private final String mKind;
     private final String mDetail;
@@ -92,12 +88,10 @@
     }
 
     /**
-     * Returns true if {@code relation} has the same kind and detail. If {@code
-     * relation.getDetail()} is wildcard (*) then returns true if the kind is the same.
+     * Returns true if {@code relation} has the same kind and detail.
      */
     public boolean matches(Relation relation) {
-        return getKind().equals(relation.getKind()) && (getDetail().equals(MATCH_ALL_DETAILS)
-                || getDetail().equals(relation.getDetail()));
+        return getKind().equals(relation.getKind()) && getDetail().equals(relation.getDetail());
     }
 
     /**
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/WifiTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/WifiTile.java
index 9504ea3..9bc5b75 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/WifiTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/WifiTile.java
@@ -326,7 +326,7 @@
                     item.tag = ap;
                     item.icon = mWifiController.getIcon(ap);
                     item.line1 = ap.getSsid();
-                    item.line2 = ap.getSummary();
+                    item.line2 = ap.isActive() ? ap.getSummary() : null;
                     item.overlay = ap.getSecurity() != AccessPoint.SECURITY_NONE
                             ? mContext.getDrawable(R.drawable.qs_ic_wifi_lock)
                             : null;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index 50cdbb6..1e4aa61 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -745,7 +745,8 @@
         mHandlerThread.start();
 
         // Other icons
-        mLocationController = new LocationControllerImpl(mContext); // will post a notification
+        mLocationController = new LocationControllerImpl(mContext,
+                mHandlerThread.getLooper()); // will post a notification
         mBatteryController = new BatteryController(mContext);
         mBatteryController.addStateChangedCallback(new BatteryStateChangeCallback() {
             @Override
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/LocationControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/LocationControllerImpl.java
index d8d7042..93a8fd8 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/LocationControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/LocationControllerImpl.java
@@ -26,6 +26,8 @@
 import android.content.IntentFilter;
 import android.location.LocationManager;
 import android.os.Handler;
+import android.os.Looper;
+import android.os.Message;
 import android.os.UserHandle;
 import android.os.UserManager;
 import android.provider.Settings;
@@ -56,31 +58,21 @@
 
     private ArrayList<LocationSettingsChangeCallback> mSettingsChangeCallbacks =
             new ArrayList<LocationSettingsChangeCallback>();
+    private final H mHandler = new H();
 
-    public LocationControllerImpl(Context context) {
+    public LocationControllerImpl(Context context, Looper bgLooper) {
         mContext = context;
 
+        // Register to listen for changes in location settings.
         IntentFilter filter = new IntentFilter();
         filter.addAction(LocationManager.HIGH_POWER_REQUEST_CHANGE_ACTION);
-        context.registerReceiverAsUser(this, UserHandle.ALL, filter, null, null);
+        filter.addAction(LocationManager.MODE_CHANGED_ACTION);
+        context.registerReceiverAsUser(this, UserHandle.ALL, filter, null, new Handler(bgLooper));
 
         mAppOpsManager = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
         mStatusBarManager
                 = (StatusBarManager) context.getSystemService(Context.STATUS_BAR_SERVICE);
 
-        // Register to listen for changes in location settings.
-        IntentFilter intentFilter = new IntentFilter();
-        intentFilter.addAction(LocationManager.MODE_CHANGED_ACTION);
-        context.registerReceiverAsUser(new BroadcastReceiver() {
-            @Override
-            public void onReceive(Context context, Intent intent) {
-                String action = intent.getAction();
-                if (LocationManager.MODE_CHANGED_ACTION.equals(action)) {
-                    locationSettingsChanged();
-                }
-            }
-        }, UserHandle.ALL, intentFilter, null, new Handler());
-
         // Examine the current location state and initialize the status view.
         updateActiveLocationRequests();
         refreshViews();
@@ -91,7 +83,7 @@
      */
     public void addSettingsChangedCallback(LocationSettingsChangeCallback cb) {
         mSettingsChangeCallbacks.add(cb);
-        locationSettingsChanged(cb);
+        mHandler.sendEmptyMessage(H.MSG_LOCATION_SETTINGS_CHANGED);
     }
 
     public void removeSettingsChangedCallback(LocationSettingsChangeCallback cb) {
@@ -181,8 +173,8 @@
     // Updates the status view based on the current state of location requests.
     private void refreshViews() {
         if (mAreActiveLocationRequests) {
-            mStatusBarManager.setIcon(LOCATION_STATUS_ICON_PLACEHOLDER, LOCATION_STATUS_ICON_ID, 0,
-                    mContext.getString(R.string.accessibility_location_active));
+            mStatusBarManager.setIcon(LOCATION_STATUS_ICON_PLACEHOLDER, LOCATION_STATUS_ICON_ID,
+                    0, mContext.getString(R.string.accessibility_location_active));
         } else {
             mStatusBarManager.removeIcon(LOCATION_STATUS_ICON_PLACEHOLDER);
         }
@@ -197,22 +189,33 @@
         }
     }
 
-    private void locationSettingsChanged() {
-        boolean isEnabled = isLocationEnabled();
-        for (LocationSettingsChangeCallback cb : mSettingsChangeCallbacks) {
-            cb.onLocationSettingsChanged(isEnabled);
-        }
-    }
-
-    private void locationSettingsChanged(LocationSettingsChangeCallback cb) {
-        cb.onLocationSettingsChanged(isLocationEnabled());
-    }
-
     @Override
     public void onReceive(Context context, Intent intent) {
         final String action = intent.getAction();
         if (LocationManager.HIGH_POWER_REQUEST_CHANGE_ACTION.equals(action)) {
             updateActiveLocationRequests();
+        } else if (LocationManager.MODE_CHANGED_ACTION.equals(action)) {
+            mHandler.sendEmptyMessage(H.MSG_LOCATION_SETTINGS_CHANGED);
+        }
+    }
+
+    private final class H extends Handler {
+        private static final int MSG_LOCATION_SETTINGS_CHANGED = 1;
+
+        @Override
+        public void handleMessage(Message msg) {
+            switch (msg.what) {
+                case MSG_LOCATION_SETTINGS_CHANGED:
+                    locationSettingsChanged();
+                    break;
+            }
+        }
+
+        private void locationSettingsChanged() {
+            boolean isEnabled = isLocationEnabled();
+            for (LocationSettingsChangeCallback cb : mSettingsChangeCallbacks) {
+                cb.onLocationSettingsChanged(isEnabled);
+            }
         }
     }
 }
diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java
index 7ac2655..edca4b8 100644
--- a/services/core/java/com/android/server/ConnectivityService.java
+++ b/services/core/java/com/android/server/ConnectivityService.java
@@ -3640,6 +3640,7 @@
 
     @Override
     public void releasePendingNetworkRequest(PendingIntent operation) {
+        checkNotNull(operation, "PendingIntent cannot be null.");
         mHandler.sendMessage(mHandler.obtainMessage(EVENT_RELEASE_NETWORK_REQUEST_WITH_INTENT,
                 getCallingUid(), 0, operation));
     }
diff --git a/services/net/java/android/net/dhcp/DhcpClient.java b/services/net/java/android/net/dhcp/DhcpClient.java
index e1d1787..316496f 100644
--- a/services/net/java/android/net/dhcp/DhcpClient.java
+++ b/services/net/java/android/net/dhcp/DhcpClient.java
@@ -225,17 +225,18 @@
      * {@code CONNECTIVITY_INTERNAL} permission.
      *
      * @param cmdName the name of the command. The intent's action will be
-     *         {@code android.net.dhcp.DhcpClient.<cmdName>}
+     *         {@code android.net.dhcp.DhcpClient.<mIfaceName>.<cmdName>}
      * @param cmd the command to send to the state machine when the PendingIntent is triggered.
      * @return the PendingIntent
      */
     private PendingIntent createStateMachineCommandIntent(final String cmdName, final int cmd) {
-        String action = DhcpClient.class.getName() + "." + cmdName;
+        String action = DhcpClient.class.getName() + "." + mIfaceName + "." + cmdName;
 
-        // TODO: figure out what values to pass to intent.setPackage() and intent.setClass() that
-        // result in the Intent being received by this class and nowhere else, and use them.
         Intent intent = new Intent(action, null)
                 .addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
+        // TODO: The intent's package covers the whole of the system server, so it's pretty generic.
+        // Consider adding some sort of token as well.
+        intent.setPackage(mContext.getPackageName());
         PendingIntent pendingIntent =  PendingIntent.getBroadcast(mContext, cmd, intent, 0);
 
         mContext.registerReceiver(
diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java
index 0a5b668..6de887b 100644
--- a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java
+++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java
@@ -248,6 +248,12 @@
     }
 
     void shutdownLocked() {
+        // If there is an active session, cancel it to allow it to clean up its window and other
+        // state.
+        if (mActiveSession != null) {
+            mActiveSession.cancel();
+            mActiveSession = null;
+        }
         try {
             if (mService != null) {
                 mService.shutdown();