am 7c6ebac7: am b1199209: am 702543f3: am c0f462c9: am 86593304: am 068e2315: Merge "A/V sync and latency PCB" into jb-mr1.1-docs

* commit '7c6ebac75dd75382dbc71e8a5ca943d29266af06':
  A/V sync and latency PCB
diff --git a/Android.mk b/Android.mk
index 7d2420c..f367a24 100644
--- a/Android.mk
+++ b/Android.mk
@@ -247,7 +247,7 @@
 			$(framework_res_source_path)/com/android/internal/R.java
 
 LOCAL_NO_STANDARD_LIBRARIES := true
-LOCAL_JAVA_LIBRARIES := bouncycastle core core-junit ext
+LOCAL_JAVA_LIBRARIES := bouncycastle conscrypt core core-junit ext okhttp
 
 LOCAL_MODULE := framework
 LOCAL_MODULE_CLASS := JAVA_LIBRARIES
@@ -415,7 +415,9 @@
 
 framework_docs_LOCAL_API_CHECK_JAVA_LIBRARIES := \
 	bouncycastle \
+	conscrypt \
 	core \
+	okhttp \
 	ext \
 	framework \
 	mms-common \
diff --git a/api/current.txt b/api/current.txt
index 9b9fe6a..9130a32 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -31558,7 +31558,7 @@
     ctor public CharConversionException(java.lang.String);
   }
 
-  public abstract interface Closeable {
+  public abstract interface Closeable implements java.lang.AutoCloseable {
     method public abstract void close() throws java.io.IOException;
   }
 
@@ -31728,7 +31728,7 @@
     method public abstract boolean accept(java.io.File);
   }
 
