Merge "Fixed a leaked partial wakelock in AbstractThreadedSyncAdapter."
diff --git a/api/current.txt b/api/current.txt
index 962b332..6f0bbce 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -7255,6 +7255,7 @@
     field public static final int KEYBOARD_NOKEYS = 1; // 0x1
     field public static final int KEYBOARD_QWERTY = 2; // 0x2
     field public static final int KEYBOARD_UNDEFINED = 0; // 0x0
+    field public static final int MNC_ZERO = 65535; // 0xffff
     field public static final int NAVIGATIONHIDDEN_NO = 1; // 0x1
     field public static final int NAVIGATIONHIDDEN_UNDEFINED = 0; // 0x0
     field public static final int NAVIGATIONHIDDEN_YES = 2; // 0x2
diff --git a/core/java/android/content/res/Configuration.java b/core/java/android/content/res/Configuration.java
index 68db33a..6318e38 100644
--- a/core/java/android/content/res/Configuration.java
+++ b/core/java/android/content/res/Configuration.java
@@ -54,10 +54,17 @@
     /**
      * IMSI MNC (Mobile Network Code), corresponding to
      * <a href="{@docRoot}guide/topics/resources/providing-resources.html#MccQualifier">mnc</a>
-     * resource qualifier.  0 if undefined.
+     * resource qualifier.  0 if undefined. Note that the actual MNC may be 0; in order to check
+     * for this use the {@link #MNC_ZERO} symbol.
      */
     public int mnc;
