Merge "Overlay java files Issue 3370836" into honeycomb
diff --git a/api/11.xml b/api/11.xml
index d79baf0..232f62c4 100644
--- a/api/11.xml
+++ b/api/11.xml
@@ -238854,7 +238854,7 @@
 >
 </method>
 <method name="onRemoteAdapterConnected"
- return="void"
+ return="boolean"
  abstract="false"
  native="false"
  synchronized="false"
@@ -240832,7 +240832,7 @@
 >
 </method>
 <method name="onRemoteAdapterConnected"
- return="void"
+ return="boolean"
  abstract="false"
  native="false"
  synchronized="false"
diff --git a/api/current.xml b/api/current.xml
index d79baf0..8b9f381 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -225876,6 +225876,16 @@
  visibility="public"
 >
 </field>
+<field name="systemUiVisibility"
+ type="int"
+ transient="false"
+ volatile="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="token"
  type="android.os.IBinder"
  transient="false"
@@ -238854,7 +238864,7 @@
 >
 </method>
 <method name="onRemoteAdapterConnected"
- return="void"
+ return="boolean"
  abstract="false"
  native="false"
  synchronized="false"
@@ -240832,7 +240842,7 @@
 >
 </method>
 <method name="onRemoteAdapterConnected"
- return="void"
+ return="boolean"
  abstract="false"
  native="false"
  synchronized="false"
diff --git a/core/java/android/bluetooth/BluetoothA2dp.java b/core/java/android/bluetooth/BluetoothA2dp.java
index 61b4303..9246a10 100644
--- a/core/java/android/bluetooth/BluetoothA2dp.java
+++ b/core/java/android/bluetooth/BluetoothA2dp.java
@@ -50,15 +50,18 @@
      * profile.
      *
      * <p>This intent will have 3 extras:
