Merge "Backward-compatibility max file size support, ignoring 0 or negative file size limit"
diff --git a/api/current.xml b/api/current.xml
index cb08b20..9ab1dd0 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -166304,6 +166304,92 @@
 >
 </field>
 </class>
+<class name="RecognizerResultsIntent"
+ extends="java.lang.Object"
+ abstract="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<field name="ACTION_VOICE_SEARCH_RESULTS"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;android.speech.action.VOICE_SEARCH_RESULTS&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="EXTRA_VOICE_SEARCH_RESULT_HTML"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;android.speech.extras.VOICE_SEARCH_RESULT_HTML&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="EXTRA_VOICE_SEARCH_RESULT_HTML_BASE_URLS"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;android.speech.extras.VOICE_SEARCH_RESULT_HTML_BASE_URLS&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="EXTRA_VOICE_SEARCH_RESULT_HTTP_HEADERS"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;android.speech.extras.EXTRA_VOICE_SEARCH_RESULT_HTTP_HEADERS&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="EXTRA_VOICE_SEARCH_RESULT_STRINGS"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;android.speech.extras.VOICE_SEARCH_RESULT_STRINGS&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="EXTRA_VOICE_SEARCH_RESULT_URLS"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;android.speech.extras.VOICE_SEARCH_RESULT_URLS&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="URI_SCHEME_INLINE"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;inline&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+</class>
 <class name="SpeechRecognizer"
  extends="java.lang.Object"
  abstract="false"
@@ -251289,7 +251375,7 @@
  deprecated="not deprecated"
  visibility="public"
 >
-<parameter name="arg0" type="T">
+<parameter name="t" type="T">
 </parameter>
 </method>
 </interface>
diff --git a/core/java/android/nfc/technology/MifareClassic.java b/core/java/android/nfc/technology/MifareClassic.java
index d5f0a31..8a9ebf1 100644
--- a/core/java/android/nfc/technology/MifareClassic.java
+++ b/core/java/android/nfc/technology/MifareClassic.java
@@ -161,7 +161,9 @@
                 mSize = SIZE_4K;
                 break;
             default:
-                // Unknown, not MIFARE
+                // Unknown mifare
+                mType = TYPE_UNKNOWN;
+                mSize = SIZE_UNKNOWN;
                 break;
         }
     }
@@ -226,9 +228,10 @@
 
     // Methods that require connect()
     /**
-     * Authenticate for a given sector.
+     * Authenticate for a given block.
+     * Note that this will authenticate the entire sector the block belongs to.
      */
-    public boolean authenticateSector(int sector, byte[] key, boolean keyA) {
+    public boolean authenticateBlock(int block, byte[] key, boolean keyA) {
         checkConnected();
 
         byte[] cmd = new byte[12];
@@ -241,7 +244,7 @@
         }
 
         // Second byte is block address
-        cmd[1] = firstBlockInSector(sector);
+        cmd[1] = (byte) block;
 
         // Next 4 bytes are last 4 bytes of UID
         byte[] uid = getTag().getId();
@@ -261,6 +264,19 @@
     }
 
     /**
+     * Authenticate for a given sector.
+     */
+    public boolean authenticateSector(int sector, byte[] key, boolean keyA) {
+        checkConnected();
+
+        byte addr = (byte) ((firstBlockInSector(sector)) & 0xff);
+
+        // Note that authenticating a block of a sector, will authenticate
+        // the entire sector.
+        return authenticateBlock(addr, key, keyA);
+    }
+
+    /**
      * Sector indexing starts at 0.
      * Block indexing starts at 0, and resets in each sector.
      * @throws IOException
@@ -269,28 +285,69 @@
         checkConnected();
 
         byte addr = (byte) ((firstBlockInSector(sector) + block) & 0xff);
-        byte[] blockread_cmd = { 0x30, addr }; // phHal_eMifareRead
+        return readBlock(addr);
 
-        // TODO deal with authentication problems
+    }
+
+    /**
+     * Reads absolute block index.
+     * @throws IOException
+     */
+    public byte[] readBlock(int block) throws IOException {
+        checkConnected();
+
+        byte addr = (byte) block;
+        byte[] blockread_cmd = { 0x30, addr };
+
         return transceive(blockread_cmd);
     }
 
