Merge "Fix for 3124993. Crash in Browser on long press."
diff --git a/api/current.xml b/api/current.xml
index 22a105a..0948888 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -22935,17 +22935,6 @@
  visibility="public"
 >
 </field>
-<field name="IMPORTANCE_HEAVY_WEIGHT"
- type="int"
- transient="false"
- volatile="false"
- value="170"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
 <field name="IMPORTANCE_PERCEPTIBLE"
  type="int"
  transient="false"
@@ -36131,7 +36120,7 @@
 <implements name="android.bluetooth.BluetoothProfile">
 </implements>
 <method name="getConnectedDevices"
- return="java.util.Set&lt;android.bluetooth.BluetoothDevice&gt;"
+ return="java.util.List&lt;android.bluetooth.BluetoothDevice&gt;"
  abstract="false"
  native="false"
  synchronized="false"
@@ -36155,7 +36144,7 @@
 </parameter>
 </method>
 <method name="getDevicesMatchingConnectionStates"
- return="java.util.Set&lt;android.bluetooth.BluetoothDevice&gt;"
+ return="java.util.List&lt;android.bluetooth.BluetoothDevice&gt;"
  abstract="false"
  native="false"
  synchronized="false"
@@ -37969,7 +37958,7 @@
 <implements name="android.bluetooth.BluetoothProfile">
 </implements>
 <method name="getConnectedDevices"
- return="java.util.Set&lt;android.bluetooth.BluetoothDevice&gt;"
+ return="java.util.List&lt;android.bluetooth.BluetoothDevice&gt;"
  abstract="false"
  native="false"
  synchronized="false"
@@ -37993,7 +37982,7 @@
 </parameter>
 </method>
 <method name="getDevicesMatchingConnectionStates"
- return="java.util.Set&lt;android.bluetooth.BluetoothDevice&gt;"
+ return="java.util.List&lt;android.bluetooth.BluetoothDevice&gt;"
  abstract="false"
  native="false"
  synchronized="false"
@@ -38097,7 +38086,7 @@
  visibility="public"
 >
 <method name="getConnectedDevices"
- return="java.util.Set&lt;android.bluetooth.BluetoothDevice&gt;"
+ return="java.util.List&lt;android.bluetooth.BluetoothDevice&gt;"
  abstract="true"
  native="false"
  synchronized="false"
@@ -38121,7 +38110,7 @@
 </parameter>
 </method>
 <method name="getDevicesMatchingConnectionStates"
- return="java.util.Set&lt;android.bluetooth.BluetoothDevice&gt;"
+ return="java.util.List&lt;android.bluetooth.BluetoothDevice&gt;"
  abstract="true"
  native="false"
  synchronized="false"
@@ -111981,6 +111970,18 @@
  deprecated="not deprecated"
  visibility="public"
 >
+<parameter name="data" type="byte[]">
+</parameter>
+<exception name="FormatException" type="android.nfc.FormatException">
+</exception>
+</constructor>
+<constructor name="NdefMessage"
+ type="android.nfc.NdefMessage"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
 <parameter name="records" type="android.nfc.NdefRecord[]">
 </parameter>
 </constructor>
@@ -112006,6 +112007,17 @@
  visibility="public"
 >
 </method>
+<method name="toByteArray"
+ return="byte[]"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="writeToParcel"
  return="void"
  abstract="false"
@@ -112125,6 +112137,17 @@
  visibility="public"
 >
 </method>
+<method name="toByteArray"
+ return="byte[]"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="writeToParcel"
  return="void"
  abstract="false"
diff --git a/cmds/installd/commands.c b/cmds/installd/commands.c
index a5b3e0e..2f03c7a 100644
--- a/cmds/installd/commands.c
+++ b/cmds/installd/commands.c
@@ -946,14 +946,12 @@
     const size_t libdirLen = strlen(dataDir) + strlen(PKG_LIB_POSTFIX);
     if (libdirLen >= PKG_PATH_MAX) {
         LOGE("library dir len too large");
-        rc = -1;
-        goto out;
+        return -1;
     }
 
     if (snprintf(libdir, sizeof(libdir), "%s%s", dataDir, PKG_LIB_POSTFIX) != (ssize_t)libdirLen) {
         LOGE("library dir not written successfully: %s\n", strerror(errno));
-        rc = -1;
-        goto out;
+        return -1;
     }
 
     if (stat(dataDir, &s) < 0) return -1;
diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java
index 5ae8a1f..fe1e7d7 100644
--- a/core/java/android/app/ActivityManager.java
+++ b/core/java/android/app/ActivityManager.java
@@ -797,10 +797,12 @@
         public static final int IMPORTANCE_PERCEPTIBLE = 130;
         
         /**
-         * Constant for {@link #importance}: this process is running a
-         * heavy-weight application and thus should not be killed.
+         * Constant for {@link #importance}: this process is running an
+         * application that can not save its state, and thus can't be killed
+         * while in the background.
+         * @hide
          */
-        public static final int IMPORTANCE_HEAVY_WEIGHT = 170;
+        public static final int IMPORTANCE_CANT_SAVE_STATE = 170;
         
         /**
          * Constant for {@link #importance}: this process is contains services
diff --git a/core/java/android/bluetooth/BluetoothA2dp.java b/core/java/android/bluetooth/BluetoothA2dp.java
index 920ef89..61b4303 100644
--- a/core/java/android/bluetooth/BluetoothA2dp.java
+++ b/core/java/android/bluetooth/BluetoothA2dp.java
@@ -26,11 +26,8 @@
 import android.server.BluetoothA2dpService;
 import android.util.Log;
 
-import java.util.Collections;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Set;
+import java.util.ArrayList;
+import java.util.List;
 
 
 /**
@@ -167,35 +164,35 @@
     /**
      * {@inheritDoc}
      */
-    public Set<BluetoothDevice> getConnectedDevices() {
+    public List<BluetoothDevice> getConnectedDevices() {
         if (DBG) log("getConnectedDevices()");
         if (mService != null && isEnabled()) {
             try {
-                return toDeviceSet(mService.getConnectedDevices());
+                return mService.getConnectedDevices();
             } catch (RemoteException e) {
                 Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable()));
-                return toDeviceSet(new BluetoothDevice[0]);
+                return new ArrayList<BluetoothDevice>();
             }
         }
         if (mService == null) Log.w(TAG, "Proxy not attached to service");
-        return toDeviceSet(new BluetoothDevice[0]);
+        return new ArrayList<BluetoothDevice>();
     }
 
     /**
      * {@inheritDoc}
      */
-    public Set<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states) {
+    public List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states) {
         if (DBG) log("getDevicesMatchingStates()");
         if (mService != null && isEnabled()) {
             try {
-                return toDeviceSet(mService.getDevicesMatchingConnectionStates(states));
+                return mService.getDevicesMatchingConnectionStates(states);
             } catch (RemoteException e) {
                 Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable()));
-                return toDeviceSet(new BluetoothDevice[0]);
+                return new ArrayList<BluetoothDevice>();
             }
         }
         if (mService == null) Log.w(TAG, "Proxy not attached to service");
-        return toDeviceSet(new BluetoothDevice[0]);
+        return new ArrayList<BluetoothDevice>();
     }
 
     /**
@@ -396,11 +393,6 @@
        return false;
     }
 
-    private Set<BluetoothDevice> toDeviceSet(BluetoothDevice[] devices) {
-       return Collections.unmodifiableSet(
-          new HashSet<BluetoothDevice>(Arrays.asList(devices)));
-    }
-
     private static void log(String msg) {
       Log.d(TAG, msg);
     }
diff --git a/core/java/android/bluetooth/BluetoothDeviceProfileState.java b/core/java/android/bluetooth/BluetoothDeviceProfileState.java
index b33ab21..fd8f930 100644
--- a/core/java/android/bluetooth/BluetoothDeviceProfileState.java
+++ b/core/java/android/bluetooth/BluetoothDeviceProfileState.java
@@ -321,7 +321,7 @@
                               mA2dpService.getDevicesMatchingConnectionStates(
                                   new int[] {BluetoothA2dp.STATE_CONNECTED,
                                              BluetoothProfile.STATE_CONNECTING,
-                                             BluetoothProfile.STATE_DISCONNECTING}).length == 0) {
+                                             BluetoothProfile.STATE_DISCONNECTING}).size() == 0) {
                             mA2dpService.connect(mDevice);
                         }
                         if (mService.getInputDevicePriority(mDevice) ==
diff --git a/core/java/android/bluetooth/BluetoothHeadset.java b/core/java/android/bluetooth/BluetoothHeadset.java
index 0496b1f..c64fdbe 100644
--- a/core/java/android/bluetooth/BluetoothHeadset.java
+++ b/core/java/android/bluetooth/BluetoothHeadset.java
@@ -18,20 +18,16 @@
 
 import android.annotation.SdkConstant;
 import android.annotation.SdkConstant.SdkConstantType;
-import android.bluetooth.BluetoothAdapter;
-import android.bluetooth.BluetoothDevice;
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.Intent;
 import android.content.ServiceConnection;
-import android.os.RemoteException;
 import android.os.IBinder;
+import android.os.RemoteException;
 import android.util.Log;
 
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * Public API for controlling the Bluetooth Headset Service. This includes both
@@ -218,35 +214,35 @@
     /**
      * {@inheritDoc}
      */
-    public Set<BluetoothDevice> getConnectedDevices() {
+    public List<BluetoothDevice> getConnectedDevices() {
         if (DBG) log("getConnectedDevices()");
         if (mService != null && isEnabled()) {
             try {
-                return toDeviceSet(mService.getConnectedDevices());
+                return mService.getConnectedDevices();
             } catch (RemoteException e) {
                 Log.e(TAG, Log.getStackTraceString(new Throwable()));
-                return toDeviceSet(new BluetoothDevice[0]);
+                return new ArrayList<BluetoothDevice>();
             }
         }
         if (mService == null) Log.w(TAG, "Proxy not attached to service");
-        return toDeviceSet(new BluetoothDevice[0]);
+        return new ArrayList<BluetoothDevice>();
     }
 
     /**
      * {@inheritDoc}
      */
-    public Set<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states) {
+    public List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states) {
         if (DBG) log("getDevicesMatchingStates()");
         if (mService != null && isEnabled()) {
             try {
-                return toDeviceSet(mService.getDevicesMatchingConnectionStates(states));
+                return mService.getDevicesMatchingConnectionStates(states);
             } catch (RemoteException e) {
                 Log.e(TAG, Log.getStackTraceString(new Throwable()));
-                return toDeviceSet(new BluetoothDevice[0]);
+                return new ArrayList<BluetoothDevice>();
             }
         }
         if (mService == null) Log.w(TAG, "Proxy not attached to service");
-        return toDeviceSet(new BluetoothDevice[0]);
+        return new ArrayList<BluetoothDevice>();
     }
 
     /**
@@ -569,11 +565,6 @@
        return false;
     }
 
-    private Set<BluetoothDevice> toDeviceSet(BluetoothDevice[] devices) {
-       return Collections.unmodifiableSet(
-          new HashSet<BluetoothDevice>(Arrays.asList(devices)));
-    }
-
     private static void log(String msg) {
         Log.d(TAG, msg);
     }
diff --git a/core/java/android/bluetooth/BluetoothInputDevice.java b/core/java/android/bluetooth/BluetoothInputDevice.java
index 1793838..bc8a836 100644
--- a/core/java/android/bluetooth/BluetoothInputDevice.java
+++ b/core/java/android/bluetooth/BluetoothInputDevice.java
@@ -24,10 +24,8 @@
 import android.os.ServiceManager;
 import android.util.Log;
 
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * Public API for controlling the Bluetooth HID (Input Device) Profile
@@ -167,18 +165,16 @@
 
     /** Check if any Input Device is connected.
      *
-     * @return a unmodifiable set of connected Input Devices, or null on error.
+     * @return List of devices, empty List on error.
      * @hide
      */