-     * {@link #EXTRA_STATE} - The current state of the profile.
-     * {@link #EXTRA_PREVIOUS_STATE}- The previous state of the profile
-     * {@link BluetoothDevice#EXTRA_DEVICE} - The remote device.
+     * <ul>
+     *   <li> {@link #EXTRA_STATE} - The current state of the profile. </li>
+     *   <li> {@link #EXTRA_PREVIOUS_STATE}- The previous state of the profile.</li>
+     *   <li> {@link BluetoothDevice#EXTRA_DEVICE} - The remote device. </li>
+     * </ul>
      *
-     * {@link #EXTRA_STATE} or {@link #EXTRA_PREVIOUS_STATE} can be any of
+     * <p>{@link #EXTRA_STATE} or {@link #EXTRA_PREVIOUS_STATE} can be any of
      * {@link #STATE_DISCONNECTED}, {@link #STATE_CONNECTING},
      * {@link #STATE_CONNECTED}, {@link #STATE_DISCONNECTING}.
      *
-     * <p>Requires {@link android.Manifest.permission#BLUETOOTH} to receive.
+     * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission to
+     * receive.
      */
     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
     public static final String ACTION_CONNECTION_STATE_CHANGED =
@@ -69,14 +72,17 @@
      * profile.
      *
      * <p>This intent will have 3 extras:
-     * {@link #EXTRA_STATE} - The current state of the profile.
-     * {@link #EXTRA_PREVIOUS_STATE}- The previous state of the profile
-     * {@link BluetoothDevice#EXTRA_DEVICE} - The remote device.
+     * <ul>
+     *   <li> {@link #EXTRA_STATE} - The current state of the profile. </li>
+     *   <li> {@link #EXTRA_PREVIOUS_STATE}- The previous state of the profile. </li>
+     *   <li> {@link BluetoothDevice#EXTRA_DEVICE} - The remote device. </li>
+     * </ul>
      *
-     * {@link #EXTRA_STATE} or {@link #EXTRA_PREVIOUS_STATE} can be any of
+     * <p>{@link #EXTRA_STATE} or {@link #EXTRA_PREVIOUS_STATE} can be any of
      * {@link #STATE_PLAYING}, {@link #STATE_NOT_PLAYING},
      *
-     * <p>Requires {@link android.Manifest.permission#BLUETOOTH} to receive.
+     * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission to
+     * receive.
      */
     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
     public static final String ACTION_PLAYING_STATE_CHANGED =
@@ -258,7 +264,7 @@
     /**
      * Check if A2DP profile is streaming music.
      *
-     * <p>Requires {@link android.Manifest.permission#BLUETOOTH}
+     * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
      *
      * @param device BluetoothDevice device
      */
@@ -281,11 +287,12 @@
      *
      * <p> This API will return false in scenarios like the A2DP
      * device is not in connected state etc. When this API returns,
-     * true, it is guaranteed that {@link #ACTION_SINK_STATE_CHANGED}
+     * true, it is guaranteed that {@link #ACTION_CONNECTION_STATE_CHANGED}
      * intent will be broadcasted with the state. Users can get the
      * state of the A2DP device from this intent.
      *
      * <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN}
+     * permission.
      *
      * @param device Remote A2DP sink
      * @return false on immediate error,
diff --git a/core/java/android/bluetooth/BluetoothDevice.java b/core/java/android/bluetooth/BluetoothDevice.java
index 24217d7..254e2f8 100644
--- a/core/java/android/bluetooth/BluetoothDevice.java
+++ b/core/java/android/bluetooth/BluetoothDevice.java
@@ -748,6 +748,15 @@
      * outgoing connection to this remote device on given channel.
      * <p>The remote device will be authenticated and communication on this
      * socket will be encrypted.
+     * <p> Use this socket only if an authenticated socket link is possible.
+     * Authentication refers to the authentication of the link key to
+     * prevent man-in-the-middle type of attacks.
+     * For example, for Bluetooth 2.1 devices, if any of the devices does not
+     * have an input and output capability or just has the ability to
+     * display a numeric key, a secure socket connection is not possible.
+     * In such a case, use {#link createInsecureRfcommSocket}.
+     * For more details, refer to the Security Model section 5.2 (vol 3) of
+     * Bluetooth Core Specification version 2.1 + EDR.
      * <p>Use {@link BluetoothSocket#connect} to initiate the outgoing
      * connection.
      * <p>Valid RFCOMM channels are in range 1 to 30.
@@ -775,6 +784,15 @@
      * determine which channel to connect to.
      * <p>The remote device will be authenticated and communication on this
      * socket will be encrypted.
+     * <p> Use this socket only if an authenticated socket link is possible.
+     * Authentication refers to the authentication of the link key to
+     * prevent man-in-the-middle type of attacks.
+     * For example, for Bluetooth 2.1 devices, if any of the devices does not
+     * have an input and output capability or just has the ability to
+     * display a numeric key, a secure socket connection is not possible.
+     * In such a case, use {#link createInsecureRfcommSocketToServiceRecord}.
+     * For more details, refer to the Security Model section 5.2 (vol 3) of
+     * Bluetooth Core Specification version 2.1 + EDR.
      * <p>Hint: If you are connecting to a Bluetooth serial board then try
      * using the well-known SPP UUID 00001101-0000-1000-8000-00805F9B34FB.
      * However if you are connecting to an Android peer then please generate
diff --git a/core/java/android/bluetooth/BluetoothHeadset.java b/core/java/android/bluetooth/BluetoothHeadset.java
index a7e4518..fa55520 100644
--- a/core/java/android/bluetooth/BluetoothHeadset.java
+++ b/core/java/android/bluetooth/BluetoothHeadset.java
@@ -52,15 +52,17 @@
      * profile.
      *
      * <p>This intent will have 3 extras:
-     * {@link #EXTRA_STATE} - The current state of the profile.
-     * {@link #EXTRA_PREVIOUS_STATE}- The previous state of the profile
-     * {@link BluetoothDevice#EXTRA_DEVICE} - The remote device.
-     *
-     * {@link #EXTRA_STATE} or {@link #EXTRA_PREVIOUS_STATE} can be any of
+     * <ul>
+     *   <li> {@link #EXTRA_STATE} - The current state of the profile. </li>
+     *   <li> {@link #EXTRA_PREVIOUS_STATE}- The previous state of the profile. </li>
+     *   <li> {@link BluetoothDevice#EXTRA_DEVICE} - The remote device. </li>
+     * </ul>
+     * <p>{@link #EXTRA_STATE} or {@link #EXTRA_PREVIOUS_STATE} can be any of
      * {@link #STATE_DISCONNECTED}, {@link #STATE_CONNECTING},
      * {@link #STATE_CONNECTED}, {@link #STATE_DISCONNECTING}.
      *
-     * <p>Requires {@link android.Manifest.permission#BLUETOOTH} to receive.
+     * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission to
+     * receive.
      */
     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
     public static final String ACTION_CONNECTION_STATE_CHANGED =
@@ -71,14 +73,16 @@
      * A2DP profile.
      *
      * <p>This intent will have 3 extras:
-     * {@link #EXTRA_STATE} - The current state of the profile.
-     * {@link #EXTRA_PREVIOUS_STATE}- The previous state of the profile
-     * {@link BluetoothDevice#EXTRA_DEVICE} - The remote device.
-     *
-     * {@link #EXTRA_STATE} or {@link #EXTRA_PREVIOUS_STATE} can be any of
+     * <ul>
+     *   <li> {@link #EXTRA_STATE} - The current state of the profile. </li>
+     *   <li> {@link #EXTRA_PREVIOUS_STATE}- The previous state of the profile. </li>
+     *   <li> {@link BluetoothDevice#EXTRA_DEVICE} - The remote device. </li>
+     * </ul>
+     * <p>{@link #EXTRA_STATE} or {@link #EXTRA_PREVIOUS_STATE} can be any of
      * {@link #STATE_AUDIO_CONNECTED}, {@link #STATE_AUDIO_DISCONNECTED},
      *
-     * <p>Requires {@link android.Manifest.permission#BLUETOOTH} to receive.
+     * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission
+     * to receive.
      */
     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
     public static final String ACTION_AUDIO_STATE_CHANGED =
@@ -90,29 +94,33 @@
      * vendor-specific event.
      *
      * <p>This intent will have 4 extras and 1 category.
-     * {@link BluetoothDevice#EXTRA_DEVICE} - The remote Bluetooth Device
-     * {@link #EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_CMD} - The vendor specific
-     *                                                    command
-     * {@link #EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_CMD_TYPE} - The AT command
-     *                                                         type.
-     * Can be one of  {@link #AT_CMD_TYPE_READ}, {@link #AT_CMD_TYPE_TEST},
-     * or {@link #AT_CMD_TYPE_SET}, {@link #AT_CMD_TYPE_BASIC},
-     * {@link #AT_CMD_TYPE_ACTION}.
+     * <ul>
+     *  <li> {@link BluetoothDevice#EXTRA_DEVICE} - The remote Bluetooth Device
+     *       </li>
+     *  <li> {@link #EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_CMD} - The vendor
+     *       specific command </li>
+     *  <li> {@link #EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_CMD_TYPE} - The AT
+     *       command type which can be one of  {@link #AT_CMD_TYPE_READ},
+     *       {@link #AT_CMD_TYPE_TEST}, or {@link #AT_CMD_TYPE_SET},
+     *       {@link #AT_CMD_TYPE_BASIC},{@link #AT_CMD_TYPE_ACTION}. </li>
+     *  <li> {@link #EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_ARGS} - Command
+     *       arguments. </li>
+     * </ul>
      *
-     * {@link #EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_ARGS} - Command arguments.
-     *
-     * The category is the Company ID of the vendor defining the
+     *<p> The category is the Company ID of the vendor defining the
      * vendor-specific command. {@link BluetoothAssignedNumbers}
      *
      * For example, for Plantronics specific events
      * Category will be {@link #VENDOR_SPECIFIC_HEADSET_EVENT_COMPANY_ID_CATEGORY}.55
      *
      * <p> For example, an AT+XEVENT=foo,3 will get translated into
-     * EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_CMD = +XEVENT
-     * EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_CMD_TYPE = AT_CMD_TYPE_SET
-     * EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_ARGS = foo, 3
-     *
-     * <p>Requires {@link android.Manifest.permission#BLUETOOTH} to receive.
+     * <ul>
+     *   <li> EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_CMD = +XEVENT </li>
+     *   <li> EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_CMD_TYPE = AT_CMD_TYPE_SET </li>
+     *   <li> EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_ARGS = foo, 3 </li>
+     * </ul>
+     * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission
+     * to receive.
      */
     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
     public static final String ACTION_VENDOR_SPECIFIC_HEADSET_EVENT =
@@ -184,7 +192,7 @@
             "android.bluetooth.headset.intent.category.companyid";
 
     /**
-     * Headset state when SCO audio is not connected
+     * Headset state when SCO audio is not connected.
      * This state can be one of
      * {@link #EXTRA_STATE} or {@link #EXTRA_PREVIOUS_STATE} of
      * {@link #ACTION_AUDIO_STATE_CHANGED} intent.
@@ -192,7 +200,7 @@
     public static final int STATE_AUDIO_DISCONNECTED = 10;
 
     /**
-     * Headset state when SCO audio is connecting
+     * Headset state when SCO audio is connecting.
      * This state can be one of
      * {@link #EXTRA_STATE} or {@link #EXTRA_PREVIOUS_STATE} of
      * {@link #ACTION_AUDIO_STATE_CHANGED} intent.
@@ -200,7 +208,7 @@
     public static final int STATE_AUDIO_CONNECTING = 11;
 
     /**
-     * Headset state when SCO audio is connected
+     * Headset state when SCO audio is connected.
      * This state can be one of
      * {@link #EXTRA_STATE} or {@link #EXTRA_PREVIOUS_STATE} of
      * {@link #ACTION_AUDIO_STATE_CHANGED} intent.
@@ -410,7 +418,7 @@
      * Stop Bluetooth Voice Recognition mode, and shut down the
      * Bluetooth audio path.
      *
-     * <p>Requires {@link android.Manifest.permission#BLUETOOTH}
+     * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
      *
      * @param device Bluetooth headset
      * @return false if there is no headset connected
@@ -433,7 +441,7 @@
     /**
      * Check if Bluetooth SCO audio is connected.
      *
-     * <p>Requires {@link android.Manifest.permission#BLUETOOTH}
+     * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
      *
      * @param device Bluetooth headset
      * @return true if SCO is connected,
@@ -674,26 +682,6 @@
         return false;
     }
 
-    /**
-     * Send a AT command message to the headset.
-     * @param device Remote Bluetooth Device
-     * @param cmd The String to send.
-     * @hide
-     */
-    public void sendAtCommand(BluetoothDevice device, String command) {
-        if (DBG) log("sendAtCommand()");
-        if (mService != null && isEnabled() && isValidDevice(device)) {
-            try {
-                mService.sendAtCommand(device, command);
-            } catch (RemoteException e) {
-                Log.e(TAG, e.toString());
-            }
-        } else {
-            Log.w(TAG, "Proxy not attached to service");
-            if (DBG) Log.d(TAG, Log.getStackTraceString(new Throwable()));
-        }
-    }
-
     private ServiceConnection mConnection = new ServiceConnection() {
         public void onServiceConnected(ComponentName className, IBinder service) {
             if (DBG) Log.d(TAG, "Proxy object connected");
diff --git a/core/java/android/bluetooth/BluetoothProfile.java b/core/java/android/bluetooth/BluetoothProfile.java
index 3949b26..ef80195d 100644
--- a/core/java/android/bluetooth/BluetoothProfile.java
+++ b/core/java/android/bluetooth/BluetoothProfile.java
@@ -105,6 +105,7 @@
      * from this intent.
      *
      * <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN}
+     * permission.
      *
      * @param device Remote Bluetooth Device
      * @return false on immediate error,
@@ -132,6 +133,7 @@
      * two scenarios.
      *
      * <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN}
+     * permission.
      *
      * @param device Remote Bluetooth Device
      * @return false on immediate error,
@@ -145,20 +147,20 @@
      *
      * <p> Return the set of devices which are in state {@link #STATE_CONNECTED}
      *
-     * <p>Requires {@link android.Manifest.permission#BLUETOOTH}
+     * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
      *
      * @return List of devices. The list will be empty on error.
      */
     public List<BluetoothDevice> getConnectedDevices();
 
     /**
-     * Get a set of devices that match any of the given connection
+     * Get a list of devices that match any of the given connection
      * states.
      *
-     * <p> If none of devices match any of the given states,
-     * an empty set will be returned.
+     * <p> If none of the devices match any of the given states,
+     * an empty list will be returned.
      *
-     * <p>Requires {@link android.Manifest.permission#BLUETOOTH}
+     * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
      *
      * @param states Array of states. States can be one of
      *              {@link #STATE_CONNECTED}, {@link #STATE_CONNECTING},
@@ -170,7 +172,7 @@
     /**
      * Get the current connection state of the profile
      *
-     * <p>Requires {@link android.Manifest.permission#BLUETOOTH}
+     * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
      *
      * @param device Remote bluetooth device.
      * @return State of the profile connection. One of
@@ -187,6 +189,7 @@
      * {@link #PRIORITY_OFF},
      *
      * <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN}
+     * permission.
      *
      * @param device Paired bluetooth device
      * @param priority
@@ -202,7 +205,7 @@
      * {@link #PRIORITY_AUTO_CONNECT}, {@link #PRIORITY_OFF},
      * {@link #PRIORITY_ON}, {@link #PRIORITY_UNDEFINED}
      *
-     * <p>Requires {@link android.Manifest.permission#BLUETOOTH}
+     * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
      *
      * @param device Bluetooth device
      * @return priority of the device
diff --git a/core/java/android/bluetooth/IBluetoothHeadset.aidl b/core/java/android/bluetooth/IBluetoothHeadset.aidl
index 41f63b2..273cda7 100644
--- a/core/java/android/bluetooth/IBluetoothHeadset.aidl
+++ b/core/java/android/bluetooth/IBluetoothHeadset.aidl
@@ -50,6 +50,4 @@
 
     boolean startScoUsingVirtualVoiceCall(in BluetoothDevice device);
     boolean stopScoUsingVirtualVoiceCall(in BluetoothDevice device);
-
-    void sendAtCommand(in BluetoothDevice device, String urc);
 }
diff --git a/core/java/android/os/storage/IObbActionListener.java b/core/java/android/os/storage/IObbActionListener.java
index d6fa58a..35da4b0 100644
--- a/core/java/android/os/storage/IObbActionListener.java
+++ b/core/java/android/os/storage/IObbActionListener.java
@@ -112,7 +112,8 @@
                     _data.writeString(filename);
                     _data.writeInt(nonce);
                     _data.writeInt(status);
-                    mRemote.transact(Stub.TRANSACTION_onObbResult, _data, _reply, 0);
+                    mRemote.transact(Stub.TRANSACTION_onObbResult, _data, _reply,
+                            android.os.IBinder.FLAG_ONEWAY);
                     _reply.readException();
                 } finally {
                     _reply.recycle();
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 65d2e11..3ed7549 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -4750,7 +4750,7 @@
     }
 
     void performCollectViewAttributes(int visibility) {
-        if ((visibility & VISIBILITY_MASK) == VISIBLE) {
+        if ((visibility & VISIBILITY_MASK) == VISIBLE && mAttachInfo != null) {
             if ((mViewFlags & KEEP_SCREEN_ON) == KEEP_SCREEN_ON) {
                 mAttachInfo.mKeepScreenOn = true;
             }
@@ -8249,7 +8249,6 @@
             // If we got here, we're recreating it. Mark it as such to ensure that
             // we copy in child display lists into ours in drawChild()
             mRecreateDisplayList = true;
-
             if (mDisplayList == null) {
                 mDisplayList = mAttachInfo.mHardwareRenderer.createDisplayList(this);
                 // If we're creating a new display list, make sure our parent gets invalidated
@@ -8287,6 +8286,9 @@
 
                 mDisplayList.end();
             }
+        } else {
+            mPrivateFlags |= DRAWN | DRAWING_CACHE_VALID;
+            mPrivateFlags &= ~DIRTY_MASK;
         }
 
         return mDisplayList;
@@ -10805,6 +10807,7 @@
     /**
      */
     public void dispatchSystemUiVisibilityChanged(int visibility) {
+        mSystemUiVisibility = visibility;
         if (mOnSystemUiVisibilityChangeListener != null) {
             mOnSystemUiVisibilityChangeListener.onSystemUiVisibilityChange(visibility);
         }
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java
index f198c46..9e5b23c 100644
--- a/core/java/android/view/ViewGroup.java
+++ b/core/java/android/view/ViewGroup.java
@@ -3497,7 +3497,8 @@
                         ((ViewRoot) parent).invalidate();
                         parent = null;
                     } else if (view != null) {
-                        if ((mPrivateFlags & DRAWN) == DRAWN) {
+                        if ((view.mPrivateFlags & DRAWN) == DRAWN ||
+                                (view.mPrivateFlags & DRAWING_CACHE_VALID) == DRAWING_CACHE_VALID) {
                             view.mPrivateFlags &= ~DRAWING_CACHE_VALID;
                             view.mPrivateFlags |= DIRTY;
                             parent = view.mParent;
@@ -3594,7 +3595,8 @@
             ViewDebug.trace(this, ViewDebug.HierarchyTraceType.INVALIDATE_CHILD_IN_PARENT);
         }
 
-        if ((mPrivateFlags & DRAWN) == DRAWN) {
+        if ((mPrivateFlags & DRAWN) == DRAWN ||
+                (mPrivateFlags & DRAWING_CACHE_VALID) == DRAWING_CACHE_VALID) {
             if ((mGroupFlags & (FLAG_OPTIMIZE_INVALIDATE | FLAG_ANIMATION_DONE)) !=
                         FLAG_OPTIMIZE_INVALIDATE) {
                 dirty.offset(location[CHILD_LEFT_INDEX] - mScrollX,
diff --git a/core/java/android/view/ViewRoot.java b/core/java/android/view/ViewRoot.java
index b0553c6..042095a 100644
--- a/core/java/android/view/ViewRoot.java
+++ b/core/java/android/view/ViewRoot.java
@@ -903,8 +903,9 @@
             attachInfo.mSystemUiVisibility = 0;
             attachInfo.mHasSystemUiListeners = false;
             host.dispatchCollectViewAttributes(0);
-            if (attachInfo.mKeepScreenOn != oldScreenOn ||
-                    attachInfo.mSystemUiVisibility != oldVis) {
+            if (attachInfo.mKeepScreenOn != oldScreenOn
+                    || attachInfo.mSystemUiVisibility != oldVis
+                    || attachInfo.mHasSystemUiListeners) {
                 params = lp;
             }
         }
@@ -987,8 +988,10 @@
                     if (attachInfo.mKeepScreenOn) {
                         params.flags |= WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
                     }
-                    params.systemUiVisibility = attachInfo.mSystemUiVisibility;
-                    params.hasSystemUiListeners = attachInfo.mHasSystemUiListeners;
+                    params.subtreeSystemUiVisibility = attachInfo.mSystemUiVisibility;
+                    params.hasSystemUiListeners = attachInfo.mHasSystemUiListeners
+                            || params.subtreeSystemUiVisibility != 0
+                            || params.systemUiVisibility != 0;
                 }
                 if (DEBUG_LAYOUT) {
                     Log.i(TAG, "host=w:" + host.getMeasuredWidth() + ", h:" +
@@ -2854,6 +2857,9 @@
 
     public void handleDispatchSystemUiVisibilityChanged(int visibility) {
         if (mView == null) return;
+        if (mAttachInfo != null) {
+            mAttachInfo.mSystemUiVisibility = visibility;
+        }
         mView.dispatchSystemUiVisibilityChanged(visibility);
     }
 
diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java
index 491a79f..c26fa93 100644
--- a/core/java/android/view/WindowManager.java
+++ b/core/java/android/view/WindowManager.java
@@ -953,11 +953,20 @@
 
         /**
          * Control the visibility of the status bar.
-         * @hide
+         *
+         * @see View#STATUS_BAR_VISIBLE
+         * @see View#STATUS_BAR_HIDDEN
          */
         public int systemUiVisibility;
 
         /**
+         * @hide
+         * The ui visibility as requested by the views in this hierarchy.
+         * the combined value should be systemUiVisibility | subtreeSystemUiVisibility.
+         */
+        public int subtreeSystemUiVisibility;
+
+        /**
          * Get callbacks about the system ui visibility changing.
          * 
          * TODO: Maybe there should be a bitfield of optional callbacks that we need.
@@ -1046,6 +1055,7 @@
             TextUtils.writeToParcel(mTitle, out, parcelableFlags);
             out.writeInt(screenOrientation);
             out.writeInt(systemUiVisibility);
+            out.writeInt(subtreeSystemUiVisibility);
             out.writeInt(hasSystemUiListeners ? 1 : 0);
         }
         
@@ -1083,6 +1093,7 @@
             mTitle = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
             screenOrientation = in.readInt();
             systemUiVisibility = in.readInt();
+            subtreeSystemUiVisibility = in.readInt();
             hasSystemUiListeners = in.readInt() != 0;
         }
     
@@ -1212,8 +1223,10 @@
                 changes |= SCREEN_ORIENTATION_CHANGED;
             }
 
-            if (systemUiVisibility != o.systemUiVisibility) {
+            if (systemUiVisibility != o.systemUiVisibility
+                    || subtreeSystemUiVisibility != o.subtreeSystemUiVisibility) {
                 systemUiVisibility = o.systemUiVisibility;
+                subtreeSystemUiVisibility = o.subtreeSystemUiVisibility;
                 changes |= SYSTEM_UI_VISIBILITY_CHANGED;
             }
 
@@ -1298,6 +1311,10 @@
                 sb.append(" sysui=0x");
                 sb.append(Integer.toHexString(systemUiVisibility));
             }
+            if (subtreeSystemUiVisibility != 0) {
+                sb.append(" vsysui=0x");
+                sb.append(Integer.toHexString(subtreeSystemUiVisibility));
+            }
             if (hasSystemUiListeners) {
                 sb.append(" sysuil=");
                 sb.append(hasSystemUiListeners);
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index ca45e68..1d5d08f 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -4087,7 +4087,9 @@
                 df = mScrollFilter;
             }
             canvas.setDrawFilter(df);
-            int content = nativeDraw(canvas, color, extras, true);
+            // XXX: Revisit splitting content.  Right now it causes a
+            // synchronization problem with layers.
+            int content = nativeDraw(canvas, color, extras, false);
             canvas.setDrawFilter(null);
             if (content != 0) {
                 mWebViewCore.sendMessage(EventHub.SPLIT_PICTURE_SET, content, 0);
@@ -8073,7 +8075,7 @@
                     + " mLastCursorTime=" + mLastCursorTime
                     + " handled=" + keyHandled);
         }
-        if (keyHandled == false || mHeightCanMeasure == false) {
+        if (keyHandled == false) {
             return keyHandled;
         }
         Rect contentCursorRingBounds = nativeGetCursorRingBounds();
@@ -8082,6 +8084,9 @@
         // set last touch so that context menu related functions will work
         mLastTouchX = (viewCursorRingBounds.left + viewCursorRingBounds.right) / 2;
         mLastTouchY = (viewCursorRingBounds.top + viewCursorRingBounds.bottom) / 2;
+        if (mHeightCanMeasure == false) {
+            return keyHandled;
+        }
         Rect visRect = new Rect();
         calcOurVisibleRect(visRect);
         Rect outset = new Rect(visRect);
diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java
index 6d66bbc..631ba0c 100644
--- a/core/java/android/widget/AbsListView.java
+++ b/core/java/android/widget/AbsListView.java
@@ -5289,12 +5289,15 @@
     /**
      * Called back when the adapter connects to the RemoteViewsService.
      */
-    public void onRemoteAdapterConnected() {
+    public boolean onRemoteAdapterConnected() {
         if (mRemoteAdapter != mAdapter) {
             setAdapter(mRemoteAdapter);
+            return false;
         } else if (mRemoteAdapter != null) {
             mRemoteAdapter.superNotifyDataSetChanged();
+            return true;
         }
+        return false;
     }
 
     /**
diff --git a/core/java/android/widget/AdapterViewAnimator.java b/core/java/android/widget/AdapterViewAnimator.java
index b505c85..d596339 100644
--- a/core/java/android/widget/AdapterViewAnimator.java
+++ b/core/java/android/widget/AdapterViewAnimator.java
@@ -54,6 +54,12 @@
     int mWhichChild = 0;
 
     /**
+     * The index of the child to restore after the asynchronous connection from the
+     * RemoteViewsAdapter has been.
+     */
+    private int mRestoreWhichChild = -1;
+
+    /**
      * Whether or not the first view(s) should be animated in
      */
     boolean mAnimateFirstTime = true;
@@ -780,7 +786,15 @@
         // set mWhichChild
         mWhichChild = ss.whichChild;
 
-        setDisplayedChild(mWhichChild);
+        // When using RemoteAdapters, the async connection process can lead to
+        // onRestoreInstanceState to be called before setAdapter(), so we need to save the previous
+        // values to restore the list position after we connect, and can skip setting the displayed
+        // child until then.
+        if (mRemoteViewsAdapter != null && mAdapter == null) {
+            mRestoreWhichChild = mWhichChild;
+        } else {
+            setDisplayedChild(mWhichChild);
+        }
     }
 
     /**
@@ -957,12 +971,21 @@
     /**
      * Called back when the adapter connects to the RemoteViewsService.
      */
-    public void onRemoteAdapterConnected() {
+    public boolean onRemoteAdapterConnected() {
         if (mRemoteViewsAdapter != mAdapter) {
             setAdapter(mRemoteViewsAdapter);
+
+            // Restore the previous position (see onRestoreInstanceState)
+            if (mRestoreWhichChild > -1) {
+                setDisplayedChild(mRestoreWhichChild);
+                mRestoreWhichChild = -1;
+            }
+            return false;
         } else if (mRemoteViewsAdapter != null) {
             mRemoteViewsAdapter.superNotifyDataSetChanged();
+            return true;
         }
+        return false;
     }
 
     /**
@@ -995,7 +1018,7 @@
 
     @Override
     protected void onDetachedFromWindow() {
-        mAdapter = null;
+        setAdapter(null);
         super.onDetachedFromWindow();
     }
 }
diff --git a/core/java/android/widget/RemoteViewsAdapter.java b/core/java/android/widget/RemoteViewsAdapter.java
index f329a3e..2457f7f 100644
--- a/core/java/android/widget/RemoteViewsAdapter.java
+++ b/core/java/android/widget/RemoteViewsAdapter.java
@@ -48,11 +48,11 @@
     private static final String TAG = "RemoteViewsAdapter";
 
     // The max number of items in the cache
-    private static final int sDefaultCacheSize = 36;
+    private static final int sDefaultCacheSize = 50;
     // The delay (in millis) to wait until attempting to unbind from a service after a request.
     // This ensures that we don't stay continually bound to the service and that it can be destroyed
     // if we need the memory elsewhere in the system.
-    private static final int sUnbindServiceDelay = 5000;
+    private static final int sUnbindServiceDelay = 1000;
     // Type defs for controlling different messages across the main and worker message queues
     private static final int sDefaultMessageType = 0;
     private static final int sUnbindServiceMessageType = 1;
@@ -65,6 +65,9 @@
     private WeakReference<RemoteAdapterConnectionCallback> mCallback;
     private FixedSizeRemoteViewsCache mCache;
 
+    // A flag to determine whether we should notify data set changed after we connect
+    private boolean mNotifyDataSetChangedAfterOnServiceConnected = false;
+
     // The set of requested views that are to be notified when the associated RemoteViews are
     // loaded.
     private RemoteViewsFrameLayoutRefSet mRequestedViews;
@@ -79,7 +82,10 @@
      * are actually connected to/disconnected from their actual services.
      */
     public interface RemoteAdapterConnectionCallback {
-        public void onRemoteAdapterConnected();
+        /**
+         * @return whether the adapter was set or not.
+         */
+        public boolean onRemoteAdapterConnected();
 
         public void onRemoteAdapterDisconnected();
     }
@@ -93,7 +99,8 @@
      */
     private static class RemoteViewsAdapterServiceConnection extends
             IRemoteViewsAdapterConnection.Stub {
-        private boolean mConnected;
+        private boolean mIsConnected;
+        private boolean mIsConnecting;
         private WeakReference<RemoteViewsAdapter> mAdapter;
         private IRemoteViewsFactory mRemoteViewsFactory;
 
@@ -101,27 +108,58 @@
             mAdapter = new WeakReference<RemoteViewsAdapter>(adapter);
         }
 
-        public void onServiceConnected(IBinder service) {
-            mRemoteViewsFactory = IRemoteViewsFactory.Stub.asInterface(service);
-            mConnected = true;
+        public synchronized void bind(Context context, int appWidgetId, Intent intent) {
+            if (!mIsConnecting) {
+                try {
+                    final AppWidgetManager mgr = AppWidgetManager.getInstance(context);
+                    mgr.bindRemoteViewsService(appWidgetId, intent, asBinder());
+                    mIsConnecting = true;
+                } catch (Exception e) {
+                    Log.e("RemoteViewsAdapterServiceConnection", "bind(): " + e.getMessage());
+                    mIsConnecting = false;
+                    mIsConnected = false;
+                }
+            }
+        }
 
-            // Queue up work that we need to do for the callback to run
+        public synchronized void unbind(Context context, int appWidgetId, Intent intent) {
+            try {
+                final AppWidgetManager mgr = AppWidgetManager.getInstance(context);
+                mgr.unbindRemoteViewsService(appWidgetId, intent);
+                mIsConnecting = false;
+            } catch (Exception e) {
+                Log.e("RemoteViewsAdapterServiceConnection", "unbind(): " + e.getMessage());
+                mIsConnecting = false;
+                mIsConnected = false;
+            }
+        }
+
+        public synchronized void onServiceConnected(IBinder service) {
+            mRemoteViewsFactory = IRemoteViewsFactory.Stub.asInterface(service);
+
+            // Remove any deferred unbind messages
             final RemoteViewsAdapter adapter = mAdapter.get();
             if (adapter == null) return;
+
+            // Queue up work that we need to do for the callback to run
             adapter.mWorkerQueue.post(new Runnable() {
                 @Override
                 public void run() {
-                    // Call back to the service to notify that the data set changed
-                    if (adapter.mServiceConnection.isConnected()) {
+                    if (adapter.mNotifyDataSetChangedAfterOnServiceConnected) {
+                        // Handle queued notifyDataSetChanged() if necessary
+                        adapter.onNotifyDataSetChanged();
+                    } else {
                         IRemoteViewsFactory factory =
                             adapter.mServiceConnection.getRemoteViewsFactory();
                         try {
-                            // call back to the factory
-                            factory.onDataSetChanged();
+                            if (!factory.isCreated()) {
+                                // We only call onDataSetChanged() if this is the factory was just
+                                // create in response to this bind
+                                factory.onDataSetChanged();
+                            }
                         } catch (Exception e) {
                             Log.e(TAG, "Error notifying factory of data set changed in " +
                                         "onServiceConnected(): " + e.getMessage());
-                            e.printStackTrace();
 
                             // Return early to prevent anything further from being notified
                             // (effectively nothing has changed)
@@ -130,13 +168,16 @@
 
                         // Request meta data so that we have up to date data when calling back to
                         // the remote adapter callback
-                        adapter.updateMetaData();
+                        adapter.updateTemporaryMetaData();
 
-                        // Post a runnable to call back to the view to notify it that we have
-                        // connected
+                        // Notify the host that we've connected
                         adapter.mMainQueue.post(new Runnable() {
                             @Override
                             public void run() {
+                                synchronized (adapter.mCache) {
+                                    adapter.mCache.commitTemporaryMetaData();
+                                }
+
                                 final RemoteAdapterConnectionCallback callback =
                                     adapter.mCallback.get();
                                 if (callback != null) {
@@ -145,35 +186,44 @@
                             }
                         });
                     }
+
+                    // Enqueue unbind message
+                    adapter.enqueueDeferredUnbindServiceMessage();
+                    mIsConnected = true;
+                    mIsConnecting = false;
                 }
             });
         }
 
-        public void onServiceDisconnected() {
-            mConnected = false;
+        public synchronized void onServiceDisconnected() {
+            mIsConnected = false;
+            mIsConnecting = false;
             mRemoteViewsFactory = null;
 
+            // Clear the main/worker queues
             final RemoteViewsAdapter adapter = mAdapter.get();
             if (adapter == null) return;
             
-            // Clear the main/worker queues
-            adapter.mMainQueue.removeMessages(sUnbindServiceMessageType);
-            adapter.mMainQueue.removeMessages(sDefaultMessageType);
-            adapter.mWorkerQueue.removeMessages(sDefaultMessageType);
+            adapter.mMainQueue.post(new Runnable() {
+                @Override
+                public void run() {
+                    // Dequeue any unbind messages
+                    adapter.mMainQueue.removeMessages(sUnbindServiceMessageType);
 
-            final RemoteAdapterConnectionCallback callback = adapter.mCallback.get();
-            if (callback != null) {
-                callback.onRemoteAdapterDisconnected();
-            }
-            adapter.mCache.reset();
+                    final RemoteAdapterConnectionCallback callback = adapter.mCallback.get();
+                    if (callback != null) {
+                        callback.onRemoteAdapterDisconnected();
+                    }
+                }
+            });
         }
 
-        public IRemoteViewsFactory getRemoteViewsFactory() {
+        public synchronized IRemoteViewsFactory getRemoteViewsFactory() {
             return mRemoteViewsFactory;
         }
 
-        public boolean isConnected() {
-            return mConnected;
+        public synchronized boolean isConnected() {
+            return mIsConnected;
         }
     }
 
@@ -270,7 +320,6 @@
         int count;
         int viewTypeCount;
         boolean hasStableIds;
-        boolean isDataDirty;
 
         // Used to determine how to construct loading views.  If a loading view is not specified
         // by the user, then we try and load the first view, and use its height as the height for
@@ -280,22 +329,31 @@
         int mFirstViewHeight;
 
         // A mapping from type id to a set of unique type ids
-        private Map<Integer, Integer> mTypeIdIndexMap;
+        private final HashMap<Integer, Integer> mTypeIdIndexMap = new HashMap<Integer, Integer>();
 
         public RemoteViewsMetaData() {
             reset();
         }
 
+        public void set(RemoteViewsMetaData d) {
+            synchronized (d) {
+                count = d.count;
+                viewTypeCount = d.viewTypeCount;
+                hasStableIds = d.hasStableIds;
+                setLoadingViewTemplates(d.mUserLoadingView, d.mFirstView);
+            }
+        }
+
         public void reset() {
             count = 0;
+
             // by default there is at least one dummy view type
             viewTypeCount = 1;
             hasStableIds = true;
-            isDataDirty = false;
             mUserLoadingView = null;
             mFirstView = null;
             mFirstViewHeight = 0;
-            mTypeIdIndexMap = new HashMap<Integer, Integer>();
+            mTypeIdIndexMap.clear();
         }
 
         public void setLoadingViewTemplates(RemoteViews loadingView, RemoteViews firstView) {
@@ -385,6 +443,7 @@
 
         // The meta data related to all the RemoteViews, ie. count, is stable, etc.
         private RemoteViewsMetaData mMetaData;
+        private RemoteViewsMetaData mTemporaryMetaData;
 
         // The cache/mapping of position to RemoteViewsMetaData.  This set is guaranteed to be
         // greater than or equal to the set of RemoteViews.
@@ -426,6 +485,7 @@
             mPreloadLowerBound = 0;
             mPreloadUpperBound = -1;
             mMetaData = new RemoteViewsMetaData();
+            mTemporaryMetaData = new RemoteViewsMetaData();
             mIndexMetaData = new HashMap<Integer, RemoteViewsIndexMetaData>();
             mIndexRemoteViews = new HashMap<Integer, RemoteViews>();
             mRequestedIndices = new HashSet<Integer>();
@@ -461,6 +521,9 @@
         public RemoteViewsMetaData getMetaData() {
             return mMetaData;
         }
+        public RemoteViewsMetaData getTemporaryMetaData() {
+            return mTemporaryMetaData;
+        }
         public RemoteViews getRemoteViewsAt(int position) {
             if (mIndexRemoteViews.containsKey(position)) {
                 return mIndexRemoteViews.get(position);
@@ -474,6 +537,14 @@
             return null;
         }
 
+        public void commitTemporaryMetaData() {
+            synchronized (mTemporaryMetaData) {
+                synchronized (mMetaData) {
+                    mMetaData.set(mTemporaryMetaData);
+                }
+            }
+        }
+
         private int getRemoteViewsBitmapMemoryUsage() {
             // Calculate the memory usage of all the RemoteViews bitmaps being cached
             int mem = 0;
@@ -505,12 +576,12 @@
                 mLoadIndices.add(position);
             }
         }
-        public void queuePositionsToBePreloadedFromRequestedPosition(int position) {
+        public boolean queuePositionsToBePreloadedFromRequestedPosition(int position) {
             // Check if we need to preload any items
             if (mPreloadLowerBound <= position && position <= mPreloadUpperBound) {
                 int center = (mPreloadUpperBound + mPreloadLowerBound) / 2;
                 if (Math.abs(position - center) < mMaxCountSlack) {
-                    return;
+                    return false;
                 }
             }
 
@@ -537,6 +608,7 @@
                 // But remove all the indices that have already been loaded and are cached
                 mLoadIndices.removeAll(mIndexRemoteViews.keySet());
             }
+            return true;
         }
         public int getNextIndexToLoad() {
             // We try and prioritize items that have been requested directly, instead
@@ -616,100 +688,114 @@
         mWorkerQueue.post(new Runnable() {
             @Override
             public void run() {
-                // Get the next index to load
-                int position = -1;
-                synchronized (mCache) {
-                    position = mCache.getNextIndexToLoad();
-                }
-                if (position > -1) {
-                    // Load the item, and notify any existing RemoteViewsFrameLayouts
-                    updateRemoteViews(position);
+                if (mServiceConnection.isConnected()) {
+                    // Get the next index to load
+                    int position = -1;
+                    synchronized (mCache) {
+                        position = mCache.getNextIndexToLoad();
+                    }
+                    if (position > -1) {
+                        // Load the item, and notify any existing RemoteViewsFrameLayouts
+                        updateRemoteViews(position);
 
-                    // Queue up for the next one to load
-                    loadNextIndexInBackground();
+                        // Queue up for the next one to load
+                        loadNextIndexInBackground();
+                    } else {
+                        // No more items to load, so queue unbind
+                        enqueueDeferredUnbindServiceMessage();
+                    }
                 }
             }
         });
     }
 
-    private void updateMetaData() {
-        if (mServiceConnection.isConnected()) {
-            try {
-                IRemoteViewsFactory factory = mServiceConnection.getRemoteViewsFactory();
+    private void processException(String method, Exception e) {
+        Log.e("RemoteViewsAdapter", "Error in " + method + ": " + e.getMessage());
 
-                // get the properties/first view (so that we can use it to
-                // measure our dummy views)
-                boolean hasStableIds = factory.hasStableIds();
-                int viewTypeCount = factory.getViewTypeCount();
-                int count = factory.getCount();
-                RemoteViews loadingView = factory.getLoadingView();
-                RemoteViews firstView = null;
-                if ((count > 0) && (loadingView == null)) {
-                    firstView = factory.getViewAt(0);
-                }
-                final RemoteViewsMetaData metaData = mCache.getMetaData();
-                synchronized (metaData) {
-                    metaData.hasStableIds = hasStableIds;
-                    metaData.viewTypeCount = viewTypeCount + 1;
-                    metaData.count = count;
-                    metaData.setLoadingViewTemplates(loadingView, firstView);
-                }
-            } catch (Exception e) {
-                // print the error
-                Log.e(TAG, "Error in requestMetaData(): " + e.getMessage());
-
-                // reset any members after the failed call
-                final RemoteViewsMetaData metaData = mCache.getMetaData();
-                synchronized (metaData) {
-                    metaData.reset();
-                }
+        // If we encounter a crash when updating, we should reset the metadata & cache and trigger
+        // a notifyDataSetChanged to update the widget accordingly
+        final RemoteViewsMetaData metaData = mCache.getMetaData();
+        synchronized (metaData) {
+            metaData.reset();
+        }
+        synchronized (mCache) {
+            mCache.reset();
+        }
+        mMainQueue.post(new Runnable() {
+            @Override
+            public void run() {
+                superNotifyDataSetChanged();
             }
+        });
+    }
+
+    private void updateTemporaryMetaData() {
+        IRemoteViewsFactory factory = mServiceConnection.getRemoteViewsFactory();
+
+        try {
+            // get the properties/first view (so that we can use it to
+            // measure our dummy views)
+            boolean hasStableIds = factory.hasStableIds();
+            int viewTypeCount = factory.getViewTypeCount();
+            int count = factory.getCount();
+            RemoteViews loadingView = factory.getLoadingView();
+            RemoteViews firstView = null;
+            if ((count > 0) && (loadingView == null)) {
+                firstView = factory.getViewAt(0);
+            }
+            final RemoteViewsMetaData tmpMetaData = mCache.getTemporaryMetaData();
+            synchronized (tmpMetaData) {
+                tmpMetaData.hasStableIds = hasStableIds;
+                // We +1 because the base view type is the loading view
+                tmpMetaData.viewTypeCount = viewTypeCount + 1;
+                tmpMetaData.count = count;
+                tmpMetaData.setLoadingViewTemplates(loadingView, firstView);
+            }
+        } catch (Exception e) {
+            processException("updateMetaData", e);
         }
     }
 
     private void updateRemoteViews(final int position) {
-        if (mServiceConnection.isConnected()) {
-            IRemoteViewsFactory factory = mServiceConnection.getRemoteViewsFactory();
+        if (!mServiceConnection.isConnected()) return;
+        IRemoteViewsFactory factory = mServiceConnection.getRemoteViewsFactory();
 
-            // Load the item information from the remote service
-            RemoteViews remoteViews = null;
-            long itemId = 0;
-            try {
-                remoteViews = factory.getViewAt(position);
-                itemId = factory.getItemId(position);
-            } catch (Throwable t) {
-                Log.e(TAG, "Error in updateRemoteViews(" + position + "): " + t.getMessage());
-                t.printStackTrace();
+        // Load the item information from the remote service
+        RemoteViews remoteViews = null;
+        long itemId = 0;
+        try {
+            remoteViews = factory.getViewAt(position);
+            itemId = factory.getItemId(position);
+        } catch (Exception e) {
+            Log.e(TAG, "Error in updateRemoteViews(" + position + "): " + e.getMessage());
 
-                // Return early to prevent additional work in re-centering the view cache, and
-                // swapping from the loading view
-                return;
-            }
+            // Return early to prevent additional work in re-centering the view cache, and
+            // swapping from the loading view
+            return;
+        }
 
-            if (remoteViews == null) {
-                // If a null view was returned, we break early to prevent it from getting
-                // into our cache and causing problems later. The effect is that the child  at this
-                // position will remain as a loading view until it is updated.
-                Log.e(TAG, "Error in updateRemoteViews(" + position + "): " + " null RemoteViews " +
-                        "returned from RemoteViewsFactory.");
-                return;
-            }
-            synchronized (mCache) {
-                // Cache the RemoteViews we loaded
-                mCache.insert(position, remoteViews, itemId);
+        if (remoteViews == null) {
+            // If a null view was returned, we break early to prevent it from getting
+            // into our cache and causing problems later. The effect is that the child  at this
+            // position will remain as a loading view until it is updated.
+            Log.e(TAG, "Error in updateRemoteViews(" + position + "): " + " null RemoteViews " +
+                    "returned from RemoteViewsFactory.");
+            return;
+        }
+        synchronized (mCache) {
+            // Cache the RemoteViews we loaded
+            mCache.insert(position, remoteViews, itemId);
 
-                // Notify all the views that we have previously returned for this index that
-                // there is new data for it.
-                final RemoteViews rv = remoteViews;
-                final int typeId = mCache.getMetaDataAt(position).typeId;
-                mMainQueue.post(new Runnable() {
-                    @Override
-                    public void run() {
-                        mRequestedViews.notifyOnRemoteViewsLoaded(position, rv, typeId);
-                        enqueueDeferredUnbindServiceMessage();
-                    }
-                });
-            }
+            // Notify all the views that we have previously returned for this index that
+            // there is new data for it.
+            final RemoteViews rv = remoteViews;
+            final int typeId = mCache.getMetaDataAt(position).typeId;
+            mMainQueue.post(new Runnable() {
+                @Override
+                public void run() {
+                    mRequestedViews.notifyOnRemoteViewsLoaded(position, rv, typeId);
+                }
+            });
         }
     }
 
@@ -718,7 +804,6 @@
     }
 
     public int getCount() {
-        requestBindService();
         final RemoteViewsMetaData metaData = mCache.getMetaData();
         synchronized (metaData) {
             return metaData.count;
@@ -731,7 +816,6 @@
     }
 
     public long getItemId(int position) {
-        requestBindService();
         synchronized (mCache) {
             if (mCache.containsMetaDataAt(position)) {
                 return mCache.getMetaDataAt(position).itemId;
@@ -741,7 +825,6 @@
     }
 
     public int getItemViewType(int position) {
-        requestBindService();
         int typeId = 0;
         synchronized (mCache) {
             if (mCache.containsMetaDataAt(position)) {
@@ -773,13 +856,23 @@
     }
 
     public View getView(int position, View convertView, ViewGroup parent) {
-        requestBindService();
-        if (mServiceConnection.isConnected()) {
-            // "Request" an index so that we can queue it for loading, initiate subsequent
-            // preloading, etc.
-            synchronized (mCache) {
+        // "Request" an index so that we can queue it for loading, initiate subsequent
+        // preloading, etc.
+        synchronized (mCache) {
+            boolean isInCache = mCache.containsRemoteViewAt(position);
+            boolean isConnected = mServiceConnection.isConnected();
+            boolean hasNewItems = false;
+
+            if (!isConnected) {
+                // Requesting bind service will trigger a super.notifyDataSetChanged(), which will
+                // in turn trigger another request to getView()
+                requestBindService();
+            } else {
                 // Queue up other indices to be preloaded based on this position
-                mCache.queuePositionsToBePreloadedFromRequestedPosition(position);
+                hasNewItems = mCache.queuePositionsToBePreloadedFromRequestedPosition(position);
+            }
+
+            if (isInCache) {
                 View convertViewChild = null;
                 int convertViewTypeId = 0;
                 RemoteViewsFrameLayout layout = null;
@@ -792,51 +885,47 @@
 
                 // Second, we try and retrieve the RemoteViews from the cache, returning a loading
                 // view and queueing it to be loaded if it has not already been loaded.
-                if (mCache.containsRemoteViewAt(position)) {
-                    Context context = parent.getContext();
-                    RemoteViews rv = mCache.getRemoteViewsAt(position);
-                    int typeId = mCache.getMetaDataAt(position).typeId;
+                Context context = parent.getContext();
+                RemoteViews rv = mCache.getRemoteViewsAt(position);
+                int typeId = mCache.getMetaDataAt(position).typeId;
 
-                    // Reuse the convert view where possible
-                    if (layout != null) {
-                        if (convertViewTypeId == typeId) {
-                            rv.reapply(context, convertViewChild);
-                            return layout;
-                        }
+                // Reuse the convert view where possible
+                if (layout != null) {
+                    if (convertViewTypeId == typeId) {
+                        rv.reapply(context, convertViewChild);
+                        return layout;
                     }
-
-                    // Otherwise, create a new view to be returned
-                    View newView = rv.apply(context, parent);
-                    newView.setTagInternal(com.android.internal.R.id.rowTypeId, new Integer(typeId));
-                    if (layout != null) {
-                        layout.removeAllViews();
-                    } else {
-                        layout = new RemoteViewsFrameLayout(context);
-                    }
-                    layout.addView(newView);
-                    return layout;
+                    layout.removeAllViews();
                 } else {
-                    // If the cache does not have the RemoteViews at this position, then create a
-                    // loading view and queue the actual position to be loaded in the background
-                    RemoteViewsFrameLayout loadingView = null;
-                    final RemoteViewsMetaData metaData = mCache.getMetaData();
-                    synchronized (metaData) {
-                        loadingView = metaData.createLoadingView(position, convertView, parent);
-                    }
-
-                    mRequestedViews.add(position, loadingView);
-                    mCache.queueRequestedPositionToLoad(position);
-                    loadNextIndexInBackground();
-
-                    return loadingView;
+                    layout = new RemoteViewsFrameLayout(context);
                 }
+
+                // Otherwise, create a new view to be returned
+                View newView = rv.apply(context, parent);
+                newView.setTagInternal(com.android.internal.R.id.rowTypeId, new Integer(typeId));
+                layout.addView(newView);
+                if (hasNewItems) loadNextIndexInBackground();
+
+                return layout;
+            } else {
+                // If the cache does not have the RemoteViews at this position, then create a
+                // loading view and queue the actual position to be loaded in the background
+                RemoteViewsFrameLayout loadingView = null;
+                final RemoteViewsMetaData metaData = mCache.getMetaData();
+                synchronized (metaData) {
+                    loadingView = metaData.createLoadingView(position, convertView, parent);
+                }
+
+                mRequestedViews.add(position, loadingView);
+                mCache.queueRequestedPositionToLoad(position);
+                loadNextIndexInBackground();
+
+                return loadingView;
             }
         }
-        return new View(parent.getContext());
     }
 
     public int getViewTypeCount() {
-        requestBindService();
         final RemoteViewsMetaData metaData = mCache.getMetaData();
         synchronized (metaData) {
             return metaData.viewTypeCount;
@@ -844,7 +933,6 @@
     }
 
     public boolean hasStableIds() {
-        requestBindService();
         final RemoteViewsMetaData metaData = mCache.getMetaData();
         synchronized (metaData) {
             return metaData.hasStableIds;
@@ -855,44 +943,67 @@
         return getCount() <= 0;
     }
 
-    public void notifyDataSetChanged() {
-        mWorkerQueue.post(new Runnable() {
+
+    private void onNotifyDataSetChanged() {
+        // Complete the actual notifyDataSetChanged() call initiated earlier
+        IRemoteViewsFactory factory = mServiceConnection.getRemoteViewsFactory();
+        try {
+            factory.onDataSetChanged();
+        } catch (Exception e) {
+            Log.e(TAG, "Error in updateNotifyDataSetChanged(): " + e.getMessage());
+
+            // Return early to prevent from further being notified (since nothing has
+            // changed)
+            return;
+        }
+
+        // Flush the cache so that we can reload new items from the service
+        synchronized (mCache) {
+            mCache.reset();
+        }
+
+        // Re-request the new metadata (only after the notification to the factory)
+        updateTemporaryMetaData();
+
+        // Propagate the notification back to the base adapter
+        mMainQueue.post(new Runnable() {
             @Override
             public void run() {
-                // Complete the actual notifyDataSetChanged() call initiated earlier
-                if (mServiceConnection.isConnected()) {
-                    IRemoteViewsFactory factory = mServiceConnection.getRemoteViewsFactory();
-                    try {
-                        factory.onDataSetChanged();
-                    } catch (Exception e) {
-                        Log.e(TAG, "Error in updateNotifyDataSetChanged(): " + e.getMessage());
-
-                        // Return early to prevent from further being notified (since nothing has
-                        // changed)
-                        return;
-                    }
-                }
-
-                // Flush the cache so that we can reload new items from the service
                 synchronized (mCache) {
-                    mCache.reset();
+                    mCache.commitTemporaryMetaData();
                 }
 
-                // Re-request the new metadata (only after the notification to the factory)
-                updateMetaData();
-
-                // Propagate the notification back to the base adapter
-                mMainQueue.post(new Runnable() {
-                    @Override
-                    public void run() {
-                        superNotifyDataSetChanged();
-                    }
-                });
+                superNotifyDataSetChanged();
+                enqueueDeferredUnbindServiceMessage();
             }
         });
 
-        // Note: we do not call super.notifyDataSetChanged() until the RemoteViewsFactory has had
-        // a chance to update itself and return new meta data associated with the new data.
+        // Reset the notify flagflag
+        mNotifyDataSetChangedAfterOnServiceConnected = false;
+    }
+
+    public void notifyDataSetChanged() {
+        // Dequeue any unbind messages
+        mMainQueue.removeMessages(sUnbindServiceMessageType);
+
+        // If we are not connected, queue up the notifyDataSetChanged to be handled when we do
+        // connect
+        if (!mServiceConnection.isConnected()) {
+            if (mNotifyDataSetChangedAfterOnServiceConnected) {
+                return;
+            }
+
+            mNotifyDataSetChangedAfterOnServiceConnected = true;
+            requestBindService();
+            return;
+        }
+
+        mWorkerQueue.post(new Runnable() {
+            @Override
+            public void run() {
+                onNotifyDataSetChanged();
+            }
+        });
     }
 
     void superNotifyDataSetChanged() {
@@ -904,9 +1015,8 @@
         boolean result = false;
         switch (msg.what) {
         case sUnbindServiceMessageType:
-            final AppWidgetManager mgr = AppWidgetManager.getInstance(mContext);
             if (mServiceConnection.isConnected()) {
-                mgr.unbindRemoteViewsService(mAppWidgetId, mIntent);
+                mServiceConnection.unbind(mContext, mAppWidgetId, mIntent);
             }
             result = true;
             break;
@@ -917,20 +1027,19 @@
     }
 
     private void enqueueDeferredUnbindServiceMessage() {
-        /* Temporarily disable delayed service unbinding
         // Remove any existing deferred-unbind messages
         mMainQueue.removeMessages(sUnbindServiceMessageType);
         mMainQueue.sendEmptyMessageDelayed(sUnbindServiceMessageType, sUnbindServiceDelay);
-        */
     }
 
     private boolean requestBindService() {
         // Try binding the service (which will start it if it's not already running)
         if (!mServiceConnection.isConnected()) {
-            final AppWidgetManager mgr = AppWidgetManager.getInstance(mContext);
-            mgr.bindRemoteViewsService(mAppWidgetId, mIntent, mServiceConnection.asBinder());
+            mServiceConnection.bind(mContext, mAppWidgetId, mIntent);
         }
 
+        // Remove any existing deferred-unbind messages
+        mMainQueue.removeMessages(sUnbindServiceMessageType);
         return mServiceConnection.isConnected();
     }
 }
diff --git a/core/java/android/widget/RemoteViewsService.java b/core/java/android/widget/RemoteViewsService.java
index e5a3de2..fb2c416 100644
--- a/core/java/android/widget/RemoteViewsService.java
+++ b/core/java/android/widget/RemoteViewsService.java
@@ -17,11 +17,11 @@
 package android.widget;
 
 import java.util.HashMap;
-import java.util.Map;
 
 import android.app.Service;
 import android.content.Intent;
 import android.os.IBinder;
+import android.util.Log;
 import android.util.Pair;
 
 import com.android.internal.widget.IRemoteViewsFactory;
@@ -35,8 +35,13 @@
 
     private static final String LOG_TAG = "RemoteViewsService";
 
-    // multimap implementation for reference counting
-    private HashMap<Intent.FilterComparison, Pair<RemoteViewsFactory, Integer>> mRemoteViewFactories;
+    // Used for reference counting of RemoteViewsFactories
+    // Because we are now unbinding when we are not using the Service (to allow them to be
+    // reclaimed), the references to the factories that are created need to be stored and used when
+    // the service is restarted (in response to user input for example).  When the process is
+    // destroyed, so is this static cache of RemoteViewsFactories.
+    private static final HashMap<Intent.FilterComparison, RemoteViewsFactory> mRemoteViewFactories =
+            new HashMap<Intent.FilterComparison, RemoteViewsFactory>();
     private final Object mLock = new Object();
 
     /**
@@ -126,9 +131,13 @@
      * A private proxy class for the private IRemoteViewsFactory interface through the
      * public RemoteViewsFactory interface.
      */
-    private class RemoteViewsFactoryAdapter extends IRemoteViewsFactory.Stub {
-        public RemoteViewsFactoryAdapter(RemoteViewsFactory factory) {
+    private static class RemoteViewsFactoryAdapter extends IRemoteViewsFactory.Stub {
+        public RemoteViewsFactoryAdapter(RemoteViewsFactory factory, boolean isCreated) {
             mFactory = factory;
+            mIsCreated = isCreated;
+        }
+        public synchronized boolean isCreated() {
+            return mIsCreated;
         }
         public synchronized void onDataSetChanged() {
             mFactory.onDataSetChanged();
@@ -155,58 +164,28 @@
         }
 
         private RemoteViewsFactory mFactory;
-    }
-
-    public RemoteViewsService() {
-        mRemoteViewFactories =
-                new HashMap<Intent.FilterComparison, Pair<RemoteViewsFactory, Integer>>();
+        private boolean mIsCreated;
     }
 
     @Override
     public IBinder onBind(Intent intent) {
         synchronized (mLock) {
-            // increment the reference count to the particular factory associated with this intent
             Intent.FilterComparison fc = new Intent.FilterComparison(intent);
-            Pair<RemoteViewsFactory, Integer> factoryRef = null;
             RemoteViewsFactory factory = null;
+            boolean isCreated = false;
             if (!mRemoteViewFactories.containsKey(fc)) {
                 factory = onGetViewFactory(intent);
-                factoryRef = new Pair<RemoteViewsFactory, Integer>(factory, 1);
-                mRemoteViewFactories.put(fc, factoryRef);
+                mRemoteViewFactories.put(fc, factory);
                 factory.onCreate();
+                isCreated = false;
             } else {
-                Pair<RemoteViewsFactory, Integer> oldFactoryRef = mRemoteViewFactories.get(fc);
-                factory = oldFactoryRef.first;
-                int newRefCount = oldFactoryRef.second.intValue() + 1;
-                factoryRef = new Pair<RemoteViewsFactory, Integer>(oldFactoryRef.first, newRefCount);
-                mRemoteViewFactories.put(fc, factoryRef);
+                factory = mRemoteViewFactories.get(fc);
+                isCreated = true;
             }
-            return new RemoteViewsFactoryAdapter(factory);
+            return new RemoteViewsFactoryAdapter(factory, isCreated);
         }
     }
 
-    @Override
-    public boolean onUnbind(Intent intent) {
-        synchronized (mLock) {
-            Intent.FilterComparison fc = new Intent.FilterComparison(intent);
-            if (mRemoteViewFactories.containsKey(fc)) {
-                // this alleviates the user's responsibility of having to clear all factories
-                Pair<RemoteViewsFactory, Integer> oldFactoryRef =
-                        mRemoteViewFactories.get(fc);
-                int newRefCount = oldFactoryRef.second.intValue() - 1;
-                if (newRefCount <= 0) {
-                    oldFactoryRef.first.onDestroy();
-                    mRemoteViewFactories.remove(fc);
-                } else {
-                    Pair<RemoteViewsFactory, Integer> factoryRef =
-                            new Pair<RemoteViewsFactory, Integer>(oldFactoryRef.first, newRefCount);
-                    mRemoteViewFactories.put(fc, factoryRef);
-                }
-            }
-        }
-        return super.onUnbind(intent);
-    }
-
     /**
      * To be implemented by the derived service to generate appropriate factories for
      * the data.
diff --git a/core/java/com/android/internal/statusbar/IStatusBarService.aidl b/core/java/com/android/internal/statusbar/IStatusBarService.aidl
index d83a534..d1ea52e 100644
--- a/core/java/com/android/internal/statusbar/IStatusBarService.aidl
+++ b/core/java/com/android/internal/statusbar/IStatusBarService.aidl
@@ -30,7 +30,6 @@
     void setIcon(String slot, String iconPackage, int iconId, int iconLevel);
     void setIconVisibility(String slot, boolean visible);
     void removeIcon(String slot);
-    void setActiveWindowIsFullscreen(boolean fullscreen);
     void setMenuKeyVisible(boolean visible);
     void setIMEButtonVisible(in IBinder token, boolean visible);
 
diff --git a/core/java/com/android/internal/widget/IRemoteViewsFactory.aidl b/core/java/com/android/internal/widget/IRemoteViewsFactory.aidl
index ae9900c..60eca00 100644
--- a/core/java/com/android/internal/widget/IRemoteViewsFactory.aidl
+++ b/core/java/com/android/internal/widget/IRemoteViewsFactory.aidl
@@ -27,5 +27,6 @@
     int getViewTypeCount();
     long getItemId(int position);
     boolean hasStableIds();
+    boolean isCreated();
 }
 
diff --git a/core/res/res/drawable-hdpi/checkbox_disabled_off_holo_dark.png b/core/res/res/drawable-hdpi/checkbox_disabled_off_holo_dark.png
deleted file mode 100644
index 6de74a7..0000000
--- a/core/res/res/drawable-hdpi/checkbox_disabled_off_holo_dark.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-hdpi/checkbox_disabled_off_holo_light.png b/core/res/res/drawable-hdpi/checkbox_disabled_off_holo_light.png
deleted file mode 100644
index a0e201d..0000000
--- a/core/res/res/drawable-hdpi/checkbox_disabled_off_holo_light.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-hdpi/checkbox_disabled_on_holo_dark.png b/core/res/res/drawable-hdpi/checkbox_disabled_on_holo_dark.png
deleted file mode 100644
index 9bb69c4..0000000
--- a/core/res/res/drawable-hdpi/checkbox_disabled_on_holo_dark.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-hdpi/checkbox_disabled_on_holo_light.png b/core/res/res/drawable-hdpi/checkbox_disabled_on_holo_light.png
deleted file mode 100644
index bffc5aa..0000000
--- a/core/res/res/drawable-hdpi/checkbox_disabled_on_holo_light.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-hdpi/checkbox_focused_off_holo_dark.png b/core/res/res/drawable-hdpi/checkbox_focused_off_holo_dark.png
deleted file mode 100644
index bbe04b6..0000000
--- a/core/res/res/drawable-hdpi/checkbox_focused_off_holo_dark.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-hdpi/checkbox_focused_off_holo_light.png b/core/res/res/drawable-hdpi/checkbox_focused_off_holo_light.png
deleted file mode 100644
index 62f1efa..0000000
--- a/core/res/res/drawable-hdpi/checkbox_focused_off_holo_light.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-hdpi/checkbox_focused_on_holo_dark.png b/core/res/res/drawable-hdpi/checkbox_focused_on_holo_dark.png
deleted file mode 100644
index c4026a8..0000000
--- a/core/res/res/drawable-hdpi/checkbox_focused_on_holo_dark.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-hdpi/checkbox_focused_on_holo_light.png b/core/res/res/drawable-hdpi/checkbox_focused_on_holo_light.png
deleted file mode 100644
index 409aa3e..0000000
--- a/core/res/res/drawable-hdpi/checkbox_focused_on_holo_light.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-hdpi/checkbox_normal_off_holo_dark.png b/core/res/res/drawable-hdpi/checkbox_normal_off_holo_dark.png
deleted file mode 100644
index 10f1bc4..0000000
--- a/core/res/res/drawable-hdpi/checkbox_normal_off_holo_dark.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-hdpi/checkbox_normal_off_holo_light.png b/core/res/res/drawable-hdpi/checkbox_normal_off_holo_light.png
deleted file mode 100644
index 20a1efa..0000000
--- a/core/res/res/drawable-hdpi/checkbox_normal_off_holo_light.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-hdpi/checkbox_normal_on_holo_dark.png b/core/res/res/drawable-hdpi/checkbox_normal_on_holo_dark.png
deleted file mode 100644
index 0a10ec8..0000000
--- a/core/res/res/drawable-hdpi/checkbox_normal_on_holo_dark.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-hdpi/checkbox_normal_on_holo_light.png b/core/res/res/drawable-hdpi/checkbox_normal_on_holo_light.png
deleted file mode 100644
index 34b53ee..0000000
--- a/core/res/res/drawable-hdpi/checkbox_normal_on_holo_light.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-hdpi/checkbox_pressed_off_holo_dark.png b/core/res/res/drawable-hdpi/checkbox_pressed_off_holo_dark.png
deleted file mode 100644
index 7f14620..0000000
--- a/core/res/res/drawable-hdpi/checkbox_pressed_off_holo_dark.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-hdpi/checkbox_pressed_off_holo_light.png b/core/res/res/drawable-hdpi/checkbox_pressed_off_holo_light.png
deleted file mode 100644
index cabf936..0000000
--- a/core/res/res/drawable-hdpi/checkbox_pressed_off_holo_light.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-hdpi/checkbox_pressed_on_holo_dark.png b/core/res/res/drawable-hdpi/checkbox_pressed_on_holo_dark.png
deleted file mode 100644
index bcddb31..0000000
--- a/core/res/res/drawable-hdpi/checkbox_pressed_on_holo_dark.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-hdpi/checkbox_pressed_on_holo_light.png b/core/res/res/drawable-hdpi/checkbox_pressed_on_holo_light.png
deleted file mode 100644
index 84160e5..0000000
--- a/core/res/res/drawable-hdpi/checkbox_pressed_on_holo_light.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-hdpi/stat_notify_call_mute.png b/core/res/res/drawable-hdpi/stat_notify_call_mute.png
index b0f7990..048f56e 100755
--- a/core/res/res/drawable-hdpi/stat_notify_call_mute.png
+++ b/core/res/res/drawable-hdpi/stat_notify_call_mute.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/stat_notify_car_mode.png b/core/res/res/drawable-hdpi/stat_notify_car_mode.png
index e700d79..76dd2ae 100644
--- a/core/res/res/drawable-hdpi/stat_notify_car_mode.png
+++ b/core/res/res/drawable-hdpi/stat_notify_car_mode.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/stat_notify_chat.png b/core/res/res/drawable-hdpi/stat_notify_chat.png
index 71ea8de..b2e65c6 100644
--- a/core/res/res/drawable-hdpi/stat_notify_chat.png
+++ b/core/res/res/drawable-hdpi/stat_notify_chat.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/stat_notify_disk_full.png b/core/res/res/drawable-hdpi/stat_notify_disk_full.png
index 66e7380..9956fad 100755
--- a/core/res/res/drawable-hdpi/stat_notify_disk_full.png
+++ b/core/res/res/drawable-hdpi/stat_notify_disk_full.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/stat_notify_email_generic.png b/core/res/res/drawable-hdpi/stat_notify_email_generic.png
index bc5fcab..4ea619c 100644
--- a/core/res/res/drawable-hdpi/stat_notify_email_generic.png
+++ b/core/res/res/drawable-hdpi/stat_notify_email_generic.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/stat_notify_error.png b/core/res/res/drawable-hdpi/stat_notify_error.png
index b3a18b3..598094f 100755
--- a/core/res/res/drawable-hdpi/stat_notify_error.png
+++ b/core/res/res/drawable-hdpi/stat_notify_error.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/stat_notify_gmail.png b/core/res/res/drawable-hdpi/stat_notify_gmail.png
index ea8beae..7028ea7 100644
--- a/core/res/res/drawable-hdpi/stat_notify_gmail.png
+++ b/core/res/res/drawable-hdpi/stat_notify_gmail.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/stat_notify_missed_call.png b/core/res/res/drawable-hdpi/stat_notify_missed_call.png
index 3c19c93..b0f7a6e 100644
--- a/core/res/res/drawable-hdpi/stat_notify_missed_call.png
+++ b/core/res/res/drawable-hdpi/stat_notify_missed_call.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/stat_notify_sdcard.png b/core/res/res/drawable-hdpi/stat_notify_sdcard.png
index dd947a5..a916488 100755
--- a/core/res/res/drawable-hdpi/stat_notify_sdcard.png
+++ b/core/res/res/drawable-hdpi/stat_notify_sdcard.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/stat_notify_sdcard_prepare.png b/core/res/res/drawable-hdpi/stat_notify_sdcard_prepare.png
index 4b9b9ca..e267700 100755
--- a/core/res/res/drawable-hdpi/stat_notify_sdcard_prepare.png
+++ b/core/res/res/drawable-hdpi/stat_notify_sdcard_prepare.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/stat_notify_sdcard_usb.png b/core/res/res/drawable-hdpi/stat_notify_sdcard_usb.png
index fb2b26a..233e438 100755
--- a/core/res/res/drawable-hdpi/stat_notify_sdcard_usb.png
+++ b/core/res/res/drawable-hdpi/stat_notify_sdcard_usb.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/stat_notify_sim_toolkit.png b/core/res/res/drawable-hdpi/stat_notify_sim_toolkit.png
index 8865bda..42101077 100755
--- a/core/res/res/drawable-hdpi/stat_notify_sim_toolkit.png
+++ b/core/res/res/drawable-hdpi/stat_notify_sim_toolkit.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/stat_notify_sync.png b/core/res/res/drawable-hdpi/stat_notify_sync.png
index 004cfab..2076c55 100755
--- a/core/res/res/drawable-hdpi/stat_notify_sync.png
+++ b/core/res/res/drawable-hdpi/stat_notify_sync.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/stat_notify_sync_anim0.png b/core/res/res/drawable-hdpi/stat_notify_sync_anim0.png
index 6973fc5..2076c55 100755
--- a/core/res/res/drawable-hdpi/stat_notify_sync_anim0.png
+++ b/core/res/res/drawable-hdpi/stat_notify_sync_anim0.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/stat_notify_sync_error.png b/core/res/res/drawable-hdpi/stat_notify_sync_error.png
index 26b2446..bade508 100755
--- a/core/res/res/drawable-hdpi/stat_notify_sync_error.png
+++ b/core/res/res/drawable-hdpi/stat_notify_sync_error.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/stat_notify_voicemail.png b/core/res/res/drawable-hdpi/stat_notify_voicemail.png
index 5b77846..43fe530 100755
--- a/core/res/res/drawable-hdpi/stat_notify_voicemail.png
+++ b/core/res/res/drawable-hdpi/stat_notify_voicemail.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/stat_notify_wifi_in_range.png b/core/res/res/drawable-hdpi/stat_notify_wifi_in_range.png
index 76034e5..5c42e53 100644
--- a/core/res/res/drawable-hdpi/stat_notify_wifi_in_range.png
+++ b/core/res/res/drawable-hdpi/stat_notify_wifi_in_range.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/stat_sys_adb.png b/core/res/res/drawable-hdpi/stat_sys_adb.png
index f99b780..58c1746 100755
--- a/core/res/res/drawable-hdpi/stat_sys_adb.png
+++ b/core/res/res/drawable-hdpi/stat_sys_adb.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/stat_sys_battery_0.png b/core/res/res/drawable-hdpi/stat_sys_battery_0.png
index 82f2509..160a6f7 100644
--- a/core/res/res/drawable-hdpi/stat_sys_battery_0.png
+++ b/core/res/res/drawable-hdpi/stat_sys_battery_0.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/stat_sys_battery_100.png b/core/res/res/drawable-hdpi/stat_sys_battery_100.png
old mode 100755
new mode 100644
index e49448d..fa1624c
--- a/core/res/res/drawable-hdpi/stat_sys_battery_100.png
+++ b/core/res/res/drawable-hdpi/stat_sys_battery_100.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/stat_sys_battery_charge_anim0.png b/core/res/res/drawable-hdpi/stat_sys_battery_charge_anim0.png
old mode 100755
new mode 100644
index c7464f7..f9f2baf
--- a/core/res/res/drawable-hdpi/stat_sys_battery_charge_anim0.png
+++ b/core/res/res/drawable-hdpi/stat_sys_battery_charge_anim0.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/stat_sys_battery_unknown.png b/core/res/res/drawable-hdpi/stat_sys_battery_unknown.png
old mode 100755
new mode 100644
index dadfe8d..368e7d9
--- a/core/res/res/drawable-hdpi/stat_sys_battery_unknown.png
+++ b/core/res/res/drawable-hdpi/stat_sys_battery_unknown.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/stat_sys_data_usb.png b/core/res/res/drawable-hdpi/stat_sys_data_usb.png
index e916fbb..bdec072 100755
--- a/core/res/res/drawable-hdpi/stat_sys_data_usb.png
+++ b/core/res/res/drawable-hdpi/stat_sys_data_usb.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/stat_sys_gps_on.png b/core/res/res/drawable-hdpi/stat_sys_gps_on.png
index 2ed6082..0d6f622 100644
--- a/core/res/res/drawable-hdpi/stat_sys_gps_on.png
+++ b/core/res/res/drawable-hdpi/stat_sys_gps_on.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/stat_sys_phone_call.png b/core/res/res/drawable-hdpi/stat_sys_phone_call.png
old mode 100644
new mode 100755
index 950713b..9b5f075
--- a/core/res/res/drawable-hdpi/stat_sys_phone_call.png
+++ b/core/res/res/drawable-hdpi/stat_sys_phone_call.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/stat_sys_phone_call_forward.png b/core/res/res/drawable-hdpi/stat_sys_phone_call_forward.png
old mode 100644
new mode 100755
index 07a2e9d..032f8f1
--- a/core/res/res/drawable-hdpi/stat_sys_phone_call_forward.png
+++ b/core/res/res/drawable-hdpi/stat_sys_phone_call_forward.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/stat_sys_phone_call_on_hold.png b/core/res/res/drawable-hdpi/stat_sys_phone_call_on_hold.png
old mode 100644
new mode 100755
index 033a558..5b0a68d
--- a/core/res/res/drawable-hdpi/stat_sys_phone_call_on_hold.png
+++ b/core/res/res/drawable-hdpi/stat_sys_phone_call_on_hold.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/stat_sys_secure.png b/core/res/res/drawable-hdpi/stat_sys_secure.png
index 0889e49..8d24990 100755
--- a/core/res/res/drawable-hdpi/stat_sys_secure.png
+++ b/core/res/res/drawable-hdpi/stat_sys_secure.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/stat_sys_speakerphone.png b/core/res/res/drawable-hdpi/stat_sys_speakerphone.png
index 21f96c4..82c06a9 100755
--- a/core/res/res/drawable-hdpi/stat_sys_speakerphone.png
+++ b/core/res/res/drawable-hdpi/stat_sys_speakerphone.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/stat_sys_throttled.png b/core/res/res/drawable-hdpi/stat_sys_throttled.png
index 58eafc0..bd8323a 100755
--- a/core/res/res/drawable-hdpi/stat_sys_throttled.png
+++ b/core/res/res/drawable-hdpi/stat_sys_throttled.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/stat_sys_vp_phone_call.png b/core/res/res/drawable-hdpi/stat_sys_vp_phone_call.png
old mode 100644
new mode 100755
index dfb3424..83e8ead
--- a/core/res/res/drawable-hdpi/stat_sys_vp_phone_call.png
+++ b/core/res/res/drawable-hdpi/stat_sys_vp_phone_call.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/stat_sys_vp_phone_call_on_hold.png b/core/res/res/drawable-hdpi/stat_sys_vp_phone_call_on_hold.png
old mode 100644
new mode 100755
index 402295b..9731c46
--- a/core/res/res/drawable-hdpi/stat_sys_vp_phone_call_on_hold.png
+++ b/core/res/res/drawable-hdpi/stat_sys_vp_phone_call_on_hold.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/stat_sys_warning.png b/core/res/res/drawable-hdpi/stat_sys_warning.png
index cb8a3d4..2783d89 100755
--- a/core/res/res/drawable-hdpi/stat_sys_warning.png
+++ b/core/res/res/drawable-hdpi/stat_sys_warning.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/checkbox_disabled_off_holo_dark.png b/core/res/res/drawable-mdpi/checkbox_disabled_off_holo_dark.png
deleted file mode 100644
index e1094be..0000000
--- a/core/res/res/drawable-mdpi/checkbox_disabled_off_holo_dark.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-mdpi/checkbox_disabled_off_holo_light.png b/core/res/res/drawable-mdpi/checkbox_disabled_off_holo_light.png
deleted file mode 100644
index c17377c..0000000
--- a/core/res/res/drawable-mdpi/checkbox_disabled_off_holo_light.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-mdpi/checkbox_disabled_on_holo_dark.png b/core/res/res/drawable-mdpi/checkbox_disabled_on_holo_dark.png
deleted file mode 100644
index f2c5290..0000000
--- a/core/res/res/drawable-mdpi/checkbox_disabled_on_holo_dark.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-mdpi/checkbox_disabled_on_holo_light.png b/core/res/res/drawable-mdpi/checkbox_disabled_on_holo_light.png
deleted file mode 100644
index 06bd903..0000000
--- a/core/res/res/drawable-mdpi/checkbox_disabled_on_holo_light.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-mdpi/checkbox_focused_off_holo_dark.png b/core/res/res/drawable-mdpi/checkbox_focused_off_holo_dark.png
deleted file mode 100644
index be624c2..0000000
--- a/core/res/res/drawable-mdpi/checkbox_focused_off_holo_dark.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-mdpi/checkbox_focused_off_holo_light.png b/core/res/res/drawable-mdpi/checkbox_focused_off_holo_light.png
deleted file mode 100644
index 2493ce2..0000000
--- a/core/res/res/drawable-mdpi/checkbox_focused_off_holo_light.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-mdpi/checkbox_focused_on_holo_dark.png b/core/res/res/drawable-mdpi/checkbox_focused_on_holo_dark.png
deleted file mode 100644
index 7cdc1df..0000000
--- a/core/res/res/drawable-mdpi/checkbox_focused_on_holo_dark.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-mdpi/checkbox_focused_on_holo_light.png b/core/res/res/drawable-mdpi/checkbox_focused_on_holo_light.png
deleted file mode 100644
index f977e72..0000000
--- a/core/res/res/drawable-mdpi/checkbox_focused_on_holo_light.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-mdpi/checkbox_normal_off_holo_dark.png b/core/res/res/drawable-mdpi/checkbox_normal_off_holo_dark.png
deleted file mode 100644
index f824f76..0000000
--- a/core/res/res/drawable-mdpi/checkbox_normal_off_holo_dark.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-mdpi/checkbox_normal_off_holo_light.png b/core/res/res/drawable-mdpi/checkbox_normal_off_holo_light.png
deleted file mode 100644
index a76f68c..0000000
--- a/core/res/res/drawable-mdpi/checkbox_normal_off_holo_light.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-mdpi/checkbox_normal_on_holo_dark.png b/core/res/res/drawable-mdpi/checkbox_normal_on_holo_dark.png
deleted file mode 100644
index e4fd418..0000000
--- a/core/res/res/drawable-mdpi/checkbox_normal_on_holo_dark.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-mdpi/checkbox_normal_on_holo_light.png b/core/res/res/drawable-mdpi/checkbox_normal_on_holo_light.png
deleted file mode 100644
index d572ef5..0000000
--- a/core/res/res/drawable-mdpi/checkbox_normal_on_holo_light.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-mdpi/checkbox_pressed_off_holo_dark.png b/core/res/res/drawable-mdpi/checkbox_pressed_off_holo_dark.png
deleted file mode 100644
index 686707e..0000000
--- a/core/res/res/drawable-mdpi/checkbox_pressed_off_holo_dark.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-mdpi/checkbox_pressed_off_holo_light.png b/core/res/res/drawable-mdpi/checkbox_pressed_off_holo_light.png
deleted file mode 100644
index 17dd1da..0000000
--- a/core/res/res/drawable-mdpi/checkbox_pressed_off_holo_light.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-mdpi/checkbox_pressed_on_holo_dark.png b/core/res/res/drawable-mdpi/checkbox_pressed_on_holo_dark.png
deleted file mode 100644
index 8cf2b1b..0000000
--- a/core/res/res/drawable-mdpi/checkbox_pressed_on_holo_dark.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-mdpi/checkbox_pressed_on_holo_light.png b/core/res/res/drawable-mdpi/checkbox_pressed_on_holo_light.png
deleted file mode 100644
index c2df6da..0000000
--- a/core/res/res/drawable-mdpi/checkbox_pressed_on_holo_light.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-mdpi/stat_notify_call_mute.png b/core/res/res/drawable-mdpi/stat_notify_call_mute.png
index 4a3b057..be26065 100644
--- a/core/res/res/drawable-mdpi/stat_notify_call_mute.png
+++ b/core/res/res/drawable-mdpi/stat_notify_call_mute.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/stat_notify_car_mode.png b/core/res/res/drawable-mdpi/stat_notify_car_mode.png
index 3b644d3..60d9202 100644
--- a/core/res/res/drawable-mdpi/stat_notify_car_mode.png
+++ b/core/res/res/drawable-mdpi/stat_notify_car_mode.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/stat_notify_chat.png b/core/res/res/drawable-mdpi/stat_notify_chat.png
index 306d9c5..f98b032 100644
--- a/core/res/res/drawable-mdpi/stat_notify_chat.png
+++ b/core/res/res/drawable-mdpi/stat_notify_chat.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/stat_notify_disk_full.png b/core/res/res/drawable-mdpi/stat_notify_disk_full.png
index 3eebeb8..4e198ef 100755
--- a/core/res/res/drawable-mdpi/stat_notify_disk_full.png
+++ b/core/res/res/drawable-mdpi/stat_notify_disk_full.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/stat_notify_email_generic.png b/core/res/res/drawable-mdpi/stat_notify_email_generic.png
index 1620ad53..a01485e 100644
--- a/core/res/res/drawable-mdpi/stat_notify_email_generic.png
+++ b/core/res/res/drawable-mdpi/stat_notify_email_generic.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/stat_notify_error.png b/core/res/res/drawable-mdpi/stat_notify_error.png
index 1275738..69c02d7 100644
--- a/core/res/res/drawable-mdpi/stat_notify_error.png
+++ b/core/res/res/drawable-mdpi/stat_notify_error.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/stat_notify_gmail.png b/core/res/res/drawable-mdpi/stat_notify_gmail.png
index 4860c34..55bae33 100644
--- a/core/res/res/drawable-mdpi/stat_notify_gmail.png
+++ b/core/res/res/drawable-mdpi/stat_notify_gmail.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/stat_notify_missed_call.png b/core/res/res/drawable-mdpi/stat_notify_missed_call.png
index 7bd5fcd..58030fd 100644
--- a/core/res/res/drawable-mdpi/stat_notify_missed_call.png
+++ b/core/res/res/drawable-mdpi/stat_notify_missed_call.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/stat_notify_sdcard.png b/core/res/res/drawable-mdpi/stat_notify_sdcard.png
index fc0784d..0071bf4 100644
--- a/core/res/res/drawable-mdpi/stat_notify_sdcard.png
+++ b/core/res/res/drawable-mdpi/stat_notify_sdcard.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/stat_notify_sdcard_prepare.png b/core/res/res/drawable-mdpi/stat_notify_sdcard_prepare.png
index 93fad38..c04d70d 100644
--- a/core/res/res/drawable-mdpi/stat_notify_sdcard_prepare.png
+++ b/core/res/res/drawable-mdpi/stat_notify_sdcard_prepare.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/stat_notify_sdcard_usb.png b/core/res/res/drawable-mdpi/stat_notify_sdcard_usb.png
index cda4546..2880934 100644
--- a/core/res/res/drawable-mdpi/stat_notify_sdcard_usb.png
+++ b/core/res/res/drawable-mdpi/stat_notify_sdcard_usb.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/stat_notify_sim_toolkit.png b/core/res/res/drawable-mdpi/stat_notify_sim_toolkit.png
index 8b33a0f..ee7b10c 100755
--- a/core/res/res/drawable-mdpi/stat_notify_sim_toolkit.png
+++ b/core/res/res/drawable-mdpi/stat_notify_sim_toolkit.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/stat_notify_sync.png b/core/res/res/drawable-mdpi/stat_notify_sync.png
index 03ce57a..ef9d4eb 100644
--- a/core/res/res/drawable-mdpi/stat_notify_sync.png
+++ b/core/res/res/drawable-mdpi/stat_notify_sync.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/stat_notify_sync_anim0.png b/core/res/res/drawable-mdpi/stat_notify_sync_anim0.png
index 5481461..ef9d4eb 100644
--- a/core/res/res/drawable-mdpi/stat_notify_sync_anim0.png
+++ b/core/res/res/drawable-mdpi/stat_notify_sync_anim0.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/stat_notify_sync_error.png b/core/res/res/drawable-mdpi/stat_notify_sync_error.png
index f849b50..f55bf58 100644
--- a/core/res/res/drawable-mdpi/stat_notify_sync_error.png
+++ b/core/res/res/drawable-mdpi/stat_notify_sync_error.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/stat_notify_voicemail.png b/core/res/res/drawable-mdpi/stat_notify_voicemail.png
index 636d1cc..b72a07a 100644
--- a/core/res/res/drawable-mdpi/stat_notify_voicemail.png
+++ b/core/res/res/drawable-mdpi/stat_notify_voicemail.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/stat_notify_wifi_in_range.png b/core/res/res/drawable-mdpi/stat_notify_wifi_in_range.png
index 517c515..90dd76e 100644
--- a/core/res/res/drawable-mdpi/stat_notify_wifi_in_range.png
+++ b/core/res/res/drawable-mdpi/stat_notify_wifi_in_range.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/stat_sys_adb.png b/core/res/res/drawable-mdpi/stat_sys_adb.png
index f0fad76..255ce94 100644
--- a/core/res/res/drawable-mdpi/stat_sys_adb.png
+++ b/core/res/res/drawable-mdpi/stat_sys_adb.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/stat_sys_data_usb.png b/core/res/res/drawable-mdpi/stat_sys_data_usb.png
index 2d0da4c..4175b29 100644
--- a/core/res/res/drawable-mdpi/stat_sys_data_usb.png
+++ b/core/res/res/drawable-mdpi/stat_sys_data_usb.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/stat_sys_gps_on.png b/core/res/res/drawable-mdpi/stat_sys_gps_on.png
index df737f29..ab59f7c 100644
--- a/core/res/res/drawable-mdpi/stat_sys_gps_on.png
+++ b/core/res/res/drawable-mdpi/stat_sys_gps_on.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/stat_sys_secure.png b/core/res/res/drawable-mdpi/stat_sys_secure.png
index a632fb2..db73d06 100644
--- a/core/res/res/drawable-mdpi/stat_sys_secure.png
+++ b/core/res/res/drawable-mdpi/stat_sys_secure.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/stat_sys_speakerphone.png b/core/res/res/drawable-mdpi/stat_sys_speakerphone.png
index d0411cf..0673060 100644
--- a/core/res/res/drawable-mdpi/stat_sys_speakerphone.png
+++ b/core/res/res/drawable-mdpi/stat_sys_speakerphone.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/stat_sys_throttled.png b/core/res/res/drawable-mdpi/stat_sys_throttled.png
index bc9b223..28a293b 100644
--- a/core/res/res/drawable-mdpi/stat_sys_throttled.png
+++ b/core/res/res/drawable-mdpi/stat_sys_throttled.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/stat_sys_warning.png b/core/res/res/drawable-mdpi/stat_sys_warning.png
index c0823da..494c96a 100644
--- a/core/res/res/drawable-mdpi/stat_sys_warning.png
+++ b/core/res/res/drawable-mdpi/stat_sys_warning.png
Binary files differ
diff --git a/data/fonts/fonts.mk b/data/fonts/fonts.mk
index faecfee..692ce34 100644
--- a/data/fonts/fonts.mk
+++ b/data/fonts/fonts.mk
@@ -29,4 +29,4 @@
     frameworks/base/data/fonts/DroidSansFallback.ttf:system/fonts/DroidSansFallback.ttf \
     frameworks/base/data/fonts/AndroidClock.ttf:system/fonts/AndroidClock.ttf \
     frameworks/base/data/fonts/AndroidClock_Highlight.ttf:system/fonts/AndroidClock_Highlight.ttf \
-    frameworks/base/data/fonts/AndroidClock_Highlight.ttf:system/fonts/AndroidClock_Solid.ttf 
+    frameworks/base/data/fonts/AndroidClock_Solid.ttf:system/fonts/AndroidClock_Solid.ttf
diff --git a/data/keyboards/qwerty.idc b/data/keyboards/qwerty.idc
index 4cf0b84..375d785 100644
--- a/data/keyboards/qwerty.idc
+++ b/data/keyboards/qwerty.idc
@@ -16,6 +16,9 @@
 # Emulator keyboard configuration file #1.
 #
 
+touch.deviceType = touchScreen
+touch.orientationAware = 1
+
 keyboard.layout = qwerty
 keyboard.characterMap = qwerty
 keyboard.orientationAware = 1
diff --git a/data/keyboards/qwerty2.idc b/data/keyboards/qwerty2.idc
index 2e5a938..369205e 100644
--- a/data/keyboards/qwerty2.idc
+++ b/data/keyboards/qwerty2.idc
@@ -16,6 +16,9 @@
 # Emulator keyboard configuration file #2.
 #
 
+touch.deviceType = touchScreen
+touch.orientationAware = 1
+
 keyboard.layout = qwerty
 keyboard.characterMap = qwerty2
 keyboard.orientationAware = 1
diff --git a/include/media/MediaPlayerInterface.h b/include/media/MediaPlayerInterface.h
index c0963a6..048f041 100644
--- a/include/media/MediaPlayerInterface.h
+++ b/include/media/MediaPlayerInterface.h
@@ -126,8 +126,6 @@
     virtual status_t    setLooping(int loop) = 0;
     virtual player_type playerType() = 0;
 
-    virtual void        setNotifyCallback(void* cookie, notify_callback_f notifyFunc) {
-                            mCookie = cookie; mNotify = notifyFunc; }
     // Invoke a generic method on the player by using opaque parcels
     // for the request and reply.
     //
@@ -149,9 +147,21 @@
         return INVALID_OPERATION;
     };
 
-    virtual void        sendEvent(int msg, int ext1=0, int ext2=0) { if (mNotify) mNotify(mCookie, msg, ext1, ext2); }
+    void        setNotifyCallback(
+            void* cookie, notify_callback_f notifyFunc) {
+        Mutex::Autolock autoLock(mNotifyLock);
+        mCookie = cookie; mNotify = notifyFunc;
+    }
 
-protected:
+    void        sendEvent(int msg, int ext1=0, int ext2=0) {
+        Mutex::Autolock autoLock(mNotifyLock);
+        if (mNotify) mNotify(mCookie, msg, ext1, ext2);
+    }
+
+private:
+    friend class MediaPlayerService;
+
+    Mutex               mNotifyLock;
     void*               mCookie;
     notify_callback_f   mNotify;
 };
diff --git a/libs/rs/rsScriptC_Lib.cpp b/libs/rs/rsScriptC_Lib.cpp
index beb4d72..8a85f6e 100644
--- a/libs/rs/rsScriptC_Lib.cpp
+++ b/libs/rs/rsScriptC_Lib.cpp
@@ -347,6 +347,489 @@
     s->runForEach(rsc, ain, aout, usr, call);
 }
 
+
+//////////////////////////////////////////////////////////////////////////////
+// Heavy math functions
+//////////////////////////////////////////////////////////////////////////////
+
+typedef struct {
+    float m[16];
+} rs_matrix4x4;
+
+typedef struct {
+    float m[9];
+} rs_matrix3x3;
+
+typedef struct {
+    float m[4];
+} rs_matrix2x2;
+
+static inline void
+rsMatrixSet(rs_matrix4x4 *m, uint32_t row, uint32_t col, float v) {
+    m->m[row * 4 + col] = v;
+}
+
+static inline float
+rsMatrixGet(const rs_matrix4x4 *m, uint32_t row, uint32_t col) {
+    return m->m[row * 4 + col];
+}
+
+static inline void
+rsMatrixSet(rs_matrix3x3 *m, uint32_t row, uint32_t col, float v) {
+    m->m[row * 3 + col] = v;
+}
+
+static inline float
+rsMatrixGet(const rs_matrix3x3 *m, uint32_t row, uint32_t col) {
+    return m->m[row * 3 + col];
+}
+
+static inline void
+rsMatrixSet(rs_matrix2x2 *m, uint32_t row, uint32_t col, float v) {
+    m->m[row * 2 + col] = v;
+}
+
+static inline float
+rsMatrixGet(const rs_matrix2x2 *m, uint32_t row, uint32_t col) {
+    return m->m[row * 2 + col];
+}
+
+
+static void SC_MatrixLoadIdentity_4x4(rs_matrix4x4 *m) {
+    m->m[0] = 1.f;
+    m->m[1] = 0.f;
+    m->m[2] = 0.f;
+    m->m[3] = 0.f;
+    m->m[4] = 0.f;
+    m->m[5] = 1.f;
+    m->m[6] = 0.f;
+    m->m[7] = 0.f;
+    m->m[8] = 0.f;
+    m->m[9] = 0.f;
+    m->m[10] = 1.f;
+    m->m[11] = 0.f;
+    m->m[12] = 0.f;
+    m->m[13] = 0.f;
+    m->m[14] = 0.f;
+    m->m[15] = 1.f;
+}
+
+static void SC_MatrixLoadIdentity_3x3(rs_matrix3x3 *m) {
+    m->m[0] = 1.f;
+    m->m[1] = 0.f;
+    m->m[2] = 0.f;
+    m->m[3] = 0.f;
+    m->m[4] = 1.f;
+    m->m[5] = 0.f;
+    m->m[6] = 0.f;
+    m->m[7] = 0.f;
+    m->m[8] = 1.f;
+}
+
+static void SC_MatrixLoadIdentity_2x2(rs_matrix2x2 *m) {
+    m->m[0] = 1.f;
+    m->m[1] = 0.f;
+    m->m[2] = 0.f;
+    m->m[3] = 1.f;
+}
+
+static void SC_MatrixLoad_4x4_f(rs_matrix4x4 *m, const float *v) {
+    m->m[0] = v[0];
+    m->m[1] = v[1];
+    m->m[2] = v[2];
+    m->m[3] = v[3];
+    m->m[4] = v[4];
+    m->m[5] = v[5];
+    m->m[6] = v[6];
+    m->m[7] = v[7];
+    m->m[8] = v[8];
+    m->m[9] = v[9];
+    m->m[10] = v[10];
+    m->m[11] = v[11];
+    m->m[12] = v[12];
+    m->m[13] = v[13];
+    m->m[14] = v[14];
+    m->m[15] = v[15];
+}
+
+static void SC_MatrixLoad_3x3_f(rs_matrix3x3 *m, const float *v) {
+    m->m[0] = v[0];
+    m->m[1] = v[1];
+    m->m[2] = v[2];
+    m->m[3] = v[3];
+    m->m[4] = v[4];
+    m->m[5] = v[5];
+    m->m[6] = v[6];
+    m->m[7] = v[7];
+    m->m[8] = v[8];
+}
+
+static void SC_MatrixLoad_2x2_f(rs_matrix2x2 *m, const float *v) {
+    m->m[0] = v[0];
+    m->m[1] = v[1];
+    m->m[2] = v[2];
+    m->m[3] = v[3];
+}
+
+static void SC_MatrixLoad_4x4_4x4(rs_matrix4x4 *m, const rs_matrix4x4 *v) {
+    m->m[0] = v->m[0];
+    m->m[1] = v->m[1];
+    m->m[2] = v->m[2];
+    m->m[3] = v->m[3];
+    m->m[4] = v->m[4];
+    m->m[5] = v->m[5];
+    m->m[6] = v->m[6];
+    m->m[7] = v->m[7];
+    m->m[8] = v->m[8];
+    m->m[9] = v->m[9];
+    m->m[10] = v->m[10];
+    m->m[11] = v->m[11];
+    m->m[12] = v->m[12];
+    m->m[13] = v->m[13];
+    m->m[14] = v->m[14];
+    m->m[15] = v->m[15];
+}
+
+static void SC_MatrixLoad_4x4_3x3(rs_matrix4x4 *m, const rs_matrix3x3 *v) {
+    m->m[0] = v->m[0];
+    m->m[1] = v->m[1];
+    m->m[2] = v->m[2];
+    m->m[3] = 0.f;
+    m->m[4] = v->m[3];
+    m->m[5] = v->m[4];
+    m->m[6] = v->m[5];
+    m->m[7] = 0.f;
+    m->m[8] = v->m[6];
+    m->m[9] = v->m[7];
+    m->m[10] = v->m[8];
+    m->m[11] = 0.f;
+    m->m[12] = 0.f;
+    m->m[13] = 0.f;
+    m->m[14] = 0.f;
+    m->m[15] = 1.f;
+}
+
+static void SC_MatrixLoad_4x4_2x2(rs_matrix4x4 *m, const rs_matrix2x2 *v) {
+    m->m[0] = v->m[0];
+    m->m[1] = v->m[1];
+    m->m[2] = 0.f;
+    m->m[3] = 0.f;
+    m->m[4] = v->m[2];
+    m->m[5] = v->m[3];
+    m->m[6] = 0.f;
+    m->m[7] = 0.f;
+    m->m[8] = 0.f;
+    m->m[9] = 0.f;
+    m->m[10] = 1.f;
+    m->m[11] = 0.f;
+    m->m[12] = 0.f;
+    m->m[13] = 0.f;
+    m->m[14] = 0.f;
+    m->m[15] = 1.f;
+}
+
+static void SC_MatrixLoad_3x3_3x3(rs_matrix3x3 *m, const rs_matrix3x3 *v) {
+    m->m[0] = v->m[0];
+    m->m[1] = v->m[1];
+    m->m[2] = v->m[2];
+    m->m[3] = v->m[3];
+    m->m[4] = v->m[4];
+    m->m[5] = v->m[5];
+    m->m[6] = v->m[6];
+    m->m[7] = v->m[7];
+    m->m[8] = v->m[8];
+}
+
+static void SC_MatrixLoad_2x2_2x2(rs_matrix2x2 *m, const rs_matrix2x2 *v) {
+    m->m[0] = v->m[0];
+    m->m[1] = v->m[1];
+    m->m[2] = v->m[2];
+    m->m[3] = v->m[3];
+}
+
+static void SC_MatrixLoadRotate(rs_matrix4x4 *m, float rot, float x, float y, float z) {
+    float c, s;
+    m->m[3] = 0;
+    m->m[7] = 0;
+    m->m[11]= 0;
+    m->m[12]= 0;
+    m->m[13]= 0;
+    m->m[14]= 0;
+    m->m[15]= 1;
+    rot *= (float)(M_PI / 180.0f);
+    c = cos(rot);
+    s = sin(rot);
+
+    const float len = x*x + y*y + z*z;
+    if (len != 1) {
+        const float recipLen = 1.f / sqrt(len);
+        x *= recipLen;
+        y *= recipLen;
+        z *= recipLen;
+    }
+    const float nc = 1.0f - c;
+    const float xy = x * y;
+    const float yz = y * z;
+    const float zx = z * x;
+    const float xs = x * s;
+    const float ys = y * s;
+    const float zs = z * s;
+    m->m[ 0] = x*x*nc +  c;
+    m->m[ 4] =  xy*nc - zs;
+    m->m[ 8] =  zx*nc + ys;
+    m->m[ 1] =  xy*nc + zs;
+    m->m[ 5] = y*y*nc +  c;
+    m->m[ 9] =  yz*nc - xs;
+    m->m[ 2] =  zx*nc - ys;
+    m->m[ 6] =  yz*nc + xs;
+    m->m[10] = z*z*nc +  c;
+}
+
+static void SC_MatrixLoadScale(rs_matrix4x4 *m, float x, float y, float z) {
+    SC_MatrixLoadIdentity_4x4(m);
+    m->m[0] = x;
+    m->m[5] = y;
+    m->m[10] = z;
+}
+
+static void SC_MatrixLoadTranslate(rs_matrix4x4 *m, float x, float y, float z) {
+    SC_MatrixLoadIdentity_4x4(m);
+    m->m[12] = x;
+    m->m[13] = y;
+    m->m[14] = z;
+}
+
+static void SC_MatrixLoadMultiply_4x4_4x4_4x4(rs_matrix4x4 *m, const rs_matrix4x4 *lhs, const rs_matrix4x4 *rhs) {
+    for (int i=0 ; i<4 ; i++) {
+        float ri0 = 0;
+        float ri1 = 0;
+        float ri2 = 0;
+        float ri3 = 0;
+        for (int j=0 ; j<4 ; j++) {
+            const float rhs_ij = rsMatrixGet(rhs, i,j);
+            ri0 += rsMatrixGet(lhs, j, 0) * rhs_ij;
+            ri1 += rsMatrixGet(lhs, j, 1) * rhs_ij;
+            ri2 += rsMatrixGet(lhs, j, 2) * rhs_ij;
+            ri3 += rsMatrixGet(lhs, j, 3) * rhs_ij;
+        }
+        rsMatrixSet(m, i, 0, ri0);
+        rsMatrixSet(m, i, 1, ri1);
+        rsMatrixSet(m, i, 2, ri2);
+        rsMatrixSet(m, i, 3, ri3);
+    }
+}
+
+static void SC_MatrixMultiply_4x4_4x4(rs_matrix4x4 *m, const rs_matrix4x4 *rhs) {
+    rs_matrix4x4 mt;
+    SC_MatrixLoadMultiply_4x4_4x4_4x4(&mt, m, rhs);
+    SC_MatrixLoad_4x4_4x4(m, &mt);
+}
+
+static void SC_MatrixLoadMultiply_3x3_3x3_3x3(rs_matrix3x3 *m, const rs_matrix3x3 *lhs, const rs_matrix3x3 *rhs) {
+    for (int i=0 ; i<3 ; i++) {
+        float ri0 = 0;
+        float ri1 = 0;
+        float ri2 = 0;
+        for (int j=0 ; j<3 ; j++) {
+            const float rhs_ij = rsMatrixGet(rhs, i,j);
+            ri0 += rsMatrixGet(lhs, j, 0) * rhs_ij;
+            ri1 += rsMatrixGet(lhs, j, 1) * rhs_ij;
+            ri2 += rsMatrixGet(lhs, j, 2) * rhs_ij;
+        }
+        rsMatrixSet(m, i, 0, ri0);
+        rsMatrixSet(m, i, 1, ri1);
+        rsMatrixSet(m, i, 2, ri2);
+    }
+}
+
+static void SC_MatrixMultiply_3x3_3x3(rs_matrix3x3 *m, const rs_matrix3x3 *rhs) {
+    rs_matrix3x3 mt;
+    SC_MatrixLoadMultiply_3x3_3x3_3x3(&mt, m, rhs);
+    SC_MatrixLoad_3x3_3x3(m, &mt);
+}
+
+static void SC_MatrixLoadMultiply_2x2_2x2_2x2(rs_matrix2x2 *m, const rs_matrix2x2 *lhs, const rs_matrix2x2 *rhs) {
+    for (int i=0 ; i<2 ; i++) {
+        float ri0 = 0;
+        float ri1 = 0;
+        for (int j=0 ; j<2 ; j++) {
+            const float rhs_ij = rsMatrixGet(rhs, i,j);
+            ri0 += rsMatrixGet(lhs, j, 0) * rhs_ij;
+            ri1 += rsMatrixGet(lhs, j, 1) * rhs_ij;
+        }
+        rsMatrixSet(m, i, 0, ri0);
+        rsMatrixSet(m, i, 1, ri1);
+    }
+}
+
+static void SC_MatrixMultiply_2x2_2x2(rs_matrix2x2 *m, const rs_matrix2x2 *rhs) {
+    rs_matrix2x2 mt;
+    SC_MatrixLoadMultiply_2x2_2x2_2x2(&mt, m, rhs);
+    SC_MatrixLoad_2x2_2x2(m, &mt);
+}
+
+static void SC_MatrixRotate(rs_matrix4x4 *m, float rot, float x, float y, float z) {
+    rs_matrix4x4 m1;
+    SC_MatrixLoadRotate(&m1, rot, x, y, z);
+    SC_MatrixMultiply_4x4_4x4(m, &m1);
+}
+
+static void SC_MatrixScale(rs_matrix4x4 *m, float x, float y, float z) {
+    rs_matrix4x4 m1;
+    SC_MatrixLoadScale(&m1, x, y, z);
+    SC_MatrixMultiply_4x4_4x4(m, &m1);
+}
+
+static void SC_MatrixTranslate(rs_matrix4x4 *m, float x, float y, float z) {
+    rs_matrix4x4 m1;
+    SC_MatrixLoadTranslate(&m1, x, y, z);
+    SC_MatrixMultiply_4x4_4x4(m, &m1);
+}
+
+static void SC_MatrixLoadOrtho(rs_matrix4x4 *m, float left, float right, float bottom, float top, float near, float far) {
+    SC_MatrixLoadIdentity_4x4(m);
+    m->m[0] = 2.f / (right - left);
+    m->m[5] = 2.f / (top - bottom);
+    m->m[10]= -2.f / (far - near);
+    m->m[12]= -(right + left) / (right - left);
+    m->m[13]= -(top + bottom) / (top - bottom);
+    m->m[14]= -(far + near) / (far - near);
+}
+
+static void SC_MatrixLoadFrustum(rs_matrix4x4 *m, float left, float right, float bottom, float top, float near, float far) {
+    SC_MatrixLoadIdentity_4x4(m);
+    m->m[0] = 2.f * near / (right - left);
+    m->m[5] = 2.f * near / (top - bottom);
+    m->m[8] = (right + left) / (right - left);
+    m->m[9] = (top + bottom) / (top - bottom);
+    m->m[10]= -(far + near) / (far - near);
+    m->m[11]= -1.f;
+    m->m[14]= -2.f * far * near / (far - near);
+    m->m[15]= 0.f;
+}
+
+static void SC_MatrixLoadPerspective(rs_matrix4x4* m, float fovy, float aspect, float near, float far) {
+    float top = near * tan((float) (fovy * M_PI / 360.0f));
+    float bottom = -top;
+    float left = bottom * aspect;
+    float right = top * aspect;
+    SC_MatrixLoadFrustum(m, left, right, bottom, top, near, far);
+}
+
+
+// Returns true if the matrix was successfully inversed
+static bool SC_MatrixInverse_4x4(rs_matrix4x4 *m) {
+    rs_matrix4x4 result;
+
+    int i, j;
+    for (i = 0; i < 4; ++i) {
+        for (j = 0; j < 4; ++j) {
+            // computeCofactor for int i, int j
+            int c0 = (i+1) % 4;
+            int c1 = (i+2) % 4;
+            int c2 = (i+3) % 4;
+            int r0 = (j+1) % 4;
+            int r1 = (j+2) % 4;
+            int r2 = (j+3) % 4;
+
+            float minor = (m->m[c0 + 4*r0] * (m->m[c1 + 4*r1] * m->m[c2 + 4*r2] - m->m[c1 + 4*r2] * m->m[c2 + 4*r1]))
+                         - (m->m[c0 + 4*r1] * (m->m[c1 + 4*r0] * m->m[c2 + 4*r2] - m->m[c1 + 4*r2] * m->m[c2 + 4*r0]))
+                         + (m->m[c0 + 4*r2] * (m->m[c1 + 4*r0] * m->m[c2 + 4*r1] - m->m[c1 + 4*r1] * m->m[c2 + 4*r0]));
+
+            float cofactor = (i+j) & 1 ? -minor : minor;
+
+            result.m[4*i + j] = cofactor;
+        }
+    }
+
+    // Dot product of 0th column of source and 0th row of result
+    float det = m->m[0]*result.m[0] + m->m[4]*result.m[1] +
+                 m->m[8]*result.m[2] + m->m[12]*result.m[3];
+
+    if (fabs(det) < 1e-6) {
+        return false;
+    }
+
+    det = 1.0f / det;
+    for (i = 0; i < 16; ++i) {
+        m->m[i] = result.m[i] * det;
+    }
+
+    return true;
+}
+
+// Returns true if the matrix was successfully inversed
+static bool SC_MatrixInverseTranspose_4x4(rs_matrix4x4 *m) {
+    rs_matrix4x4 result;
+
+    int i, j;
+    for (i = 0; i < 4; ++i) {
+        for (j = 0; j < 4; ++j) {
+            // computeCofactor for int i, int j
+            int c0 = (i+1) % 4;
+            int c1 = (i+2) % 4;
+            int c2 = (i+3) % 4;
+            int r0 = (j+1) % 4;
+            int r1 = (j+2) % 4;
+            int r2 = (j+3) % 4;
+
+            float minor = (m->m[c0 + 4*r0] * (m->m[c1 + 4*r1] * m->m[c2 + 4*r2] - m->m[c1 + 4*r2] * m->m[c2 + 4*r1]))
+                         - (m->m[c0 + 4*r1] * (m->m[c1 + 4*r0] * m->m[c2 + 4*r2] - m->m[c1 + 4*r2] * m->m[c2 + 4*r0]))
+                         + (m->m[c0 + 4*r2] * (m->m[c1 + 4*r0] * m->m[c2 + 4*r1] - m->m[c1 + 4*r1] * m->m[c2 + 4*r0]));
+
+            float cofactor = (i+j) & 1 ? -minor : minor;
+
+            result.m[4*j + i] = cofactor;
+        }
+    }
+
+    // Dot product of 0th column of source and 0th column of result
+    float det = m->m[0]*result.m[0] + m->m[4]*result.m[4] +
+                 m->m[8]*result.m[8] + m->m[12]*result.m[12];
+
+    if (fabs(det) < 1e-6) {
+        return false;
+    }
+
+    det = 1.0f / det;
+    for (i = 0; i < 16; ++i) {
+        m->m[i] = result.m[i] * det;
+    }
+
+    return true;
+}
+
+static void SC_MatrixTranspose_4x4(rs_matrix4x4 *m) {
+    int i, j;
+    float temp;
+    for (i = 0; i < 3; ++i) {
+        for (j = i + 1; j < 4; ++j) {
+            temp = m->m[i*4 + j];
+            m->m[i*4 + j] = m->m[j*4 + i];
+            m->m[j*4 + i] = temp;
+        }
+    }
+}
+
+static void SC_MatrixTranspose_3x3(rs_matrix3x3 *m) {
+    int i, j;
+    float temp;
+    for (i = 0; i < 2; ++i) {
+        for (j = i + 1; j < 3; ++j) {
+            temp = m->m[i*3 + j];
+            m->m[i*3 + j] = m->m[j*4 + i];
+            m->m[j*3 + i] = temp;
+        }
+    }
+}
+
+static void SC_MatrixTranspose_2x2(rs_matrix2x2 *m) {
+    float temp = m->m[1];
+    m->m[1] = m->m[2];
+    m->m[2] = temp;
+}
+
+
 //////////////////////////////////////////////////////////////////////////////
 // Class implementation
 //////////////////////////////////////////////////////////////////////////////
@@ -473,6 +956,45 @@
     { "_Z22rsSendToClientBlockingi", (void *)&SC_toClientBlocking, false },
     { "_Z22rsSendToClientBlockingiPKvj", (void *)&SC_toClientBlocking2, false },
 
+    // matrix
+    { "_Z20rsMatrixLoadIdentityP12rs_matrix4x4", (void *)&SC_MatrixLoadIdentity_4x4, false },
+    { "_Z20rsMatrixLoadIdentityP12rs_matrix3x3", (void *)&SC_MatrixLoadIdentity_3x3, false },
+    { "_Z20rsMatrixLoadIdentityP12rs_matrix2x2", (void *)&SC_MatrixLoadIdentity_2x2, false },
+
+    { "_Z12rsMatrixLoadP12rs_matrix4x4PKf", (void *)&SC_MatrixLoad_4x4_f, false },
+    { "_Z12rsMatrixLoadP12rs_matrix3x3PKf", (void *)&SC_MatrixLoad_3x3_f, false },
+    { "_Z12rsMatrixLoadP12rs_matrix2x2PKf", (void *)&SC_MatrixLoad_2x2_f, false },
+
+    { "_Z12rsMatrixLoadP12rs_matrix4x4PKS_", (void *)&SC_MatrixLoad_4x4_4x4, false },
+    { "_Z12rsMatrixLoadP12rs_matrix4x4PK12rs_matrix3x3", (void *)&SC_MatrixLoad_4x4_3x3, false },
+    { "_Z12rsMatrixLoadP12rs_matrix4x4PK12rs_matrix2x2", (void *)&SC_MatrixLoad_4x4_2x2, false },
+    { "_Z12rsMatrixLoadP12rs_matrix3x3PKS_", (void *)&SC_MatrixLoad_3x3_3x3, false },
+    { "_Z12rsMatrixLoadP12rs_matrix2x2PKS_", (void *)&SC_MatrixLoad_2x2_2x2, false },
+
+    { "_Z18rsMatrixLoadRotateP12rs_matrix4x4ffff", (void *)&SC_MatrixLoadRotate, false },
+    { "_Z17rsMatrixLoadScaleP12rs_matrix4x4fff", (void *)&SC_MatrixLoadScale, false },
+    { "_Z21rsMatrixLoadTranslateP12rs_matrix4x4fff", (void *)&SC_MatrixLoadTranslate, false },
+    { "_Z14rsMatrixRotateP12rs_matrix4x4ffff", (void *)&SC_MatrixRotate, false },
+    { "_Z13rsMatrixScaleP12rs_matrix4x4fff", (void *)&SC_MatrixScale, false },
+    { "_Z17rsMatrixTranslateP12rs_matrix4x4fff", (void *)&SC_MatrixTranslate, false },
+
+    { "_Z20rsMatrixLoadMultiplyP12rs_matrix4x4PKS_S2_", (void *)&SC_MatrixLoadMultiply_4x4_4x4_4x4, false },
+    { "_Z16rsMatrixMultiplyP12rs_matrix4x4PKS_", (void *)&SC_MatrixMultiply_4x4_4x4, false },
+    { "_Z20rsMatrixLoadMultiplyP12rs_matrix3x3PKS_S2_", (void *)&SC_MatrixLoadMultiply_3x3_3x3_3x3, false },
+    { "_Z16rsMatrixMultiplyP12rs_matrix3x3PKS_", (void *)&SC_MatrixMultiply_3x3_3x3, false },
+    { "_Z20rsMatrixLoadMultiplyP12rs_matrix2x2PKS_S2_", (void *)&SC_MatrixLoadMultiply_2x2_2x2_2x2, false },
+    { "_Z16rsMatrixMultiplyP12rs_matrix2x2PKS_", (void *)&SC_MatrixMultiply_2x2_2x2, false },
+
+    { "_Z17rsMatrixLoadOrthoP12rs_matrix4x4ffffff", (void *)&SC_MatrixLoadOrtho, false },
+    { "_Z19rsMatrixLoadFrustumP12rs_matrix4x4ffffff", (void *)&SC_MatrixLoadFrustum, false },
+    { "_Z23rsMatrixLoadPerspectiveP12rs_matrix4x4ffff", (void *)&SC_MatrixLoadPerspective, false },
+
+    { "_Z15rsMatrixInverseP12rs_matrix4x4", (void *)&SC_MatrixInverse_4x4, false },
+    { "_Z24rsMatrixInverseTransposeP12rs_matrix4x4", (void *)&SC_MatrixInverseTranspose_4x4, false },
+    { "_Z17rsMatrixTransposeP12rs_matrix4x4", (void *)&SC_MatrixTranspose_4x4, false },
+    { "_Z17rsMatrixTransposeP12rs_matrix4x4", (void *)&SC_MatrixTranspose_3x3, false },
+    { "_Z17rsMatrixTransposeP12rs_matrix4x4", (void *)&SC_MatrixTranspose_2x2, false },
+
     { "_Z9rsForEach9rs_script13rs_allocationS0_PKv", (void *)&SC_ForEach, false },
     //{ "_Z9rsForEach9rs_script13rs_allocationS0_PKv", (void *)&SC_ForEach2, true },
 
diff --git a/libs/rs/scriptc/rs_cl.rsh b/libs/rs/scriptc/rs_cl.rsh
index 3c0496d..3a9686b 100644
--- a/libs/rs/scriptc/rs_cl.rsh
+++ b/libs/rs/scriptc/rs_cl.rsh
@@ -1,30 +1,17 @@
 #ifndef __RS_CL_RSH__
 #define __RS_CL_RSH__
 
-#ifdef BCC_PREPARE_BC
 #define _RS_STATIC  extern
-#else
-#define _RS_STATIC  static
-#endif
 
 // Conversions
 #define CVT_FUNC_2(typeout, typein)                             \
 _RS_STATIC typeout##2 __attribute__((overloadable))             \
-        convert_##typeout##2(typein##2 v) {                     \
-    typeout##2 r = {(typeout)v.x, (typeout)v.y};                \
-    return r;                                                   \
-}                                                               \
+        convert_##typeout##2(typein##2 v);                      \
 _RS_STATIC typeout##3 __attribute__((overloadable))             \
-        convert_##typeout##3(typein##3 v) {                     \
-    typeout##3 r = {(typeout)v.x, (typeout)v.y, (typeout)v.z};  \
-    return r;                                                   \
-}                                                               \
+        convert_##typeout##3(typein##3 v);                      \
 _RS_STATIC typeout##4 __attribute__((overloadable))             \
-        convert_##typeout##4(typein##4 v) {                     \
-    typeout##4 r = {(typeout)v.x, (typeout)v.y, (typeout)v.z,   \
-                    (typeout)v.w};                              \
-    return r;                                                   \
-}
+        convert_##typeout##4(typein##4 v);
+
 
 #define CVT_FUNC(type)  CVT_FUNC_2(type, uchar)     \
                         CVT_FUNC_2(type, char)      \
@@ -45,279 +32,63 @@
 // Float ops, 6.11.2
 
 #define FN_FUNC_FN(fnc)                                         \
-_RS_STATIC float2 __attribute__((overloadable)) fnc(float2 v) { \
-    float2 r;                                                   \
-    r.x = fnc(v.x);                                             \
-    r.y = fnc(v.y);                                             \
-    return r;                                                   \
-}                                                               \
-_RS_STATIC float3 __attribute__((overloadable)) fnc(float3 v) { \
-    float3 r;                                                   \
-    r.x = fnc(v.x);                                             \
-    r.y = fnc(v.y);                                             \
-    r.z = fnc(v.z);                                             \
-    return r;                                                   \
-}                                                               \
-_RS_STATIC float4 __attribute__((overloadable)) fnc(float4 v) { \
-    float4 r;                                                   \
-    r.x = fnc(v.x);                                             \
-    r.y = fnc(v.y);                                             \
-    r.z = fnc(v.z);                                             \
-    r.w = fnc(v.w);                                             \
-    return r;                                                   \
-}
+_RS_STATIC float2 __attribute__((overloadable)) fnc(float2 v);  \
+_RS_STATIC float3 __attribute__((overloadable)) fnc(float3 v);  \
+_RS_STATIC float4 __attribute__((overloadable)) fnc(float4 v);
 
 #define IN_FUNC_FN(fnc)                                         \
-_RS_STATIC int2 __attribute__((overloadable)) fnc(float2 v) {   \
-    int2 r;                                                     \
-    r.x = fnc(v.x);                                             \
-    r.y = fnc(v.y);                                             \
-    return r;                                                   \
-}                                                               \
-_RS_STATIC int3 __attribute__((overloadable)) fnc(float3 v) {   \
-    int3 r;                                                     \
-    r.x = fnc(v.x);                                             \
-    r.y = fnc(v.y);                                             \
-    r.z = fnc(v.z);                                             \
-    return r;                                                   \
-}                                                               \
-_RS_STATIC int4 __attribute__((overloadable)) fnc(float4 v) {   \
-    int4 r;                                                     \
-    r.x = fnc(v.x);                                             \
-    r.y = fnc(v.y);                                             \
-    r.z = fnc(v.z);                                             \
-    r.w = fnc(v.w);                                             \
-    return r;                                                   \
-}
+_RS_STATIC int2 __attribute__((overloadable)) fnc(float2 v);    \
+_RS_STATIC int3 __attribute__((overloadable)) fnc(float3 v);    \
+_RS_STATIC int4 __attribute__((overloadable)) fnc(float4 v);
 
 #define FN_FUNC_FN_FN(fnc)                                                  \
-_RS_STATIC float2 __attribute__((overloadable)) fnc(float2 v1, float2 v2) { \
-    float2 r;                                                               \
-    r.x = fnc(v1.x, v2.x);                                                  \
-    r.y = fnc(v1.y, v2.y);                                                  \
-    return r;                                                               \
-}                                                                           \
-_RS_STATIC float3 __attribute__((overloadable)) fnc(float3 v1, float3 v2) { \
-    float3 r;                                                               \
-    r.x = fnc(v1.x, v2.x);                                                  \
-    r.y = fnc(v1.y, v2.y);                                                  \
-    r.z = fnc(v1.z, v2.z);                                                  \
-    return r;                                                               \
-}                                                                           \
-_RS_STATIC float4 __attribute__((overloadable)) fnc(float4 v1, float4 v2) { \
-    float4 r;                                                               \
-    r.x = fnc(v1.x, v2.x);                                                  \
-    r.y = fnc(v1.y, v2.y);                                                  \
-    r.z = fnc(v1.z, v2.z);                                                  \
-    r.w = fnc(v1.w, v2.w);                                                  \
-    return r;                                                               \
-}
+_RS_STATIC float2 __attribute__((overloadable)) fnc(float2 v1, float2 v2);  \
+_RS_STATIC float3 __attribute__((overloadable)) fnc(float3 v1, float3 v2);  \
+_RS_STATIC float4 __attribute__((overloadable)) fnc(float4 v1, float4 v2);
 
 #define FN_FUNC_FN_F(fnc)                                                   \
-_RS_STATIC float2 __attribute__((overloadable)) fnc(float2 v1, float v2) {  \
-    float2 r;                                                               \
-    r.x = fnc(v1.x, v2);                                                    \
-    r.y = fnc(v1.y, v2);                                                    \
-    return r;                                                               \
-}                                                                           \
-_RS_STATIC float3 __attribute__((overloadable)) fnc(float3 v1, float v2) {  \
-    float3 r;                                                               \
-    r.x = fnc(v1.x, v2);                                                    \
-    r.y = fnc(v1.y, v2);                                                    \
-    r.z = fnc(v1.z, v2);                                                    \
-    return r;                                                               \
-}                                                                           \
-_RS_STATIC float4 __attribute__((overloadable)) fnc(float4 v1, float v2) {  \
-    float4 r;                                                               \
-    r.x = fnc(v1.x, v2);                                                    \
-    r.y = fnc(v1.y, v2);                                                    \
-    r.z = fnc(v1.z, v2);                                                    \
-    r.w = fnc(v1.w, v2);                                                    \
-    return r;                                                               \
-}
+_RS_STATIC float2 __attribute__((overloadable)) fnc(float2 v1, float v2);   \
+_RS_STATIC float3 __attribute__((overloadable)) fnc(float3 v1, float v2);   \
+_RS_STATIC float4 __attribute__((overloadable)) fnc(float4 v1, float v2);
 
 #define FN_FUNC_FN_IN(fnc)                                                  \
-_RS_STATIC float2 __attribute__((overloadable)) fnc(float2 v1, int2 v2) {   \
-    float2 r;                                                               \
-    r.x = fnc(v1.x, v2.x);                                                  \
-    r.y = fnc(v1.y, v2.y);                                                  \
-    return r;                                                               \
-}                                                                           \
-_RS_STATIC float3 __attribute__((overloadable)) fnc(float3 v1, int3 v2) {   \
-    float3 r;                                                               \
-    r.x = fnc(v1.x, v2.x);                                                  \
-    r.y = fnc(v1.y, v2.y);                                                  \
-    r.z = fnc(v1.z, v2.z);                                                  \
-    return r;                                                               \
-}                                                                           \
-_RS_STATIC float4 __attribute__((overloadable)) fnc(float4 v1, int4 v2) {   \
-    float4 r;                                                               \
-    r.x = fnc(v1.x, v2.x);                                                  \
-    r.y = fnc(v1.y, v2.y);                                                  \
-    r.z = fnc(v1.z, v2.z);                                                  \
-    r.w = fnc(v1.w, v2.w);                                                  \
-    return r;                                                               \
-}
+_RS_STATIC float2 __attribute__((overloadable)) fnc(float2 v1, int2 v2);    \
+_RS_STATIC float3 __attribute__((overloadable)) fnc(float3 v1, int3 v2);    \
+_RS_STATIC float4 __attribute__((overloadable)) fnc(float4 v1, int4 v2);    \
 
 #define FN_FUNC_FN_I(fnc)                                                   \
-_RS_STATIC float2 __attribute__((overloadable)) fnc(float2 v1, int v2) {    \
-    float2 r;                                                               \
-    r.x = fnc(v1.x, v2);                                                    \
-    r.y = fnc(v1.y, v2);                                                    \
-    return r;                                                               \
-}                                                                           \
-_RS_STATIC float3 __attribute__((overloadable)) fnc(float3 v1, int v2) {    \
-    float3 r;                                                               \
-    r.x = fnc(v1.x, v2);                                                    \
-    r.y = fnc(v1.y, v2);                                                    \
-    r.z = fnc(v1.z, v2);                                                    \
-    return r;                                                               \
-}                                                                           \
-_RS_STATIC float4 __attribute__((overloadable)) fnc(float4 v1, int v2) {    \
-    float4 r;                                                               \
-    r.x = fnc(v1.x, v2);                                                    \
-    r.y = fnc(v1.y, v2);                                                    \
-    r.z = fnc(v1.z, v2);                                                    \
-    r.w = fnc(v1.w, v2);                                                    \
-    return r;                                                               \
-}
+_RS_STATIC float2 __attribute__((overloadable)) fnc(float2 v1, int v2);     \
+_RS_STATIC float3 __attribute__((overloadable)) fnc(float3 v1, int v2);     \
+_RS_STATIC float4 __attribute__((overloadable)) fnc(float4 v1, int v2);
 
 #define FN_FUNC_FN_PFN(fnc)                     \
 _RS_STATIC float2 __attribute__((overloadable)) \
-        fnc(float2 v1, float2 *v2) {            \
-    float2 r;                                   \
-    float t[2];                                 \
-    r.x = fnc(v1.x, &t[0]);                     \
-    r.y = fnc(v1.y, &t[1]);                     \
-    v2->x = t[0];                               \
-    v2->y = t[1];                               \
-    return r;                                   \
-}                                               \
+        fnc(float2 v1, float2 *v2);             \
 _RS_STATIC float3 __attribute__((overloadable)) \
-        fnc(float3 v1, float3 *v2) {            \
-    float3 r;                                   \
-    float t[3];                                 \
-    r.x = fnc(v1.x, &t[0]);                     \
-    r.y = fnc(v1.y, &t[1]);                     \
-    r.z = fnc(v1.z, &t[2]);                     \
-    v2->x = t[0];                               \
-    v2->y = t[1];                               \
-    v2->z = t[2];                               \
-    return r;                                   \
-}                                               \
+        fnc(float3 v1, float3 *v2);             \
 _RS_STATIC float4 __attribute__((overloadable)) \
-        fnc(float4 v1, float4 *v2) {            \
-    float4 r;                                   \
-    float t[4];                                 \
-    r.x = fnc(v1.x, &t[0]);                     \
-    r.y = fnc(v1.y, &t[1]);                     \
-    r.z = fnc(v1.z, &t[2]);                     \
-    r.w = fnc(v1.w, &t[3]);                     \
-    v2->x = t[0];                               \
-    v2->y = t[1];                               \
-    v2->z = t[2];                               \
-    v2->w = t[3];                               \
-    return r;                                   \
-}
+        fnc(float4 v1, float4 *v2);
 
 #define FN_FUNC_FN_PIN(fnc)                                                 \
-_RS_STATIC float2 __attribute__((overloadable)) fnc(float2 v1, int2 *v2) {  \
-    float2 r;                                                               \
-    int t[2];                                                               \
-    r.x = fnc(v1.x, &t[0]);                                                 \
-    r.y = fnc(v1.y, &t[1]);                                                 \
-    v2->x = t[0];                                                           \
-    v2->y = t[1];                                                           \
-    return r;                                                               \
-}                                                                           \
-_RS_STATIC float3 __attribute__((overloadable)) fnc(float3 v1, int3 *v2) {  \
-    float3 r;                                                               \
-    int t[3];                                                               \
-    r.x = fnc(v1.x, &t[0]);                                                 \
-    r.y = fnc(v1.y, &t[1]);                                                 \
-    r.z = fnc(v1.z, &t[2]);                                                 \
-    v2->x = t[0];                                                           \
-    v2->y = t[1];                                                           \
-    v2->z = t[2];                                                           \
-    return r;                                                               \
-}                                                                           \
-_RS_STATIC float4 __attribute__((overloadable)) fnc(float4 v1, int4 *v2) {  \
-    float4 r;                                                               \
-    int t[4];                                                               \
-    r.x = fnc(v1.x, &t[0]);                                                 \
-    r.y = fnc(v1.y, &t[1]);                                                 \
-    r.z = fnc(v1.z, &t[2]);                                                 \
-    r.w = fnc(v1.w, &t[3]);                                                 \
-    v2->x = t[0];                                                           \
-    v2->y = t[1];                                                           \
-    v2->z = t[2];                                                           \
-    v2->w = t[3];                                                           \
-    return r;                                                               \
-}
+_RS_STATIC float2 __attribute__((overloadable)) fnc(float2 v1, int2 *v2);   \
+_RS_STATIC float3 __attribute__((overloadable)) fnc(float3 v1, int3 *v2);   \
+_RS_STATIC float4 __attribute__((overloadable)) fnc(float4 v1, int4 *v2);
 
 #define FN_FUNC_FN_FN_FN(fnc)                   \
 _RS_STATIC float2 __attribute__((overloadable)) \
-        fnc(float2 v1, float2 v2, float2 v3) {  \
-    float2 r;                                   \
-    r.x = fnc(v1.x, v2.x, v3.x);                \
-    r.y = fnc(v1.y, v2.y, v3.y);                \
-    return r;                                   \
-}                                               \
+        fnc(float2 v1, float2 v2, float2 v3);   \
 _RS_STATIC float3 __attribute__((overloadable)) \
-        fnc(float3 v1, float3 v2, float3 v3) {  \
-    float3 r;                                   \
-    r.x = fnc(v1.x, v2.x, v3.x);                \
-    r.y = fnc(v1.y, v2.y, v3.y);                \
-    r.z = fnc(v1.z, v2.z, v3.z);                \
-    return r;                                   \
-}                                               \
+        fnc(float3 v1, float3 v2, float3 v3);   \
 _RS_STATIC float4 __attribute__((overloadable)) \
-        fnc(float4 v1, float4 v2, float4 v3) {  \
-    float4 r;                                   \
-    r.x = fnc(v1.x, v2.x, v3.x);                \
-    r.y = fnc(v1.y, v2.y, v3.y);                \
-    r.z = fnc(v1.z, v2.z, v3.z);                \
-    r.w = fnc(v1.w, v2.w, v3.w);                \
-    return r;                                   \
-}
+        fnc(float4 v1, float4 v2, float4 v3);
 
 #define FN_FUNC_FN_FN_PIN(fnc)                  \
 _RS_STATIC float2 __attribute__((overloadable)) \
-        fnc(float2 v1, float2 v2, int2 *v3) {   \
-    float2 r;                                   \
-    int t[2];                                   \
-    r.x = fnc(v1.x, v2.x, &t[0]);               \
-    r.y = fnc(v1.y, v2.y, &t[1]);               \
-    v3->x = t[0];                               \
-    v3->y = t[1];                               \
-    return r;                                   \
-}                                               \
+        fnc(float2 v1, float2 v2, int2 *v3);    \
 _RS_STATIC float3 __attribute__((overloadable)) \
-        fnc(float3 v1, float3 v2, int3 *v3) {   \
-    float3 r;                                   \
-    int t[3];                                   \
-    r.x = fnc(v1.x, v2.x, &t[0]);               \
-    r.y = fnc(v1.y, v2.y, &t[1]);               \
-    r.z = fnc(v1.z, v2.z, &t[2]);               \
-    v3->x = t[0];                               \
-    v3->y = t[1];                               \
-    v3->z = t[2];                               \
-    return r;                                   \
-}                                               \
+        fnc(float3 v1, float3 v2, int3 *v3);    \
 _RS_STATIC float4 __attribute__((overloadable)) \
-        fnc(float4 v1, float4 v2, int4 *v3) {   \
-    float4 r;                                   \
-    int t[4];                                   \
-    r.x = fnc(v1.x, v2.x, &t[0]);               \
-    r.y = fnc(v1.y, v2.y, &t[1]);               \
-    r.z = fnc(v1.z, v2.z, &t[2]);               \
-    r.w = fnc(v1.w, v2.w, &t[3]);               \
-    v3->x = t[0];                               \
-    v3->y = t[1];                               \
-    v3->z = t[2];                               \
-    v3->w = t[3];                               \
-    return r;                                   \
-}
+        fnc(float4 v1, float4 v2, int4 *v3);
 
 
 extern float __attribute__((overloadable)) acos(float);
@@ -326,9 +97,9 @@
 extern float __attribute__((overloadable)) acosh(float);
 FN_FUNC_FN(acosh)
 
-_RS_STATIC float __attribute__((overloadable)) acospi(float v) {
-    return acos(v) / M_PI;
-}
+_RS_STATIC float __attribute__((overloadable)) acospi(float v);
+
+
 FN_FUNC_FN(acospi)
 
 extern float __attribute__((overloadable)) asin(float);
@@ -337,9 +108,8 @@
 extern float __attribute__((overloadable)) asinh(float);
 FN_FUNC_FN(asinh)
 
-_RS_STATIC float __attribute__((overloadable)) asinpi(float v) {
-    return asin(v) / M_PI;
-}
+
+_RS_STATIC float __attribute__((overloadable)) asinpi(float v);
 FN_FUNC_FN(asinpi)
 
 extern float __attribute__((overloadable)) atan(float);
@@ -351,14 +121,12 @@
 extern float __attribute__((overloadable)) atanh(float);
 FN_FUNC_FN(atanh)
 
-_RS_STATIC float __attribute__((overloadable)) atanpi(float v) {
-    return atan(v) / M_PI;
-}
+
+_RS_STATIC float __attribute__((overloadable)) atanpi(float v);
 FN_FUNC_FN(atanpi)
 
-_RS_STATIC float __attribute__((overloadable)) atan2pi(float y, float x) {
-    return atan2(y, x) / M_PI;
-}
+
+_RS_STATIC float __attribute__((overloadable)) atan2pi(float y, float x);
 FN_FUNC_FN_FN(atan2pi)
 
 extern float __attribute__((overloadable)) cbrt(float);
@@ -376,9 +144,8 @@
 extern float __attribute__((overloadable)) cosh(float);
 FN_FUNC_FN(cosh)
 
-_RS_STATIC float __attribute__((overloadable)) cospi(float v) {
-    return cos(v * M_PI);
-}
+
+_RS_STATIC float __attribute__((overloadable)) cospi(float v);
 FN_FUNC_FN(cospi)
 
 extern float __attribute__((overloadable)) erfc(float);
@@ -394,9 +161,8 @@
 FN_FUNC_FN(exp2)
 
 extern float __attribute__((overloadable)) pow(float, float);
-_RS_STATIC float __attribute__((overloadable)) exp10(float v) {
-    return pow(10.f, v);
-}
+
+_RS_STATIC float __attribute__((overloadable)) exp10(float v);
 FN_FUNC_FN(exp10)
 
 extern float __attribute__((overloadable)) expm1(float);
@@ -425,11 +191,8 @@
 extern float __attribute__((overloadable)) fmod(float, float);
 FN_FUNC_FN_FN(fmod)
 
-_RS_STATIC float __attribute__((overloadable)) fract(float v, float *iptr) {
-    int i = (int)floor(v);
-    iptr[0] = i;
-    return fmin(v - i, 0x1.fffffep-1f);
-}
+
+_RS_STATIC float __attribute__((overloadable)) fract(float v, float *iptr);
 FN_FUNC_FN_PFN(fract)
 
 extern float __attribute__((overloadable)) frexp(float, int *);
@@ -457,9 +220,8 @@
 extern float __attribute__((overloadable)) log10(float);
 FN_FUNC_FN(log10)
 
-_RS_STATIC float __attribute__((overloadable)) log2(float v) {
-    return log10(v) / log10(2.f);
-}
+
+_RS_STATIC float __attribute__((overloadable)) log2(float v);
 FN_FUNC_FN(log2)
 
 extern float __attribute__((overloadable)) log1p(float);
@@ -481,31 +243,15 @@
 
 FN_FUNC_FN_FN(pow)
 
-_RS_STATIC float __attribute__((overloadable)) pown(float v, int p) {
-    return pow(v, (float)p);
-}
-_RS_STATIC float2 __attribute__((overloadable)) pown(float2 v, int2 p) {
-    return pow(v, (float2)p);
-}
-_RS_STATIC float3 __attribute__((overloadable)) pown(float3 v, int3 p) {
-    return pow(v, (float3)p);
-}
-_RS_STATIC float4 __attribute__((overloadable)) pown(float4 v, int4 p) {
-    return pow(v, (float4)p);
-}
+_RS_STATIC float __attribute__((overloadable)) pown(float v, int p);
+_RS_STATIC float2 __attribute__((overloadable)) pown(float2 v, int2 p);
+_RS_STATIC float3 __attribute__((overloadable)) pown(float3 v, int3 p);
+_RS_STATIC float4 __attribute__((overloadable)) pown(float4 v, int4 p);
 
-_RS_STATIC float __attribute__((overloadable)) powr(float v, float p) {
-    return pow(v, p);
-}
-_RS_STATIC float2 __attribute__((overloadable)) powr(float2 v, float2 p) {
-    return pow(v, p);
-}
-_RS_STATIC float3 __attribute__((overloadable)) powr(float3 v, float3 p) {
-    return pow(v, p);
-}
-_RS_STATIC float4 __attribute__((overloadable)) powr(float4 v, float4 p) {
-    return pow(v, p);
-}
+_RS_STATIC float __attribute__((overloadable)) powr(float v, float p);
+_RS_STATIC float2 __attribute__((overloadable)) powr(float2 v, float2 p);
+_RS_STATIC float3 __attribute__((overloadable)) powr(float3 v, float3 p);
+_RS_STATIC float4 __attribute__((overloadable)) powr(float4 v, float4 p);
 
 extern float __attribute__((overloadable)) remainder(float, float);
 FN_FUNC_FN_FN(remainder)
@@ -516,57 +262,33 @@
 extern float __attribute__((overloadable)) rint(float);
 FN_FUNC_FN(rint)
 
-_RS_STATIC float __attribute__((overloadable)) rootn(float v, int r) {
-    return pow(v, 1.f / r);
-}
-_RS_STATIC float2 __attribute__((overloadable)) rootn(float2 v, int2 r) {
-    float2 t = {1.f / r.x, 1.f / r.y};
-    return pow(v, t);
-}
-_RS_STATIC float3 __attribute__((overloadable)) rootn(float3 v, int3 r) {
-    float3 t = {1.f / r.x, 1.f / r.y, 1.f / r.z};
-    return pow(v, t);
-}
-_RS_STATIC float4 __attribute__((overloadable)) rootn(float4 v, int4 r) {
-    float4 t = {1.f / r.x, 1.f / r.y, 1.f / r.z, 1.f / r.w};
-    return pow(v, t);
-}
+
+_RS_STATIC float __attribute__((overloadable)) rootn(float v, int r);
+_RS_STATIC float2 __attribute__((overloadable)) rootn(float2 v, int2 r);
+_RS_STATIC float3 __attribute__((overloadable)) rootn(float3 v, int3 r);
+_RS_STATIC float4 __attribute__((overloadable)) rootn(float4 v, int4 r);
+
 
 extern float __attribute__((overloadable)) round(float);
 FN_FUNC_FN(round)
 
+
 extern float __attribute__((overloadable)) sqrt(float);
-_RS_STATIC float __attribute__((overloadable)) rsqrt(float v) {
-    return 1.f / sqrt(v);
-}
+_RS_STATIC float __attribute__((overloadable)) rsqrt(float v);
 FN_FUNC_FN(rsqrt)
 
 extern float __attribute__((overloadable)) sin(float);
 FN_FUNC_FN(sin)
 
-_RS_STATIC float __attribute__((overloadable)) sincos(float v, float *cosptr) {
-    *cosptr = cos(v);
-    return sin(v);
-}
-_RS_STATIC float2 __attribute__((overloadable)) sincos(float2 v, float2 *cosptr) {
-    *cosptr = cos(v);
-    return sin(v);
-}
-_RS_STATIC float3 __attribute__((overloadable)) sincos(float3 v, float3 *cosptr) {
-    *cosptr = cos(v);
-    return sin(v);
-}
-_RS_STATIC float4 __attribute__((overloadable)) sincos(float4 v, float4 *cosptr) {
-    *cosptr = cos(v);
-    return sin(v);
-}
+_RS_STATIC float __attribute__((overloadable)) sincos(float v, float *cosptr);
+_RS_STATIC float2 __attribute__((overloadable)) sincos(float2 v, float2 *cosptr);
+_RS_STATIC float3 __attribute__((overloadable)) sincos(float3 v, float3 *cosptr);
+_RS_STATIC float4 __attribute__((overloadable)) sincos(float4 v, float4 *cosptr);
 
 extern float __attribute__((overloadable)) sinh(float);
 FN_FUNC_FN(sinh)
 
-_RS_STATIC float __attribute__((overloadable)) sinpi(float v) {
-    return sin(v * M_PI);
-}
+_RS_STATIC float __attribute__((overloadable)) sinpi(float v);
 FN_FUNC_FN(sinpi)
 
 FN_FUNC_FN(sqrt)
@@ -577,11 +299,10 @@
 extern float __attribute__((overloadable)) tanh(float);
 FN_FUNC_FN(tanh)
 
-_RS_STATIC float __attribute__((overloadable)) tanpi(float v) {
-    return tan(v * M_PI);
-}
+_RS_STATIC float __attribute__((overloadable)) tanpi(float v);
 FN_FUNC_FN(tanpi)
 
+
 extern float __attribute__((overloadable)) tgamma(float);
 FN_FUNC_FN(tgamma)
 
@@ -592,27 +313,9 @@
 
 #define XN_FUNC_YN(typeout, fnc, typein)                                \
 extern typeout __attribute__((overloadable)) fnc(typein);               \
-_RS_STATIC typeout##2 __attribute__((overloadable)) fnc(typein##2 v) {  \
-    typeout##2 r;                                                       \
-    r.x = fnc(v.x);                                                     \
-    r.y = fnc(v.y);                                                     \
-    return r;                                                           \
-}                                                                       \
-_RS_STATIC typeout##3 __attribute__((overloadable)) fnc(typein##3 v) {  \
-    typeout##3 r;                                                       \
-    r.x = fnc(v.x);                                                     \
-    r.y = fnc(v.y);                                                     \
-    r.z = fnc(v.z);                                                     \
-    return r;                                                           \
-}                                                                       \
-_RS_STATIC typeout##4 __attribute__((overloadable)) fnc(typein##4 v) {  \
-    typeout##4 r;                                                       \
-    r.x = fnc(v.x);                                                     \
-    r.y = fnc(v.y);                                                     \
-    r.z = fnc(v.z);                                                     \
-    r.w = fnc(v.w);                                                     \
-    return r;                                                           \
-}
+_RS_STATIC typeout##2 __attribute__((overloadable)) fnc(typein##2 v);   \
+_RS_STATIC typeout##3 __attribute__((overloadable)) fnc(typein##3 v);   \
+_RS_STATIC typeout##4 __attribute__((overloadable)) fnc(typein##4 v);
 
 #define UIN_FUNC_IN(fnc)          \
 XN_FUNC_YN(uchar, fnc, char)      \
@@ -627,35 +330,16 @@
 XN_FUNC_YN(uint, fnc, uint)       \
 XN_FUNC_YN(int, fnc, int)
 
+
 #define XN_FUNC_XN_XN_BODY(type, fnc, body)         \
 _RS_STATIC type __attribute__((overloadable))       \
-        fnc(type v1, type v2) {                     \
-    return body;                                    \
-}                                                   \
+        fnc(type v1, type v2);                      \
 _RS_STATIC type##2 __attribute__((overloadable))    \
-        fnc(type##2 v1, type##2 v2) {               \
-    type##2 r;                                      \
-    r.x = fnc(v1.x, v2.x);                          \
-    r.y = fnc(v1.y, v2.y);                          \
-    return r;                                       \
-}                                                   \
+        fnc(type##2 v1, type##2 v2);                \
 _RS_STATIC type##3 __attribute__((overloadable))    \
-        fnc(type##3 v1, type##3 v2) {               \
-    type##3 r;                                      \
-    r.x = fnc(v1.x, v2.x);                          \
-    r.y = fnc(v1.y, v2.y);                          \
-    r.z = fnc(v1.z, v2.z);                          \
-    return r;                                       \
-}                                                   \
+        fnc(type##3 v1, type##3 v2);                \
 _RS_STATIC type##4 __attribute__((overloadable))    \
-        fnc(type##4 v1, type##4 v2) {               \
-    type##4 r;                                      \
-    r.x = fnc(v1.x, v2.x);                          \
-    r.y = fnc(v1.y, v2.y);                          \
-    r.z = fnc(v1.z, v2.z);                          \
-    r.w = fnc(v1.w, v2.w);                          \
-    return r;                                       \
-}
+        fnc(type##4 v1, type##4 v2);
 
 #define IN_FUNC_IN_IN_BODY(fnc, body) \
 XN_FUNC_XN_XN_BODY(uchar, fnc, body)  \
@@ -677,129 +361,35 @@
 
 // 6.11.4
 
-_RS_STATIC float __attribute__((overloadable)) clamp(float amount, float low, float high) {
-    return amount < low ? low : (amount > high ? high : amount);
-}
-_RS_STATIC float2 __attribute__((overloadable)) clamp(float2 amount, float2 low, float2 high) {
-    float2 r;
-    r.x = amount.x < low.x ? low.x : (amount.x > high.x ? high.x : amount.x);
-    r.y = amount.y < low.y ? low.y : (amount.y > high.y ? high.y : amount.y);
-    return r;
-}
-_RS_STATIC float3 __attribute__((overloadable)) clamp(float3 amount, float3 low, float3 high) {
-    float3 r;
-    r.x = amount.x < low.x ? low.x : (amount.x > high.x ? high.x : amount.x);
-    r.y = amount.y < low.y ? low.y : (amount.y > high.y ? high.y : amount.y);
-    r.z = amount.z < low.z ? low.z : (amount.z > high.z ? high.z : amount.z);
-    return r;
-}
-_RS_STATIC float4 __attribute__((overloadable)) clamp(float4 amount, float4 low, float4 high) {
-    float4 r;
-    r.x = amount.x < low.x ? low.x : (amount.x > high.x ? high.x : amount.x);
-    r.y = amount.y < low.y ? low.y : (amount.y > high.y ? high.y : amount.y);
-    r.z = amount.z < low.z ? low.z : (amount.z > high.z ? high.z : amount.z);
-    r.w = amount.w < low.w ? low.w : (amount.w > high.w ? high.w : amount.w);
-    return r;
-}
-_RS_STATIC float2 __attribute__((overloadable)) clamp(float2 amount, float low, float high) {
-    float2 r;
-    r.x = amount.x < low ? low : (amount.x > high ? high : amount.x);
-    r.y = amount.y < low ? low : (amount.y > high ? high : amount.y);
-    return r;
-}
-_RS_STATIC float3 __attribute__((overloadable)) clamp(float3 amount, float low, float high) {
-    float3 r;
-    r.x = amount.x < low ? low : (amount.x > high ? high : amount.x);
-    r.y = amount.y < low ? low : (amount.y > high ? high : amount.y);
-    r.z = amount.z < low ? low : (amount.z > high ? high : amount.z);
-    return r;
-}
-_RS_STATIC float4 __attribute__((overloadable)) clamp(float4 amount, float low, float high) {
-    float4 r;
-    r.x = amount.x < low ? low : (amount.x > high ? high : amount.x);
-    r.y = amount.y < low ? low : (amount.y > high ? high : amount.y);
-    r.z = amount.z < low ? low : (amount.z > high ? high : amount.z);
-    r.w = amount.w < low ? low : (amount.w > high ? high : amount.w);
-    return r;
-}
+_RS_STATIC float __attribute__((overloadable)) clamp(float amount, float low, float high);
+_RS_STATIC float2 __attribute__((overloadable)) clamp(float2 amount, float2 low, float2 high);
+_RS_STATIC float3 __attribute__((overloadable)) clamp(float3 amount, float3 low, float3 high);
+_RS_STATIC float4 __attribute__((overloadable)) clamp(float4 amount, float4 low, float4 high);
+_RS_STATIC float2 __attribute__((overloadable)) clamp(float2 amount, float low, float high);
+_RS_STATIC float3 __attribute__((overloadable)) clamp(float3 amount, float low, float high);
+_RS_STATIC float4 __attribute__((overloadable)) clamp(float4 amount, float low, float high);
 
-_RS_STATIC float __attribute__((overloadable)) degrees(float radians) {
-    return radians * (180.f / M_PI);
-}
+_RS_STATIC float __attribute__((overloadable)) degrees(float radians);
 FN_FUNC_FN(degrees)
 
-_RS_STATIC float __attribute__((overloadable)) mix(float start, float stop, float amount) {
-    return start + (stop - start) * amount;
-}
-_RS_STATIC float2 __attribute__((overloadable)) mix(float2 start, float2 stop, float2 amount) {
-    return start + (stop - start) * amount;
-}
-_RS_STATIC float3 __attribute__((overloadable)) mix(float3 start, float3 stop, float3 amount) {
-    return start + (stop - start) * amount;
-}
-_RS_STATIC float4 __attribute__((overloadable)) mix(float4 start, float4 stop, float4 amount) {
-    return start + (stop - start) * amount;
-}
-_RS_STATIC float2 __attribute__((overloadable)) mix(float2 start, float2 stop, float amount) {
-    return start + (stop - start) * amount;
-}
-_RS_STATIC float3 __attribute__((overloadable)) mix(float3 start, float3 stop, float amount) {
-    return start + (stop - start) * amount;
-}
-_RS_STATIC float4 __attribute__((overloadable)) mix(float4 start, float4 stop, float amount) {
-    return start + (stop - start) * amount;
-}
+_RS_STATIC float __attribute__((overloadable)) mix(float start, float stop, float amount);
+_RS_STATIC float2 __attribute__((overloadable)) mix(float2 start, float2 stop, float2 amount);
+_RS_STATIC float3 __attribute__((overloadable)) mix(float3 start, float3 stop, float3 amount);
+_RS_STATIC float4 __attribute__((overloadable)) mix(float4 start, float4 stop, float4 amount);
+_RS_STATIC float2 __attribute__((overloadable)) mix(float2 start, float2 stop, float amount);
+_RS_STATIC float3 __attribute__((overloadable)) mix(float3 start, float3 stop, float amount);
+_RS_STATIC float4 __attribute__((overloadable)) mix(float4 start, float4 stop, float amount);
 
-_RS_STATIC float __attribute__((overloadable)) radians(float degrees) {
-    return degrees * (M_PI / 180.f);
-}
+_RS_STATIC float __attribute__((overloadable)) radians(float degrees);
 FN_FUNC_FN(radians)
 
-_RS_STATIC float __attribute__((overloadable)) step(float edge, float v) {
-    return (v < edge) ? 0.f : 1.f;
-}
-_RS_STATIC float2 __attribute__((overloadable)) step(float2 edge, float2 v) {
-    float2 r;
-    r.x = (v.x < edge.x) ? 0.f : 1.f;
-    r.y = (v.y < edge.y) ? 0.f : 1.f;
-    return r;
-}
-_RS_STATIC float3 __attribute__((overloadable)) step(float3 edge, float3 v) {
-    float3 r;
-    r.x = (v.x < edge.x) ? 0.f : 1.f;
-    r.y = (v.y < edge.y) ? 0.f : 1.f;
-    r.z = (v.z < edge.z) ? 0.f : 1.f;
-    return r;
-}
-_RS_STATIC float4 __attribute__((overloadable)) step(float4 edge, float4 v) {
-    float4 r;
-    r.x = (v.x < edge.x) ? 0.f : 1.f;
-    r.y = (v.y < edge.y) ? 0.f : 1.f;
-    r.z = (v.z < edge.z) ? 0.f : 1.f;
-    r.w = (v.w < edge.w) ? 0.f : 1.f;
-    return r;
-}
-_RS_STATIC float2 __attribute__((overloadable)) step(float2 edge, float v) {
-    float2 r;
-    r.x = (v < edge.x) ? 0.f : 1.f;
-    r.y = (v < edge.y) ? 0.f : 1.f;
-    return r;
-}
-_RS_STATIC float3 __attribute__((overloadable)) step(float3 edge, float v) {
-    float3 r;
-    r.x = (v < edge.x) ? 0.f : 1.f;
-    r.y = (v < edge.y) ? 0.f : 1.f;
-    r.z = (v < edge.z) ? 0.f : 1.f;
-    return r;
-}
-_RS_STATIC float4 __attribute__((overloadable)) step(float4 edge, float v) {
-    float4 r;
-    r.x = (v < edge.x) ? 0.f : 1.f;
-    r.y = (v < edge.y) ? 0.f : 1.f;
-    r.z = (v < edge.z) ? 0.f : 1.f;
-    r.w = (v < edge.w) ? 0.f : 1.f;
-    return r;
-}
+_RS_STATIC float __attribute__((overloadable)) step(float edge, float v);
+_RS_STATIC float2 __attribute__((overloadable)) step(float2 edge, float2 v);
+_RS_STATIC float3 __attribute__((overloadable)) step(float3 edge, float3 v);
+_RS_STATIC float4 __attribute__((overloadable)) step(float4 edge, float4 v);
+_RS_STATIC float2 __attribute__((overloadable)) step(float2 edge, float v);
+_RS_STATIC float3 __attribute__((overloadable)) step(float3 edge, float v);
+_RS_STATIC float4 __attribute__((overloadable)) step(float4 edge, float v);
 
 extern float __attribute__((overloadable)) smoothstep(float, float, float);
 extern float2 __attribute__((overloadable)) smoothstep(float2, float2, float2);
@@ -809,82 +399,33 @@
 extern float3 __attribute__((overloadable)) smoothstep(float, float, float3);
 extern float4 __attribute__((overloadable)) smoothstep(float, float, float4);
 
-_RS_STATIC float __attribute__((overloadable)) sign(float v) {
-    if (v > 0) return 1.f;
-    if (v < 0) return -1.f;
-    return v;
-}
+_RS_STATIC float __attribute__((overloadable)) sign(float v);
 FN_FUNC_FN(sign)
 
 // 6.11.5
-_RS_STATIC float3 __attribute__((overloadable)) cross(float3 lhs, float3 rhs) {
-    float3 r;
-    r.x = lhs.y * rhs.z  - lhs.z * rhs.y;
-    r.y = lhs.z * rhs.x  - lhs.x * rhs.z;
-    r.z = lhs.x * rhs.y  - lhs.y * rhs.x;
-    return r;
-}
+_RS_STATIC float3 __attribute__((overloadable)) cross(float3 lhs, float3 rhs);
 
-_RS_STATIC float4 __attribute__((overloadable)) cross(float4 lhs, float4 rhs) {
-    float4 r;
-    r.x = lhs.y * rhs.z  - lhs.z * rhs.y;
-    r.y = lhs.z * rhs.x  - lhs.x * rhs.z;
-    r.z = lhs.x * rhs.y  - lhs.y * rhs.x;
-    r.w = 0.f;
-    return r;
-}
+_RS_STATIC float4 __attribute__((overloadable)) cross(float4 lhs, float4 rhs);
 
-_RS_STATIC float __attribute__((overloadable)) dot(float lhs, float rhs) {
-    return lhs * rhs;
-}
-_RS_STATIC float __attribute__((overloadable)) dot(float2 lhs, float2 rhs) {
-    return lhs.x*rhs.x + lhs.y*rhs.y;
-}
-_RS_STATIC float __attribute__((overloadable)) dot(float3 lhs, float3 rhs) {
-    return lhs.x*rhs.x + lhs.y*rhs.y + lhs.z*rhs.z;
-}
-_RS_STATIC float __attribute__((overloadable)) dot(float4 lhs, float4 rhs) {
-    return lhs.x*rhs.x + lhs.y*rhs.y + lhs.z*rhs.z + lhs.w*rhs.w;
-}
+_RS_STATIC float __attribute__((overloadable)) dot(float lhs, float rhs);
+_RS_STATIC float __attribute__((overloadable)) dot(float2 lhs, float2 rhs);
+_RS_STATIC float __attribute__((overloadable)) dot(float3 lhs, float3 rhs);
+_RS_STATIC float __attribute__((overloadable)) dot(float4 lhs, float4 rhs);
 
-_RS_STATIC float __attribute__((overloadable)) length(float v) {
-    return v;
-}
-_RS_STATIC float __attribute__((overloadable)) length(float2 v) {
-    return sqrt(v.x*v.x + v.y*v.y);
-}
-_RS_STATIC float __attribute__((overloadable)) length(float3 v) {
-    return sqrt(v.x*v.x + v.y*v.y + v.z*v.z);
-}
-_RS_STATIC float __attribute__((overloadable)) length(float4 v) {
-    return sqrt(v.x*v.x + v.y*v.y + v.z*v.z + v.w*v.w);
-}
+_RS_STATIC float __attribute__((overloadable)) length(float v);
+_RS_STATIC float __attribute__((overloadable)) length(float2 v);
+_RS_STATIC float __attribute__((overloadable)) length(float3 v);
+_RS_STATIC float __attribute__((overloadable)) length(float4 v);
 
-_RS_STATIC float __attribute__((overloadable)) distance(float lhs, float rhs) {
-    return length(lhs - rhs);
-}
-_RS_STATIC float __attribute__((overloadable)) distance(float2 lhs, float2 rhs) {
-    return length(lhs - rhs);
-}
-_RS_STATIC float __attribute__((overloadable)) distance(float3 lhs, float3 rhs) {
-    return length(lhs - rhs);
-}
-_RS_STATIC float __attribute__((overloadable)) distance(float4 lhs, float4 rhs) {
-    return length(lhs - rhs);
-}
+_RS_STATIC float __attribute__((overloadable)) distance(float lhs, float rhs);
+_RS_STATIC float __attribute__((overloadable)) distance(float2 lhs, float2 rhs);
+_RS_STATIC float __attribute__((overloadable)) distance(float3 lhs, float3 rhs);
+_RS_STATIC float __attribute__((overloadable)) distance(float4 lhs, float4 rhs);
 
-_RS_STATIC float __attribute__((overloadable)) normalize(float v) {
-    return 1.f;
-}
-_RS_STATIC float2 __attribute__((overloadable)) normalize(float2 v) {
-    return v / length(v);
-}
-_RS_STATIC float3 __attribute__((overloadable)) normalize(float3 v) {
-    return v / length(v);
-}
-_RS_STATIC float4 __attribute__((overloadable)) normalize(float4 v) {
-    return v / length(v);
-}
+_RS_STATIC float __attribute__((overloadable)) normalize(float v);
+_RS_STATIC float2 __attribute__((overloadable)) normalize(float2 v);
+_RS_STATIC float3 __attribute__((overloadable)) normalize(float3 v);
+_RS_STATIC float4 __attribute__((overloadable)) normalize(float4 v);
 
 #undef CVT_FUNC
 #undef CVT_FUNC_2
diff --git a/libs/rs/scriptc/rs_core.rsh b/libs/rs/scriptc/rs_core.rsh
index 21c0f7b..fdaa903 100644
--- a/libs/rs/scriptc/rs_core.rsh
+++ b/libs/rs/scriptc/rs_core.rsh
@@ -131,352 +131,62 @@
     return m->m[row * 2 + col];
 }
 
-_RS_STATIC void __attribute__((overloadable))
-rsMatrixLoadIdentity(rs_matrix4x4 *m) {
-    m->m[0] = 1.f;
-    m->m[1] = 0.f;
-    m->m[2] = 0.f;
-    m->m[3] = 0.f;
-    m->m[4] = 0.f;
-    m->m[5] = 1.f;
-    m->m[6] = 0.f;
-    m->m[7] = 0.f;
-    m->m[8] = 0.f;
-    m->m[9] = 0.f;
-    m->m[10] = 1.f;
-    m->m[11] = 0.f;
-    m->m[12] = 0.f;
-    m->m[13] = 0.f;
-    m->m[14] = 0.f;
-    m->m[15] = 1.f;
-}
+extern void __attribute__((overloadable)) rsMatrixLoadIdentity(rs_matrix4x4 *m);
+extern void __attribute__((overloadable)) rsMatrixLoadIdentity(rs_matrix3x3 *m);
+extern void __attribute__((overloadable)) rsMatrixLoadIdentity(rs_matrix2x2 *m);
+extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix4x4 *m, const float *v);
+extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix3x3 *m, const float *v);
+extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix2x2 *m, const float *v);
+extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix4x4 *m, const rs_matrix4x4 *v);
+extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix4x4 *m, const rs_matrix3x3 *v);
+extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix4x4 *m, const rs_matrix2x2 *v);
+extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix3x3 *m, const rs_matrix3x3 *v);
+extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix2x2 *m, const rs_matrix2x2 *v);
 
-_RS_STATIC void __attribute__((overloadable))
-rsMatrixLoadIdentity(rs_matrix3x3 *m) {
-    m->m[0] = 1.f;
-    m->m[1] = 0.f;
-    m->m[2] = 0.f;
-    m->m[3] = 0.f;
-    m->m[4] = 1.f;
-    m->m[5] = 0.f;
-    m->m[6] = 0.f;
-    m->m[7] = 0.f;
-    m->m[8] = 1.f;
-}
+extern void __attribute__((overloadable))
+rsMatrixLoadRotate(rs_matrix4x4 *m, float rot, float x, float y, float z);
 
-_RS_STATIC void __attribute__((overloadable))
-rsMatrixLoadIdentity(rs_matrix2x2 *m) {
-    m->m[0] = 1.f;
-    m->m[1] = 0.f;
-    m->m[2] = 0.f;
-    m->m[3] = 1.f;
-}
+extern void __attribute__((overloadable))
+rsMatrixLoadScale(rs_matrix4x4 *m, float x, float y, float z);
 
-_RS_STATIC void __attribute__((overloadable))
-rsMatrixLoad(rs_matrix4x4 *m, const float *v) {
-    m->m[0] = v[0];
-    m->m[1] = v[1];
-    m->m[2] = v[2];
-    m->m[3] = v[3];
-    m->m[4] = v[4];
-    m->m[5] = v[5];
-    m->m[6] = v[6];
-    m->m[7] = v[7];
-    m->m[8] = v[8];
-    m->m[9] = v[9];
-    m->m[10] = v[10];
-    m->m[11] = v[11];
-    m->m[12] = v[12];
-    m->m[13] = v[13];
-    m->m[14] = v[14];
-    m->m[15] = v[15];
-}
+extern void __attribute__((overloadable))
+rsMatrixLoadTranslate(rs_matrix4x4 *m, float x, float y, float z);
 
-_RS_STATIC void __attribute__((overloadable))
-rsMatrixLoad(rs_matrix3x3 *m, const float *v) {
-    m->m[0] = v[0];
-    m->m[1] = v[1];
-    m->m[2] = v[2];
-    m->m[3] = v[3];
-    m->m[4] = v[4];
-    m->m[5] = v[5];
-    m->m[6] = v[6];
-    m->m[7] = v[7];
-    m->m[8] = v[8];
-}
+extern void __attribute__((overloadable))
+rsMatrixLoadMultiply(rs_matrix4x4 *m, const rs_matrix4x4 *lhs, const rs_matrix4x4 *rhs);
 
-_RS_STATIC void __attribute__((overloadable))
-rsMatrixLoad(rs_matrix2x2 *m, const float *v) {
-    m->m[0] = v[0];
-    m->m[1] = v[1];
-    m->m[2] = v[2];
-    m->m[3] = v[3];
-}
+extern void __attribute__((overloadable))
+rsMatrixMultiply(rs_matrix4x4 *m, const rs_matrix4x4 *rhs);
 
-_RS_STATIC void __attribute__((overloadable))
-rsMatrixLoad(rs_matrix4x4 *m, const rs_matrix4x4 *v) {
-    m->m[0] = v->m[0];
-    m->m[1] = v->m[1];
-    m->m[2] = v->m[2];
-    m->m[3] = v->m[3];
-    m->m[4] = v->m[4];
-    m->m[5] = v->m[5];
-    m->m[6] = v->m[6];
-    m->m[7] = v->m[7];
-    m->m[8] = v->m[8];
-    m->m[9] = v->m[9];
-    m->m[10] = v->m[10];
-    m->m[11] = v->m[11];
-    m->m[12] = v->m[12];
-    m->m[13] = v->m[13];
-    m->m[14] = v->m[14];
-    m->m[15] = v->m[15];
-}
+extern void __attribute__((overloadable))
+rsMatrixLoadMultiply(rs_matrix3x3 *m, const rs_matrix3x3 *lhs, const rs_matrix3x3 *rhs);
 
-_RS_STATIC void __attribute__((overloadable))
-rsMatrixLoad(rs_matrix4x4 *m, const rs_matrix3x3 *v) {
-    m->m[0] = v->m[0];
-    m->m[1] = v->m[1];
-    m->m[2] = v->m[2];
-    m->m[3] = 0.f;
-    m->m[4] = v->m[3];
-    m->m[5] = v->m[4];
-    m->m[6] = v->m[5];
-    m->m[7] = 0.f;
-    m->m[8] = v->m[6];
-    m->m[9] = v->m[7];
-    m->m[10] = v->m[8];
-    m->m[11] = 0.f;
-    m->m[12] = 0.f;
-    m->m[13] = 0.f;
-    m->m[14] = 0.f;
-    m->m[15] = 1.f;
-}
+extern void __attribute__((overloadable))
+rsMatrixMultiply(rs_matrix3x3 *m, const rs_matrix3x3 *rhs);
 
-_RS_STATIC void __attribute__((overloadable))
-rsMatrixLoad(rs_matrix4x4 *m, const rs_matrix2x2 *v) {
-    m->m[0] = v->m[0];
-    m->m[1] = v->m[1];
-    m->m[2] = 0.f;
-    m->m[3] = 0.f;
-    m->m[4] = v->m[3];
-    m->m[5] = v->m[4];
-    m->m[6] = 0.f;
-    m->m[7] = 0.f;
-    m->m[8] = v->m[6];
-    m->m[9] = v->m[7];
-    m->m[10] = 1.f;
-    m->m[11] = 0.f;
-    m->m[12] = 0.f;
-    m->m[13] = 0.f;
-    m->m[14] = 0.f;
-    m->m[15] = 1.f;
-}
+extern void __attribute__((overloadable))
+rsMatrixLoadMultiply(rs_matrix2x2 *m, const rs_matrix2x2 *lhs, const rs_matrix2x2 *rhs);
 
-_RS_STATIC void __attribute__((overloadable))
-rsMatrixLoad(rs_matrix3x3 *m, const rs_matrix3x3 *v) {
-    m->m[0] = v->m[0];
-    m->m[1] = v->m[1];
-    m->m[2] = v->m[2];
-    m->m[3] = v->m[3];
-    m->m[4] = v->m[4];
-    m->m[5] = v->m[5];
-    m->m[6] = v->m[6];
-    m->m[7] = v->m[7];
-    m->m[8] = v->m[8];
-}
+extern void __attribute__((overloadable))
+rsMatrixMultiply(rs_matrix2x2 *m, const rs_matrix2x2 *rhs);
 
-_RS_STATIC void __attribute__((overloadable))
-rsMatrixLoad(rs_matrix2x2 *m, const rs_matrix2x2 *v) {
-    m->m[0] = v->m[0];
-    m->m[1] = v->m[1];
-    m->m[2] = v->m[2];
-    m->m[3] = v->m[3];
-}
+extern void __attribute__((overloadable))
+rsMatrixRotate(rs_matrix4x4 *m, float rot, float x, float y, float z);
 
-_RS_STATIC void __attribute__((overloadable))
-rsMatrixLoadRotate(rs_matrix4x4 *m, float rot, float x, float y, float z) {
-    float c, s;
-    m->m[3] = 0;
-    m->m[7] = 0;
-    m->m[11]= 0;
-    m->m[12]= 0;
-    m->m[13]= 0;
-    m->m[14]= 0;
-    m->m[15]= 1;
-    rot *= (float)(M_PI / 180.0f);
-    c = cos(rot);
-    s = sin(rot);
+extern void __attribute__((overloadable))
+rsMatrixScale(rs_matrix4x4 *m, float x, float y, float z);
 
-    const float len = x*x + y*y + z*z;
-    if (len != 1) {
-        const float recipLen = 1.f / sqrt(len);
-        x *= recipLen;
-        y *= recipLen;
-        z *= recipLen;
-    }
-    const float nc = 1.0f - c;
-    const float xy = x * y;
-    const float yz = y * z;
-    const float zx = z * x;
-    const float xs = x * s;
-    const float ys = y * s;
-    const float zs = z * s;
-    m->m[ 0] = x*x*nc +  c;
-    m->m[ 4] =  xy*nc - zs;
-    m->m[ 8] =  zx*nc + ys;
-    m->m[ 1] =  xy*nc + zs;
-    m->m[ 5] = y*y*nc +  c;
-    m->m[ 9] =  yz*nc - xs;
-    m->m[ 2] =  zx*nc - ys;
-    m->m[ 6] =  yz*nc + xs;
-    m->m[10] = z*z*nc +  c;
-}
+extern void __attribute__((overloadable))
+rsMatrixTranslate(rs_matrix4x4 *m, float x, float y, float z);
 
-_RS_STATIC void __attribute__((overloadable))
-rsMatrixLoadScale(rs_matrix4x4 *m, float x, float y, float z) {
-    rsMatrixLoadIdentity(m);
-    m->m[0] = x;
-    m->m[5] = y;
-    m->m[10] = z;
-}
+extern void __attribute__((overloadable))
+rsMatrixLoadOrtho(rs_matrix4x4 *m, float left, float right, float bottom, float top, float near, float far);
 
-_RS_STATIC void __attribute__((overloadable))
-rsMatrixLoadTranslate(rs_matrix4x4 *m, float x, float y, float z) {
-    rsMatrixLoadIdentity(m);
-    m->m[12] = x;
-    m->m[13] = y;
-    m->m[14] = z;
-}
+extern void __attribute__((overloadable))
+rsMatrixLoadFrustum(rs_matrix4x4 *m, float left, float right, float bottom, float top, float near, float far);
 
-_RS_STATIC void __attribute__((overloadable))
-rsMatrixLoadMultiply(rs_matrix4x4 *m, const rs_matrix4x4 *lhs, const rs_matrix4x4 *rhs) {
-    for (int i=0 ; i<4 ; i++) {
-        float ri0 = 0;
-        float ri1 = 0;
-        float ri2 = 0;
-        float ri3 = 0;
-        for (int j=0 ; j<4 ; j++) {
-            const float rhs_ij = rsMatrixGet(rhs, i,j);
-            ri0 += rsMatrixGet(lhs, j, 0) * rhs_ij;
-            ri1 += rsMatrixGet(lhs, j, 1) * rhs_ij;
-            ri2 += rsMatrixGet(lhs, j, 2) * rhs_ij;
-            ri3 += rsMatrixGet(lhs, j, 3) * rhs_ij;
-        }
-        rsMatrixSet(m, i, 0, ri0);
-        rsMatrixSet(m, i, 1, ri1);
-        rsMatrixSet(m, i, 2, ri2);
-        rsMatrixSet(m, i, 3, ri3);
-    }
-}
-
-_RS_STATIC void __attribute__((overloadable))
-rsMatrixMultiply(rs_matrix4x4 *m, const rs_matrix4x4 *rhs) {
-    rs_matrix4x4 mt;
-    rsMatrixLoadMultiply(&mt, m, rhs);
-    rsMatrixLoad(m, &mt);
-}
-
-_RS_STATIC void __attribute__((overloadable))
-rsMatrixLoadMultiply(rs_matrix3x3 *m, const rs_matrix3x3 *lhs, const rs_matrix3x3 *rhs) {
-    for (int i=0 ; i<3 ; i++) {
-        float ri0 = 0;
-        float ri1 = 0;
-        float ri2 = 0;
-        for (int j=0 ; j<3 ; j++) {
-            const float rhs_ij = rsMatrixGet(rhs, i,j);
-            ri0 += rsMatrixGet(lhs, j, 0) * rhs_ij;
-            ri1 += rsMatrixGet(lhs, j, 1) * rhs_ij;
-            ri2 += rsMatrixGet(lhs, j, 2) * rhs_ij;
-        }
-        rsMatrixSet(m, i, 0, ri0);
-        rsMatrixSet(m, i, 1, ri1);
-        rsMatrixSet(m, i, 2, ri2);
-    }
-}
-
-_RS_STATIC void __attribute__((overloadable))
-rsMatrixMultiply(rs_matrix3x3 *m, const rs_matrix3x3 *rhs) {
-    rs_matrix3x3 mt;
-    rsMatrixLoadMultiply(&mt, m, rhs);
-    rsMatrixLoad(m, &mt);
-}
-
-_RS_STATIC void __attribute__((overloadable))
-rsMatrixLoadMultiply(rs_matrix2x2 *m, const rs_matrix2x2 *lhs, const rs_matrix2x2 *rhs) {
-    for (int i=0 ; i<2 ; i++) {
-        float ri0 = 0;
-        float ri1 = 0;
-        for (int j=0 ; j<2 ; j++) {
-            const float rhs_ij = rsMatrixGet(rhs, i,j);
-            ri0 += rsMatrixGet(lhs, j, 0) * rhs_ij;
-            ri1 += rsMatrixGet(lhs, j, 1) * rhs_ij;
-        }
-        rsMatrixSet(m, i, 0, ri0);
-        rsMatrixSet(m, i, 1, ri1);
-    }
-}
-
-_RS_STATIC void __attribute__((overloadable))
-rsMatrixMultiply(rs_matrix2x2 *m, const rs_matrix2x2 *rhs) {
-    rs_matrix2x2 mt;
-    rsMatrixLoadMultiply(&mt, m, rhs);
-    rsMatrixLoad(m, &mt);
-}
-
-_RS_STATIC void __attribute__((overloadable))
-rsMatrixRotate(rs_matrix4x4 *m, float rot, float x, float y, float z) {
-    rs_matrix4x4 m1;
-    rsMatrixLoadRotate(&m1, rot, x, y, z);
-    rsMatrixMultiply(m, &m1);
-}
-
-_RS_STATIC void __attribute__((overloadable))
-rsMatrixScale(rs_matrix4x4 *m, float x, float y, float z) {
-    rs_matrix4x4 m1;
-    rsMatrixLoadScale(&m1, x, y, z);
-    rsMatrixMultiply(m, &m1);
-}
-
-_RS_STATIC void __attribute__((overloadable))
-rsMatrixTranslate(rs_matrix4x4 *m, float x, float y, float z) {
-    rs_matrix4x4 m1;
-    rsMatrixLoadTranslate(&m1, x, y, z);
-    rsMatrixMultiply(m, &m1);
-}
-
-_RS_STATIC void __attribute__((overloadable))
-rsMatrixLoadOrtho(rs_matrix4x4 *m, float left, float right, float bottom, float top, float near, float far) {
-    rsMatrixLoadIdentity(m);
-    m->m[0] = 2.f / (right - left);
-    m->m[5] = 2.f / (top - bottom);
-    m->m[10]= -2.f / (far - near);
-    m->m[12]= -(right + left) / (right - left);
-    m->m[13]= -(top + bottom) / (top - bottom);
-    m->m[14]= -(far + near) / (far - near);
-}
-
-_RS_STATIC void __attribute__((overloadable))
-rsMatrixLoadFrustum(rs_matrix4x4 *m, float left, float right, float bottom, float top, float near, float far) {
-    rsMatrixLoadIdentity(m);
-    m->m[0] = 2.f * near / (right - left);
-    m->m[5] = 2.f * near / (top - bottom);
-    m->m[8] = (right + left) / (right - left);
-    m->m[9] = (top + bottom) / (top - bottom);
-    m->m[10]= -(far + near) / (far - near);
-    m->m[11]= -1.f;
-    m->m[14]= -2.f * far * near / (far - near);
-    m->m[15]= 0.f;
-}
-
-_RS_STATIC void __attribute__((overloadable))
-rsMatrixLoadPerspective(rs_matrix4x4* m, float fovy, float aspect, float near, float far) {
-    float top = near * tan((float) (fovy * M_PI / 360.0f));
-    float bottom = -top;
-    float left = bottom * aspect;
-    float right = top * aspect;
-    rsMatrixLoadFrustum(m, left, right, bottom, top, near, far);
-}
+extern void __attribute__((overloadable))
+rsMatrixLoadPerspective(rs_matrix4x4* m, float fovy, float aspect, float near, float far);
 
 _RS_STATIC float4 __attribute__((overloadable))
 rsMatrixMultiply(rs_matrix4x4 *m, float4 in) {
@@ -535,371 +245,11 @@
 }
 
 // Returns true if the matrix was successfully inversed
-_RS_STATIC bool __attribute__((overloadable))
-rsMatrixInverse(rs_matrix4x4 *m) {
-    rs_matrix4x4 result;
-
-    int i, j;
-    for (i = 0; i < 4; ++i) {
-        for (j = 0; j < 4; ++j) {
-            // computeCofactor for int i, int j
-            int c0 = (i+1) % 4;
-            int c1 = (i+2) % 4;
-            int c2 = (i+3) % 4;
-            int r0 = (j+1) % 4;
-            int r1 = (j+2) % 4;
-            int r2 = (j+3) % 4;
-
-            float minor = (m->m[c0 + 4*r0] * (m->m[c1 + 4*r1] * m->m[c2 + 4*r2] - m->m[c1 + 4*r2] * m->m[c2 + 4*r1]))
-                         - (m->m[c0 + 4*r1] * (m->m[c1 + 4*r0] * m->m[c2 + 4*r2] - m->m[c1 + 4*r2] * m->m[c2 + 4*r0]))
-                         + (m->m[c0 + 4*r2] * (m->m[c1 + 4*r0] * m->m[c2 + 4*r1] - m->m[c1 + 4*r1] * m->m[c2 + 4*r0]));
-
-            float cofactor = (i+j) & 1 ? -minor : minor;
-
-            result.m[4*i + j] = cofactor;
-        }
-    }
-
-    // Dot product of 0th column of source and 0th row of result
-    float det = m->m[0]*result.m[0] + m->m[4]*result.m[1] +
-                 m->m[8]*result.m[2] + m->m[12]*result.m[3];
-
-    if (fabs(det) < 1e-6) {
-        return false;
-    }
-
-    det = 1.0f / det;
-    for (i = 0; i < 16; ++i) {
-        m->m[i] = result.m[i] * det;
-    }
-
-    return true;
-}
-
-// Returns true if the matrix was successfully inversed
-_RS_STATIC bool __attribute__((overloadable))
-rsMatrixInverseTranspose(rs_matrix4x4 *m) {
-    rs_matrix4x4 result;
-
-    int i, j;
-    for (i = 0; i < 4; ++i) {
-        for (j = 0; j < 4; ++j) {
-            // computeCofactor for int i, int j
-            int c0 = (i+1) % 4;
-            int c1 = (i+2) % 4;
-            int c2 = (i+3) % 4;
-            int r0 = (j+1) % 4;
-            int r1 = (j+2) % 4;
-            int r2 = (j+3) % 4;
-
-            float minor = (m->m[c0 + 4*r0] * (m->m[c1 + 4*r1] * m->m[c2 + 4*r2] - m->m[c1 + 4*r2] * m->m[c2 + 4*r1]))
-                         - (m->m[c0 + 4*r1] * (m->m[c1 + 4*r0] * m->m[c2 + 4*r2] - m->m[c1 + 4*r2] * m->m[c2 + 4*r0]))
-                         + (m->m[c0 + 4*r2] * (m->m[c1 + 4*r0] * m->m[c2 + 4*r1] - m->m[c1 + 4*r1] * m->m[c2 + 4*r0]));
-
-            float cofactor = (i+j) & 1 ? -minor : minor;
-
-            result.m[4*j + i] = cofactor;
-        }
-    }
-
-    // Dot product of 0th column of source and 0th column of result
-    float det = m->m[0]*result.m[0] + m->m[4]*result.m[4] +
-                 m->m[8]*result.m[8] + m->m[12]*result.m[12];
-
-    if (fabs(det) < 1e-6) {
-        return false;
-    }
-
-    det = 1.0f / det;
-    for (i = 0; i < 16; ++i) {
-        m->m[i] = result.m[i] * det;
-    }
-
-    return true;
-}
-
-_RS_STATIC void __attribute__((overloadable))
-rsMatrixTranspose(rs_matrix4x4 *m) {
-    int i, j;
-    float temp;
-    for (i = 0; i < 3; ++i) {
-        for (j = i + 1; j < 4; ++j) {
-            temp = m->m[i*4 + j];
-            m->m[i*4 + j] = m->m[j*4 + i];
-            m->m[j*4 + i] = temp;
-        }
-    }
-}
-
-_RS_STATIC void __attribute__((overloadable))
-rsMatrixTranspose(rs_matrix3x3 *m) {
-    int i, j;
-    float temp;
-    for (i = 0; i < 2; ++i) {
-        for (j = i + 1; j < 3; ++j) {
-            temp = m->m[i*3 + j];
-            m->m[i*3 + j] = m->m[j*4 + i];
-            m->m[j*3 + i] = temp;
-        }
-    }
-}
-
-_RS_STATIC void __attribute__((overloadable))
-rsMatrixTranspose(rs_matrix2x2 *m) {
-    float temp = m->m[1];
-    m->m[1] = m->m[2];
-    m->m[2] = temp;
-}
-
-/////////////////////////////////////////////////////
-// quaternion ops
-/////////////////////////////////////////////////////
-
-_RS_STATIC void __attribute__((overloadable))
-rsQuaternionSet(rs_quaternion *q, float w, float x, float y, float z) {
-    q->w = w;
-    q->x = x;
-    q->y = y;
-    q->z = z;
-}
-
-_RS_STATIC void __attribute__((overloadable))
-rsQuaternionSet(rs_quaternion *q, const rs_quaternion *rhs) {
-    q->w = rhs->w;
-    q->x = rhs->x;
-    q->y = rhs->y;
-    q->z = rhs->z;
-}
-
-_RS_STATIC void __attribute__((overloadable))
-rsQuaternionMultiply(rs_quaternion *q, float s) {
-    q->w *= s;
-    q->x *= s;
-    q->y *= s;
-    q->z *= s;
-}
-
-_RS_STATIC void __attribute__((overloadable))
-rsQuaternionMultiply(rs_quaternion *q, const rs_quaternion *rhs) {
-    q->w = -q->x*rhs->x - q->y*rhs->y - q->z*rhs->z + q->w*rhs->w;
-    q->x =  q->x*rhs->w + q->y*rhs->z - q->z*rhs->y + q->w*rhs->x;
-    q->y = -q->x*rhs->z + q->y*rhs->w + q->z*rhs->x + q->w*rhs->y;
-    q->z =  q->x*rhs->y - q->y*rhs->x + q->z*rhs->w + q->w*rhs->z;
-}
-
-_RS_STATIC void
-rsQuaternionAdd(rs_quaternion *q, const rs_quaternion *rhs) {
-    q->w *= rhs->w;
-    q->x *= rhs->x;
-    q->y *= rhs->y;
-    q->z *= rhs->z;
-}
-
-_RS_STATIC void
-rsQuaternionLoadRotateUnit(rs_quaternion *q, float rot, float x, float y, float z) {
-    rot *= (float)(M_PI / 180.0f) * 0.5f;
-    float c = cos(rot);
-    float s = sin(rot);
-
-    q->w = c;
-    q->x = x * s;
-    q->y = y * s;
-    q->z = z * s;
-}
-
-_RS_STATIC void
-rsQuaternionLoadRotate(rs_quaternion *q, float rot, float x, float y, float z) {
-    const float len = x*x + y*y + z*z;
-    if (len != 1) {
-        const float recipLen = 1.f / sqrt(len);
-        x *= recipLen;
-        y *= recipLen;
-        z *= recipLen;
-    }
-    rsQuaternionLoadRotateUnit(q, rot, x, y, z);
-}
-
-_RS_STATIC void
-rsQuaternionConjugate(rs_quaternion *q) {
-    q->x = -q->x;
-    q->y = -q->y;
-    q->z = -q->z;
-}
-
-_RS_STATIC float
-rsQuaternionDot(const rs_quaternion *q0, const rs_quaternion *q1) {
-    return q0->w*q1->w + q0->x*q1->x + q0->y*q1->y + q0->z*q1->z;
-}
-
-_RS_STATIC void
-rsQuaternionNormalize(rs_quaternion *q) {
-    const float len = rsQuaternionDot(q, q);
-    if (len != 1) {
-        const float recipLen = 1.f / sqrt(len);
-        rsQuaternionMultiply(q, recipLen);
-    }
-}
-
-_RS_STATIC void
-rsQuaternionSlerp(rs_quaternion *q, const rs_quaternion *q0, const rs_quaternion *q1, float t) {
-    if (t <= 0.0f) {
-        rsQuaternionSet(q, q0);
-        return;
-    }
-    if (t >= 1.0f) {
-        rsQuaternionSet(q, q1);
-        return;
-    }
-
-    rs_quaternion tempq0, tempq1;
-    rsQuaternionSet(&tempq0, q0);
-    rsQuaternionSet(&tempq1, q1);
-
-    float angle = rsQuaternionDot(q0, q1);
-    if (angle < 0) {
-        rsQuaternionMultiply(&tempq0, -1.0f);
-        angle *= -1.0f;
-    }
-
-    float scale, invScale;
-    if (angle + 1.0f > 0.05f) {
-        if (1.0f - angle >= 0.05f) {
-            float theta = acos(angle);
-            float invSinTheta = 1.0f / sin(theta);
-            scale = sin(theta * (1.0f - t)) * invSinTheta;
-            invScale = sin(theta * t) * invSinTheta;
-        } else {
-            scale = 1.0f - t;
-            invScale = t;
-        }
-    } else {
-        rsQuaternionSet(&tempq1, tempq0.z, -tempq0.y, tempq0.x, -tempq0.w);
-        scale = sin(M_PI * (0.5f - t));
-        invScale = sin(M_PI * t);
-    }
-
-    rsQuaternionSet(q, tempq0.w*scale + tempq1.w*invScale, tempq0.x*scale + tempq1.x*invScale,
-                        tempq0.y*scale + tempq1.y*invScale, tempq0.z*scale + tempq1.z*invScale);
-}
-
-_RS_STATIC void rsQuaternionGetMatrixUnit(rs_matrix4x4 *m, const rs_quaternion *q) {
-    float x2 = 2.0f * q->x * q->x;
-    float y2 = 2.0f * q->y * q->y;
-    float z2 = 2.0f * q->z * q->z;
-    float xy = 2.0f * q->x * q->y;
-    float wz = 2.0f * q->w * q->z;
-    float xz = 2.0f * q->x * q->z;
-    float wy = 2.0f * q->w * q->y;
-    float wx = 2.0f * q->w * q->x;
-    float yz = 2.0f * q->y * q->z;
-
-    m->m[0] = 1.0f - y2 - z2;
-    m->m[1] = xy - wz;
-    m->m[2] = xz + wy;
-    m->m[3] = 0.0f;
-
-    m->m[4] = xy + wz;
-    m->m[5] = 1.0f - x2 - z2;
-    m->m[6] = yz - wx;
-    m->m[7] = 0.0f;
-
-    m->m[8] = xz - wy;
-    m->m[9] = yz - wx;
-    m->m[10] = 1.0f - x2 - y2;
-    m->m[11] = 0.0f;
-
-    m->m[12] = 0.0f;
-    m->m[13] = 0.0f;
-    m->m[14] = 0.0f;
-    m->m[15] = 1.0f;
-}
-
-/////////////////////////////////////////////////////
-// utility funcs
-/////////////////////////////////////////////////////
-__inline__ _RS_STATIC void __attribute__((overloadable, always_inline))
-rsExtractFrustumPlanes(const rs_matrix4x4 *modelViewProj,
-                         float4 *left, float4 *right,
-                         float4 *top, float4 *bottom,
-                         float4 *near, float4 *far) {
-    // x y z w = a b c d in the plane equation
-    left->x = modelViewProj->m[3] + modelViewProj->m[0];
-    left->y = modelViewProj->m[7] + modelViewProj->m[4];
-    left->z = modelViewProj->m[11] + modelViewProj->m[8];
-    left->w = modelViewProj->m[15] + modelViewProj->m[12];
-
-    right->x = modelViewProj->m[3] - modelViewProj->m[0];
-    right->y = modelViewProj->m[7] - modelViewProj->m[4];
-    right->z = modelViewProj->m[11] - modelViewProj->m[8];
-    right->w = modelViewProj->m[15] - modelViewProj->m[12];
-
-    top->x = modelViewProj->m[3] - modelViewProj->m[1];
-    top->y = modelViewProj->m[7] - modelViewProj->m[5];
-    top->z = modelViewProj->m[11] - modelViewProj->m[9];
-    top->w = modelViewProj->m[15] - modelViewProj->m[13];
-
-    bottom->x = modelViewProj->m[3] + modelViewProj->m[1];
-    bottom->y = modelViewProj->m[7] + modelViewProj->m[5];
-    bottom->z = modelViewProj->m[11] + modelViewProj->m[9];
-    bottom->w = modelViewProj->m[15] + modelViewProj->m[13];
-
-    near->x = modelViewProj->m[3] + modelViewProj->m[2];
-    near->y = modelViewProj->m[7] + modelViewProj->m[6];
-    near->z = modelViewProj->m[11] + modelViewProj->m[10];
-    near->w = modelViewProj->m[15] + modelViewProj->m[14];
-
-    far->x = modelViewProj->m[3] - modelViewProj->m[2];
-    far->y = modelViewProj->m[7] - modelViewProj->m[6];
-    far->z = modelViewProj->m[11] - modelViewProj->m[10];
-    far->w = modelViewProj->m[15] - modelViewProj->m[14];
-
-    float len = length(left->xyz);
-    *left /= len;
-    len = length(right->xyz);
-    *right /= len;
-    len = length(top->xyz);
-    *top /= len;
-    len = length(bottom->xyz);
-    *bottom /= len;
-    len = length(near->xyz);
-    *near /= len;
-    len = length(far->xyz);
-    *far /= len;
-}
-
-__inline__ _RS_STATIC bool __attribute__((overloadable, always_inline))
-rsIsSphereInFrustum(float4 *sphere,
-                      float4 *left, float4 *right,
-                      float4 *top, float4 *bottom,
-                      float4 *near, float4 *far) {
-
-    float distToCenter = dot(left->xyz, sphere->xyz) + left->w;
-    if (distToCenter < -sphere->w) {
-        return false;
-    }
-    distToCenter = dot(right->xyz, sphere->xyz) + right->w;
-    if (distToCenter < -sphere->w) {
-        return false;
-    }
-    distToCenter = dot(top->xyz, sphere->xyz) + top->w;
-    if (distToCenter < -sphere->w) {
-        return false;
-    }
-    distToCenter = dot(bottom->xyz, sphere->xyz) + bottom->w;
-    if (distToCenter < -sphere->w) {
-        return false;
-    }
-    distToCenter = dot(near->xyz, sphere->xyz) + near->w;
-    if (distToCenter < -sphere->w) {
-        return false;
-    }
-    distToCenter = dot(far->xyz, sphere->xyz) + far->w;
-    if (distToCenter < -sphere->w) {
-        return false;
-    }
-    return true;
-}
-
+extern bool __attribute__((overloadable)) rsMatrixInverse(rs_matrix4x4 *m);
+extern bool __attribute__((overloadable)) rsMatrixInverseTranspose(rs_matrix4x4 *m);
+extern void __attribute__((overloadable)) rsMatrixTranspose(rs_matrix4x4 *m);
+extern void __attribute__((overloadable)) rsMatrixTranspose(rs_matrix3x3 *m);
+extern void __attribute__((overloadable)) rsMatrixTranspose(rs_matrix2x2 *m);
 
 /////////////////////////////////////////////////////
 // int ops
diff --git a/media/jni/mediaeditor/VideoEditorClasses.cpp b/media/jni/mediaeditor/VideoEditorClasses.cpp
index 52e032a..369faa9 100755
--- a/media/jni/mediaeditor/VideoEditorClasses.cpp
+++ b/media/jni/mediaeditor/VideoEditorClasses.cpp
@@ -2481,7 +2481,7 @@
 
             pSettings->xVSS.width = pSettings->xVSS.pFramingBuffer->u_width;
             pSettings->xVSS.height = pSettings->xVSS.pFramingBuffer->u_height;
-            pSettings->xVSS.rgbType = M4VSS3GPP_kRGB888;
+            pSettings->xVSS.rgbType = M4VSS3GPP_kRGB565;
 
             VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
                     "pFramingBuffer u_width %d ", pSettings->xVSS.pFramingBuffer->u_width);
diff --git a/media/jni/mediaeditor/VideoEditorMain.cpp b/media/jni/mediaeditor/VideoEditorMain.cpp
index 8ce788b..4149bc9 100755
--- a/media/jni/mediaeditor/VideoEditorMain.cpp
+++ b/media/jni/mediaeditor/VideoEditorMain.cpp
@@ -86,6 +86,7 @@
     jmethodID                      onWarningMethodId;
     jmethodID                      onProgressUpdateMethodId;
     jmethodID                      onPreviewProgressUpdateMethodId;
+    jmethodID                      previewFrameEditInfoId;
     M4xVSS_InitParams              initParams;
     void*                          pTextRendererHandle;
     M4xVSS_getTextRgbBufferFct     pTextRendererFunction;
@@ -102,6 +103,9 @@
     M4OSA_Bool                      bSkipState;
     jmethodID                       onAudioGraphProgressUpdateMethodId;
     Mutex                           mLock;
+    bool                            mIsUpdateOverlay;
+    char                            *mOverlayFileName;
+    int                             mOverlayRenderingMode;
 } ManualEditContext;
 
 extern "C" M4OSA_ERR M4MCS_open_normalMode(
@@ -224,7 +228,7 @@
                 JNIEnv*                             pEnv);
 
 static void jniPreviewProgressCallback(void* cookie, M4OSA_UInt32 msgType,
-                                        M4OSA_UInt32 argc);
+                                        void *argc);
 
 static int videoEditor_renderMediaItemPreviewFrame(JNIEnv* pEnv,
                                                     jobject thiz,
@@ -374,35 +378,105 @@
 }
 
 static void jniPreviewProgressCallback (void* cookie, M4OSA_UInt32 msgType,
-                                        M4OSA_UInt32 argc)
+                                        void *argc)
 {
     ManualEditContext *pContext = (ManualEditContext *)cookie;
     JNIEnv*     pEnv = NULL;
     bool        isFinished = false;
     int         currentMs = 0;
     int         error = M4NO_ERROR;
+    bool        isUpdateOverlay = false;
+    int         overlayEffectIndex;
+    char        *extPos;
+    bool        isSendProgress = true;
+    jstring     tmpFileName;
+    VideoEditorCurretEditInfo *pCurrEditInfo;
 
     // Attach the current thread.
     pContext->pVM->AttachCurrentThread(&pEnv, NULL);
     switch(msgType)
     {
         case MSG_TYPE_PROGRESS_INDICATION:
-            currentMs = argc;
+            currentMs = *(int*)argc;
             break;
         case MSG_TYPE_PLAYER_ERROR:
             currentMs = -1;
-            error = argc;
+            error = *(int*)argc;
             break;
         case MSG_TYPE_PREVIEW_END:
             isFinished = true;
             break;
+        case MSG_TYPE_OVERLAY_UPDATE:
+        {
+            int overlayFileNameLen = 0;
+            isSendProgress = false;
+            pContext->mIsUpdateOverlay = true;
+            pCurrEditInfo = (VideoEditorCurretEditInfo*)argc;
+            overlayEffectIndex = pCurrEditInfo->overlaySettingsIndex;
+            LOGV("MSG_TYPE_OVERLAY_UPDATE");
+
+            if (pContext->mOverlayFileName != NULL) {
+                M4OSA_free((M4OSA_MemAddr32)pContext->mOverlayFileName);
+                pContext->mOverlayFileName = NULL;
+            }
+
+            overlayFileNameLen =
+                strlen((const char*)pContext->pEditSettings->Effects[overlayEffectIndex].xVSS.pFramingFilePath);
+
+            pContext->mOverlayFileName =
+                (char*)M4OSA_malloc(overlayFileNameLen+1,
+                                    M4VS, (M4OSA_Char*)"videoEdito JNI overlayFile");
+            if (pContext->mOverlayFileName != NULL) {
+                strncpy (pContext->mOverlayFileName,
+                    (const char*)pContext->pEditSettings->\
+                    Effects[overlayEffectIndex].xVSS.pFramingFilePath, overlayFileNameLen);
+                //Change the name to png file
+                extPos = strstr(pContext->mOverlayFileName, ".rgb");
+                if (extPos != NULL) {
+                    *extPos = '\0';
+                } else {
+                    LOGE("ERROR the overlay file is incorrect");
+                }
+
+                strcat(pContext->mOverlayFileName, ".png");
+                LOGV("Conv string is %s", pContext->mOverlayFileName);
+                LOGV("Current Clip index = %d", pCurrEditInfo->clipIndex);
+
+                pContext->mOverlayRenderingMode = pContext->pEditSettings->\
+                         pClipList[pCurrEditInfo->clipIndex]->xVSS.MediaRendering;
+                LOGI("rendering mode %d ", pContext->mOverlayRenderingMode);
+
+            }
+
+            break;
+        }
+
+        case MSG_TYPE_OVERLAY_CLEAR:
+            isSendProgress = false;
+            pContext->mOverlayFileName = NULL;
+            LOGI("MSG_TYPE_OVERLAY_CLEAR");
+            //argc is not used
+            pContext->mIsUpdateOverlay = true;
+            break;
         default:
             break;
     }
 
-    pEnv->CallVoidMethod(pContext->engine,
-                        pContext->onPreviewProgressUpdateMethodId,
-                        currentMs,isFinished);
+    if (isSendProgress) {
+        tmpFileName  = pEnv->NewStringUTF(pContext->mOverlayFileName);
+        pEnv->CallVoidMethod(pContext->engine,
+                pContext->onPreviewProgressUpdateMethodId,
+                currentMs,isFinished, pContext->mIsUpdateOverlay,
+                tmpFileName, pContext->mOverlayRenderingMode);
+
+        if (pContext->mIsUpdateOverlay) {
+            pContext->mIsUpdateOverlay = false;
+        }
+
+        if (tmpFileName) {
+            pEnv->DeleteLocalRef(tmpFileName);
+        }
+    }
 
     // Detach the current thread.
     pContext->pVM->DetachCurrentThread();
@@ -422,6 +496,11 @@
                                              (M4OSA_NULL == pContext),
                                              "not initialized");
     pContext->mPreviewController->stopPreview();
+
+    if (pContext->mOverlayFileName != NULL) {
+        M4OSA_free((M4OSA_MemAddr32)pContext->mOverlayFileName);
+        pContext->mOverlayFileName = NULL;
+    }
 }
 
 static void videoEditor_clearSurface(JNIEnv* pEnv,
@@ -507,6 +586,7 @@
     M4OSA_Context tnContext = M4OSA_NULL;
     const char* pMessage = NULL;
     M4VIFI_ImagePlane *yuvPlane = NULL;
+    VideoEditorCurretEditInfo  currEditInfo;
 
     VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO,
         "VIDEO_EDITOR", "surfaceWidth = %d",surfaceWidth);
@@ -770,9 +850,36 @@
         pContext->pEditSettings->\
         pClipList[iCurrentClipIndex]->xVSS.MediaRendering,
         pContext->pEditSettings->xVSS.outputVideoSize);
-
     result = pContext->mPreviewController->renderPreviewFrame(previewSurface,
-                                                              &frameStr);
+                                                              &frameStr, &currEditInfo);
+
+    if (currEditInfo.overlaySettingsIndex != -1) {
+        char tmpOverlayFilename[100];
+        char *extPos = NULL;
+        jstring tmpOverlayString;
+        int tmpRenderingMode = 0;
+
+        strncpy (tmpOverlayFilename,
+                (const char*)pContext->pEditSettings->Effects[currEditInfo.overlaySettingsIndex].xVSS.pFramingFilePath, 99);
+
+        //Change the name to png file
+        extPos = strstr(tmpOverlayFilename, ".rgb");
+        if (extPos != NULL) {
+            *extPos = '\0';
+        } else {
+            LOGE("ERROR the overlay file is incorrect");
+        }
+
+        strcat(tmpOverlayFilename, ".png");
+
+        tmpRenderingMode = pContext->pEditSettings->pClipList[iCurrentClipIndex]->xVSS.MediaRendering;
+        tmpOverlayString = pEnv->NewStringUTF(tmpOverlayFilename);
+        pEnv->CallVoidMethod(pContext->engine,
+            pContext->previewFrameEditInfoId,
+            tmpOverlayString, tmpRenderingMode);
+
+    }
+
     videoEditJava_checkAndThrowRuntimeException(&needToBeLoaded, pEnv,
             (M4NO_ERROR != result), result);
 
@@ -937,7 +1044,7 @@
     /*  pContext->mPreviewController->setPreviewFrameRenderingMode(M4xVSS_kBlackBorders,
     (M4VIDEOEDITING_VideoFrameSize)(M4VIDEOEDITING_kHD960+1));*/
     result
-    = pContext->mPreviewController->renderPreviewFrame(previewSurface,&frameStr);
+    = pContext->mPreviewController->renderPreviewFrame(previewSurface,&frameStr, NULL);
     videoEditJava_checkAndThrowRuntimeException(&needToBeLoaded, pEnv,
                                                 (M4NO_ERROR != result), result);
 
@@ -1325,7 +1432,7 @@
                                      "not initialized");
 
     pContext->onPreviewProgressUpdateMethodId = pEnv->GetMethodID(engineClass,
-            "onPreviewProgressUpdate",     "(IZ)V");
+            "onPreviewProgressUpdate",     "(IZZLjava/lang/String;I)V");
     // Check if the context is valid (required because the context is dereferenced).
     if (needToBeLoaded) {
         // Make sure that we are in a correct state.
@@ -1342,6 +1449,9 @@
     }
     M4OSA_TRACE1_0("videoEditorC_getEditSettings done");
 
+    pContext->previewFrameEditInfoId = pEnv->GetMethodID(engineClass,
+        "previewFrameEditInfo", "(Ljava/lang/String;I)V");
+
     if ( pContext->pEditSettings != NULL )
     {
         // Check if the edit settings could be retrieved.
@@ -1440,22 +1550,22 @@
                 width = pContext->pEditSettings->Effects[j].xVSS.pFramingBuffer->u_width;
                 height = pContext->pEditSettings->Effects[j].xVSS.pFramingBuffer->u_height;
 
-                pContext->pEditSettings->Effects[j].xVSS.pFramingBuffer->u_stride = width*3;
+                //RGB 565
+                pContext->pEditSettings->Effects[j].xVSS.pFramingBuffer->u_stride = width*2;
 
-                //for RGB888
+                //for RGB565
                 pContext->pEditSettings->Effects[j].xVSS.pFramingBuffer->u_topleft = 0;
-
                 pContext->pEditSettings->Effects[j].xVSS.pFramingBuffer->pac_data =
-                                                    (M4VIFI_UInt8 *)M4OSA_malloc(width*height*3,
-                    0x00,(M4OSA_Char *)"pac_data buffer");
+                            (M4VIFI_UInt8 *)M4OSA_malloc(width*height*2,
+                            0x00,(M4OSA_Char *)"pac_data buffer");
 
                 M4OSA_memcpy((M4OSA_Int8 *)&pContext->pEditSettings->\
                     Effects[j].xVSS.pFramingBuffer->\
-                    pac_data[0],(M4OSA_Int8 *)&aFramingCtx->FramingRgb->pac_data[0],(width*height*3));
+                    pac_data[0],(M4OSA_Int8 *)&aFramingCtx->FramingRgb->pac_data[0],(width*height*2));
 
-                //As of now rgb type is always rgb888, can be changed in future for rgb 565
+                //As of now rgb type is 565
                 pContext->pEditSettings->Effects[j].xVSS.rgbType =
-                (M4VSS3GPP_RGBType)M4VSS3GPP_kRGB888; //M4VSS3GPP_kRGB565;
+                    (M4VSS3GPP_RGBType) M4VSS3GPP_kRGB565;
 
                 if (aFramingCtx->FramingYuv != M4OSA_NULL )
                 {
@@ -2153,6 +2263,8 @@
             M4OSA_chrNCat((M4OSA_Char*)pContext->initParams.pTempPath, tmpString, M4OSA_chrLength(tmpString));
             M4OSA_chrNCat((M4OSA_Char*)pContext->initParams.pTempPath, (M4OSA_Char*)"/", 1);
             M4OSA_free((M4OSA_MemAddr32)tmpString);
+            pContext->mIsUpdateOverlay = false;
+            pContext->mOverlayFileName = NULL;
         }
 
         // Check if the initialization succeeded
diff --git a/media/jni/mediaeditor/VideoEditorMain.h b/media/jni/mediaeditor/VideoEditorMain.h
index b73913a..ca4a945 100755
--- a/media/jni/mediaeditor/VideoEditorMain.h
+++ b/media/jni/mediaeditor/VideoEditorMain.h
@@ -21,11 +21,18 @@
 
 typedef enum
 {
-    MSG_TYPE_PROGRESS_INDICATION,             /* Playback progress indication event*/
-    MSG_TYPE_PLAYER_ERROR,                    /* Playback error*/
-    MSG_TYPE_PREVIEW_END,                     /* Preview of clips is complete */
+    MSG_TYPE_PROGRESS_INDICATION,     // Playback progress indication event
+    MSG_TYPE_PLAYER_ERROR,            // Playback error
+    MSG_TYPE_PREVIEW_END,             // Preview of clips is complete
+    MSG_TYPE_OVERLAY_UPDATE,          // update overlay during preview
+    MSG_TYPE_OVERLAY_CLEAR,           // clear the overlay
 } progress_callback_msg_type;
 
+typedef struct {
+    int overlaySettingsIndex;
+    int clipIndex;
+} VideoEditorCurretEditInfo;
+
 typedef struct
 {
     M4OSA_Void     *pFile;                   /** PCM file path */
diff --git a/media/libstagefright/AudioPlayer.cpp b/media/libstagefright/AudioPlayer.cpp
index 5ff934d..e7c0299 100644
--- a/media/libstagefright/AudioPlayer.cpp
+++ b/media/libstagefright/AudioPlayer.cpp
@@ -286,7 +286,9 @@
     }
 
     if (mReachedEOS) {
-        return 0;
+        memset(data, 0, size);
+
+        return size;
     }
 
     size_t size_done = 0;
diff --git a/media/libstagefright/HTTPStream.cpp b/media/libstagefright/HTTPStream.cpp
index 057868c..77a61a5 100644
--- a/media/libstagefright/HTTPStream.cpp
+++ b/media/libstagefright/HTTPStream.cpp
@@ -124,6 +124,80 @@
     return result;
 }
 
+// Apparently under out linux closing a socket descriptor from one thread
+// will not unblock a pending send/recv on that socket on another thread.
+static ssize_t MySendReceive(
+        int s, void *data, size_t size, int flags, bool sendData) {
+    ssize_t result = 0;
+
+    while (size > 0) {
+        fd_set rs, ws, es;
+        FD_ZERO(&rs);
+        FD_ZERO(&ws);
+        FD_ZERO(&es);
+        FD_SET(s, sendData ? &ws : &rs);
+        FD_SET(s, &es);
+
+        struct timeval tv;
+        tv.tv_sec = 0;
+        tv.tv_usec = 100000ll;
+
+        int nfds = ::select(
+                s + 1,
+                sendData ? NULL : &rs,
+                sendData ? &ws : NULL,
+                &es,
+                &tv);
+
+        if (nfds < 0) {
+            if (errno == EINTR) {
+                continue;
+            }
+
+            result = -errno;
+            break;
+        } else if (nfds == 0) {
+            // timeout
+
+            continue;
+        }
+
+        CHECK_EQ(nfds, 1);
+
+        ssize_t nbytes =
+            sendData ? send(s, data, size, flags) : recv(s, data, size, flags);
+
+        if (nbytes < 0) {
+            if (errno == EINTR) {
+                continue;
+            }
+
+            result = -errno;
+            break;
+        } else if (nbytes == 0) {
+            result = 0;
+            break;
+        }
+
+        data = (uint8_t *)data + nbytes;
+        size -= nbytes;
+
+        result = nbytes;
+        break;
+    }
+
+    return result;
+}
+
+static ssize_t MySend(int s, const void *data, size_t size, int flags) {
+    return MySendReceive(
+            s, const_cast<void *>(data), size, flags, true /* sendData */);
+}
+
+static ssize_t MyReceive(int s, void *data, size_t size, int flags) {
+    return MySendReceive(s, data, size, flags, false /* sendData */);
+}
+
 status_t HTTPStream::connect(const char *server, int port) {
     Mutex::Autolock autoLock(mLock);
 
@@ -202,16 +276,12 @@
     }
 
     while (size > 0) {
-        ssize_t n = ::send(mSocket, data, size, 0);
+        ssize_t n = MySend(mSocket, data, size, 0);
 
         if (n < 0) {
-            if (errno == EINTR) {
-                continue;
-            }
-
             disconnect();
 
-            return ERROR_IO;
+            return n;
         } else if (n == 0) {
             disconnect();
 
@@ -247,12 +317,8 @@
 
     for (;;) {
         char c;
-        ssize_t n = recv(mSocket, &c, 1, 0);
+        ssize_t n = MyReceive(mSocket, &c, 1, 0);
         if (n < 0) {
-            if (errno == EINTR) {
-                continue;
-            }
-
             disconnect();
 
             return ERROR_IO;
@@ -371,14 +437,10 @@
 ssize_t HTTPStream::receive(void *data, size_t size) {
     size_t total = 0;
     while (total < size) {
-        ssize_t n = recv(mSocket, (char *)data + total, size - total, 0);
+        ssize_t n = MyReceive(mSocket, (char *)data + total, size - total, 0);
 
         if (n < 0) {
-            if (errno == EINTR) {
-                continue;
-            }
-
-            LOGE("recv failed, errno = %d (%s)", errno, strerror(errno));
+            LOGE("recv failed, errno = %d (%s)", (int)n, strerror(-n));
 
             disconnect();
             return (ssize_t)ERROR_IO;
diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp
index 94694a3..7c6e561 100644
--- a/media/libstagefright/OMXCodec.cpp
+++ b/media/libstagefright/OMXCodec.cpp
@@ -2203,8 +2203,9 @@
                         crop.right = right;
                         crop.bottom = bottom;
 
-                        CHECK_EQ(0, native_window_set_crop(
-                                    mNativeWindow.get(), &crop));
+                        // We'll ignore any errors here, if the surface is
+                        // already invalid, we'll know soon enough.
+                        native_window_set_crop(mNativeWindow.get(), &crop);
                     }
                 }
             }
@@ -3316,7 +3317,7 @@
 
     mSource->stop();
 
-    CODEC_LOGV("stopped");
+    CODEC_LOGI("stopped in state %d", mState);
 
     return OK;
 }
diff --git a/media/libstagefright/omx/OMXNodeInstance.cpp b/media/libstagefright/omx/OMXNodeInstance.cpp
index 9b6d441..c7c1409 100644
--- a/media/libstagefright/omx/OMXNodeInstance.cpp
+++ b/media/libstagefright/omx/OMXNodeInstance.cpp
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-//#define LOG_NDEBUG 0
+#define LOG_NDEBUG 0
 #define LOG_TAG "OMXNodeInstance"
 #include <utils/Log.h>
 
@@ -124,6 +124,8 @@
 }
 
 status_t OMXNodeInstance::freeNode(OMXMaster *master) {
+    static int32_t kMaxNumIterations = 10;
+
     // Transition the node from its current state all the way down
     // to "Loaded".
     // This ensures that all active buffers are properly freed even
@@ -143,9 +145,16 @@
             LOGV("forcing Executing->Idle");
             sendCommand(OMX_CommandStateSet, OMX_StateIdle);
             OMX_ERRORTYPE err;
+            int32_t iteration = 0;
             while ((err = OMX_GetState(mHandle, &state)) == OMX_ErrorNone
                    && state != OMX_StateIdle
                    && state != OMX_StateInvalid) {
+                if (++iteration > kMaxNumIterations) {
+                    LOGE("component failed to enter Idle state, aborting.");
+                    state = OMX_StateInvalid;
+                    break;
+                }
+
                 usleep(100000);
             }
             CHECK_EQ(err, OMX_ErrorNone);
@@ -165,9 +174,16 @@
             freeActiveBuffers();
 
             OMX_ERRORTYPE err;
+            int32_t iteration = 0;
             while ((err = OMX_GetState(mHandle, &state)) == OMX_ErrorNone
                    && state != OMX_StateLoaded
                    && state != OMX_StateInvalid) {
+                if (++iteration > kMaxNumIterations) {
+                    LOGE("component failed to enter Loaded state, aborting.");
+                    state = OMX_StateInvalid;
+                    break;
+                }
+
                 LOGV("waiting for Loaded state...");
                 usleep(100000);
             }
@@ -185,8 +201,10 @@
             break;
     }
 
+    LOGV("calling destroyComponentInstance");
     OMX_ERRORTYPE err = master->destroyComponentInstance(
             static_cast<OMX_COMPONENTTYPE *>(mHandle));
+    LOGV("destroyComponentInstance returned err %d", err);
 
     mHandle = NULL;
 
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_notification_open.png b/packages/SystemUI/res/drawable-hdpi/ic_notification_open.png
index d083396..c3e381e 100644
--- a/packages/SystemUI/res/drawable-hdpi/ic_notification_open.png
+++ b/packages/SystemUI/res/drawable-hdpi/ic_notification_open.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_airplane_on.png b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_airplane_on.png
index b76c366..728a25d 100644
--- a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_airplane_on.png
+++ b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_airplane_on.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_brightness.png b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_brightness.png
index 6e8995e..299a0e7 100644
--- a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_brightness.png
+++ b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_brightness.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_quicksettings.png b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_quicksettings.png
index d9b4eca..47b4ba2 100644
--- a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_quicksettings.png
+++ b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_quicksettings.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_rotate_on.png b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_rotate_on.png
index 9acd6f4..20d28da 100644
--- a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_rotate_on.png
+++ b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_rotate_on.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_sound_on.png b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_sound_on.png
index a1d5a2d..3be2eef 100644
--- a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_sound_on.png
+++ b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_sound_on.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_wifi_on.png b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_wifi_on.png
index 7c889356..88ac760 100644
--- a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_wifi_on.png
+++ b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_wifi_on.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_notify_alarm.png b/packages/SystemUI/res/drawable-hdpi/stat_notify_alarm.png
index 2d3eb30..51b4f3f 100644
--- a/packages/SystemUI/res/drawable-hdpi/stat_notify_alarm.png
+++ b/packages/SystemUI/res/drawable-hdpi/stat_notify_alarm.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_notify_more.png b/packages/SystemUI/res/drawable-hdpi/stat_notify_more.png
index 1c7f9db..170178c 100755
--- a/packages/SystemUI/res/drawable-hdpi/stat_notify_more.png
+++ b/packages/SystemUI/res/drawable-hdpi/stat_notify_more.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_data_bluetooth.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_data_bluetooth.png
index e8fbc9e..08f1993 100644
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_data_bluetooth.png
+++ b/packages/SystemUI/res/drawable-hdpi/stat_sys_data_bluetooth.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_data_bluetooth_connected.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_data_bluetooth_connected.png
index 18c77df..4a40b14 100644
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_data_bluetooth_connected.png
+++ b/packages/SystemUI/res/drawable-hdpi/stat_sys_data_bluetooth_connected.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_0.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_0.png
index 20ea735..ecb3951 100644
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_0.png
+++ b/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_0.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_1.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_1.png
index a5e9c7c..e375a8a 100644
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_1.png
+++ b/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_1.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_1_fully.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_1_fully.png
index 0287d5a..13dde32a 100644
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_1_fully.png
+++ b/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_1_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_2.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_2.png
index 4dfbcb2..24ade2c 100644
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_2.png
+++ b/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_2.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_2_fully.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_2_fully.png
index b9d4cb0..efa6f79 100644
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_2_fully.png
+++ b/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_2_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_3.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_3.png
index 4c8ec0e..5b5baed 100644
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_3.png
+++ b/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_3.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_3_fully.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_3_fully.png
index 7e30894..2eaff98 100644
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_3_fully.png
+++ b/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_3_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_4.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_4.png
index 72635a5..b515cf0 100644
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_4.png
+++ b/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_4.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_4_fully.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_4_fully.png
index 6f56886..d8599b5 100644
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_4_fully.png
+++ b/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_4_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_flightmode.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_flightmode.png
index 118a6b4..c763976 100644
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_flightmode.png
+++ b/packages/SystemUI/res/drawable-hdpi/stat_sys_signal_flightmode.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_0.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_0.png
index ecd880f..1b404b3 100644
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_0.png
+++ b/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_0.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_1.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_1.png
index 7251b14..ba9cc9c 100644
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_1.png
+++ b/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_1.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_1_fully.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_1_fully.png
index 01135c8..3e29d5e 100644
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_1_fully.png
+++ b/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_1_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_2.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_2.png
index 794d9edd..e1900ea 100644
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_2.png
+++ b/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_2.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_2_fully.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_2_fully.png
index 851ca41..2b00f3b 100755
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_2_fully.png
+++ b/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_2_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_3.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_3.png
index f16783c..6158e66 100644
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_3.png
+++ b/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_3.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_3_fully.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_3_fully.png
index d217d09..b183160 100755
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_3_fully.png
+++ b/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_3_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_4.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_4.png
index b577ebe..1b96f39 100644
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_4.png
+++ b/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_4.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_4_fully.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_4_fully.png
index 6cf4829..cf504f5 100755
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_4_fully.png
+++ b/packages/SystemUI/res/drawable-hdpi/stat_sys_wifi_signal_4_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/battery_low_battery.png b/packages/SystemUI/res/drawable-mdpi/battery_low_battery.png
index e74c22f..7417afc 100644
--- a/packages/SystemUI/res/drawable-mdpi/battery_low_battery.png
+++ b/packages/SystemUI/res/drawable-mdpi/battery_low_battery.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_notification_open.png b/packages/SystemUI/res/drawable-mdpi/ic_notification_open.png
index 17fd52e..e0f67e8 100644
--- a/packages/SystemUI/res/drawable-mdpi/ic_notification_open.png
+++ b/packages/SystemUI/res/drawable-mdpi/ic_notification_open.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_airplane_on.png b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_airplane_on.png
index 0296b5b..f8d7008 100644
--- a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_airplane_on.png
+++ b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_airplane_on.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_brightness.png b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_brightness.png
index 97fa5fc..55b767f 100644
--- a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_brightness.png
+++ b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_brightness.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_quicksettings.png b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_quicksettings.png
index 4434b5c..7928104 100644
--- a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_quicksettings.png
+++ b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_quicksettings.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_rotate_on.png b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_rotate_on.png
index 4517d1b..d338fc0 100644
--- a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_rotate_on.png
+++ b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_rotate_on.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_sound_on.png b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_sound_on.png
index 1b3ba2f..70f72fa 100644
--- a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_sound_on.png
+++ b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_sound_on.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_wifi_on.png b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_wifi_on.png
index bbb1c74..f2d0cd9 100644
--- a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_wifi_on.png
+++ b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_wifi_on.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/scrubber_control_disabled_holo.png b/packages/SystemUI/res/drawable-mdpi/scrubber_control_disabled_holo.png
index 177ddb8..b8adc97 100644
--- a/packages/SystemUI/res/drawable-mdpi/scrubber_control_disabled_holo.png
+++ b/packages/SystemUI/res/drawable-mdpi/scrubber_control_disabled_holo.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_notify_alarm.png b/packages/SystemUI/res/drawable-mdpi/stat_notify_alarm.png
index 1b01b85..d846afe 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_notify_alarm.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_notify_alarm.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_notify_more.png b/packages/SystemUI/res/drawable-mdpi/stat_notify_more.png
index e129ba9..9b28252 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_notify_more.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_notify_more.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_bluetooth.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_bluetooth.png
index 3ddf728..5ca2415 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_bluetooth.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_bluetooth.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_bluetooth_connected.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_bluetooth_connected.png
old mode 100755
new mode 100644
index f09b83b..b727c2d
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_bluetooth_connected.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_bluetooth_connected.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_connected_1x.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_connected_1x.png
index f8b6f11..78ece9e 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_connected_1x.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_connected_1x.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_connected_3g.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_connected_3g.png
index 3198abc..31fc1b0 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_connected_3g.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_connected_3g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_connected_e.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_connected_e.png
index 16e3b0b..19adb4b 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_connected_e.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_connected_e.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_connected_g.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_connected_g.png
index 91db8e8..fd419ea 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_connected_g.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_connected_g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_connected_h.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_connected_h.png
index 44ab1ec..94e77ae 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_connected_h.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_connected_h.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_connected_1x.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_connected_1x.png
index c9d6719..91328c0 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_connected_1x.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_connected_1x.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_connected_3g.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_connected_3g.png
index e0a39cf..2fee6924 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_connected_3g.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_connected_3g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_connected_e.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_connected_e.png
index 93b8f94..d0968aa 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_connected_e.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_connected_e.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_connected_g.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_connected_g.png
index 5561011..991228b 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_connected_g.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_connected_g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_connected_h.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_connected_h.png
index 697b908..ae03e38 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_connected_h.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_connected_h.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_in_1x.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_in_1x.png
index 4cced10..97b011e 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_in_1x.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_in_1x.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_in_3g.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_in_3g.png
index 6f2f058..a826866 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_in_3g.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_in_3g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_in_e.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_in_e.png
index b523d64..f6a6891 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_in_e.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_in_e.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_in_g.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_in_g.png
index c9bbf6c..19b9816 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_in_g.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_in_g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_in_h.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_in_h.png
index 6bc637a..f8c0961 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_in_h.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_in_h.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_inandout_1x.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_inandout_1x.png
index 6e47d43..22deb70 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_inandout_1x.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_inandout_1x.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_inandout_3g.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_inandout_3g.png
index a20e5bf..c7c1b49 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_inandout_3g.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_inandout_3g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_inandout_e.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_inandout_e.png
index 8f135a5..d9a0702 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_inandout_e.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_inandout_e.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_inandout_g.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_inandout_g.png
index cecf2c6..6beed8a 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_inandout_g.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_inandout_g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_inandout_h.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_inandout_h.png
index 3f86741..e4179c1 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_inandout_h.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_inandout_h.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_out_1x.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_out_1x.png
index 4740b9f..4b2f86d 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_out_1x.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_out_1x.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_out_3g.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_out_3g.png
index 5d0ac29..6779604 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_out_3g.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_out_3g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_out_e.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_out_e.png
index 768eac6..1309a97 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_out_e.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_out_e.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_out_g.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_out_g.png
index 49d6279..2fc1e8e 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_out_g.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_out_g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_out_h.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_out_h.png
index 4d7df96..0eef2c1 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_out_h.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_fully_out_h.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_in_1x.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_in_1x.png
index 3045a57..f8904e2 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_in_1x.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_in_1x.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_in_3g.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_in_3g.png
index 661eccc..3ef306e 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_in_3g.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_in_3g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_in_e.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_in_e.png
index 401cb55..2ff6d90 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_in_e.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_in_e.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_in_g.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_in_g.png
index cc4e26f..8ff49b0 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_in_g.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_in_g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_in_h.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_in_h.png
index a000da2..f416203 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_in_h.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_in_h.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_inandout_1x.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_inandout_1x.png
index 32c547e..24b7daa 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_inandout_1x.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_inandout_1x.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_inandout_3g.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_inandout_3g.png
index d769174..5ea9142 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_inandout_3g.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_inandout_3g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_inandout_e.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_inandout_e.png
index c895aeb..5bf6aca 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_inandout_e.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_inandout_e.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_inandout_g.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_inandout_g.png
index c201350..002bf46 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_inandout_g.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_inandout_g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_inandout_h.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_inandout_h.png
index df2aa30..924b84f 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_inandout_h.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_inandout_h.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_out_1x.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_out_1x.png
index 6b1a914..bd0d1ca 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_out_1x.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_out_1x.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_out_3g.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_out_3g.png
index 5edc35a..f583eec 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_out_3g.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_out_3g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_out_e.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_out_e.png
index c94c001..66940eaf 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_out_e.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_out_e.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_out_g.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_out_g.png
index 16c3d6b..0381f52 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_out_g.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_out_g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_out_h.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_out_h.png
index 7daf6af..0b84fe8 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_out_h.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_out_h.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_gps_acquiring.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_gps_acquiring.png
index 31bc94e..e5e98f9 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_gps_acquiring.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_gps_acquiring.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_r_signal_0.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_r_signal_0.png
index 8f5b3ef..7f6fa9c 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_r_signal_0.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_r_signal_0.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_r_signal_0_fully.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_r_signal_0_fully.png
index 8f5b3ef..7f6fa9c 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_r_signal_0_fully.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_r_signal_0_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_r_signal_1.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_r_signal_1.png
index 960c0e2..ca20839 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_r_signal_1.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_r_signal_1.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_r_signal_1_fully.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_r_signal_1_fully.png
index 960c0e2..1ad5d8b 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_r_signal_1_fully.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_r_signal_1_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_r_signal_2.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_r_signal_2.png
index a115a23..6eba560 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_r_signal_2.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_r_signal_2.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_r_signal_2_fully.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_r_signal_2_fully.png
index a115a23..f2358dd 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_r_signal_2_fully.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_r_signal_2_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_r_signal_3.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_r_signal_3.png
index 0ef34df..1ebe23e 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_r_signal_3.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_r_signal_3.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_r_signal_3_fully.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_r_signal_3_fully.png
index 0ef34df..468ad7d 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_r_signal_3_fully.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_r_signal_3_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_r_signal_4.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_r_signal_4.png
index 648599b..d9f2a0d 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_r_signal_4.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_r_signal_4.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_r_signal_4_fully.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_r_signal_4_fully.png
index 648599b..290822a 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_r_signal_4_fully.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_r_signal_4_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_ringer_silent.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_ringer_silent.png
index d62f32d..e0a3141 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_ringer_silent.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_ringer_silent.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_ringer_vibrate.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_ringer_vibrate.png
index 665ca38..116b8e2 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_ringer_vibrate.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_ringer_vibrate.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_0.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_0.png
index 39025f0..cf11f0d 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_0.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_0.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_1.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_1.png
index a1f7057..3b69d1e 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_1.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_1.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_1_fully.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_1_fully.png
index 7cc9f02..b012b18 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_1_fully.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_1_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_2.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_2.png
index 122a473..8736234 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_2.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_2.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_2_fully.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_2_fully.png
index 4b126dc..cc68512 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_2_fully.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_2_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_3.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_3.png
index 828c0e2..5a2d3c0 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_3.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_3.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_3_fully.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_3_fully.png
index f52d8f9..a93d49c 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_3_fully.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_3_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_4.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_4.png
index 61501c1..3fbf7fc 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_4.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_4.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_4_fully.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_4_fully.png
index 1171ffc..e3ff8b9 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_4_fully.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_4_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_flightmode.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_flightmode.png
index 98c3b10..a1a9794 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_flightmode.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_flightmode.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_null.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_null.png
index cf13c79..5d9957a 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_null.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_signal_null.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_0.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_0.png
index 94c41a7..b11ad16 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_0.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_0.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_1.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_1.png
index ac32aa6..94d40e0 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_1.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_1.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_1_fully.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_1_fully.png
index 9845c46..4a896f3 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_1_fully.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_1_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_2.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_2.png
index 34494e3..b09b40d 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_2.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_2.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_2_fully.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_2_fully.png
index 77f4a7b..0f9c187 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_2_fully.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_2_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_3.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_3.png
index a635c3c..b852dba 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_3.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_3.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_3_fully.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_3_fully.png
index c3e9240..0468d06 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_3_fully.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_3_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_4.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_4.png
index 68ffdc9..06bbb4a 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_4.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_4.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_4_fully.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_4_fully.png
index 93a3dc0..1858af3 100644
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_4_fully.png
+++ b/packages/SystemUI/res/drawable-mdpi/stat_sys_wifi_signal_4_fully.png
Binary files differ
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/InputMethodsPanel.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/InputMethodsPanel.java
index 06c789c..a1cc274 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/InputMethodsPanel.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/InputMethodsPanel.java
@@ -16,8 +16,10 @@
 
 package com.android.systemui.statusbar.tablet;
 
+import android.content.BroadcastReceiver;
 import android.content.Context;
 import android.content.Intent;
+import android.content.IntentFilter;
 import android.content.pm.PackageManager;
 import android.graphics.drawable.Drawable;
 import android.os.IBinder;
@@ -49,14 +51,24 @@
     private static final boolean DEBUG = TabletStatusBar.DEBUG;
     private static final String TAG = "InputMethodsPanel";
 
+    private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            onPackageChanged();
+        }
+    };
+
     private final InputMethodManager mImm;
+    private final IntentFilter mIntentFilter = new IntentFilter();
+    private final HashMap<View, Pair<InputMethodInfo, InputMethodSubtype>> mRadioViewAndImiMap =
+            new HashMap<View, Pair<InputMethodInfo, InputMethodSubtype>>();
     private final TreeMap<InputMethodInfo, List<InputMethodSubtype>>
             mEnabledInputMethodAndSubtypesCache =
                     new TreeMap<InputMethodInfo, List<InputMethodSubtype>>(
                             new InputMethodComparator());
-    private final HashMap<View, Pair<InputMethodInfo, InputMethodSubtype>> mRadioViewAndImiMap =
-            new HashMap<View, Pair<InputMethodInfo, InputMethodSubtype>>();
 
+    private boolean mAttached = false;
+    private boolean mPackageChanged = false;
     private Context mContext;
     private IBinder mToken;
     private InputMethodButton mInputMethodSwitchButton;
@@ -88,6 +100,28 @@
         super(context, attrs, defStyle);
         mContext = context;
         mImm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
+        mIntentFilter.addAction(Intent.ACTION_PACKAGE_REPLACED);
+        mIntentFilter.addAction(Intent.ACTION_PACKAGE_ADDED);
+        mIntentFilter.addAction(Intent.ACTION_PACKAGE_REMOVED);
+        mIntentFilter.addDataScheme("package");
+    }
+
+    @Override
+    protected void onDetachedFromWindow() {
+        super.onDetachedFromWindow();
+        if (mAttached) {
+            getContext().unregisterReceiver(mBroadcastReceiver);
+            mAttached = false;
+        }
+    }
+
+    @Override
+    protected void onAttachedToWindow() {
+        super.onAttachedToWindow();
+        if (!mAttached) {
+            getContext().registerReceiver(mBroadcastReceiver, mIntentFilter);
+            mAttached = true;
+        }
     }
 
     @Override
@@ -302,7 +336,8 @@
         String newEnabledIMIs = Settings.Secure.getString(
                 mContext.getContentResolver(), Settings.Secure.ENABLED_INPUT_METHODS);
         if (mEnabledInputMethodAndSubtypesCacheStr == null
-                || !mEnabledInputMethodAndSubtypesCacheStr.equals(newEnabledIMIs)) {
+                || !mEnabledInputMethodAndSubtypesCacheStr.equals(newEnabledIMIs)
+                || mPackageChanged) {
             mEnabledInputMethodAndSubtypesCache.clear();
             final List<InputMethodInfo> imis = mImm.getEnabledInputMethodList();
             for (InputMethodInfo imi: imis) {
@@ -310,6 +345,7 @@
                         mImm.getEnabledInputMethodSubtypeList(imi, true));
             }
             mEnabledInputMethodAndSubtypesCacheStr = newEnabledIMIs;
+            mPackageChanged = false;
         }
         return mEnabledInputMethodAndSubtypesCache;
     }
@@ -376,4 +412,11 @@
         }
         return null;
     }
+
+    private void onPackageChanged() {
+        if (DEBUG) {
+            Log.d(TAG, "onPackageChanged.");
+        }
+        mPackageChanged = true;
+    }
 }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java
index d46de15..14a2f90 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java
@@ -391,8 +391,11 @@
             new View.OnTouchListener() {
                 public boolean onTouch(View v, MotionEvent ev) {
                     if (ev.getAction() == MotionEvent.ACTION_DOWN) {
-                        mShadow.setVisibility(View.GONE);
-                        mBarContents.setVisibility(View.VISIBLE);
+                        try {
+                            mBarService.setSystemUiVisibility(View.STATUS_BAR_VISIBLE);
+                        } catch (RemoteException ex) {
+                            // system process dead
+                        }
                     }
                     return false;
                 }
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
index 9b5c42e..fd84a2a 100755
--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -1892,14 +1892,12 @@
                 + (topNeedsMenu ? "needs" : "does not need")
                 + " the MENU key");
 
-        final boolean changedFullscreen = (mTopIsFullscreen != topIsFullscreen);
+        mTopIsFullscreen = topIsFullscreen;
         final boolean changedMenu = (topNeedsMenu != mShowMenuKey);
 
-        if (changedFullscreen || changedMenu) {
-            final boolean topIsFullscreenF = topIsFullscreen;
+        if (changedMenu) {
             final boolean topNeedsMenuF = topNeedsMenu;
 
-            mTopIsFullscreen = topIsFullscreen;
             mShowMenuKey = topNeedsMenu;
 
             mHandler.post(new Runnable() {
@@ -1918,9 +1916,6 @@
                                 if (changedMenu) {
                                     sbs.setMenuKeyVisible(topNeedsMenuF);
                                 }
-                                if (changedFullscreen) {
-                                    sbs.setActiveWindowIsFullscreen(topIsFullscreenF);
-                                }
                             } catch (RemoteException e) {
                                 // This should be impossible because we're in the same process.
                                 mStatusBarService = null;
@@ -2860,7 +2855,8 @@
         // If there is no window focused, there will be nobody to handle the events
         // anyway, so just hang on in whatever state we're in until things settle down.
         if (mFocusedWindow != null) {
-            final int visibility = mFocusedWindow.getAttrs().systemUiVisibility;
+            final WindowManager.LayoutParams params = mFocusedWindow.getAttrs();
+            final int visibility = params.systemUiVisibility | params.subtreeSystemUiVisibility;
             mHandler.post(new Runnable() {
                     public void run() {
                         if (mStatusBarService == null) {
diff --git a/services/java/com/android/server/AppWidgetService.java b/services/java/com/android/server/AppWidgetService.java
index 59a540b..ad25657 100644
--- a/services/java/com/android/server/AppWidgetService.java
+++ b/services/java/com/android/server/AppWidgetService.java
@@ -22,6 +22,7 @@
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.PrintWriter;
+import java.lang.ref.WeakReference;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -62,6 +63,7 @@
 import android.os.RemoteException;
 import android.os.SystemClock;
 import android.util.AttributeSet;
+import android.util.Log;
 import android.util.Pair;
 import android.util.Slog;
 import android.util.TypedValue;
@@ -121,18 +123,15 @@
      * globally and may lead us to leak AppWidgetService instances (if there were more than one).
      */
     static class ServiceConnectionProxy implements ServiceConnection {
-        private final AppWidgetService mAppWidgetService;
         private final Pair<Integer, Intent.FilterComparison> mKey;
         private final IBinder mConnectionCb;
 
-        ServiceConnectionProxy(AppWidgetService appWidgetService,
-                Pair<Integer, Intent.FilterComparison> key, IBinder connectionCb) {
-            mAppWidgetService = appWidgetService;
+        ServiceConnectionProxy(Pair<Integer, Intent.FilterComparison> key, IBinder connectionCb) {
             mKey = key;
             mConnectionCb = connectionCb;
         }
         public void onServiceConnected(ComponentName name, IBinder service) {
-            IRemoteViewsAdapterConnection cb =
+            final IRemoteViewsAdapterConnection cb =
                 IRemoteViewsAdapterConnection.Stub.asInterface(mConnectionCb);
             try {
                 cb.onServiceConnected(service);
@@ -141,19 +140,13 @@
             }
         }
         public void onServiceDisconnected(ComponentName name) {
-            IRemoteViewsAdapterConnection cb =
+            disconnect();
+        }
+        public void disconnect() {
+            final IRemoteViewsAdapterConnection cb =
                 IRemoteViewsAdapterConnection.Stub.asInterface(mConnectionCb);
             try {
                 cb.onServiceDisconnected();
-                mAppWidgetService.mServiceConnectionUpdateHandler.post(new Runnable() {
-                    public void run() {
-                        // We don't want to touch mBoundRemoteViewsServices from any other thread
-                        // so queue this to run on the main thread.
-                        if (mAppWidgetService.mBoundRemoteViewsServices.containsKey(mKey)) {
-                            mAppWidgetService.mBoundRemoteViewsServices.remove(mKey);
-                        }
-                    }
-                });
             } catch (RemoteException e) {
                 e.printStackTrace();
             }
@@ -163,7 +156,6 @@
     // Manages connections to RemoteViewsServices
     private final HashMap<Pair<Integer, FilterComparison>, ServiceConnection>
         mBoundRemoteViewsServices = new HashMap<Pair<Integer,FilterComparison>,ServiceConnection>();
-    private final Handler mServiceConnectionUpdateHandler = new Handler();
 
     Context mContext;
     Locale mLocale;
@@ -456,13 +448,24 @@
                 throw new IllegalArgumentException("Unknown component " + componentName);
             }
 
-            // Bind to the RemoteViewsService (which will trigger a callback to the
-            // RemoteViewsAdapter)
+            // If there is already a connection made for this service intent, then disconnect from
+            // that first.  (This does not allow multiple connections to the same service under
+            // the same key)
+            ServiceConnectionProxy conn = null;
             Pair<Integer, FilterComparison> key = Pair.create(appWidgetId,
                     new FilterComparison(intent));
-            final ServiceConnection conn = new ServiceConnectionProxy(this, key, connection);
+            if (mBoundRemoteViewsServices.containsKey(key)) {
+                conn = (ServiceConnectionProxy) mBoundRemoteViewsServices.get(key);
+                conn.disconnect();
+                mContext.unbindService(conn);
+                mBoundRemoteViewsServices.remove(key);
+            }
+
+            // Bind to the RemoteViewsService (which will trigger a callback to the
+            // RemoteViewsAdapter.onServiceConnected())
             final long token = Binder.clearCallingIdentity();
             try {
+                conn = new ServiceConnectionProxy(key, connection);
                 mContext.bindService(intent, conn, Context.BIND_AUTO_CREATE);
                 mBoundRemoteViewsServices.put(key, conn);
             } finally {
@@ -473,37 +476,43 @@
 
     public void unbindRemoteViewsService(int appWidgetId, Intent intent) {
         synchronized (mAppWidgetIds) {
-            AppWidgetId id = lookupAppWidgetIdLocked(appWidgetId);
-            if (id == null) {
-                throw new IllegalArgumentException("bad appWidgetId");
-            }
-
             // Unbind from the RemoteViewsService (which will trigger a callback to the bound
             // RemoteViewsAdapter)
             Pair<Integer, FilterComparison> key = Pair.create(appWidgetId,
                     new FilterComparison(intent));
             if (mBoundRemoteViewsServices.containsKey(key)) {
-                final ServiceConnection conn = mBoundRemoteViewsServices.get(key);
-                mBoundRemoteViewsServices.remove(key);
-                conn.onServiceDisconnected(null);
+                // We don't need to use the appWidgetId until after we are sure there is something
+                // to unbind.  Note that this may mask certain issues with apps calling unbind()
+                // more than necessary.
+                AppWidgetId id = lookupAppWidgetIdLocked(appWidgetId);
+                if (id == null) {
+                    throw new IllegalArgumentException("bad appWidgetId");
+                }
+
+                ServiceConnectionProxy conn =
+                    (ServiceConnectionProxy) mBoundRemoteViewsServices.get(key);
+                conn.disconnect();
                 mContext.unbindService(conn);
+                mBoundRemoteViewsServices.remove(key);
+            } else {
+                Log.e("AppWidgetService", "Error (unbindRemoteViewsService): Connection not bound");
             }
         }
     }
 
     private void unbindAppWidgetRemoteViewsServicesLocked(AppWidgetId id) {
+        int appWidgetId = id.appWidgetId;
+        // Unbind all connections to Services bound to this AppWidgetId
         Iterator<Pair<Integer, Intent.FilterComparison>> it =
             mBoundRemoteViewsServices.keySet().iterator();
-        int appWidgetId = id.appWidgetId;
-
-        // Unbind all connections to AppWidgets bound to this id
         while (it.hasNext()) {
             final Pair<Integer, Intent.FilterComparison> key = it.next();
             if (key.first.intValue() == appWidgetId) {
-                final ServiceConnection conn = mBoundRemoteViewsServices.get(key);
-                it.remove();
-                conn.onServiceDisconnected(null);
+                final ServiceConnectionProxy conn = (ServiceConnectionProxy)
+                        mBoundRemoteViewsServices.get(key);
+                conn.disconnect();
                 mContext.unbindService(conn);
+                it.remove();
             }
         }
     }
diff --git a/services/java/com/android/server/ScreenRotationAnimation.java b/services/java/com/android/server/ScreenRotationAnimation.java
index bef64b3..90318f1 100644
--- a/services/java/com/android/server/ScreenRotationAnimation.java
+++ b/services/java/com/android/server/ScreenRotationAnimation.java
@@ -102,7 +102,7 @@
                 Slog.w(TAG, "Unable to allocate freeze surface", e);
             }
 
-            if (false) {
+            if (true) {
                 try {
                     int size = mOriginalWidth > mOriginalHeight ? mOriginalWidth : mOriginalHeight;
                     mBlackSurface = new Surface(session, 0, "BlackSurface",
diff --git a/services/java/com/android/server/StatusBarManagerService.java b/services/java/com/android/server/StatusBarManagerService.java
index 50ea3fa..bdaa3b0 100644
--- a/services/java/com/android/server/StatusBarManagerService.java
+++ b/services/java/com/android/server/StatusBarManagerService.java
@@ -283,33 +283,8 @@
         }
     }
 
-    /**
-     * This is used for the automatic version of lights-out mode.  Only call this from
-     * the window manager.
-     *
-     * @see setLightsOn(boolean)
-     */
-    public void setActiveWindowIsFullscreen(boolean fullscreen) {
-        // We could get away with a separate permission here, but STATUS_BAR is
-        // signatureOrSystem which is probably good enough.  There is no public API
-        // for this, so the question is a security issue, not an API compatibility issue.
-        enforceStatusBar();
-
-        synchronized (mLock) {
-            updateLightsOnLocked(!fullscreen);
-        }
-    }
-
-    /**
-     * This is used for the user-controlled version of lights-out mode.  Only call this from
-     * the status bar itself.
-     *
-     * We have two different functions here, because I think we're going to want to
-     * tweak the behavior when the user keeps turning lights-out mode off and the
-     * app keeps trying to turn it on.  For now they can just fight it out.  Having
-     * these two separte inputs will allow us to keep that change local to here.  --joeo
-     */
     public void setSystemUiVisibility(int vis) {
+        // also allows calls from window manager which is in this process.
         enforceStatusBarService();
 
         synchronized (mLock) {
diff --git a/services/surfaceflinger/LayerBase.cpp b/services/surfaceflinger/LayerBase.cpp
index 464841b..8d83f0b 100644
--- a/services/surfaceflinger/LayerBase.cpp
+++ b/services/surfaceflinger/LayerBase.cpp
@@ -563,10 +563,15 @@
     if (s == 0) {
         s = createSurface();
         mClientSurface = s;
+        mClientSurfaceBinder = s->asBinder();
     }
     return s;
 }
 
+wp<IBinder> LayerBaseClient::getSurfaceBinder() const {
+    return mClientSurfaceBinder;
+}
+
 sp<LayerBaseClient::Surface> LayerBaseClient::createSurface() const
 {
     return new Surface(mFlinger, mIdentity,
diff --git a/services/surfaceflinger/LayerBase.h b/services/surfaceflinger/LayerBase.h
index 1a34f52..8ed4749 100644
--- a/services/surfaceflinger/LayerBase.h
+++ b/services/surfaceflinger/LayerBase.h
@@ -285,6 +285,7 @@
     virtual ~LayerBaseClient();
 
             sp<Surface> getSurface();
+            wp<IBinder> getSurfaceBinder() const;
     virtual sp<Surface> createSurface() const;
     virtual sp<LayerBaseClient> getLayerBaseClient() const {
         return const_cast<LayerBaseClient*>(this); }
@@ -325,6 +326,7 @@
 private:
     mutable Mutex mLock;
     mutable wp<Surface> mClientSurface;
+    wp<IBinder> mClientSurfaceBinder;
     const wp<Client> mClientRef;
     // only read
     const uint32_t mIdentity;
diff --git a/services/surfaceflinger/LayerDim.cpp b/services/surfaceflinger/LayerDim.cpp
index 80cc52c..11f8feb 100644
--- a/services/surfaceflinger/LayerDim.cpp
+++ b/services/surfaceflinger/LayerDim.cpp
@@ -67,8 +67,14 @@
         const GLfloat alpha = s.alpha/255.0f;
         const uint32_t fbHeight = hw.getHeight();
         glDisable(GL_DITHER);
-        glEnable(GL_BLEND);
-        glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+
+        if (s.alpha == 0xFF) {
+            glDisable(GL_BLEND);
+        } else {
+            glEnable(GL_BLEND);
+            glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+        }
+
         glColor4f(0, 0, 0, alpha);
 
 #if defined(GL_OES_EGL_image_external)
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 291ebc5..87b66ea 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -1088,7 +1088,7 @@
 {
     sp<LayerBaseClient> lbc(layerBase->getLayerBaseClient());
     if (lbc != 0) {
-        mLayerMap.removeItem( lbc->getSurface()->asBinder() );
+        mLayerMap.removeItem( lbc->getSurfaceBinder() );
     }
     ssize_t index = mCurrentState.layersSortedByZ.remove(layerBase);
     if (index >= 0) {
diff --git a/telephony/java/com/android/internal/telephony/RIL.java b/telephony/java/com/android/internal/telephony/RIL.java
index 7506bb1..39bbd63 100644
--- a/telephony/java/com/android/internal/telephony/RIL.java
+++ b/telephony/java/com/android/internal/telephony/RIL.java
@@ -214,7 +214,7 @@
      * Wake lock timeout should be longer than the longest timeout in
      * the vendor ril.
      */
-    private static final int DEFAULT_WAKE_LOCK_TIMEOUT = 30000;
+    private static final int DEFAULT_WAKE_LOCK_TIMEOUT = 60000;
 
     //***** Instance Variables