-    
+
+    /**
+     * Constant used to to represent MNC (Mobile Network Code) zero.
+     * 0 cannot be used, since it is used to represent an undefined MNC.
+     */
+    public static final int MNC_ZERO = 0xffff;
+
     /**
      * Current user preference for the locale, corresponding to
      * <a href="{@docRoot}guide/topics/resources/providing-resources.html#LocaleQualifier">locale</a>
diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java
index 219891c..c36ecc8 100644
--- a/core/java/android/widget/AbsListView.java
+++ b/core/java/android/widget/AbsListView.java
@@ -919,9 +919,9 @@
      * the choice mode has not been set to {@link #CHOICE_MODE_NONE}.
      *
      * @return  A SparseBooleanArray which will return true for each call to
-     *          get(int position) where position is a position in the list,
-     *          or <code>null</code> if the choice mode is set to
-     *          {@link #CHOICE_MODE_NONE}.
+     *          get(int position) where position is a checked position in the
+     *          list and false otherwise, or <code>null</code> if the choice
+     *          mode is set to {@link #CHOICE_MODE_NONE}.
      */
     public SparseBooleanArray getCheckedItemPositions() {
         if (mChoiceMode != CHOICE_MODE_NONE) {
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index 4572f5b..bbfbe0c 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -488,7 +488,6 @@
     <integer name="config_shutdownBatteryTemperature">680</integer>
 
     <!-- Display low battery warning when battery level dips to this value -->
-    <!-- Display low battery warning when battery level dips to this value -->
     <integer name="config_lowBatteryWarningLevel">15</integer>
 
     <!-- Close low battery warning when battery level reaches this value -->
diff --git a/data/keyboards/Vendor_0a5c_Product_8502.kl b/data/keyboards/Vendor_0a5c_Product_8502.kl
deleted file mode 100644
index 0084969..0000000
--- a/data/keyboards/Vendor_0a5c_Product_8502.kl
+++ /dev/null
@@ -1,33 +0,0 @@
-# Copyright (C) 2013 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# Snakebyte
-
-key 289 BUTTON_A
-key 290 BUTTON_B
-key 288 BUTTON_X
-key 291 BUTTON_Y
-key 292 BUTTON_L1
-key 293 BUTTON_R1
-key 294 BUTTON_L2
-key 295 BUTTON_R2
-key 297 BUTTON_START
-key 296 BUTTON_SELECT
-
-axis 0x00 X
-axis 0x01 Y
-axis 0x02 Z
-axis 0x05 RZ
-axis 0x10 HAT_X
-axis 0x11 HAT_Y
diff --git a/data/keyboards/common.mk b/data/keyboards/common.mk
index 7b36167..6fb633b 100644
--- a/data/keyboards/common.mk
+++ b/data/keyboards/common.mk
@@ -31,7 +31,6 @@
     Vendor_046d_Product_c219.kl \
     Vendor_046d_Product_c21f.kl \
     Vendor_0583_Product_2060.kl \
-    Vendor_0a5c_Product_8502.kl \
     Vendor_1038_Product_1412.kl \
     Vendor_12bd_Product_d015.kl \
     Vendor_1689_Product_fd00.kl \
diff --git a/media/java/android/media/MediaFormat.java b/media/java/android/media/MediaFormat.java
index a2eb8d9..3fbaf69 100644
--- a/media/java/android/media/MediaFormat.java
+++ b/media/java/android/media/MediaFormat.java
@@ -40,7 +40,8 @@
  * <tr><th>Name</th><th>Value Type</th><th>Description</th></tr>
  * <tr><td>{@link #KEY_WIDTH}</td><td>Integer</td><td></td></tr>
  * <tr><td>{@link #KEY_HEIGHT}</td><td>Integer</td><td></td></tr>
- * <tr><td>{@link #KEY_COLOR_FORMAT}</td><td>Integer</td><td><b>encoder-only</b></td></tr>
+ * <tr><td>{@link #KEY_COLOR_FORMAT}</td><td>Integer</td><td>set by the user
+ *         for encoders, readable in the output format of decoders</b></td></tr>
  * <tr><td>{@link #KEY_FRAME_RATE}</td><td>Integer or Float</td><td><b>encoder-only</b></td></tr>
  * <tr><td>{@link #KEY_I_FRAME_INTERVAL}</td><td>Integer</td><td><b>encoder-only</b></td></tr>
  * </table>
@@ -154,7 +155,7 @@
 
     /**
      * A key describing the AAC profile to be used (AAC audio formats only).
-     * Constants are declared in {@link android.media.MediaCodecInfo.CodecCapabilities}.
+     * Constants are declared in {@link android.media.MediaCodecInfo.CodecProfileLevel}.
      */
     public static final String KEY_AAC_PROFILE = "aac-profile";
 
diff --git a/media/java/android/media/MediaMetadataRetriever.java b/media/java/android/media/MediaMetadataRetriever.java
index 376bb2d..9014453 100644
--- a/media/java/android/media/MediaMetadataRetriever.java
+++ b/media/java/android/media/MediaMetadataRetriever.java
@@ -59,6 +59,10 @@
      * @throws IllegalArgumentException If the path is invalid.
      */
     public void setDataSource(String path) throws IllegalArgumentException {
+        if (path == null) {
+            throw new IllegalArgumentException();
+        }
+
         FileInputStream is = null;
         try {
             is = new FileInputStream(path);
diff --git a/preloaded-classes b/preloaded-classes
index 2aa610a..8d1d1a5 100644
--- a/preloaded-classes
+++ b/preloaded-classes
@@ -1672,7 +1672,6 @@
 com.android.org.bouncycastle.jce.provider.BouncyCastleProviderConfiguration
 com.android.org.bouncycastle.jce.provider.CertBlacklist
 com.android.org.bouncycastle.jce.provider.CertPathValidatorUtilities
-com.android.org.bouncycastle.jce.provider.JDKKeyStore
 com.android.org.bouncycastle.jce.provider.PKIXCRLUtil
 com.android.org.bouncycastle.jce.provider.PKIXCertPathValidatorSpi
 com.android.org.bouncycastle.jce.provider.PKIXNameConstraintValidator
@@ -2027,7 +2026,6 @@
 java.net.ProxySelector
 java.net.ProxySelectorImpl
 java.net.ResponseCache
-java.net.ResponseSource
 java.net.Socket
 java.net.SocketAddress
 java.net.SocketImpl
@@ -2464,7 +2462,6 @@
 libcore.io.StructPasswd
 libcore.io.StructPollfd
 libcore.io.StructStat
-libcore.io.StructStatFs
 libcore.io.StructTimeval
 libcore.io.StructUcred
 libcore.io.StructUtsname
@@ -2472,26 +2469,8 @@
 libcore.net.MimeUtils
 libcore.net.RawSocket
 libcore.net.UriCodec
-libcore.net.http.AbstractHttpInputStream
-libcore.net.http.FixedLengthInputStream
-libcore.net.http.HeaderParser$CacheControlHandler
-libcore.net.http.HttpConnection
-libcore.net.http.HttpConnection$Address
-libcore.net.http.HttpConnectionPool
 libcore.net.http.HttpDate
 libcore.net.http.HttpDate$1
-libcore.net.http.HttpEngine
-libcore.net.http.HttpEngine$1
-libcore.net.http.HttpHandler
-libcore.net.http.HttpURLConnectionImpl
-libcore.net.http.HttpURLConnectionImpl$Retry
-libcore.net.http.HttpsHandler
-libcore.net.http.RawHeaders
-libcore.net.http.RawHeaders$1
-libcore.net.http.RequestHeaders
-libcore.net.http.RequestHeaders$1
-libcore.net.http.ResponseHeaders
-libcore.net.http.ResponseHeaders$1
 libcore.net.url.FileHandler
 libcore.net.url.FileURLConnection
 libcore.net.url.JarHandler
@@ -2517,9 +2496,6 @@
 org.apache.harmony.dalvik.ddmc.Chunk
 org.apache.harmony.dalvik.ddmc.ChunkHandler
 org.apache.harmony.dalvik.ddmc.DdmServer
-org.apache.harmony.lang.annotation.AnnotationFactory
-org.apache.harmony.lang.annotation.AnnotationMember
-org.apache.harmony.lang.annotation.AnnotationMember$DefaultValues
 org.apache.harmony.luni.internal.util.TimezoneGetter
 org.apache.harmony.security.asn1.ASN1Any
 org.apache.harmony.security.asn1.ASN1BitString
@@ -2567,8 +2543,6 @@
 org.apache.harmony.security.provider.cert.DRLCertFactory
 org.apache.harmony.security.provider.cert.X509CertImpl
 org.apache.harmony.security.provider.crypto.CryptoProvider
-org.apache.harmony.security.provider.crypto.RandomBitsSupplier
-org.apache.harmony.security.provider.crypto.SHA1_Data
 org.apache.harmony.security.utils.AlgNameMapper
 org.apache.harmony.security.utils.ObjectIdentifier
 org.apache.harmony.security.x501.AttributeTypeAndValue
diff --git a/services/java/com/android/server/connectivity/Nat464Xlat.java b/services/java/com/android/server/connectivity/Nat464Xlat.java
index 59403c5..a15d678 100644
--- a/services/java/com/android/server/connectivity/Nat464Xlat.java
+++ b/services/java/com/android/server/connectivity/Nat464Xlat.java
@@ -147,17 +147,24 @@
                    " added, mIsRunning = " + mIsRunning + " -> true");
             mIsRunning = true;
 
-            // Get the network configuration of the clat interface, store it
-            // in our link properties, and stack it on top of the interface
-            // it's running on.
+            // Create the LinkProperties for the clat interface by fetching the
+            // IPv4 address for the interface and adding an IPv4 default route,
+            // then stack the LinkProperties on top of the link it's running on.
+            // Although the clat interface is a point-to-point tunnel, we don't
+            // point the route directly at the interface because some apps don't
+            // understand routes without gateways (see, e.g., http://b/9597256
+            // http://b/9597516). Instead, set the next hop of the route to the
+            // clat IPv4 address itself (for those apps, it doesn't matter what
+            // the IP of the gateway is, only that there is one).
             try {
                 InterfaceConfiguration config = mNMService.getInterfaceConfig(iface);
+                LinkAddress clatAddress = config.getLinkAddress();
                 mLP.clear();
                 mLP.setInterfaceName(iface);
-                RouteInfo ipv4Default = new RouteInfo(new LinkAddress(Inet4Address.ANY, 0), null,
-                                                      iface);
+                RouteInfo ipv4Default = new RouteInfo(new LinkAddress(Inet4Address.ANY, 0),
+                                                      clatAddress.getAddress(), iface);
                 mLP.addRoute(ipv4Default);
-                mLP.addLinkAddress(config.getLinkAddress());
+                mLP.addLinkAddress(clatAddress);
                 mTracker.addStackedLink(mLP);
                 Slog.i(TAG, "Adding stacked link. tracker LP: " +
                        mTracker.getLinkProperties());
diff --git a/services/java/com/android/server/connectivity/Vpn.java b/services/java/com/android/server/connectivity/Vpn.java
index 2fc972f..63d3958 100644
--- a/services/java/com/android/server/connectivity/Vpn.java
+++ b/services/java/com/android/server/connectivity/Vpn.java
@@ -467,15 +467,15 @@
     private native int jniCheck(String interfaze);
     private native void jniProtect(int socket, String interfaze);
 
-    private static String findLegacyVpnGateway(LinkProperties prop) {
-        for (RouteInfo route : prop.getRoutes()) {
+    private static RouteInfo findIPv4DefaultRoute(LinkProperties prop) {
+        for (RouteInfo route : prop.getAllRoutes()) {
             // Currently legacy VPN only works on IPv4.
             if (route.isDefaultRoute() && route.getGateway() instanceof Inet4Address) {
-                return route.getGateway().getHostAddress();
+                return route;
             }
         }
 
-        throw new IllegalStateException("Unable to find suitable gateway");
+        throw new IllegalStateException("Unable to find IPv4 default gateway");
     }
 
     /**
@@ -488,8 +488,9 @@
             throw new IllegalStateException("KeyStore isn't unlocked");
         }
 
-        final String iface = egress.getInterfaceName();
-        final String gateway = findLegacyVpnGateway(egress);
+        final RouteInfo ipv4DefaultRoute = findIPv4DefaultRoute(egress);
+        final String gateway = ipv4DefaultRoute.getGateway().getHostAddress();
+        final String iface = ipv4DefaultRoute.getInterface();
 
         // Load certificates.
         String privateKey = "";
diff --git a/tools/aapt/AaptAssets.cpp b/tools/aapt/AaptAssets.cpp
index 2149190..3797b49 100644
--- a/tools/aapt/AaptAssets.cpp
+++ b/tools/aapt/AaptAssets.cpp
@@ -934,6 +934,9 @@
 
     if (out) {
         out->mnc = atoi(val);
+        if (out->mnc == 0) {
+            out->mnc = ACONFIGURATION_MNC_ZERO;
+        }
     }
 
     return true;