-//    public byte[] readSector(int sector);
-    //TODO: define an enumeration for access control settings
-//    public int readSectorAccessControl(int sector);
+    /**
+     * Writes absolute block index.
+     * @throws IOException
+     */
+    public void writeBlock(int block, byte[] data) throws IOException {
+        checkConnected();
+
+        byte addr = (byte) block;
+        byte[] blockwrite_cmd = new byte[data.length + 2];
+        blockwrite_cmd[0] = (byte) 0xA0; // MF write command
+        blockwrite_cmd[1] = addr;
+        System.arraycopy(data, 0, blockwrite_cmd, 2, data.length);
+
+        transceive(blockwrite_cmd);
+    }
 
     /**
+     * Writes relative block in sector.
      * @throws IOException
-     * @throws NotAuthenticatedException
      */
-/*
-    public void writeBlock(int block, byte[] data);
-    public void writeSector(int block, byte[] sector);
-    public void writeSectorAccessControl(int sector, int access);
-    public void increment(int block);
-    public void decrement(int block);
+    public void writeBlock(int sector, int block, byte[] data) throws IOException {
+        checkConnected();
 
-*/
+        byte addr = (byte) ((firstBlockInSector(sector) + block) & 0xff);
+
+        writeBlock(addr, data);
+    }
+
+    public void increment(int block) throws IOException {
+        checkConnected();
+
+        byte addr = (byte) block;
+        byte[] incr_cmd = { (byte) 0xC1, (byte) block };
+
+        transceive(incr_cmd);
+    }
+
+    public void decrement(int block) throws IOException {
+        checkConnected();
+
+        byte addr = (byte) block;
+        byte[] incr_cmd = { (byte) 0xC0, (byte) block };
+
+        transceive(incr_cmd);
+    }
+
     /**
      * Send data to a tag and receive the response.
      * <p>
diff --git a/core/java/android/nfc/technology/Ndef.java b/core/java/android/nfc/technology/Ndef.java
index c45c97d..cd12249 100644
--- a/core/java/android/nfc/technology/Ndef.java
+++ b/core/java/android/nfc/technology/Ndef.java
@@ -148,17 +148,23 @@
         checkConnected();
 
         try {
-            int errorCode = mTagService.ndefWrite(mTag.getServiceHandle(), msg);
-            switch (errorCode) {
-                case ErrorCodes.SUCCESS:
-                    break;
-                case ErrorCodes.ERROR_IO:
-                    throw new IOException();
-                case ErrorCodes.ERROR_INVALID_PARAM:
-                    throw new FormatException();
-                default:
-                    // Should not happen
-                    throw new IOException();
+            int serviceHandle = mTag.getServiceHandle();
+            if (mTagService.isNdef(serviceHandle)) {
+                int errorCode = mTagService.ndefWrite(serviceHandle, msg);
+                switch (errorCode) {
+                    case ErrorCodes.SUCCESS:
+                        break;
+                    case ErrorCodes.ERROR_IO:
+                        throw new IOException();
+                    case ErrorCodes.ERROR_INVALID_PARAM:
+                        throw new FormatException();
+                    default:
+                        // Should not happen
+                        throw new IOException();
+                }
+            }
+            else {
+                throw new IOException("Tag is not ndef");
             }
         } catch (RemoteException e) {
             attemptDeadServiceRecovery(e);
diff --git a/core/java/android/os/IBinder.java b/core/java/android/os/IBinder.java
index 174f3b6..8ae8008 100644
--- a/core/java/android/os/IBinder.java
+++ b/core/java/android/os/IBinder.java
@@ -162,7 +162,7 @@
      * @param code The action to perform.  This should
      * be a number between {@link #FIRST_CALL_TRANSACTION} and
      * {@link #LAST_CALL_TRANSACTION}.
-     * @param data Marshalled data to send to the target.  Most not be null.
+     * @param data Marshalled data to send to the target.  Must not be null.
      * If you are not sending any data, you must create an empty Parcel
      * that is given here.
      * @param reply Marshalled data to be received from the target.  May be
diff --git a/core/java/android/speech/RecognizerResultsIntent.java b/core/java/android/speech/RecognizerResultsIntent.java
index b45e4b1..15ac57c 100644
--- a/core/java/android/speech/RecognizerResultsIntent.java
+++ b/core/java/android/speech/RecognizerResultsIntent.java
@@ -34,8 +34,6 @@
  * the search results. If that is not available, then the corresponding url for that result in
  * {@link #EXTRA_VOICE_SEARCH_RESULT_URLS} should be used. And if even that is not available,
  * then a search url should be constructed from the actual recognition result string.
- * 
- * @hide for making public in a later release
  */
 public class RecognizerResultsIntent {
     private RecognizerResultsIntent() {
@@ -58,8 +56,6 @@
      * and, possibly, the full html to display for that result at index N of
      * {@link #EXTRA_VOICE_SEARCH_RESULT_HTML}. If full html is provided, a base url (or
      * list of base urls) should be provided with {@link #EXTRA_VOICE_SEARCH_RESULT_HTML_BASE_URLS}.
-     * 
-     * @hide for making public in a later release
      */
     public static final String ACTION_VOICE_SEARCH_RESULTS =
             "android.speech.action.VOICE_SEARCH_RESULTS";
@@ -67,8 +63,6 @@
     /**
      * The key to an extra {@link ArrayList} of {@link String}s that contains the list of
      * recognition alternates from voice search, in order from highest to lowest confidence.
-     * 
-     * @hide for making public in a later release
      */
     public static final String EXTRA_VOICE_SEARCH_RESULT_STRINGS =
             "android.speech.extras.VOICE_SEARCH_RESULT_STRINGS";
@@ -81,8 +75,6 @@
      * search url, that entry in this ArrayList should be <code>null</code>, and the implementor of
      * {@link #ACTION_VOICE_SEARCH_RESULTS} should execute a search of its own choosing,
      * based on the recognition result string.
-     * 
-     * @hide for making public in a later release
      */
     public static final String EXTRA_VOICE_SEARCH_RESULT_URLS =
             "android.speech.extras.VOICE_SEARCH_RESULT_URLS";
@@ -102,8 +94,6 @@
      * uri or some other identifier. Anyone who reads this extra should confirm that a result is
      * in fact an "inline:" uri and back off to the urls or strings gracefully if it is not, thus
      * maintaining future backwards compatibility if this changes.
-     * 
-     * @hide not to be exposed immediately as the implementation details may change
      */
     public static final String EXTRA_VOICE_SEARCH_RESULT_HTML =
             "android.speech.extras.VOICE_SEARCH_RESULT_HTML";
@@ -116,8 +106,6 @@
      * A list of the same size as {@link #EXTRA_VOICE_SEARCH_RESULT_STRINGS} may be provided
      * to apply different base urls to each different html result in the
      * {@link #EXTRA_VOICE_SEARCH_RESULT_HTML} list.
-     * 
-     * @hide not to be exposed immediately as the implementation details may change
      */
     public static final String EXTRA_VOICE_SEARCH_RESULT_HTML_BASE_URLS =
             "android.speech.extras.VOICE_SEARCH_RESULT_HTML_BASE_URLS";
@@ -132,16 +120,14 @@
      * apply different HTTP headers to each different web result in the list. These headers will
      * only be used in the case that the url for a particular web result (from
      * {@link #EXTRA_VOICE_SEARCH_RESULT_URLS}) is loaded.
-     *
-     * @hide not to be exposed immediately as the implementation details may change
      */
     public static final String EXTRA_VOICE_SEARCH_RESULT_HTTP_HEADERS =
             "android.speech.extras.EXTRA_VOICE_SEARCH_RESULT_HTTP_HEADERS";
 
     /**
      * The scheme used currently for html content in {@link #EXTRA_VOICE_SEARCH_RESULT_HTML}.
-     * 
-     * @hide not to be exposed immediately as the implementation details may change
+     * Note that this should only be used in tandem with this particular extra; it should
+     * NOT be used for generic URIs such as those found in the data field of an Intent.
      */
     public static final String URI_SCHEME_INLINE = "inline";
 }
diff --git a/core/java/android/view/Surface.java b/core/java/android/view/Surface.java
index b8d72a6..e203355 100644
--- a/core/java/android/view/Surface.java
+++ b/core/java/android/view/Surface.java
@@ -24,7 +24,7 @@
 import android.util.Log;
 
 /**
- * Handle on to a raw buffer that is being managed by the screen compositor.
+ * Handle onto a raw buffer that is being managed by the screen compositor.
  */
 public class Surface implements Parcelable {
     private static final String LOG_TAG = "Surface";
@@ -41,7 +41,7 @@
     @Deprecated
     public static final int HARDWARE            = 0x00000010;
 
-    /** Implies "HARDWARE", the surface is to be used by the GPU
+    /** Implies "HARDWARE", the surface is to be used by the GPU;
      * additionally the backbuffer is never preserved for these
      * surfaces. 
      * @deprecated this is ignored, this value is set automatically when needed.
@@ -81,9 +81,9 @@
     
     /**
      * Creates a surface without a rendering buffer. Instead, the content
-     * of the surface must be pushed by an external entity. This is type
+     * of the surface must be pushed by an external entity. This type
      * of surface can be used for efficient camera preview or movie
-     * play back.
+     * playback.
      *
      * @deprecated not support by the system anymore
      */
@@ -99,7 +99,7 @@
      */
     public static final int OPAQUE              = 0x00000400;
     
-    /** Creates a normal surface. This is the default */
+    /** Creates a normal surface. This is the default. */
     public static final int FX_SURFACE_NORMAL   = 0x00000000;
     
     /** Creates a Blur surface. Everything behind this surface is blurred
@@ -111,7 +111,7 @@
     public static final int FX_SURFACE_BLUR     = 0x00010000;
     
     /** Creates a Dim surface. Everything behind this surface is dimmed
-     * by the amount specified in setAlpha(). 
+     * by the amount specified in {@link #setAlpha}.
      * It is an error to lock a Dim surface, since it doesn't have
      * a backing store.
      */
@@ -122,14 +122,14 @@
 
     /* flags used with setFlags() (keep in sync with ISurfaceComposer.h) */
     
-    /** Hide the surface. Equivalent to calling hide() */
+    /** Hide the surface. Equivalent to calling hide(). */
     public static final int SURFACE_HIDDEN    = 0x01;
     
-    /** Freeze the surface. Equivalent to calling freeze() */ 
+    /** Freeze the surface. Equivalent to calling freeze(). */
     public static final int SURFACE_FROZEN     = 0x02;
 
     /**
-     * @deprecated use {@link #SURFACE_FROZEN} instead.
+     * @deprecated Use {@link #SURFACE_FROZEN} instead.
      */
     @Deprecated
     public static final int SURACE_FROZEN     = 0x02;
@@ -241,7 +241,7 @@
      *  like obtained from getMatrix. This is a hack to handle the case that an application
      *  uses getMatrix to keep the original matrix, set matrix of its own, then set the original
      *  matrix back. There is no perfect solution that works for all cases, and there are a lot of
-     *  cases that this model dose not work, but we hope this works for many apps.
+     *  cases that this model does not work, but we hope this works for many apps.
      * </ul>
      */
     private class CompatibleCanvas extends Canvas {
@@ -284,7 +284,7 @@
     }
 
     /**
-     * Sets the display metrics used to provide canva's width/height in compatibility mode.
+     * Sets the display metrics used to provide canvas's width/height in compatibility mode.
      */
     void setCompatibleDisplayMetrics(DisplayMetrics metrics, Translator translator) {
         mCompatibleDisplayMetrics = metrics;
diff --git a/core/java/android/view/SurfaceHolder.java b/core/java/android/view/SurfaceHolder.java
index 1b242b3..2a16725 100644
--- a/core/java/android/view/SurfaceHolder.java
+++ b/core/java/android/view/SurfaceHolder.java
@@ -25,9 +25,10 @@
  * monitor changes to the surface.  This interface is typically available
  * through the {@link SurfaceView} class.
  * 
- * <p>When using this interface from a thread different than the one running
+ * <p>When using this interface from a thread other than the one running
  * its {@link SurfaceView}, you will want to carefully read the
- * {@link #lockCanvas} and {@link Callback#surfaceCreated Callback.surfaceCreated}.
+ * methods
+ * {@link #lockCanvas} and {@link Callback#surfaceCreated Callback.surfaceCreated()}.
  */
 public interface SurfaceHolder {
 
@@ -46,7 +47,7 @@
 
     /**
      * Exception that is thrown from {@link #lockCanvas} when called on a Surface
-     * whose is SURFACE_TYPE_PUSH_BUFFERS.
+     * whose type is SURFACE_TYPE_PUSH_BUFFERS.
      */
     public static class BadSurfaceTypeException extends RuntimeException {
         public BadSurfaceTypeException() {
@@ -62,7 +63,7 @@
      * changes to the surface.  When used with a {@link SurfaceView}, the
      * Surface being held is only available between calls to
      * {@link #surfaceCreated(SurfaceHolder)} and
-     * {@link #surfaceDestroyed(SurfaceHolder).  The Callback is set with
+     * {@link #surfaceDestroyed(SurfaceHolder)}.  The Callback is set with
      * {@link SurfaceHolder#addCallback SurfaceHolder.addCallback} method.
      */
     public interface Callback {
@@ -110,7 +111,7 @@
         /**
          * Called when the application needs to redraw the content of its
          * surface, after it is resized or for some other reason.  By not
-         * returning here until the redraw is complete, you can ensure that
+         * returning from here until the redraw is complete, you can ensure that
          * the user will not see your surface in a bad state (at its new
          * size before it has been correctly drawn that way).  This will
          * typically be preceeded by a call to {@link #surfaceChanged}.
@@ -122,7 +123,7 @@
 
     /**
      * Add a Callback interface for this holder.  There can several Callback
-     * interfaces associated to a holder.
+     * interfaces associated with a holder.
      * 
      * @param callback The new Callback interface.
      */
@@ -187,7 +188,7 @@
      * surface is displayed.  The default is false, allowing it to turn off.
      * This is safe to call from any thread.
      * 
-     * @param screenOn Supply to true to force the screen to stay on, false
+     * @param screenOn Set to true to force the screen to stay on, false
      * to allow it to turn off.
      */
     public void setKeepScreenOn(boolean screenOn);
@@ -195,14 +196,14 @@
     /**
      * Start editing the pixels in the surface.  The returned Canvas can be used
      * to draw into the surface's bitmap.  A null is returned if the surface has
-     * not been created or otherwise can not be edited.  You will usually need
+     * not been created or otherwise cannot be edited.  You will usually need
      * to implement {@link Callback#surfaceCreated Callback.surfaceCreated}
      * to find out when the Surface is available for use.
      * 
      * <p>The content of the Surface is never preserved between unlockCanvas() and
      * lockCanvas(), for this reason, every pixel within the Surface area
      * must be written. The only exception to this rule is when a dirty
-     * rectangle is specified, in which case, non dirty pixels will be
+     * rectangle is specified, in which case, non-dirty pixels will be
      * preserved.
      * 
      * <p>If you call this repeatedly when the Surface is not ready (before
@@ -213,7 +214,7 @@
      * <p>If null is not returned, this function internally holds a lock until
      * the corresponding {@link #unlockCanvasAndPost} call, preventing
      * {@link SurfaceView} from creating, destroying, or modifying the surface
-     * while it is being drawn.  This can be more convenience than accessing
+     * while it is being drawn.  This can be more convenient than accessing
      * the Surface directly, as you do not need to do special synchronization
      * with a drawing thread in {@link Callback#surfaceDestroyed
      * Callback.surfaceDestroyed}.
@@ -224,7 +225,7 @@
 
     
     /**
-     * Just like {@link #lockCanvas()} but allows to specify a dirty rectangle.
+     * Just like {@link #lockCanvas()} but allows specification of a dirty rectangle.
      * Every
      * pixel within that rectangle must be written; however pixels outside
      * the dirty rectangle will be preserved by the next call to lockCanvas().
diff --git a/core/java/android/view/SurfaceView.java b/core/java/android/view/SurfaceView.java
index 7021604..6451d47 100644
--- a/core/java/android/view/SurfaceView.java
+++ b/core/java/android/view/SurfaceView.java
@@ -65,7 +65,7 @@
  * Surface is created and destroyed as the window is shown and hidden.
  * 
  * <p>One of the purposes of this class is to provide a surface in which a
- * secondary thread can render in to the screen.  If you are going to use it
+ * secondary thread can render into the screen.  If you are going to use it
  * this way, you need to be aware of some threading semantics:
  * 
  * <ul>
diff --git a/core/java/android/webkit/JWebCoreJavaBridge.java b/core/java/android/webkit/JWebCoreJavaBridge.java
index 908526f..976e786 100644
--- a/core/java/android/webkit/JWebCoreJavaBridge.java
+++ b/core/java/android/webkit/JWebCoreJavaBridge.java
@@ -307,4 +307,5 @@
     public native void addPackageNames(Set<String> packageNames);
     public native void addPackageName(String packageName);
     public native void removePackageName(String packageName);
+    public native void updateProxy(String newProxy);
 }
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index 885bada..9718443 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -48,6 +48,8 @@
 import android.graphics.Region;
 import android.graphics.Shader;
 import android.graphics.drawable.Drawable;
+import android.net.Proxy;
+import android.net.ProxyProperties;
 import android.net.Uri;
 import android.net.http.SslCertificate;
 import android.os.AsyncTask;
@@ -981,6 +983,7 @@
          */
         init();
         setupPackageListener(context);
+        setupProxyListener(context);
         updateMultiTouchSupport(context);
 
         if (privateBrowsing) {
@@ -990,6 +993,42 @@
         mAutoFillData = new WebViewCore.AutoFillData();
     }
 
+    private static class ProxyReceiver extends BroadcastReceiver {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            if (intent.getAction().equals(Proxy.PROXY_CHANGE_ACTION)) {
+                handleProxyBroadcast(intent);
+            }
+        }
+    }
+
+    private static void setupProxyListener(Context context) {
+        IntentFilter filter = new IntentFilter();
+        filter.addAction(Proxy.PROXY_CHANGE_ACTION);
+        Intent currentProxy = context.registerReceiver(new ProxyReceiver(), filter);
+        if (currentProxy != null) {
+            handleProxyBroadcast(currentProxy);
+        }
+    }
+
+    private static void handleProxyBroadcast(Intent intent) {
+        ProxyProperties proxyProperties = (ProxyProperties)intent.getExtra(Proxy.EXTRA_PROXY_INFO);
+        if (proxyProperties == null) {
+            WebViewCore.sendStaticMessage(EventHub.PROXY_CHANGED, "");
+            return;
+        }
+
+        String host = proxyProperties.getHost();
+        int port = proxyProperties.getPort();
+        host += ": " + port;
+
+        // TODO: Handle exclusion list
+        // The plan is to make an AndroidProxyResolver, and handle the blacklist
+        // there
+        String exclusionList = proxyProperties.getExclusionList();
+        WebViewCore.sendStaticMessage(EventHub.PROXY_CHANGED, host);
+    }
+
     /*
      * A variable to track if there is a receiver added for ACTION_PACKAGE_ADDED
      * or ACTION_PACKAGE_REMOVED.
diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java
index f45fad9..45927f9 100644
--- a/core/java/android/webkit/WebViewCore.java
+++ b/core/java/android/webkit/WebViewCore.java
@@ -684,6 +684,14 @@
                                 }
                                 BrowserFrame.sJavaBridge.removePackageName((String) msg.obj);
                                 break;
+
+                            case EventHub.PROXY_CHANGED:
+                                if (BrowserFrame.sJavaBridge == null) {
+                                    throw new IllegalStateException(
+                                            "No WebView has been created in this process!");
+                                }
+                                BrowserFrame.sJavaBridge.updateProxy((String) msg.obj);
+                                break;
                         }
                     }
                 };
@@ -983,6 +991,8 @@
 
         static final int AUTOFILL_FORM = 192;
 
+        static final int PROXY_CHANGED = 193;
+
         // private message ids
         private static final int DESTROY =     200;
 
diff --git a/docs/html/guide/topics/media/index.jd b/docs/html/guide/topics/media/index.jd
index 8e18754..e355212 100644
--- a/docs/html/guide/topics/media/index.jd
+++ b/docs/html/guide/topics/media/index.jd
@@ -115,9 +115,8 @@
 <p>{@link android.media.MediaPlayer#stop() stop()} and 
 {@link android.media.MediaPlayer#pause() pause()} work the same as discussed
 above.</p>
-  <p class="note"><strong>Note:</strong> It is possible that <code>mp</code> could be
-  null, so good code should <code>null</code> check after the <code>new</code>.
-  Also, <code>IllegalArgumentException</code> and <code>IOException</code> either
+  <p class="note"><strong>Note:</strong>
+  <code>IllegalArgumentException</code> and <code>IOException</code> either
   need to be caught or passed on when using <code>setDataSource()</code>, since
   the file you are referencing may not exist.</p>
 <p class="note"><strong>Note:</strong>
diff --git a/docs/html/guide/topics/resources/drawable-resource.jd b/docs/html/guide/topics/resources/drawable-resource.jd
index 129462e..d9f619f 100644
--- a/docs/html/guide/topics/resources/drawable-resource.jd
+++ b/docs/html/guide/topics/resources/drawable-resource.jd
@@ -474,7 +474,7 @@
         android:right="<em>dimension</em>"
         android:bottom="<em>dimension</em>"
         android:left="<em>dimension</em>" /&gt;
-&lt;/selector>
+&lt;/layer-list>
 </pre>
 </dd>
 
@@ -906,7 +906,7 @@
         android:right="<em>dimension</em>"
         android:bottom="<em>dimension</em>"
         android:left="<em>dimension</em>" /&gt;
-&lt;/selector>
+&lt;/transition>
 </pre>
 </dd>
 
@@ -926,8 +926,8 @@
       </dl>
     </dd>
   <dt id="transition-item-element"><code>&lt;item&gt;</code></dt>
-    <dd>Defines a drawable to place in the layer drawable, in a position defined by its attributes.
-Must be a child of a <code>&lt;selector&gt;</code> element. Accepts child {@code &lt;bitmap&gt;}
+    <dd>Defines a drawable to use as part of the drawable transition.
+Must be a child of a <code>&lt;transition&gt;</code> element. Accepts child {@code &lt;bitmap&gt;}
 elements.
       <p class="caps">attributes:</p>
       <dl class="atn-list">
@@ -963,7 +963,7 @@
 &lt;transition xmlns:android="http://schemas.android.com/apk/res/android"&gt;
     &lt;item android:drawable="@drawable/on" /&gt;
     &lt;item android:drawable="@drawable/off" /&gt;
-&lt;/layer-list&gt;
+&lt;/transition&gt;
 </pre>
 
 <p>This layout XML applies the drawable to a View:</p>
@@ -1226,11 +1226,11 @@
 <dd>XML file saved at <code>res/drawable/clip.xml</code>:
 <pre>
 &lt;?xml version="1.0" encoding="utf-8"?>
-&lt;shape xmlns:android="http://schemas.android.com/apk/res/android"
+&lt;clip xmlns:android="http://schemas.android.com/apk/res/android"
     android:drawable="@drawable/android"
     android:clipOrientation="horizontal"
     android:gravity="left" /&gt;
-&lt;/shape>
+&lt;/clip>
 </pre>
     <p>The following layout XML applies the clip drawable to a View:</p>
 <pre>
diff --git a/docs/html/sdk/android-2.3.jd b/docs/html/sdk/android-2.3.jd
index a0b7c99..e00674f 100644
--- a/docs/html/sdk/android-2.3.jd
+++ b/docs/html/sdk/android-2.3.jd
@@ -238,9 +238,8 @@
 <ul>
 <li>New {@link android.hardware.Camera.CameraInfo} class stores a camera's
 positional characteristics (orientation, front-facing or back-facing).</li>
-<li>New {@link android.hardware.Camera#getNumberOfCameras()}, {@link
-android.hardware.Camera#getCameraInfo(int,CameraInfo) getCameraInfo()}, and
-{@link android.hardware.Camera#getNumberOfCameras()} methods in the {@link
+<li>New {@link android.hardware.Camera#getNumberOfCameras()} and {@link
+android.hardware.Camera#getCameraInfo(int,CameraInfo) getCameraInfo()} methods in the {@link
 android.hardware.Camera} class let applications query for the cameras available
 and open the camera that they need.</li>
 <li>New {@link android.media.CamcorderProfile get(int,int) method lets
@@ -691,7 +690,7 @@
 <li><code>"reverseLandscape"</code> &mdash; The Activity would like to have the
 screen in landscape orientation, turned in the opposite direction from normal
 landscape.</li>
-<li><code>"reversePortait"</code> &mdash; The Activity would like to have the
+<li><code>"reversePortrait"</code> &mdash; The Activity would like to have the
 screen in portrait orientation, turned in the opposite direction from normal
 portrait.</li>
 <li><code>"sensorLandscape"</code> &mdash; The Activity would like to have the
diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp
index 69ab75a..352f9fb 100644
--- a/media/libstagefright/OMXCodec.cpp
+++ b/media/libstagefright/OMXCodec.cpp
@@ -1536,7 +1536,9 @@
     }
 
     err = allocateBuffers();
-    CHECK_EQ(err, (status_t)OK);
+    if (err != (status_t)OK) {
+        return err;
+    }
 
     if (mQuirks & kRequiresLoadedToIdleAfterAllocation) {
         err = mOMX->sendCommand(mNode, OMX_CommandStateSet, OMX_StateIdle);
diff --git a/services/java/com/android/server/PackageManagerService.java b/services/java/com/android/server/PackageManagerService.java
index 2691e1d..7965dda 100644
--- a/services/java/com/android/server/PackageManagerService.java
+++ b/services/java/com/android/server/PackageManagerService.java
@@ -5774,7 +5774,10 @@
         res.removedInfo.removedPackage = packageName;
         // Remove existing system package
         removePackageLI(oldPkg, true);
-
+        synchronized (mPackages) {
+            mSettings.disableSystemPackageLP(packageName);
+        }
+        
         // Successfully disabled the old package. Now proceed with re-installation
         mLastScanError = PackageManager.INSTALL_SUCCEEDED;
         pkg.applicationInfo.flags |= ApplicationInfo.FLAG_UPDATED_SYSTEM_APP;
diff --git a/voip/java/com/android/server/sip/SipSessionGroup.java b/voip/java/com/android/server/sip/SipSessionGroup.java
index edf8b52..3275317 100644
--- a/voip/java/com/android/server/sip/SipSessionGroup.java
+++ b/voip/java/com/android/server/sip/SipSessionGroup.java
@@ -872,8 +872,13 @@
                 }
                 return true;
             } else {
-                onError(SipErrorCode.INVALID_CREDENTIALS,
-                        "incorrect username or password");
+                if (crossDomainAuthenticationRequired(response)) {
+                    onError(SipErrorCode.CROSS_DOMAIN_AUTHENTICATION,
+                            getRealmFromResponse(response));
+                } else {
+                    onError(SipErrorCode.INVALID_CREDENTIALS,
+                            "incorrect username or password");
+                }
                 return false;
             }
         }
@@ -1025,10 +1030,7 @@
                     return true;
                 case Response.UNAUTHORIZED:
                 case Response.PROXY_AUTHENTICATION_REQUIRED:
-                    if (crossDomainAuthenticationRequired(response)) {
-                        onError(SipErrorCode.CROSS_DOMAIN_AUTHENTICATION,
-                                getRealmFromResponse(response));
-                    } else if (handleAuthentication(event)) {
+                    if (handleAuthentication(event)) {
                         addSipSession(this);
                     }
                     return true;