-  public class FileInputStream extends java.io.InputStream implements java.io.Closeable {
+  public class FileInputStream extends java.io.InputStream {
     ctor public FileInputStream(java.io.File) throws java.io.FileNotFoundException;
     ctor public FileInputStream(java.io.FileDescriptor);
     ctor public FileInputStream(java.lang.String) throws java.io.FileNotFoundException;
@@ -31742,7 +31742,7 @@
     ctor public FileNotFoundException(java.lang.String);
   }
 
-  public class FileOutputStream extends java.io.OutputStream implements java.io.Closeable {
+  public class FileOutputStream extends java.io.OutputStream {
     ctor public FileOutputStream(java.io.File) throws java.io.FileNotFoundException;
     ctor public FileOutputStream(java.io.File, boolean) throws java.io.FileNotFoundException;
     ctor public FileOutputStream(java.io.FileDescriptor);
@@ -31881,7 +31881,7 @@
     ctor public NotSerializableException(java.lang.String);
   }
 
-  public abstract interface ObjectInput implements java.io.DataInput {
+  public abstract interface ObjectInput implements java.lang.AutoCloseable java.io.DataInput {
     method public abstract int available() throws java.io.IOException;
     method public abstract void close() throws java.io.IOException;
     method public abstract int read() throws java.io.IOException;
@@ -31943,7 +31943,7 @@
     method public abstract void validateObject() throws java.io.InvalidObjectException;
   }
 
-  public abstract interface ObjectOutput implements java.io.DataOutput {
+  public abstract interface ObjectOutput implements java.lang.AutoCloseable java.io.DataOutput {
     method public abstract void close() throws java.io.IOException;
     method public abstract void flush() throws java.io.IOException;
     method public abstract void write(byte[]) throws java.io.IOException;
@@ -32442,6 +32442,7 @@
 
   public class AssertionError extends java.lang.Error {
     ctor public AssertionError();
+    ctor public AssertionError(java.lang.String, java.lang.Throwable);
     ctor public AssertionError(java.lang.Object);
     ctor public AssertionError(boolean);
     ctor public AssertionError(char);
@@ -32451,10 +32452,15 @@
     ctor public AssertionError(double);
   }
 
+  public abstract interface AutoCloseable {
+    method public abstract void close() throws java.lang.Exception;
+  }
+
   public final class Boolean implements java.lang.Comparable java.io.Serializable {
     ctor public Boolean(java.lang.String);
     ctor public Boolean(boolean);
     method public boolean booleanValue();
+    method public static int compare(boolean, boolean);
     method public int compareTo(java.lang.Boolean);
     method public static boolean getBoolean(java.lang.String);
     method public static boolean parseBoolean(java.lang.String);
@@ -32469,6 +32475,7 @@
   public final class Byte extends java.lang.Number implements java.lang.Comparable {
     ctor public Byte(byte);
     ctor public Byte(java.lang.String) throws java.lang.NumberFormatException;
+    method public static int compare(byte, byte);
     method public int compareTo(java.lang.Byte);
     method public static java.lang.Byte decode(java.lang.String) throws java.lang.NumberFormatException;
     method public double doubleValue();
@@ -32506,16 +32513,20 @@
     method public static int codePointBefore(char[], int, int);
     method public static int codePointCount(java.lang.CharSequence, int, int);
     method public static int codePointCount(char[], int, int);
+    method public static int compare(char, char);
     method public int compareTo(java.lang.Character);
     method public static int digit(char, int);
     method public static int digit(int, int);
     method public static char forDigit(int, int);
     method public static byte getDirectionality(char);
     method public static byte getDirectionality(int);
+    method public static java.lang.String getName(int);
     method public static int getNumericValue(char);
     method public static int getNumericValue(int);
     method public static int getType(char);
     method public static int getType(int);
+    method public static char highSurrogate(int);
+    method public static boolean isBmpCodePoint(int);
     method public static boolean isDefined(char);
     method public static boolean isDefined(int);
     method public static boolean isDigit(char);
@@ -32544,6 +32555,7 @@
     method public static boolean isSpaceChar(char);
     method public static boolean isSpaceChar(int);
     method public static boolean isSupplementaryCodePoint(int);
+    method public static boolean isSurrogate(char);
     method public static boolean isSurrogatePair(char, char);
     method public static boolean isTitleCase(char);
     method public static boolean isTitleCase(int);
@@ -32556,6 +32568,7 @@
     method public static boolean isValidCodePoint(int);
     method public static boolean isWhitespace(char);
     method public static boolean isWhitespace(int);
+    method public static char lowSurrogate(int);
     method public static int offsetByCodePoints(java.lang.CharSequence, int, int);
     method public static int offsetByCodePoints(char[], int, int, int, int);
     method public static char reverseBytes(char);
@@ -33084,6 +33097,7 @@
     ctor public Integer(int);
     ctor public Integer(java.lang.String) throws java.lang.NumberFormatException;
     method public static int bitCount(int);
+    method public static int compare(int, int);
     method public int compareTo(java.lang.Integer);
     method public static java.lang.Integer decode(java.lang.String) throws java.lang.NumberFormatException;
     method public double doubleValue();
@@ -33135,12 +33149,14 @@
   public class LinkageError extends java.lang.Error {
     ctor public LinkageError();
     ctor public LinkageError(java.lang.String);
+    ctor public LinkageError(java.lang.String, java.lang.Throwable);
   }
 
   public final class Long extends java.lang.Number implements java.lang.Comparable {
     ctor public Long(long);
     ctor public Long(java.lang.String) throws java.lang.NumberFormatException;
     method public static int bitCount(long);
+    method public static int compare(long, long);
     method public int compareTo(java.lang.Long);
     method public static java.lang.Long decode(java.lang.String) throws java.lang.NumberFormatException;
     method public double doubleValue();
@@ -33397,6 +33413,9 @@
     ctor public RuntimePermission(java.lang.String, java.lang.String);
   }
 
+  public abstract class SafeVarargs implements java.lang.annotation.Annotation {
+  }
+
   public class SecurityException extends java.lang.RuntimeException {
     ctor public SecurityException();
     ctor public SecurityException(java.lang.String);
@@ -33453,6 +33472,7 @@
   public final class Short extends java.lang.Number implements java.lang.Comparable {
     ctor public Short(java.lang.String) throws java.lang.NumberFormatException;
     ctor public Short(short);
+    method public static int compare(short, short);
     method public int compareTo(java.lang.Short);
     method public static java.lang.Short decode(java.lang.String) throws java.lang.NumberFormatException;
     method public double doubleValue();
@@ -33724,6 +33744,7 @@
     method public static java.util.Map<java.lang.String, java.lang.String> getenv();
     method public static int identityHashCode(java.lang.Object);
     method public static java.nio.channels.Channel inheritedChannel() throws java.io.IOException;
+    method public static java.lang.String lineSeparator();
     method public static void load(java.lang.String);
     method public static void loadLibrary(java.lang.String);
     method public static java.lang.String mapLibraryName(java.lang.String);
@@ -33856,11 +33877,14 @@
     ctor public Throwable(java.lang.String);
     ctor public Throwable(java.lang.String, java.lang.Throwable);
     ctor public Throwable(java.lang.Throwable);
+    ctor protected Throwable(java.lang.String, java.lang.Throwable, boolean, boolean);
+    method public final void addSuppressed(java.lang.Throwable);
     method public java.lang.Throwable fillInStackTrace();
     method public java.lang.Throwable getCause();
     method public java.lang.String getLocalizedMessage();
     method public java.lang.String getMessage();
     method public java.lang.StackTraceElement[] getStackTrace();
+    method public final java.lang.Throwable[] getSuppressed();
     method public java.lang.Throwable initCause(java.lang.Throwable);
     method public void printStackTrace();
     method public void printStackTrace(java.io.PrintStream);
@@ -34155,6 +34179,10 @@
 
   public class Modifier {
     ctor public Modifier();
+    method public static int classModifiers();
+    method public static int constructorModifiers();
+    method public static int fieldModifiers();
+    method public static int interfaceModifiers();
     method public static boolean isAbstract(int);
     method public static boolean isFinal(int);
     method public static boolean isInterface(int);
@@ -34167,6 +34195,7 @@
     method public static boolean isSynchronized(int);
     method public static boolean isTransient(int);
     method public static boolean isVolatile(int);
+    method public static int methodModifiers();
     method public static java.lang.String toString(int);
     field public static final int ABSTRACT = 1024; // 0x400
     field public static final int FINAL = 16; // 0x10
@@ -34506,7 +34535,7 @@
     method public synchronized void setSocketAddress(java.net.SocketAddress);
   }
 
-  public class DatagramSocket {
+  public class DatagramSocket implements java.io.Closeable {
     ctor public DatagramSocket() throws java.net.SocketException;
     ctor public DatagramSocket(int) throws java.net.SocketException;
     ctor public DatagramSocket(int, java.net.InetAddress) throws java.net.SocketException;
@@ -34703,6 +34732,7 @@
     method public java.lang.String getHostAddress();
     method public java.lang.String getHostName();
     method public static java.net.InetAddress getLocalHost() throws java.net.UnknownHostException;
+    method public static java.net.InetAddress getLoopbackAddress();
     method public boolean isAnyLocalAddress();
     method public boolean isLinkLocalAddress();
     method public boolean isLoopbackAddress();
@@ -34725,6 +34755,7 @@
     method public final boolean equals(java.lang.Object);
     method public final java.net.InetAddress getAddress();
     method public final java.lang.String getHostName();
+    method public final java.lang.String getHostString();
     method public final int getPort();
     method public final int hashCode();
     method public final boolean isUnresolved();
@@ -34781,10 +34812,12 @@
   }
 
   public final class NetworkInterface {
+    method public static java.net.NetworkInterface getByIndex(int) throws java.net.SocketException;
     method public static java.net.NetworkInterface getByInetAddress(java.net.InetAddress) throws java.net.SocketException;
     method public static java.net.NetworkInterface getByName(java.lang.String) throws java.net.SocketException;
     method public java.lang.String getDisplayName();
     method public byte[] getHardwareAddress() throws java.net.SocketException;
+    method public int getIndex();
     method public java.util.Enumeration<java.net.InetAddress> getInetAddresses();
     method public java.util.List<java.net.InterfaceAddress> getInterfaceAddresses();
     method public int getMTU() throws java.net.SocketException;
@@ -34862,7 +34895,7 @@
     method public abstract java.util.List<java.security.cert.Certificate> getServerCertificateChain() throws javax.net.ssl.SSLPeerUnverifiedException;
   }
 
-  public class ServerSocket {
+  public class ServerSocket implements java.io.Closeable {
     ctor public ServerSocket() throws java.io.IOException;
     ctor public ServerSocket(int) throws java.io.IOException;
     ctor public ServerSocket(int, int) throws java.io.IOException;
@@ -34888,7 +34921,7 @@
     method public static synchronized void setSocketFactory(java.net.SocketImplFactory) throws java.io.IOException;
   }
 
-  public class Socket {
+  public class Socket implements java.io.Closeable {
     ctor public Socket();
     ctor public Socket(java.net.Proxy);
     ctor public Socket(java.lang.String, int) throws java.io.IOException, java.net.UnknownHostException;
@@ -35566,9 +35599,10 @@
     field public static final java.nio.channels.FileChannel.MapMode READ_WRITE;
   }
 
-  public abstract class FileLock {
+  public abstract class FileLock implements java.lang.AutoCloseable {
     ctor protected FileLock(java.nio.channels.FileChannel, long, long, boolean);
     method public final java.nio.channels.FileChannel channel();
+    method public final void close() throws java.io.IOException;
     method public final boolean isShared();
     method public abstract boolean isValid();
     method public final boolean overlaps(long, long);
@@ -35683,7 +35717,7 @@
     field public static final int OP_WRITE = 4; // 0x4
   }
 
-  public abstract class Selector {
+  public abstract class Selector implements java.io.Closeable {
     ctor protected Selector();
     method public abstract void close() throws java.io.IOException;
     method public abstract boolean isOpen();
@@ -37619,7 +37653,7 @@
     method public abstract void truncate(long) throws java.sql.SQLException;
   }
 
-  public abstract interface Connection implements java.sql.Wrapper {
+  public abstract interface Connection implements java.lang.AutoCloseable java.sql.Wrapper {
     method public abstract void clearWarnings() throws java.sql.SQLException;
     method public abstract void close() throws java.sql.SQLException;
     method public abstract void commit() throws java.sql.SQLException;
@@ -38048,7 +38082,7 @@
     method public abstract void setObject(java.lang.Object) throws java.sql.SQLException;
   }
 
-  public abstract interface ResultSet implements java.sql.Wrapper {
+  public abstract interface ResultSet implements java.lang.AutoCloseable java.sql.Wrapper {
     method public abstract boolean absolute(int) throws java.sql.SQLException;
     method public abstract void afterLast() throws java.sql.SQLException;
     method public abstract void beforeFirst() throws java.sql.SQLException;
@@ -38554,7 +38588,7 @@
     method public abstract java.lang.String getSavepointName() throws java.sql.SQLException;
   }
 
-  public abstract interface Statement implements java.sql.Wrapper {
+  public abstract interface Statement implements java.lang.AutoCloseable java.sql.Wrapper {
     method public abstract void addBatch(java.lang.String) throws java.sql.SQLException;
     method public abstract void cancel() throws java.sql.SQLException;
     method public abstract void clearBatch() throws java.sql.SQLException;
@@ -39454,11 +39488,19 @@
     method public int nextClearBit(int);
     method public int nextSetBit(int);
     method public void or(java.util.BitSet);
+    method public int previousClearBit(int);
+    method public int previousSetBit(int);
     method public void set(int);
     method public void set(int, boolean);
     method public void set(int, int, boolean);
     method public void set(int, int);
     method public int size();
+    method public byte[] toByteArray();
+    method public long[] toLongArray();
+    method public static java.util.BitSet valueOf(long[]);
+    method public static java.util.BitSet valueOf(java.nio.LongBuffer);
+    method public static java.util.BitSet valueOf(byte[]);
+    method public static java.util.BitSet valueOf(java.nio.ByteBuffer);
     method public void xor(java.util.BitSet);
   }
 
@@ -39591,7 +39633,10 @@
     method public static java.util.SortedSet<E> checkedSortedSet(java.util.SortedSet<E>, java.lang.Class<E>);
     method public static void copy(java.util.List<? super T>, java.util.List<? extends T>);
     method public static boolean disjoint(java.util.Collection<?>, java.util.Collection<?>);
+    method public static java.util.Enumeration<T> emptyEnumeration();
+    method public static java.util.Iterator<T> emptyIterator();
     method public static final java.util.List<T> emptyList();
+    method public static java.util.ListIterator<T> emptyListIterator();
     method public static final java.util.Map<K, V> emptyMap();
     method public static final java.util.Set<T> emptySet();
     method public static java.util.Enumeration<T> enumeration(java.util.Collection<T>);
@@ -39644,11 +39689,16 @@
   public class ConcurrentModificationException extends java.lang.RuntimeException {
     ctor public ConcurrentModificationException();
     ctor public ConcurrentModificationException(java.lang.String);
+    ctor public ConcurrentModificationException(java.lang.String, java.lang.Throwable);
+    ctor public ConcurrentModificationException(java.lang.Throwable);
   }
 
   public final class Currency implements java.io.Serializable {
+    method public static java.util.Set<java.util.Currency> getAvailableCurrencies();
     method public java.lang.String getCurrencyCode();
     method public int getDefaultFractionDigits();
+    method public java.lang.String getDisplayName();
+    method public java.lang.String getDisplayName(java.util.Locale);
     method public static java.util.Currency getInstance(java.lang.String);
     method public static java.util.Currency getInstance(java.util.Locale);
     method public java.lang.String getSymbol();
@@ -40313,7 +40363,7 @@
     field public static final long TTL_NO_EXPIRATION_CONTROL = -2L; // 0xfffffffffffffffeL
   }
 
-  public final class Scanner implements java.util.Iterator {
+  public final class Scanner implements java.io.Closeable java.util.Iterator {
     ctor public Scanner(java.io.File) throws java.io.FileNotFoundException;
     ctor public Scanner(java.io.File, java.lang.String) throws java.io.FileNotFoundException;
     ctor public Scanner(java.lang.String);
@@ -41955,6 +42005,7 @@
     method public static java.util.logging.Logger getAnonymousLogger();
     method public static java.util.logging.Logger getAnonymousLogger(java.lang.String);
     method public java.util.logging.Filter getFilter();
+    method public static java.util.logging.Logger getGlobal();
     method public java.util.logging.Handler[] getHandlers();
     method public java.util.logging.Level getLevel();
     method public static java.util.logging.Logger getLogger(java.lang.String);
@@ -42301,6 +42352,7 @@
     ctor public Deflater(int, boolean);
     method public int deflate(byte[]);
     method public synchronized int deflate(byte[], int, int);
+    method public synchronized int deflate(byte[], int, int, int);
     method public synchronized void end();
     method public synchronized void finish();
     method public synchronized boolean finished();
@@ -42323,8 +42375,11 @@
     field public static final int DEFAULT_STRATEGY = 0; // 0x0
     field public static final int DEFLATED = 8; // 0x8
     field public static final int FILTERED = 1; // 0x1
+    field public static final int FULL_FLUSH = 3; // 0x3
     field public static final int HUFFMAN_ONLY = 2; // 0x2
     field public static final int NO_COMPRESSION = 0; // 0x0
+    field public static final int NO_FLUSH = 0; // 0x0
+    field public static final int SYNC_FLUSH = 2; // 0x2
   }
 
   public class DeflaterInputStream extends java.io.FilterInputStream {
@@ -42336,9 +42391,12 @@
   }
 
   public class DeflaterOutputStream extends java.io.FilterOutputStream {
-    ctor public DeflaterOutputStream(java.io.OutputStream, java.util.zip.Deflater);
     ctor public DeflaterOutputStream(java.io.OutputStream);
+    ctor public DeflaterOutputStream(java.io.OutputStream, java.util.zip.Deflater);
     ctor public DeflaterOutputStream(java.io.OutputStream, java.util.zip.Deflater, int);
+    ctor public DeflaterOutputStream(java.io.OutputStream, boolean);
+    ctor public DeflaterOutputStream(java.io.OutputStream, java.util.zip.Deflater, boolean);
+    ctor public DeflaterOutputStream(java.io.OutputStream, java.util.zip.Deflater, int, boolean);
     method protected void deflate() throws java.io.IOException;
     method public void finish() throws java.io.IOException;
     field protected byte[] buf;
@@ -42433,7 +42491,7 @@
     ctor public ZipException(java.lang.String);
   }
 
-  public class ZipFile {
+  public class ZipFile implements java.io.Closeable {
     ctor public ZipFile(java.io.File) throws java.io.IOException, java.util.zip.ZipException;
     ctor public ZipFile(java.lang.String) throws java.io.IOException;
     ctor public ZipFile(java.io.File, int) throws java.io.IOException;
diff --git a/cmds/input/src/com/android/commands/input/Input.java b/cmds/input/src/com/android/commands/input/Input.java
index e43501c..80ac539 100644
--- a/cmds/input/src/com/android/commands/input/Input.java
+++ b/cmds/input/src/com/android/commands/input/Input.java
@@ -56,12 +56,14 @@
                     return;
                 }
             } else if (command.equals("keyevent")) {
-                if (args.length == 2) {
-                    int keyCode = KeyEvent.keyCodeFromString(args[1]);
-                    if (keyCode == KeyEvent.KEYCODE_UNKNOWN) {
-                        keyCode = KeyEvent.keyCodeFromString("KEYCODE_" + args[1]);
+                if (args.length >= 2) {
+                    for (int i=1; i < args.length; i++) {
+                        int keyCode = KeyEvent.keyCodeFromString(args[i]);
+                        if (keyCode == KeyEvent.KEYCODE_UNKNOWN) {
+                            keyCode = KeyEvent.keyCodeFromString("KEYCODE_" + args[i]);
+                        }
+                        sendKeyEvent(keyCode);
                     }
-                    sendKeyEvent(keyCode);
                     return;
                 }
             } else if (command.equals("tap")) {
@@ -237,7 +239,7 @@
                 DEFAULT_META_STATE, DEFAULT_PRECISION_X, DEFAULT_PRECISION_Y, DEFAULT_DEVICE_ID,
                 DEFAULT_EDGE_FLAGS);
         event.setSource(inputSource);
-        Log.i("Input", "injectMotionEvent: " + event);
+        Log.i(TAG, "injectMotionEvent: " + event);
         InputManager.getInstance().injectInputEvent(event,
                 InputManager.INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH);
     }
@@ -249,7 +251,7 @@
     private void showUsage() {
         System.err.println("usage: input ...");
         System.err.println("       input text <string>");
-        System.err.println("       input keyevent <key code number or name>");
+        System.err.println("       input keyevent <key code number or name> ...");
         System.err.println("       input [touchscreen|touchpad|touchnavigation] tap <x> <y>");
         System.err.println("       input [touchscreen|touchpad|touchnavigation] swipe "
                 + "<x1> <y1> <x2> <y2> [duration(ms)]");
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index d4056c9..4268fa6 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -92,8 +92,7 @@
 import com.android.internal.os.RuntimeInit;
 import com.android.internal.os.SamplingProfilerIntegration;
 import com.android.internal.util.Objects;
-
-import org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl;
+import com.android.org.conscrypt.OpenSSLSocketImpl;
 
 import java.io.File;
 import java.io.FileDescriptor;
diff --git a/core/java/android/database/sqlite/SQLiteConnection.java b/core/java/android/database/sqlite/SQLiteConnection.java
index 4f59e8e..725a1ff 100644
--- a/core/java/android/database/sqlite/SQLiteConnection.java
+++ b/core/java/android/database/sqlite/SQLiteConnection.java
@@ -30,9 +30,9 @@
 import android.util.LruCache;
 import android.util.Printer;
 
-import java.sql.Date;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.Map;
 import java.util.regex.Pattern;
 
diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java
index 2b15afd..4881d14 100644
--- a/core/java/android/inputmethodservice/InputMethodService.java
+++ b/core/java/android/inputmethodservice/InputMethodService.java
@@ -431,7 +431,7 @@
                 }
             }
             // If user uses hard keyboard, IME button should always be shown.
-            boolean showing = onEvaluateInputViewShown();
+            boolean showing = isInputViewShown();
             mImm.setImeWindowStatus(mToken, IME_ACTIVE | (showing ? IME_VISIBLE : 0),
                     mBackDisposition);
             if (resultReceiver != null) {
diff --git a/core/java/android/net/SSLCertificateSocketFactory.java b/core/java/android/net/SSLCertificateSocketFactory.java
index 2a2f7cf..37f04d3 100644
--- a/core/java/android/net/SSLCertificateSocketFactory.java
+++ b/core/java/android/net/SSLCertificateSocketFactory.java
@@ -18,6 +18,9 @@
 
 import android.os.SystemProperties;
 import android.util.Log;
+import com.android.org.conscrypt.OpenSSLContextImpl;
+import com.android.org.conscrypt.OpenSSLSocketImpl;
+import com.android.org.conscrypt.SSLClientSessionCache;
 import java.io.IOException;
 import java.net.InetAddress;
 import java.net.Socket;
@@ -36,9 +39,6 @@
 import javax.net.ssl.SSLSocketFactory;
 import javax.net.ssl.TrustManager;
 import javax.net.ssl.X509TrustManager;
-import org.apache.harmony.xnet.provider.jsse.OpenSSLContextImpl;
-import org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl;
-import org.apache.harmony.xnet.provider.jsse.SSLClientSessionCache;
 
 /**
  * SSLSocketFactory implementation with several extra features:
diff --git a/core/java/android/net/SSLSessionCache.java b/core/java/android/net/SSLSessionCache.java
index 4cbeb94..15421de 100644
--- a/core/java/android/net/SSLSessionCache.java
+++ b/core/java/android/net/SSLSessionCache.java
@@ -16,12 +16,12 @@
 
 package android.net;
 
-import org.apache.harmony.xnet.provider.jsse.FileClientSessionCache;
-import org.apache.harmony.xnet.provider.jsse.SSLClientSessionCache;
-
 import android.content.Context;
 import android.util.Log;
 
+import com.android.org.conscrypt.FileClientSessionCache;
+import com.android.org.conscrypt.SSLClientSessionCache;
+
 import java.io.File;
 import java.io.IOException;
 
diff --git a/core/java/android/net/http/CertificateChainValidator.java b/core/java/android/net/http/CertificateChainValidator.java
index f66075d..3652a4c 100644
--- a/core/java/android/net/http/CertificateChainValidator.java
+++ b/core/java/android/net/http/CertificateChainValidator.java
@@ -16,21 +16,22 @@
 
 package android.net.http;
 
+import com.android.org.conscrypt.SSLParametersImpl;
+import com.android.org.conscrypt.TrustManagerImpl;
 
+import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.security.GeneralSecurityException;
 import java.security.KeyManagementException;
 import java.security.cert.Certificate;
 import java.security.cert.CertificateException;
+import java.security.cert.CertificateFactory;
 import java.security.cert.X509Certificate;
 import javax.net.ssl.DefaultHostnameVerifier;
 import javax.net.ssl.SSLHandshakeException;
 import javax.net.ssl.SSLSession;
 import javax.net.ssl.SSLSocket;
 import javax.net.ssl.X509TrustManager;
-import org.apache.harmony.security.provider.cert.X509CertImpl;
-import org.apache.harmony.xnet.provider.jsse.SSLParametersImpl;
-import org.apache.harmony.xnet.provider.jsse.TrustManagerImpl;
 
 /**
  * Class responsible for all server certificate validation functionality
@@ -118,8 +119,14 @@
 
         X509Certificate[] serverCertificates = new X509Certificate[certChain.length];
 
-        for (int i = 0; i < certChain.length; ++i) {
-            serverCertificates[i] = new X509CertImpl(certChain[i]);
+        try {
+            CertificateFactory cf = CertificateFactory.getInstance("X.509");
+            for (int i = 0; i < certChain.length; ++i) {
+                serverCertificates[i] = (X509Certificate) cf.generateCertificate(
+                        new ByteArrayInputStream(certChain[i]));
+            }
+        } catch (CertificateException e) {
+            throw new IOException("can't read certificate", e);
         }
 
         return verifyServerDomainAndCertificates(serverCertificates, domain, authType);
diff --git a/core/java/android/net/http/HttpResponseCache.java b/core/java/android/net/http/HttpResponseCache.java
index 73f3d7c..4e986a9 100644
--- a/core/java/android/net/http/HttpResponseCache.java
+++ b/core/java/android/net/http/HttpResponseCache.java
@@ -17,21 +17,21 @@
 package android.net.http;
 
 import android.content.Context;
+import com.android.okhttp.OkResponseCache;
+import com.android.okhttp.ResponseSource;
+import com.android.okhttp.internal.DiskLruCache;
 import java.io.Closeable;
 import java.io.File;
 import java.io.IOException;
 import java.net.CacheRequest;
 import java.net.CacheResponse;
-import java.net.ExtendedResponseCache;
 import java.net.HttpURLConnection;
 import java.net.ResponseCache;
-import java.net.ResponseSource;
 import java.net.URI;
 import java.net.URLConnection;
 import java.util.List;
 import java.util.Map;
 import javax.net.ssl.HttpsURLConnection;
-import libcore.io.DiskLruCache;
 import libcore.io.IoUtils;
 import org.apache.http.impl.client.DefaultHttpClient;
 
@@ -152,12 +152,12 @@
  *       }}</pre>
  */
 public final class HttpResponseCache extends ResponseCache
-        implements Closeable, ExtendedResponseCache {
+        implements Closeable, OkResponseCache {
 
-    private final libcore.net.http.HttpResponseCache delegate;
+    private final com.android.okhttp.internal.http.HttpResponseCache delegate;
 
     private HttpResponseCache(File directory, long maxSize) throws IOException {
-        this.delegate = new libcore.net.http.HttpResponseCache(directory, maxSize);
+        this.delegate = new com.android.okhttp.internal.http.HttpResponseCache(directory, maxSize);
     }
 
     /**
@@ -274,7 +274,8 @@
     }
 
     /** @hide */
-    @Override public void update(CacheResponse conditionalCacheHit, HttpURLConnection connection) {
+    @Override public void update(CacheResponse conditionalCacheHit, HttpURLConnection connection)
+            throws IOException {
         delegate.update(conditionalCacheHit, connection);
     }
 
diff --git a/core/java/android/net/http/HttpsConnection.java b/core/java/android/net/http/HttpsConnection.java
index 84765a5..f421d29 100644
--- a/core/java/android/net/http/HttpsConnection.java
+++ b/core/java/android/net/http/HttpsConnection.java
@@ -18,9 +18,9 @@
 
 import android.content.Context;
 import android.util.Log;
-import org.apache.harmony.xnet.provider.jsse.FileClientSessionCache;
-import org.apache.harmony.xnet.provider.jsse.OpenSSLContextImpl;
-import org.apache.harmony.xnet.provider.jsse.SSLClientSessionCache;
+import com.android.org.conscrypt.FileClientSessionCache;
+import com.android.org.conscrypt.OpenSSLContextImpl;
+import com.android.org.conscrypt.SSLClientSessionCache;
 import org.apache.http.Header;
 import org.apache.http.HttpException;
 import org.apache.http.HttpHost;
diff --git a/core/java/android/net/http/X509TrustManagerExtensions.java b/core/java/android/net/http/X509TrustManagerExtensions.java
index 64eacbc..cfe5f27 100644
--- a/core/java/android/net/http/X509TrustManagerExtensions.java
+++ b/core/java/android/net/http/X509TrustManagerExtensions.java
@@ -16,7 +16,7 @@
 
 package android.net.http;
 
-import org.apache.harmony.xnet.provider.jsse.TrustManagerImpl;
+import com.android.org.conscrypt.TrustManagerImpl;
 
 import java.security.cert.CertificateException;
 import java.security.cert.X509Certificate;
diff --git a/core/java/android/text/format/DateFormat.java b/core/java/android/text/format/DateFormat.java
index c497e35..36b7d16 100644
--- a/core/java/android/text/format/DateFormat.java
+++ b/core/java/android/text/format/DateFormat.java
@@ -313,39 +313,13 @@
      * Gets the current date format stored as a char array. The array will contain
      * 3 elements ({@link #DATE}, {@link #MONTH}, and {@link #YEAR}) in the order
      * specified by the user's format preference.  Note that this order is
-     * only appropriate for all-numeric dates; spelled-out (MEDIUM and LONG)
+     * <i>only</i> appropriate for all-numeric dates; spelled-out (MEDIUM and LONG)
      * dates will generally contain other punctuation, spaces, or words,
      * not just the day, month, and year, and not necessarily in the same
      * order returned here.
      */
     public static char[] getDateFormatOrder(Context context) {
-        char[] order = new char[] {DATE, MONTH, YEAR};
-        String value = getDateFormatString(context);
-        int index = 0;
-        boolean foundDate = false;
-        boolean foundMonth = false;
-        boolean foundYear = false;
-
-        for (char c : value.toCharArray()) {
-            if (!foundDate && (c == DATE)) {
-                foundDate = true;
-                order[index] = DATE;
-                index++;
-            }
-
-            if (!foundMonth && (c == MONTH || c == STANDALONE_MONTH)) {
-                foundMonth = true;
-                order[index] = MONTH;
-                index++;
-            }
-
-            if (!foundYear && (c == YEAR)) {
-                foundYear = true;
-                order[index] = YEAR;
-                index++;
-            }
-        }
-        return order;
+        return ICU.getDateFormatOrder(getDateFormatString(context));
     }
 
     private static String getDateFormatString(Context context) {
diff --git a/core/java/android/util/SparseArray.java b/core/java/android/util/SparseArray.java
index 366abd3..7e8fee5 100644
--- a/core/java/android/util/SparseArray.java
+++ b/core/java/android/util/SparseArray.java
@@ -118,7 +118,7 @@
             mGarbage = true;
         }
     }
-    
+
     private void gc() {
         // Log.e("SparseArray", "gc start with " + mSize);
 
@@ -214,7 +214,7 @@
     /**
      * Given an index in the range <code>0...size()-1</code>, returns
      * the key from the <code>index</code>th key-value mapping that this
-     * SparseArray stores.  
+     * SparseArray stores.
      */
     public int keyAt(int index) {
         if (mGarbage) {
@@ -223,11 +223,11 @@
 
         return mKeys[index];
     }
-    
+
     /**
      * Given an index in the range <code>0...size()-1</code>, returns
      * the value from the <code>index</code>th key-value mapping that this
-     * SparseArray stores.  
+     * SparseArray stores.
      */
     @SuppressWarnings("unchecked")
     public E valueAt(int index) {
@@ -241,7 +241,7 @@
     /**
      * Given an index in the range <code>0...size()-1</code>, sets a new
      * value for the <code>index</code>th key-value mapping that this
-     * SparseArray stores.  
+     * SparseArray stores.
      */
     public void setValueAt(int index, E value) {
         if (mGarbage) {
@@ -250,7 +250,7 @@
 
         mValues[index] = value;
     }
-    
+
     /**
      * Returns the index for which {@link #keyAt} would return the
      * specified key, or a negative number if the specified
@@ -268,9 +268,11 @@
      * Returns an index for which {@link #valueAt} would return the
      * specified key, or a negative number if no keys map to the
      * specified value.
-     * Beware that this is a linear search, unlike lookups by key,
+     * <p>Beware that this is a linear search, unlike lookups by key,
      * and that multiple keys can map to the same value and this will
      * find only one of them.
+     * <p>Note also that unlike most collections' {@code indexOf} methods,
+     * this method compares values using {@code ==} rather than {@code equals}.
      */
     public int indexOfValue(E value) {
         if (mGarbage) {
@@ -332,7 +334,7 @@
         mValues[pos] = value;
         mSize = pos + 1;
     }
-    
+
     private static int binarySearch(int[] a, int start, int len, int key) {
         int high = start + len, low = start - 1, guess;
 
diff --git a/core/java/android/util/TimeUtils.java b/core/java/android/util/TimeUtils.java
index 5a4f322..33964a0 100644
--- a/core/java/android/util/TimeUtils.java
+++ b/core/java/android/util/TimeUtils.java
@@ -235,7 +235,7 @@
      * during the lifetime of an activity.
      */
     public static String getTimeZoneDatabaseVersion() {
-        return ZoneInfoDB.getVersion();
+        return ZoneInfoDB.getInstance().getVersion();
     }
 
     /** @hide Field length that can hold 999 days of time */
diff --git a/core/java/android/view/KeyEvent.java b/core/java/android/view/KeyEvent.java
index 0546d24..5db3909 100644
--- a/core/java/android/view/KeyEvent.java
+++ b/core/java/android/view/KeyEvent.java
@@ -634,8 +634,8 @@
 
     // NOTE: If you add a new keycode here you must also add it to:
     //  isSystem()
-    //  native/include/android/keycodes.h
-    //  frameworks/base/include/ui/KeycodeLabels.h
+    //  frameworks/native/include/android/keycodes.h
+    //  frameworks/base/include/androidfw/KeycodeLabels.h
     //  external/webkit/WebKit/android/plugins/ANPKeyCodes.h
     //  frameworks/base/core/res/res/values/attrs.xml
     //  emulator?
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 7f09a6a..6b119bd 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -10669,8 +10669,9 @@
      * handler can be used to pump events in the UI events queue.
      */
     public Handler getHandler() {
-        if (mAttachInfo != null) {
-            return mAttachInfo.mHandler;
+        final AttachInfo attachInfo = mAttachInfo;
+        if (attachInfo != null) {
+            return attachInfo.mHandler;
         }
         return null;
     }
diff --git a/core/java/android/webkit/BrowserFrame.java b/core/java/android/webkit/BrowserFrame.java
index ce886f2..6955d14 100644
--- a/core/java/android/webkit/BrowserFrame.java
+++ b/core/java/android/webkit/BrowserFrame.java
@@ -40,13 +40,13 @@
 
 import junit.framework.Assert;
 
+import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.lang.ref.WeakReference;
 import java.net.URLEncoder;
-import java.nio.charset.Charsets;
 import java.security.PrivateKey;
-import java.security.cert.CertificateEncodingException;
+import java.security.cert.CertificateFactory;
 import java.security.cert.X509Certificate;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -55,9 +55,8 @@
 import java.util.Map;
 import java.util.Set;
 
-import org.apache.harmony.security.provider.cert.X509CertImpl;
-import org.apache.harmony.xnet.provider.jsse.OpenSSLKey;
-import org.apache.harmony.xnet.provider.jsse.OpenSSLKeyHolder;
+import com.android.org.conscrypt.OpenSSLKey;
+import com.android.org.conscrypt.OpenSSLKeyHolder;
 
 class BrowserFrame extends Handler {
 
@@ -1081,10 +1080,12 @@
             String url) {
         final SslError sslError;
         try {
-            X509Certificate cert = new X509CertImpl(certDER);
+            CertificateFactory cf = CertificateFactory.getInstance("X.509");
+            X509Certificate cert = (X509Certificate) cf.generateCertificate(
+                    new ByteArrayInputStream(certDER));
             SslCertificate sslCert = new SslCertificate(cert);
             sslError = SslError.SslErrorFromChromiumErrorCode(certError, sslCert, url);
-        } catch (IOException e) {
+        } catch (Exception e) {
             // Can't get the certificate, not much to do.
             Log.e(LOGTAG, "Can't get the certificate from WebKit, canceling");
             nativeSslCertErrorCancel(handle, certError);
@@ -1202,9 +1203,11 @@
      */
     private void setCertificate(byte cert_der[]) {
         try {
-            X509Certificate cert = new X509CertImpl(cert_der);
+            CertificateFactory cf = CertificateFactory.getInstance("X.509");
+            X509Certificate cert = (X509Certificate) cf.generateCertificate(
+                    new ByteArrayInputStream(cert_der));
             mCallbackProxy.onReceivedCertificate(new SslCertificate(cert));
-        } catch (IOException e) {
+        } catch (Exception e) {
             // Can't get the certificate, not much to do.
             Log.e(LOGTAG, "Can't get the certificate from WebKit, canceling");
             return;
diff --git a/core/java/android/webkit/ClientCertRequestHandler.java b/core/java/android/webkit/ClientCertRequestHandler.java
index f5a60f6..d7a6806 100644
--- a/core/java/android/webkit/ClientCertRequestHandler.java
+++ b/core/java/android/webkit/ClientCertRequestHandler.java
@@ -20,9 +20,9 @@
 import java.security.PrivateKey;
 import java.security.cert.CertificateEncodingException;
 import java.security.cert.X509Certificate;
-import org.apache.harmony.xnet.provider.jsse.NativeCrypto;
-import org.apache.harmony.xnet.provider.jsse.OpenSSLKey;
-import org.apache.harmony.xnet.provider.jsse.OpenSSLKeyHolder;
+import com.android.org.conscrypt.NativeCrypto;
+import com.android.org.conscrypt.OpenSSLKey;
+import com.android.org.conscrypt.OpenSSLKeyHolder;
 
 /**
  * ClientCertRequestHandler: class responsible for handling client
diff --git a/core/java/android/widget/DatePicker.java b/core/java/android/widget/DatePicker.java
index 8f515f5..d03161e 100644
--- a/core/java/android/widget/DatePicker.java
+++ b/core/java/android/widget/DatePicker.java
@@ -23,6 +23,7 @@
 import android.os.Parcel;
 import android.os.Parcelable;
 import android.text.TextUtils;
+import android.text.InputType;
 import android.text.format.DateFormat;
 import android.text.format.DateUtils;
 import android.util.AttributeSet;
@@ -38,6 +39,7 @@
 
 import com.android.internal.R;
 
+import java.text.DateFormatSymbols;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.Arrays;
@@ -45,6 +47,8 @@
 import java.util.Locale;
 import java.util.TimeZone;
 
+import libcore.icu.ICU;
+
 /**
  * This class is a widget for selecting a date. The date can be selected by a
  * year, month, and day spinners or a {@link CalendarView}. The set of spinners
@@ -477,14 +481,27 @@
         mCurrentDate = getCalendarForLocale(mCurrentDate, locale);
 
         mNumberOfMonths = mTempDate.getActualMaximum(Calendar.MONTH) + 1;
-        mShortMonths = new String[mNumberOfMonths];
-        for (int i = 0; i < mNumberOfMonths; i++) {
-            mShortMonths[i] = DateUtils.getMonthString(Calendar.JANUARY + i,
-                    DateUtils.LENGTH_MEDIUM);
+        mShortMonths = new DateFormatSymbols().getShortMonths();
+
+        if (usingNumericMonths()) {
+            // We're in a locale where a date should either be all-numeric, or all-text.
+            // All-text would require custom NumberPicker formatters for day and year.
+            mShortMonths = new String[mNumberOfMonths];
+            for (int i = 0; i < mNumberOfMonths; ++i) {
+                mShortMonths[i] = String.format("%d", i + 1);
+            }
         }
     }
 
     /**
+     * Tests whether the current locale is one where there are no real month names,
+     * such as Chinese, Japanese, or Korean locales.
+     */
+    private boolean usingNumericMonths() {
+        return Character.isDigit(mShortMonths[Calendar.JANUARY].charAt(0));
+    }
+
+    /**
      * Gets a calendar for locale bootstrapped with the value of a given calendar.
      *
      * @param oldCalendar The old calendar.
@@ -508,24 +525,27 @@
      */
     private void reorderSpinners() {
         mSpinners.removeAllViews();
-        char[] order = DateFormat.getDateFormatOrder(getContext());
+        // We use numeric spinners for year and day, but textual months. Ask icu4c what
+        // order the user's locale uses for that combination. http://b/7207103.
+        String pattern = ICU.getBestDateTimePattern("yyyyMMMdd", Locale.getDefault().toString());
+        char[] order = ICU.getDateFormatOrder(pattern);
         final int spinnerCount = order.length;
         for (int i = 0; i < spinnerCount; i++) {
             switch (order[i]) {
-                case DateFormat.DATE:
+                case 'd':
                     mSpinners.addView(mDaySpinner);
                     setImeOptions(mDaySpinner, spinnerCount, i);
                     break;
-                case DateFormat.MONTH:
+                case 'M':
                     mSpinners.addView(mMonthSpinner);
                     setImeOptions(mMonthSpinner, spinnerCount, i);
                     break;
-                case DateFormat.YEAR:
+                case 'y':
                     mSpinners.addView(mYearSpinner);
                     setImeOptions(mYearSpinner, spinnerCount, i);
                     break;
                 default:
-                    throw new IllegalArgumentException();
+                    throw new IllegalArgumentException(Arrays.toString(order));
             }
         }
     }
@@ -660,6 +680,10 @@
         mYearSpinner.setValue(mCurrentDate.get(Calendar.YEAR));
         mMonthSpinner.setValue(mCurrentDate.get(Calendar.MONTH));
         mDaySpinner.setValue(mCurrentDate.get(Calendar.DAY_OF_MONTH));
+
+        if (usingNumericMonths()) {
+            mMonthSpinnerInput.setRawInputType(InputType.TYPE_CLASS_NUMBER);
+        }
     }
 
     /**
diff --git a/core/java/android/widget/HeaderViewListAdapter.java b/core/java/android/widget/HeaderViewListAdapter.java
index 0685e61..222f108 100644
--- a/core/java/android/widget/HeaderViewListAdapter.java
+++ b/core/java/android/widget/HeaderViewListAdapter.java
@@ -145,7 +145,7 @@
     }
 
     public boolean isEnabled(int position) {
-        // Header (negative positions will throw an ArrayIndexOutOfBoundsException)
+        // Header (negative positions will throw an IndexOutOfBoundsException)
         int numHeaders = getHeadersCount();
         if (position < numHeaders) {
             return mHeaderViewInfos.get(position).isSelectable;
@@ -161,12 +161,12 @@
             }
         }
 
-        // Footer (off-limits positions will throw an ArrayIndexOutOfBoundsException)
+        // Footer (off-limits positions will throw an IndexOutOfBoundsException)
         return mFooterViewInfos.get(adjPosition - adapterCount).isSelectable;
     }
 
     public Object getItem(int position) {
-        // Header (negative positions will throw an ArrayIndexOutOfBoundsException)
+        // Header (negative positions will throw an IndexOutOfBoundsException)
         int numHeaders = getHeadersCount();
         if (position < numHeaders) {
             return mHeaderViewInfos.get(position).data;
@@ -182,7 +182,7 @@
             }
         }
 
-        // Footer (off-limits positions will throw an ArrayIndexOutOfBoundsException)
+        // Footer (off-limits positions will throw an IndexOutOfBoundsException)
         return mFooterViewInfos.get(adjPosition - adapterCount).data;
     }
 
@@ -206,7 +206,7 @@
     }
 
     public View getView(int position, View convertView, ViewGroup parent) {
-        // Header (negative positions will throw an ArrayIndexOutOfBoundsException)
+        // Header (negative positions will throw an IndexOutOfBoundsException)
         int numHeaders = getHeadersCount();
         if (position < numHeaders) {
             return mHeaderViewInfos.get(position).view;
@@ -222,7 +222,7 @@
             }
         }
 
-        // Footer (off-limits positions will throw an ArrayIndexOutOfBoundsException)
+        // Footer (off-limits positions will throw an IndexOutOfBoundsException)
         return mFooterViewInfos.get(adjPosition - adapterCount).view;
     }
 
diff --git a/core/java/com/android/internal/os/ZygoteInit.java b/core/java/com/android/internal/os/ZygoteInit.java
index 2184fd2..fb22df7 100644
--- a/core/java/com/android/internal/os/ZygoteInit.java
+++ b/core/java/com/android/internal/os/ZygoteInit.java
@@ -34,6 +34,7 @@
 
 import libcore.io.IoUtils;
 import libcore.io.Libcore;
+import libcore.io.OsConstants;
 
 import java.io.BufferedReader;
 import java.io.FileDescriptor;
@@ -472,12 +473,25 @@
      */
     private static boolean startSystemServer()
             throws MethodAndArgsCaller, RuntimeException {
+        long capabilities = posixCapabilitiesAsBits(
+            OsConstants.CAP_KILL,
+            OsConstants.CAP_NET_ADMIN,
+            OsConstants.CAP_NET_BIND_SERVICE,
+            OsConstants.CAP_NET_BROADCAST,
+            OsConstants.CAP_NET_RAW,
+            OsConstants.CAP_SYS_BOOT,
+            OsConstants.CAP_SYS_MODULE,
+            OsConstants.CAP_SYS_NICE,
+            OsConstants.CAP_SYS_RESOURCE,
+            OsConstants.CAP_SYS_TIME,
+            OsConstants.CAP_SYS_TTY_CONFIG
+        );
         /* Hardcoded command line to start the system server */
         String args[] = {
             "--setuid=1000",
             "--setgid=1000",
             "--setgroups=1001,1002,1003,1004,1005,1006,1007,1008,1009,1010,1018,3001,3002,3003,3006,3007",
-            "--capabilities=130104352,130104352",
+            "--capabilities=" + capabilities + "," + capabilities,
             "--runtime-init",
             "--nice-name=system_server",
             "com.android.server.SystemServer",
@@ -511,6 +525,20 @@
         return true;
     }
 
+    /**
+     * Gets the bit array representation of the provided list of POSIX capabilities.
+     */
+    private static long posixCapabilitiesAsBits(int... capabilities) {
+        long result = 0;
+        for (int capability : capabilities) {
+            if ((capability < 0) || (capability > OsConstants.CAP_LAST_CAP)) {
+                throw new IllegalArgumentException(String.valueOf(capability));
+            }
+            result |= (1L << capability);
+        }
+        return result;
+    }
+
     public static void main(String argv[]) {
         try {
             // Start profiling the zygote initialization.
diff --git a/core/jni/Android.mk b/core/jni/Android.mk
index 594d578..337c1ec 100644
--- a/core/jni/Android.mk
+++ b/core/jni/Android.mk
@@ -230,6 +230,7 @@
 
 LOCAL_MODULE:= libandroid_runtime
 
+include external/stlport/libstlport.mk
 include $(BUILD_SHARED_LIBRARY)
 
 include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/core/tests/coretests/Android.mk b/core/tests/coretests/Android.mk
index b6b15c4..22fa7fc 100644
--- a/core/tests/coretests/Android.mk
+++ b/core/tests/coretests/Android.mk
@@ -23,7 +23,7 @@
 
 LOCAL_DX_FLAGS := --core-library
 LOCAL_STATIC_JAVA_LIBRARIES := core-tests android-common frameworks-core-util-lib mockwebserver guava littlemock
-LOCAL_JAVA_LIBRARIES := android.test.runner telephony-common
+LOCAL_JAVA_LIBRARIES := android.test.runner conscrypt telephony-common
 LOCAL_PACKAGE_NAME := FrameworksCoreTests
 
 LOCAL_CERTIFICATE := platform
diff --git a/core/tests/coretests/src/android/net/http/X509TrustManagerExtensionsTest.java b/core/tests/coretests/src/android/net/http/X509TrustManagerExtensionsTest.java
index 60c40db..04aa62a 100644
--- a/core/tests/coretests/src/android/net/http/X509TrustManagerExtensionsTest.java
+++ b/core/tests/coretests/src/android/net/http/X509TrustManagerExtensionsTest.java
@@ -25,7 +25,7 @@
 
 import junit.framework.TestCase;
 
-import org.apache.harmony.xnet.provider.jsse.TrustManagerImpl;
+import com.android.org.conscrypt.TrustManagerImpl;
 
 public class X509TrustManagerExtensionsTest extends TestCase {
 
diff --git a/docs/html/guide/topics/data/backup.jd b/docs/html/guide/topics/data/backup.jd
index 598b08a..4903852 100644
--- a/docs/html/guide/topics/data/backup.jd
+++ b/docs/html/guide/topics/data/backup.jd
@@ -680,7 +680,7 @@
 
 <pre>
 public class MyFileBackupAgent extends BackupAgentHelper {
-    // The name of the SharedPreferences file
+    // The name of the file
     static final String TOP_SCORES = "scores";
     static final String PLAYER_STATS = "stats";
 
diff --git a/keystore/java/android/security/AndroidKeyPairGenerator.java b/keystore/java/android/security/AndroidKeyPairGenerator.java
index 43d1eb6..390e732 100644
--- a/keystore/java/android/security/AndroidKeyPairGenerator.java
+++ b/keystore/java/android/security/AndroidKeyPairGenerator.java
@@ -18,7 +18,7 @@
 
 import com.android.org.bouncycastle.x509.X509V3CertificateGenerator;
 
-import org.apache.harmony.xnet.provider.jsse.OpenSSLEngine;
+import com.android.org.conscrypt.OpenSSLEngine;
 
 import java.security.InvalidAlgorithmParameterException;
 import java.security.InvalidKeyException;
diff --git a/keystore/java/android/security/AndroidKeyStore.java b/keystore/java/android/security/AndroidKeyStore.java
index 04ee8c4..acbae8f 100644
--- a/keystore/java/android/security/AndroidKeyStore.java
+++ b/keystore/java/android/security/AndroidKeyStore.java
@@ -16,8 +16,8 @@
 
 package android.security;
 
-import org.apache.harmony.xnet.provider.jsse.OpenSSLEngine;
-import org.apache.harmony.xnet.provider.jsse.OpenSSLKeyHolder;
+import com.android.org.conscrypt.OpenSSLEngine;
+import com.android.org.conscrypt.OpenSSLKeyHolder;
 
 import android.util.Log;
 
diff --git a/keystore/java/android/security/KeyChain.java b/keystore/java/android/security/KeyChain.java
index c99dff0..328ac5d 100644
--- a/keystore/java/android/security/KeyChain.java
+++ b/keystore/java/android/security/KeyChain.java
@@ -37,8 +37,8 @@
 import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.LinkedBlockingQueue;
 
-import org.apache.harmony.xnet.provider.jsse.OpenSSLEngine;
-import org.apache.harmony.xnet.provider.jsse.TrustedCertificateStore;
+import com.android.org.conscrypt.OpenSSLEngine;
+import com.android.org.conscrypt.TrustedCertificateStore;
 
 /**
  * The {@code KeyChain} class provides access to private keys and
@@ -346,6 +346,8 @@
             List<X509Certificate> chain = store
                     .getCertificateChain(toCertificate(certificateBytes));
             return chain.toArray(new X509Certificate[chain.size()]);
+        } catch (CertificateException e) {
+            throw new KeyChainException(e);
         } catch (RemoteException e) {
             throw new KeyChainException(e);
         } catch (RuntimeException e) {
diff --git a/keystore/tests/Android.mk b/keystore/tests/Android.mk
index 61cf640..35388d7 100644
--- a/keystore/tests/Android.mk
+++ b/keystore/tests/Android.mk
@@ -5,7 +5,7 @@
 LOCAL_MODULE_TAGS := tests
 LOCAL_CERTIFICATE := platform
 
-LOCAL_JAVA_LIBRARIES := android.test.runner bouncycastle
+LOCAL_JAVA_LIBRARIES := android.test.runner bouncycastle conscrypt
 
 # Include all test java files.
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
diff --git a/keystore/tests/src/android/security/AndroidKeyStoreTest.java b/keystore/tests/src/android/security/AndroidKeyStoreTest.java
index 8798fb5..b7129db 100644
--- a/keystore/tests/src/android/security/AndroidKeyStoreTest.java
+++ b/keystore/tests/src/android/security/AndroidKeyStoreTest.java
@@ -18,7 +18,7 @@
 
 import com.android.org.bouncycastle.x509.X509V3CertificateGenerator;
 
-import org.apache.harmony.xnet.provider.jsse.OpenSSLEngine;
+import com.android.org.conscrypt.OpenSSLEngine;
 
 import android.test.AndroidTestCase;
 
diff --git a/media/java/android/media/MediaCodec.java b/media/java/android/media/MediaCodec.java
index 45a8b99..d703642c 100644
--- a/media/java/android/media/MediaCodec.java
+++ b/media/java/android/media/MediaCodec.java
@@ -171,7 +171,7 @@
      * <li>"audio/3gpp" - AMR narrowband audio
      * <li>"audio/amr-wb" - AMR wideband audio
      * <li>"audio/mpeg" - MPEG1/2 audio layer III
-     * <li>"audio/mp4a-latm" - AAC audio
+     * <li>"audio/mp4a-latm" - AAC audio (note, this is raw AAC packets, not packaged in LATM!)
      * <li>"audio/vorbis" - vorbis audio
      * <li>"audio/g711-alaw" - G.711 alaw audio
      * <li>"audio/g711-mlaw" - G.711 ulaw audio
diff --git a/packages/InputDevices/res/raw/keyboard_layout_brazilian.kcm b/packages/InputDevices/res/raw/keyboard_layout_brazilian.kcm
new file mode 100644
index 0000000..140c7ac
--- /dev/null
+++ b/packages/InputDevices/res/raw/keyboard_layout_brazilian.kcm
@@ -0,0 +1,339 @@
+# 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.
+
+#
+# Brazilian keyboard layout.
+#
+
+type OVERLAY
+
+map key 86 PLUS
+map key 89 RO
+
+### ROW 1
+
+key GRAVE {
+    label:                              '\''
+    base:                               '\''
+    shift:                              '"'
+}
+
+key 1 {
+    label:                              '1'
+    base:                               '1'
+    shift:                              '!'
+    ralt:                               '\u00b9'
+}
+
+key 2 {
+    label:                              '2'
+    base:                               '2'
+    shift:                              '@'
+    ralt:                               '\u00b2'
+}
+
+key 3 {
+    label:                              '3'
+    base:                               '3'
+    shift:                              '#'
+    ralt:                               '\u00b3'
+}
+
+key 4 {
+    label:                              '4'
+    base:                               '4'
+    shift:                              '$'
+    ralt:                               '\u00a3'
+}
+
+key 5 {
+    label:                              '5'
+    base:                               '5'
+    shift:                              '%'
+    ralt:                               '\u00a2'
+}
+
+key 6 {
+    label:                              '6'
+    base:                               '6'
+    shift:                              '\u0308'
+    ralt:                               '\u00ac'
+}
+
+key 7 {
+    label:                              '7'
+    base:                               '7'
+    shift:                              '&'
+}
+
+key 8 {
+    label:                              '8'
+    base:                               '8'
+    shift:                              '*'
+}
+
+key 9 {
+    label:                              '9'
+    base:                               '9'
+    shift:                              '('
+}
+
+key 0 {
+    label:                              '0'
+    base:                               '0'
+    shift:                              ')'
+    ralt:                               '}'
+}
+
+key MINUS {
+    label:                              '-'
+    base:                               '-'
+    shift:                              '_'
+}
+
+key EQUALS {
+    label:                              '='
+    base:                               '='
+    shift:                              '+'
+    ralt:                               '\u00a7'
+}
+
+### ROW 2
+
+key Q {
+    label:                              'Q'
+    base:                               'q'
+    shift, capslock:                    'Q'
+    ralt:                               '/'
+}
+
+key W {
+    label:                              'W'
+    base:                               'w'
+    shift, capslock:                    'W'
+    ralt:                               '?'
+}
+
+key E {
+    label:                              'E'
+    base:                               'e'
+    shift, capslock:                    'E'
+    ralt:                               '\u20ac'
+}
+
+key R {
+    label:                              'R'
+    base:                               'r'
+    shift, capslock:                    'R'
+}
+
+key T {
+    label:                              'T'
+    base:                               't'
+    shift, capslock:                    'T'
+}
+
+key Y {
+    label:                              'Y'
+    base:                               'y'
+    shift, capslock:                    'Y'
+}
+
+key U {
+    label:                              'U'
+    base:                               'u'
+    shift, capslock:                    'U'
+}
+
+key I {
+    label:                              'I'
+    base:                               'i'
+    shift, capslock:                    'I'
+}
+
+key O {
+    label:                              'O'
+    base:                               'o'
+    shift, capslock:                    'O'
+}
+
+key P {
+    label:                              'P'
+    base:                               'p'
+    shift, capslock:                    'P'
+}
+
+key LEFT_BRACKET {
+    label:                              '\u00b4'
+    base:                               '\u0301'
+    shift:                              '\u0300'
+}
+
+key RIGHT_BRACKET {
+    label:                              '['
+    base:                               '['
+    shift:                              '{'
+    ralt:                               '\u00aa'
+}
+
+### ROW 3
+
+key A {
+    label:                              'A'
+    base:                               'a'
+    shift, capslock:                    'A'
+}
+
+key S {
+    label:                              'S'
+    base:                               's'
+    shift, capslock:                    'S'
+}
+
+key D {
+    label:                              'D'
+    base:                               'd'
+    shift, capslock:                    'D'
+}
+
+key F {
+    label:                              'F'
+    base:                               'f'
+    shift, capslock:                    'F'
+}
+
+key G {
+    label:                              'G'
+    base:                               'g'
+    shift, capslock:                    'G'
+}
+
+key H {
+    label:                              'H'
+    base:                               'h'
+    shift, capslock:                    'H'
+}
+
+key J {
+    label:                              'J'
+    base:                               'j'
+    shift, capslock:                    'J'
+}
+
+key K {
+    label:                              'K'
+    base:                               'k'
+    shift, capslock:                    'K'
+}
+
+key L {
+    label:                              'L'
+    base:                               'l'
+    shift, capslock:                    'L'
+}
+
+key SEMICOLON {
+    label:                              '\u00c7'
+    base:                               '\u00e7'
+    shift, capslock:                    '\u00c7'
+}
+
+key APOSTROPHE {
+    label:                              '\u02dc'
+    base:                               '\u0303'
+    shift:                              '\u0302'
+}
+
+key BACKSLASH {
+    label:                              ']'
+    base:                               ']'
+    shift, capslock:                    '}'
+    ralt:                               '\u00ba'
+}
+
+### ROW 4
+
+key PLUS {
+    label:                              '\\'
+    base:                               '\\'
+    shift:                              '|'
+}
+
+key Z {
+    label:                              'Z'
+    base:                               'z'
+    shift, capslock:                    'Z'
+}
+
+key X {
+    label:                              'X'
+    base:                               'x'
+    shift, capslock:                    'X'
+}
+
+key C {
+    label:                              'C'
+    base:                               'c'
+    shift, capslock:                    'C'
+    ralt:                               '\u20a2'
+}
+
+key V {
+    label:                              'V'
+    base:                               'v'
+    shift, capslock:                    'V'
+}
+
+key B {
+    label:                              'B'
+    base:                               'b'
+    shift, capslock:                    'B'
+}
+
+key N {
+    label:                              'N'
+    base:                               'n'
+    shift, capslock:                    'N'
+}
+
+key M {
+    label:                              'M'
+    base:                               'm'
+    shift, capslock:                    'M'
+}
+
+key COMMA {
+    label:                              ','
+    base:                               ','
+    shift:                              '<'
+}
+
+key PERIOD {
+    label:                              '.'
+    base:                               '.'
+    shift:                              '>'
+}
+
+key SLASH {
+    label:                              ';'
+    base:                               ';'
+    shift:                              ':'
+}
+
+key RO {
+    label:                              '/'
+    base:                               '/'
+    shift:                              '?'
+    ralt:                               '\u00b0'
+}
diff --git a/packages/InputDevices/res/raw/keyboard_layout_english_us_intl.kcm b/packages/InputDevices/res/raw/keyboard_layout_english_us_intl.kcm
new file mode 100644
index 0000000..0fabf02
--- /dev/null
+++ b/packages/InputDevices/res/raw/keyboard_layout_english_us_intl.kcm
@@ -0,0 +1,379 @@
+# 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.
+
+#
+# English (US) International keyboard layout.
+#
+
+type OVERLAY
+
+map key 86 PLUS
+
+### ROW 1
+
+key GRAVE {
+    label:                              '\u0300'
+    base:                               '\u0300'
+    shift:                              '\u0303'
+}
+
+key 1 {
+    label:                              '1'
+    base:                               '1'
+    shift:                              '!'
+    ralt:                               '\u00a1'
+    ralt+shift:                         '\u00b9'
+}
+
+key 2 {
+    label:                              '2'
+    base:                               '2'
+    shift:                              '@'
+    ralt:                               '\u00b2'
+}
+
+key 3 {
+    label:                              '3'
+    base:                               '3'
+    shift:                              '#'
+    ralt:                               '\u00b3'
+}
+
+key 4 {
+    label:                              '4'
+    base:                               '4'
+    shift:                              '$'
+    ralt:                               '\u00a4'
+    ralt+shift:                         '\u00a3'
+}
+
+key 5 {
+    label:                              '5'
+    base:                               '5'
+    shift:                              '%'
+    ralt:                               '\u20ac'
+}
+
+key 6 {
+    label:                              '6'
+    base:                               '6'
+    shift:                              '\u0302'
+    ralt:                               '\u00bc'
+}
+
+key 7 {
+    label:                              '7'
+    base:                               '7'
+    shift:                              '&'
+    ralt:                               '\u00bd'
+}
+
+key 8 {
+    label:                              '8'
+    base:                               '8'
+    shift:                              '*'
+    ralt:                               '\u00be'
+}
+
+key 9 {
+    label:                              '9'
+    base:                               '9'
+    shift:                              '('
+    ralt:                               '\u2018'
+}
+
+key 0 {
+    label:                              '0'
+    base:                               '0'
+    shift:                              ')'
+    ralt:                               '\u2019'
+}
+
+key MINUS {
+    label:                              '-'
+    base:                               '-'
+    shift:                              '_'
+    ralt:                               '\u00a5'
+}
+
+key EQUALS {
+    label:                              '='
+    base:                               '='
+    shift:                              '+'
+    ralt:                               '\u00d7'
+    shift+ralt:                         '\u00f7'
+}
+
+### ROW 2
+
+key Q {
+    label:                              'Q'
+    base:                               'q'
+    shift, capslock:                    'Q'
+    ralt:                               '\u00e4'
+    shift+ralt:                         '\u00c4'
+}
+
+key W {
+    label:                              'W'
+    base:                               'w'
+    shift, capslock:                    'W'
+    ralt:                               '\u00e5'
+    shift+ralt:                         '\u00c5'
+}
+
+key E {
+    label:                              'E'
+    base:                               'e'
+    shift, capslock:                    'E'
+    ralt:                               '\u00e9'
+    shift+ralt:                         '\u00c9'
+}
+
+key R {
+    label:                              'R'
+    base:                               'r'
+    shift, capslock:                    'R'
+    ralt:                               '\u00ae'
+}
+
+key T {
+    label:                              'T'
+    base:                               't'
+    shift, capslock:                    'T'
+    ralt:                               '\u00fe'
+    shift+ralt:                         '\u00de'
+}
+
+key Y {
+    label:                              'Y'
+    base:                               'y'
+    shift, capslock:                    'Y'
+    ralt:                               '\u00fc'
+    shift+ralt:                         '\u00dc'
+}
+
+key U {
+    label:                              'U'
+    base:                               'u'
+    shift, capslock:                    'U'
+    ralt:                               '\u00fa'
+    shift+ralt:                         '\u00da'
+}
+
+key I {
+    label:                              'I'
+    base:                               'i'
+    shift, capslock:                    'I'
+    ralt:                               '\u00ed'
+    shift+ralt:                         '\u00cd'
+}
+
+key O {
+    label:                              'O'
+    base:                               'o'
+    shift, capslock:                    'O'
+    ralt:                               '\u00f3'
+    shift+ralt:                         '\u00d3'
+}
+
+key P {
+    label:                              'P'
+    base:                               'p'
+    shift, capslock:                    'P'
+    ralt:                               '\u00f6'
+    shift+ralt:                         '\u00d6'
+}
+
+key LEFT_BRACKET {
+    label:                              '['
+    base:                               '['
+    shift:                              '{'
+    ralt:                               '\u00ab'
+}
+
+key RIGHT_BRACKET {
+    label:                              ']'
+    base:                               ']'
+    shift:                              '}'
+    ralt:                               '\u00bb'
+}
+
+key BACKSLASH {
+    label:                              '\\'
+    base:                               '\\'
+    shift:                              '|'
+    ralt:                               '\u00ac'
+    shift+ralt:                         '\u00a6'
+}
+
+### ROW 3
+
+key A {
+    label:                              'A'
+    base:                               'a'
+    shift, capslock:                    'A'
+    ralt:                               '\u00e1'
+    shift+ralt:                         '\u00c1'
+}
+
+key S {
+    label:                              'S'
+    base:                               's'
+    shift, capslock:                    'S'
+    ralt:                               '\u00df'
+    shift+ralt:                         '\u00a7'
+}
+
+key D {
+    label:                              'D'
+    base:                               'd'
+    shift, capslock:                    'D'
+    ralt:                               '\u00f0'
+    shift+ralt:                         '\u00d0'
+}
+
+key F {
+    label:                              'F'
+    base:                               'f'
+    shift, capslock:                    'F'
+}
+
+key G {
+    label:                              'G'
+    base:                               'g'
+    shift, capslock:                    'G'
+}
+
+key H {
+    label:                              'H'
+    base:                               'h'
+    shift, capslock:                    'H'
+}
+
+key J {
+    label:                              'J'
+    base:                               'j'
+    shift, capslock:                    'J'
+}
+
+key K {
+    label:                              'K'
+    base:                               'k'
+    shift, capslock:                    'K'
+}
+
+key L {
+    label:                              'L'
+    base:                               'l'
+    shift, capslock:                    'L'
+    ralt:                               '\u00f8'
+    shift+ralt:                         '\u00d8'
+}
+
+key SEMICOLON {
+    label:                              ';'
+    base:                               ';'
+    shift:                              ':'
+    ralt:                               '\u00b6'
+    shift+ralt:                         '\u00b0'
+}
+
+key APOSTROPHE {
+    label:                              '\''
+    base:                               '\''
+    shift:                              '"'
+    ralt:                               '\u0301'
+    shift+ralt:                         '\u0308'
+}
+
+### ROW 4
+
+key PLUS {
+    label:                              '\\'
+    base:                               '\\'
+    shift:                              '|'
+    ralt:                               '\u00ac'
+    shift+ralt:                         '\u00a6'
+}
+
+key Z {
+    label:                              'Z'
+    base:                               'z'
+    shift, capslock:                    'Z'
+    ralt:                               '\u00e6'
+    shift+ralt:                         '\u00c6'
+}
+
+key X {
+    label:                              'X'
+    base:                               'x'
+    shift, capslock:                    'X'
+}
+
+key C {
+    label:                              'C'
+    base:                               'c'
+    shift, capslock:                    'C'
+    ralt:                               '\u00a9'
+    shift+ralt:                         '\u00a2'
+}
+
+key V {
+    label:                              'V'
+    base:                               'v'
+    shift, capslock:                    'V'
+}
+
+key B {
+    label:                              'B'
+    base:                               'b'
+    shift, capslock:                    'B'
+}
+
+key N {
+    label:                              'N'
+    base:                               'n'
+    shift, capslock:                    'N'
+    ralt:                               '\u00f1'
+    shift+ralt:                         '\u00d1'
+}
+
+key M {
+    label:                              'M'
+    base:                               'm'
+    shift, capslock:                    'M'
+    ralt:                               '\u00b5'
+}
+
+key COMMA {
+    label:                              ','
+    base:                               ','
+    shift:                              '<'
+    ralt:                               '\u00e7'
+    shift+ralt:                         '\u00c7'
+}
+
+key PERIOD {
+    label:                              '.'
+    base:                               '.'
+    shift:                              '>'
+}
+
+key SLASH {
+    label:                              '/'
+    base:                               '/'
+    shift:                              '?'
+    ralt:                               '\u00bf'
+}
diff --git a/packages/InputDevices/res/values/strings.xml b/packages/InputDevices/res/values/strings.xml
index 65d3304..32c665a 100644
--- a/packages/InputDevices/res/values/strings.xml
+++ b/packages/InputDevices/res/values/strings.xml
@@ -12,6 +12,9 @@
     <!-- US English keyboard layout label. [CHAR LIMIT=35] -->
     <string name="keyboard_layout_english_us_label">English (US)</string>
 
+    <!-- US English (International style) keyboard layout label. [CHAR LIMIT=35] -->
+    <string name="keyboard_layout_english_us_intl">English (US), International style</string>
+
     <!-- US English (Dvorak style) keyboard layout label. [CHAR LIMIT=35] -->
     <string name="keyboard_layout_english_us_dvorak_label">English (US), Dvorak style</string>
 
@@ -75,6 +78,9 @@
     <!-- Icelandic keyboard layout label. [CHAR LIMIT=35] -->
     <string name="keyboard_layout_icelandic">Icelandic</string>
 
+    <!-- Brazilian keyboard layout label. [CHAR LIMIT=35] -->
+    <string name="keyboard_layout_brazilian">Brazilian</string>
+
     <!-- Portuguese keyboard layout label. [CHAR LIMIT=35] -->
     <string name="keyboard_layout_portuguese">Portuguese</string>
 
diff --git a/packages/InputDevices/res/xml/keyboard_layouts.xml b/packages/InputDevices/res/xml/keyboard_layouts.xml
index 3cfa170..ffd1a23 100644
--- a/packages/InputDevices/res/xml/keyboard_layouts.xml
+++ b/packages/InputDevices/res/xml/keyboard_layouts.xml
@@ -8,6 +8,10 @@
             android:label="@string/keyboard_layout_english_us_label"
             android:keyboardLayout="@raw/keyboard_layout_english_us" />
 
+    <keyboard-layout android:name="keyboard_layout_english_us_intl"
+            android:label="@string/keyboard_layout_english_us_intl"
+            android:keyboardLayout="@raw/keyboard_layout_english_us_intl" />
+
     <keyboard-layout android:name="keyboard_layout_english_us_dvorak"
             android:label="@string/keyboard_layout_english_us_dvorak_label"
             android:keyboardLayout="@raw/keyboard_layout_english_us_dvorak" />
@@ -92,6 +96,10 @@
             android:label="@string/keyboard_layout_icelandic"
             android:keyboardLayout="@raw/keyboard_layout_icelandic" />
 
+    <keyboard-layout android:name="keyboard_layout_brazilian"
+            android:label="@string/keyboard_layout_brazilian"
+            android:keyboardLayout="@raw/keyboard_layout_brazilian" />
+
     <keyboard-layout android:name="keyboard_layout_portuguese"
             android:label="@string/keyboard_layout_portuguese"
             android:keyboardLayout="@raw/keyboard_layout_portuguese" />
diff --git a/preloaded-classes b/preloaded-classes
index 8e426c5..2aa610a 100644
--- a/preloaded-classes
+++ b/preloaded-classes
@@ -1685,6 +1685,120 @@
 com.android.org.bouncycastle.util.encoders.HexEncoder
 com.android.org.bouncycastle.util.io.Streams
 com.android.org.bouncycastle.x509.ExtendedPKIXParameters
+com.android.org.conscrypt.AbstractSessionContext
+com.android.org.conscrypt.AbstractSessionContext$1
+com.android.org.conscrypt.ByteArray
+com.android.org.conscrypt.CertPinManager
+com.android.org.conscrypt.ChainStrengthAnalyzer
+com.android.org.conscrypt.ClientSessionContext
+com.android.org.conscrypt.ClientSessionContext$HostAndPort
+com.android.org.conscrypt.DefaultSSLContextImpl
+com.android.org.conscrypt.FileClientSessionCache
+com.android.org.conscrypt.FileClientSessionCache$Impl
+com.android.org.conscrypt.JSSEProvider
+com.android.org.conscrypt.KeyManagerFactoryImpl
+com.android.org.conscrypt.KeyManagerImpl
+com.android.org.conscrypt.NativeCrypto
+com.android.org.conscrypt.NativeCrypto$SSLHandshakeCallbacks
+com.android.org.conscrypt.OpenSSLBIOInputStream
+com.android.org.conscrypt.OpenSSLCipher
+com.android.org.conscrypt.OpenSSLCipher$AES
+com.android.org.conscrypt.OpenSSLCipher$AES$CBC
+com.android.org.conscrypt.OpenSSLCipher$AES$CBC$NoPadding
+com.android.org.conscrypt.OpenSSLCipher$AES$CBC$PKCS5Padding
+com.android.org.conscrypt.OpenSSLCipher$AES$CFB
+com.android.org.conscrypt.OpenSSLCipher$AES$CFB$NoPadding
+com.android.org.conscrypt.OpenSSLCipher$AES$CFB$PKCS5Padding
+com.android.org.conscrypt.OpenSSLCipher$AES$CTR
+com.android.org.conscrypt.OpenSSLCipher$AES$CTR$NoPadding
+com.android.org.conscrypt.OpenSSLCipher$AES$CTR$PKCS5Padding
+com.android.org.conscrypt.OpenSSLCipher$AES$ECB
+com.android.org.conscrypt.OpenSSLCipher$AES$ECB$NoPadding
+com.android.org.conscrypt.OpenSSLCipher$AES$ECB$PKCS5Padding
+com.android.org.conscrypt.OpenSSLCipher$AES$OFB
+com.android.org.conscrypt.OpenSSLCipher$AES$OFB$NoPadding
+com.android.org.conscrypt.OpenSSLCipher$AES$OFB$PKCS5Padding
+com.android.org.conscrypt.OpenSSLCipher$ARC4
+com.android.org.conscrypt.OpenSSLCipher$DESEDE
+com.android.org.conscrypt.OpenSSLCipher$DESEDE$CBC
+com.android.org.conscrypt.OpenSSLCipher$DESEDE$CBC$NoPadding
+com.android.org.conscrypt.OpenSSLCipher$DESEDE$CBC$PKCS5Padding
+com.android.org.conscrypt.OpenSSLCipher$DESEDE$CFB
+com.android.org.conscrypt.OpenSSLCipher$DESEDE$CFB$NoPadding
+com.android.org.conscrypt.OpenSSLCipher$DESEDE$CFB$PKCS5Padding
+com.android.org.conscrypt.OpenSSLCipher$DESEDE$ECB
+com.android.org.conscrypt.OpenSSLCipher$DESEDE$ECB$NoPadding
+com.android.org.conscrypt.OpenSSLCipher$DESEDE$ECB$PKCS5Padding
+com.android.org.conscrypt.OpenSSLCipher$DESEDE$OFB
+com.android.org.conscrypt.OpenSSLCipher$DESEDE$OFB$NoPadding
+com.android.org.conscrypt.OpenSSLCipher$DESEDE$OFB$PKCS5Padding
+com.android.org.conscrypt.OpenSSLCipherRSA
+com.android.org.conscrypt.OpenSSLCipherRSA$PKCS1
+com.android.org.conscrypt.OpenSSLCipherRSA$Raw
+com.android.org.conscrypt.OpenSSLContextImpl
+com.android.org.conscrypt.OpenSSLDSAKeyFactory
+com.android.org.conscrypt.OpenSSLDSAKeyPairGenerator
+com.android.org.conscrypt.OpenSSLECDHKeyAgreement
+com.android.org.conscrypt.OpenSSLECKeyFactory
+com.android.org.conscrypt.OpenSSLECKeyPairGenerator
+com.android.org.conscrypt.OpenSSLKey
+com.android.org.conscrypt.OpenSSLKeyHolder
+com.android.org.conscrypt.OpenSSLMac
+com.android.org.conscrypt.OpenSSLMac$HmacMD5
+com.android.org.conscrypt.OpenSSLMac$HmacSHA1
+com.android.org.conscrypt.OpenSSLMac$HmacSHA256
+com.android.org.conscrypt.OpenSSLMac$HmacSHA384
+com.android.org.conscrypt.OpenSSLMac$HmacSHA512
+com.android.org.conscrypt.OpenSSLMessageDigestJDK
+com.android.org.conscrypt.OpenSSLMessageDigestJDK$MD5
+com.android.org.conscrypt.OpenSSLMessageDigestJDK$SHA1
+com.android.org.conscrypt.OpenSSLProvider
+com.android.org.conscrypt.OpenSSLRSAKeyFactory
+com.android.org.conscrypt.OpenSSLRSAKeyPairGenerator
+com.android.org.conscrypt.OpenSSLRSAPublicKey
+com.android.org.conscrypt.OpenSSLRandom
+com.android.org.conscrypt.OpenSSLSessionImpl
+com.android.org.conscrypt.OpenSSLSignature
+com.android.org.conscrypt.OpenSSLSignature$1
+com.android.org.conscrypt.OpenSSLSignature$EngineType
+com.android.org.conscrypt.OpenSSLSignature$MD5RSA
+com.android.org.conscrypt.OpenSSLSignature$SHA1DSA
+com.android.org.conscrypt.OpenSSLSignature$SHA1ECDSA
+com.android.org.conscrypt.OpenSSLSignature$SHA1RSA
+com.android.org.conscrypt.OpenSSLSignature$SHA256ECDSA
+com.android.org.conscrypt.OpenSSLSignature$SHA256RSA
+com.android.org.conscrypt.OpenSSLSignature$SHA384ECDSA
+com.android.org.conscrypt.OpenSSLSignature$SHA384RSA
+com.android.org.conscrypt.OpenSSLSignature$SHA512ECDSA
+com.android.org.conscrypt.OpenSSLSignature$SHA512RSA
+com.android.org.conscrypt.OpenSSLSignatureRawRSA
+com.android.org.conscrypt.OpenSSLSocketFactoryImpl
+com.android.org.conscrypt.OpenSSLSocketImpl
+com.android.org.conscrypt.OpenSSLSocketImpl$SSLInputStream
+com.android.org.conscrypt.OpenSSLSocketImpl$SSLOutputStream
+com.android.org.conscrypt.OpenSSLSocketImplWrapper
+com.android.org.conscrypt.OpenSSLX509CertPath
+com.android.org.conscrypt.OpenSSLX509CertPath$Encoding
+com.android.org.conscrypt.OpenSSLX509Certificate
+com.android.org.conscrypt.OpenSSLX509CertificateFactory
+com.android.org.conscrypt.OpenSSLX509CertificateFactory$1
+com.android.org.conscrypt.OpenSSLX509CertificateFactory$2
+com.android.org.conscrypt.OpenSSLX509CertificateFactory$Parser
+com.android.org.conscrypt.ProtocolVersion
+com.android.org.conscrypt.SSLClientSessionCache
+com.android.org.conscrypt.SSLContextImpl
+com.android.org.conscrypt.SSLParametersImpl
+com.android.org.conscrypt.ServerSessionContext
+com.android.org.conscrypt.TrustManagerFactoryImpl
+com.android.org.conscrypt.TrustManagerImpl
+com.android.org.conscrypt.TrustManagerImpl$ExtendedKeyUsagePKIXCertPathChecker
+com.android.org.conscrypt.TrustedCertificateIndex
+com.android.org.conscrypt.TrustedCertificateKeyStoreSpi
+com.android.org.conscrypt.TrustedCertificateStore
+com.android.org.conscrypt.TrustedCertificateStore$1
+com.android.org.conscrypt.TrustedCertificateStore$2
+com.android.org.conscrypt.TrustedCertificateStore$3
+com.android.org.conscrypt.TrustedCertificateStore$CertSelector
 com.android.server.NetworkManagementSocketTagger
 com.android.server.NetworkManagementSocketTagger$1
 com.android.server.NetworkManagementSocketTagger$SocketTags
@@ -2503,120 +2617,6 @@
 org.apache.harmony.security.x509.Validity$1
 org.apache.harmony.xml.ExpatAttributes
 org.apache.harmony.xml.ExpatParser
-org.apache.harmony.xnet.provider.jsse.AbstractSessionContext
-org.apache.harmony.xnet.provider.jsse.AbstractSessionContext$1
-org.apache.harmony.xnet.provider.jsse.ByteArray
-org.apache.harmony.xnet.provider.jsse.CertPinManager
-org.apache.harmony.xnet.provider.jsse.ChainStrengthAnalyzer
-org.apache.harmony.xnet.provider.jsse.ClientSessionContext
-org.apache.harmony.xnet.provider.jsse.ClientSessionContext$HostAndPort
-org.apache.harmony.xnet.provider.jsse.DefaultSSLContextImpl
-org.apache.harmony.xnet.provider.jsse.FileClientSessionCache
-org.apache.harmony.xnet.provider.jsse.FileClientSessionCache$Impl
-org.apache.harmony.xnet.provider.jsse.JSSEProvider
-org.apache.harmony.xnet.provider.jsse.KeyManagerFactoryImpl
-org.apache.harmony.xnet.provider.jsse.KeyManagerImpl
-org.apache.harmony.xnet.provider.jsse.NativeCrypto
-org.apache.harmony.xnet.provider.jsse.NativeCrypto$SSLHandshakeCallbacks
-org.apache.harmony.xnet.provider.jsse.OpenSSLBIOInputStream
-org.apache.harmony.xnet.provider.jsse.OpenSSLCipher
-org.apache.harmony.xnet.provider.jsse.OpenSSLCipher$AES
-org.apache.harmony.xnet.provider.jsse.OpenSSLCipher$AES$CBC
-org.apache.harmony.xnet.provider.jsse.OpenSSLCipher$AES$CBC$NoPadding
-org.apache.harmony.xnet.provider.jsse.OpenSSLCipher$AES$CBC$PKCS5Padding
-org.apache.harmony.xnet.provider.jsse.OpenSSLCipher$AES$CFB
-org.apache.harmony.xnet.provider.jsse.OpenSSLCipher$AES$CFB$NoPadding
-org.apache.harmony.xnet.provider.jsse.OpenSSLCipher$AES$CFB$PKCS5Padding
-org.apache.harmony.xnet.provider.jsse.OpenSSLCipher$AES$CTR
-org.apache.harmony.xnet.provider.jsse.OpenSSLCipher$AES$CTR$NoPadding
-org.apache.harmony.xnet.provider.jsse.OpenSSLCipher$AES$CTR$PKCS5Padding
-org.apache.harmony.xnet.provider.jsse.OpenSSLCipher$AES$ECB
-org.apache.harmony.xnet.provider.jsse.OpenSSLCipher$AES$ECB$NoPadding
-org.apache.harmony.xnet.provider.jsse.OpenSSLCipher$AES$ECB$PKCS5Padding
-org.apache.harmony.xnet.provider.jsse.OpenSSLCipher$AES$OFB
-org.apache.harmony.xnet.provider.jsse.OpenSSLCipher$AES$OFB$NoPadding
-org.apache.harmony.xnet.provider.jsse.OpenSSLCipher$AES$OFB$PKCS5Padding
-org.apache.harmony.xnet.provider.jsse.OpenSSLCipher$ARC4
-org.apache.harmony.xnet.provider.jsse.OpenSSLCipher$DESEDE
-org.apache.harmony.xnet.provider.jsse.OpenSSLCipher$DESEDE$CBC
-org.apache.harmony.xnet.provider.jsse.OpenSSLCipher$DESEDE$CBC$NoPadding
-org.apache.harmony.xnet.provider.jsse.OpenSSLCipher$DESEDE$CBC$PKCS5Padding
-org.apache.harmony.xnet.provider.jsse.OpenSSLCipher$DESEDE$CFB
-org.apache.harmony.xnet.provider.jsse.OpenSSLCipher$DESEDE$CFB$NoPadding
-org.apache.harmony.xnet.provider.jsse.OpenSSLCipher$DESEDE$CFB$PKCS5Padding
-org.apache.harmony.xnet.provider.jsse.OpenSSLCipher$DESEDE$ECB
-org.apache.harmony.xnet.provider.jsse.OpenSSLCipher$DESEDE$ECB$NoPadding
-org.apache.harmony.xnet.provider.jsse.OpenSSLCipher$DESEDE$ECB$PKCS5Padding
-org.apache.harmony.xnet.provider.jsse.OpenSSLCipher$DESEDE$OFB
-org.apache.harmony.xnet.provider.jsse.OpenSSLCipher$DESEDE$OFB$NoPadding
-org.apache.harmony.xnet.provider.jsse.OpenSSLCipher$DESEDE$OFB$PKCS5Padding
-org.apache.harmony.xnet.provider.jsse.OpenSSLCipherRSA
-org.apache.harmony.xnet.provider.jsse.OpenSSLCipherRSA$PKCS1
-org.apache.harmony.xnet.provider.jsse.OpenSSLCipherRSA$Raw
-org.apache.harmony.xnet.provider.jsse.OpenSSLContextImpl
-org.apache.harmony.xnet.provider.jsse.OpenSSLDSAKeyFactory
-org.apache.harmony.xnet.provider.jsse.OpenSSLDSAKeyPairGenerator
-org.apache.harmony.xnet.provider.jsse.OpenSSLECDHKeyAgreement
-org.apache.harmony.xnet.provider.jsse.OpenSSLECKeyFactory
-org.apache.harmony.xnet.provider.jsse.OpenSSLECKeyPairGenerator
-org.apache.harmony.xnet.provider.jsse.OpenSSLKey
-org.apache.harmony.xnet.provider.jsse.OpenSSLKeyHolder
-org.apache.harmony.xnet.provider.jsse.OpenSSLMac
-org.apache.harmony.xnet.provider.jsse.OpenSSLMac$HmacMD5
-org.apache.harmony.xnet.provider.jsse.OpenSSLMac$HmacSHA1
-org.apache.harmony.xnet.provider.jsse.OpenSSLMac$HmacSHA256
-org.apache.harmony.xnet.provider.jsse.OpenSSLMac$HmacSHA384
-org.apache.harmony.xnet.provider.jsse.OpenSSLMac$HmacSHA512
-org.apache.harmony.xnet.provider.jsse.OpenSSLMessageDigestJDK
-org.apache.harmony.xnet.provider.jsse.OpenSSLMessageDigestJDK$MD5
-org.apache.harmony.xnet.provider.jsse.OpenSSLMessageDigestJDK$SHA1
-org.apache.harmony.xnet.provider.jsse.OpenSSLProvider
-org.apache.harmony.xnet.provider.jsse.OpenSSLRSAKeyFactory
-org.apache.harmony.xnet.provider.jsse.OpenSSLRSAKeyPairGenerator
-org.apache.harmony.xnet.provider.jsse.OpenSSLRSAPublicKey
-org.apache.harmony.xnet.provider.jsse.OpenSSLRandom
-org.apache.harmony.xnet.provider.jsse.OpenSSLSessionImpl
-org.apache.harmony.xnet.provider.jsse.OpenSSLSignature
-org.apache.harmony.xnet.provider.jsse.OpenSSLSignature$1
-org.apache.harmony.xnet.provider.jsse.OpenSSLSignature$EngineType
-org.apache.harmony.xnet.provider.jsse.OpenSSLSignature$MD5RSA
-org.apache.harmony.xnet.provider.jsse.OpenSSLSignature$SHA1DSA
-org.apache.harmony.xnet.provider.jsse.OpenSSLSignature$SHA1ECDSA
-org.apache.harmony.xnet.provider.jsse.OpenSSLSignature$SHA1RSA
-org.apache.harmony.xnet.provider.jsse.OpenSSLSignature$SHA256ECDSA
-org.apache.harmony.xnet.provider.jsse.OpenSSLSignature$SHA256RSA
-org.apache.harmony.xnet.provider.jsse.OpenSSLSignature$SHA384ECDSA
-org.apache.harmony.xnet.provider.jsse.OpenSSLSignature$SHA384RSA
-org.apache.harmony.xnet.provider.jsse.OpenSSLSignature$SHA512ECDSA
-org.apache.harmony.xnet.provider.jsse.OpenSSLSignature$SHA512RSA
-org.apache.harmony.xnet.provider.jsse.OpenSSLSignatureRawRSA
-org.apache.harmony.xnet.provider.jsse.OpenSSLSocketFactoryImpl
-org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl
-org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl$SSLInputStream
-org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl$SSLOutputStream
-org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImplWrapper
-org.apache.harmony.xnet.provider.jsse.OpenSSLX509CertPath
-org.apache.harmony.xnet.provider.jsse.OpenSSLX509CertPath$Encoding
-org.apache.harmony.xnet.provider.jsse.OpenSSLX509Certificate
-org.apache.harmony.xnet.provider.jsse.OpenSSLX509CertificateFactory
-org.apache.harmony.xnet.provider.jsse.OpenSSLX509CertificateFactory$1
-org.apache.harmony.xnet.provider.jsse.OpenSSLX509CertificateFactory$2
-org.apache.harmony.xnet.provider.jsse.OpenSSLX509CertificateFactory$Parser
-org.apache.harmony.xnet.provider.jsse.ProtocolVersion
-org.apache.harmony.xnet.provider.jsse.SSLClientSessionCache
-org.apache.harmony.xnet.provider.jsse.SSLContextImpl
-org.apache.harmony.xnet.provider.jsse.SSLParametersImpl
-org.apache.harmony.xnet.provider.jsse.ServerSessionContext
-org.apache.harmony.xnet.provider.jsse.TrustManagerFactoryImpl
-org.apache.harmony.xnet.provider.jsse.TrustManagerImpl
-org.apache.harmony.xnet.provider.jsse.TrustManagerImpl$ExtendedKeyUsagePKIXCertPathChecker
-org.apache.harmony.xnet.provider.jsse.TrustedCertificateIndex
-org.apache.harmony.xnet.provider.jsse.TrustedCertificateKeyStoreSpi
-org.apache.harmony.xnet.provider.jsse.TrustedCertificateStore
-org.apache.harmony.xnet.provider.jsse.TrustedCertificateStore$1
-org.apache.harmony.xnet.provider.jsse.TrustedCertificateStore$2
-org.apache.harmony.xnet.provider.jsse.TrustedCertificateStore$3
-org.apache.harmony.xnet.provider.jsse.TrustedCertificateStore$CertSelector
 org.apache.http.ConnectionReuseStrategy
 org.apache.http.FormattedHeader
 org.apache.http.Header
diff --git a/services/java/com/android/server/InputMethodManagerService.java b/services/java/com/android/server/InputMethodManagerService.java
index 1dd5fc6..c916857 100644
--- a/services/java/com/android/server/InputMethodManagerService.java
+++ b/services/java/com/android/server/InputMethodManagerService.java
@@ -1500,7 +1500,9 @@
                 if (mStatusBar != null) {
                     mStatusBar.setImeWindowStatus(token, vis, backDisposition);
                 }
-                final boolean iconVisibility = (vis & InputMethodService.IME_ACTIVE) != 0;
+                final boolean iconVisibility = ((vis & (InputMethodService.IME_ACTIVE)) != 0)
+                        && (mWindowManagerService.isHardKeyboardAvailable()
+                                || (vis & (InputMethodService.IME_VISIBLE)) != 0);
                 final InputMethodInfo imi = mMethodMap.get(mCurMethodId);
                 if (imi != null && iconVisibility && needsToShowImeSwitchOngoingNotification()) {
                     // Used to load label
diff --git a/services/java/com/android/server/pm/SELinuxMMAC.java b/services/java/com/android/server/pm/SELinuxMMAC.java
index 4bbdb5e..04f43d9 100644
--- a/services/java/com/android/server/pm/SELinuxMMAC.java
+++ b/services/java/com/android/server/pm/SELinuxMMAC.java
@@ -57,7 +57,7 @@
 
     // Locations of potential install policy files.
     private static final File[] INSTALL_POLICY_FILE = {
-        new File(Environment.getDataDirectory(), "system/mac_permissions.xml"),
+        new File(Environment.getDataDirectory(), "security/mac_permissions.xml"),
         new File(Environment.getRootDirectory(), "etc/security/mac_permissions.xml"),
         null};
 
diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java
index bc442ce..de72c26 100644
--- a/services/java/com/android/server/wm/WindowManagerService.java
+++ b/services/java/com/android/server/wm/WindowManagerService.java
@@ -8943,10 +8943,31 @@
                 if (DEBUG_ORIENTATION &&
                         winAnimator.mDrawState == WindowStateAnimator.DRAW_PENDING) Slog.i(
                         TAG, "Resizing " + win + " WITH DRAW PENDING");
-                win.mClient.resized(win.mFrame, win.mLastOverscanInsets, win.mLastContentInsets,
-                        win.mLastVisibleInsets,
-                        winAnimator.mDrawState == WindowStateAnimator.DRAW_PENDING,
-                        configChanged ? win.mConfiguration : null);
+                final IWindow client = win.mClient;
+                final Rect frame = win.mFrame;
+                final Rect overscanInsets = win.mLastOverscanInsets;
+                final Rect contentInsets = win.mLastContentInsets;
+                final Rect visibleInsets = win.mLastVisibleInsets;
+                final boolean reportDraw
+                        = winAnimator.mDrawState == WindowStateAnimator.DRAW_PENDING;
+                final Configuration newConfig = configChanged ? win.mConfiguration : null;
+                if (win.mClient instanceof IWindow.Stub) {
+                    // To prevent deadlock simulate one-way call if win.mClient is a local object.
+                    mH.post(new Runnable() {
+                        @Override
+                        public void run() {
+                            try {
+                                client.resized(frame, overscanInsets, contentInsets,
+                                        visibleInsets, reportDraw, newConfig);
+                            } catch (RemoteException e) {
+                                // Not a remote call, RemoteException won't be raised.
+                            }
+                        }
+                    });
+                } else {
+                   client.resized(frame, overscanInsets, contentInsets, visibleInsets, reportDraw,
+                           newConfig);
+                }
                 win.mOverscanInsetsChanged = false;
                 win.mContentInsetsChanged = false;
                 win.mVisibleInsetsChanged = false;
diff --git a/tests/CoreTests/android/Android.mk b/tests/CoreTests/android/Android.mk
index 5abfc88..bc0e4e4 100644
--- a/tests/CoreTests/android/Android.mk
+++ b/tests/CoreTests/android/Android.mk
@@ -6,7 +6,7 @@
 LOCAL_SRC_FILES := \
 	$(call all-subdir-java-files)
 
-LOCAL_JAVA_LIBRARIES := android.test.runner bouncycastle
+LOCAL_JAVA_LIBRARIES := android.test.runner bouncycastle conscrypt
 
 LOCAL_PACKAGE_NAME := CoreTests
 
diff --git a/tests/CoreTests/android/core/SSLSocketTest.java b/tests/CoreTests/android/core/SSLSocketTest.java
index 03905e1..b06790b 100644
--- a/tests/CoreTests/android/core/SSLSocketTest.java
+++ b/tests/CoreTests/android/core/SSLSocketTest.java
@@ -18,10 +18,10 @@
 
 import junit.framework.TestCase;
 
+import com.android.org.conscrypt.FileClientSessionCache;
+import com.android.org.conscrypt.OpenSSLContextImpl;
+import com.android.org.conscrypt.SSLClientSessionCache;
 import org.apache.commons.codec.binary.Base64;
-import org.apache.harmony.xnet.provider.jsse.FileClientSessionCache;
-import org.apache.harmony.xnet.provider.jsse.OpenSSLContextImpl;
-import org.apache.harmony.xnet.provider.jsse.SSLClientSessionCache;
 
 import java.io.ByteArrayInputStream;
 import java.io.DataInputStream;
diff --git a/tools/aapt/Main.cpp b/tools/aapt/Main.cpp
index 32fecb2..977226b 100644
--- a/tools/aapt/Main.cpp
+++ b/tools/aapt/Main.cpp
@@ -48,6 +48,7 @@
         "   List contents of Zip-compatible archive.\n\n", gProgName);
     fprintf(stderr,
         " %s d[ump] [--values] WHAT file.{apk} [asset [asset ...]]\n"
+        "   strings          Print the contents of the resource table string pool in the APK.\n"
         "   badging          Print the label and icon for the app declared in APK.\n"
         "   permissions      Print the permissions from the APK.\n"
         "   resources        Print the resource table from the APK.\n"
diff --git a/wifi/java/android/net/wifi/SupplicantStateTracker.java b/wifi/java/android/net/wifi/SupplicantStateTracker.java
index f7fc795..f6a621f 100644
--- a/wifi/java/android/net/wifi/SupplicantStateTracker.java
+++ b/wifi/java/android/net/wifi/SupplicantStateTracker.java
@@ -45,6 +45,7 @@
     private WifiStateMachine mWifiStateMachine;
     private WifiConfigStore mWifiConfigStore;
     private int mAuthenticationFailuresCount = 0;
+    private int mAssociationRejectCount = 0;
     /* Indicates authentication failure in supplicant broadcast.
      * TODO: enhance auth failure reporting to include notification
      * for all type of failures: EAP, WPS & WPA networks */
@@ -53,6 +54,9 @@
     /* Maximum retries on a authentication failure notification */
     private static final int MAX_RETRIES_ON_AUTHENTICATION_FAILURE = 2;
 
+    /* Maximum retries on assoc rejection events */
+    private static final int MAX_RETRIES_ON_ASSOCIATION_REJECT = 4;
+
     /* Tracks if networks have been disabled during a connection */
     private boolean mNetworksDisabledDuringConnect = false;
 
@@ -89,14 +93,14 @@
         start();
     }
 
-    private void handleNetworkConnectionFailure(int netId) {
+    private void handleNetworkConnectionFailure(int netId, int disableReason) {
         /* If other networks disabled during connection, enable them */
         if (mNetworksDisabledDuringConnect) {
             mWifiConfigStore.enableAllNetworks();
             mNetworksDisabledDuringConnect = false;
         }
         /* Disable failed network */
-        mWifiConfigStore.disableNetwork(netId, WifiConfiguration.DISABLED_AUTH_FAILURE);
+        mWifiConfigStore.disableNetwork(netId, disableReason);
     }
 
     private void transitionOnSupplicantStateChange(StateChangeResult stateChangeResult) {
@@ -182,6 +186,10 @@
                     break;
                 case WifiManager.CONNECT_NETWORK:
                     mNetworksDisabledDuringConnect = true;
+                    mAssociationRejectCount = 0;
+                    break;
+                case WifiMonitor.ASSOCIATION_REJECTION_EVENT:
+                    mAssociationRejectCount++;
                     break;
                 default:
                     Log.e(TAG, "Ignoring " + message);
@@ -226,9 +234,17 @@
              if (mAuthenticationFailuresCount >= MAX_RETRIES_ON_AUTHENTICATION_FAILURE) {
                  Log.d(TAG, "Failed to authenticate, disabling network " +
                          stateChangeResult.networkId);
-                 handleNetworkConnectionFailure(stateChangeResult.networkId);
+                 handleNetworkConnectionFailure(stateChangeResult.networkId,
+                         WifiConfiguration.DISABLED_AUTH_FAILURE);
                  mAuthenticationFailuresCount = 0;
              }
+             else if (mAssociationRejectCount >= MAX_RETRIES_ON_ASSOCIATION_REJECT) {
+                 Log.d(TAG, "Association getting rejected, disabling network " +
+                         stateChangeResult.networkId);
+                 handleNetworkConnectionFailure(stateChangeResult.networkId,
+                         WifiConfiguration.DISABLED_ASSOCIATION_REJECT);
+                 mAssociationRejectCount = 0;
+            }
          }
     }
 
@@ -268,7 +284,8 @@
                         if (mLoopDetectCount > MAX_SUPPLICANT_LOOP_ITERATIONS) {
                             Log.d(TAG, "Supplicant loop detected, disabling network " +
                                     stateChangeResult.networkId);
-                            handleNetworkConnectionFailure(stateChangeResult.networkId);
+                            handleNetworkConnectionFailure(stateChangeResult.networkId,
+                                    WifiConfiguration.DISABLED_AUTH_FAILURE);
                         }
                         mLoopDetectIndex = state.ordinal();
                         sendSupplicantStateChangedBroadcast(state,
@@ -291,6 +308,7 @@
              if (DBG) Log.d(TAG, getName() + "\n");
              /* Reset authentication failure count */
              mAuthenticationFailuresCount = 0;
+             mAssociationRejectCount = 0;
              if (mNetworksDisabledDuringConnect) {
                  mWifiConfigStore.enableAllNetworks();
                  mNetworksDisabledDuringConnect = false;
diff --git a/wifi/java/android/net/wifi/WifiConfiguration.java b/wifi/java/android/net/wifi/WifiConfiguration.java
index b971fc33..bd8f0eb 100644
--- a/wifi/java/android/net/wifi/WifiConfiguration.java
+++ b/wifi/java/android/net/wifi/WifiConfiguration.java
@@ -173,6 +173,8 @@
     public static final int DISABLED_DHCP_FAILURE                           = 2;
     /** @hide */
     public static final int DISABLED_AUTH_FAILURE                           = 3;
+    /** @hide */
+    public static final int DISABLED_ASSOCIATION_REJECT                     = 4;
 
     /**
      * The ID number that the supplicant uses to identify this
diff --git a/wifi/java/android/net/wifi/WifiEnterpriseConfig.java b/wifi/java/android/net/wifi/WifiEnterpriseConfig.java
index 6e3034b..4bee937 100644
--- a/wifi/java/android/net/wifi/WifiEnterpriseConfig.java
+++ b/wifi/java/android/net/wifi/WifiEnterpriseConfig.java
@@ -85,6 +85,7 @@
     private static final String ENGINE_KEY          = "engine";
     private static final String ENGINE_ID_KEY       = "engine_id";
     private static final String PRIVATE_KEY_ID_KEY  = "key_id";
+    private static final String OPP_KEY_CACHING     = "proactive_key_caching";
 
     private HashMap<String, String> mFields = new HashMap<String, String>();
     private X509Certificate mCaCert;
@@ -273,6 +274,7 @@
             case Eap.TLS:
             case Eap.TTLS:
                 mFields.put(EAP_KEY, Eap.strings[eapMethod]);
+                mFields.put(OPP_KEY_CACHING, "1");
                 break;
             default:
                 throw new IllegalArgumentException("Unknown EAP method");
diff --git a/wifi/java/android/net/wifi/WifiMonitor.java b/wifi/java/android/net/wifi/WifiMonitor.java
index 0b0d7388e..fe3c709 100644
--- a/wifi/java/android/net/wifi/WifiMonitor.java
+++ b/wifi/java/android/net/wifi/WifiMonitor.java
@@ -56,7 +56,8 @@
     private static final int TERMINATING  = 6;
     private static final int DRIVER_STATE = 7;
     private static final int EAP_FAILURE  = 8;
-    private static final int UNKNOWN      = 9;
+    private static final int ASSOC_REJECT = 9;
+    private static final int UNKNOWN      = 10;
 
     /** All events coming from the supplicant start with this prefix */
     private static final String EVENT_PREFIX_STR = "CTRL-EVENT-";
@@ -153,6 +154,11 @@
     private static final String EAP_AUTH_FAILURE_STR = "EAP authentication failed";
 
     /**
+     * This indicates an assoc reject event
+     */
+    private static final String ASSOC_REJECT_STR = "ASSOC-REJECT";
+
+    /**
      * Regex pattern for extracting an Ethernet-style MAC address from a string.
      * Matches a strings like the following:<pre>
      * CTRL-EVENT-CONNECTED - Connection to 00:1e:58:ec:d5:6d completed (reauth) [id=1 id_str=]</pre>
@@ -328,6 +334,8 @@
     public static final int AP_STA_DISCONNECTED_EVENT            = BASE + 41;
     public static final int AP_STA_CONNECTED_EVENT               = BASE + 42;
 
+    /* Indicates assoc reject event */
+    public static final int ASSOCIATION_REJECTION_EVENT          = BASE + 43;
     /**
      * This indicates the supplicant connection for the monitor is closed
      */
@@ -429,6 +437,8 @@
                     event = DRIVER_STATE;
                 else if (eventName.equals(EAP_FAILURE_STR))
                     event = EAP_FAILURE;
+                else if (eventName.equals(ASSOC_REJECT_STR))
+                    event = ASSOC_REJECT;
                 else
                     event = UNKNOWN;
 
@@ -473,6 +483,8 @@
                     if (eventData.startsWith(EAP_AUTH_FAILURE_STR)) {
                         mStateMachine.sendMessage(AUTHENTICATION_FAILURE_EVENT);
                     }
+                } else if (event == ASSOC_REJECT) {
+                        mStateMachine.sendMessage(ASSOCIATION_REJECTION_EVENT);
                 } else {
                     handleEvent(event, eventData);
                 }
diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java
index 9cae2cb..81efd1c 100644
--- a/wifi/java/android/net/wifi/WifiStateMachine.java
+++ b/wifi/java/android/net/wifi/WifiStateMachine.java
@@ -1915,6 +1915,7 @@
                 case WifiMonitor.SCAN_RESULTS_EVENT:
                 case WifiMonitor.SUPPLICANT_STATE_CHANGE_EVENT:
                 case WifiMonitor.AUTHENTICATION_FAILURE_EVENT:
+                case WifiMonitor.ASSOCIATION_REJECTION_EVENT:
                 case WifiMonitor.WPS_OVERLAP_EVENT:
                 case CMD_BLACKLIST_NETWORK:
                 case CMD_CLEAR_BLACKLIST:
@@ -2332,6 +2333,7 @@
                 case WifiMonitor.NETWORK_CONNECTION_EVENT:
                 case WifiMonitor.NETWORK_DISCONNECTION_EVENT:
                 case WifiMonitor.AUTHENTICATION_FAILURE_EVENT:
+                case WifiMonitor.ASSOCIATION_REJECTION_EVENT:
                 case WifiMonitor.WPS_OVERLAP_EVENT:
                 case CMD_SET_COUNTRY_CODE:
                 case CMD_SET_FREQUENCY_BAND:
@@ -2697,6 +2699,9 @@
             WifiConfiguration config;
             boolean ok;
             switch(message.what) {
+                case WifiMonitor.ASSOCIATION_REJECTION_EVENT:
+                    mSupplicantStateTracker.sendMessage(WifiMonitor.ASSOCIATION_REJECTION_EVENT);
+                    break;
                 case WifiMonitor.AUTHENTICATION_FAILURE_EVENT:
                     mSupplicantStateTracker.sendMessage(WifiMonitor.AUTHENTICATION_FAILURE_EVENT);
                     break;
@@ -3426,6 +3431,9 @@
                     if (DBG) log("Network connection lost");
                     handleNetworkDisconnect();
                     break;
+                case WifiMonitor.ASSOCIATION_REJECTION_EVENT:
+                    if (DBG) log("Ignore Assoc reject event during WPS Connection");
+                    break;
                 case WifiMonitor.AUTHENTICATION_FAILURE_EVENT:
                     // Disregard auth failure events during WPS connection. The
                     // EAP sequence is retried several times, and there might be