-    public Set<BluetoothDevice> getConnectedInputDevices() {
+    public List<BluetoothDevice> getConnectedInputDevices() {
         if (DBG) log("getConnectedInputDevices()");
         try {
-            return Collections.unmodifiableSet(
-                    new HashSet<BluetoothDevice>(
-                        Arrays.asList(mService.getConnectedInputDevices())));
+            return mService.getConnectedInputDevices();
         } catch (RemoteException e) {
             Log.e(TAG, "", e);
-            return null;
+            return new ArrayList<BluetoothDevice>();
         }
     }
 
diff --git a/core/java/android/bluetooth/BluetoothPan.java b/core/java/android/bluetooth/BluetoothPan.java
index 9d0b3f2..f55e96a 100644
--- a/core/java/android/bluetooth/BluetoothPan.java
+++ b/core/java/android/bluetooth/BluetoothPan.java
@@ -19,15 +19,13 @@
 import android.annotation.SdkConstant;
 import android.annotation.SdkConstant.SdkConstantType;
 import android.content.Context;
-import android.os.ServiceManager;
-import android.os.RemoteException;
 import android.os.IBinder;
+import android.os.RemoteException;
+import android.os.ServiceManager;
 import android.util.Log;
 
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * @hide
@@ -154,18 +152,16 @@
    *
    * Does not include devices that are currently connecting or disconnecting
    *
-   * @return a unmodifiable set of connected PAN Devices, or null on error.
+   * @return List of PAN devices or empty on Error
    * @hide
    */
-   public Set<BluetoothDevice> getConnectedDevices() {
+   public List<BluetoothDevice> getConnectedDevices() {
       if (DBG) log("getConnectedDevices");
       try {
-          return Collections.unmodifiableSet(
-                  new HashSet<BluetoothDevice>(
-                      Arrays.asList(mService.getConnectedPanDevices())));
+          return mService.getConnectedPanDevices();
       } catch (RemoteException e) {
           Log.e(TAG, "", e);
-          return null;
+          return new ArrayList<BluetoothDevice>();
       }
    }
 
diff --git a/core/java/android/bluetooth/BluetoothProfile.java b/core/java/android/bluetooth/BluetoothProfile.java
index 3b4c84c..3949b26 100644
--- a/core/java/android/bluetooth/BluetoothProfile.java
+++ b/core/java/android/bluetooth/BluetoothProfile.java
@@ -17,10 +17,7 @@
 
 package android.bluetooth;
 
-import android.annotation.SdkConstant;
-import android.annotation.SdkConstant.SdkConstantType;
-
-import java.util.Set;
+import java.util.List;
 
 /**
  * Public APIs for the Bluetooth Profiles.
@@ -150,9 +147,9 @@
      *
      * <p>Requires {@link android.Manifest.permission#BLUETOOTH}
      *
-     * @return An unmodifiable set of devices. The set will be empty on error.
+     * @return List of devices. The list will be empty on error.
      */
-    public Set<BluetoothDevice> getConnectedDevices();
+    public List<BluetoothDevice> getConnectedDevices();
 
     /**
      * Get a set of devices that match any of the given connection
@@ -166,9 +163,9 @@
      * @param states Array of states. States can be one of
      *              {@link #STATE_CONNECTED}, {@link #STATE_CONNECTING},
      *              {@link #STATE_DISCONNECTED}, {@link #STATE_DISCONNECTING},
-     * @return An unmodifiable set of devices. The set will be empty on error.
+     * @return List of devices. The list will be empty on error.
      */
-    public Set<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states);
+    public List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states);
 
     /**
      * Get the current connection state of the profile
diff --git a/core/java/android/bluetooth/IBluetooth.aidl b/core/java/android/bluetooth/IBluetooth.aidl
index cc23146..f0252b7 100644
--- a/core/java/android/bluetooth/IBluetooth.aidl
+++ b/core/java/android/bluetooth/IBluetooth.aidl
@@ -81,7 +81,7 @@
     // HID profile APIs
     boolean connectInputDevice(in BluetoothDevice device);
     boolean disconnectInputDevice(in BluetoothDevice device);
-    BluetoothDevice[] getConnectedInputDevices();  // change to Set<> once AIDL supports
+    List<BluetoothDevice> getConnectedInputDevices();
     int getInputDeviceState(in BluetoothDevice device);
     boolean setInputDevicePriority(in BluetoothDevice device, int priority);
     int getInputDevicePriority(in BluetoothDevice device);
@@ -89,7 +89,7 @@
     boolean isTetheringOn();
     void setBluetoothTethering(boolean value);
     int getPanDeviceState(in BluetoothDevice device);
-    BluetoothDevice[] getConnectedPanDevices();
+    List<BluetoothDevice> getConnectedPanDevices();
     boolean connectPanDevice(in BluetoothDevice device);
     boolean disconnectPanDevice(in BluetoothDevice device);
 }
diff --git a/core/java/android/bluetooth/IBluetoothA2dp.aidl b/core/java/android/bluetooth/IBluetoothA2dp.aidl
index c5044c2..b4fc366 100644
--- a/core/java/android/bluetooth/IBluetoothA2dp.aidl
+++ b/core/java/android/bluetooth/IBluetoothA2dp.aidl
@@ -27,9 +27,8 @@
     // Public API
     boolean connect(in BluetoothDevice device);
     boolean disconnect(in BluetoothDevice device);
-    // change to Set<> once AIDL supports
-    BluetoothDevice[] getConnectedDevices();
-    BluetoothDevice[] getDevicesMatchingConnectionStates(in int[] states);
+    List<BluetoothDevice> getConnectedDevices();
+    List<BluetoothDevice> getDevicesMatchingConnectionStates(in int[] states);
     int getConnectionState(in BluetoothDevice device);
     boolean setPriority(in BluetoothDevice device, int priority);
     int getPriority(in BluetoothDevice device);
diff --git a/core/java/android/bluetooth/IBluetoothHeadset.aidl b/core/java/android/bluetooth/IBluetoothHeadset.aidl
index 8bcf103..3e4c7b4 100644
--- a/core/java/android/bluetooth/IBluetoothHeadset.aidl
+++ b/core/java/android/bluetooth/IBluetoothHeadset.aidl
@@ -27,9 +27,8 @@
     // Public API
     boolean connect(in BluetoothDevice device);
     boolean disconnect(in BluetoothDevice device);
-    // Change to Set<> when AIDL supports
-    BluetoothDevice[] getConnectedDevices();
-    BluetoothDevice[] getDevicesMatchingConnectionStates(in int[] states);
+    List<BluetoothDevice> getConnectedDevices();
+    List<BluetoothDevice> getDevicesMatchingConnectionStates(in int[] states);
     int getConnectionState(in BluetoothDevice device);
     boolean setPriority(in BluetoothDevice device, int priority);
     int getPriority(in BluetoothDevice device);
diff --git a/core/java/android/net/http/CertificateChainValidator.java b/core/java/android/net/http/CertificateChainValidator.java
index 503c470..218df75 100644
--- a/core/java/android/net/http/CertificateChainValidator.java
+++ b/core/java/android/net/http/CertificateChainValidator.java
@@ -129,57 +129,6 @@
             }
         }
 
-        // Clean up the certificates chain and build a new one.
-        // Theoretically, we shouldn't have to do this, but various web servers
-        // in practice are mis-configured to have out-of-order certificates or
-        // expired self-issued root certificate.
-        int chainLength = serverCertificates.length;
-        if (serverCertificates.length > 1) {
-          // 1. we clean the received certificates chain.
-          // We start from the end-entity certificate, tracing down by matching
-          // the "issuer" field and "subject" field until we can't continue.
-          // This helps when the certificates are out of order or
-          // some certificates are not related to the site.
-          int currIndex;
-          for (currIndex = 0; currIndex < serverCertificates.length; ++currIndex) {
-            boolean foundNext = false;
-            for (int nextIndex = currIndex + 1;
-                 nextIndex < serverCertificates.length;
-                 ++nextIndex) {
-              if (serverCertificates[currIndex].getIssuerDN().equals(
-                  serverCertificates[nextIndex].getSubjectDN())) {
-                foundNext = true;
-                // Exchange certificates so that 0 through currIndex + 1 are in proper order
-                if (nextIndex != currIndex + 1) {
-                  X509Certificate tempCertificate = serverCertificates[nextIndex];
-                  serverCertificates[nextIndex] = serverCertificates[currIndex + 1];
-                  serverCertificates[currIndex + 1] = tempCertificate;
-                }
-                break;
-              }
-            }
-            if (!foundNext) break;
-          }
-
-          // 2. we exam if the last traced certificate is self issued and it is expired.
-          // If so, we drop it and pass the rest to checkServerTrusted(), hoping we might
-          // have a similar but unexpired trusted root.
-          chainLength = currIndex + 1;
-          X509Certificate lastCertificate = serverCertificates[chainLength - 1];
-          Date now = new Date();
-          if (lastCertificate.getSubjectDN().equals(lastCertificate.getIssuerDN())
-              && now.after(lastCertificate.getNotAfter())) {
-            --chainLength;
-          }
-        }
-
-        // 3. Now we copy the newly built chain into an appropriately sized array.
-        X509Certificate[] newServerCertificates = null;
-        newServerCertificates = new X509Certificate[chainLength];
-        for (int i = 0; i < chainLength; ++i) {
-          newServerCertificates[i] = serverCertificates[i];
-        }
-
         // first, we validate the new chain using the standard validation
         // solution; if we do not find any errors, we are done; if we
         // fail the standard validation, we re-validate again below,
@@ -188,7 +137,7 @@
         //
         try {
             SSLParametersImpl.getDefaultTrustManager().checkServerTrusted(
-                newServerCertificates, "RSA");
+                serverCertificates, "RSA");
 
             // no errors!!!
             return null;
diff --git a/core/java/android/nfc/NdefMessage.java b/core/java/android/nfc/NdefMessage.java
index 378304e..feca94e 100644
--- a/core/java/android/nfc/NdefMessage.java
+++ b/core/java/android/nfc/NdefMessage.java
@@ -34,15 +34,12 @@
 
     private final NdefRecord[] mRecords;
 
-    //TODO(npelly) FormatException
     /**
      * Create an NDEF message from raw bytes.
      * <p>
      * Validation is performed to make sure the Record format headers are valid,
      * and the ID + TYPE + PAYLOAD fields are of the correct size.
      * @throws FormatException
-     *
-     * @hide
      */
     public NdefMessage(byte[] data) throws FormatException {
         mRecords = null;  // stop compiler complaints about final field
@@ -69,10 +66,7 @@
     }
 
     /**
-     * Get a byte array representation of this NDEF message.
-     *
-     * @return byte array
-     * @hide
+     * Returns a byte array representation of this entire NDEF message.
      */
     public byte[] toByteArray() {
         //TODO(nxp): do not return null
diff --git a/core/java/android/nfc/NdefRecord.java b/core/java/android/nfc/NdefRecord.java
index edc5ab9..557e44d 100644
--- a/core/java/android/nfc/NdefRecord.java
+++ b/core/java/android/nfc/NdefRecord.java
@@ -247,8 +247,7 @@
     }
 
     /**
-     * Return this NDEF Record as a byte array.
-     * @hide
+     * Returns this entire NDEF Record as a byte array.
      */
     public byte[] toByteArray() {
         return generate(mFlags, mTnf, mType, mId, mPayload);
diff --git a/core/java/android/os/Build.java b/core/java/android/os/Build.java
index 9767786..b4c6a2923 100644
--- a/core/java/android/os/Build.java
+++ b/core/java/android/os/Build.java
@@ -188,15 +188,7 @@
         public static final int FROYO = 8;
         
         /**
-         * Next version of Android.
-         * 
-         * <p>Applications targeting this or a later release will get these
-         * new changes in behavior:</p>
-         * <ul>
-         * <li> The status bar is now dark.  Targeting this version allows
-         * the platform to perform performing compatibility on status bar
-         * graphics to ensure they look okay on a dark background.
-         * </ul>
+         * Newest version of Android, version 2.3.
          */
         public static final int GINGERBREAD = 9;
 
diff --git a/core/java/android/server/BluetoothA2dpService.java b/core/java/android/server/BluetoothA2dpService.java
index 7b2022b..61e2305 100644
--- a/core/java/android/server/BluetoothA2dpService.java
+++ b/core/java/android/server/BluetoothA2dpService.java
@@ -41,6 +41,7 @@
 import java.io.PrintWriter;
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
 
 
 public class BluetoothA2dpService extends IBluetoothA2dp.Stub {
@@ -107,10 +108,10 @@
             } else if (action.equals(AudioManager.VOLUME_CHANGED_ACTION)) {
                 int streamType = intent.getIntExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE, -1);
                 if (streamType == AudioManager.STREAM_MUSIC) {
-                    BluetoothDevice sinks[] = getConnectedDevices();
+                    List<BluetoothDevice> sinks = getConnectedDevices();
 
-                    if (sinks.length != 0 && isPhoneDocked(sinks[0])) {
-                        String address = sinks[0].getAddress();
+                    if (sinks.size() != 0 && isPhoneDocked(sinks.get(0))) {
+                        String address = sinks.get(0).getAddress();
                         int newVolLevel =
                           intent.getIntExtra(AudioManager.EXTRA_VOLUME_STREAM_VALUE, 0);
                         int oldVolLevel =
@@ -319,7 +320,7 @@
         if (getDevicesMatchingConnectionStates(new int[] {
                 BluetoothA2dp.STATE_CONNECTING,
                 BluetoothA2dp.STATE_CONNECTED,
-                BluetoothA2dp.STATE_DISCONNECTING}).length != 0) {
+                BluetoothA2dp.STATE_DISCONNECTING}).size() != 0) {
             return false;
         }
 
@@ -430,19 +431,16 @@
         return state;
     }
 
-    public synchronized BluetoothDevice[] getConnectedDevices() {
+    public synchronized List<BluetoothDevice> getConnectedDevices() {
         mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
-        BluetoothDevice[] sinks = getDevicesMatchingConnectionStates(
+        List<BluetoothDevice> sinks = getDevicesMatchingConnectionStates(
                 new int[] {BluetoothA2dp.STATE_CONNECTED});
         return sinks;
     }
 
-    public synchronized BluetoothDevice[] getDevicesMatchingConnectionStates(int[] states) {
+    public synchronized List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states) {
         mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
-        ArrayList<BluetoothDevice> sinks = new ArrayList();
-        if (mAudioDevices.isEmpty()) {
-            return sinks.toArray(new BluetoothDevice[sinks.size()]);
-        }
+        ArrayList<BluetoothDevice> sinks = new ArrayList<BluetoothDevice>();
         for (BluetoothDevice device: mAudioDevices.keySet()) {
             int sinkState = getConnectionState(device);
             for (int state : states) {
@@ -452,7 +450,7 @@
                 }
             }
         }
-        return sinks.toArray(new BluetoothDevice[sinks.size()]);
+        return sinks;
     }
 
     public synchronized int getPriority(BluetoothDevice device) {
diff --git a/core/java/android/server/BluetoothEventLoop.java b/core/java/android/server/BluetoothEventLoop.java
index 239c3ac..f47c553 100644
--- a/core/java/android/server/BluetoothEventLoop.java
+++ b/core/java/android/server/BluetoothEventLoop.java
@@ -29,11 +29,12 @@
 import android.os.Handler;
 import android.os.Message;
 import android.os.ParcelUuid;
+import android.os.PowerManager;
 import android.util.Log;
 
 import java.util.HashMap;
+import java.util.List;
 import java.util.Set;
-import android.os.PowerManager;
 
 
 /**
@@ -629,7 +630,7 @@
     }
 
     private boolean isOtherInputDeviceConnected(String address) {
-        Set<BluetoothDevice> devices =
+        List<BluetoothDevice> devices =
             mBluetoothService.lookupInputDevicesMatchingStates(new int[] {
                                                 BluetoothInputDevice.STATE_CONNECTING,
                                                 BluetoothInputDevice.STATE_CONNECTED});
@@ -654,13 +655,13 @@
     }
 
     private boolean isOtherSinkInNonDisconnectedState(String address) {
-        Set<BluetoothDevice> devices =
+        List<BluetoothDevice> devices =
             mA2dp.getDevicesMatchingConnectionStates(new int[] {BluetoothA2dp.STATE_CONNECTED,
                                                      BluetoothA2dp.STATE_CONNECTING,
                                                      BluetoothA2dp.STATE_DISCONNECTING});
 
         if (devices.size() == 0) return false;
-        for(BluetoothDevice dev: devices) {
+        for (BluetoothDevice dev: devices) {
             if (!dev.getAddress().equals(address)) return true;
         }
         return false;
diff --git a/core/java/android/server/BluetoothService.java b/core/java/android/server/BluetoothService.java
index 7abb98e..660f9ab 100644
--- a/core/java/android/server/BluetoothService.java
+++ b/core/java/android/server/BluetoothService.java
@@ -27,12 +27,12 @@
 import android.bluetooth.BluetoothAdapter;
 import android.bluetooth.BluetoothClass;
 import android.bluetooth.BluetoothDevice;
-import android.bluetooth.BluetoothHeadset;
 import android.bluetooth.BluetoothDeviceProfileState;
+import android.bluetooth.BluetoothHeadset;
+import android.bluetooth.BluetoothInputDevice;
 import android.bluetooth.BluetoothPan;
 import android.bluetooth.BluetoothProfile;
 import android.bluetooth.BluetoothProfileState;
-import android.bluetooth.BluetoothInputDevice;
 import android.bluetooth.BluetoothSocket;
 import android.bluetooth.BluetoothUuid;
 import android.bluetooth.IBluetooth;
@@ -80,6 +80,7 @@
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
@@ -1415,7 +1416,7 @@
     }
 
     /*package*/ synchronized boolean allowIncomingTethering() {
-        if (isTetheringOn() && getConnectedPanDevices().length < mMaxPanDevices)
+        if (isTetheringOn() && getConnectedPanDevices().size() < mMaxPanDevices)
             return true;
         return false;
     }
@@ -1503,16 +1504,17 @@
         return true;
     }
 
-    public synchronized BluetoothDevice[] getConnectedPanDevices() {
+    public synchronized List<BluetoothDevice> getConnectedPanDevices() {
         mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
 
-        Set<BluetoothDevice> devices = new HashSet<BluetoothDevice>();
+        List<BluetoothDevice> devices = new ArrayList<BluetoothDevice>();
+
         for (BluetoothDevice device: mPanDevices.keySet()) {
             if (getPanDeviceState(device) == BluetoothPan.STATE_CONNECTED) {
                 devices.add(device);
             }
         }
-        return devices.toArray(new BluetoothDevice[devices.size()]);
+        return devices;
     }
 
     public synchronized boolean disconnectPanDevice(BluetoothDevice device) {
@@ -1569,7 +1571,7 @@
     }
 
     private String createNewTetheringAddressLocked() {
-        if (getConnectedPanDevices().length == mMaxPanDevices) {
+        if (getConnectedPanDevices().size() == mMaxPanDevices) {
             log("Max PAN device connections reached");
             return null;
         }
@@ -1688,7 +1690,7 @@
                                                 "Need BLUETOOTH_ADMIN permission");
 
         String objectPath = getObjectPathFromAddress(device.getAddress());
-        if (objectPath == null || getConnectedInputDevices().length == 0) {
+        if (objectPath == null || getConnectedInputDevices().size() == 0) {
             return false;
         }
         BluetoothDeviceProfileState state = mDeviceProfileState.get(device.getAddress());
@@ -1721,11 +1723,11 @@
         return mInputDevices.get(device);
     }
 
-    public synchronized BluetoothDevice[] getConnectedInputDevices() {
+    public synchronized List<BluetoothDevice> getConnectedInputDevices() {
         mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
-        Set<BluetoothDevice> devices = lookupInputDevicesMatchingStates(
+        List<BluetoothDevice> devices = lookupInputDevicesMatchingStates(
             new int[] {BluetoothInputDevice.STATE_CONNECTED});
-        return devices.toArray(new BluetoothDevice[devices.size()]);
+        return devices;
     }
 
     public synchronized int getInputDevicePriority(BluetoothDevice device) {
@@ -1746,11 +1748,9 @@
                 priority);
     }
 
-    /*package*/synchronized Set<BluetoothDevice> lookupInputDevicesMatchingStates(int[] states) {
-        Set<BluetoothDevice> inputDevices = new HashSet<BluetoothDevice>();
-        if (mInputDevices.isEmpty()) {
-            return inputDevices;
-        }
+    /*package*/synchronized List<BluetoothDevice> lookupInputDevicesMatchingStates(int[] states) {
+        List<BluetoothDevice> inputDevices = new ArrayList<BluetoothDevice>();
+
         for (BluetoothDevice device: mInputDevices.keySet()) {
             int inputDeviceState = getInputDeviceState(device);
             for (int state : states) {
@@ -2487,11 +2487,11 @@
         // dump
         pw.println("\n--Headset Service--");
         if (mBluetoothHeadset != null) {
-           Set<BluetoothDevice> deviceSet = mBluetoothHeadset.getConnectedDevices();
-           if (deviceSet.size() == 0) {
+           List<BluetoothDevice> deviceList = mBluetoothHeadset.getConnectedDevices();
+           if (deviceList.size() == 0) {
               pw.println("\n--No headsets connected--");
            }
-           BluetoothDevice device = (BluetoothDevice) deviceSet.toArray()[0];
+           BluetoothDevice device = deviceList.get(0);
 
             switch (mBluetoothHeadset.getConnectionState(device)) {
                 case BluetoothHeadset.STATE_DISCONNECTED:
@@ -2511,11 +2511,11 @@
                     break;
             }
 
-            deviceSet.clear();
-            deviceSet = mBluetoothHeadset.getDevicesMatchingConnectionStates(new int[] {
+            deviceList.clear();
+            deviceList = mBluetoothHeadset.getDevicesMatchingConnectionStates(new int[] {
                      BluetoothProfile.STATE_CONNECTED, BluetoothProfile.STATE_DISCONNECTED});
             pw.println("\n--Connected and Disconnected Headsets");
-            for (BluetoothDevice dev: deviceSet) {
+            for (BluetoothDevice dev: deviceList) {
                 pw.println(device);
                 if (mBluetoothHeadset.isAudioConnected(device)) {
                     pw.println("SCO audio connected to device:" + device);
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index 13b9d98..c095199 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -2388,7 +2388,7 @@
         if (!rect.equals(mLastVisibleRectSent)) {
             Point pos = new Point(rect.left, rect.top);
             mWebViewCore.sendMessage(EventHub.SET_SCROLL_OFFSET,
-                    nativeMoveGeneration(), 0, pos);
+                    nativeMoveGeneration(), mUserScroll ? 1 : 0, pos);
             mLastVisibleRectSent = rect;
         }
         Rect globalRect = new Rect();
@@ -6444,6 +6444,7 @@
                 }
                 case NEW_PICTURE_MSG_ID: {
                     // called for new content
+                    mUserScroll = false;
                     final WebViewCore.DrawData draw = (WebViewCore.DrawData) msg.obj;
                     setBaseLayer(draw.mBaseLayer, draw.mInvalRegion.getBounds());
                     final Point viewSize = draw.mViewPoint;
diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java
index 8cd9f68..71da36d 100644
--- a/core/java/android/webkit/WebViewCore.java
+++ b/core/java/android/webkit/WebViewCore.java
@@ -1074,7 +1074,7 @@
                             // note: these are in document coordinates
                             // (inv-zoom)
                             Point pt = (Point) msg.obj;
-                            nativeSetScrollOffset(msg.arg1, pt.x, pt.y);
+                            nativeSetScrollOffset(msg.arg1, msg.arg2, pt.x, pt.y);
                             break;
 
                         case SET_GLOBAL_BOUNDS:
@@ -2347,7 +2347,7 @@
     private native void nativeScrollFocusedTextInput(float xPercent, int y);
 
     // these must be in document space (i.e. not scaled/zoomed).
-    private native void nativeSetScrollOffset(int gen, int dx, int dy);
+    private native void nativeSetScrollOffset(int gen, int userScrolled, int dx, int dy);
 
     private native void nativeSetGlobalBounds(int x, int y, int w, int h);
 
diff --git a/core/java/android/widget/SearchView.java b/core/java/android/widget/SearchView.java
index 1d36b49..029aebf 100644
--- a/core/java/android/widget/SearchView.java
+++ b/core/java/android/widget/SearchView.java
@@ -306,6 +306,10 @@
      */
     public void setQuery(CharSequence query, boolean submit) {
         mQueryTextView.setText(query);
+        if (query != null) {
+            mQueryTextView.setSelection(query.length());
+        }
+
         // If the query is not empty and submit is requested, submit the query
         if (submit && !TextUtils.isEmpty(query)) {
             onSubmitQuery();
diff --git a/core/java/com/android/internal/os/BatteryStatsImpl.java b/core/java/com/android/internal/os/BatteryStatsImpl.java
index 224f9a5..0f482b7 100644
--- a/core/java/com/android/internal/os/BatteryStatsImpl.java
+++ b/core/java/com/android/internal/os/BatteryStatsImpl.java
@@ -51,8 +51,8 @@
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
-import java.util.Set;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.locks.ReentrantLock;
 
@@ -65,16 +65,16 @@
     private static final String TAG = "BatteryStatsImpl";
     private static final boolean DEBUG = false;
     private static final boolean DEBUG_HISTORY = false;
-    
+
     // In-memory Parcel magic number, used to detect attempts to unmarshall bad data
-    private static final int MAGIC = 0xBA757475; // 'BATSTATS' 
+    private static final int MAGIC = 0xBA757475; // 'BATSTATS'
 
     // Current on-disk Parcel version
     private static final int VERSION = 52;
 
     // Maximum number of items we will record in the history.
     private static final int MAX_HISTORY_ITEMS = 2000;
-    
+
     // No, really, THIS is the maximum number of items we will record in the history.
     private static final int MAX_MAX_HISTORY_ITEMS = 3000;
 
@@ -82,9 +82,9 @@
     // per uid; once the limit is reached, we batch the remaining wakelocks
     // in to one common name.
     private static final int MAX_WAKELOCKS_PER_UID = 30;
-    
+
     private static final String BATCHED_WAKELOCK_NAME = "*overflow*";
-    
+
     private static int sNumSpeedSteps;
 
     private final JournaledFile mFile;
@@ -147,9 +147,9 @@
     // These are the objects that will want to do something when the device
     // is unplugged from power.
     final ArrayList<Unpluggable> mUnpluggables = new ArrayList<Unpluggable>();
-    
+
     boolean mShuttingDown;
-    
+
     long mHistoryBaseTime;
     boolean mHaveBatteryLevel = false;
     boolean mRecordingHistory = true;
@@ -159,7 +159,7 @@
     HistoryItem mHistoryLastEnd;
     HistoryItem mHistoryCache;
     final HistoryItem mHistoryCur = new HistoryItem();
-    
+
     int mStartCount;
 
     long mBatteryUptime;
@@ -173,41 +173,41 @@
     long mRealtime;
     long mRealtimeStart;
     long mLastRealtime;
-    
+
     boolean mScreenOn;
     StopwatchTimer mScreenOnTimer;
 
     int mScreenBrightnessBin = -1;
     final StopwatchTimer[] mScreenBrightnessTimer = new StopwatchTimer[NUM_SCREEN_BRIGHTNESS_BINS];
-    
+
     Counter mInputEventCounter;
-    
+
     boolean mPhoneOn;
     StopwatchTimer mPhoneOnTimer;
-    
+
     boolean mAudioOn;
     StopwatchTimer mAudioOnTimer;
-    
+
     boolean mVideoOn;
     StopwatchTimer mVideoOnTimer;
-    
+
     int mPhoneSignalStrengthBin = -1;
-    final StopwatchTimer[] mPhoneSignalStrengthsTimer = 
+    final StopwatchTimer[] mPhoneSignalStrengthsTimer =
             new StopwatchTimer[NUM_SIGNAL_STRENGTH_BINS];
 
     StopwatchTimer mPhoneSignalScanningTimer;
 
     int mPhoneDataConnectionType = -1;
-    final StopwatchTimer[] mPhoneDataConnectionsTimer = 
+    final StopwatchTimer[] mPhoneDataConnectionsTimer =
             new StopwatchTimer[NUM_DATA_CONNECTION_TYPES];
-    
+
     boolean mWifiOn;
     StopwatchTimer mWifiOnTimer;
     int mWifiOnUid = -1;
 
     boolean mGlobalWifiRunning;
     StopwatchTimer mGlobalWifiRunningTimer;
-    
+
     boolean mBluetoothOn;
     StopwatchTimer mBluetoothOnTimer;
 
@@ -256,15 +256,15 @@
     /*
      * Holds a SamplingTimer associated with each kernel wakelock name being tracked.
      */
-    private final HashMap<String, SamplingTimer> mKernelWakelockStats = 
+    private final HashMap<String, SamplingTimer> mKernelWakelockStats =
             new HashMap<String, SamplingTimer>();
-    
+
     public Map<String, ? extends SamplingTimer> getKernelWakelockStats() {
         return mKernelWakelockStats;
     }
-    
+
     private static int sKernelWakelockUpdateVersion = 0;
-    
+
     private static final int[] PROC_WAKELOCKS_FORMAT = new int[] {
         Process.PROC_TAB_TERM|Process.PROC_OUT_STRING,                // 0: name
         Process.PROC_TAB_TERM|Process.PROC_OUT_LONG,                  // 1: count
@@ -273,19 +273,19 @@
         Process.PROC_TAB_TERM,
         Process.PROC_TAB_TERM|Process.PROC_OUT_LONG,                  // 5: totalTime
     };
-    
+
     private final String[] mProcWakelocksName = new String[3];
     private final long[] mProcWakelocksData = new long[3];
-    
+
     /*
      * Used as a buffer for reading in data from /proc/wakelocks before it is processed and added
      * to mKernelWakelockStats.
      */
-    private final Map<String, KernelWakelockStats> mProcWakelockFileStats = 
+    private final Map<String, KernelWakelockStats> mProcWakelockFileStats =
             new HashMap<String, KernelWakelockStats>();
 
     private HashMap<String, Integer> mUidCache = new HashMap<String, Integer>();
-    
+
     // For debugging
     public BatteryStatsImpl() {
         mFile = null;
@@ -296,7 +296,7 @@
         void unplug(long batteryUptime, long batteryRealtime);
         void plug(long batteryUptime, long batteryRealtime);
     }
-    
+
     /**
      * State for keeping track of counting information.
      */
@@ -307,7 +307,7 @@
         int mLastCount;
         int mUnpluggedCount;
         int mPluggedCount;
-        
+
         Counter(ArrayList<Unpluggable> unpluggables, Parcel in) {
             mUnpluggables = unpluggables;
             mPluggedCount = in.readInt();
@@ -322,7 +322,7 @@
             mUnpluggables = unpluggables;
             unpluggables.add(this);
         }
-        
+
         public void writeToParcel(Parcel out) {
             out.writeInt(mCount.get());
             out.writeInt(mLoadedCount);
@@ -337,7 +337,7 @@
         public void plug(long batteryUptime, long batteryRealtime) {
             mPluggedCount = mCount.get();
         }
-        
+
         /**
          * Writes a possibly null Counter to a Parcel.
          *
@@ -377,7 +377,7 @@
                     + " mUnpluggedCount=" + mUnpluggedCount
                     + " mPluggedCount=" + mPluggedCount);
         }
-        
+
         void stepAtomic() {
             mCount.incrementAndGet();
         }
@@ -392,11 +392,11 @@
                 detach();
             }
         }
-        
+
         void detach() {
             mUnpluggables.remove(this);
         }
-        
+
         void writeSummaryFromParcelLocked(Parcel out) {
             int count = mCount.get();
             out.writeInt(count);
@@ -431,41 +431,41 @@
     public static abstract class Timer extends BatteryStats.Timer implements Unpluggable {
         final int mType;
         final ArrayList<Unpluggable> mUnpluggables;
-        
+
         int mCount;
         int mLoadedCount;
         int mLastCount;
         int mUnpluggedCount;
-        
+
         // Times are in microseconds for better accuracy when dividing by the
         // lock count, and are in "battery realtime" units.
-        
+
         /**
          * The total time we have accumulated since the start of the original
          * boot, to the last time something interesting happened in the
          * current run.
          */
         long mTotalTime;
-        
+
         /**
          * The total time we loaded for the previous runs.  Subtract this from
          * mTotalTime to find the time for the current run of the system.
          */
         long mLoadedTime;
-        
+
         /**
          * The run time of the last run of the system, as loaded from the
          * saved data.
          */
         long mLastTime;
-        
+
         /**
          * The value of mTotalTime when unplug() was last called.  Subtract
          * this from mTotalTime to find the time since the last unplug from
          * power.
          */
         long mUnpluggedTime;
-        
+
         /**
          * Constructs from a parcel.
          * @param type
@@ -476,7 +476,7 @@
         Timer(int type, ArrayList<Unpluggable> unpluggables, Parcel in) {
             mType = type;
             mUnpluggables = unpluggables;
-            
+
             mCount = in.readInt();
             mLoadedCount = in.readInt();
             mLastCount = 0;
@@ -495,9 +495,9 @@
         }
 
         protected abstract long computeRunTimeLocked(long curBatteryRealtime);
-        
+
         protected abstract int computeCurrentCountLocked();
-        
+
         /**
          * Clear state of this timer.  Returns true if the timer is inactive
          * so can be completely dropped.
@@ -510,11 +510,11 @@
             }
             return true;
         }
-        
+
         void detach() {
             mUnpluggables.remove(this);
         }
-        
+
         public void writeToParcel(Parcel out, long batteryRealtime) {
             out.writeInt(mCount);
             out.writeInt(mLoadedCount);
@@ -551,7 +551,7 @@
                         + ": new mTotalTime=" + mTotalTime);
             }
         }
-        
+
         /**
          * Writes a possibly null Timer to a Parcel.
          *
@@ -612,8 +612,8 @@
             pw.println(prefix + "mLastTime=" + mLastTime
                     + " mUnpluggedTime=" + mUnpluggedTime);
         }
-        
-        
+
+
         void writeSummaryFromParcelLocked(Parcel out, long batteryRealtime) {
             long runTime = computeRunTimeLocked(batteryRealtime);
             // Divide by 1000 for backwards compatibility
@@ -631,9 +631,9 @@
             mUnpluggedCount = mCount;
         }
     }
-    
+
     public static final class SamplingTimer extends Timer {
-        
+
         /**
          * The most recent reported count from /proc/wakelocks.
          */
@@ -647,7 +647,7 @@
 
         /**
          * The most recent reported total_time from /proc/wakelocks.
-         */ 
+         */
         long mCurrentReportedTotalTime;
 
 
@@ -666,12 +666,12 @@
          * Whether we are currently recording reported values.
          */
         boolean mTrackingReportedValues;
-        
+
         /*
          * A sequnce counter, incremented once for each update of the stats.
          */
         int mUpdateVersion;
-        
+
         SamplingTimer(ArrayList<Unpluggable> unpluggables, boolean inDischarge, Parcel in) {
             super(0, unpluggables, in);
             mCurrentReportedCount = in.readInt();
@@ -681,28 +681,28 @@
             mTrackingReportedValues = in.readInt() == 1;
             mInDischarge = inDischarge;
         }
-        
-        SamplingTimer(ArrayList<Unpluggable> unpluggables, boolean inDischarge, 
+
+        SamplingTimer(ArrayList<Unpluggable> unpluggables, boolean inDischarge,
                 boolean trackReportedValues) {
             super(0, unpluggables);
             mTrackingReportedValues = trackReportedValues;
             mInDischarge = inDischarge;
         }
-        
+
         public void setStale() {
             mTrackingReportedValues = false;
             mUnpluggedReportedTotalTime = 0;
             mUnpluggedReportedCount = 0;
         }
-        
+
         public void setUpdateVersion(int version) {
             mUpdateVersion = version;
         }
-        
+
         public int getUpdateVersion() {
             return mUpdateVersion;
         }
-        
+
         public void updateCurrentReportedCount(int count) {
             if (mInDischarge && mUnpluggedReportedCount == 0) {
                 // Updating the reported value for the first time.
@@ -712,7 +712,7 @@
             }
             mCurrentReportedCount = count;
         }
-        
+
         public void updateCurrentReportedTotalTime(long totalTime) {
             if (mInDischarge && mUnpluggedReportedTotalTime == 0) {
                 // Updating the reported value for the first time.
@@ -722,7 +722,7 @@
             }
             mCurrentReportedTotalTime = totalTime;
         }
-        
+
         public void unplug(long batteryUptime, long batteryRealtime) {
             super.unplug(batteryUptime, batteryRealtime);
             if (mTrackingReportedValues) {
@@ -736,25 +736,25 @@
             super.plug(batteryUptime, batteryRealtime);
             mInDischarge = false;
         }
-        
+
         public void logState(Printer pw, String prefix) {
             super.logState(pw, prefix);
-            pw.println(prefix + "mCurrentReportedCount=" + mCurrentReportedCount 
+            pw.println(prefix + "mCurrentReportedCount=" + mCurrentReportedCount
                     + " mUnpluggedReportedCount=" + mUnpluggedReportedCount
                     + " mCurrentReportedTotalTime=" + mCurrentReportedTotalTime
                     + " mUnpluggedReportedTotalTime=" + mUnpluggedReportedTotalTime);
         }
-        
+
         protected long computeRunTimeLocked(long curBatteryRealtime) {
-            return mTotalTime + (mInDischarge && mTrackingReportedValues 
+            return mTotalTime + (mInDischarge && mTrackingReportedValues
                     ? mCurrentReportedTotalTime - mUnpluggedReportedTotalTime : 0);
         }
-        
+
         protected int computeCurrentCountLocked() {
             return mCount + (mInDischarge && mTrackingReportedValues
                     ? mCurrentReportedCount - mUnpluggedReportedCount : 0);
         }
-        
+
         public void writeToParcel(Parcel out, long batteryRealtime) {
             super.writeToParcel(out, batteryRealtime);
             out.writeInt(mCurrentReportedCount);
@@ -763,13 +763,13 @@
             out.writeLong(mUnpluggedReportedTotalTime);
             out.writeInt(mTrackingReportedValues ? 1 : 0);
         }
-        
+
         boolean reset(BatteryStatsImpl stats, boolean detachIfReset) {
             super.reset(stats, detachIfReset);
             setStale();
             return true;
         }
-        
+
         void writeSummaryFromParcelLocked(Parcel out, long batteryRealtime) {
             super.writeSummaryFromParcelLocked(out, batteryRealtime);
             out.writeLong(mCurrentReportedTotalTime);
@@ -784,7 +784,7 @@
             mTrackingReportedValues = in.readInt() == 1;
         }
     }
-    
+
     /**
      * State for keeping track of timing information.
      */
@@ -800,7 +800,7 @@
          * time we have been running since we last computed an update.
          */
         long mUpdateTime;
-        
+
         /**
          * The total time at which the timer was acquired, to determine if it
          * was actually held for an interesting duration.
@@ -829,7 +829,7 @@
             mUid = uid;
             mTimerPool = timerPool;
         }
-        
+
         void setTimeout(long timeout) {
             mTimeout = timeout;
         }
@@ -857,7 +857,7 @@
             pw.println(prefix + "mNesting=" + mNesting + "mUpdateTime=" + mUpdateTime
                     + " mAcquireTime=" + mAcquireTime);
         }
-        
+
         void startRunningLocked(BatteryStatsImpl stats) {
             if (mNesting++ == 0) {
                 mUpdateTime = stats.getBatteryRealtimeLocked(
@@ -897,19 +897,19 @@
                     // Remove this timer from the active pool
                     mTimerPool.remove(this);
                 } else {
-                    final long realtime = SystemClock.elapsedRealtime() * 1000; 
+                    final long realtime = SystemClock.elapsedRealtime() * 1000;
                     final long batteryRealtime = stats.getBatteryRealtimeLocked(realtime);
                     mNesting = 1;
                     mTotalTime = computeRunTimeLocked(batteryRealtime);
                     mNesting = 0;
                 }
-                
+
                 if (DEBUG && mType < 0) {
                     Log.v(TAG, "stop #" + mType + ": mUpdateTime=" + mUpdateTime
                             + " mTotalTime=" + mTotalTime + " mCount=" + mCount
                             + " mAcquireTime=" + mAcquireTime);
                 }
-                
+
                 if (mTotalTime == mAcquireTime) {
                     // If there was no change in the time, then discard this
                     // count.  A somewhat cheezy strategy, but hey.
@@ -922,7 +922,7 @@
         // due to a change in timer count
         private static void refreshTimersLocked(final BatteryStatsImpl stats,
                 final ArrayList<StopwatchTimer> pool) {
-            final long realtime = SystemClock.elapsedRealtime() * 1000; 
+            final long realtime = SystemClock.elapsedRealtime() * 1000;
             final long batteryRealtime = stats.getBatteryRealtimeLocked(realtime);
             final int N = pool.size();
             for (int i=N-1; i>= 0; i--) {
@@ -961,25 +961,25 @@
             mAcquireTime = mTotalTime;
             return canDetach;
         }
-        
+
         void detach() {
             super.detach();
             if (mTimerPool != null) {
                 mTimerPool.remove(this);
             }
         }
-        
+
         void readSummaryFromParcelLocked(Parcel in) {
             super.readSummaryFromParcelLocked(in);
             mNesting = 0;
         }
     }
-    
+
     private final Map<String, KernelWakelockStats> readKernelWakelockStats() {
-        
+
         byte[] buffer = new byte[8192];
         int len;
-        
+
         try {
             FileInputStream is = new FileInputStream("/proc/wakelocks");
             len = is.read(buffer);
@@ -999,10 +999,10 @@
         } catch (java.io.IOException e) {
             return null;
         }
-        
+
         return parseProcWakelocks(buffer, len);
     }
-    
+
     private final Map<String, KernelWakelockStats> parseProcWakelocks(
             byte[] wlBuffer, int len) {
         String name;
@@ -1018,11 +1018,11 @@
 
         synchronized(this) {
             Map<String, KernelWakelockStats> m = mProcWakelockFileStats;
-            
+
             sKernelWakelockUpdateVersion++;
             while (endIndex < len) {
-                for (endIndex=startIndex; 
-                        endIndex < len && wlBuffer[endIndex] != '\n' && wlBuffer[endIndex] != '\0'; 
+                for (endIndex=startIndex;
+                        endIndex < len && wlBuffer[endIndex] != '\n' && wlBuffer[endIndex] != '\0';
                         endIndex++);
                 endIndex++; // endIndex is an exclusive upper bound.
                 // Don't go over the end of the buffer, Process.parseProcLine might
@@ -1049,7 +1049,7 @@
 
                 if (parsed && name.length() > 0) {
                     if (!m.containsKey(name)) {
-                        m.put(name, new KernelWakelockStats(count, totalTime, 
+                        m.put(name, new KernelWakelockStats(count, totalTime,
                                 sKernelWakelockUpdateVersion));
                         numUpdatedWlNames++;
                     } else {
@@ -1080,27 +1080,27 @@
             return m;
         }
     }
-    
+
     private class KernelWakelockStats {
         public int mCount;
         public long mTotalTime;
         public int mVersion;
-        
+
         KernelWakelockStats(int count, long totalTime, int version) {
             mCount = count;
             mTotalTime = totalTime;
             mVersion = version;
         }
     }
-    
+
     /*
-     * Get the KernelWakelockTimer associated with name, and create a new one if one 
+     * Get the KernelWakelockTimer associated with name, and create a new one if one
      * doesn't already exist.
      */
     public SamplingTimer getKernelWakelockTimerLocked(String name) {
         SamplingTimer kwlt = mKernelWakelockStats.get(name);
         if (kwlt == null) {
-            kwlt = new SamplingTimer(mUnpluggables, mOnBatteryInternal, 
+            kwlt = new SamplingTimer(mUnpluggables, mOnBatteryInternal,
                     true /* track reported values */);
             mKernelWakelockStats.put(name, kwlt);
         }
@@ -1144,7 +1144,7 @@
     }
 
     /**
-     * Returns the duration that the cell radio was up for data transfers. 
+     * Returns the duration that the cell radio was up for data transfers.
      */
     public long getRadioDataUptime() {
         if (mRadioDataStart == -1) {
@@ -1156,10 +1156,9 @@
 
     private int getCurrentBluetoothPingCount() {
         if (mBtHeadset != null) {
-            Set<BluetoothDevice> deviceSet = mBtHeadset.getConnectedDevices();
-            BluetoothDevice[] devices = deviceSet.toArray(new BluetoothDevice[deviceSet.size()]);
-            if (devices.length > 0) {
-                return mBtHeadset.getBatteryUsageHint(devices[0]);
+            List<BluetoothDevice> deviceList = mBtHeadset.getConnectedDevices();
+            if (deviceList.size() > 0) {
+                return mBtHeadset.getBatteryUsageHint(deviceList.get(0));
             }
         }
         return -1;
@@ -1234,7 +1233,7 @@
 
         addHistoryRecordLocked(curTime, HistoryItem.CMD_UPDATE);
     }
-    
+
     void addHistoryRecordLocked(long curTime, byte cmd) {
         HistoryItem rec = mHistoryCache;
         if (rec != null) {
@@ -1243,10 +1242,10 @@
             rec = new HistoryItem();
         }
         rec.setTo(mHistoryBaseTime + curTime, cmd, mHistoryCur);
-        
+
         addHistoryRecordLocked(rec);
     }
-    
+
     void addHistoryRecordLocked(HistoryItem rec) {
         mNumHistoryItems++;
         rec.next = null;
@@ -1258,7 +1257,7 @@
             mHistory = mHistoryEnd = rec;
         }
     }
-    
+
     void clearHistoryLocked() {
         if (mHistory != null) {
             mHistoryEnd.next = mHistoryCache;
@@ -1268,7 +1267,7 @@
         mNumHistoryItems = 0;
         mHistoryBaseTime = 0;
     }
-    
+
     public void doUnplugLocked(long batteryUptime, long batteryRealtime) {
         for (int iu = mUidStats.size() - 1; iu >= 0; iu--) {
             Uid u = mUidStats.valueAt(iu);
@@ -1532,7 +1531,7 @@
     }
 
     int mGpsNesting;
-    
+
     public void noteStartGpsLocked(int uid) {
         if (mGpsNesting == 0) {
             mHistoryCur.states |= HistoryItem.STATE_GPS_ON_FLAG;
@@ -1543,7 +1542,7 @@
         mGpsNesting++;
         getUidStatsLocked(uid).noteStartGps();
     }
-    
+
     public void noteStopGpsLocked(int uid) {
         mGpsNesting--;
         if (mGpsNesting == 0) {
@@ -1572,7 +1571,7 @@
             noteStartWakeLocked(-1, -1, "dummy", WAKE_TYPE_PARTIAL);
         }
     }
-    
+
     public void noteScreenOffLocked() {
         if (mScreenOn) {
             mHistoryCur.states &= ~HistoryItem.STATE_SCREEN_ON_FLAG;
@@ -1588,7 +1587,7 @@
             noteStopWakeLocked(-1, -1, "dummy", WAKE_TYPE_PARTIAL);
         }
     }
-    
+
     public void noteScreenBrightnessLocked(int brightness) {
         // Bin the brightness.
         int bin = brightness / (256/NUM_SCREEN_BRIGHTNESS_BINS);
@@ -1609,15 +1608,15 @@
             mScreenBrightnessBin = bin;
         }
     }
-    
+
     public void noteInputEventAtomic() {
         mInputEventCounter.stepAtomic();
     }
-    
+
     public void noteUserActivityLocked(int uid, int event) {
         getUidStatsLocked(uid).noteUserActivityLocked(event);
     }
-    
+
     public void notePhoneOnLocked() {
         if (!mPhoneOn) {
             mHistoryCur.states |= HistoryItem.STATE_PHONE_IN_CALL_FLAG;
@@ -1628,7 +1627,7 @@
             mPhoneOnTimer.startRunningLocked(this);
         }
     }
-    
+
     public void notePhoneOffLocked() {
         if (mPhoneOn) {
             mHistoryCur.states &= ~HistoryItem.STATE_PHONE_IN_CALL_FLAG;
@@ -1688,7 +1687,7 @@
                 mPhoneSignalScanningTimer.startRunningLocked(this);
             }
         }
-        
+
         if (!scanning) {
             // If we are no longer scanning, then stop the scanning timer.
             if (mPhoneSignalScanningTimer.isRunningLocked()) {
@@ -1746,7 +1745,7 @@
             mPhoneSignalStrengthsTimer[bin].startRunningLocked(this);
         }
     }
-    
+
     public void notePhoneDataConnectionStateLocked(int dataType, boolean hasData) {
         int bin = DATA_CONNECTION_NONE;
         if (hasData) {
@@ -1806,7 +1805,7 @@
             mPhoneDataConnectionsTimer[bin].startRunningLocked(this);
         }
     }
-    
+
     public void noteWifiOnLocked() {
         if (!mWifiOn) {
             mHistoryCur.states |= HistoryItem.STATE_WIFI_ON_FLAG;
@@ -1817,7 +1816,7 @@
             mWifiOnTimer.startRunningLocked(this);
         }
     }
-    
+
     public void noteWifiOffLocked() {
         if (mWifiOn) {
             mHistoryCur.states &= ~HistoryItem.STATE_WIFI_ON_FLAG;
@@ -1844,7 +1843,7 @@
         }
         getUidStatsLocked(uid).noteAudioTurnedOnLocked();
     }
-    
+
     public void noteAudioOffLocked(int uid) {
         if (mAudioOn) {
             mHistoryCur.states &= ~HistoryItem.STATE_AUDIO_ON_FLAG;
@@ -1868,7 +1867,7 @@
         }
         getUidStatsLocked(uid).noteVideoTurnedOnLocked();
     }
-    
+
     public void noteVideoOffLocked(int uid) {
         if (mVideoOn) {
             mHistoryCur.states &= ~HistoryItem.STATE_VIDEO_ON_FLAG;
@@ -1940,7 +1939,7 @@
             mBluetoothOnTimer.startRunningLocked(this);
         }
     }
-    
+
     public void noteBluetoothOffLocked() {
         if (mBluetoothOn) {
             mHistoryCur.states &= ~HistoryItem.STATE_BLUETOOTH_ON_FLAG;
@@ -1951,9 +1950,9 @@
             mBluetoothOnTimer.stopRunningLocked(this);
         }
     }
-    
+
     int mWifiFullLockNesting = 0;
-    
+
     public void noteFullWifiLockAcquiredLocked(int uid) {
         if (mWifiFullLockNesting == 0) {
             mHistoryCur.states |= HistoryItem.STATE_WIFI_FULL_LOCK_FLAG;
@@ -1977,7 +1976,7 @@
     }
 
     int mWifiScanLockNesting = 0;
-    
+
     public void noteScanWifiLockAcquiredLocked(int uid) {
         if (mWifiScanLockNesting == 0) {
             mHistoryCur.states |= HistoryItem.STATE_WIFI_SCAN_LOCK_FLAG;
@@ -2001,7 +2000,7 @@
     }
 
     int mWifiMulticastNesting = 0;
-    
+
     public void noteWifiMulticastEnabledLocked(int uid) {
         if (mWifiMulticastNesting == 0) {
             mHistoryCur.states |= HistoryItem.STATE_WIFI_MULTICAST_ON_FLAG;
@@ -2069,7 +2068,7 @@
     @Override public long getScreenOnTime(long batteryRealtime, int which) {
         return mScreenOnTimer.getTotalTimeLocked(batteryRealtime, which);
     }
-    
+
     @Override public long getScreenBrightnessTime(int brightnessBin,
             long batteryRealtime, int which) {
         return mScreenBrightnessTimer[brightnessBin].getTotalTimeLocked(
@@ -2079,7 +2078,7 @@
     @Override public int getInputEventCount(int which) {
         return mInputEventCounter.getCountLocked(which);
     }
-    
+
     @Override public long getPhoneOnTime(long batteryRealtime, int which) {
         return mPhoneOnTimer.getTotalTimeLocked(batteryRealtime, which);
     }
@@ -2099,21 +2098,21 @@
     @Override public int getPhoneSignalStrengthCount(int dataType, int which) {
         return mPhoneDataConnectionsTimer[dataType].getCountLocked(which);
     }
-    
+
     @Override public long getPhoneDataConnectionTime(int dataType,
             long batteryRealtime, int which) {
         return mPhoneDataConnectionsTimer[dataType].getTotalTimeLocked(
                 batteryRealtime, which);
     }
-    
+
     @Override public int getPhoneDataConnectionCount(int dataType, int which) {
         return mPhoneDataConnectionsTimer[dataType].getCountLocked(which);
     }
-    
+
     @Override public long getWifiOnTime(long batteryRealtime, int which) {
         return mWifiOnTimer.getTotalTimeLocked(batteryRealtime, which);
     }
-    
+
     @Override public long getGlobalWifiRunningTime(long batteryRealtime, int which) {
         return mGlobalWifiRunningTimer.getTotalTimeLocked(batteryRealtime, which);
     }
@@ -2121,11 +2120,11 @@
     @Override public long getBluetoothOnTime(long batteryRealtime, int which) {
         return mBluetoothOnTimer.getTotalTimeLocked(batteryRealtime, which);
     }
-    
+
     @Override public boolean getIsOnBattery() {
         return mOnBattery;
     }
-    
+
     @Override public SparseArray<? extends BatteryStats.Uid> getUidStats() {
         return mUidStats;
     }
@@ -2134,7 +2133,7 @@
      * The statistics associated with a particular uid.
      */
     public final class Uid extends BatteryStats.Uid {
-        
+
         final int mUid;
         long mLoadedTcpBytesReceived;
         long mLoadedTcpBytesSent;
@@ -2142,32 +2141,32 @@
         long mCurrentTcpBytesSent;
         long mTcpBytesReceivedAtLastUnplug;
         long mTcpBytesSentAtLastUnplug;
-        
+
         // These are not saved/restored when parcelling, since we want
         // to return from the parcel with a snapshot of the state.
         long mStartedTcpBytesReceived = -1;
         long mStartedTcpBytesSent = -1;
-        
+
         boolean mWifiRunning;
         StopwatchTimer mWifiRunningTimer;
-        
+
         boolean mFullWifiLockOut;
         StopwatchTimer mFullWifiLockTimer;
-        
+
         boolean mScanWifiLockOut;
         StopwatchTimer mScanWifiLockTimer;
-        
+
         boolean mWifiMulticastEnabled;
         StopwatchTimer mWifiMulticastTimer;
-        
+
         boolean mAudioTurnedOn;
         StopwatchTimer mAudioTurnedOnTimer;
-        
+
         boolean mVideoTurnedOn;
         StopwatchTimer mVideoTurnedOnTimer;
 
         Counter[] mUserActivityCounters;
-        
+
         /**
          * The statistics we have collected for this uid's wake locks.
          */
@@ -2187,7 +2186,7 @@
          * The statistics we have collected for this uid's processes.
          */
         final HashMap<String, Pkg> mPackageStats = new HashMap<String, Pkg>();
-        
+
         /**
          * The transient wake stats we have collected for this uid's pids.
          */
@@ -2248,7 +2247,7 @@
                 return current;
             }
         }
-        
+
         public long computeCurrentTcpBytesReceived() {
             return mCurrentTcpBytesReceived + (mStartedTcpBytesReceived >= 0
                     ? (TrafficStats.getUidRxBytes(mUid) - mStartedTcpBytesReceived) : 0);
@@ -2268,7 +2267,7 @@
                 return current;
             }
         }
-        
+
         @Override
         public void noteWifiRunningLocked() {
             if (!mWifiRunning) {
@@ -2280,7 +2279,7 @@
                 mWifiRunningTimer.startRunningLocked(BatteryStatsImpl.this);
             }
         }
-        
+
         @Override
         public void noteWifiStoppedLocked() {
             if (mWifiRunning) {
@@ -2288,7 +2287,7 @@
                 mWifiRunningTimer.stopRunningLocked(BatteryStatsImpl.this);
             }
         }
-        
+
         @Override
         public void noteFullWifiLockAcquiredLocked() {
             if (!mFullWifiLockOut) {
@@ -2300,7 +2299,7 @@
                 mFullWifiLockTimer.startRunningLocked(BatteryStatsImpl.this);
             }
         }
-        
+
         @Override
         public void noteFullWifiLockReleasedLocked() {
             if (mFullWifiLockOut) {
@@ -2308,7 +2307,7 @@
                 mFullWifiLockTimer.stopRunningLocked(BatteryStatsImpl.this);
             }
         }
-        
+
         @Override
         public void noteScanWifiLockAcquiredLocked() {
             if (!mScanWifiLockOut) {
@@ -2320,7 +2319,7 @@
                 mScanWifiLockTimer.startRunningLocked(BatteryStatsImpl.this);
             }
         }
-        
+
         @Override
         public void noteScanWifiLockReleasedLocked() {
             if (mScanWifiLockOut) {
@@ -2389,7 +2388,7 @@
             }
         }
 
-        @Override 
+        @Override
         public long getWifiRunningTime(long batteryRealtime, int which) {
             if (mWifiRunningTimer == null) {
                 return 0;
@@ -2397,15 +2396,15 @@
             return mWifiRunningTimer.getTotalTimeLocked(batteryRealtime, which);
         }
 
-        @Override 
+        @Override
         public long getFullWifiLockTime(long batteryRealtime, int which) {
             if (mFullWifiLockTimer == null) {
                 return 0;
             }
             return mFullWifiLockTimer.getTotalTimeLocked(batteryRealtime, which);
         }
-        
-        @Override 
+
+        @Override
         public long getScanWifiLockTime(long batteryRealtime, int which) {
             if (mScanWifiLockTimer == null) {
                 return 0;
@@ -2422,7 +2421,7 @@
                                                           which);
         }
 
-        @Override 
+        @Override
         public long getAudioTurnedOnTime(long batteryRealtime, int which) {
             if (mAudioTurnedOnTimer == null) {
                 return 0;
@@ -2430,7 +2429,7 @@
             return mAudioTurnedOnTimer.getTotalTimeLocked(batteryRealtime, which);
         }
 
-        @Override 
+        @Override
         public long getVideoTurnedOnTime(long batteryRealtime, int which) {
             if (mVideoTurnedOnTimer == null) {
                 return 0;
@@ -2447,12 +2446,12 @@
             else if (type >= NUM_USER_ACTIVITY_TYPES) type = NUM_USER_ACTIVITY_TYPES-1;
             mUserActivityCounters[type].stepAtomic();
         }
-        
+
         @Override
         public boolean hasUserActivity() {
             return mUserActivityCounters != null;
         }
-        
+
         @Override
         public int getUserActivityCount(int type, int which) {
             if (mUserActivityCounters == null) {
@@ -2460,14 +2459,14 @@
             }
             return mUserActivityCounters[type].getCountLocked(which);
         }
-        
+
         void initUserActivityLocked() {
             mUserActivityCounters = new Counter[NUM_USER_ACTIVITY_TYPES];
             for (int i=0; i<NUM_USER_ACTIVITY_TYPES; i++) {
                 mUserActivityCounters[i] = new Counter(mUnpluggables);
             }
         }
-        
+
         public long computeCurrentTcpBytesSent() {
             return mCurrentTcpBytesSent + (mStartedTcpBytesSent >= 0
                     ? (TrafficStats.getUidTxBytes(mUid) - mStartedTcpBytesSent) : 0);
@@ -2479,7 +2478,7 @@
          */
         boolean reset() {
             boolean active = false;
-            
+
             if (mWifiRunningTimer != null) {
                 active |= !mWifiRunningTimer.reset(BatteryStatsImpl.this, false);
                 active |= mWifiRunning;
@@ -2504,10 +2503,10 @@
                 active |= !mVideoTurnedOnTimer.reset(BatteryStatsImpl.this, false);
                 active |= mVideoTurnedOn;
             }
-            
+
             mLoadedTcpBytesReceived = mLoadedTcpBytesSent = 0;
             mCurrentTcpBytesReceived = mCurrentTcpBytesSent = 0;
-            
+
             if (mUserActivityCounters != null) {
                 for (int i=0; i<NUM_USER_ACTIVITY_TYPES; i++) {
                     mUserActivityCounters[i].reset(false);
@@ -2571,7 +2570,7 @@
                 }
                 mPackageStats.clear();
             }
-            
+
             mPids.clear();
 
             if (!active) {
@@ -2599,10 +2598,10 @@
                     }
                 }
             }
-            
+
             return !active;
         }
-        
+
         void writeToParcelLocked(Parcel out, long batteryRealtime) {
             out.writeInt(mWakelockStats.size());
             for (Map.Entry<String, Uid.Wakelock> wakelockEntry : mWakelockStats.entrySet()) {
@@ -2631,7 +2630,7 @@
                 Uid.Pkg pkg = pkgEntry.getValue();
                 pkg.writeToParcelLocked(out);
             }
-            
+
             out.writeLong(mLoadedTcpBytesReceived);
             out.writeLong(mLoadedTcpBytesSent);
             out.writeLong(computeCurrentTcpBytesReceived());
@@ -2725,7 +2724,7 @@
                 pkg.readFromParcelLocked(in);
                 mPackageStats.put(packageName, pkg);
             }
-            
+
             mLoadedTcpBytesReceived = in.readLong();
             mLoadedTcpBytesSent = in.readLong();
             mCurrentTcpBytesReceived = in.readLong();
@@ -2846,7 +2845,7 @@
                 }
                 return !wlactive;
             }
-            
+
             void readFromParcelLocked(ArrayList<Unpluggable> unpluggables, Parcel in) {
                 mTimerPartial = readTimerFromParcel(WAKE_TYPE_PARTIAL,
                         mPartialTimers, unpluggables, in);
@@ -2876,7 +2875,7 @@
         public final class Sensor extends BatteryStats.Uid.Sensor {
             final int mHandle;
             StopwatchTimer mTimer;
-            
+
             public Sensor(int handle) {
                 mHandle = handle;
             }
@@ -2902,7 +2901,7 @@
                 }
                 return false;
             }
-            
+
             void readFromParcelLocked(ArrayList<Unpluggable> unpluggables, Parcel in) {
                 mTimer = readTimerFromParcel(unpluggables, in);
             }
@@ -3024,7 +3023,7 @@
 
             public void plug(long batteryUptime, long batteryRealtime) {
             }
-            
+
             void detach() {
                 mUnpluggables.remove(this);
                 for (int i = 0; i < mSpeedBins.length; i++) {
@@ -3035,7 +3034,7 @@
                     }
                 }
             }
-            
+
             public int countExcessivePowers() {
                 return mExcessivePower != null ? mExcessivePower.size() : 0;
             }
@@ -3302,18 +3301,18 @@
             Pkg() {
                 mUnpluggables.add(this);
             }
-            
+
             public void unplug(long batteryUptime, long batteryRealtime) {
                 mUnpluggedWakeups = mWakeups;
             }
 
             public void plug(long batteryUptime, long batteryRealtime) {
             }
-            
+
             void detach() {
                 mUnpluggables.remove(this);
             }
-            
+
             void readFromParcelLocked(Parcel in) {
                 mWakeups = in.readInt();
                 mLoadedWakeups = in.readInt();
@@ -3464,7 +3463,7 @@
                 Serv() {
                     mUnpluggables.add(this);
                 }
-                
+
                 public void unplug(long batteryUptime, long batteryRealtime) {
                     mUnpluggedStartTime = getStartTimeToNowLocked(batteryUptime);
                     mUnpluggedStarts = mStarts;
@@ -3473,11 +3472,11 @@
 
                 public void plug(long batteryUptime, long batteryRealtime) {
                 }
-                
+
                 void detach() {
                     mUnpluggables.remove(this);
                 }
-                
+
                 void readFromParcelLocked(Parcel in) {
                     mStartTime = in.readLong();
                     mRunningSince = in.readLong();
@@ -3652,7 +3651,7 @@
         public SparseArray<? extends Pid> getPidStats() {
             return mPids;
         }
-        
+
         public Pid getPidStatsLocked(int pid) {
             Pid p = mPids.get(pid);
             if (p == null) {
@@ -3790,7 +3789,7 @@
                 p.addExcessiveWake(overTime, usedTime);
             }
         }
-        
+
         public void reportExcessiveCpuLocked(String proc, long overTime, long usedTime) {
             Proc p = getProcessStatsLocked(proc);
             if (p != null) {
@@ -3802,7 +3801,7 @@
             StopwatchTimer t = getSensorTimerLocked(sensor, true);
             if (t != null) {
                 t.startRunningLocked(BatteryStatsImpl.this);
-            }            
+            }
         }
 
         public void noteStopSensor(int sensor) {
@@ -3810,16 +3809,16 @@
             StopwatchTimer t = getSensorTimerLocked(sensor, false);
             if (t != null) {
                 t.stopRunningLocked(BatteryStatsImpl.this);
-            }            
+            }
         }
-        
+
         public void noteStartGps() {
             StopwatchTimer t = getSensorTimerLocked(Sensor.GPS, true);
             if (t != null) {
                 t.startRunningLocked(BatteryStatsImpl.this);
-            }  
+            }
         }
-        
+
         public void noteStopGps() {
             StopwatchTimer t = getSensorTimerLocked(Sensor.GPS, false);
             if (t != null) {
@@ -3909,12 +3908,12 @@
     public HistoryItem getHistory() {
         return mHistory;
     }
-    
+
     @Override
     public long getHistoryBaseTime() {
         return mHistoryBaseTime;
     }
-    
+
     @Override
     public int getStartCount() {
         return mStartCount;
@@ -3936,7 +3935,7 @@
         mUnpluggedBatteryUptime = getBatteryUptimeLocked(mUptimeStart);
         mUnpluggedBatteryRealtime = getBatteryRealtimeLocked(mRealtimeStart);
     }
-    
+
     public void resetAllStatsLocked() {
         mStartCount = 0;
         initTimes();
@@ -3958,24 +3957,24 @@
         mWifiOnTimer.reset(this, false);
         mGlobalWifiRunningTimer.reset(this, false);
         mBluetoothOnTimer.reset(this, false);
-        
+
         for (int i=0; i<mUidStats.size(); i++) {
             if (mUidStats.valueAt(i).reset()) {
                 mUidStats.remove(mUidStats.keyAt(i));
                 i--;
             }
         }
-        
+
         if (mKernelWakelockStats.size() > 0) {
             for (SamplingTimer timer : mKernelWakelockStats.values()) {
                 mUnpluggables.remove(timer);
             }
             mKernelWakelockStats.clear();
         }
-        
+
         clearHistoryLocked();
     }
-    
+
     void setOnBattery(boolean onBattery, int oldStatus, int level) {
         synchronized(this) {
             boolean doWrite = false;
@@ -3983,7 +3982,7 @@
             m.arg1 = onBattery ? 1 : 0;
             mHandler.sendMessage(m);
             mOnBattery = mOnBatteryInternal = onBattery;
-            
+
             long uptime = SystemClock.uptimeMillis() * 1000;
             long mSecRealtime = SystemClock.elapsedRealtime();
             long realtime = mSecRealtime * 1000;
@@ -4036,10 +4035,10 @@
             }
         }
     }
-    
+
     // This should probably be exposed in the API, though it's not critical
     private static final int BATTERY_PLUGGED_NONE = 0;
-    
+
     public void setBatteryState(int status, int health, int plugType, int level,
             int temp, int volt) {
         boolean onBattery = plugType == BATTERY_PLUGGED_NONE;
@@ -4107,10 +4106,10 @@
             mRecordingHistory = false;
         }
     }
-    
+
     public void updateKernelWakelocksLocked() {
         Map<String, KernelWakelockStats> m = readKernelWakelockStats();
-        
+
         if (m == null) {
             // Not crashing might make board bringup easier.
             Slog.w(TAG, "Couldn't get kernel wake lock stats");
@@ -4120,10 +4119,10 @@
         for (Map.Entry<String, KernelWakelockStats> ent : m.entrySet()) {
             String name = ent.getKey();
             KernelWakelockStats kws = ent.getValue();
-        
+
             SamplingTimer kwlt = mKernelWakelockStats.get(name);
             if (kwlt == null) {
-                kwlt = new SamplingTimer(mUnpluggables, mOnBatteryInternal, 
+                kwlt = new SamplingTimer(mUnpluggables, mOnBatteryInternal,
                         true /* track reported values */);
                 mKernelWakelockStats.put(name, kwlt);
             }
@@ -4131,7 +4130,7 @@
             kwlt.updateCurrentReportedTotalTime(kws.mTotalTime);
             kwlt.setUpdateVersion(sKernelWakelockUpdateVersion);
         }
-        
+
         if (m.size() != mKernelWakelockStats.size()) {
             // Set timers to stale if they didn't appear in /proc/wakelocks this time.
             for (Map.Entry<String, SamplingTimer> ent : mKernelWakelockStats.entrySet()) {
@@ -4276,18 +4275,18 @@
             return getDischargeStartLevelLocked();
         }
     }
-    
+
     public int getDischargeStartLevelLocked() {
             return mDischargeUnplugLevel;
     }
-    
+
     @Override
     public int getDischargeCurrentLevel() {
         synchronized(this) {
             return getDischargeCurrentLevelLocked();
         }
     }
-    
+
     public int getDischargeCurrentLevelLocked() {
             return mDischargeCurrentLevel;
     }
@@ -4430,7 +4429,7 @@
         writeSyncLocked();
         mShuttingDown = true;
     }
-    
+
     Parcel mPendingWrite = null;
     final ReentrantLock mWriteLock = new ReentrantLock();
 
@@ -4451,7 +4450,7 @@
         if (mShuttingDown) {
             return;
         }
-        
+
         Parcel out = Parcel.obtain();
         writeSummaryToParcel(out);
         mLastWriteTime = SystemClock.elapsedRealtime();
@@ -4551,7 +4550,7 @@
         } catch(java.io.IOException e) {
             Slog.e("BatteryStats", "Error reading battery statistics", e);
         }
-        
+
         addHistoryRecordLocked(SystemClock.elapsedRealtime(), HistoryItem.CMD_START);
     }
 
@@ -4570,7 +4569,7 @@
                 mHistoryBaseTime = rec.time;
             }
         }
-        
+
         long oldnow = SystemClock.elapsedRealtime() - (5*60*100);
         if (oldnow > 0) {
             // If the system process has restarted, but not the entire
@@ -4582,7 +4581,7 @@
             mHistoryBaseTime -= oldnow;
         }
     }
-    
+
     void writeHistory(Parcel out) {
         HistoryItem rec = mHistory;
         while (rec != null) {
@@ -4591,7 +4590,7 @@
         }
         out.writeLong(-1);
     }
-    
+
     private void readSummaryFromParcel(Parcel in) {
         final int version = in.readInt();
         if (version != VERSION) {
@@ -4601,7 +4600,7 @@
         }
 
         readHistory(in);
-        
+
         mStartCount = in.readInt();
         mBatteryUptime = in.readLong();
         mBatteryRealtime = in.readLong();
@@ -4611,9 +4610,9 @@
         mDischargeCurrentLevel = in.readInt();
         mLowDischargeAmountSinceCharge = in.readInt();
         mHighDischargeAmountSinceCharge = in.readInt();
-        
+
         mStartCount++;
-        
+
         mScreenOn = false;
         mScreenOnTimer.readSummaryFromParcelLocked(in);
         for (int i=0; i<NUM_SCREEN_BRIGHTNESS_BINS; i++) {
@@ -4693,7 +4692,7 @@
                     u.mUserActivityCounters[i].readSummaryFromParcelLocked(in);
                 }
             }
-            
+
             int NW = in.readInt();
             if (NW > 10000) {
                 Slog.w(TAG, "File corrupt: too many wake locks " + NW);
@@ -4786,7 +4785,7 @@
         out.writeInt(VERSION);
 
         writeHistory(out);
-        
+
         out.writeInt(mStartCount);
         out.writeLong(computeBatteryUptime(NOW_SYS, STATS_SINCE_CHARGED));
         out.writeLong(computeBatteryRealtime(NOWREAL_SYS, STATS_SINCE_CHARGED));
@@ -4796,7 +4795,7 @@
         out.writeInt(mDischargeCurrentLevel);
         out.writeInt(mLowDischargeAmountSinceCharge);
         out.writeInt(mHighDischargeAmountSinceCharge);
-        
+
         mScreenOnTimer.writeSummaryFromParcelLocked(out, NOWREAL);
         for (int i=0; i<NUM_SCREEN_BRIGHTNESS_BINS; i++) {
             mScreenBrightnessTimer[i].writeSummaryFromParcelLocked(out, NOWREAL);
@@ -4825,14 +4824,14 @@
                 out.writeInt(0);
             }
         }
-        
+
         out.writeInt(sNumSpeedSteps);
         final int NU = mUidStats.size();
         out.writeInt(NU);
         for (int iu = 0; iu < NU; iu++) {
             out.writeInt(mUidStats.keyAt(iu));
             Uid u = mUidStats.valueAt(iu);
-            
+
             if (u.mWifiRunningTimer != null) {
                 out.writeInt(1);
                 u.mWifiRunningTimer.writeSummaryFromParcelLocked(out, NOWREAL);
@@ -4878,7 +4877,7 @@
                     u.mUserActivityCounters[i].writeSummaryFromParcelLocked(out);
                 }
             }
-            
+
             int NW = u.mWakelockStats.size();
             out.writeInt(NW);
             if (NW > 0) {
@@ -4970,7 +4969,7 @@
                     }
                 }
             }
-            
+
             out.writeLong(u.getTcpBytesReceived(STATS_SINCE_CHARGED));
             out.writeLong(u.getTcpBytesSent(STATS_SINCE_CHARGED));
         }
@@ -4979,7 +4978,7 @@
     public void readFromParcel(Parcel in) {
         readFromParcelLocked(in);
     }
-    
+
     void readFromParcelLocked(Parcel in) {
         int magic = in.readInt();
         if (magic != MAGIC) {
@@ -4987,7 +4986,7 @@
         }
 
         readHistory(in);
-        
+
         mStartCount = in.readInt();
         mBatteryUptime = in.readLong();
         mBatteryLastUptime = 0;
@@ -5062,7 +5061,7 @@
                 mKernelWakelockStats.put(wakelockName, kwlt);
             }
         }
-        
+
         mPartialTimers.clear();
         mFullTimers.clear();
         mWindowTimers.clear();
@@ -5090,18 +5089,18 @@
     public void writeToParcelWithoutUids(Parcel out, int flags) {
         writeToParcelLocked(out, false, flags);
     }
-    
-    @SuppressWarnings("unused") 
+
+    @SuppressWarnings("unused")
     void writeToParcelLocked(Parcel out, boolean inclUids, int flags) {
         final long uSecUptime = SystemClock.uptimeMillis() * 1000;
         final long uSecRealtime = SystemClock.elapsedRealtime() * 1000;
         final long batteryUptime = getBatteryUptimeLocked(uSecUptime);
         final long batteryRealtime = getBatteryRealtimeLocked(uSecRealtime);
-        
+
         out.writeInt(MAGIC);
-        
+
         writeHistory(out);
-        
+
         out.writeInt(mStartCount);
         out.writeLong(mBatteryUptime);
         out.writeLong(mBatteryRealtime);
@@ -5190,7 +5189,7 @@
             return new BatteryStatsImpl[size];
         }
     };
-    
+
     public void dumpLocked(PrintWriter pw) {
         if (DEBUG) {
             Printer pr = new PrintWriterPrinter(pw);
diff --git a/core/jni/android/graphics/BitmapRegionDecoder.cpp b/core/jni/android/graphics/BitmapRegionDecoder.cpp
index f700791..bf18d55 100644
--- a/core/jni/android/graphics/BitmapRegionDecoder.cpp
+++ b/core/jni/android/graphics/BitmapRegionDecoder.cpp
@@ -65,6 +65,7 @@
         }
     }
     data = (char*)sk_realloc_throw(data, streamLen);
+
     SkMemoryStream* streamMem = new SkMemoryStream();
     streamMem->setMemoryOwned(data, streamLen);
     return streamMem;
@@ -133,6 +134,12 @@
         }
         stream = fdStream;
     } else {
+        /* Restore our offset when we leave, so we can be called more than once
+           with the same descriptor. This is only required if we didn't dup the
+           file descriptor, but it is OK to do it all the time.
+        */
+        AutoFDSeek as(descriptor);
+
         SkFDStream* fdStream = new SkFDStream(descriptor, false);
         if (!fdStream->isValid()) {
             fdStream->unref();
@@ -142,12 +149,6 @@
         fdStream->unref();
     }
 
-    /* Restore our offset when we leave, so we can be called more than once
-       with the same descriptor. This is only required if we didn't dup the
-       file descriptor, but it is OK to do it all the time.
-    */
-    AutoFDSeek as(descriptor);
-
     return doBuildTileIndex(env, stream);
 }
 
diff --git a/include/media/IOMX.h b/include/media/IOMX.h
index 1f8ce71..fa775e7 100644
--- a/include/media/IOMX.h
+++ b/include/media/IOMX.h
@@ -79,6 +79,9 @@
             node_id node, OMX_INDEXTYPE index,
             const void *params, size_t size) = 0;
 
+    virtual status_t storeMetaDataInBuffers(
+            node_id node, OMX_U32 port_index, OMX_BOOL enable) = 0;
+
     virtual status_t enableGraphicBuffers(
             node_id node, OMX_U32 port_index, OMX_BOOL enable) = 0;
 
diff --git a/include/media/stagefright/HardwareAPI.h b/include/media/stagefright/HardwareAPI.h
index 4ded5e8..b009e1b 100644
--- a/include/media/stagefright/HardwareAPI.h
+++ b/include/media/stagefright/HardwareAPI.h
@@ -49,6 +49,32 @@
     OMX_BOOL enable;
 };
 
+// A pointer to this struct is passed to OMX_SetParameter() when the extension
+// index "OMX.google.android.index.storeMetaDataInBuffers"
+// is given.
+//
+// When meta data is stored in the video buffers passed between OMX clients
+// and OMX components, interpretation of the buffer data is up to the
+// buffer receiver, and the data may or may not be the actual video data, but
+// some information helpful for the receiver to locate the actual data.
+// The buffer receiver thus needs to know how to interpret what is stored
+// in these buffers, with mechanisms pre-determined externally. How to
+// interpret the meta data is outside of the scope of this method.
+//
+// Currently, this is specifically used to pass meta data from video source
+// (camera component, for instance) to video encoder to avoid memcpying of
+// input video frame data. To do this, bStoreMetaDta is set to OMX_TRUE.
+// If bStoreMetaData is set to false, real YUV frame data will be stored
+// in the buffers. In addition, if no OMX_SetParameter() call is made
+// with the corresponding extension index, real YUV data is stored
+// in the buffers.
+struct StoreMetaDataInBuffersParams {
+    OMX_U32 nSize;
+    OMX_VERSIONTYPE nVersion;
+    OMX_U32 nPortIndex;
+    OMX_BOOL bStoreMetaData;
+};
+
 // Color formats in the range [OMX_COLOR_FormatAndroidPrivateStart,
 // OMX_COLOR_FormatAndroidPrivateEnd) will be converted to a gralloc pixel
 // format when used to allocate Android native buffers via gralloc.  The
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index 17ef598..faad297 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -355,8 +355,16 @@
     Rect bounds(left, top, right, bottom);
     if (!fboLayer) {
         mSnapshot->transform->mapRect(bounds);
+
         // Layers only make sense if they are in the framebuffer's bounds
-        bounds.intersect(*mSnapshot->clipRect);
+        bounds.intersect(*snapshot->clipRect);
+
+        // When the layer is not an FBO, we may use glCopyTexImage so we
+        // need to make sure the layer does not extend outside the bounds
+        // of the framebuffer
+        bounds.intersect(snapshot->previous->viewport);
+
+        // We cannot work with sub-pixels in this case
         bounds.snapToPixelBoundaries();
     }
 
diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java
index 6aa1ae6..23f34d2 100644
--- a/media/java/android/media/AudioService.java
+++ b/media/java/android/media/AudioService.java
@@ -58,6 +58,7 @@
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
 import java.util.NoSuchElementException;
 import java.util.Set;
@@ -1112,18 +1113,16 @@
         new BluetoothProfile.ServiceListener() {
         public void onServiceConnected(int profile, BluetoothProfile proxy) {
             mBluetoothHeadset = (BluetoothHeadset) proxy;
-            Set<BluetoothDevice> deviceSet = mBluetoothHeadset.getConnectedDevices();
-            if (deviceSet.size() > 0) {
-                BluetoothDevice[] devices =
-                    deviceSet.toArray(new BluetoothDevice[deviceSet.size()]);
-                mBluetoothHeadsetDevice = devices[0];
+            List<BluetoothDevice> deviceList = mBluetoothHeadset.getConnectedDevices();
+            if (deviceList.size() > 0) {
+                mBluetoothHeadsetDevice = deviceList.get(0);
             } else {
                 mBluetoothHeadsetDevice = null;
             }
         }
         public void onServiceDisconnected(int profile) {
             if (mBluetoothHeadset != null) {
-                Set<BluetoothDevice> devices = mBluetoothHeadset.getConnectedDevices();
+                List<BluetoothDevice> devices = mBluetoothHeadset.getConnectedDevices();
                 if (devices.size() == 0) {
                     mBluetoothHeadsetDevice = null;
                     clearAllScoClients();
diff --git a/media/libmedia/IOMX.cpp b/media/libmedia/IOMX.cpp
index 40801a2..f975217 100644
--- a/media/libmedia/IOMX.cpp
+++ b/media/libmedia/IOMX.cpp
@@ -24,6 +24,7 @@
     ENABLE_GRAPHIC_BUFFERS,
     USE_BUFFER,
     USE_GRAPHIC_BUFFER,
+    STORE_META_DATA_IN_BUFFERS,
     ALLOC_BUFFER,
     ALLOC_BUFFER_WITH_BACKUP,
     FREE_BUFFER,
@@ -276,6 +277,19 @@
         return err;
     }
 
+    virtual status_t storeMetaDataInBuffers(
+            node_id node, OMX_U32 port_index, OMX_BOOL enable) {
+        Parcel data, reply;
+        data.writeInterfaceToken(IOMX::getInterfaceDescriptor());
+        data.writeIntPtr((intptr_t)node);
+        data.writeInt32(port_index);
+        data.writeInt32((uint32_t)enable);
+        remote()->transact(STORE_META_DATA_IN_BUFFERS, data, &reply);
+
+        status_t err = reply.readInt32();
+        return err;
+    }
+
     virtual status_t allocateBuffer(
             node_id node, OMX_U32 port_index, size_t size,
             buffer_id *buffer, void **buffer_data) {
@@ -634,6 +648,20 @@
             return NO_ERROR;
         }
 
+        case STORE_META_DATA_IN_BUFFERS:
+        {
+            CHECK_INTERFACE(IOMX, data, reply);
+
+            node_id node = (void*)data.readIntPtr();
+            OMX_U32 port_index = data.readInt32();
+            OMX_BOOL enable = (OMX_BOOL)data.readInt32();
+
+            status_t err = storeMetaDataInBuffers(node, port_index, enable);
+            reply->writeInt32(err);
+
+            return NO_ERROR;
+        }
+
         case ALLOC_BUFFER:
         {
             CHECK_INTERFACE(IOMX, data, reply);
diff --git a/media/libstagefright/include/OMX.h b/media/libstagefright/include/OMX.h
index 83b75ad..5a6c96f9 100644
--- a/media/libstagefright/include/OMX.h
+++ b/media/libstagefright/include/OMX.h
@@ -62,6 +62,9 @@
     virtual status_t enableGraphicBuffers(
             node_id node, OMX_U32 port_index, OMX_BOOL enable);
 
+    virtual status_t storeMetaDataInBuffers(
+            node_id node, OMX_U32 port_index, OMX_BOOL enable);
+
     virtual status_t useBuffer(
             node_id node, OMX_U32 port_index, const sp<IMemory> &params,
             buffer_id *buffer);
diff --git a/media/libstagefright/include/OMXNodeInstance.h b/media/libstagefright/include/OMXNodeInstance.h
index 8c7c562..86c102c 100644
--- a/media/libstagefright/include/OMXNodeInstance.h
+++ b/media/libstagefright/include/OMXNodeInstance.h
@@ -50,6 +50,7 @@
     status_t setConfig(OMX_INDEXTYPE index, const void *params, size_t size);
 
     status_t enableGraphicBuffers(OMX_U32 portIndex, OMX_BOOL enable);
+    status_t storeMetaDataInBuffers(OMX_U32 portIndex, OMX_BOOL enable);
 
     status_t useBuffer(
             OMX_U32 portIndex, const sp<IMemory> &params,
diff --git a/media/libstagefright/omx/OMX.cpp b/media/libstagefright/omx/OMX.cpp
index d89f54b..f9f638f 100644
--- a/media/libstagefright/omx/OMX.cpp
+++ b/media/libstagefright/omx/OMX.cpp
@@ -294,6 +294,11 @@
     return findInstance(node)->enableGraphicBuffers(port_index, enable);
 }
 
+status_t OMX::storeMetaDataInBuffers(
+        node_id node, OMX_U32 port_index, OMX_BOOL enable) {
+    return findInstance(node)->storeMetaDataInBuffers(port_index, enable);
+}
+
 status_t OMX::useBuffer(
         node_id node, OMX_U32 port_index, const sp<IMemory> &params,
         buffer_id *buffer) {
diff --git a/media/libstagefright/omx/OMXNodeInstance.cpp b/media/libstagefright/omx/OMXNodeInstance.cpp
index ba4d765..9b6d441 100644
--- a/media/libstagefright/omx/OMXNodeInstance.cpp
+++ b/media/libstagefright/omx/OMXNodeInstance.cpp
@@ -284,6 +284,37 @@
     return OK;
 }
 
+status_t OMXNodeInstance::storeMetaDataInBuffers(
+        OMX_U32 portIndex,
+        OMX_BOOL enable) {
+    Mutex::Autolock autolock(mLock);
+
+    OMX_INDEXTYPE index;
+    OMX_STRING name = const_cast<OMX_STRING>(
+            "OMX.google.android.index.storeMetaDataInBuffers");
+
+    OMX_ERRORTYPE err = OMX_GetExtensionIndex(mHandle, name, &index);
+    if (err != OMX_ErrorNone) {
+        LOGE("OMX_GetExtensionIndex %s failed", name);
+        return StatusFromOMXError(err);
+    }
+
+    StoreMetaDataInBuffersParams params;
+    memset(&params, 0, sizeof(params));
+    params.nSize = sizeof(params);
+
+    // Version: 1.0.0.0
+    params.nVersion.s.nVersionMajor = 1;
+
+    params.nPortIndex = portIndex;
+    params.bStoreMetaData = enable;
+    if ((err = OMX_SetParameter(mHandle, index, &params)) != OMX_ErrorNone) {
+        LOGE("OMX_SetParameter() failed for StoreMetaDataInBuffers: 0x%08x", err);
+        return UNKNOWN_ERROR;
+    }
+    return err;
+}
+
 status_t OMXNodeInstance::useBuffer(
         OMX_U32 portIndex, const sp<IMemory> &params,
         OMX::buffer_id *buffer) {
diff --git a/native/copy-to-ndk.sh b/native/copy-to-ndk.sh
index 4f5a16a..6470892 100644
--- a/native/copy-to-ndk.sh
+++ b/native/copy-to-ndk.sh
@@ -10,7 +10,7 @@
     local DST_HEADERS=$NDK_PLATFORMS/$CURR_PLATFORM
 
     local SRC_LIB_ANDROID=$ANDROID_PRODUCT_OUT/system/lib/libandroid.so
-    local DST_LIB_ANDROID=$NDK_PLATFORMS/$CURR_PLATFORM/arch-arm/usr/lib/libandroid.so
+    local DST_LIB_ANDROID=$NDK_PLATFORMS/$CURR_PLATFORM/arch-arm/lib/libandroid.so
 
     local didsomething=""
 
@@ -20,9 +20,9 @@
         local src=$SRC_HEADERS/$i
         local changed=""
         for j in $ALL_PLATFORMS; do
-            local dst=$NDK_PLATFORMS/$j/arch-arm/usr/include/android/$i
+            local dst=$NDK_PLATFORMS/$j/include/android/$i
             if [ "$changed" == "" -a -e $dst ]; then
-                #echo "Exists: $dst"
+                echo "Exists: $dst"
                 if diff $src $dst >/dev/null; then
                     echo "$i: has not changed from $j" >/dev/null
                     changed="false"
@@ -34,13 +34,13 @@
         done
         if [ "$changed" == "true" -o "$changed" == "" ]; then
             echo "Updating: $i"
-            cp $src $NDK_PLATFORMS/$CURR_PLATFORM/arch-arm/usr/include/android/$i
+            cp $src $NDK_PLATFORMS/$CURR_PLATFORM/include/android/$i
             didsomething="true"
         fi
     done
 
     if diff $SRC_LIB_ANDROID $DST_LIB_ANDROID >/dev/null; then
-        echo "libandroid.so: has not changed" >/dev/null
+        echo "libandroid.so: has not changed"
     else
         echo "Updating: $DST_LIB_ANDROID"
         cp $SRC_LIB_ANDROID $DST_LIB_ANDROID
diff --git a/packages/SystemUI/res/anim/notification_dnd_off.xml b/packages/SystemUI/res/anim/notification_dnd_off.xml
new file mode 100644
index 0000000..4e88855
--- /dev/null
+++ b/packages/SystemUI/res/anim/notification_dnd_off.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2010 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.
+-->
+
+<set xmlns:android="http://schemas.android.com/apk/res/android"
+    >
+    <translate android:fromXDelta="100%p" android:toXDelta="0"
+        android:duration="@android:integer/config_longAnimTime" 
+        android:interpolator="@anim/hydraulic_brake_interpolator"
+        />
+</set>
diff --git a/packages/SystemUI/res/anim/notification_dnd_on.xml b/packages/SystemUI/res/anim/notification_dnd_on.xml
new file mode 100644
index 0000000..309943b
--- /dev/null
+++ b/packages/SystemUI/res/anim/notification_dnd_on.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2010 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.
+-->
+
+<set xmlns:android="http://schemas.android.com/apk/res/android"
+    >
+    <translate android:toXDelta="100%p" android:fromXDelta="0"
+        android:duration="@android:integer/config_longAnimTime" 
+        android:interpolator="@anim/hydraulic_brake_interpolator"
+        />
+</set>
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_noti_avail.png b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_noti_avail.png
new file mode 100644
index 0000000..9123fef
--- /dev/null
+++ b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_noti_avail.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_noti_avail_open.png b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_noti_avail_open.png
new file mode 100644
index 0000000..8e56f2a
--- /dev/null
+++ b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_noti_avail_open.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_noti_dnd.png b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_noti_dnd.png
new file mode 100644
index 0000000..80cf99c
--- /dev/null
+++ b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_noti_dnd.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_noti_none.png b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_noti_none.png
new file mode 100644
index 0000000..e0d018b
--- /dev/null
+++ b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_noti_none.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_noti_none_open.png b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_noti_none_open.png
new file mode 100644
index 0000000..5db8c9c
--- /dev/null
+++ b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_noti_none_open.png
Binary files differ
diff --git a/packages/SystemUI/res/layout-xlarge/status_bar.xml b/packages/SystemUI/res/layout-xlarge/status_bar.xml
index ed52ad5..cf96e37 100644
--- a/packages/SystemUI/res/layout-xlarge/status_bar.xml
+++ b/packages/SystemUI/res/layout-xlarge/status_bar.xml
@@ -28,19 +28,21 @@
         >
 
         <ImageView
-            android:id="@+id/expand"
+            android:id="@+id/notificationTrigger"
             android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:src="@drawable/ic_sysbar_open"
+            android:layout_height="match_parent"
+            android:layout_alignParentRight="true"
+            android:layout_marginLeft="6dip"
+            android:src="@drawable/ic_sysbar_noti_none"
             android:background="@drawable/ic_sysbar_icon_bg"
-            android:paddingLeft="6dip"
+            android:gravity="center"
             />
 
         <LinearLayout
             android:id="@+id/notificationButtons"
             android:layout_width="wrap_content"
             android:layout_height="match_parent"
-            android:layout_toRightOf="@+id/expand"
+            android:layout_toLeftOf="@+id/notificationTrigger"
             android:gravity="center_vertical"
             android:orientation="horizontal"
             android:visibility="gone"
@@ -78,7 +80,7 @@
             android:id="@+id/notificationIcons"
             android:layout_width="wrap_content"
             android:layout_height="match_parent"
-            android:layout_toLeftOf="@+id/expand"
+            android:layout_toLeftOf="@+id/notificationTrigger"
             android:gravity="center_vertical"
             android:orientation="horizontal"
             >
@@ -92,14 +94,6 @@
                 android:visibility="invisible"
                 />
             <view
-                class="com.android.systemui.statusbar.tablet.NotificationIconArea$DraggerView"
-                android:id="@+id/handle"
-                android:layout_width="32dip"
-                android:layout_height="match_parent"
-                android:background="@drawable/sysbar_hidenotification_handle"
-                android:layout_marginLeft="8dip"
-                />
-            <view
                 class="com.android.systemui.statusbar.tablet.NotificationIconArea$IconLayout"
                 android:id="@+id/icons"
                 android:layout_width="wrap_content"
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/NotificationIconArea.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/NotificationIconArea.java
index 7c7d74c3..2b4f9d2 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/NotificationIconArea.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/NotificationIconArea.java
@@ -32,13 +32,11 @@
     private static final String TAG = "NotificationIconArea";
 
     IconLayout mIconLayout;
-    DraggerView mDraggerView;
 
     public NotificationIconArea(Context context, AttributeSet attrs) {
         super(context, attrs);
 
         mIconLayout = (IconLayout)findViewById(R.id.icons);
-        mDraggerView = (DraggerView) findViewById(R.id.handle);
     }
 
     static class IconLayout extends LinearLayout {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBarService.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBarService.java
index fd65e4d..d11aba6 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBarService.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBarService.java
@@ -77,7 +77,7 @@
     private NotificationData mNotns = new NotificationData();
     
     TabletStatusBarView mStatusBarView;
-    View mNotificationTrigger;
+    ImageView mNotificationTrigger;
     NotificationIconArea mNotificationIconArea;
     View mNotificationButtons;
     View mSystemInfo;
@@ -192,7 +192,7 @@
         mCurtains.setOnLongClickListener(on);
 
         // the button to open the notification area
-        mNotificationTrigger = sb.findViewById(R.id.expand);
+        mNotificationTrigger = (ImageView) sb.findViewById(R.id.notificationTrigger);
         mNotificationTrigger.setOnClickListener(mOnClickListener);
 
         // the more notifications icon
@@ -222,6 +222,7 @@
 
         // set the initial view visibility
         setAreThereNotifications();
+        refreshNotificationTrigger();
 
         // Add the windows
         addPanelWindows();
@@ -253,6 +254,7 @@
                                 R.anim.notification_icons_out);
                         setViewVisibility(mNotificationButtons, View.VISIBLE,
                                 R.anim.notification_buttons_in);
+                        refreshNotificationTrigger();
                     }
                     break;
                 case MSG_CLOSE_NOTIFICATION_PANEL:
@@ -263,6 +265,7 @@
                                 R.anim.notification_icons_in);
                         setViewVisibility(mNotificationButtons, View.GONE,
                                 R.anim.notification_buttons_out);
+                        refreshNotificationTrigger();
                     }
                     break;
                 case MSG_OPEN_SYSTEM_PANEL:
@@ -276,6 +279,22 @@
             }
         }
     }
+
+    public void refreshNotificationTrigger() {
+        if (mNotificationTrigger == null) return;
+
+        int resId;
+        boolean panel = (mNotificationPanel != null 
+                && mNotificationPanel.getVisibility() == View.VISIBLE);
+        if (!mNotificationsOn) {
+            resId = R.drawable.ic_sysbar_noti_dnd;
+        } else if (mNotns.size() > 0) {
+            resId = panel ? R.drawable.ic_sysbar_noti_avail_open : R.drawable.ic_sysbar_noti_avail;
+        } else {
+            resId = panel ? R.drawable.ic_sysbar_noti_none_open : R.drawable.ic_sysbar_noti_none;
+        }
+        mNotificationTrigger.setImageResource(resId);
+    }
     
     public void setBatteryMeter(int level, boolean plugged) {
         if (DEBUG) Slog.d(TAG, "battery=" + level + (plugged ? " - plugged" : " - unplugged"));
@@ -598,21 +617,30 @@
             // system process is dead if we're here.
         }
         animateCollapse();
+        refreshNotificationTrigger();
     }
 
     void onClickDoNotDisturb() {
         mNotificationsOn = !mNotificationsOn;
+        mIconLayout.setVisibility(mNotificationsOn ? View.VISIBLE : View.INVISIBLE); // TODO: animation
         animateCollapse();
+        refreshNotificationTrigger();
     }
 
     public void onClickNotificationTrigger() {
         if (DEBUG) Slog.d(TAG, "clicked notification icons");
         if ((mDisabled & StatusBarManager.DISABLE_EXPAND) == 0) {
-            int msg = (mNotificationPanel.getVisibility() == View.GONE) 
-                ? MSG_OPEN_NOTIFICATION_PANEL
-                : MSG_CLOSE_NOTIFICATION_PANEL;
-            mHandler.removeMessages(msg);
-            mHandler.sendEmptyMessage(msg);
+            if (!mNotificationsOn) {
+                mNotificationsOn = true;
+                mIconLayout.setVisibility(View.VISIBLE); // TODO: animation
+                refreshNotificationTrigger();
+            } else {
+                int msg = (mNotificationPanel.getVisibility() == View.GONE) 
+                    ? MSG_OPEN_NOTIFICATION_PANEL
+                    : MSG_CLOSE_NOTIFICATION_PANEL;
+                mHandler.removeMessages(msg);
+                mHandler.sendEmptyMessage(msg);
+            }
         }
     }
 
@@ -757,6 +785,8 @@
         for (int i=0; i<N; i++) {
             mPile.addView(mNotns.get(N-i-1).row);
         }
+
+        refreshNotificationTrigger();
     }
 
     private boolean inflateViews(NotificationData.Entry entry, ViewGroup parent) {
diff --git a/services/java/com/android/server/PackageManagerService.java b/services/java/com/android/server/PackageManagerService.java
index c50a01e..7c758a2 100644
--- a/services/java/com/android/server/PackageManagerService.java
+++ b/services/java/com/android/server/PackageManagerService.java
@@ -7166,7 +7166,9 @@
                     pw.print("    resourcePath="); pw.println(ps.resourcePathString);
                     pw.print("    nativeLibraryPath="); pw.println(ps.nativeLibraryPathString);
                     pw.print("    obbPath="); pw.println(ps.obbPathString);
+                    pw.print("    versionCode="); pw.println(ps.versionCode);
                     if (ps.pkg != null) {
+                        pw.print("    versionName="); pw.println(ps.pkg.mVersionName);
                         pw.print("    dataDir="); pw.println(ps.pkg.applicationInfo.dataDir);
                         pw.print("    targetSdk="); pw.println(ps.pkg.applicationInfo.targetSdkVersion);
                         if (ps.pkg.mOperationPending) {
@@ -7224,8 +7226,6 @@
                     pw.print("    pkgFlags=0x"); pw.print(Integer.toHexString(ps.pkgFlags));
                             pw.print(" installStatus="); pw.print(ps.installStatus);
                             pw.print(" enabled="); pw.println(ps.enabled);
-                    pw.print("    versionCode="); pw.print(ps.versionCode);
-                            pw.print(" versionName="); pw.println(ps.pkg.mVersionName);
                     if (ps.disabledComponents.size() > 0) {
                         pw.println("    disabledComponents:");
                         for (String s : ps.disabledComponents) {
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index 54a7aa1..de2e965 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -7152,7 +7152,7 @@
                     } else if (adj >= SECONDARY_SERVER_ADJ) {
                         currApp.importance = ActivityManager.RunningAppProcessInfo.IMPORTANCE_SERVICE;
                     } else if (adj >= HEAVY_WEIGHT_APP_ADJ) {
-                        currApp.importance = ActivityManager.RunningAppProcessInfo.IMPORTANCE_HEAVY_WEIGHT;
+                        currApp.importance = ActivityManager.RunningAppProcessInfo.IMPORTANCE_CANT_SAVE_STATE;
                     } else if (adj >= PERCEPTIBLE_APP_ADJ) {
                         currApp.importance = ActivityManager.RunningAppProcessInfo.IMPORTANCE_PERCEPTIBLE;
                     } else if (adj >= VISIBLE_APP_ADJ) {
diff --git a/tools/layoutlib/bridge/.classpath b/tools/layoutlib/bridge/.classpath
index 175a98b..70140d8 100644
--- a/tools/layoutlib/bridge/.classpath
+++ b/tools/layoutlib/bridge/.classpath
@@ -4,7 +4,7 @@
 	<classpathentry kind="src" path="tests"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
-	<classpathentry combineaccessrules="false" kind="src" path="/layoutlib_api"/>
+	<classpathentry kind="var" path="ANDROID_SRC/prebuilt/common/layoutlib_api/layoutlib_api-prebuilt.jar"/>
 	<classpathentry kind="var" path="ANDROID_SRC/prebuilt/common/kxml2/kxml2-2.3.0.jar" sourcepath="/ANDROID_SRC/dalvik/libcore/xml/src/main/java"/>
 	<classpathentry kind="var" path="ANDROID_OUT_FRAMEWORK/layoutlib.jar" sourcepath="/ANDROID_SRC/frameworks/base/core/java"/>
 	<classpathentry kind="var" path="ANDROID_OUT_FRAMEWORK/ninepatch.jar" sourcepath="/ANDROID_SRC/development/tools/ninepatch/src"/>
diff --git a/tools/layoutlib/bridge/Android.mk b/tools/layoutlib/bridge/Android.mk
index b2010d5..b7a602a 100644
--- a/tools/layoutlib/bridge/Android.mk
+++ b/tools/layoutlib/bridge/Android.mk
@@ -20,7 +20,7 @@
 
 LOCAL_JAVA_LIBRARIES := \
 	kxml2-2.3.0 \
-	layoutlib_api \
+	layoutlib_api-prebuilt \
 	ninepatch
 
 LOCAL_STATIC_JAVA_LIBRARIES := temp_layoutlib
diff --git a/tools/layoutlib/create/tests/com/android/tools/layoutlib/create/DelegateClassAdapterTest.java b/tools/layoutlib/create/tests/com/android/tools/layoutlib/create/DelegateClassAdapterTest.java
index 9ad2e6e..7d80796 100644
--- a/tools/layoutlib/create/tests/com/android/tools/layoutlib/create/DelegateClassAdapterTest.java
+++ b/tools/layoutlib/create/tests/com/android/tools/layoutlib/create/DelegateClassAdapterTest.java
@@ -28,11 +28,8 @@
 import org.junit.Test;
 import org.objectweb.asm.ClassReader;
 import org.objectweb.asm.ClassWriter;
-import org.objectweb.asm.util.TraceClassVisitor;
 
 import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
@@ -178,24 +175,26 @@
             };
             cl2.testModifiedInstance();
 
-        } catch (Throwable t) {
-            // For debugging, dump the bytecode of the class in case of unexpected error.
-            StringWriter sw = new StringWriter();
-            PrintWriter pw = new PrintWriter(sw);
-            TraceClassVisitor tcv = new TraceClassVisitor(pw);
-
-            ClassReader cr2 = new ClassReader(bytes);
-            cr2.accept(tcv, 0 /* flags */);
-
-            String msg = "\n" + t.getClass().getCanonicalName();
-            if (t.getMessage() != null) {
-                msg += ": " + t.getMessage();
-            }
-            msg = msg + "\nBytecode dump:\n" + sw.toString();
-
-            // Re-throw exception with new message
-            RuntimeException ex = new RuntimeException(msg, t);
-            throw ex;
+        // This code block is useful for debugging. However to make it work you need to
+        // pull in the org.objectweb.asm.util.TraceClassVisitor class and associated
+        // utilities which are found in the ASM source jar.
+        //
+        // } catch (Throwable t) {
+        //     For debugging, dump the bytecode of the class in case of unexpected error.
+        //     StringWriter sw = new StringWriter();
+        //     PrintWriter pw = new PrintWriter(sw);
+        //     TraceClassVisitor tcv = new TraceClassVisitor(pw);
+        //     ClassReader cr2 = new ClassReader(bytes);
+        //     cr2.accept(tcv, 0 /* flags */);
+        //     String msg = "\n" + t.getClass().getCanonicalName();
+        //     if (t.getMessage() != null) {
+        //       msg += ": " + t.getMessage();
+        //     }
+        //     msg = msg + "\nBytecode dump:\n" + sw.toString();
+        //  // Re-throw exception with new message
+        //     RuntimeException ex = new RuntimeException(msg, t);
+        //     throw ex;
+        } finally {
         }
     }
 
diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java
index 65b910b..e3deeb3 100644
--- a/wifi/java/android/net/wifi/WifiStateMachine.java
+++ b/wifi/java/android/net/wifi/WifiStateMachine.java
@@ -79,7 +79,6 @@
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.regex.Pattern;
 
@@ -1297,14 +1296,14 @@
      */
     private boolean shouldDisableCoexistenceMode() {
         if (mBluetoothHeadset == null) return true;
-        Set<BluetoothDevice> devices = mBluetoothHeadset.getConnectedDevices();
+        List<BluetoothDevice> devices = mBluetoothHeadset.getConnectedDevices();
         return (devices.size() != 0 ? false : true);
     }
 
     private void checkIsBluetoothPlaying() {
         boolean isBluetoothPlaying = false;
         if (mBluetoothA2dp != null) {
-            Set<BluetoothDevice> connected = mBluetoothA2dp.getConnectedDevices();
+            List<BluetoothDevice> connected = mBluetoothA2dp.getConnectedDevices();
 
             for (BluetoothDevice device : connected) {
                 if (mBluetoothA2dp.isA2dpPlaying(device)) {