Merge "Fix initial 0 duration video sample in the recorded videos"
diff --git a/api/current.txt b/api/current.txt
index 72ba551..286e640 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -3558,6 +3558,7 @@
     method public android.app.Notification.Builder setNumber(int);
     method public android.app.Notification.Builder setOngoing(boolean);
     method public android.app.Notification.Builder setOnlyAlertOnce(boolean);
+    method public android.app.Notification.Builder setProgress(int, int, boolean);
     method public android.app.Notification.Builder setSmallIcon(int);
     method public android.app.Notification.Builder setSmallIcon(int, int);
     method public android.app.Notification.Builder setSound(android.net.Uri);
@@ -9097,6 +9098,7 @@
     method public final void release();
     method public final void setDisplayOrientation(int);
     method public final void setErrorCallback(android.hardware.Camera.ErrorCallback);
+    method public final void setFaceDetectionListener(android.hardware.Camera.FaceDetectionListener);
     method public final void setOneShotPreviewCallback(android.hardware.Camera.PreviewCallback);
     method public void setParameters(android.hardware.Camera.Parameters);
     method public final void setPreviewCallback(android.hardware.Camera.PreviewCallback);
@@ -9104,8 +9106,10 @@
     method public final void setPreviewDisplay(android.view.SurfaceHolder) throws java.io.IOException;
     method public final void setPreviewTexture(android.graphics.SurfaceTexture) throws java.io.IOException;
     method public final void setZoomChangeListener(android.hardware.Camera.OnZoomChangeListener);
+    method public final void startFaceDetection();
     method public final void startPreview();
     method public final void startSmoothZoom(int);
+    method public final void stopFaceDetection();
     method public final void stopPreview();
     method public final void stopSmoothZoom();
     method public final void takePicture(android.hardware.Camera.ShutterCallback, android.hardware.Camera.PictureCallback, android.hardware.Camera.PictureCallback);
@@ -9139,6 +9143,16 @@
     method public abstract void onError(int, android.hardware.Camera);
   }
 
+  public static class Camera.Face {
+    ctor public Camera.Face();
+    field public android.graphics.Rect rect;
+    field public int score;
+  }
+
+  public static abstract interface Camera.FaceDetectionListener {
+    method public abstract void onFaceDetection(android.hardware.Camera.Face[], android.hardware.Camera);
+  }
+
   public static abstract interface Camera.OnZoomChangeListener {
     method public abstract void onZoomChange(int, boolean, android.hardware.Camera);
   }
@@ -9163,6 +9177,7 @@
     method public int getJpegThumbnailQuality();
     method public android.hardware.Camera.Size getJpegThumbnailSize();
     method public int getMaxExposureCompensation();
+    method public int getMaxNumDetectedFaces();
     method public int getMaxNumFocusAreas();
     method public int getMaxNumMeteringAreas();
     method public int getMaxZoom();
@@ -17032,6 +17047,7 @@
     field public static final deprecated java.lang.String PARENTAL_CONTROL_REDIRECT_URL = "parental_control_redirect_url";
     field public static final java.lang.String RADIO_BLUETOOTH = "bluetooth";
     field public static final java.lang.String RADIO_CELL = "cell";
+    field public static final java.lang.String RADIO_NFC = "nfc";
     field public static final java.lang.String RADIO_WIFI = "wifi";
     field public static final java.lang.String RINGTONE = "ringtone";
     field public static final java.lang.String SCREEN_BRIGHTNESS = "screen_brightness";
@@ -17929,7 +17945,7 @@
     method public void destroyRenderScriptGL();
     method public android.renderscript.RenderScriptGL getRenderScriptGL();
     method public void onSurfaceTextureAvailable(android.graphics.SurfaceTexture, int, int);
-    method public void onSurfaceTextureDestroyed(android.graphics.SurfaceTexture);
+    method public boolean onSurfaceTextureDestroyed(android.graphics.SurfaceTexture);
     method public void onSurfaceTextureSizeChanged(android.graphics.SurfaceTexture, int, int);
     method public void onSurfaceTextureUpdated(android.graphics.SurfaceTexture);
     method public void pause();
@@ -22350,7 +22366,7 @@
 
   public static abstract interface TextureView.SurfaceTextureListener {
     method public abstract void onSurfaceTextureAvailable(android.graphics.SurfaceTexture, int, int);
-    method public abstract void onSurfaceTextureDestroyed(android.graphics.SurfaceTexture);
+    method public abstract boolean onSurfaceTextureDestroyed(android.graphics.SurfaceTexture);
     method public abstract void onSurfaceTextureSizeChanged(android.graphics.SurfaceTexture, int, int);
     method public abstract void onSurfaceTextureUpdated(android.graphics.SurfaceTexture);
   }
@@ -26455,6 +26471,8 @@
     method public void onActionViewExpanded();
     method public void setIconified(boolean);
     method public void setIconifiedByDefault(boolean);
+    method public void setImeOptions(int);
+    method public void setInputType(int);
     method public void setMaxWidth(int);
     method public void setOnCloseListener(android.widget.SearchView.OnCloseListener);
     method public void setOnQueryTextFocusChangeListener(android.view.View.OnFocusChangeListener);
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index 170d2b5..9490b96 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -26,6 +26,7 @@
 import android.os.Parcelable;
 import android.text.TextUtils;
 import android.view.View;
+import android.widget.ProgressBar;
 import android.widget.RemoteViews;
 
 import java.text.NumberFormat;
@@ -645,6 +646,9 @@
         private int mLedOffMs;
         private int mDefaults;
         private int mFlags;
+        private int mProgressMax;
+        private int mProgress;
+        private boolean mProgressIndeterminate;
 
         /**
          * Constructor.
@@ -736,6 +740,17 @@
         }
 
         /**
+         * Set the progress this notification represents, which may be
+         * represented as a {@link ProgressBar}.
+         */
+        public Builder setProgress(int max, int progress, boolean indeterminate) {
+            mProgressMax = max;
+            mProgress = progress;
+            mProgressIndeterminate = indeterminate;
+            return this;
+        }
+
+        /**
          * Supply a custom RemoteViews to use instead of the standard one.
          */
         public Builder setContent(RemoteViews views) {
@@ -917,17 +932,24 @@
 
         private RemoteViews makeRemoteViews(int resId) {
             RemoteViews contentView = new RemoteViews(mContext.getPackageName(), resId);
+            boolean hasLine3 = false;
             if (mSmallIcon != 0) {
                 contentView.setImageViewResource(R.id.icon, mSmallIcon);
+                contentView.setViewVisibility(R.id.icon, View.VISIBLE);
+            } else {
+                contentView.setViewVisibility(R.id.icon, View.GONE);
             }
             if (mContentTitle != null) {
                 contentView.setTextViewText(R.id.title, mContentTitle);
             }
             if (mContentText != null) {
                 contentView.setTextViewText(R.id.text, mContentText);
+                hasLine3 = true;
             }
             if (mContentInfo != null) {
                 contentView.setTextViewText(R.id.info, mContentInfo);
+                contentView.setViewVisibility(R.id.info, View.VISIBLE);
+                hasLine3 = true;
             } else if (mNumber > 0) {
                 final int tooBig = mContext.getResources().getInteger(
                         R.integer.status_bar_notification_info_maxnum);
@@ -938,12 +960,22 @@
                     NumberFormat f = NumberFormat.getIntegerInstance();
                     contentView.setTextViewText(R.id.info, f.format(mNumber));
                 }
+                contentView.setViewVisibility(R.id.info, View.VISIBLE);
+                hasLine3 = true;
             } else {
                 contentView.setViewVisibility(R.id.info, View.GONE);
             }
+            if (mProgressMax != 0 || mProgressIndeterminate) {
+                contentView.setProgressBar(
+                        R.id.progress, mProgressMax, mProgress, mProgressIndeterminate);
+                contentView.setViewVisibility(R.id.progress, View.VISIBLE);
+            } else {
+                contentView.setViewVisibility(R.id.progress, View.GONE);
+            }
             if (mWhen != 0) {
                 contentView.setLong(R.id.time, "setTime", mWhen);
             }
+            contentView.setViewVisibility(R.id.line3, hasLine3 ? View.VISIBLE : View.GONE);
             return contentView;
         }
 
diff --git a/core/java/android/hardware/Camera.java b/core/java/android/hardware/Camera.java
index 8d3750a..cab8457 100644
--- a/core/java/android/hardware/Camera.java
+++ b/core/java/android/hardware/Camera.java
@@ -167,22 +167,13 @@
 
     /**
      * Hardware face detection. It does not use much CPU.
-     *
-     * @see #startFaceDetection(int)
-     * @see Parameters#getMaxNumDetectedFaces(int)
-     * @see #CAMERA_FACE_DETECTION_SW
-     * @hide
      */
-    public static final int CAMERA_FACE_DETECTION_HW = 0;
+    private static final int CAMERA_FACE_DETECTION_HW = 0;
 
     /**
-     * Software face detection. It uses some CPU. Applications must use
-     * {@link #setPreviewTexture(SurfaceTexture)} for preview in this mode.
-     *
-     * @see #CAMERA_FACE_DETECTION_HW
-     * @hide
+     * Software face detection. It uses some CPU.
      */
-    public static final int CAMERA_FACE_DETECTION_SW = 1;
+    private static final int CAMERA_FACE_DETECTION_SW = 1;
 
     /**
      * Returns the number of physical cameras available on this device.
@@ -1071,7 +1062,6 @@
     /**
      * Callback interface for face detected in the preview frame.
      *
-     * @hide
      */
     public interface FaceDetectionListener
     {
@@ -1086,12 +1076,11 @@
     }
 
     /**
-     * Registers a listener to be notified about the face detected of the
+     * Registers a listener to be notified about the faces detected in the
      * preview frame.
      *
      * @param listener the listener to notify
-     * @see #startFaceDetection(int)
-     * @hide
+     * @see #startFaceDetection()
      */
     public final void setFaceDetectionListener(FaceDetectionListener listener)
     {
@@ -1099,48 +1088,37 @@
     }
 
     /**
-     * Start the face detection. This should be called after preview is started.
+     * Starts the face detection. This should be called after preview is started.
      * The camera will notify {@link FaceDetectionListener} of the detected
      * faces in the preview frame. The detected faces may be the same as the
      * previous ones. Applications should call {@link #stopFaceDetection} to
      * stop the face detection. This method is supported if {@link
-     * Parameters#getMaxNumDetectedFaces(int)} returns a number larger than 0.
-     * Hardware and software face detection cannot be used at the same time.
+     * Parameters#getMaxNumDetectedFaces()} returns a number larger than 0.
      * If the face detection has started, apps should not call this again.
      *
-     * In hardware face detection mode, {@link Parameters#setWhiteBalance(String)},
+     * When the face detection is running, {@link Parameters#setWhiteBalance(String)},
      * {@link Parameters#setFocusAreas(List)}, and {@link Parameters#setMeteringAreas(List)}
      * have no effect.
      *
-     * @param type face detection type. This can be either {@link
-     *        #CAMERA_FACE_DETECTION_HW} or {@link #CAMERA_FACE_DETECTION_SW}
-     * @throws IllegalArgumentException if the face detection type is
-     *         unsupported or invalid.
+     * @throws IllegalArgumentException if the face detection is unsupported.
      * @throws RuntimeException if the method fails or the face detection is
      *         already running.
-     * @see #CAMERA_FACE_DETECTION_HW
-     * @see #CAMERA_FACE_DETECTION_SW
      * @see FaceDetectionListener
      * @see #stopFaceDetection()
-     * @see Parameters#getMaxNumDetectedFaces(int)
-     * @hide
+     * @see Parameters#getMaxNumDetectedFaces()
      */
-    public final void startFaceDetection(int type) {
-        if (type != CAMERA_FACE_DETECTION_HW && type != CAMERA_FACE_DETECTION_SW) {
-            throw new IllegalArgumentException("Invalid face detection type " + type);
-        }
+    public final void startFaceDetection() {
         if (mFaceDetectionRunning) {
             throw new RuntimeException("Face detection is already running");
         }
-        _startFaceDetection(type);
+        _startFaceDetection(CAMERA_FACE_DETECTION_HW);
         mFaceDetectionRunning = true;
     }
 
     /**
-     * Stop the face detection.
+     * Stops the face detection.
      *
      * @see #startFaceDetection(int)
-     * @hide
      */
     public final void stopFaceDetection() {
         _stopFaceDetection();
@@ -1153,17 +1131,21 @@
     /**
      * The information of a face from camera face detection.
      *
-     * @hide
      */
     public static class Face {
+        /**
+         * Create an empty face.
+         */
         public Face() {
         }
 
         /**
          * Bounds of the face. (-1000, -1000) represents the top-left of the
          * camera field of view, and (1000, 1000) represents the bottom-right of
-         * the field of view. The width and height cannot be 0 or negative. This
-         * is supported by both hardware and software face detection.
+         * the field of view. For example, suppose the size of the viewfinder UI
+         * is 800x480. The rect passed from the driver is (-1000, -1000, 0, 0).
+         * The corresponding viewfinder rect should be (0, 0, 400, 240). The
+         * width and height of the rect will not be 0 or negative.
          *
          * <p>The direction is relative to the sensor orientation, that is, what
          * the sensor sees. The direction is not affected by the rotation or
@@ -1175,37 +1157,11 @@
 
         /**
          * The confidence level of the face. The range is 1 to 100. 100 is the
-         * highest confidence. This is supported by both hardware and software
-         * face detction.
+         * highest confidence.
          *
          * @see #startFaceDetection(int)
          */
         public int score;
-
-        /**
-         * An unique id per face while the face is visible to the tracker. If
-         * the face leaves the field-of-view and comes back, it will get a new
-         * id. If the value is 0, id is not supported.
-         */
-        public int id;
-
-        /**
-         * The coordinates of the center of the left eye. The range is -1000 to
-         * 1000. null if this is not supported.
-         */
-        public Point leftEye;
-
-        /**
-         * The coordinates of the center of the right eye. The range is -1000 to
-         * 1000. null if this is not supported.
-         */
-        public Point rightEye;
-
-        /**
-         * The coordinates of the center of the mouth. The range is -1000 to
-         * 1000. null if this is not supported.
-         */
-        public Point mouth;
     }
 
     // Error codes match the enum in include/ui/Camera.h
@@ -3167,15 +3123,9 @@
          *
          * @return the maximum number of detected face supported by the camera.
          * @see #startFaceDetection(int)
-         * @hide
          */
-        public int getMaxNumDetectedFaces(int type) {
-            if (type == CAMERA_FACE_DETECTION_HW) {
-                return getInt(KEY_MAX_NUM_DETECTED_FACES_HW, 0);
-            } else if (type == CAMERA_FACE_DETECTION_SW){
-                return getInt(KEY_MAX_NUM_DETECTED_FACES_SW, 0);
-            }
-            throw new IllegalArgumentException("Invalid face detection type " + type);
+        public int getMaxNumDetectedFaces() {
+            return getInt(KEY_MAX_NUM_DETECTED_FACES_HW, 0);
         }
 
         /**
diff --git a/core/java/android/net/DnsPinger.java b/core/java/android/net/DnsPinger.java
index 81738f3..6115fef 100644
--- a/core/java/android/net/DnsPinger.java
+++ b/core/java/android/net/DnsPinger.java
@@ -147,8 +147,9 @@
                     DatagramPacket packet = new DatagramPacket(buf,
                             buf.length, dnsAddress, DNS_PORT);
                     if (V) {
-                        Slog.v(TAG, "Sending a ping to " + dnsAddress.getHostAddress()
-                                + " with ID " + newActivePing.packetId + ".");
+                        Slog.v(TAG, "Sending a ping " + newActivePing.internalId +
+                                " to " + dnsAddress.getHostAddress()
+                                + " with packetId " + newActivePing.packetId + ".");
                     }
 
                     newActivePing.socket.send(packet);
@@ -157,7 +158,7 @@
                     sendMessageDelayed(obtainMessage(ACTION_LISTEN_FOR_RESPONSE, mEventCounter, 0),
                             RECEIVE_POLL_INTERVAL_MS);
                 } catch (IOException e) {
-                    sendResponse((short) msg.arg1, SOCKET_EXCEPTION);
+                    sendResponse(msg.arg1, -9999, SOCKET_EXCEPTION);
                 }
                 break;
             case ACTION_LISTEN_FOR_RESPONSE:
@@ -193,12 +194,12 @@
                 while (iter.hasNext()) {
                    ActivePing curPing = iter.next();
                    if (curPing.result != null) {
-                       sendResponse(curPing.internalId, curPing.result);
+                       sendResponse(curPing.internalId, curPing.packetId, curPing.result);
                        curPing.socket.close();
                        iter.remove();
                    } else if (SystemClock.elapsedRealtime() >
                                   curPing.start + curPing.timeout) {
-                       sendResponse(curPing.internalId, TIMEOUT);
+                       sendResponse(curPing.internalId, curPing.packetId, TIMEOUT);
                        curPing.socket.close();
                        iter.remove();
                    }
@@ -255,9 +256,11 @@
         obtainMessage(ACTION_CANCEL_ALL_PINGS).sendToTarget();
     }
 
-    private void sendResponse(int internalId, int responseVal) {
+    private void sendResponse(int internalId, int externalId, int responseVal) {
         if(V) {
-            Slog.v(TAG, "Responding with id " + internalId + " and val " + responseVal);
+            Slog.d(TAG, "Responding to packet " + internalId +
+                    " externalId " + externalId +
+                    " and val " + responseVal);
         }
         mTarget.sendMessage(obtainMessage(DNS_PING_RESULT, internalId, responseVal));
     }
@@ -288,7 +291,7 @@
 
     private static final byte[] mDnsQuery = new byte[] {
         0, 0, // [0-1] is for ID (will set each time)
-        0, 0, // [2-3] are flags.  Set byte[2] = 1 for recursion desired (RD) on.  Currently off. 
+        1, 0, // [2-3] are flags.  Set byte[2] = 1 for recursion desired (RD) on.  Currently on.
         0, 1, // [4-5] bytes are for number of queries (QCOUNT)
         0, 0, // [6-7] unused count field for dns response packets
         0, 0, // [8-9] unused count field for dns response packets
diff --git a/core/java/android/net/NetworkStatsHistory.java b/core/java/android/net/NetworkStatsHistory.java
index c917af9..4ba44ca 100644
--- a/core/java/android/net/NetworkStatsHistory.java
+++ b/core/java/android/net/NetworkStatsHistory.java
@@ -424,8 +424,8 @@
         final NetworkStats.Entry entry = new NetworkStats.Entry(
                 IFACE_ALL, UID_ALL, TAG_NONE, 0L, 0L, 0L, 0L, 0L);
         final Random r = new Random();
-        while (rxBytes > 1024 && rxPackets > 128 && txBytes > 1024 && txPackets > 128
-                && operations > 32) {
+        while (rxBytes > 1024 || rxPackets > 128 || txBytes > 1024 || txPackets > 128
+                || operations > 32) {
             final long curStart = randomLong(r, start, end);
             final long curEnd = randomLong(r, curStart, end);
 
diff --git a/core/java/android/nfc/INfcAdapter.aidl b/core/java/android/nfc/INfcAdapter.aidl
index 83a055c..4fc248f 100644
--- a/core/java/android/nfc/INfcAdapter.aidl
+++ b/core/java/android/nfc/INfcAdapter.aidl
@@ -35,7 +35,7 @@
     INfcAdapterExtras getNfcAdapterExtrasInterface();
 
     // NfcAdapter-class related methods
-    boolean isEnabled();
+    int getState();
     void enableForegroundDispatch(in ComponentName activity, in PendingIntent intent,
             in IntentFilter[] filters, in TechListParcel techLists);
     void disableForegroundDispatch(in ComponentName activity);
@@ -48,5 +48,5 @@
     boolean enable();
     boolean enableZeroClick();
     boolean disableZeroClick();
-    boolean zeroClickEnabled();
+    boolean isZeroClickEnabled();
 }
diff --git a/core/java/android/nfc/NfcAdapter.java b/core/java/android/nfc/NfcAdapter.java
index 4d04027..6a904ae 100644
--- a/core/java/android/nfc/NfcAdapter.java
+++ b/core/java/android/nfc/NfcAdapter.java
@@ -157,23 +157,35 @@
     public static final String EXTRA_ID = "android.nfc.extra.ID";
 
     /**
-     * Broadcast Action: an adapter's state changed between enabled and disabled.
-     *
-     * The new value is stored in the extra EXTRA_NEW_BOOLEAN_STATE and just contains
-     * whether it's enabled or disabled, not including any information about whether it's
-     * actively enabling or disabling.
-     *
+     * Broadcast Action: The state of the local NFC adapter has been
+     * changed.
+     * <p>For example, NFC has been turned on or off.
+     * <p>Always contains the extra field {@link #EXTRA_STATE}
      * @hide
      */
-    public static final String ACTION_ADAPTER_STATE_CHANGE =
-            "android.nfc.action.ADAPTER_STATE_CHANGE";
+    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
+    public static final String ACTION_ADAPTER_STATE_CHANGED =
+            "android.nfc.action.ADAPTER_STATE_CHANGED";
 
     /**
-     * The Intent extra for ACTION_ADAPTER_STATE_CHANGE, saying what the new state is.
-     *
+     * Used as an int extra field in {@link #ACTION_STATE_CHANGED}
+     * intents to request the current power state. Possible values are:
+     * {@link #STATE_OFF},
+     * {@link #STATE_TURNING_ON},
+     * {@link #STATE_ON},
+     * {@link #STATE_TURNING_OFF},
      * @hide
      */
-    public static final String EXTRA_NEW_BOOLEAN_STATE = "android.nfc.isEnabled";
+    public static final String EXTRA_ADAPTER_STATE = "android.nfc.extra.ADAPTER_STATE";
+
+    /** @hide */
+    public static final int STATE_OFF = 1;
+    /** @hide */
+    public static final int STATE_TURNING_ON = 2;
+    /** @hide */
+    public static final int STATE_ON = 3;
+    /** @hide */
+    public static final int STATE_TURNING_OFF = 4;
 
     /**
      * LLCP link status: The LLCP link is activated.
@@ -430,7 +442,7 @@
      */
     public boolean isEnabled() {
         try {
-            return sService.isEnabled();
+            return sService.getState() == STATE_ON;
         } catch (RemoteException e) {
             attemptDeadServiceRecovery(e);
             return false;
@@ -438,10 +450,40 @@
     }
 
     /**
+     * Return the state of this NFC Adapter.
+     *
+     * <p>Returns one of {@link #STATE_ON}, {@link #STATE_TURNING_ON},
+     * {@link #STATE_OFF}, {@link #STATE_TURNING_OFF}.
+     *
+     * <p>{@link #isEnabled()} is equivalent to
+     * <code>{@link #getAdapterState()} == {@link #STATE_ON}</code>
+     *
+     * @return the current state of this NFC adapter
+     *
+     * @hide
+     */
+    public int getAdapterState() {
+        try {
+            return sService.getState();
+        } catch (RemoteException e) {
+            attemptDeadServiceRecovery(e);
+            return NfcAdapter.STATE_OFF;
+        }
+    }
+
+    /**
      * Enable NFC hardware.
-     * <p>
-     * NOTE: may block for ~second or more.  Poor API.  Avoid
-     * calling from the UI thread.
+     *
+     * <p>This call is asynchronous. Listen for
+     * {@link #ACTION_ADAPTER_STATE_CHANGED} broadcasts to find out when the
+     * operation is complete.
+     *
+     * <p>If this returns true, then either NFC is already on, or
+     * a {@link #ACTION_ADAPTER_STATE_CHANGED} broadcast will be sent
+     * to indicate a state transition. If this returns false, then
+     * there is some problem that prevents an attempt to turn
+     * NFC on (for example we are in airplane mode and NFC is not
+     * toggleable in airplane mode on this platform).
      *
      * @hide
      */
@@ -456,11 +498,19 @@
 
     /**
      * Disable NFC hardware.
-     * No NFC features will work after this call, and the hardware
+     *
+     * <p>No NFC features will work after this call, and the hardware
      * will not perform or respond to any NFC communication.
-     * <p>
-     * NOTE: may block for ~second or more.  Poor API.  Avoid
-     * calling from the UI thread.
+     *
+     * <p>This call is asynchronous. Listen for
+     * {@link #ACTION_ADAPTER_STATE_CHANGED} broadcasts to find out when the
+     * operation is complete.
+     *
+     * <p>If this returns true, then either NFC is already off, or
+     * a {@link #ACTION_ADAPTER_STATE_CHANGED} broadcast will be sent
+     * to indicate a state transition. If this returns false, then
+     * there is some problem that prevents an attempt to turn
+     * NFC off.
      *
      * @hide
      */
@@ -712,14 +762,20 @@
     }
 
     /**
-     * Return true if zero-click sharing is enabled.
+     * Return true if zero-click sharing feature is enabled.
+     * <p>This function can return true even if NFC is currently turned-off.
+     * This indicates that zero-click is not currently active, but it has
+     * been requested by the user and will be active as soon as NFC is turned
+     * on.
+     * <p>If you want to check if zero-click sharing is currently active, use
+     * <code>{@link #isEnabled()} && {@link #isZeroClickEnabled()}</code>
      *
      * @return true if zero-click sharing is enabled
      * @hide
      */
-    public boolean zeroClickEnabled() {
+    public boolean isZeroClickEnabled() {
         try {
-            return sService.zeroClickEnabled();
+            return sService.isZeroClickEnabled();
         } catch (RemoteException e) {
             attemptDeadServiceRecovery(e);
             return false;
diff --git a/core/java/android/provider/CallLog.java b/core/java/android/provider/CallLog.java
index b8ef7be..9c6f5c9 100644
--- a/core/java/android/provider/CallLog.java
+++ b/core/java/android/provider/CallLog.java
@@ -193,6 +193,15 @@
         public static final String IS_READ = "is_read";
 
         /**
+         * A geocoded location for the number associated with this call.
+         * <p>
+         * The string represents a city, state, or country associated with the number.
+         * <P>Type: TEXT</P>
+         * @hide
+         */
+        public static final String GEOCODED_LOCATION = "geocoded_location";
+
+        /**
          * Adds a call to the call log.
          *
          * @param ci the CallerInfo object to get the target contact from.  Can be null
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 1ecdfce..f8702b9 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -1169,6 +1169,11 @@
         public static final String RADIO_CELL = "cell";
 
         /**
+         * Constant for use in AIRPLANE_MODE_RADIOS to specify NFC radio.
+         */
+        public static final String RADIO_NFC = "nfc";
+
+        /**
          * A comma separated list of radios that need to be disabled when airplane mode
          * is on. This overrides WIFI_ON and BLUETOOTH_ON, if Wi-Fi and bluetooth are
          * included in the comma separated list.
diff --git a/core/java/android/server/BluetoothBondState.java b/core/java/android/server/BluetoothBondState.java
index 4e2608e..6710aab 100644
--- a/core/java/android/server/BluetoothBondState.java
+++ b/core/java/android/server/BluetoothBondState.java
@@ -134,6 +134,7 @@
     /** reason is ignored unless state == BOND_NOT_BONDED */
     public synchronized void setBondState(String address, int state, int reason) {
         if (DBG) Log.d(TAG, "setBondState " + "address" + " " + state + "reason: " + reason);
+        if (!mService.isEnabled()) return;
 
         int oldState = getBondState(address);
         if (oldState == state) {
diff --git a/core/java/android/server/BluetoothService.java b/core/java/android/server/BluetoothService.java
index 0357958..8047f0c 100755
--- a/core/java/android/server/BluetoothService.java
+++ b/core/java/android/server/BluetoothService.java
@@ -748,18 +748,13 @@
 
     /**
      * @param on true set the local Bluetooth module to be connectable
-     *                but not dicoverable
+     *                The dicoverability is recovered to what it was before
+     *                switchConnectable(false) call
      *           false set the local Bluetooth module to be not connectable
      *                 and not dicoverable
      */
     /*package*/ synchronized void switchConnectable(boolean on) {
-        if (on) {
-            // 0 is a dummy value, does not apply for SCAN_MODE_CONNECTABLE
-            setScanMode(BluetoothAdapter.SCAN_MODE_CONNECTABLE, 0, false);
-        } else {
-            // 0 is a dummy value, does not apply for SCAN_MODE_NONE
-            setScanMode(BluetoothAdapter.SCAN_MODE_NONE, 0, false);
-        }
+        setAdapterPropertyBooleanNative("Powered", on ? 1 : 0);
     }
 
     private synchronized boolean setScanMode(int mode, int duration, boolean allowOnlyInOnState) {
diff --git a/core/java/android/text/TextLine.java b/core/java/android/text/TextLine.java
index c114c37..3e5f32e 100644
--- a/core/java/android/text/TextLine.java
+++ b/core/java/android/text/TextLine.java
@@ -828,7 +828,10 @@
         if (start == measureLimit) {
             TextPaint wp = mWorkPaint;
             wp.set(mPaint);
-            return handleText(wp, 0, 0, 0, 0, runIsRtl, c, x, top, y, bottom, fmi, needWidth);
+            if (fmi != null) {
+                expandMetricsFromPaint(fmi, wp);
+            }
+            return 0f;
         }
 
         // Shaping needs to take into account context up to metric boundaries,
diff --git a/core/java/android/text/style/TextAppearanceSpan.java b/core/java/android/text/style/TextAppearanceSpan.java
index deed713..5fd7c57 100644
--- a/core/java/android/text/style/TextAppearanceSpan.java
+++ b/core/java/android/text/style/TextAppearanceSpan.java
@@ -205,7 +205,7 @@
         }
 
         if (mTextColorLink != null) {
-            ds.linkColor = mTextColor.getColorForState(ds.drawableState, 0);
+            ds.linkColor = mTextColorLink.getColorForState(ds.drawableState, 0);
         }
     }
 
diff --git a/core/java/android/view/TextureView.java b/core/java/android/view/TextureView.java
index 76aa21f..53a6bcb 100644
--- a/core/java/android/view/TextureView.java
+++ b/core/java/android/view/TextureView.java
@@ -73,9 +73,10 @@
  *          // Ignored, Camera does all the work for us
  *      }
  *
- *      public void onSurfaceTextureDestroyed(SurfaceTexture surface) {
+ *      public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
  *          mCamera.stopPreview();
  *          mCamera.release();
+ *          return true;
  *      }
  *
  *      public void onSurfaceTextureUpdated(SurfaceTexture surface) {
@@ -195,8 +196,9 @@
         super.onDetachedFromWindow();
 
         if (mLayer != null) {
+            boolean shouldRelease = true;
             if (mListener != null) {
-                mListener.onSurfaceTextureDestroyed(mSurface);
+                shouldRelease = mListener.onSurfaceTextureDestroyed(mSurface);
             }
 
             synchronized (mNativeWindowLock) {
@@ -204,7 +206,7 @@
             }
 
             mLayer.destroy();
-            mSurface.release();
+            if (shouldRelease) mSurface.release();
             mSurface = null;
             mLayer = null;
         }
@@ -578,12 +580,12 @@
 
         /**
          * Invoked when the specified {@link SurfaceTexture} is about to be destroyed.
-         * After this method is invoked, no rendering should happen inside the surface
-         * texture.
+         * If returns true, no rendering should happen inside the surface texture after this method
+         * is invoked. If returns false, the client needs to call {@link SurfaceTexture#release()}.
          * 
          * @param surface The surface about to be destroyed
          */
-        public void onSurfaceTextureDestroyed(SurfaceTexture surface);
+        public boolean onSurfaceTextureDestroyed(SurfaceTexture surface);
 
         /**
          * Invoked when the specified {@link SurfaceTexture} is updated through
diff --git a/core/java/android/webkit/BrowserFrame.java b/core/java/android/webkit/BrowserFrame.java
index 9fbc4a7..f89d490 100644
--- a/core/java/android/webkit/BrowserFrame.java
+++ b/core/java/android/webkit/BrowserFrame.java
@@ -1129,7 +1129,8 @@
      * synchronous call and unable to pump our MessageQueue.
      */
     private void didReceiveAuthenticationChallenge(
-            final int handle, String host, String realm, final boolean useCachedCredentials) {
+            final int handle, String host, String realm, final boolean useCachedCredentials,
+            final boolean suppressDialog) {
 
         HttpAuthHandler handler = new HttpAuthHandler() {
 
@@ -1147,6 +1148,11 @@
             public void cancel() {
                 nativeAuthenticationCancel(handle);
             }
+
+            @Override
+            public boolean suppressDialog() {
+                return suppressDialog;
+            }
         };
         mCallbackProxy.onReceivedHttpAuthRequest(handler, host, realm);
     }
diff --git a/core/java/android/webkit/HttpAuthHandler.java b/core/java/android/webkit/HttpAuthHandler.java
index 1797eb4..2fbd1d0 100644
--- a/core/java/android/webkit/HttpAuthHandler.java
+++ b/core/java/android/webkit/HttpAuthHandler.java
@@ -50,4 +50,12 @@
      */
     public void proceed(String username, String password) {
     }
+
+    /**
+     * return true if the prompt dialog should be suppressed.
+     * @hide
+     */
+    public boolean suppressDialog() {
+        return false;
+    }
 }
diff --git a/core/java/android/widget/DateTimeView.java b/core/java/android/widget/DateTimeView.java
index 6b845b0..6e6e4af 100644
--- a/core/java/android/widget/DateTimeView.java
+++ b/core/java/android/widget/DateTimeView.java
@@ -78,7 +78,7 @@
 
     @Override
     protected void onAttachedToWindow() {
-        super.onDetachedFromWindow();
+        super.onAttachedToWindow();
         registerReceivers();
         mAttachedToWindow = true;
     }
diff --git a/core/java/android/widget/SearchView.java b/core/java/android/widget/SearchView.java
index 8c288d10..4eecd64 100644
--- a/core/java/android/widget/SearchView.java
+++ b/core/java/android/widget/SearchView.java
@@ -37,6 +37,7 @@
 import android.os.Bundle;
 import android.speech.RecognizerIntent;
 import android.text.Editable;
+import android.text.InputType;
 import android.text.Spannable;
 import android.text.SpannableStringBuilder;
 import android.text.TextUtils;
@@ -49,6 +50,7 @@
 import android.view.KeyEvent;
 import android.view.LayoutInflater;
 import android.view.View;
+import android.view.inputmethod.EditorInfo;
 import android.view.inputmethod.InputMethodManager;
 import android.widget.AdapterView.OnItemClickListener;
 import android.widget.AdapterView.OnItemSelectedListener;
@@ -79,6 +81,8 @@
  *
  * @see android.view.MenuItem#SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW
  * @attr ref android.R.styleable#SearchView_iconifiedByDefault
+ * @attr ref android.R.styleable#SearchView_imeOptions
+ * @attr ref android.R.styleable#SearchView_inputType
  * @attr ref android.R.styleable#SearchView_maxWidth
  * @attr ref android.R.styleable#SearchView_queryHint
  */
@@ -254,8 +258,6 @@
             }
         });
 
-        boolean focusable = true;
-
         TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SearchView, 0, 0);
         setIconifiedByDefault(a.getBoolean(R.styleable.SearchView_iconifiedByDefault, true));
         int maxWidth = a.getDimensionPixelSize(R.styleable.SearchView_maxWidth, -1);
@@ -266,8 +268,19 @@
         if (!TextUtils.isEmpty(queryHint)) {
             setQueryHint(queryHint);
         }
+        int imeOptions = a.getInt(R.styleable.SearchView_imeOptions, -1);
+        if (imeOptions != -1) {
+            setImeOptions(imeOptions);
+        }
+        int inputType = a.getInt(R.styleable.SearchView_inputType, -1);
+        if (inputType != -1) {
+            setInputType(inputType);
+        }
+
         a.recycle();
 
+        boolean focusable = true;
+
         a = context.obtainStyledAttributes(attrs, R.styleable.View, 0, 0);
         focusable = a.getBoolean(R.styleable.View_focusable, focusable);
         a.recycle();
@@ -326,6 +339,30 @@
         mAppSearchData = appSearchData;
     }
 
+    /**
+     * Sets the IME options on the query text field.
+     *
+     * @see TextView#setImeOptions(int)
+     * @param imeOptions the options to set on the query text field
+     *
+     * @attr ref android.R.styleable#SearchView_imeOptions
+     */
+    public void setImeOptions(int imeOptions) {
+        mQueryTextView.setImeOptions(imeOptions);
+    }
+
+    /**
+     * Sets the input type on the query text field.
+     *
+     * @see TextView#setInputType(int)
+     * @param inputType the input type to set on the query text field
+     *
+     * @attr ref android.R.styleable#SearchView_inputType
+     */
+    public void setInputType(int inputType) {
+        mQueryTextView.setInputType(inputType);
+    }
+
     /** @hide */
     @Override
     public boolean requestFocus(int direction, Rect previouslyFocusedRect) {
@@ -918,11 +955,21 @@
      * Updates the auto-complete text view.
      */
     private void updateSearchAutoComplete() {
-        // close any existing suggestions adapter
-        //closeSuggestionsAdapter();
-
         mQueryTextView.setDropDownAnimationStyle(0); // no animation
         mQueryTextView.setThreshold(mSearchable.getSuggestThreshold());
+        mQueryTextView.setImeOptions(mSearchable.getImeOptions());
+        int inputType = mSearchable.getInputType();
+        // We only touch this if the input type is set up for text (which it almost certainly
+        // should be, in the case of search!)
+        if ((inputType & InputType.TYPE_MASK_CLASS) == InputType.TYPE_CLASS_TEXT) {
+            // The existence of a suggestions authority is the proxy for "suggestions
+            // are available here"
+            inputType &= ~InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE;
+            if (mSearchable.getSuggestAuthority() != null) {
+                inputType |= InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE;
+            }
+        }
+        mQueryTextView.setInputType(inputType);
 
         // attach the suggestions adapter, if suggestions are available
         // The existence of a suggestions authority is the proxy for "suggestions available here"
diff --git a/core/java/android/widget/Switch.java b/core/java/android/widget/Switch.java
index 9ac170d..4143383 100644
--- a/core/java/android/widget/Switch.java
+++ b/core/java/android/widget/Switch.java
@@ -489,7 +489,7 @@
             mVelocityTracker.computeCurrentVelocity(1000);
             float xvel = mVelocityTracker.getXVelocity();
             if (Math.abs(xvel) > mMinFlingVelocity) {
-                newState = xvel < 0;
+                newState = xvel > 0;
             } else {
                 newState = getTargetCheckedState();
             }
diff --git a/core/jni/Android.mk b/core/jni/Android.mk
index 6e73889..170957c 100644
--- a/core/jni/Android.mk
+++ b/core/jni/Android.mk
@@ -178,6 +178,7 @@
 	external/icu4c/i18n \
 	external/icu4c/common \
 	external/jpeg \
+	external/harfbuzz/contrib \
 	external/harfbuzz/src \
 	external/zlib \
 	frameworks/opt/emoji \
diff --git a/core/jni/android/graphics/Paint.cpp b/core/jni/android/graphics/Paint.cpp
index 64749e9..98d7fce 100644
--- a/core/jni/android/graphics/Paint.cpp
+++ b/core/jni/android/graphics/Paint.cpp
@@ -325,11 +325,13 @@
         NPE_CHECK_RETURN_ZERO(env, text);
 
         size_t textLength = env->GetArrayLength(text);
-
         if ((index | count) < 0 || (size_t)(index + count) > textLength) {
             doThrowAIOOBE(env);
             return 0;
         }
+        if (count == 0) {
+            return 0;
+        }
 
         SkPaint* paint = GraphicsJNI::getNativePaint(env, jpaint);
         const jchar* textArray = env->GetCharArrayElements(text, NULL);
@@ -350,15 +352,22 @@
         NPE_CHECK_RETURN_ZERO(env, jpaint);
         NPE_CHECK_RETURN_ZERO(env, text);
 
-        SkPaint* paint = GraphicsJNI::getNativePaint(env, jpaint);
-        const jchar* textArray = env->GetStringChars(text, NULL);
-
         int count = end - start;
-        size_t textLength = env->GetStringLength(text);
-        if ((start | count) < 0 || (size_t)count > textLength) {
+        if ((start | count) < 0) {
             doThrowAIOOBE(env);
             return 0;
         }
+        if (count == 0) {
+            return 0;
+        }
+        size_t textLength = env->GetStringLength(text);
+        if ((size_t)count > textLength) {
+            doThrowAIOOBE(env);
+            return 0;
+        }
+
+        const jchar* textArray = env->GetStringChars(text, NULL);
+        SkPaint* paint = GraphicsJNI::getNativePaint(env, jpaint);
         jfloat width = 0;
 
 #if RTL_USE_HARFBUZZ
@@ -376,10 +385,15 @@
         NPE_CHECK_RETURN_ZERO(env, jpaint);
         NPE_CHECK_RETURN_ZERO(env, text);
 
-        SkPaint* paint = GraphicsJNI::getNativePaint(env, jpaint);
-        const jchar* textArray = env->GetStringChars(text, NULL);
         size_t textLength = env->GetStringLength(text);
+        if (textLength == 0) {
+            return 0;
+        }
+
+        const jchar* textArray = env->GetStringChars(text, NULL);
+        SkPaint* paint = GraphicsJNI::getNativePaint(env, jpaint);
         jfloat width = 0;
+
 #if RTL_USE_HARFBUZZ
         TextLayout::getTextRunAdvances(paint, textArray, 0, textLength, textLength,
                 paint->getFlags(), NULL /* dont need all advances */, width);
@@ -391,8 +405,25 @@
     }
 
     static int dotextwidths(JNIEnv* env, SkPaint* paint, const jchar text[], int count, jfloatArray widths) {
+        NPE_CHECK_RETURN_ZERO(env, paint);
+        NPE_CHECK_RETURN_ZERO(env, text);
+
+        if (count < 0 || !widths) {
+            doThrowAIOOBE(env);
+            return 0;
+        }
+        if (count == 0) {
+            return 0;
+        }
+        size_t widthsLength = env->GetArrayLength(widths);
+        if ((size_t)count > widthsLength) {
+            doThrowAIOOBE(env);
+            return 0;
+        }
+
         AutoJavaFloatArray autoWidths(env, widths, count);
         jfloat* widthsArray = autoWidths.ptr();
+
 #if RTL_USE_HARFBUZZ
         jfloat totalAdvance;
 
@@ -427,6 +458,22 @@
 
     static int doTextGlyphs(JNIEnv* env, SkPaint* paint, const jchar* text, jint start, jint count,
             jint contextCount, jint flags, jcharArray glyphs) {
+        NPE_CHECK_RETURN_ZERO(env, paint);
+        NPE_CHECK_RETURN_ZERO(env, text);
+
+        if ((start | count | contextCount) < 0 || contextCount < count || !glyphs) {
+            doThrowAIOOBE(env);
+            return 0;
+        }
+        if (count == 0) {
+            return 0;
+        }
+        size_t glypthsLength = env->GetArrayLength(glyphs);
+        if ((size_t)count > glypthsLength) {
+            doThrowAIOOBE(env);
+            return 0;
+        }
+
         jchar* glyphsArray = env->GetCharArrayElements(glyphs, NULL);
         HB_ShaperItem shaperItem;
         HB_FontRec font;
@@ -455,8 +502,25 @@
     static jfloat doTextRunAdvances(JNIEnv *env, SkPaint *paint, const jchar *text,
                                     jint start, jint count, jint contextCount, jint flags,
                                     jfloatArray advances, jint advancesIndex) {
+        NPE_CHECK_RETURN_ZERO(env, paint);
+        NPE_CHECK_RETURN_ZERO(env, text);
+
+        if ((start | count | contextCount | advancesIndex) < 0 || contextCount < count) {
+            doThrowAIOOBE(env);
+            return 0;
+        }
+        if (count == 0) {
+            return 0;
+        }
+        if (advances) {
+            size_t advancesLength = env->GetArrayLength(advances);
+            if ((size_t)count > advancesLength) {
+                doThrowAIOOBE(env);
+                return 0;
+            }
+        }
         jfloat advancesArray[count];
-        jfloat totalAdvance;
+        jfloat totalAdvance = 0;
 
         TextLayout::getTextRunAdvances(paint, text, start, count, contextCount, flags,
                                        advancesArray, totalAdvance);
@@ -470,8 +534,26 @@
     static jfloat doTextRunAdvancesICU(JNIEnv *env, SkPaint *paint, const jchar *text,
                                     jint start, jint count, jint contextCount, jint flags,
                                     jfloatArray advances, jint advancesIndex) {
+        NPE_CHECK_RETURN_ZERO(env, paint);
+        NPE_CHECK_RETURN_ZERO(env, text);
+
+        if ((start | count | contextCount | advancesIndex) < 0 || contextCount < count) {
+            doThrowAIOOBE(env);
+            return 0;
+        }
+        if (count == 0) {
+            return 0;
+        }
+        if (advances) {
+            size_t advancesLength = env->GetArrayLength(advances);
+            if ((size_t)count > advancesLength) {
+                doThrowAIOOBE(env);
+                return 0;
+            }
+        }
+
         jfloat advancesArray[count];
-        jfloat totalAdvance;
+        jfloat totalAdvance = 0;
 
         TextLayout::getTextRunAdvancesICU(paint, text, start, count, contextCount, flags,
                                        advancesArray, totalAdvance);
@@ -512,7 +594,7 @@
             jint count, jint flags, jint offset, jint opt) {
 #if RTL_USE_HARFBUZZ
         jfloat scalarArray[count];
-        jfloat totalAdvance;
+        jfloat totalAdvance = 0;
 
         TextLayout::getTextRunAdvances(paint, text, start, count, count, flags,
                 scalarArray, totalAdvance);
diff --git a/core/jni/android/graphics/TextLayoutCache.cpp b/core/jni/android/graphics/TextLayoutCache.cpp
index 30fe298..23a4ec7 100644
--- a/core/jni/android/graphics/TextLayoutCache.cpp
+++ b/core/jni/android/graphics/TextLayoutCache.cpp
@@ -17,6 +17,10 @@
 #include "TextLayoutCache.h"
 #include "TextLayout.h"
 
+extern "C" {
+  #include "harfbuzz-unicode.h"
+}
+
 namespace android {
 
 TextLayoutCache::TextLayoutCache() :
@@ -355,7 +359,32 @@
     shaperItem->item.pos = start;
     shaperItem->item.length = count;
     shaperItem->item.bidiLevel = isRTL;
-    shaperItem->item.script = isRTL ? HB_Script_Arabic : HB_Script_Common;
+
+    ssize_t nextCodePoint = 0;
+    uint32_t codePoint = utf16_to_code_point(chars, count, &nextCodePoint);
+
+    HB_Script script = code_point_to_script(codePoint);
+
+    if (script == HB_Script_Inherited) {
+#if DEBUG_GLYPHS
+        LOGD("Cannot find a correct script for code point=%d "
+                " Need to look at the next code points.", codePoint);
+#endif
+        while (script == HB_Script_Inherited && nextCodePoint < count) {
+            codePoint = utf16_to_code_point(chars, count, &nextCodePoint);
+            script = code_point_to_script(codePoint);
+        }
+    }
+
+    if (script == HB_Script_Inherited) {
+#if DEBUG_GLYPHS
+        LOGD("Cannot find a correct script from the text."
+                " Need to select a default script depending on the passed text direction.");
+#endif
+        script = isRTL ? HB_Script_Arabic : HB_Script_Common;
+    }
+
+    shaperItem->item.script = script;
 
     shaperItem->string = chars;
     shaperItem->stringLength = contextCount;
diff --git a/core/jni/android_server_BluetoothEventLoop.cpp b/core/jni/android_server_BluetoothEventLoop.cpp
index 8f84b81..45b7f27 100644
--- a/core/jni/android_server_BluetoothEventLoop.cpp
+++ b/core/jni/android_server_BluetoothEventLoop.cpp
@@ -229,6 +229,13 @@
         DBusError err;
         dbus_error_init(&err);
 
+        const char *agent_path = "/android/bluetooth/agent";
+        const char *capabilities = "DisplayYesNo";
+        if (register_agent(nat, agent_path, capabilities) < 0) {
+            dbus_connection_unregister_object_path (nat->conn, agent_path);
+            return JNI_FALSE;
+        }
+
         // Add a filter for all incoming messages
         if (!dbus_connection_add_filter(nat->conn, event_filter, nat, NULL)){
             return JNI_FALSE;
@@ -294,12 +301,6 @@
             return JNI_FALSE;
         }
 
-        const char *agent_path = "/android/bluetooth/agent";
-        const char *capabilities = "DisplayYesNo";
-        if (register_agent(nat, agent_path, capabilities) < 0) {
-            dbus_connection_unregister_object_path (nat->conn, agent_path);
-            return JNI_FALSE;
-        }
         return JNI_TRUE;
     }
     return JNI_FALSE;
diff --git a/core/res/res/drawable-hdpi/btn_default_disabled_focused_holo_dark.9.png b/core/res/res/drawable-hdpi/btn_default_disabled_focused_holo_dark.9.png
index 3239dd2..f57126b 100644
--- a/core/res/res/drawable-hdpi/btn_default_disabled_focused_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/btn_default_disabled_focused_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_default_disabled_focused_holo_light.9.png b/core/res/res/drawable-hdpi/btn_default_disabled_focused_holo_light.9.png
index 3239dd2..f57126b 100644
--- a/core/res/res/drawable-hdpi/btn_default_disabled_focused_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/btn_default_disabled_focused_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_default_disabled_holo.9.png b/core/res/res/drawable-hdpi/btn_default_disabled_holo.9.png
index 6840962..1b65492 100644
--- a/core/res/res/drawable-hdpi/btn_default_disabled_holo.9.png
+++ b/core/res/res/drawable-hdpi/btn_default_disabled_holo.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_default_disabled_holo_dark.9.png b/core/res/res/drawable-hdpi/btn_default_disabled_holo_dark.9.png
index 45c957b..05cb4e4 100644
--- a/core/res/res/drawable-hdpi/btn_default_disabled_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/btn_default_disabled_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_default_disabled_holo_light.9.png b/core/res/res/drawable-hdpi/btn_default_disabled_holo_light.9.png
index 45c957b..05cb4e4 100644
--- a/core/res/res/drawable-hdpi/btn_default_disabled_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/btn_default_disabled_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_default_focused_holo.9.png b/core/res/res/drawable-hdpi/btn_default_focused_holo.9.png
index 6549253..70c1e262 100644
--- a/core/res/res/drawable-hdpi/btn_default_focused_holo.9.png
+++ b/core/res/res/drawable-hdpi/btn_default_focused_holo.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_default_focused_holo_dark.9.png b/core/res/res/drawable-hdpi/btn_default_focused_holo_dark.9.png
index ef3ec7a..3b9d734 100644
--- a/core/res/res/drawable-hdpi/btn_default_focused_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/btn_default_focused_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_default_focused_holo_light.9.png b/core/res/res/drawable-hdpi/btn_default_focused_holo_light.9.png
index ef3ec7a..3b9d734 100644
--- a/core/res/res/drawable-hdpi/btn_default_focused_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/btn_default_focused_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_default_normal_holo.9.png b/core/res/res/drawable-hdpi/btn_default_normal_holo.9.png
index f4f657b..9fa19ef 100644
--- a/core/res/res/drawable-hdpi/btn_default_normal_holo.9.png
+++ b/core/res/res/drawable-hdpi/btn_default_normal_holo.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_default_normal_holo_dark.9.png b/core/res/res/drawable-hdpi/btn_default_normal_holo_dark.9.png
index ef12e72..b2851834 100644
--- a/core/res/res/drawable-hdpi/btn_default_normal_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/btn_default_normal_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_default_normal_holo_light.9.png b/core/res/res/drawable-hdpi/btn_default_normal_holo_light.9.png
index ef12e72..b2851834 100644
--- a/core/res/res/drawable-hdpi/btn_default_normal_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/btn_default_normal_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_default_pressed_holo.9.png b/core/res/res/drawable-hdpi/btn_default_pressed_holo.9.png
index ec7fa78..8384797 100644
--- a/core/res/res/drawable-hdpi/btn_default_pressed_holo.9.png
+++ b/core/res/res/drawable-hdpi/btn_default_pressed_holo.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_default_pressed_holo_dark.9.png b/core/res/res/drawable-hdpi/btn_default_pressed_holo_dark.9.png
index 93a30e3..13d154f 100644
--- a/core/res/res/drawable-hdpi/btn_default_pressed_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/btn_default_pressed_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_default_pressed_holo_light.9.png b/core/res/res/drawable-hdpi/btn_default_pressed_holo_light.9.png
index 93a30e3..13d154f 100644
--- a/core/res/res/drawable-hdpi/btn_default_pressed_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/btn_default_pressed_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_toggle_off_disabled_focused_holo_dark.9.png b/core/res/res/drawable-hdpi/btn_toggle_off_disabled_focused_holo_dark.9.png
index 3ecf008..15b9fb9 100644
--- a/core/res/res/drawable-hdpi/btn_toggle_off_disabled_focused_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/btn_toggle_off_disabled_focused_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_toggle_off_disabled_focused_holo_light.9.png b/core/res/res/drawable-hdpi/btn_toggle_off_disabled_focused_holo_light.9.png
index 6e1f0dd..4d83d65 100644
--- a/core/res/res/drawable-hdpi/btn_toggle_off_disabled_focused_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/btn_toggle_off_disabled_focused_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_toggle_off_disabled_holo_dark.9.png b/core/res/res/drawable-hdpi/btn_toggle_off_disabled_holo_dark.9.png
index 90b35b8..e06aef0 100644
--- a/core/res/res/drawable-hdpi/btn_toggle_off_disabled_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/btn_toggle_off_disabled_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_toggle_off_disabled_holo_light.9.png b/core/res/res/drawable-hdpi/btn_toggle_off_disabled_holo_light.9.png
index 6b4b388..d81d346 100644
--- a/core/res/res/drawable-hdpi/btn_toggle_off_disabled_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/btn_toggle_off_disabled_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_toggle_off_focused_holo_dark.9.png b/core/res/res/drawable-hdpi/btn_toggle_off_focused_holo_dark.9.png
index c0ed2c6..9f027b7 100644
--- a/core/res/res/drawable-hdpi/btn_toggle_off_focused_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/btn_toggle_off_focused_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_toggle_off_focused_holo_light.9.png b/core/res/res/drawable-hdpi/btn_toggle_off_focused_holo_light.9.png
index fa386b8..a7582d6 100644
--- a/core/res/res/drawable-hdpi/btn_toggle_off_focused_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/btn_toggle_off_focused_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_toggle_off_holo.9.png b/core/res/res/drawable-hdpi/btn_toggle_off_holo.9.png
deleted file mode 100755
index f903bdb..0000000
--- a/core/res/res/drawable-hdpi/btn_toggle_off_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_toggle_off_normal_holo_dark.9.png b/core/res/res/drawable-hdpi/btn_toggle_off_normal_holo_dark.9.png
index 9fbd1e99..21be9f4 100644
--- a/core/res/res/drawable-hdpi/btn_toggle_off_normal_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/btn_toggle_off_normal_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_toggle_off_normal_holo_light.9.png b/core/res/res/drawable-hdpi/btn_toggle_off_normal_holo_light.9.png
index 1800eb4..791b318 100644
--- a/core/res/res/drawable-hdpi/btn_toggle_off_normal_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/btn_toggle_off_normal_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_toggle_off_pressed_holo_dark.9.png b/core/res/res/drawable-hdpi/btn_toggle_off_pressed_holo_dark.9.png
index 45d99ee..8cf35b2 100644
--- a/core/res/res/drawable-hdpi/btn_toggle_off_pressed_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/btn_toggle_off_pressed_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_toggle_off_pressed_holo_light.9.png b/core/res/res/drawable-hdpi/btn_toggle_off_pressed_holo_light.9.png
index 8929825..e475b49 100644
--- a/core/res/res/drawable-hdpi/btn_toggle_off_pressed_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/btn_toggle_off_pressed_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_toggle_on_disabled_focused_holo_dark.9.png b/core/res/res/drawable-hdpi/btn_toggle_on_disabled_focused_holo_dark.9.png
index 5fc3fbd..7996db4 100644
--- a/core/res/res/drawable-hdpi/btn_toggle_on_disabled_focused_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/btn_toggle_on_disabled_focused_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_toggle_on_disabled_focused_holo_light.9.png b/core/res/res/drawable-hdpi/btn_toggle_on_disabled_focused_holo_light.9.png
index 5fc3fbd..7996db4 100644
--- a/core/res/res/drawable-hdpi/btn_toggle_on_disabled_focused_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/btn_toggle_on_disabled_focused_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_toggle_on_disabled_holo_dark.9.png b/core/res/res/drawable-hdpi/btn_toggle_on_disabled_holo_dark.9.png
index b0cfa4b..906a229 100644
--- a/core/res/res/drawable-hdpi/btn_toggle_on_disabled_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/btn_toggle_on_disabled_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_toggle_on_disabled_holo_light.9.png b/core/res/res/drawable-hdpi/btn_toggle_on_disabled_holo_light.9.png
index b0cfa4b..906a229 100644
--- a/core/res/res/drawable-hdpi/btn_toggle_on_disabled_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/btn_toggle_on_disabled_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_toggle_on_focused_holo_dark.9.png b/core/res/res/drawable-hdpi/btn_toggle_on_focused_holo_dark.9.png
index 054c18b..56bd325 100644
--- a/core/res/res/drawable-hdpi/btn_toggle_on_focused_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/btn_toggle_on_focused_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_toggle_on_focused_holo_light.9.png b/core/res/res/drawable-hdpi/btn_toggle_on_focused_holo_light.9.png
index 054c18b..56bd325 100644
--- a/core/res/res/drawable-hdpi/btn_toggle_on_focused_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/btn_toggle_on_focused_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_toggle_on_normal_holo_dark.9.png b/core/res/res/drawable-hdpi/btn_toggle_on_normal_holo_dark.9.png
index a858836..61b2efc 100644
--- a/core/res/res/drawable-hdpi/btn_toggle_on_normal_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/btn_toggle_on_normal_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_toggle_on_normal_holo_light.9.png b/core/res/res/drawable-hdpi/btn_toggle_on_normal_holo_light.9.png
index a858836..61b2efc 100644
--- a/core/res/res/drawable-hdpi/btn_toggle_on_normal_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/btn_toggle_on_normal_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_toggle_on_pressed_holo_dark.9.png b/core/res/res/drawable-hdpi/btn_toggle_on_pressed_holo_dark.9.png
index b5aa5c1..d2e4ca8 100644
--- a/core/res/res/drawable-hdpi/btn_toggle_on_pressed_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/btn_toggle_on_pressed_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_toggle_on_pressed_holo_light.9.png b/core/res/res/drawable-hdpi/btn_toggle_on_pressed_holo_light.9.png
index b5aa5c1..d2e4ca8 100644
--- a/core/res/res/drawable-hdpi/btn_toggle_on_pressed_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/btn_toggle_on_pressed_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/dialog_bottom_holo_dark.9.png b/core/res/res/drawable-hdpi/dialog_bottom_holo_dark.9.png
index acbbb38..256067d 100644
--- a/core/res/res/drawable-hdpi/dialog_bottom_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/dialog_bottom_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/dialog_bottom_holo_light.9.png b/core/res/res/drawable-hdpi/dialog_bottom_holo_light.9.png
index 6009528..2338175 100644
--- a/core/res/res/drawable-hdpi/dialog_bottom_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/dialog_bottom_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/dialog_full_holo_dark.9.png b/core/res/res/drawable-hdpi/dialog_full_holo_dark.9.png
index 30727d7..79e56f5 100644
--- a/core/res/res/drawable-hdpi/dialog_full_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/dialog_full_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/dialog_full_holo_light.9.png b/core/res/res/drawable-hdpi/dialog_full_holo_light.9.png
index 7cea5e1..e029f21 100644
--- a/core/res/res/drawable-hdpi/dialog_full_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/dialog_full_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/dialog_middle_holo_dark.9.png b/core/res/res/drawable-hdpi/dialog_middle_holo_dark.9.png
index ba0d612..8ee0072 100644
--- a/core/res/res/drawable-hdpi/dialog_middle_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/dialog_middle_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/dialog_middle_holo_light.9.png b/core/res/res/drawable-hdpi/dialog_middle_holo_light.9.png
index e8646b9..df030c1 100644
--- a/core/res/res/drawable-hdpi/dialog_middle_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/dialog_middle_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/dialog_top_holo_dark.9.png b/core/res/res/drawable-hdpi/dialog_top_holo_dark.9.png
index 14cb4c9..50534a1 100644
--- a/core/res/res/drawable-hdpi/dialog_top_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/dialog_top_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/dialog_top_holo_light.9.png b/core/res/res/drawable-hdpi/dialog_top_holo_light.9.png
index 80fd218..0b84155 100644
--- a/core/res/res/drawable-hdpi/dialog_top_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/dialog_top_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/menu_dropdown_panel_holo_dark.9.png b/core/res/res/drawable-hdpi/menu_dropdown_panel_holo_dark.9.png
index 1014d8a..4d3d208 100644
--- a/core/res/res/drawable-hdpi/menu_dropdown_panel_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/menu_dropdown_panel_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/menu_dropdown_panel_holo_light.9.png b/core/res/res/drawable-hdpi/menu_dropdown_panel_holo_light.9.png
index 18cd171..924a99d 100644
--- a/core/res/res/drawable-hdpi/menu_dropdown_panel_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/menu_dropdown_panel_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/spinner_ab_activated_holo_dark.9.png b/core/res/res/drawable-hdpi/spinner_ab_activated_holo_dark.9.png
deleted file mode 100644
index d471c30..0000000
--- a/core/res/res/drawable-hdpi/spinner_ab_activated_holo_dark.9.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-hdpi/spinner_ab_activated_holo_light.9.png b/core/res/res/drawable-hdpi/spinner_ab_activated_holo_light.9.png
deleted file mode 100644
index d471c30..0000000
--- a/core/res/res/drawable-hdpi/spinner_ab_activated_holo_light.9.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-hdpi/spinner_ab_default_holo_dark.9.png b/core/res/res/drawable-hdpi/spinner_ab_default_holo_dark.9.png
index 001cfbb..15a7aa1 100644
--- a/core/res/res/drawable-hdpi/spinner_ab_default_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/spinner_ab_default_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/spinner_ab_default_holo_light.9.png b/core/res/res/drawable-hdpi/spinner_ab_default_holo_light.9.png
index 5e278c8..a0f7e3e 100644
--- a/core/res/res/drawable-hdpi/spinner_ab_default_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/spinner_ab_default_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/spinner_ab_disabled_holo_dark.9.png b/core/res/res/drawable-hdpi/spinner_ab_disabled_holo_dark.9.png
index cf2e149..03f0254 100644
--- a/core/res/res/drawable-hdpi/spinner_ab_disabled_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/spinner_ab_disabled_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/spinner_ab_disabled_holo_light.9.png b/core/res/res/drawable-hdpi/spinner_ab_disabled_holo_light.9.png
index 63f212d..54c4f17 100644
--- a/core/res/res/drawable-hdpi/spinner_ab_disabled_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/spinner_ab_disabled_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/spinner_ab_focused_holo_dark.9.png b/core/res/res/drawable-hdpi/spinner_ab_focused_holo_dark.9.png
index 85663e6..7f062fe 100644
--- a/core/res/res/drawable-hdpi/spinner_ab_focused_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/spinner_ab_focused_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/spinner_ab_focused_holo_light.9.png b/core/res/res/drawable-hdpi/spinner_ab_focused_holo_light.9.png
index 85663e6..7f062fe 100644
--- a/core/res/res/drawable-hdpi/spinner_ab_focused_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/spinner_ab_focused_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/spinner_ab_pressed_holo_dark.9.png b/core/res/res/drawable-hdpi/spinner_ab_pressed_holo_dark.9.png
index afddbe8..5b0958b 100644
--- a/core/res/res/drawable-hdpi/spinner_ab_pressed_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/spinner_ab_pressed_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/spinner_ab_pressed_holo_light.9.png b/core/res/res/drawable-hdpi/spinner_ab_pressed_holo_light.9.png
index 0ad6476..6d34b40 100644
--- a/core/res/res/drawable-hdpi/spinner_ab_pressed_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/spinner_ab_pressed_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/textfield_activated_holo_dark.9.png b/core/res/res/drawable-hdpi/textfield_activated_holo_dark.9.png
index 8bb4048..d9ac6ad 100644
--- a/core/res/res/drawable-hdpi/textfield_activated_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/textfield_activated_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/textfield_activated_holo_light.9.png b/core/res/res/drawable-hdpi/textfield_activated_holo_light.9.png
index fdd3ee7..d9ac6ad 100644
--- a/core/res/res/drawable-hdpi/textfield_activated_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/textfield_activated_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/textfield_default_holo_dark.9.png b/core/res/res/drawable-hdpi/textfield_default_holo_dark.9.png
index ab6abdc..503607e 100644
--- a/core/res/res/drawable-hdpi/textfield_default_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/textfield_default_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/textfield_default_holo_light.9.png b/core/res/res/drawable-hdpi/textfield_default_holo_light.9.png
index dbdfc79..bfc378b 100644
--- a/core/res/res/drawable-hdpi/textfield_default_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/textfield_default_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/textfield_disabled_focused_holo_dark.9.png b/core/res/res/drawable-hdpi/textfield_disabled_focused_holo_dark.9.png
index 4eba040..ddc4f7d 100644
--- a/core/res/res/drawable-hdpi/textfield_disabled_focused_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/textfield_disabled_focused_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/textfield_disabled_focused_holo_light.9.png b/core/res/res/drawable-hdpi/textfield_disabled_focused_holo_light.9.png
index b186730..e2540570 100644
--- a/core/res/res/drawable-hdpi/textfield_disabled_focused_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/textfield_disabled_focused_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/textfield_disabled_holo_dark.9.png b/core/res/res/drawable-hdpi/textfield_disabled_holo_dark.9.png
index 06190a1..374c576 100644
--- a/core/res/res/drawable-hdpi/textfield_disabled_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/textfield_disabled_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/textfield_disabled_holo_light.9.png b/core/res/res/drawable-hdpi/textfield_disabled_holo_light.9.png
index 8c16566..ebaaa14 100644
--- a/core/res/res/drawable-hdpi/textfield_disabled_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/textfield_disabled_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/textfield_multiline_activated_holo_dark.9.png b/core/res/res/drawable-hdpi/textfield_multiline_activated_holo_dark.9.png
index 33e6dc8..d9ac6ad 100644
--- a/core/res/res/drawable-hdpi/textfield_multiline_activated_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/textfield_multiline_activated_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/textfield_multiline_activated_holo_light.9.png b/core/res/res/drawable-hdpi/textfield_multiline_activated_holo_light.9.png
index eb0d90f..d9ac6ad 100644
--- a/core/res/res/drawable-hdpi/textfield_multiline_activated_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/textfield_multiline_activated_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/textfield_multiline_default_holo_dark.9.png b/core/res/res/drawable-hdpi/textfield_multiline_default_holo_dark.9.png
index 74c02c2..503607e 100644
--- a/core/res/res/drawable-hdpi/textfield_multiline_default_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/textfield_multiline_default_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/textfield_multiline_default_holo_light.9.png b/core/res/res/drawable-hdpi/textfield_multiline_default_holo_light.9.png
index 345f4f5..bfc378b 100644
--- a/core/res/res/drawable-hdpi/textfield_multiline_default_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/textfield_multiline_default_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/textfield_multiline_disabled_focused_holo_dark.9.png b/core/res/res/drawable-hdpi/textfield_multiline_disabled_focused_holo_dark.9.png
index 40e5db3..ddc4f7d 100644
--- a/core/res/res/drawable-hdpi/textfield_multiline_disabled_focused_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/textfield_multiline_disabled_focused_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/textfield_multiline_disabled_focused_holo_light.9.png b/core/res/res/drawable-hdpi/textfield_multiline_disabled_focused_holo_light.9.png
index 0cbf6d2..e2540570 100644
--- a/core/res/res/drawable-hdpi/textfield_multiline_disabled_focused_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/textfield_multiline_disabled_focused_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/textfield_multiline_disabled_holo_dark.9.png b/core/res/res/drawable-hdpi/textfield_multiline_disabled_holo_dark.9.png
index bc56916..374c576 100644
--- a/core/res/res/drawable-hdpi/textfield_multiline_disabled_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/textfield_multiline_disabled_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/textfield_multiline_disabled_holo_light.9.png b/core/res/res/drawable-hdpi/textfield_multiline_disabled_holo_light.9.png
index 84adf68..ebaaa14 100644
--- a/core/res/res/drawable-hdpi/textfield_multiline_disabled_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/textfield_multiline_disabled_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/textfield_multiline_focused_holo_dark.9.png b/core/res/res/drawable-hdpi/textfield_multiline_focused_holo_dark.9.png
index 4a98e57..78cbf0b 100644
--- a/core/res/res/drawable-hdpi/textfield_multiline_focused_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/textfield_multiline_focused_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/textfield_multiline_focused_holo_light.9.png b/core/res/res/drawable-hdpi/textfield_multiline_focused_holo_light.9.png
index 5cf6bf3..78cbf0b 100644
--- a/core/res/res/drawable-hdpi/textfield_multiline_focused_holo_light.9.png
+++ b/core/res/res/drawable-hdpi/textfield_multiline_focused_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/toast_frame_holo.9.png b/core/res/res/drawable-hdpi/toast_frame_holo.9.png
index ad2cb5a..f8f75db 100644
--- a/core/res/res/drawable-hdpi/toast_frame_holo.9.png
+++ b/core/res/res/drawable-hdpi/toast_frame_holo.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_default_disabled_focused_holo_dark.9.png b/core/res/res/drawable-mdpi/btn_default_disabled_focused_holo_dark.9.png
index e5197e6..74ed9b5 100644
--- a/core/res/res/drawable-mdpi/btn_default_disabled_focused_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/btn_default_disabled_focused_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_default_disabled_focused_holo_light.9.png b/core/res/res/drawable-mdpi/btn_default_disabled_focused_holo_light.9.png
index e5197e6..74ed9b5 100644
--- a/core/res/res/drawable-mdpi/btn_default_disabled_focused_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/btn_default_disabled_focused_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_default_disabled_holo.9.png b/core/res/res/drawable-mdpi/btn_default_disabled_holo.9.png
index 9a24b9c..86debc4 100644
--- a/core/res/res/drawable-mdpi/btn_default_disabled_holo.9.png
+++ b/core/res/res/drawable-mdpi/btn_default_disabled_holo.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_default_disabled_holo_dark.9.png b/core/res/res/drawable-mdpi/btn_default_disabled_holo_dark.9.png
index c832855..3b5d850 100644
--- a/core/res/res/drawable-mdpi/btn_default_disabled_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/btn_default_disabled_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_default_disabled_holo_light.9.png b/core/res/res/drawable-mdpi/btn_default_disabled_holo_light.9.png
index c832855..3b5d850 100644
--- a/core/res/res/drawable-mdpi/btn_default_disabled_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/btn_default_disabled_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_default_focused_holo.9.png b/core/res/res/drawable-mdpi/btn_default_focused_holo.9.png
index 8838414..b403e67 100644
--- a/core/res/res/drawable-mdpi/btn_default_focused_holo.9.png
+++ b/core/res/res/drawable-mdpi/btn_default_focused_holo.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_default_focused_holo_dark.9.png b/core/res/res/drawable-mdpi/btn_default_focused_holo_dark.9.png
index e0a1e0d..215002b 100644
--- a/core/res/res/drawable-mdpi/btn_default_focused_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/btn_default_focused_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_default_focused_holo_light.9.png b/core/res/res/drawable-mdpi/btn_default_focused_holo_light.9.png
index e0a1e0d..215002b 100644
--- a/core/res/res/drawable-mdpi/btn_default_focused_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/btn_default_focused_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_default_normal_holo.9.png b/core/res/res/drawable-mdpi/btn_default_normal_holo.9.png
index e4864c9..d06361a 100644
--- a/core/res/res/drawable-mdpi/btn_default_normal_holo.9.png
+++ b/core/res/res/drawable-mdpi/btn_default_normal_holo.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_default_normal_holo_dark.9.png b/core/res/res/drawable-mdpi/btn_default_normal_holo_dark.9.png
index 3d9310a..dd8ee9d 100644
--- a/core/res/res/drawable-mdpi/btn_default_normal_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/btn_default_normal_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_default_normal_holo_light.9.png b/core/res/res/drawable-mdpi/btn_default_normal_holo_light.9.png
index 3d9310a..dd8ee9d 100644
--- a/core/res/res/drawable-mdpi/btn_default_normal_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/btn_default_normal_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_default_pressed_holo.9.png b/core/res/res/drawable-mdpi/btn_default_pressed_holo.9.png
index 18ec722..a4dae66 100644
--- a/core/res/res/drawable-mdpi/btn_default_pressed_holo.9.png
+++ b/core/res/res/drawable-mdpi/btn_default_pressed_holo.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_default_pressed_holo_dark.9.png b/core/res/res/drawable-mdpi/btn_default_pressed_holo_dark.9.png
index 1e3314e..2ca4c3b 100644
--- a/core/res/res/drawable-mdpi/btn_default_pressed_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/btn_default_pressed_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_default_pressed_holo_light.9.png b/core/res/res/drawable-mdpi/btn_default_pressed_holo_light.9.png
index 1e3314e..2ca4c3b 100644
--- a/core/res/res/drawable-mdpi/btn_default_pressed_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/btn_default_pressed_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_toggle_off_disabled_focused_holo_dark.9.png b/core/res/res/drawable-mdpi/btn_toggle_off_disabled_focused_holo_dark.9.png
index 5f2017d..0fa2859 100644
--- a/core/res/res/drawable-mdpi/btn_toggle_off_disabled_focused_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/btn_toggle_off_disabled_focused_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_toggle_off_disabled_focused_holo_light.9.png b/core/res/res/drawable-mdpi/btn_toggle_off_disabled_focused_holo_light.9.png
index eab31e8..bdc0330 100644
--- a/core/res/res/drawable-mdpi/btn_toggle_off_disabled_focused_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/btn_toggle_off_disabled_focused_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_toggle_off_disabled_holo_dark.9.png b/core/res/res/drawable-mdpi/btn_toggle_off_disabled_holo_dark.9.png
index 29f9e23..35aca07 100644
--- a/core/res/res/drawable-mdpi/btn_toggle_off_disabled_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/btn_toggle_off_disabled_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_toggle_off_disabled_holo_light.9.png b/core/res/res/drawable-mdpi/btn_toggle_off_disabled_holo_light.9.png
index 2d3574d..3a07479 100644
--- a/core/res/res/drawable-mdpi/btn_toggle_off_disabled_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/btn_toggle_off_disabled_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_toggle_off_focused_holo_dark.9.png b/core/res/res/drawable-mdpi/btn_toggle_off_focused_holo_dark.9.png
index deea02d..5755584 100644
--- a/core/res/res/drawable-mdpi/btn_toggle_off_focused_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/btn_toggle_off_focused_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_toggle_off_focused_holo_light.9.png b/core/res/res/drawable-mdpi/btn_toggle_off_focused_holo_light.9.png
index d480b2e..b0af68f 100644
--- a/core/res/res/drawable-mdpi/btn_toggle_off_focused_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/btn_toggle_off_focused_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_toggle_off_holo.9.png b/core/res/res/drawable-mdpi/btn_toggle_off_holo.9.png
deleted file mode 100755
index 0ca659e..0000000
--- a/core/res/res/drawable-mdpi/btn_toggle_off_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_toggle_off_normal_holo_dark.9.png b/core/res/res/drawable-mdpi/btn_toggle_off_normal_holo_dark.9.png
index 7f9d813..7c725b2 100644
--- a/core/res/res/drawable-mdpi/btn_toggle_off_normal_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/btn_toggle_off_normal_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_toggle_off_normal_holo_light.9.png b/core/res/res/drawable-mdpi/btn_toggle_off_normal_holo_light.9.png
index 848621a..93696aa 100644
--- a/core/res/res/drawable-mdpi/btn_toggle_off_normal_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/btn_toggle_off_normal_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_toggle_off_pressed_holo_dark.9.png b/core/res/res/drawable-mdpi/btn_toggle_off_pressed_holo_dark.9.png
index 2a94003..6dc4f1e 100644
--- a/core/res/res/drawable-mdpi/btn_toggle_off_pressed_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/btn_toggle_off_pressed_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_toggle_off_pressed_holo_light.9.png b/core/res/res/drawable-mdpi/btn_toggle_off_pressed_holo_light.9.png
index 75983d8..3a7e25c 100644
--- a/core/res/res/drawable-mdpi/btn_toggle_off_pressed_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/btn_toggle_off_pressed_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_toggle_on_disabled_focused_holo_dark.9.png b/core/res/res/drawable-mdpi/btn_toggle_on_disabled_focused_holo_dark.9.png
index 909586a..5ddcc42 100644
--- a/core/res/res/drawable-mdpi/btn_toggle_on_disabled_focused_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/btn_toggle_on_disabled_focused_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_toggle_on_disabled_focused_holo_light.9.png b/core/res/res/drawable-mdpi/btn_toggle_on_disabled_focused_holo_light.9.png
index 909586a..5ddcc42 100644
--- a/core/res/res/drawable-mdpi/btn_toggle_on_disabled_focused_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/btn_toggle_on_disabled_focused_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_toggle_on_disabled_holo_dark.9.png b/core/res/res/drawable-mdpi/btn_toggle_on_disabled_holo_dark.9.png
index d64e60a..6f19f49 100644
--- a/core/res/res/drawable-mdpi/btn_toggle_on_disabled_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/btn_toggle_on_disabled_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_toggle_on_disabled_holo_light.9.png b/core/res/res/drawable-mdpi/btn_toggle_on_disabled_holo_light.9.png
index d64e60a..6f19f49 100644
--- a/core/res/res/drawable-mdpi/btn_toggle_on_disabled_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/btn_toggle_on_disabled_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_toggle_on_focused_holo_dark.9.png b/core/res/res/drawable-mdpi/btn_toggle_on_focused_holo_dark.9.png
index 3b64aa1..1087fe3 100644
--- a/core/res/res/drawable-mdpi/btn_toggle_on_focused_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/btn_toggle_on_focused_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_toggle_on_focused_holo_light.9.png b/core/res/res/drawable-mdpi/btn_toggle_on_focused_holo_light.9.png
index 3b64aa1..1087fe3 100644
--- a/core/res/res/drawable-mdpi/btn_toggle_on_focused_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/btn_toggle_on_focused_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_toggle_on_normal_holo_dark.9.png b/core/res/res/drawable-mdpi/btn_toggle_on_normal_holo_dark.9.png
index 6039850..7db7486 100644
--- a/core/res/res/drawable-mdpi/btn_toggle_on_normal_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/btn_toggle_on_normal_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_toggle_on_normal_holo_light.9.png b/core/res/res/drawable-mdpi/btn_toggle_on_normal_holo_light.9.png
index 6039850..7db7486 100644
--- a/core/res/res/drawable-mdpi/btn_toggle_on_normal_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/btn_toggle_on_normal_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_toggle_on_pressed_holo_dark.9.png b/core/res/res/drawable-mdpi/btn_toggle_on_pressed_holo_dark.9.png
index 21b655b..842d967f 100644
--- a/core/res/res/drawable-mdpi/btn_toggle_on_pressed_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/btn_toggle_on_pressed_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/btn_toggle_on_pressed_holo_light.9.png b/core/res/res/drawable-mdpi/btn_toggle_on_pressed_holo_light.9.png
index 21b655b..842d967f 100644
--- a/core/res/res/drawable-mdpi/btn_toggle_on_pressed_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/btn_toggle_on_pressed_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/dialog_bottom_holo_dark.9.png b/core/res/res/drawable-mdpi/dialog_bottom_holo_dark.9.png
index 4836da1..611d538 100644
--- a/core/res/res/drawable-mdpi/dialog_bottom_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/dialog_bottom_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/dialog_bottom_holo_light.9.png b/core/res/res/drawable-mdpi/dialog_bottom_holo_light.9.png
index c299931..cf2f01b 100644
--- a/core/res/res/drawable-mdpi/dialog_bottom_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/dialog_bottom_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/dialog_full_holo_dark.9.png b/core/res/res/drawable-mdpi/dialog_full_holo_dark.9.png
index 86edad7..fb3660e 100644
--- a/core/res/res/drawable-mdpi/dialog_full_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/dialog_full_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/dialog_full_holo_light.9.png b/core/res/res/drawable-mdpi/dialog_full_holo_light.9.png
index 53ee68b..f18050e 100644
--- a/core/res/res/drawable-mdpi/dialog_full_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/dialog_full_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/dialog_middle_holo_dark.9.png b/core/res/res/drawable-mdpi/dialog_middle_holo_dark.9.png
index 606adaf..b620341 100644
--- a/core/res/res/drawable-mdpi/dialog_middle_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/dialog_middle_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/dialog_middle_holo_light.9.png b/core/res/res/drawable-mdpi/dialog_middle_holo_light.9.png
index 14d2e5e..4035428 100644
--- a/core/res/res/drawable-mdpi/dialog_middle_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/dialog_middle_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/dialog_top_holo_dark.9.png b/core/res/res/drawable-mdpi/dialog_top_holo_dark.9.png
index 2646332..4d99748 100644
--- a/core/res/res/drawable-mdpi/dialog_top_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/dialog_top_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/dialog_top_holo_light.9.png b/core/res/res/drawable-mdpi/dialog_top_holo_light.9.png
index 48ec0a4..6f5f149 100644
--- a/core/res/res/drawable-mdpi/dialog_top_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/dialog_top_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/menu_dropdown_panel_holo_dark.9.png b/core/res/res/drawable-mdpi/menu_dropdown_panel_holo_dark.9.png
index dd5dd39..460ec46 100644
--- a/core/res/res/drawable-mdpi/menu_dropdown_panel_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/menu_dropdown_panel_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/menu_dropdown_panel_holo_light.9.png b/core/res/res/drawable-mdpi/menu_dropdown_panel_holo_light.9.png
index 12d65be..e84adf2 100644
--- a/core/res/res/drawable-mdpi/menu_dropdown_panel_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/menu_dropdown_panel_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/spinner_ab_activated_holo_dark.9.png b/core/res/res/drawable-mdpi/spinner_ab_activated_holo_dark.9.png
deleted file mode 100644
index 34c9188..0000000
--- a/core/res/res/drawable-mdpi/spinner_ab_activated_holo_dark.9.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-mdpi/spinner_ab_activated_holo_light.9.png b/core/res/res/drawable-mdpi/spinner_ab_activated_holo_light.9.png
deleted file mode 100644
index 34c9188..0000000
--- a/core/res/res/drawable-mdpi/spinner_ab_activated_holo_light.9.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-mdpi/spinner_ab_default_holo_dark.9.png b/core/res/res/drawable-mdpi/spinner_ab_default_holo_dark.9.png
index b92abaf..8cedc02 100644
--- a/core/res/res/drawable-mdpi/spinner_ab_default_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/spinner_ab_default_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/spinner_ab_default_holo_light.9.png b/core/res/res/drawable-mdpi/spinner_ab_default_holo_light.9.png
index 91f0e87..b5af0f7 100644
--- a/core/res/res/drawable-mdpi/spinner_ab_default_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/spinner_ab_default_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/spinner_ab_disabled_holo_dark.9.png b/core/res/res/drawable-mdpi/spinner_ab_disabled_holo_dark.9.png
index dab7eda0..ffb97a5 100644
--- a/core/res/res/drawable-mdpi/spinner_ab_disabled_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/spinner_ab_disabled_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/spinner_ab_disabled_holo_light.9.png b/core/res/res/drawable-mdpi/spinner_ab_disabled_holo_light.9.png
index bf14605..1d7948c0 100644
--- a/core/res/res/drawable-mdpi/spinner_ab_disabled_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/spinner_ab_disabled_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/spinner_ab_focused_holo_dark.9.png b/core/res/res/drawable-mdpi/spinner_ab_focused_holo_dark.9.png
index c733260..fb6a0a0 100644
--- a/core/res/res/drawable-mdpi/spinner_ab_focused_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/spinner_ab_focused_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/spinner_ab_focused_holo_light.9.png b/core/res/res/drawable-mdpi/spinner_ab_focused_holo_light.9.png
index c733260..fb6a0a0 100644
--- a/core/res/res/drawable-mdpi/spinner_ab_focused_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/spinner_ab_focused_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/spinner_ab_pressed_holo_dark.9.png b/core/res/res/drawable-mdpi/spinner_ab_pressed_holo_dark.9.png
index 6d290a6..556b106 100644
--- a/core/res/res/drawable-mdpi/spinner_ab_pressed_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/spinner_ab_pressed_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/spinner_ab_pressed_holo_light.9.png b/core/res/res/drawable-mdpi/spinner_ab_pressed_holo_light.9.png
index 6dae484..fcca39f 100644
--- a/core/res/res/drawable-mdpi/spinner_ab_pressed_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/spinner_ab_pressed_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/textfield_activated_holo_dark.9.png b/core/res/res/drawable-mdpi/textfield_activated_holo_dark.9.png
index 8bb4048..466beba 100644
--- a/core/res/res/drawable-mdpi/textfield_activated_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/textfield_activated_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/textfield_activated_holo_light.9.png b/core/res/res/drawable-mdpi/textfield_activated_holo_light.9.png
index fdd3ee7..466beba 100644
--- a/core/res/res/drawable-mdpi/textfield_activated_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/textfield_activated_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/textfield_default_holo_dark.9.png b/core/res/res/drawable-mdpi/textfield_default_holo_dark.9.png
index ab6abdc..0ef89fe 100644
--- a/core/res/res/drawable-mdpi/textfield_default_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/textfield_default_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/textfield_default_holo_light.9.png b/core/res/res/drawable-mdpi/textfield_default_holo_light.9.png
index dbdfc79..d9583ee 100644
--- a/core/res/res/drawable-mdpi/textfield_default_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/textfield_default_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/textfield_disabled_focused_holo_dark.9.png b/core/res/res/drawable-mdpi/textfield_disabled_focused_holo_dark.9.png
index 500ede3..4091b7b 100644
--- a/core/res/res/drawable-mdpi/textfield_disabled_focused_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/textfield_disabled_focused_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/textfield_disabled_focused_holo_light.9.png b/core/res/res/drawable-mdpi/textfield_disabled_focused_holo_light.9.png
index 99f7f38..d56e8f4 100644
--- a/core/res/res/drawable-mdpi/textfield_disabled_focused_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/textfield_disabled_focused_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/textfield_disabled_holo_dark.9.png b/core/res/res/drawable-mdpi/textfield_disabled_holo_dark.9.png
index 06190a1..fce496a 100644
--- a/core/res/res/drawable-mdpi/textfield_disabled_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/textfield_disabled_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/textfield_disabled_holo_light.9.png b/core/res/res/drawable-mdpi/textfield_disabled_holo_light.9.png
index 8c16566..c258087 100644
--- a/core/res/res/drawable-mdpi/textfield_disabled_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/textfield_disabled_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/textfield_multiline_activated_holo_dark.9.png b/core/res/res/drawable-mdpi/textfield_multiline_activated_holo_dark.9.png
index 33e6dc8..466beba 100644
--- a/core/res/res/drawable-mdpi/textfield_multiline_activated_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/textfield_multiline_activated_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/textfield_multiline_activated_holo_light.9.png b/core/res/res/drawable-mdpi/textfield_multiline_activated_holo_light.9.png
index eb0d90f..466beba 100644
--- a/core/res/res/drawable-mdpi/textfield_multiline_activated_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/textfield_multiline_activated_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/textfield_multiline_default_holo_dark.9.png b/core/res/res/drawable-mdpi/textfield_multiline_default_holo_dark.9.png
index 74c02c2..0ef89fe 100644
--- a/core/res/res/drawable-mdpi/textfield_multiline_default_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/textfield_multiline_default_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/textfield_multiline_default_holo_light.9.png b/core/res/res/drawable-mdpi/textfield_multiline_default_holo_light.9.png
index 345f4f5..d9583ee 100644
--- a/core/res/res/drawable-mdpi/textfield_multiline_default_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/textfield_multiline_default_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/textfield_multiline_disabled_focused_holo_dark.9.png b/core/res/res/drawable-mdpi/textfield_multiline_disabled_focused_holo_dark.9.png
index 5f0ad56..4091b7b 100644
--- a/core/res/res/drawable-mdpi/textfield_multiline_disabled_focused_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/textfield_multiline_disabled_focused_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/textfield_multiline_disabled_focused_holo_light.9.png b/core/res/res/drawable-mdpi/textfield_multiline_disabled_focused_holo_light.9.png
index df03a15..d56e8f4 100644
--- a/core/res/res/drawable-mdpi/textfield_multiline_disabled_focused_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/textfield_multiline_disabled_focused_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/textfield_multiline_disabled_holo_dark.9.png b/core/res/res/drawable-mdpi/textfield_multiline_disabled_holo_dark.9.png
index bc56916..fce496a 100644
--- a/core/res/res/drawable-mdpi/textfield_multiline_disabled_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/textfield_multiline_disabled_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/textfield_multiline_disabled_holo_light.9.png b/core/res/res/drawable-mdpi/textfield_multiline_disabled_holo_light.9.png
index 84adf68..c258087 100644
--- a/core/res/res/drawable-mdpi/textfield_multiline_disabled_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/textfield_multiline_disabled_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/textfield_multiline_focused_holo_dark.9.png b/core/res/res/drawable-mdpi/textfield_multiline_focused_holo_dark.9.png
index 4a98e57..83e1d98 100644
--- a/core/res/res/drawable-mdpi/textfield_multiline_focused_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/textfield_multiline_focused_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/textfield_multiline_focused_holo_light.9.png b/core/res/res/drawable-mdpi/textfield_multiline_focused_holo_light.9.png
index 5cf6bf3..83e1d98 100644
--- a/core/res/res/drawable-mdpi/textfield_multiline_focused_holo_light.9.png
+++ b/core/res/res/drawable-mdpi/textfield_multiline_focused_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/toast_frame_holo.9.png b/core/res/res/drawable-mdpi/toast_frame_holo.9.png
old mode 100755
new mode 100644
index b9105de..da2d52d
--- a/core/res/res/drawable-mdpi/toast_frame_holo.9.png
+++ b/core/res/res/drawable-mdpi/toast_frame_holo.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/btn_default_disabled_focused_holo_dark.9.png b/core/res/res/drawable-xhdpi/btn_default_disabled_focused_holo_dark.9.png
index 8a30fab..b534256 100644
--- a/core/res/res/drawable-xhdpi/btn_default_disabled_focused_holo_dark.9.png
+++ b/core/res/res/drawable-xhdpi/btn_default_disabled_focused_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/btn_default_disabled_focused_holo_light.9.png b/core/res/res/drawable-xhdpi/btn_default_disabled_focused_holo_light.9.png
index 8a30fab..b534256 100644
--- a/core/res/res/drawable-xhdpi/btn_default_disabled_focused_holo_light.9.png
+++ b/core/res/res/drawable-xhdpi/btn_default_disabled_focused_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/btn_default_disabled_holo.9.png b/core/res/res/drawable-xhdpi/btn_default_disabled_holo.9.png
index bb4e7f6..a364792 100644
--- a/core/res/res/drawable-xhdpi/btn_default_disabled_holo.9.png
+++ b/core/res/res/drawable-xhdpi/btn_default_disabled_holo.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/btn_default_disabled_holo_dark.9.png b/core/res/res/drawable-xhdpi/btn_default_disabled_holo_dark.9.png
index 842ea9c..137d726 100644
--- a/core/res/res/drawable-xhdpi/btn_default_disabled_holo_dark.9.png
+++ b/core/res/res/drawable-xhdpi/btn_default_disabled_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/btn_default_disabled_holo_light.9.png b/core/res/res/drawable-xhdpi/btn_default_disabled_holo_light.9.png
index 842ea9c..137d726 100644
--- a/core/res/res/drawable-xhdpi/btn_default_disabled_holo_light.9.png
+++ b/core/res/res/drawable-xhdpi/btn_default_disabled_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/btn_default_focused_holo.9.png b/core/res/res/drawable-xhdpi/btn_default_focused_holo.9.png
index 5aa02c8..5a52ad6 100644
--- a/core/res/res/drawable-xhdpi/btn_default_focused_holo.9.png
+++ b/core/res/res/drawable-xhdpi/btn_default_focused_holo.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/btn_default_focused_holo_dark.9.png b/core/res/res/drawable-xhdpi/btn_default_focused_holo_dark.9.png
index 025fc00..c5bc3ec 100644
--- a/core/res/res/drawable-xhdpi/btn_default_focused_holo_dark.9.png
+++ b/core/res/res/drawable-xhdpi/btn_default_focused_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/btn_default_focused_holo_light.9.png b/core/res/res/drawable-xhdpi/btn_default_focused_holo_light.9.png
index 025fc00..c5bc3ec 100644
--- a/core/res/res/drawable-xhdpi/btn_default_focused_holo_light.9.png
+++ b/core/res/res/drawable-xhdpi/btn_default_focused_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/btn_default_normal_holo.9.png b/core/res/res/drawable-xhdpi/btn_default_normal_holo.9.png
index 02360bd..e34ed85 100644
--- a/core/res/res/drawable-xhdpi/btn_default_normal_holo.9.png
+++ b/core/res/res/drawable-xhdpi/btn_default_normal_holo.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/btn_default_normal_holo_dark.9.png b/core/res/res/drawable-xhdpi/btn_default_normal_holo_dark.9.png
index 5c4a2d1..ed7e0f4 100644
--- a/core/res/res/drawable-xhdpi/btn_default_normal_holo_dark.9.png
+++ b/core/res/res/drawable-xhdpi/btn_default_normal_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/btn_default_normal_holo_light.9.png b/core/res/res/drawable-xhdpi/btn_default_normal_holo_light.9.png
index 5c4a2d1..ed7e0f4 100644
--- a/core/res/res/drawable-xhdpi/btn_default_normal_holo_light.9.png
+++ b/core/res/res/drawable-xhdpi/btn_default_normal_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/btn_default_pressed_holo.9.png b/core/res/res/drawable-xhdpi/btn_default_pressed_holo.9.png
index 1833ffe..f76d56b 100644
--- a/core/res/res/drawable-xhdpi/btn_default_pressed_holo.9.png
+++ b/core/res/res/drawable-xhdpi/btn_default_pressed_holo.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/btn_default_pressed_holo_dark.9.png b/core/res/res/drawable-xhdpi/btn_default_pressed_holo_dark.9.png
index 7fc5980..61f5f6f 100644
--- a/core/res/res/drawable-xhdpi/btn_default_pressed_holo_dark.9.png
+++ b/core/res/res/drawable-xhdpi/btn_default_pressed_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/btn_default_pressed_holo_light.9.png b/core/res/res/drawable-xhdpi/btn_default_pressed_holo_light.9.png
index 7fc5980..61f5f6f 100644
--- a/core/res/res/drawable-xhdpi/btn_default_pressed_holo_light.9.png
+++ b/core/res/res/drawable-xhdpi/btn_default_pressed_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/btn_toggle_off_disabled_focused_holo_dark.9.png b/core/res/res/drawable-xhdpi/btn_toggle_off_disabled_focused_holo_dark.9.png
index 9d9c6f2..18aeac6 100644
--- a/core/res/res/drawable-xhdpi/btn_toggle_off_disabled_focused_holo_dark.9.png
+++ b/core/res/res/drawable-xhdpi/btn_toggle_off_disabled_focused_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/btn_toggle_off_disabled_focused_holo_light.9.png b/core/res/res/drawable-xhdpi/btn_toggle_off_disabled_focused_holo_light.9.png
index 7d9bfd1..471b6ea 100644
--- a/core/res/res/drawable-xhdpi/btn_toggle_off_disabled_focused_holo_light.9.png
+++ b/core/res/res/drawable-xhdpi/btn_toggle_off_disabled_focused_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/btn_toggle_off_disabled_holo_dark.9.png b/core/res/res/drawable-xhdpi/btn_toggle_off_disabled_holo_dark.9.png
index 0cddd2d..393f967 100644
--- a/core/res/res/drawable-xhdpi/btn_toggle_off_disabled_holo_dark.9.png
+++ b/core/res/res/drawable-xhdpi/btn_toggle_off_disabled_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/btn_toggle_off_disabled_holo_light.9.png b/core/res/res/drawable-xhdpi/btn_toggle_off_disabled_holo_light.9.png
index 1109fe1..87193af 100644
--- a/core/res/res/drawable-xhdpi/btn_toggle_off_disabled_holo_light.9.png
+++ b/core/res/res/drawable-xhdpi/btn_toggle_off_disabled_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/btn_toggle_off_focused_holo_dark.9.png b/core/res/res/drawable-xhdpi/btn_toggle_off_focused_holo_dark.9.png
index ec33f17..0ad8f35 100644
--- a/core/res/res/drawable-xhdpi/btn_toggle_off_focused_holo_dark.9.png
+++ b/core/res/res/drawable-xhdpi/btn_toggle_off_focused_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/btn_toggle_off_focused_holo_light.9.png b/core/res/res/drawable-xhdpi/btn_toggle_off_focused_holo_light.9.png
index 0b562cc..fc21be1 100644
--- a/core/res/res/drawable-xhdpi/btn_toggle_off_focused_holo_light.9.png
+++ b/core/res/res/drawable-xhdpi/btn_toggle_off_focused_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/btn_toggle_off_normal_holo_dark.9.png b/core/res/res/drawable-xhdpi/btn_toggle_off_normal_holo_dark.9.png
index 93f565f..5ff338d 100644
--- a/core/res/res/drawable-xhdpi/btn_toggle_off_normal_holo_dark.9.png
+++ b/core/res/res/drawable-xhdpi/btn_toggle_off_normal_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/btn_toggle_off_normal_holo_light.9.png b/core/res/res/drawable-xhdpi/btn_toggle_off_normal_holo_light.9.png
index aee803d..1321473 100644
--- a/core/res/res/drawable-xhdpi/btn_toggle_off_normal_holo_light.9.png
+++ b/core/res/res/drawable-xhdpi/btn_toggle_off_normal_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/btn_toggle_off_pressed_holo_dark.9.png b/core/res/res/drawable-xhdpi/btn_toggle_off_pressed_holo_dark.9.png
index 2f56666..9c914b0 100644
--- a/core/res/res/drawable-xhdpi/btn_toggle_off_pressed_holo_dark.9.png
+++ b/core/res/res/drawable-xhdpi/btn_toggle_off_pressed_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/btn_toggle_off_pressed_holo_light.9.png b/core/res/res/drawable-xhdpi/btn_toggle_off_pressed_holo_light.9.png
index d636569..fe28238 100644
--- a/core/res/res/drawable-xhdpi/btn_toggle_off_pressed_holo_light.9.png
+++ b/core/res/res/drawable-xhdpi/btn_toggle_off_pressed_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/btn_toggle_on_disabled_focused_holo_dark.9.png b/core/res/res/drawable-xhdpi/btn_toggle_on_disabled_focused_holo_dark.9.png
index 9ec3fe0c..455fdb4 100644
--- a/core/res/res/drawable-xhdpi/btn_toggle_on_disabled_focused_holo_dark.9.png
+++ b/core/res/res/drawable-xhdpi/btn_toggle_on_disabled_focused_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/btn_toggle_on_disabled_focused_holo_light.9.png b/core/res/res/drawable-xhdpi/btn_toggle_on_disabled_focused_holo_light.9.png
index 9ec3fe0c..455fdb4 100644
--- a/core/res/res/drawable-xhdpi/btn_toggle_on_disabled_focused_holo_light.9.png
+++ b/core/res/res/drawable-xhdpi/btn_toggle_on_disabled_focused_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/btn_toggle_on_disabled_holo_dark.9.png b/core/res/res/drawable-xhdpi/btn_toggle_on_disabled_holo_dark.9.png
index 5b8bf7b..ee8329df 100644
--- a/core/res/res/drawable-xhdpi/btn_toggle_on_disabled_holo_dark.9.png
+++ b/core/res/res/drawable-xhdpi/btn_toggle_on_disabled_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/btn_toggle_on_disabled_holo_light.9.png b/core/res/res/drawable-xhdpi/btn_toggle_on_disabled_holo_light.9.png
index 5b8bf7b..ee8329df 100644
--- a/core/res/res/drawable-xhdpi/btn_toggle_on_disabled_holo_light.9.png
+++ b/core/res/res/drawable-xhdpi/btn_toggle_on_disabled_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/btn_toggle_on_focused_holo_dark.9.png b/core/res/res/drawable-xhdpi/btn_toggle_on_focused_holo_dark.9.png
index 5c3318b..ccfb2d0 100644
--- a/core/res/res/drawable-xhdpi/btn_toggle_on_focused_holo_dark.9.png
+++ b/core/res/res/drawable-xhdpi/btn_toggle_on_focused_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/btn_toggle_on_focused_holo_light.9.png b/core/res/res/drawable-xhdpi/btn_toggle_on_focused_holo_light.9.png
index 5c3318b..ccfb2d0 100644
--- a/core/res/res/drawable-xhdpi/btn_toggle_on_focused_holo_light.9.png
+++ b/core/res/res/drawable-xhdpi/btn_toggle_on_focused_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/btn_toggle_on_normal_holo_dark.9.png b/core/res/res/drawable-xhdpi/btn_toggle_on_normal_holo_dark.9.png
index ef7310a..ad1f4f0 100644
--- a/core/res/res/drawable-xhdpi/btn_toggle_on_normal_holo_dark.9.png
+++ b/core/res/res/drawable-xhdpi/btn_toggle_on_normal_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/btn_toggle_on_normal_holo_light.9.png b/core/res/res/drawable-xhdpi/btn_toggle_on_normal_holo_light.9.png
index ef7310a..ad1f4f0 100644
--- a/core/res/res/drawable-xhdpi/btn_toggle_on_normal_holo_light.9.png
+++ b/core/res/res/drawable-xhdpi/btn_toggle_on_normal_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/btn_toggle_on_pressed_holo_dark.9.png b/core/res/res/drawable-xhdpi/btn_toggle_on_pressed_holo_dark.9.png
index c55389e..97304af 100644
--- a/core/res/res/drawable-xhdpi/btn_toggle_on_pressed_holo_dark.9.png
+++ b/core/res/res/drawable-xhdpi/btn_toggle_on_pressed_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/btn_toggle_on_pressed_holo_light.9.png b/core/res/res/drawable-xhdpi/btn_toggle_on_pressed_holo_light.9.png
index c55389e..97304af 100644
--- a/core/res/res/drawable-xhdpi/btn_toggle_on_pressed_holo_light.9.png
+++ b/core/res/res/drawable-xhdpi/btn_toggle_on_pressed_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/dialog_bottom_holo_dark.9.png b/core/res/res/drawable-xhdpi/dialog_bottom_holo_dark.9.png
index 077e4d3..94bb8e1 100644
--- a/core/res/res/drawable-xhdpi/dialog_bottom_holo_dark.9.png
+++ b/core/res/res/drawable-xhdpi/dialog_bottom_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/dialog_bottom_holo_light.9.png b/core/res/res/drawable-xhdpi/dialog_bottom_holo_light.9.png
index 357c17f..ef58e29 100644
--- a/core/res/res/drawable-xhdpi/dialog_bottom_holo_light.9.png
+++ b/core/res/res/drawable-xhdpi/dialog_bottom_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/dialog_full_holo_dark.9.png b/core/res/res/drawable-xhdpi/dialog_full_holo_dark.9.png
index 5b510721..f4970ad 100644
--- a/core/res/res/drawable-xhdpi/dialog_full_holo_dark.9.png
+++ b/core/res/res/drawable-xhdpi/dialog_full_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/dialog_full_holo_light.9.png b/core/res/res/drawable-xhdpi/dialog_full_holo_light.9.png
index 2705a39..172fc3b 100644
--- a/core/res/res/drawable-xhdpi/dialog_full_holo_light.9.png
+++ b/core/res/res/drawable-xhdpi/dialog_full_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/dialog_middle_holo_dark.9.png b/core/res/res/drawable-xhdpi/dialog_middle_holo_dark.9.png
index 101876f..2bab67a 100644
--- a/core/res/res/drawable-xhdpi/dialog_middle_holo_dark.9.png
+++ b/core/res/res/drawable-xhdpi/dialog_middle_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/dialog_middle_holo_light.9.png b/core/res/res/drawable-xhdpi/dialog_middle_holo_light.9.png
index 0df1503..6b5f467 100644
--- a/core/res/res/drawable-xhdpi/dialog_middle_holo_light.9.png
+++ b/core/res/res/drawable-xhdpi/dialog_middle_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/dialog_top_holo_dark.9.png b/core/res/res/drawable-xhdpi/dialog_top_holo_dark.9.png
index 344a4e2..e1c602f 100644
--- a/core/res/res/drawable-xhdpi/dialog_top_holo_dark.9.png
+++ b/core/res/res/drawable-xhdpi/dialog_top_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/dialog_top_holo_light.9.png b/core/res/res/drawable-xhdpi/dialog_top_holo_light.9.png
index 249848f..59db99c 100644
--- a/core/res/res/drawable-xhdpi/dialog_top_holo_light.9.png
+++ b/core/res/res/drawable-xhdpi/dialog_top_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/menu_dropdown_panel_holo_dark.9.png b/core/res/res/drawable-xhdpi/menu_dropdown_panel_holo_dark.9.png
index 92acc47..e2aff72 100644
--- a/core/res/res/drawable-xhdpi/menu_dropdown_panel_holo_dark.9.png
+++ b/core/res/res/drawable-xhdpi/menu_dropdown_panel_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/menu_dropdown_panel_holo_light.9.png b/core/res/res/drawable-xhdpi/menu_dropdown_panel_holo_light.9.png
index 4e54b4b6..93066c8 100644
--- a/core/res/res/drawable-xhdpi/menu_dropdown_panel_holo_light.9.png
+++ b/core/res/res/drawable-xhdpi/menu_dropdown_panel_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/spinner_ab_activated_holo_dark.9.png b/core/res/res/drawable-xhdpi/spinner_ab_activated_holo_dark.9.png
deleted file mode 100644
index 85d8540..0000000
--- a/core/res/res/drawable-xhdpi/spinner_ab_activated_holo_dark.9.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/spinner_ab_activated_holo_light.9.png b/core/res/res/drawable-xhdpi/spinner_ab_activated_holo_light.9.png
deleted file mode 100644
index 85d8540..0000000
--- a/core/res/res/drawable-xhdpi/spinner_ab_activated_holo_light.9.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/spinner_ab_default_holo_dark.9.png b/core/res/res/drawable-xhdpi/spinner_ab_default_holo_dark.9.png
index 31b39d7..074f2d4 100644
--- a/core/res/res/drawable-xhdpi/spinner_ab_default_holo_dark.9.png
+++ b/core/res/res/drawable-xhdpi/spinner_ab_default_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/spinner_ab_default_holo_light.9.png b/core/res/res/drawable-xhdpi/spinner_ab_default_holo_light.9.png
index 1527c5c..f8c12cf 100644
--- a/core/res/res/drawable-xhdpi/spinner_ab_default_holo_light.9.png
+++ b/core/res/res/drawable-xhdpi/spinner_ab_default_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/spinner_ab_disabled_holo_dark.9.png b/core/res/res/drawable-xhdpi/spinner_ab_disabled_holo_dark.9.png
index e4cef9a..cf01901 100644
--- a/core/res/res/drawable-xhdpi/spinner_ab_disabled_holo_dark.9.png
+++ b/core/res/res/drawable-xhdpi/spinner_ab_disabled_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/spinner_ab_disabled_holo_light.9.png b/core/res/res/drawable-xhdpi/spinner_ab_disabled_holo_light.9.png
index 1c37ece..71f4f11 100644
--- a/core/res/res/drawable-xhdpi/spinner_ab_disabled_holo_light.9.png
+++ b/core/res/res/drawable-xhdpi/spinner_ab_disabled_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/spinner_ab_focused_holo_dark.9.png b/core/res/res/drawable-xhdpi/spinner_ab_focused_holo_dark.9.png
index 6aae46b..c591620 100644
--- a/core/res/res/drawable-xhdpi/spinner_ab_focused_holo_dark.9.png
+++ b/core/res/res/drawable-xhdpi/spinner_ab_focused_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/spinner_ab_focused_holo_light.9.png b/core/res/res/drawable-xhdpi/spinner_ab_focused_holo_light.9.png
index 6aae46b..c591620 100644
--- a/core/res/res/drawable-xhdpi/spinner_ab_focused_holo_light.9.png
+++ b/core/res/res/drawable-xhdpi/spinner_ab_focused_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/spinner_ab_pressed_holo_dark.9.png b/core/res/res/drawable-xhdpi/spinner_ab_pressed_holo_dark.9.png
index db2e034..30caa29 100644
--- a/core/res/res/drawable-xhdpi/spinner_ab_pressed_holo_dark.9.png
+++ b/core/res/res/drawable-xhdpi/spinner_ab_pressed_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/spinner_ab_pressed_holo_light.9.png b/core/res/res/drawable-xhdpi/spinner_ab_pressed_holo_light.9.png
index 77bb433..7ee4c7f 100644
--- a/core/res/res/drawable-xhdpi/spinner_ab_pressed_holo_light.9.png
+++ b/core/res/res/drawable-xhdpi/spinner_ab_pressed_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/textfield_activated_holo_dark.9.png b/core/res/res/drawable-xhdpi/textfield_activated_holo_dark.9.png
new file mode 100644
index 0000000..2f35995
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/textfield_activated_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/textfield_activated_holo_light.9.png b/core/res/res/drawable-xhdpi/textfield_activated_holo_light.9.png
new file mode 100644
index 0000000..2f35995
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/textfield_activated_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/textfield_default_holo_dark.9.png b/core/res/res/drawable-xhdpi/textfield_default_holo_dark.9.png
new file mode 100644
index 0000000..b22dd41
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/textfield_default_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/textfield_default_holo_light.9.png b/core/res/res/drawable-xhdpi/textfield_default_holo_light.9.png
new file mode 100644
index 0000000..3a9a51a
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/textfield_default_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/textfield_disabled_focused_holo_dark.9.png b/core/res/res/drawable-xhdpi/textfield_disabled_focused_holo_dark.9.png
new file mode 100644
index 0000000..c11d800
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/textfield_disabled_focused_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/textfield_disabled_focused_holo_light.9.png b/core/res/res/drawable-xhdpi/textfield_disabled_focused_holo_light.9.png
new file mode 100644
index 0000000..cdd8752
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/textfield_disabled_focused_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/textfield_disabled_holo_dark.9.png b/core/res/res/drawable-xhdpi/textfield_disabled_holo_dark.9.png
new file mode 100644
index 0000000..5f40cac
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/textfield_disabled_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/textfield_disabled_holo_light.9.png b/core/res/res/drawable-xhdpi/textfield_disabled_holo_light.9.png
new file mode 100644
index 0000000..aa35049
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/textfield_disabled_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/textfield_multiline_activated_holo_dark.9.png b/core/res/res/drawable-xhdpi/textfield_multiline_activated_holo_dark.9.png
new file mode 100644
index 0000000..2f35995
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/textfield_multiline_activated_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/textfield_multiline_activated_holo_light.9.png b/core/res/res/drawable-xhdpi/textfield_multiline_activated_holo_light.9.png
new file mode 100644
index 0000000..2f35995
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/textfield_multiline_activated_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/textfield_multiline_default_holo_dark.9.png b/core/res/res/drawable-xhdpi/textfield_multiline_default_holo_dark.9.png
new file mode 100644
index 0000000..b22dd41
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/textfield_multiline_default_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/textfield_multiline_default_holo_light.9.png b/core/res/res/drawable-xhdpi/textfield_multiline_default_holo_light.9.png
new file mode 100644
index 0000000..3a9a51a
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/textfield_multiline_default_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/textfield_multiline_disabled_focused_holo_dark.9.png b/core/res/res/drawable-xhdpi/textfield_multiline_disabled_focused_holo_dark.9.png
new file mode 100644
index 0000000..c11d800
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/textfield_multiline_disabled_focused_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/textfield_multiline_disabled_focused_holo_light.9.png b/core/res/res/drawable-xhdpi/textfield_multiline_disabled_focused_holo_light.9.png
new file mode 100644
index 0000000..cdd8752
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/textfield_multiline_disabled_focused_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/textfield_multiline_disabled_holo_dark.9.png b/core/res/res/drawable-xhdpi/textfield_multiline_disabled_holo_dark.9.png
new file mode 100644
index 0000000..5f40cac
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/textfield_multiline_disabled_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/textfield_multiline_disabled_holo_light.9.png b/core/res/res/drawable-xhdpi/textfield_multiline_disabled_holo_light.9.png
new file mode 100644
index 0000000..aa35049
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/textfield_multiline_disabled_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/textfield_multiline_focused_holo_dark.9.png b/core/res/res/drawable-xhdpi/textfield_multiline_focused_holo_dark.9.png
new file mode 100644
index 0000000..09e3fff
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/textfield_multiline_focused_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/textfield_multiline_focused_holo_light.9.png b/core/res/res/drawable-xhdpi/textfield_multiline_focused_holo_light.9.png
new file mode 100644
index 0000000..09e3fff
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/textfield_multiline_focused_holo_light.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/toast_frame_holo.9.png b/core/res/res/drawable-xhdpi/toast_frame_holo.9.png
index 9f39a77..9cb7c10 100644
--- a/core/res/res/drawable-xhdpi/toast_frame_holo.9.png
+++ b/core/res/res/drawable-xhdpi/toast_frame_holo.9.png
Binary files differ
diff --git a/core/res/res/drawable/spinner_ab_holo_dark.xml b/core/res/res/drawable/spinner_ab_holo_dark.xml
index 708b6ab..0932eff 100644
--- a/core/res/res/drawable/spinner_ab_holo_dark.xml
+++ b/core/res/res/drawable/spinner_ab_holo_dark.xml
@@ -21,7 +21,5 @@
           android:drawable="@drawable/spinner_ab_pressed_holo_dark" />
     <item android:state_pressed="false" android:state_focused="true"
           android:drawable="@drawable/spinner_ab_focused_holo_dark" />
-    <item android:state_activated="true"
-          android:drawable="@drawable/spinner_ab_activated_holo_dark" />
     <item android:drawable="@drawable/spinner_ab_default_holo_dark" />
 </selector>
diff --git a/core/res/res/drawable/spinner_ab_holo_light.xml b/core/res/res/drawable/spinner_ab_holo_light.xml
index c4901ca..e785cf4 100644
--- a/core/res/res/drawable/spinner_ab_holo_light.xml
+++ b/core/res/res/drawable/spinner_ab_holo_light.xml
@@ -21,7 +21,5 @@
           android:drawable="@drawable/spinner_ab_pressed_holo_light" />
     <item android:state_pressed="false" android:state_focused="true"
           android:drawable="@drawable/spinner_ab_focused_holo_light" />
-    <item android:state_activated="true"
-          android:drawable="@drawable/spinner_ab_activated_holo_light" />
     <item android:drawable="@drawable/spinner_ab_default_holo_light" />
 </selector>
diff --git a/core/res/res/layout/keyguard_screen_password_landscape.xml b/core/res/res/layout/keyguard_screen_password_landscape.xml
index 452b982..4c44049 100644
--- a/core/res/res/layout/keyguard_screen_password_landscape.xml
+++ b/core/res/res/layout/keyguard_screen_password_landscape.xml
@@ -66,13 +66,15 @@
 
     <TextView
         android:id="@+id/date"
+        android:layout_width="0dip"
+        android:layout_gravity="fill_horizontal"
+        android:gravity="right"
         android:layout_below="@id/time"
         android:layout_marginTop="6dip"
         android:singleLine="true"
         android:ellipsize="marquee"
         android:textAppearance="?android:attr/textAppearanceMedium"
         android:textSize="@dimen/keyguard_lockscreen_status_line_font_size"
-        android:layout_gravity="right"
         />
 
     <TextView
@@ -88,22 +90,26 @@
 
     <TextView
         android:id="@+id/status1"
+        android:layout_width="0dip"
+        android:layout_gravity="fill_horizontal"
+        android:gravity="right"
         android:layout_marginTop="4dip"
         android:singleLine="true"
         android:ellipsize="marquee"
         android:textAppearance="?android:attr/textAppearanceMedium"
         android:textSize="@dimen/keyguard_lockscreen_status_line_font_size"
         android:drawablePadding="4dip"
-        android:layout_gravity="right"
         />
 
     <Space android:layout_gravity="fill" />
 
     <TextView
         android:id="@+id/carrier"
+        android:layout_width="0dip"
+        android:layout_gravity="fill_horizontal"
+        android:gravity="right"
         android:singleLine="true"
         android:ellipsize="marquee"
-        android:layout_gravity="right"
         android:textAppearance="?android:attr/textAppearanceMedium"
         android:textSize="@dimen/keyguard_lockscreen_status_line_font_size"
         android:textColor="?android:attr/textColorSecondary"
@@ -144,6 +150,7 @@
             android:background="@drawable/lockscreen_password_field_dark"
             android:textColor="?android:attr/textColorPrimary"
             android:imeOptions="flagNoFullscreen|actionDone"
+            android:suggestionsEnabled="false"
             />
 
     </LinearLayout>
diff --git a/core/res/res/layout/keyguard_screen_password_portrait.xml b/core/res/res/layout/keyguard_screen_password_portrait.xml
index cd33275..1d0ea547 100644
--- a/core/res/res/layout/keyguard_screen_password_portrait.xml
+++ b/core/res/res/layout/keyguard_screen_password_portrait.xml
@@ -109,7 +109,8 @@
         android:background="@drawable/lockscreen_password_field_dark"
         android:textAppearance="?android:attr/textAppearanceMedium"
         android:textColor="#ffffffff"
-        android:imeOptions="actionDone"/>
+        android:imeOptions="actionDone"
+        android:suggestionsEnabled="false"/>
 
     <!-- Numeric keyboard -->
     <com.android.internal.widget.PasswordEntryKeyboardView android:id="@+id/keyboard"
diff --git a/core/res/res/layout/keyguard_screen_tab_unlock_land.xml b/core/res/res/layout/keyguard_screen_tab_unlock_land.xml
index 168bd1a..0568dd9 100644
--- a/core/res/res/layout/keyguard_screen_tab_unlock_land.xml
+++ b/core/res/res/layout/keyguard_screen_tab_unlock_land.xml
@@ -64,13 +64,14 @@
 
     <TextView
         android:id="@+id/date"
-        android:layout_below="@id/time"
+        android:layout_width="0dip"
+        android:layout_gravity="fill_horizontal"
+        android:gravity="right"
         android:layout_marginTop="6dip"
         android:singleLine="true"
         android:ellipsize="marquee"
         android:textAppearance="?android:attr/textAppearanceMedium"
         android:textSize="@dimen/keyguard_lockscreen_status_line_font_size"
-        android:layout_gravity="right"
         />
 
     <TextView
@@ -86,22 +87,24 @@
 
     <TextView
         android:id="@+id/status1"
+        android:layout_width="0dip"
+        android:layout_gravity="fill_horizontal"
+        android:gravity="right"
         android:layout_marginTop="4dip"
         android:singleLine="true"
         android:ellipsize="marquee"
         android:textAppearance="?android:attr/textAppearanceMedium"
         android:textSize="@dimen/keyguard_lockscreen_status_line_font_size"
         android:drawablePadding="4dip"
-        android:layout_gravity="right"
         />
 
     <Space android:layout_gravity="fill" />
 
     <TextView
         android:id="@+id/carrier"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_gravity="right"
+        android:layout_width="0dip"
+        android:layout_gravity="fill_horizontal"
+        android:gravity="right"
         android:singleLine="true"
         android:ellipsize="marquee"
         android:textAppearance="?android:attr/textAppearanceMedium"
diff --git a/core/res/res/layout/keyguard_screen_unlock_landscape.xml b/core/res/res/layout/keyguard_screen_unlock_landscape.xml
index c425b73..9b28731 100644
--- a/core/res/res/layout/keyguard_screen_unlock_landscape.xml
+++ b/core/res/res/layout/keyguard_screen_unlock_landscape.xml
@@ -64,11 +64,13 @@
 
     <TextView
         android:id="@+id/date"
+        android:layout_width="0dip"
+        android:layout_gravity="fill_horizontal"
+        android:gravity="right"
         android:singleLine="true"
         android:ellipsize="marquee"
         android:textAppearance="?android:attr/textAppearanceMedium"
         android:textSize="@dimen/keyguard_lockscreen_status_line_font_size"
-        android:layout_gravity="right"
         />
 
     <TextView
@@ -83,17 +85,21 @@
 
     <TextView
         android:id="@+id/status1"
+        android:layout_width="0dip"
+        android:layout_gravity="fill_horizontal"
+        android:gravity="right"
         android:singleLine="true"
         android:ellipsize="marquee"
         android:textAppearance="?android:attr/textAppearanceMedium"
         android:textSize="@dimen/keyguard_lockscreen_status_line_font_size"
-        android:layout_gravity="right"
         />
 
     <Space android:layout_gravity="fill" />
 
     <TextView android:id="@+id/carrier"
-        android:layout_gravity="right"
+        android:layout_width="0dip"
+        android:layout_gravity="fill_horizontal"
+        android:gravity="right"
         android:singleLine="true"
         android:ellipsize="marquee"
         android:textAppearance="?android:attr/textAppearanceMedium"
diff --git a/core/res/res/layout/status_bar_latest_event_content_large_icon.xml b/core/res/res/layout/status_bar_latest_event_content_large_icon.xml
index d937392..ac4d1e4 100644
--- a/core/res/res/layout/status_bar_latest_event_content_large_icon.xml
+++ b/core/res/res/layout/status_bar_latest_event_content_large_icon.xml
@@ -28,6 +28,7 @@
         android:alpha="0.7"
         />
     <LinearLayout
+        android:id="@+id/line3"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:orientation="horizontal"
@@ -60,6 +61,14 @@
             android:layout_weight="0"
             android:scaleType="center"
             android:paddingLeft="8dp"
+            android:visibility="gone"
             />
     </LinearLayout>
+    <ProgressBar
+        android:id="@android:id/progress"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:visibility="gone"
+        style="?android:attr/progressBarStyleHorizontal"
+        />
 </LinearLayout>
diff --git a/core/res/res/values/arrays.xml b/core/res/res/values/arrays.xml
index 753e4ac..96fa931 100644
--- a/core/res/res/values/arrays.xml
+++ b/core/res/res/values/arrays.xml
@@ -225,8 +225,6 @@
        <item>@drawable/spinner_ab_focused_holo_light</item>
        <item>@drawable/spinner_ab_pressed_holo_dark</item>
        <item>@drawable/spinner_ab_pressed_holo_light</item>
-       <item>@drawable/spinner_ab_activated_holo_dark</item>
-       <item>@drawable/spinner_ab_activated_holo_light</item>
        <item>@drawable/spinner_ab_holo_dark</item>
        <item>@drawable/spinner_ab_holo_light</item>
        <item>@drawable/spinner_default_holo_dark</item>
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index 63b49bd..f4c0240 100755
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -5281,6 +5281,10 @@
         <attr name="maxWidth" />
         <!-- An optional query hint string to be displayed in the empty query field. -->
         <attr name="queryHint" format="string" />
+        <!-- The IME options to set on the query text field. -->
+        <attr name="imeOptions" />
+        <!-- The input type to set on the query text field. -->
+        <attr name="inputType" />
     </declare-styleable>
 
     <declare-styleable name="ActionBar_LayoutParams">
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 5618bfb..4aa8ba2 100755
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -930,22 +930,22 @@
         modify your profile data.</string>
 
     <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
-    <string name="permlab_readCalendar">read calendar events</string>
+    <string name="permlab_readCalendar">read calendar events plus confidential information</string>
     <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
-    <string name="permdesc_readCalendar" product="tablet">Allows an application to read all
-        of the calendar events stored on your tablet. Malicious applications
-        can use this to send your calendar events to other people.</string>
+    <string name="permdesc_readCalendar" product="tablet">Allows an application to read all calendar 
+        events stored on your tablet, including those of friends or coworkers. A malicious application with
+        this permission can extract personal information from these calendars without the owners\' knowledge.</string>
     <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
-    <string name="permdesc_readCalendar" product="default">Allows an application to read all
-        of the calendar events stored on your phone. Malicious applications
-        can use this to send your calendar events to other people.</string>
+    <string name="permdesc_readCalendar" product="default">Allows an application to read all calendar 
+        events stored on your phone, including those of friends or coworkers. A malicious application with
+        this permission can extract personal information from these calendars without the owners\' knowledge.</string>
 
     <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
-    <string name="permlab_writeCalendar">add or modify calendar events and send email to guests</string>
+    <string name="permlab_writeCalendar">add or modify calendar events and send email to guests without owners\' knowledge</string>
     <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
-    <string name="permdesc_writeCalendar">Allows an application to add or change the
-        events on your calendar, which may send email to guests. Malicious applications can use this
-        to erase or modify your calendar events or to send email to guests.</string>
+    <string name="permdesc_writeCalendar">Allows an application to send event invitations as the calendar owner and add, remove, 
+        change events that you can modify on your device, including those of friends or co-workers. A malicious application with this permission 
+        can send spam emails that appear to come from calendar owners, modify events without the owners\' knowledge, or add fake events.</string>
 
     <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
     <string name="permlab_accessMockLocation">mock location sources for testing</string>
@@ -2466,25 +2466,24 @@
          activity chooser. See the "Select an action" title. -->
     <string name="noApplications">No applications can perform this action.</string>
     <!-- Title of the alert when an application has crashed. -->
-    <string name="aerr_title">Sorry!</string>
+    <string name="aerr_title"></string>
     <!-- Text of the alert that is displayed when an application has crashed. -->
-    <string name="aerr_application">The application <xliff:g id="application">%1$s</xliff:g>
-        (process <xliff:g id="process">%2$s</xliff:g>) has stopped unexpectedly. Please try again.</string>
+    <string name="aerr_application"><xliff:g id="application">%1$s</xliff:g> has stopped by mistake.</string>
     <!-- Text of the alert that is displayed when an application has crashed. -->
     <string name="aerr_process">The process <xliff:g id="process">%1$s</xliff:g> has
-        stopped unexpectedly. Please try again.</string>
+        stopped by mistake.</string>
     <!-- Title of the alert when an application is not responding. -->
-    <string name="anr_title">Sorry!</string>
+    <string name="anr_title"></string>
     <!-- Text of the alert that is displayed when an application is not responding. -->
-    <string name="anr_activity_application">Activity <xliff:g id="activity">%1$s</xliff:g> (in application <xliff:g id="application">%2$s</xliff:g>) is not responding.</string>
+    <string name="anr_activity_application"><xliff:g id="application">%2$s</xliff:g> is not responding.\n\nWould you like to close it?</string>
     <!-- Text of the alert that is displayed when an application is not responding. -->
-    <string name="anr_activity_process">Activity <xliff:g id="activity">%1$s</xliff:g> (in process <xliff:g id="process">%2$s</xliff:g>) is not responding.</string>
+    <string name="anr_activity_process">Activity <xliff:g id="activity">%1$s</xliff:g> is not responding.\n\nWould you like to close it?</string>
     <!-- Text of the alert that is displayed when an application is not responding. -->
-    <string name="anr_application_process">Application <xliff:g id="application">%1$s</xliff:g> (in process <xliff:g id="process">%2$s</xliff:g>) is not responding.</string>
+    <string name="anr_application_process"><xliff:g id="application">%1$s</xliff:g> is not responding. Would you like to close it?</string>
     <!-- Text of the alert that is displayed when an application is not responding. -->
-    <string name="anr_process">Process <xliff:g id="process">%1$s</xliff:g> is not responding.</string>
+    <string name="anr_process">Process <xliff:g id="process">%1$s</xliff:g> is not responding.\n\nWould you like to close it?</string>
     <!-- Button allowing the user to close an application that is not responding. This will kill the application. -->
-    <string name="force_close">Force close</string>
+    <string name="force_close">OK</string>
     <!-- Button allowing the user to send a bug report for application which has encountered an error. -->
     <string name="report">Report</string>
     <!-- Button allowing the user to choose to wait for an application that is not responding to become responsive again. -->
diff --git a/graphics/java/android/graphics/Paint.java b/graphics/java/android/graphics/Paint.java
index 1df8143..fe4b082 100644
--- a/graphics/java/android/graphics/Paint.java
+++ b/graphics/java/android/graphics/Paint.java
@@ -1179,13 +1179,26 @@
     /**
      * Return the width of the text.
      *
-     * @param text  The text to measure
+     * @param text  The text to measure. Cannot be null.
      * @param index The index of the first character to start measuring
      * @param count THe number of characters to measure, beginning with start
      * @return      The width of the text
      */
     public float measureText(char[] text, int index, int count) {
-        if (!mHasCompatScaling) return native_measureText(text, index, count);
+        if (text == null) {
+            throw new IllegalArgumentException("text cannot be null");
+        }
+        if ((index | count) < 0 || index + count > text.length) {
+            throw new ArrayIndexOutOfBoundsException();
+        }
+
+        if (text.length == 0 || count == 0) {
+            return 0f;
+        }
+        if (!mHasCompatScaling) {
+            return native_measureText(text, index, count);
+        }
+
         final float oldSize = getTextSize();
         setTextSize(oldSize*mCompatScaling);
         float w = native_measureText(text, index, count);
@@ -1198,13 +1211,26 @@
     /**
      * Return the width of the text.
      *
-     * @param text  The text to measure
+     * @param text  The text to measure. Cannot be null.
      * @param start The index of the first character to start measuring
      * @param end   1 beyond the index of the last character to measure
      * @return      The width of the text
      */
     public float measureText(String text, int start, int end) {
-        if (!mHasCompatScaling) return native_measureText(text, start, end);
+        if (text == null) {
+            throw new IllegalArgumentException("text cannot be null");
+        }
+        if ((start | end | (end - start) | (text.length() - end)) < 0) {
+            throw new IndexOutOfBoundsException();
+        }
+
+        if (text.length() == 0 || start == end) {
+            return 0f;
+        }
+        if (!mHasCompatScaling) {
+            return native_measureText(text, start, end);
+        }
+
         final float oldSize = getTextSize();
         setTextSize(oldSize*mCompatScaling);
         float w = native_measureText(text, start, end);
@@ -1217,10 +1243,18 @@
     /**
      * Return the width of the text.
      *
-     * @param text  The text to measure
+     * @param text  The text to measure. Cannot be null.
      * @return      The width of the text
      */
     public float measureText(String text) {
+        if (text == null) {
+            throw new IllegalArgumentException("text cannot be null");
+        }
+
+        if (text.length() == 0) {
+            return 0f;
+        }
+
         if (!mHasCompatScaling) return native_measureText(text);
         final float oldSize = getTextSize();
         setTextSize(oldSize*mCompatScaling);
@@ -1240,6 +1274,16 @@
      * @return      The width of the text
      */
     public float measureText(CharSequence text, int start, int end) {
+        if (text == null) {
+            throw new IllegalArgumentException("text cannot be null");
+        }
+        if ((start | end | (end - start) | (text.length() - end)) < 0) {
+            throw new IndexOutOfBoundsException();
+        }
+
+        if (text.length() == 0 || start == end) {
+            return 0f;
+        }
         if (text instanceof String) {
             return measureText((String)text, start, end);
         }
@@ -1263,7 +1307,7 @@
      * Return the number of chars that were measured, and if measuredWidth is
      * not null, return in it the actual width measured.
      *
-     * @param text  The text to measure
+     * @param text  The text to measure. Cannot be null.
      * @param index The offset into text to begin measuring at
      * @param count The number of maximum number of entries to measure. If count
      *              is negative, then the characters are measured in reverse order.
@@ -1275,9 +1319,20 @@
      */
     public int breakText(char[] text, int index, int count,
                                 float maxWidth, float[] measuredWidth) {
+        if (text == null) {
+            throw new IllegalArgumentException("text cannot be null");
+        }
+        if ((index | count) < 0 || index + count > text.length) {
+            throw new ArrayIndexOutOfBoundsException();
+        }
+
+        if (text.length == 0 || count == 0) {
+            return 0;
+        }
         if (!mHasCompatScaling) {
             return native_breakText(text, index, count, maxWidth, measuredWidth);
         }
+
         final float oldSize = getTextSize();
         setTextSize(oldSize*mCompatScaling);
         int res = native_breakText(text, index, count, maxWidth*mCompatScaling,
@@ -1295,7 +1350,7 @@
      * Return the number of chars that were measured, and if measuredWidth is
      * not null, return in it the actual width measured.
      *
-     * @param text  The text to measure
+     * @param text  The text to measure. Cannot be null.
      * @param start The offset into text to begin measuring at
      * @param end   The end of the text slice to measure.
      * @param measureForwards If true, measure forwards, starting at start.
@@ -1309,6 +1364,16 @@
     public int breakText(CharSequence text, int start, int end,
                          boolean measureForwards,
                          float maxWidth, float[] measuredWidth) {
+        if (text == null) {
+            throw new IllegalArgumentException("text cannot be null");
+        }
+        if ((start | end | (end - start) | (text.length() - end)) < 0) {
+            throw new IndexOutOfBoundsException();
+        }
+
+        if (text.length() == 0 || start == end) {
+            return 0;
+        }
         if (start == 0 && text instanceof String && end == text.length()) {
             return breakText((String) text, measureForwards, maxWidth,
                              measuredWidth);
@@ -1334,7 +1399,7 @@
      * Return the number of chars that were measured, and if measuredWidth is
      * not null, return in it the actual width measured.
      *
-     * @param text  The text to measure
+     * @param text  The text to measure. Cannot be null.
      * @param measureForwards If true, measure forwards, starting with the
      *                        first character in the string. Otherwise,
      *                        measure backwards, starting with the
@@ -1347,9 +1412,17 @@
      */
     public int breakText(String text, boolean measureForwards,
                                 float maxWidth, float[] measuredWidth) {
+        if (text == null) {
+            throw new IllegalArgumentException("text cannot be null");
+        }
+
+        if (text.length() == 0) {
+            return 0;
+        }
         if (!mHasCompatScaling) {
             return native_breakText(text, measureForwards, maxWidth, measuredWidth);
         }
+
         final float oldSize = getTextSize();
         setTextSize(oldSize*mCompatScaling);
         int res = native_breakText(text, measureForwards, maxWidth*mCompatScaling,
@@ -1365,7 +1438,7 @@
     /**
      * Return the advance widths for the characters in the string.
      *
-     * @param text     The text to measure
+     * @param text     The text to measure. Cannot be null.
      * @param index    The index of the first char to to measure
      * @param count    The number of chars starting with index to measure
      * @param widths   array to receive the advance widths of the characters.
@@ -1374,14 +1447,21 @@
      */
     public int getTextWidths(char[] text, int index, int count,
                              float[] widths) {
+        if (text == null) {
+            throw new IllegalArgumentException("text cannot be null");
+        }
         if ((index | count) < 0 || index + count > text.length
                 || count > widths.length) {
             throw new ArrayIndexOutOfBoundsException();
         }
-        
+
+        if (text.length == 0 || count == 0) {
+            return 0;
+        }
         if (!mHasCompatScaling) {
             return native_getTextWidths(mNativePaint, text, index, count, widths);
         }
+
         final float oldSize = getTextSize();
         setTextSize(oldSize*mCompatScaling);
         int res = native_getTextWidths(mNativePaint, text, index, count, widths);
@@ -1395,7 +1475,7 @@
     /**
      * Return the advance widths for the characters in the string.
      *
-     * @param text     The text to measure
+     * @param text     The text to measure. Cannot be null.
      * @param start    The index of the first char to to measure
      * @param end      The end of the text slice to measure
      * @param widths   array to receive the advance widths of the characters.
@@ -1404,6 +1484,19 @@
      */
     public int getTextWidths(CharSequence text, int start, int end,
                              float[] widths) {
+        if (text == null) {
+            throw new IllegalArgumentException("text cannot be null");
+        }
+        if ((start | end | (end - start) | (text.length() - end)) < 0) {
+            throw new IndexOutOfBoundsException();
+        }
+        if (end - start > widths.length) {
+            throw new ArrayIndexOutOfBoundsException();
+        }
+
+        if (text.length() == 0 || start == end) {
+            return 0;
+        }
         if (text instanceof String) {
             return getTextWidths((String) text, start, end, widths);
         }
@@ -1426,7 +1519,7 @@
     /**
      * Return the advance widths for the characters in the string.
      *
-     * @param text   The text to measure
+     * @param text   The text to measure. Cannot be null.
      * @param start  The index of the first char to to measure
      * @param end    The end of the text slice to measure
      * @param widths array to receive the advance widths of the characters.
@@ -1434,6 +1527,9 @@
      * @return       the number of unichars in the specified text.
      */
     public int getTextWidths(String text, int start, int end, float[] widths) {
+        if (text == null) {
+            throw new IllegalArgumentException("text cannot be null");
+        }
         if ((start | end | (end - start) | (text.length() - end)) < 0) {
             throw new IndexOutOfBoundsException();
         }
@@ -1441,9 +1537,13 @@
             throw new ArrayIndexOutOfBoundsException();
         }
         
+        if (text.length() == 0 || start == end) {
+            return 0;
+        }
         if (!mHasCompatScaling) {
             return native_getTextWidths(mNativePaint, text, start, end, widths);
         }
+
         final float oldSize = getTextSize();
         setTextSize(oldSize*mCompatScaling);
         int res = native_getTextWidths(mNativePaint, text, start, end, widths);
@@ -1488,6 +1588,12 @@
      */
     public int getTextGlypths(String text, int start, int end, int contextStart, int contextEnd,
             int flags, char[] glyphs) {
+        if (text == null) {
+            throw new IllegalArgumentException("text cannot be null");
+        }
+        if (flags != DIRECTION_LTR && flags != DIRECTION_RTL) {
+            throw new IllegalArgumentException("unknown flags value: " + flags);
+        }
         if ((start | end | contextStart | contextEnd | (end - start)
                 | (start - contextStart) | (contextEnd - end) | (text.length() - end)
                 | (text.length() - contextEnd)) < 0) {
@@ -1496,9 +1602,6 @@
         if (end - start > glyphs.length) {
             throw new ArrayIndexOutOfBoundsException();
         }
-        if (flags != DIRECTION_LTR && flags != DIRECTION_RTL) {
-            throw new IllegalArgumentException("unknown flags value: " + flags);
-        }
         return native_getTextGlyphs(mNativePaint, text, start, end, contextStart, contextEnd,
                 flags, glyphs);
     }
@@ -1528,18 +1631,24 @@
             int contextIndex, int contextCount, int flags, float[] advances,
             int advancesIndex, int reserved) {
 
+        if (chars == null) {
+            throw new IllegalArgumentException("text cannot be null");
+        }
+        if (flags != DIRECTION_LTR && flags != DIRECTION_RTL) {
+            throw new IllegalArgumentException("unknown flags value: " + flags);
+        }
         if ((index | count | contextIndex | contextCount | advancesIndex
-                | (index - contextIndex)
+                | (index - contextIndex) | (contextCount - count)
                 | ((contextIndex + contextCount) - (index + count))
                 | (chars.length - (contextIndex + contextCount))
                 | (advances == null ? 0 :
                     (advances.length - (advancesIndex + count)))) < 0) {
             throw new IndexOutOfBoundsException();
         }
-        if (flags != DIRECTION_LTR && flags != DIRECTION_RTL) {
-            throw new IllegalArgumentException("unknown flags value: " + flags);
-        }
 
+        if (chars.length == 0 || count == 0){
+            return 0f;
+        }
         if (!mHasCompatScaling) {
             return native_getTextRunAdvances(mNativePaint, chars, index, count,
                     contextIndex, contextCount, flags, advances, advancesIndex, reserved);
@@ -1584,6 +1693,17 @@
             int contextStart, int contextEnd, int flags, float[] advances,
             int advancesIndex, int reserved) {
 
+        if (text == null) {
+            throw new IllegalArgumentException("text cannot be null");
+        }
+        if ((start | end | contextStart | contextEnd | advancesIndex | (end - start)
+                | (start - contextStart) | (contextEnd - end)
+                | (text.length() - contextEnd)
+                | (advances == null ? 0 :
+                    (advances.length - advancesIndex - (end - start)))) < 0) {
+            throw new IndexOutOfBoundsException();
+        }
+
         if (text instanceof String) {
             return getTextRunAdvances((String) text, start, end,
                     contextStart, contextEnd, flags, advances, advancesIndex, reserved);
@@ -1597,6 +1717,9 @@
             return ((GraphicsOperations) text).getTextRunAdvances(start, end,
                     contextStart, contextEnd, flags, advances, advancesIndex, this);
         }
+        if (text.length() == 0 || end == start) {
+            return 0f;
+        }
 
         int contextLen = contextEnd - contextStart;
         int len = end - start;
@@ -1633,7 +1756,7 @@
      * These bounds typically reflect changes in bidi level or font
      * metrics across which shaping does not occur.
      *
-     * @param text the text to measure
+     * @param text the text to measure. Cannot be null.
      * @param start the index of the first character to measure
      * @param end the index past the last character to measure
      * @param contextStart the index of the first character to use for shaping context,
@@ -1681,7 +1804,7 @@
      * These bounds typically reflect changes in bidi level or font
      * metrics across which shaping does not occur.
      *
-     * @param text the text to measure
+     * @param text the text to measure. Cannot be null.
      * @param start the index of the first character to measure
      * @param end the index past the last character to measure
      * @param contextStart the index of the first character to use for shaping context,
@@ -1702,6 +1825,12 @@
     public float getTextRunAdvances(String text, int start, int end, int contextStart,
             int contextEnd, int flags, float[] advances, int advancesIndex, int reserved) {
 
+        if (text == null) {
+            throw new IllegalArgumentException("text cannot be null");
+        }
+        if (flags != DIRECTION_LTR && flags != DIRECTION_RTL) {
+            throw new IllegalArgumentException("unknown flags value: " + flags);
+        }
         if ((start | end | contextStart | contextEnd | advancesIndex | (end - start)
                 | (start - contextStart) | (contextEnd - end)
                 | (text.length() - contextEnd)
@@ -1709,8 +1838,9 @@
                     (advances.length - advancesIndex - (end - start)))) < 0) {
             throw new IndexOutOfBoundsException();
         }
-        if (flags != DIRECTION_LTR && flags != DIRECTION_RTL) {
-            throw new IllegalArgumentException("unknown flags value: " + flags);
+
+        if (text.length() == 0 || start == end) {
+            return 0f;
         }
 
         if (!mHasCompatScaling) {
diff --git a/graphics/java/android/renderscript/RSTextureView.java b/graphics/java/android/renderscript/RSTextureView.java
index b8dd577..30b2f99 100644
--- a/graphics/java/android/renderscript/RSTextureView.java
+++ b/graphics/java/android/renderscript/RSTextureView.java
@@ -85,13 +85,15 @@
     }
 
     @Override
-    public void onSurfaceTextureDestroyed(SurfaceTexture surface) {
+    public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
         //Log.e(RenderScript.LOG_TAG, "onSurfaceTextureDestroyed");
         mSurfaceTexture = surface;
 
         if (mRS != null) {
             mRS.setSurfaceTexture(null, 0, 0);
         }
+
+        return true;
     }
 
     @Override
diff --git a/include/gui/ISurfaceTexture.h b/include/gui/ISurfaceTexture.h
index 1eda646..50626a0 100644
--- a/include/gui/ISurfaceTexture.h
+++ b/include/gui/ISurfaceTexture.h
@@ -111,7 +111,12 @@
     //
     // This method will fail if the connect was previously called on the
     // SurfaceTexture and no corresponding disconnect call was made.
-    virtual status_t connect(int api) = 0;
+    //
+    // outWidth, outHeight and outTransform are filled with the default width
+    // and height of the window and current transform applied to buffers,
+    // respectively.
+    virtual status_t connect(int api,
+            uint32_t* outWidth, uint32_t* outHeight, uint32_t* outTransform) = 0;
 
     // disconnect attempts to disconnect a client API from the SurfaceTexture.
     // Calling this method will cause any subsequent calls to other
diff --git a/include/gui/SurfaceTexture.h b/include/gui/SurfaceTexture.h
index 2a8e725..3f9e68d 100644
--- a/include/gui/SurfaceTexture.h
+++ b/include/gui/SurfaceTexture.h
@@ -106,7 +106,8 @@
     //
     // This method will fail if the connect was previously called on the
     // SurfaceTexture and no corresponding disconnect call was made.
-    virtual status_t connect(int api);
+    virtual status_t connect(int api,
+            uint32_t* outWidth, uint32_t* outHeight, uint32_t* outTransform);
 
     // disconnect attempts to disconnect a client API from the SurfaceTexture.
     // Calling this method will cause any subsequent calls to other
diff --git a/include/media/stagefright/SurfaceMediaSource.h b/include/media/stagefright/SurfaceMediaSource.h
index fab258c..1affb8a 100644
--- a/include/media/stagefright/SurfaceMediaSource.h
+++ b/include/media/stagefright/SurfaceMediaSource.h
@@ -133,7 +133,8 @@
     //
     // This method will fail if the connect was previously called on the
     // SurfaceMediaSource and no corresponding disconnect call was made.
-    virtual status_t connect(int api);
+    virtual status_t connect(int api,
+            uint32_t* outWidth, uint32_t* outHeight, uint32_t* outTransform);
 
     // disconnect attempts to disconnect a client API from the SurfaceMediaSource.
     // Calling this method will cause any subsequent calls to other
diff --git a/libs/gui/ISurfaceTexture.cpp b/libs/gui/ISurfaceTexture.cpp
index 55246dc..babd2c0 100644
--- a/libs/gui/ISurfaceTexture.cpp
+++ b/libs/gui/ISurfaceTexture.cpp
@@ -162,11 +162,15 @@
         return result;
     }
 
-    virtual status_t connect(int api) {
+    virtual status_t connect(int api,
+            uint32_t* outWidth, uint32_t* outHeight, uint32_t* outTransform) {
         Parcel data, reply;
         data.writeInterfaceToken(ISurfaceTexture::getInterfaceDescriptor());
         data.writeInt32(api);
         remote()->transact(CONNECT, data, &reply);
+        *outWidth = reply.readInt32();
+        *outHeight = reply.readInt32();
+        *outTransform = reply.readInt32();
         status_t result = reply.readInt32();
         return result;
     }
@@ -283,7 +287,12 @@
         case CONNECT: {
             CHECK_INTERFACE(ISurfaceTexture, data, reply);
             int api = data.readInt32();
-            status_t res = connect(api);
+            uint32_t outWidth, outHeight, outTransform;
+            status_t res = connect(api,
+                    &outWidth, &outHeight, &outTransform);
+            reply->writeInt32(outWidth);
+            reply->writeInt32(outHeight);
+            reply->writeInt32(outTransform);
             reply->writeInt32(res);
             return NO_ERROR;
         } break;
diff --git a/libs/gui/SurfaceTexture.cpp b/libs/gui/SurfaceTexture.cpp
index be71c94..4bbf7eb 100644
--- a/libs/gui/SurfaceTexture.cpp
+++ b/libs/gui/SurfaceTexture.cpp
@@ -548,7 +548,8 @@
     return OK;
 }
 
-status_t SurfaceTexture::connect(int api) {
+status_t SurfaceTexture::connect(int api,
+        uint32_t* outWidth, uint32_t* outHeight, uint32_t* outTransform) {
     LOGV("SurfaceTexture::connect(this=%p, %d)", this, api);
     Mutex::Autolock lock(mMutex);
 
@@ -569,6 +570,9 @@
                 err = -EINVAL;
             } else {
                 mConnectedApi = api;
+                *outWidth = mDefaultWidth;
+                *outHeight = mDefaultHeight;
+                *outTransform = 0;
             }
             break;
         default:
@@ -595,6 +599,7 @@
         case NATIVE_WINDOW_API_CAMERA:
             if (mConnectedApi == api) {
                 mConnectedApi = NO_CONNECTED_API;
+                freeAllBuffers();
             } else {
                 LOGE("disconnect: connected to another api (cur=%d, req=%d)",
                         mConnectedApi, api);
@@ -981,19 +986,25 @@
 
     for (int i=0 ; i<mBufferCount ; i++) {
         const BufferSlot& slot(mSlots[i]);
-        const sp<GraphicBuffer>& buf(slot.mGraphicBuffer);
         snprintf(buffer, SIZE,
                 "%s%s[%02d] "
-                "%p [%4ux%4u:%4u,%3X] "
                 "state=%-8s, crop=[%d,%d,%d,%d], "
-                "transform=0x%02x, timestamp=%lld\n",
+                "transform=0x%02x, timestamp=%lld",
                 prefix, (i==mCurrentTexture)?">":" ", i,
-                buf->handle, buf->width, buf->height, buf->stride, buf->format,
                 stateName(slot.mBufferState),
                 slot.mCrop.left, slot.mCrop.top, slot.mCrop.right, slot.mCrop.bottom,
                 slot.mTransform, slot.mTimestamp
         );
         result.append(buffer);
+
+        const sp<GraphicBuffer>& buf(slot.mGraphicBuffer);
+        if (buf != NULL) {
+            snprintf(buffer, SIZE,
+                    ", %p [%4ux%4u:%4u,%3X]",
+                    buf->handle, buf->width, buf->height, buf->stride, buf->format);
+            result.append(buffer);
+        }
+        result.append("\n");
     }
 }
 
diff --git a/libs/gui/SurfaceTextureClient.cpp b/libs/gui/SurfaceTextureClient.cpp
index d1037de..e91be84 100644
--- a/libs/gui/SurfaceTextureClient.cpp
+++ b/libs/gui/SurfaceTextureClient.cpp
@@ -385,7 +385,8 @@
 int SurfaceTextureClient::connect(int api) {
     LOGV("SurfaceTextureClient::connect");
     Mutex::Autolock lock(mMutex);
-    int err = mSurfaceTexture->connect(api);
+    int err = mSurfaceTexture->connect(api,
+            &mDefaultWidth, &mDefaultHeight, &mTransformHint);
     if (!err && api == NATIVE_WINDOW_API_CPU) {
         mConnectedToCpu = true;
     }
diff --git a/libs/rs/scriptc/rs_allocation.rsh b/libs/rs/scriptc/rs_allocation.rsh
new file mode 100644
index 0000000..1e755cd
--- /dev/null
+++ b/libs/rs/scriptc/rs_allocation.rsh
@@ -0,0 +1,144 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/** @file rs_allocation.rsh
+ *  \brief Allocation routines
+ *
+ *
+ */
+
+#ifndef __RS_ALLOCATION_RSH__
+#define __RS_ALLOCATION_RSH__
+
+/**
+ * Returns the Allocation for a given pointer.  The pointer should point within
+ * a valid allocation.  The results are undefined if the pointer is not from a
+ * valid allocation.
+ */
+extern rs_allocation __attribute__((overloadable))
+    rsGetAllocation(const void *);
+
+/**
+ * Query the dimension of an allocation.
+ *
+ * @return uint32_t The X dimension of the allocation.
+ */
+extern uint32_t __attribute__((overloadable))
+    rsAllocationGetDimX(rs_allocation);
+
+/**
+ * Query the dimension of an allocation.
+ *
+ * @return uint32_t The Y dimension of the allocation.
+ */
+extern uint32_t __attribute__((overloadable))
+    rsAllocationGetDimY(rs_allocation);
+
+/**
+ * Query the dimension of an allocation.
+ *
+ * @return uint32_t The Z dimension of the allocation.
+ */
+extern uint32_t __attribute__((overloadable))
+    rsAllocationGetDimZ(rs_allocation);
+
+/**
+ * Query an allocation for the presence of more than one LOD.
+ *
+ * @return uint32_t Returns 1 if more than one LOD is present, 0 otherwise.
+ */
+extern uint32_t __attribute__((overloadable))
+    rsAllocationGetDimLOD(rs_allocation);
+
+/**
+ * Query an allocation for the presence of more than one face.
+ *
+ * @return uint32_t Returns 1 if more than one face is present, 0 otherwise.
+ */
+extern uint32_t __attribute__((overloadable))
+    rsAllocationGetDimFaces(rs_allocation);
+
+/**
+ * Copy part of an allocation from another allocation.
+ *
+ * @param dstAlloc Allocation to copy data into.
+ * @param dstOff The offset of the first element to be copied in
+ *               the destination allocation.
+ * @param dstMip Mip level in the destination allocation.
+ * @param count The number of elements to be copied.
+ * @param srcAlloc The source data allocation.
+ * @param srcOff The offset of the first element in data to be
+ *               copied in the source allocation.
+ * @param srcMip Mip level in the source allocation.
+ */
+extern void __attribute__((overloadable))
+    rsAllocationCopy1DRange(rs_allocation dstAlloc,
+                            uint32_t dstOff, uint32_t dstMip,
+                            uint32_t count,
+                            rs_allocation srcAlloc,
+                            uint32_t srcOff, uint32_t srcMip);
+
+/**
+ * Copy a rectangular region into the allocation from another
+ * allocation.
+ *
+ * @param dstAlloc allocation to copy data into.
+ * @param dstXoff X offset of the region to update in the
+ *                destination allocation.
+ * @param dstYoff Y offset of the region to update in the
+ *                destination allocation.
+ * @param dstMip Mip level in the destination allocation.
+ * @param dstFace Cubemap face of the destination allocation,
+ *                ignored for allocations that aren't cubemaps.
+ * @param width Width of the incoming region to update.
+ * @param height Height of the incoming region to update.
+ * @param srcAlloc The source data allocation.
+ * @param srcXoff X offset in data of the source allocation.
+ * @param srcYoff Y offset in data of the source allocation.
+ * @param srcMip Mip level in the source allocation.
+ * @param srcFace Cubemap face of the source allocation,
+ *                ignored for allocations that aren't cubemaps.
+ */
+extern void __attribute__((overloadable))
+    rsAllocationCopy2DRange(rs_allocation dstAlloc,
+                            uint32_t dstXoff, uint32_t dstYoff,
+                            uint32_t dstMip,
+                            rs_allocation_cubemap_face dstFace,
+                            uint32_t width, uint32_t height,
+                            rs_allocation srcAlloc,
+                            uint32_t srcXoff, uint32_t srcYoff,
+                            uint32_t srcMip,
+                            rs_allocation_cubemap_face srcFace);
+
+
+/**
+ * Extract a single element from an allocation.
+ */
+extern const void * __attribute__((overloadable))
+    rsGetElementAt(rs_allocation, uint32_t x);
+/**
+ * \overload
+ */
+extern const void * __attribute__((overloadable))
+    rsGetElementAt(rs_allocation, uint32_t x, uint32_t y);
+/**
+ * \overload
+ */
+extern const void * __attribute__((overloadable))
+    rsGetElementAt(rs_allocation, uint32_t x, uint32_t y, uint32_t z);
+
+#endif
+
diff --git a/libs/rs/scriptc/rs_atomic.rsh b/libs/rs/scriptc/rs_atomic.rsh
new file mode 100644
index 0000000..95513ad
--- /dev/null
+++ b/libs/rs/scriptc/rs_atomic.rsh
@@ -0,0 +1,248 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/** @file rs_atomic.rsh
+ *  \brief Atomic routines
+ *
+ *
+ */
+
+#ifndef __RS_ATOMIC_RSH__
+#define __RS_ATOMIC_RSH__
+
+
+/**
+ * Atomic add one to the value at addr.
+ * Equal to rsAtomicAdd(addr, 1)
+ *
+ * @param addr Address of value to increment
+ *
+ * @return old value
+ */
+extern int32_t __attribute__((overloadable))
+    rsAtomicInc(volatile int32_t* addr);
+/**
+ * Atomic add one to the value at addr.
+ * Equal to rsAtomicAdd(addr, 1)
+ *
+ * @param addr Address of value to increment
+ *
+ * @return old value
+ */
+extern uint32_t __attribute__((overloadable))
+    rsAtomicInc(volatile uint32_t* addr);
+
+/**
+ * Atomic subtract one from the value at addr. Equal to rsAtomicSub(addr, 1)
+ *
+ * @param addr Address of value to decrement
+ *
+ * @return old value
+ */
+extern int32_t __attribute__((overloadable))
+    rsAtomicDec(volatile int32_t* addr);
+/**
+ * Atomic subtract one from the value at addr. Equal to rsAtomicSub(addr, 1)
+ *
+ * @param addr Address of value to decrement
+ *
+ * @return old value
+ */
+extern uint32_t __attribute__((overloadable))
+    rsAtomicDec(volatile uint32_t* addr);
+
+/**
+ * Atomic add a value to the value at addr.  addr[0] += value
+ *
+ * @param addr Address of value to modify
+ * @param value Amount to add to the value at addr
+ *
+ * @return old value
+ */
+extern int32_t __attribute__((overloadable))
+    rsAtomicAdd(volatile int32_t* addr, int32_t value);
+/**
+ * Atomic add a value to the value at addr.  addr[0] += value
+ *
+ * @param addr Address of value to modify
+ * @param value Amount to add to the value at addr
+ *
+ * @return old value
+ */
+extern uint32_t __attribute__((overloadable))
+    rsAtomicAdd(volatile uint32_t* addr, uint32_t value);
+
+/**
+ * Atomic Subtract a value from the value at addr.  addr[0] -= value
+ *
+ * @param addr Address of value to modify
+ * @param value Amount to subtract from the value at addr
+ *
+ * @return old value
+ */
+extern int32_t __attribute__((overloadable))
+    rsAtomicSub(volatile int32_t* addr, int32_t value);
+/**
+ * Atomic Subtract a value from the value at addr.  addr[0] -= value
+ *
+ * @param addr Address of value to modify
+ * @param value Amount to subtract from the value at addr
+ *
+ * @return old value
+ */
+extern uint32_t __attribute__((overloadable))
+    rsAtomicSub(volatile uint32_t* addr, uint32_t value);
+
+/**
+ * Atomic Bitwise and a value from the value at addr.  addr[0] &= value
+ *
+ * @param addr Address of value to modify
+ * @param value Amount to and with the value at addr
+ *
+ * @return old value
+ */
+extern int32_t __attribute__((overloadable))
+    rsAtomicAnd(volatile int32_t* addr, int32_t value);
+/**
+ * Atomic Bitwise and a value from the value at addr.  addr[0] &= value
+ *
+ * @param addr Address of value to modify
+ * @param value Amount to and with the value at addr
+ *
+ * @return old value
+ */
+extern uint32_t __attribute__((overloadable))
+    rsAtomicAnd(volatile uint32_t* addr, uint32_t value);
+
+/**
+ * Atomic Bitwise or a value from the value at addr.  addr[0] |= value
+ *
+ * @param addr Address of value to modify
+ * @param value Amount to or with the value at addr
+ *
+ * @return old value
+ */
+extern int32_t __attribute__((overloadable))
+    rsAtomicOr(volatile int32_t* addr, int32_t value);
+/**
+ * Atomic Bitwise or a value from the value at addr.  addr[0] |= value
+ *
+ * @param addr Address of value to modify
+ * @param value Amount to or with the value at addr
+ *
+ * @return old value
+ */
+extern uint32_t __attribute__((overloadable))
+    rsAtomicOr(volatile uint32_t* addr, uint32_t value);
+
+/**
+ * Atomic Bitwise xor a value from the value at addr.  addr[0] ^= value
+ *
+ * @param addr Address of value to modify
+ * @param value Amount to xor with the value at addr
+ *
+ * @return old value
+ */
+extern uint32_t __attribute__((overloadable))
+    rsAtomicXor(volatile uint32_t* addr, uint32_t value);
+/**
+ * Atomic Bitwise xor a value from the value at addr.  addr[0] ^= value
+ *
+ * @param addr Address of value to modify
+ * @param value Amount to xor with the value at addr
+ *
+ * @return old value
+ */
+extern int32_t __attribute__((overloadable))
+    rsAtomicXor(volatile int32_t* addr, int32_t value);
+
+/**
+ * Atomic Set the value at addr to the min of addr and value
+ * addr[0] = rsMin(addr[0], value)
+ *
+ * @param addr Address of value to modify
+ * @param value comparison value
+ *
+ * @return old value
+ */
+extern uint32_t __attribute__((overloadable))
+    rsAtomicMin(volatile uint32_t* addr, uint32_t value);
+/**
+ * Atomic Set the value at addr to the min of addr and value
+ * addr[0] = rsMin(addr[0], value)
+ *
+ * @param addr Address of value to modify
+ * @param value comparison value
+ *
+ * @return old value
+ */
+extern int32_t __attribute__((overloadable))
+    rsAtomicMin(volatile int32_t* addr, int32_t value);
+
+/**
+ * Atomic Set the value at addr to the max of addr and value
+ * addr[0] = rsMax(addr[0], value)
+ *
+ * @param addr Address of value to modify
+ * @param value comparison value
+ *
+ * @return old value
+ */
+extern uint32_t __attribute__((overloadable))
+    rsAtomicMax(volatile uint32_t* addr, uint32_t value);
+/**
+ * Atomic Set the value at addr to the max of addr and value
+ * addr[0] = rsMin(addr[0], value)
+ *
+ * @param addr Address of value to modify
+ * @param value comparison value
+ *
+ * @return old value
+ */
+extern int32_t __attribute__((overloadable))
+    rsAtomicMax(volatile int32_t* addr, int32_t value);
+
+/**
+ * Compare-and-set operation with a full memory barrier.
+ *
+ * If the value at addr matches compareValue then newValue is written.
+ *
+ * @param addr The address to compare and replace if the compare passes.
+ * @param compareValue The value to test addr[0] against.
+ * @param newValue The value to write if the test passes.
+ *
+ * @return old value
+ */
+extern int32_t __attribute__((overloadable))
+    rsAtomicCas(volatile int32_t* addr, int32_t compareValue, int32_t newValue);
+
+/**
+ * Compare-and-set operation with a full memory barrier.
+ *
+ * If the value at addr matches compareValue then newValue is written.
+ *
+ * @param addr The address to compare and replace if the compare passes.
+ * @param compareValue The value to test addr[0] against.
+ * @param newValue The value to write if the test passes.
+ *
+ * @return old value
+ */
+extern uint32_t __attribute__((overloadable))
+    rsAtomicCas(volatile uint32_t* addr, int32_t compareValue, int32_t newValue);
+
+
+#endif
+
diff --git a/libs/rs/scriptc/rs_cl.rsh b/libs/rs/scriptc/rs_cl.rsh
index d78e62e..e402b86 100644
--- a/libs/rs/scriptc/rs_cl.rsh
+++ b/libs/rs/scriptc/rs_cl.rsh
@@ -1,8 +1,28 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/** @file rs_cl.rsh
+ *  \brief Additional compute routines
+ *
+ *
+ */
+
 #ifndef __RS_CL_RSH__
 #define __RS_CL_RSH__
 
-#define _RS_RUNTIME  extern
-
 // Conversions
 #define CVT_FUNC_2(typeout, typein)                             \
 _RS_RUNTIME typeout##2 __attribute__((overloadable))             \
@@ -444,6 +464,5 @@
 #undef IN_FUNC_IN
 #undef XN_FUNC_XN_XN_BODY
 #undef IN_FUNC_IN_IN_BODY
-#undef _RS_RUNTIME
 
 #endif
diff --git a/libs/rs/scriptc/rs_core.rsh b/libs/rs/scriptc/rs_core.rsh
index 1583090..be900cb 100644
--- a/libs/rs/scriptc/rs_core.rsh
+++ b/libs/rs/scriptc/rs_core.rsh
@@ -1,889 +1,166 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 /** @file rs_core.rsh
  *  \brief todo-jsams
  *
  *  todo-jsams
  *
  */
+
 #ifndef __RS_CORE_RSH__
 #define __RS_CORE_RSH__
 
 #define _RS_RUNTIME extern
 
-/**
- * Debug function.  Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
-    rsDebug(const char *, float);
-/**
- * Debug function.  Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
-    rsDebug(const char *, float, float);
-/**
- * Debug function.  Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
-    rsDebug(const char *, float, float, float);
-/**
- * Debug function.  Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
-    rsDebug(const char *, float, float, float, float);
-/**
- * Debug function.  Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
-    rsDebug(const char *, double);
-/**
- * Debug function.  Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
-    rsDebug(const char *, const rs_matrix4x4 *);
-/**
- * Debug function.  Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
-    rsDebug(const char *, const rs_matrix3x3 *);
-/**
- * Debug function.  Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
-    rsDebug(const char *, const rs_matrix2x2 *);
-/**
- * Debug function.  Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
-    rsDebug(const char *, int);
-/**
- * Debug function.  Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
-    rsDebug(const char *, uint);
-/**
- * Debug function.  Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
-    rsDebug(const char *, long);
-/**
- * Debug function.  Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
-    rsDebug(const char *, unsigned long);
-/**
- * Debug function.  Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
-    rsDebug(const char *, long long);
-/**
- * Debug function.  Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
-    rsDebug(const char *, unsigned long long);
-/**
- * Debug function.  Prints a string and value to the log.
- */
-extern void __attribute__((overloadable))
-    rsDebug(const char *, const void *);
-#define RS_DEBUG(a) rsDebug(#a, a)
-#define RS_DEBUG_MARKER rsDebug(__FILE__, __LINE__)
+#include "rs_types.rsh"
+#include "rs_allocation.rsh"
+#include "rs_atomic.rsh"
+#include "rs_cl.rsh"
+#include "rs_debug.rsh"
+#include "rs_math.rsh"
+#include "rs_matrix.rsh"
+#include "rs_object.rsh"
+#include "rs_quaternion.rsh"
+#include "rs_time.rsh"
+
 
 
 /**
- * Debug function.  Prints a string and value to the log.
+ * Send a message back to the client.  Will not block and returns true
+ * if the message was sendable and false if the fifo was full.
+ * A message ID is required.  Data payload is optional.
  */
-_RS_RUNTIME void __attribute__((overloadable)) rsDebug(const char *s, float2 v);
-/**
- * Debug function.  Prints a string and value to the log.
- */
-_RS_RUNTIME void __attribute__((overloadable)) rsDebug(const char *s, float3 v);
-/**
- * Debug function.  Prints a string and value to the log.
- */
-_RS_RUNTIME void __attribute__((overloadable)) rsDebug(const char *s, float4 v);
-
-
-/**
- * Pack floating point (0-1) RGB values into a uchar4.  The alpha component is
- * set to 255 (1.0).
- *
- * @param r
- * @param g
- * @param b
- *
- * @return uchar4
- */
-_RS_RUNTIME uchar4 __attribute__((overloadable)) rsPackColorTo8888(float r, float g, float b);
-
-/**
- * Pack floating point (0-1) RGBA values into a uchar4.
- *
- * @param r
- * @param g
- * @param b
- * @param a
- *
- * @return uchar4
- */
-_RS_RUNTIME uchar4 __attribute__((overloadable)) rsPackColorTo8888(float r, float g, float b, float a);
-
-/**
- * Pack floating point (0-1) RGB values into a uchar4.  The alpha component is
- * set to 255 (1.0).
- *
- * @param color
- *
- * @return uchar4
- */
-_RS_RUNTIME uchar4 __attribute__((overloadable)) rsPackColorTo8888(float3 color);
-
-/**
- * Pack floating point (0-1) RGBA values into a uchar4.
- *
- * @param color
- *
- * @return uchar4
- */
-_RS_RUNTIME uchar4 __attribute__((overloadable)) rsPackColorTo8888(float4 color);
-
-/**
- * Unpack a uchar4 color to float4.  The resulting float range will be (0-1).
- *
- * @param c
- *
- * @return float4
- */
-_RS_RUNTIME float4 rsUnpackColor8888(uchar4 c);
-
-
-/////////////////////////////////////////////////////
-// Matrix ops
-/////////////////////////////////////////////////////
-
-/**
- * Set one element of a matrix.
- *
- * @param m The matrix to be set
- * @param row
- * @param col
- * @param v
- *
- * @return void
- */
-_RS_RUNTIME void __attribute__((overloadable))
-rsMatrixSet(rs_matrix4x4 *m, uint32_t row, uint32_t col, float v);
+extern bool __attribute__((overloadable))
+    rsSendToClient(int cmdID);
 /**
  * \overload
  */
-_RS_RUNTIME void __attribute__((overloadable))
-rsMatrixSet(rs_matrix3x3 *m, uint32_t row, uint32_t col, float v);
+extern bool __attribute__((overloadable))
+    rsSendToClient(int cmdID, const void *data, uint len);
 /**
- * \overload
- */
-_RS_RUNTIME void __attribute__((overloadable))
-rsMatrixSet(rs_matrix2x2 *m, uint32_t row, uint32_t col, float v);
-
-/**
- * Get one element of a matrix.
- *
- * @param m The matrix to read from
- * @param row
- * @param col
- *
- * @return float
- */
-_RS_RUNTIME float __attribute__((overloadable))
-rsMatrixGet(const rs_matrix4x4 *m, uint32_t row, uint32_t col);
-/**
- * \overload
- */
-_RS_RUNTIME float __attribute__((overloadable))
-rsMatrixGet(const rs_matrix3x3 *m, uint32_t row, uint32_t col);
-/**
- * \overload
- */
-_RS_RUNTIME float __attribute__((overloadable))
-rsMatrixGet(const rs_matrix2x2 *m, uint32_t row, uint32_t col);
-
-/**
- * Set the elements of a matrix to the identity matrix.
- *
- * @param m
- */
-extern void __attribute__((overloadable)) rsMatrixLoadIdentity(rs_matrix4x4 *m);
-/**
- * \overload
- */
-extern void __attribute__((overloadable)) rsMatrixLoadIdentity(rs_matrix3x3 *m);
-/**
- * \overload
- */
-extern void __attribute__((overloadable)) rsMatrixLoadIdentity(rs_matrix2x2 *m);
-
-/**
- * Set the elements of a matrix from an array of floats.
- *
- * @param m
- */
-extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix4x4 *m, const float *v);
-/**
- * \overload
- */
-extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix3x3 *m, const float *v);
-/**
- * \overload
- */
-extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix2x2 *m, const float *v);
-/**
- * \overload
- */
-extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix4x4 *m, const rs_matrix4x4 *v);
-/**
- * \overload
- */
-extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix4x4 *m, const rs_matrix3x3 *v);
-
-/**
- * Set the elements of a matrix from another matrix.
- *
- * @param m
- */
-extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix4x4 *m, const rs_matrix2x2 *v);
-/**
- * \overload
- */
-extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix3x3 *m, const rs_matrix3x3 *v);
-/**
- * \overload
- */
-extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix2x2 *m, const rs_matrix2x2 *v);
-
-/**
- * Load a rotation matrix.
- *
- * @param m
- * @param rot
- * @param x
- * @param y
- * @param z
+ * Send a message back to the client, blocking until the message is queued.
+ * A message ID is required.  Data payload is optional.
  */
 extern void __attribute__((overloadable))
-rsMatrixLoadRotate(rs_matrix4x4 *m, float rot, float x, float y, float z);
-
-/**
- * Load a scale matrix.
- *
- * @param m
- * @param x
- * @param y
- * @param z
- */
-extern void __attribute__((overloadable))
-rsMatrixLoadScale(rs_matrix4x4 *m, float x, float y, float z);
-
-/**
- * Load a translation matrix.
- *
- * @param m
- * @param x
- * @param y
- * @param z
- */
-extern void __attribute__((overloadable))
-rsMatrixLoadTranslate(rs_matrix4x4 *m, float x, float y, float z);
-
-/**
- * Multiply two matrix (lhs, rhs) and place the result in m.
- *
- * @param m
- * @param lhs
- * @param rhs
- */
-extern void __attribute__((overloadable))
-rsMatrixLoadMultiply(rs_matrix4x4 *m, const rs_matrix4x4 *lhs, const rs_matrix4x4 *rhs);
+    rsSendToClientBlocking(int cmdID);
 /**
  * \overload
  */
 extern void __attribute__((overloadable))
-rsMatrixLoadMultiply(rs_matrix3x3 *m, const rs_matrix3x3 *lhs, const rs_matrix3x3 *rhs);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
-rsMatrixLoadMultiply(rs_matrix2x2 *m, const rs_matrix2x2 *lhs, const rs_matrix2x2 *rhs);
+    rsSendToClientBlocking(int cmdID, const void *data, uint len);
+
 
 /**
- * Multiply the matrix m by rhs and place the result back into m.
+ * Launch order hint for rsForEach calls.  This provides a hint to the system to
+ * determine in which order the root function of the target is called with each
+ * cell of the allocation.
  *
- * @param m (lhs)
- * @param rhs
+ * This is a hint and implementations may not obey the order.
  */
-extern void __attribute__((overloadable))
-rsMatrixMultiply(rs_matrix4x4 *m, const rs_matrix4x4 *rhs);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
-rsMatrixMultiply(rs_matrix3x3 *m, const rs_matrix3x3 *rhs);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
-rsMatrixMultiply(rs_matrix2x2 *m, const rs_matrix2x2 *rhs);
+enum rs_for_each_strategy {
+    RS_FOR_EACH_STRATEGY_SERIAL,
+    RS_FOR_EACH_STRATEGY_DONT_CARE,
+    RS_FOR_EACH_STRATEGY_DST_LINEAR,
+    RS_FOR_EACH_STRATEGY_TILE_SMALL,
+    RS_FOR_EACH_STRATEGY_TILE_MEDIUM,
+    RS_FOR_EACH_STRATEGY_TILE_LARGE
+};
+
 
 /**
- * Multiple matrix m with a rotation matrix
+ * Structure to provide extra information to a rsForEach call.  Primarly used to
+ * restrict the call to a subset of cells in the allocation.
+ */
+typedef struct rs_script_call {
+    enum rs_for_each_strategy strategy;
+    uint32_t xStart;
+    uint32_t xEnd;
+    uint32_t yStart;
+    uint32_t yEnd;
+    uint32_t zStart;
+    uint32_t zEnd;
+    uint32_t arrayStart;
+    uint32_t arrayEnd;
+} rs_script_call_t;
+
+/**
+ * Make a script to script call to launch work. One of the input or output is
+ * required to be a valid object. The input and output must be of the same
+ * dimensions.
+ * API 10-13
  *
- * @param m
- * @param rot
- * @param x
- * @param y
- * @param z
- */
-extern void __attribute__((overloadable))
-rsMatrixRotate(rs_matrix4x4 *m, float rot, float x, float y, float z);
-
-/**
- * Multiple matrix m with a scale matrix
+ * @param script The target script to call
+ * @param input The allocation to source data from
+ * @param output the allocation to write date into
+ * @param usrData The user definied params to pass to the root script.  May be
+ *                NULL.
+ * @param sc Extra control infomation used to select a sub-region of the
+ *           allocation to be processed or suggest a walking strategy.  May be
+ *           NULL.
  *
- * @param m
- * @param x
- * @param y
- * @param z
- */
-extern void __attribute__((overloadable))
-rsMatrixScale(rs_matrix4x4 *m, float x, float y, float z);
-
-/**
- * Multiple matrix m with a translation matrix
- *
- * @param m
- * @param x
- * @param y
- * @param z
- */
-extern void __attribute__((overloadable))
-rsMatrixTranslate(rs_matrix4x4 *m, float x, float y, float z);
-
-/**
- * Load an Ortho projection matrix constructed from the 6 planes
- *
- * @param m
- * @param left
- * @param right
- * @param bottom
- * @param top
- * @param near
- * @param far
- */
-extern void __attribute__((overloadable))
-rsMatrixLoadOrtho(rs_matrix4x4 *m, float left, float right, float bottom, float top, float near, float far);
-
-/**
- * Load an Frustum projection matrix constructed from the 6 planes
- *
- * @param m
- * @param left
- * @param right
- * @param bottom
- * @param top
- * @param near
- * @param far
- */
-extern void __attribute__((overloadable))
-rsMatrixLoadFrustum(rs_matrix4x4 *m, float left, float right, float bottom, float top, float near, float far);
-
-/**
- * Load an perspective projection matrix constructed from the 6 planes
- *
- * @param m
- * @param fovy Field of view, in degrees along the Y axis.
- * @param aspect Ratio of x / y.
- * @param near
- * @param far
- */
-extern void __attribute__((overloadable))
-rsMatrixLoadPerspective(rs_matrix4x4* m, float fovy, float aspect, float near, float far);
-
+ *  */
 #if !defined(RS_VERSION) || (RS_VERSION < 14)
-/**
- * Multiply a vector by a matrix and return the result vector.
- * API version 10-13
- */
-_RS_RUNTIME float4 __attribute__((overloadable))
-rsMatrixMultiply(rs_matrix4x4 *m, float4 in);
-
+extern void __attribute__((overloadable))
+    rsForEach(rs_script script, rs_allocation input,
+              rs_allocation output, const void * usrData,
+              const rs_script_call_t *sc);
 /**
  * \overload
  */
-_RS_RUNTIME float4 __attribute__((overloadable))
-rsMatrixMultiply(rs_matrix4x4 *m, float3 in);
-
-/**
- * \overload
- */
-_RS_RUNTIME float4 __attribute__((overloadable))
-rsMatrixMultiply(rs_matrix4x4 *m, float2 in);
-
-/**
- * \overload
- */
-_RS_RUNTIME float3 __attribute__((overloadable))
-rsMatrixMultiply(rs_matrix3x3 *m, float3 in);
-
-/**
- * \overload
- */
-_RS_RUNTIME float3 __attribute__((overloadable))
-rsMatrixMultiply(rs_matrix3x3 *m, float2 in);
-
-/**
- * \overload
- */
-_RS_RUNTIME float2 __attribute__((overloadable))
-rsMatrixMultiply(rs_matrix2x2 *m, float2 in);
+extern void __attribute__((overloadable))
+    rsForEach(rs_script script, rs_allocation input,
+              rs_allocation output, const void * usrData);
 #else
-/**
- * Multiply a vector by a matrix and return the result vector.
- * API version 10-13
- */
-_RS_RUNTIME float4 __attribute__((overloadable))
-rsMatrixMultiply(const rs_matrix4x4 *m, float4 in);
 
 /**
+ * Make a script to script call to launch work. One of the input or output is
+ * required to be a valid object. The input and output must be of the same
+ * dimensions.
+ * API 14+
+ *
+ * @param script The target script to call
+ * @param input The allocation to source data from
+ * @param output the allocation to write date into
+ * @param usrData The user definied params to pass to the root script.  May be
+ *                NULL.
+ * @param usrDataLen The size of the userData structure.  This will be used to
+ *                   perform a shallow copy of the data if necessary.
+ * @param sc Extra control infomation used to select a sub-region of the
+ *           allocation to be processed or suggest a walking strategy.  May be
+ *           NULL.
+ *
+ */
+extern void __attribute__((overloadable))
+    rsForEach(rs_script script, rs_allocation input, rs_allocation output,
+              const void * usrData, size_t usrDataLen, const rs_script_call_t *);
+/**
  * \overload
  */
-_RS_RUNTIME float4 __attribute__((overloadable))
-rsMatrixMultiply(const rs_matrix4x4 *m, float3 in);
-
+extern void __attribute__((overloadable))
+    rsForEach(rs_script script, rs_allocation input, rs_allocation output,
+              const void * usrData, size_t usrDataLen);
 /**
  * \overload
  */
-_RS_RUNTIME float4 __attribute__((overloadable))
-rsMatrixMultiply(const rs_matrix4x4 *m, float2 in);
-
-/**
- * \overload
- */
-_RS_RUNTIME float3 __attribute__((overloadable))
-rsMatrixMultiply(const rs_matrix3x3 *m, float3 in);
-
-/**
- * \overload
- */
-_RS_RUNTIME float3 __attribute__((overloadable))
-rsMatrixMultiply(const rs_matrix3x3 *m, float2 in);
-
-/**
- * \overload
- */
-_RS_RUNTIME float2 __attribute__((overloadable))
-rsMatrixMultiply(const rs_matrix2x2 *m, float2 in);
+extern void __attribute__((overloadable))
+    rsForEach(rs_script script, rs_allocation input, rs_allocation output);
 #endif
 
 
-/**
- * Returns true if the matrix was successfully inversed
- *
- * @param m
- */
-extern bool __attribute__((overloadable)) rsMatrixInverse(rs_matrix4x4 *m);
-
-/**
- * Returns true if the matrix was successfully inversed and transposed.
- *
- * @param m
- */
-extern bool __attribute__((overloadable)) rsMatrixInverseTranspose(rs_matrix4x4 *m);
-
-/**
- * Transpose the matrix m.
- *
- * @param m
- */
-extern void __attribute__((overloadable)) rsMatrixTranspose(rs_matrix4x4 *m);
-/**
- * \overload
- */
-extern void __attribute__((overloadable)) rsMatrixTranspose(rs_matrix3x3 *m);
-/**
- * \overload
- */
-extern void __attribute__((overloadable)) rsMatrixTranspose(rs_matrix2x2 *m);
-
-/////////////////////////////////////////////////////
-// quaternion ops
-/////////////////////////////////////////////////////
-
-/**
- * Set the quaternion components
- * @param w component
- * @param x component
- * @param y component
- * @param z component
- */
-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;
-}
-
-/**
- * Set the quaternion from another quaternion
- * @param q destination quaternion
- * @param rhs source quaternion
- */
-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;
-}
-
-/**
- * Multiply quaternion by a scalar
- * @param q quaternion to multiply
- * @param s scalar
- */
-static void __attribute__((overloadable))
-rsQuaternionMultiply(rs_quaternion *q, float s) {
-    q->w *= s;
-    q->x *= s;
-    q->y *= s;
-    q->z *= s;
-}
-
-/**
- * Multiply quaternion by another quaternion
- * @param q destination quaternion
- * @param rhs right hand side quaternion to multiply by
- */
-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;
-}
-
-/**
- * Add two quaternions
- * @param q destination quaternion to add to
- * @param rsh right hand side quaternion to add
- */
-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;
-}
-
-/**
- * Loads a quaternion that represents a rotation about an arbitrary unit vector
- * @param q quaternion to set
- * @param rot angle to rotate by
- * @param x component of a vector
- * @param y component of a vector
- * @param x component of a vector
- */
-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;
-}
-
-/**
- * Loads a quaternion that represents a rotation about an arbitrary vector
- * (doesn't have to be unit)
- * @param q quaternion to set
- * @param rot angle to rotate by
- * @param x component of a vector
- * @param y component of a vector
- * @param x component of a vector
- */
-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);
-}
-
-/**
- * Conjugates the quaternion
- * @param q quaternion to conjugate 
- */
-static void
-rsQuaternionConjugate(rs_quaternion *q) {
-    q->x = -q->x;
-    q->y = -q->y;
-    q->z = -q->z;
-}
-
-/**
- * Dot product of two quaternions
- * @param q0 first quaternion
- * @param q1 second quaternion
- * @return dot product between q0 and q1
- */
-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;
-}
-
-/**
- * Normalizes the quaternion
- * @param q quaternion to normalize
- */
-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);
-    }
-}
-
-/**
- * Performs spherical linear interpolation between two quaternions
- * @param q result quaternion from interpolation
- * @param q0 first param
- * @param q1 second param
- * @param t how much to interpolate by
- */
-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);
-}
-
-/**
- * Computes rotation matrix from the normalized quaternion
- * @param m resulting matrix
- * @param p normalized quaternion
- */
-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
-/////////////////////////////////////////////////////
-
-/**
- * Computes 6 frustum planes from the view projection matrix
- * @param viewProj matrix to extract planes from
- * @param left plane
- * @param right plane
- * @param top plane
- * @param bottom plane
- * @param near plane
- * @param far plane
- */
-__inline__ static void __attribute__((overloadable, always_inline))
-rsExtractFrustumPlanes(const rs_matrix4x4 *viewProj,
-                         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 = viewProj->m[3] + viewProj->m[0];
-    left->y = viewProj->m[7] + viewProj->m[4];
-    left->z = viewProj->m[11] + viewProj->m[8];
-    left->w = viewProj->m[15] + viewProj->m[12];
-
-    right->x = viewProj->m[3] - viewProj->m[0];
-    right->y = viewProj->m[7] - viewProj->m[4];
-    right->z = viewProj->m[11] - viewProj->m[8];
-    right->w = viewProj->m[15] - viewProj->m[12];
-
-    top->x = viewProj->m[3] - viewProj->m[1];
-    top->y = viewProj->m[7] - viewProj->m[5];
-    top->z = viewProj->m[11] - viewProj->m[9];
-    top->w = viewProj->m[15] - viewProj->m[13];
-
-    bottom->x = viewProj->m[3] + viewProj->m[1];
-    bottom->y = viewProj->m[7] + viewProj->m[5];
-    bottom->z = viewProj->m[11] + viewProj->m[9];
-    bottom->w = viewProj->m[15] + viewProj->m[13];
-
-    near->x = viewProj->m[3] + viewProj->m[2];
-    near->y = viewProj->m[7] + viewProj->m[6];
-    near->z = viewProj->m[11] + viewProj->m[10];
-    near->w = viewProj->m[15] + viewProj->m[14];
-
-    far->x = viewProj->m[3] - viewProj->m[2];
-    far->y = viewProj->m[7] - viewProj->m[6];
-    far->z = viewProj->m[11] - viewProj->m[10];
-    far->w = viewProj->m[15] - viewProj->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;
-}
-
-/**
- * Checks if a sphere is withing the 6 frustum planes
- * @param sphere float4 representing the sphere
- * @param left plane
- * @param right plane
- * @param top plane
- * @param bottom plane
- * @param near plane
- * @param far plane
- */
-__inline__ 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;
-}
-
-
-/////////////////////////////////////////////////////
-// int ops
-/////////////////////////////////////////////////////
-
-/**
- * Clamp the value amount between low and high.
- *
- * @param amount  The value to clamp
- * @param low
- * @param high
- */
-_RS_RUNTIME uint __attribute__((overloadable, always_inline)) rsClamp(uint amount, uint low, uint high);
-
-/**
- * \overload
- */
-_RS_RUNTIME int __attribute__((overloadable, always_inline)) rsClamp(int amount, int low, int high);
-/**
- * \overload
- */
-_RS_RUNTIME ushort __attribute__((overloadable, always_inline)) rsClamp(ushort amount, ushort low, ushort high);
-/**
- * \overload
- */
-_RS_RUNTIME short __attribute__((overloadable, always_inline)) rsClamp(short amount, short low, short high);
-/**
- * \overload
- */
-_RS_RUNTIME uchar __attribute__((overloadable, always_inline)) rsClamp(uchar amount, uchar low, uchar high);
-/**
- * \overload
- */
-_RS_RUNTIME char __attribute__((overloadable, always_inline)) rsClamp(char amount, char low, char high);
 
 #undef _RS_RUNTIME
 
diff --git a/libs/rs/scriptc/rs_debug.rsh b/libs/rs/scriptc/rs_debug.rsh
new file mode 100644
index 0000000..074c28f
--- /dev/null
+++ b/libs/rs/scriptc/rs_debug.rsh
@@ -0,0 +1,123 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/** @file rs_debug.rsh
+ *  \brief Utility debugging routines
+ *
+ *  Routines intended to be used during application developement.  These should
+ *  not be used in shipping applications.  All print a string and value pair to
+ *  the standard log.
+ *
+ */
+
+#ifndef __RS_DEBUG_RSH__
+#define __RS_DEBUG_RSH__
+
+
+
+/**
+ * Debug function.  Prints a string and value to the log.
+ */
+extern void __attribute__((overloadable))
+    rsDebug(const char *, float);
+/**
+ * Debug function.  Prints a string and value to the log.
+ */
+extern void __attribute__((overloadable))
+    rsDebug(const char *, float, float);
+/**
+ * Debug function.  Prints a string and value to the log.
+ */
+extern void __attribute__((overloadable))
+    rsDebug(const char *, float, float, float);
+/**
+ * Debug function.  Prints a string and value to the log.
+ */
+extern void __attribute__((overloadable))
+    rsDebug(const char *, float, float, float, float);
+/**
+ * Debug function.  Prints a string and value to the log.
+ */
+extern void __attribute__((overloadable))
+    rsDebug(const char *, double);
+/**
+ * Debug function.  Prints a string and value to the log.
+ */
+extern void __attribute__((overloadable))
+    rsDebug(const char *, const rs_matrix4x4 *);
+/**
+ * Debug function.  Prints a string and value to the log.
+ */
+extern void __attribute__((overloadable))
+    rsDebug(const char *, const rs_matrix3x3 *);
+/**
+ * Debug function.  Prints a string and value to the log.
+ */
+extern void __attribute__((overloadable))
+    rsDebug(const char *, const rs_matrix2x2 *);
+/**
+ * Debug function.  Prints a string and value to the log.
+ */
+extern void __attribute__((overloadable))
+    rsDebug(const char *, int);
+/**
+ * Debug function.  Prints a string and value to the log.
+ */
+extern void __attribute__((overloadable))
+    rsDebug(const char *, uint);
+/**
+ * Debug function.  Prints a string and value to the log.
+ */
+extern void __attribute__((overloadable))
+    rsDebug(const char *, long);
+/**
+ * Debug function.  Prints a string and value to the log.
+ */
+extern void __attribute__((overloadable))
+    rsDebug(const char *, unsigned long);
+/**
+ * Debug function.  Prints a string and value to the log.
+ */
+extern void __attribute__((overloadable))
+    rsDebug(const char *, long long);
+/**
+ * Debug function.  Prints a string and value to the log.
+ */
+extern void __attribute__((overloadable))
+    rsDebug(const char *, unsigned long long);
+/**
+ * Debug function.  Prints a string and value to the log.
+ */
+extern void __attribute__((overloadable))
+    rsDebug(const char *, const void *);
+#define RS_DEBUG(a) rsDebug(#a, a)
+#define RS_DEBUG_MARKER rsDebug(__FILE__, __LINE__)
+
+
+/**
+ * Debug function.  Prints a string and value to the log.
+ */
+_RS_RUNTIME void __attribute__((overloadable)) rsDebug(const char *s, float2 v);
+/**
+ * Debug function.  Prints a string and value to the log.
+ */
+_RS_RUNTIME void __attribute__((overloadable)) rsDebug(const char *s, float3 v);
+/**
+ * Debug function.  Prints a string and value to the log.
+ */
+_RS_RUNTIME void __attribute__((overloadable)) rsDebug(const char *s, float4 v);
+
+#endif
diff --git a/libs/rs/scriptc/rs_graphics.rsh b/libs/rs/scriptc/rs_graphics.rsh
index 9a8a4e6..00fd1b1 100644
--- a/libs/rs/scriptc/rs_graphics.rsh
+++ b/libs/rs/scriptc/rs_graphics.rsh
@@ -1,3 +1,25 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/** @file rs_graphics.rsh
+ *  \brief Renderscript graphics API
+ *
+ *  A set of graphics functions used by Renderscript.
+ *
+ */
 #ifndef __RS_GRAPHICS_RSH__
 #define __RS_GRAPHICS_RSH__
 
@@ -37,7 +59,7 @@
     rsgClearAllRenderTargets(void);
 
 /**
- * Force RenderScript to finish all rendering commands
+ * Force Renderscript to finish all rendering commands
  */
 extern uint __attribute__((overloadable))
     rsgFinish(void);
@@ -94,16 +116,38 @@
 extern void __attribute__((overloadable))
     rsgBindTexture(rs_program_fragment, uint slot, rs_allocation);
 
-
+/**
+ * Load the projection matrix for a currently bound fixed function
+ * vertex program. Calling this function with a custom vertex shader
+ * would result in an error.
+ * @param proj projection matrix
+ */
 extern void __attribute__((overloadable))
-    rsgProgramVertexLoadProjectionMatrix(const rs_matrix4x4 *);
+    rsgProgramVertexLoadProjectionMatrix(const rs_matrix4x4 *proj);
+/**
+ * Load the model matrix for a currently bound fixed function
+ * vertex program. Calling this function with a custom vertex shader
+ * would result in an error.
+ * @param model model matrix
+ */
 extern void __attribute__((overloadable))
-    rsgProgramVertexLoadModelMatrix(const rs_matrix4x4 *);
+    rsgProgramVertexLoadModelMatrix(const rs_matrix4x4 *model);
+/**
+ * Load the texture matrix for a currently bound fixed function
+ * vertex program. Calling this function with a custom vertex shader
+ * would result in an error.
+ * @param tex texture matrix
+ */
 extern void __attribute__((overloadable))
-    rsgProgramVertexLoadTextureMatrix(const rs_matrix4x4 *);
-
+    rsgProgramVertexLoadTextureMatrix(const rs_matrix4x4 *tex);
+/**
+ * Get the projection matrix for a currently bound fixed function
+ * vertex program. Calling this function with a custom vertex shader
+ * would result in an error.
+ * @param proj matrix to store the current projection matrix into
+ */
 extern void __attribute__((overloadable))
-    rsgProgramVertexGetProjectionMatrix(rs_matrix4x4 *);
+    rsgProgramVertexGetProjectionMatrix(rs_matrix4x4 *proj);
 
 /**
  * Set the constant color for a fixed function emulation program.
@@ -239,15 +283,29 @@
     rsgDrawSpriteScreenspace(float x, float y, float z, float w, float h);
 
 /**
- * Draw a mesh of geometry using the current context state.  The whole mesh is
+ * Draw a mesh using the current context state.  The whole mesh is
  * rendered.
  *
  * @param ism
  */
 extern void __attribute__((overloadable))
     rsgDrawMesh(rs_mesh ism);
+/**
+ * Draw part of a mesh using the current context state.
+ * @param ism mesh object to render
+ * @param primitiveIndex for meshes that contain multiple primitive groups
+ *        this parameter specifies the index of the group to draw.
+ */
 extern void __attribute__((overloadable))
     rsgDrawMesh(rs_mesh ism, uint primitiveIndex);
+/**
+ * Draw specified index range of part of a mesh using the current context state.
+ * @param ism mesh object to render
+ * @param primitiveIndex for meshes that contain multiple primitive groups
+ *        this parameter specifies the index of the group to draw.
+ * @param start starting index in the range
+ * @param len number of indices to draw
+ */
 extern void __attribute__((overloadable))
     rsgDrawMesh(rs_mesh ism, uint primitiveIndex, uint start, uint len);
 
@@ -264,29 +322,54 @@
 
 /**
  * Clears the depth suface to the specified value.
- *
  */
 extern void __attribute__((overloadable))
     rsgClearDepth(float value);
-
+/**
+ * Draws text given a string and location
+ */
 extern void __attribute__((overloadable))
     rsgDrawText(const char *, int x, int y);
+/**
+ * \overload
+ */
 extern void __attribute__((overloadable))
     rsgDrawText(rs_allocation, int x, int y);
+/**
+ * Binds the font object to be used for all subsequent font rendering calls
+ * @param font object to bind
+ */
 extern void __attribute__((overloadable))
-    rsgBindFont(rs_font);
+    rsgBindFont(rs_font font);
+/**
+ * Sets the font color for all subsequent rendering calls
+ * @param r red component
+ * @param g green component
+ * @param b blue component
+ * @param a alpha component
+ */
 extern void __attribute__((overloadable))
-    rsgFontColor(float, float, float, float);
-// Returns the bounding box of the text relative to (0, 0)
-// Any of left, right, top, bottom could be NULL
+    rsgFontColor(float r, float g, float b, float a);
+/**
+ * Returns the bounding box of the text relative to (0, 0)
+ * Any of left, right, top, bottom could be NULL
+ */
 extern void __attribute__((overloadable))
     rsgMeasureText(const char *, int *left, int *right, int *top, int *bottom);
+/**
+ * \overload
+ */
 extern void __attribute__((overloadable))
     rsgMeasureText(rs_allocation, int *left, int *right, int *top, int *bottom);
-
+/**
+ * Computes an axis aligned bounding box of a mesh object
+ */
 extern void __attribute__((overloadable))
     rsgMeshComputeBoundingBox(rs_mesh mesh, float *minX, float *minY, float *minZ,
                                                 float *maxX, float *maxY, float *maxZ);
+/**
+ * \overload
+ */
 __inline__ static void __attribute__((overloadable, always_inline))
 rsgMeshComputeBoundingBox(rs_mesh mesh, float3 *bBoxMin, float3 *bBoxMax) {
     float x1, y1, z1, x2, y2, z2;
diff --git a/libs/rs/scriptc/rs_math.rsh b/libs/rs/scriptc/rs_math.rsh
index e44c051..8117ca8 100644
--- a/libs/rs/scriptc/rs_math.rsh
+++ b/libs/rs/scriptc/rs_math.rsh
@@ -1,309 +1,30 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 /** @file rs_math.rsh
  *  \brief todo-jsams
  *
  *  todo-jsams
  *
  */
+
 #ifndef __RS_MATH_RSH__
 #define __RS_MATH_RSH__
 
 
-
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
-    rsSetObject(rs_element *dst, rs_element src);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
-    rsSetObject(rs_type *dst, rs_type src);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
-    rsSetObject(rs_allocation *dst, rs_allocation src);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
-    rsSetObject(rs_sampler *dst, rs_sampler src);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
-    rsSetObject(rs_script *dst, rs_script src);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
-    rsSetObject(rs_mesh *dst, rs_mesh src);
-/**
- * Copy reference to the specified object.
- *
- * @param dst
- * @param src
- */
-extern void __attribute__((overloadable))
-    rsSetObject(rs_program_fragment *dst, rs_program_fragment src);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
-    rsSetObject(rs_program_vertex *dst, rs_program_vertex src);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
-    rsSetObject(rs_program_raster *dst, rs_program_raster src);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
-    rsSetObject(rs_program_store *dst, rs_program_store src);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
-    rsSetObject(rs_font *dst, rs_font src);
-
-/**
- * Sets the object to NULL.
- *
- * @return bool
- */
-extern void __attribute__((overloadable))
-    rsClearObject(rs_element *dst);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
-    rsClearObject(rs_type *dst);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
-    rsClearObject(rs_allocation *dst);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
-    rsClearObject(rs_sampler *dst);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
-    rsClearObject(rs_script *dst);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
-    rsClearObject(rs_mesh *dst);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
-    rsClearObject(rs_program_fragment *dst);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
-    rsClearObject(rs_program_vertex *dst);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
-    rsClearObject(rs_program_raster *dst);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
-    rsClearObject(rs_program_store *dst);
-/**
- * \overload
- */
-extern void __attribute__((overloadable))
-    rsClearObject(rs_font *dst);
-
-/**
- * \overload
- */
-extern bool __attribute__((overloadable))
-    rsIsObject(rs_element);
-/**
- * \overload
- */
-extern bool __attribute__((overloadable))
-    rsIsObject(rs_type);
-/**
- * \overload
- */
-extern bool __attribute__((overloadable))
-    rsIsObject(rs_allocation);
-/**
- * Tests if the object is valid.  Returns true if the object is valid, false if
- * it is NULL.
- *
- * @return bool
- */
-
-extern bool __attribute__((overloadable))
-    rsIsObject(rs_sampler);
-/**
- * \overload
- */
-extern bool __attribute__((overloadable))
-    rsIsObject(rs_script);
-/**
- * \overload
- */
-extern bool __attribute__((overloadable))
-    rsIsObject(rs_mesh);
-/**
- * \overload
- */
-extern bool __attribute__((overloadable))
-    rsIsObject(rs_program_fragment);
-/**
- * \overload
- */
-extern bool __attribute__((overloadable))
-    rsIsObject(rs_program_vertex);
-/**
- * \overload
- */
-extern bool __attribute__((overloadable))
-    rsIsObject(rs_program_raster);
-/**
- * \overload
- */
-extern bool __attribute__((overloadable))
-    rsIsObject(rs_program_store);
-/**
- * \overload
- */
-extern bool __attribute__((overloadable))
-    rsIsObject(rs_font);
-
-
-/**
- * Returns the Allocation for a given pointer.  The pointer should point within
- * a valid allocation.  The results are undefined if the pointer is not from a
- * valid allocation.
- */
-extern rs_allocation __attribute__((overloadable))
-    rsGetAllocation(const void *);
-
-/**
- * Query the dimension of an allocation.
- *
- * @return uint32_t The X dimension of the allocation.
- */
-extern uint32_t __attribute__((overloadable))
-    rsAllocationGetDimX(rs_allocation);
-
-/**
- * Query the dimension of an allocation.
- *
- * @return uint32_t The Y dimension of the allocation.
- */
-extern uint32_t __attribute__((overloadable))
-    rsAllocationGetDimY(rs_allocation);
-
-/**
- * Query the dimension of an allocation.
- *
- * @return uint32_t The Z dimension of the allocation.
- */
-extern uint32_t __attribute__((overloadable))
-    rsAllocationGetDimZ(rs_allocation);
-
-/**
- * Query an allocation for the presence of more than one LOD.
- *
- * @return uint32_t Returns 1 if more than one LOD is present, 0 otherwise.
- */
-extern uint32_t __attribute__((overloadable))
-    rsAllocationGetDimLOD(rs_allocation);
-
-/**
- * Query an allocation for the presence of more than one face.
- *
- * @return uint32_t Returns 1 if more than one face is present, 0 otherwise.
- */
-extern uint32_t __attribute__((overloadable))
-    rsAllocationGetDimFaces(rs_allocation);
-
-/**
- * Copy part of an allocation from another allocation.
- *
- * @param dstAlloc Allocation to copy data into.
- * @param dstOff The offset of the first element to be copied in
- *               the destination allocation.
- * @param dstMip Mip level in the destination allocation.
- * @param count The number of elements to be copied.
- * @param srcAlloc The source data allocation.
- * @param srcOff The offset of the first element in data to be
- *               copied in the source allocation.
- * @param srcMip Mip level in the source allocation.
- */
-extern void __attribute__((overloadable))
-    rsAllocationCopy1DRange(rs_allocation dstAlloc,
-                            uint32_t dstOff, uint32_t dstMip,
-                            uint32_t count,
-                            rs_allocation srcAlloc,
-                            uint32_t srcOff, uint32_t srcMip);
-
-/**
- * Copy a rectangular region into the allocation from another
- * allocation.
- *
- * @param dstAlloc allocation to copy data into.
- * @param dstXoff X offset of the region to update in the
- *                destination allocation.
- * @param dstYoff Y offset of the region to update in the
- *                destination allocation.
- * @param dstMip Mip level in the destination allocation.
- * @param dstFace Cubemap face of the destination allocation,
- *                ignored for allocations that aren't cubemaps.
- * @param width Width of the incoming region to update.
- * @param height Height of the incoming region to update.
- * @param srcAlloc The source data allocation.
- * @param srcXoff X offset in data of the source allocation.
- * @param srcYoff Y offset in data of the source allocation.
- * @param srcMip Mip level in the source allocation.
- * @param srcFace Cubemap face of the source allocation,
- *                ignored for allocations that aren't cubemaps.
- */
-extern void __attribute__((overloadable))
-    rsAllocationCopy2DRange(rs_allocation dstAlloc,
-                            uint32_t dstXoff, uint32_t dstYoff,
-                            uint32_t dstMip,
-                            rs_allocation_cubemap_face dstFace,
-                            uint32_t width, uint32_t height,
-                            rs_allocation srcAlloc,
-                            uint32_t srcXoff, uint32_t srcYoff,
-                            uint32_t srcMip,
-                            rs_allocation_cubemap_face srcFace);
-
-
-/**
- * Extract a single element from an allocation.
- */
-extern const void * __attribute__((overloadable))
-    rsGetElementAt(rs_allocation, uint32_t x);
-/**
- * \overload
- */
-extern const void * __attribute__((overloadable))
-    rsGetElementAt(rs_allocation, uint32_t x, uint32_t y);
-/**
- * \overload
- */
-extern const void * __attribute__((overloadable))
-    rsGetElementAt(rs_allocation, uint32_t x, uint32_t y, uint32_t z);
-
 /**
  * Return a random value between 0 (or min_value) and max_malue.
  */
@@ -331,346 +52,197 @@
 extern float __attribute__((overloadable))
     rsFrac(float);
 
+
+/////////////////////////////////////////////////////
+// int ops
+/////////////////////////////////////////////////////
+
 /**
- * Send a message back to the client.  Will not block and returns true
- * if the message was sendable and false if the fifo was full.
- * A message ID is required.  Data payload is optional.
+ * Clamp the value amount between low and high.
+ *
+ * @param amount  The value to clamp
+ * @param low
+ * @param high
  */
-extern bool __attribute__((overloadable))
-    rsSendToClient(int cmdID);
+_RS_RUNTIME uint __attribute__((overloadable, always_inline)) rsClamp(uint amount, uint low, uint high);
+
 /**
  * \overload
  */
-extern bool __attribute__((overloadable))
-    rsSendToClient(int cmdID, const void *data, uint len);
-/**
- * Send a message back to the client, blocking until the message is queued.
- * A message ID is required.  Data payload is optional.
- */
-extern void __attribute__((overloadable))
-    rsSendToClientBlocking(int cmdID);
+_RS_RUNTIME int __attribute__((overloadable, always_inline)) rsClamp(int amount, int low, int high);
 /**
  * \overload
  */
-extern void __attribute__((overloadable))
-    rsSendToClientBlocking(int cmdID, const void *data, uint len);
-
-
-/**
- * Launch order hint for rsForEach calls.  This provides a hint to the system to
- * determine in which order the root function of the target is called with each
- * cell of the allocation.
- *
- * This is a hint and implementations may not obey the order.
- */
-enum rs_for_each_strategy {
-    RS_FOR_EACH_STRATEGY_SERIAL,
-    RS_FOR_EACH_STRATEGY_DONT_CARE,
-    RS_FOR_EACH_STRATEGY_DST_LINEAR,
-    RS_FOR_EACH_STRATEGY_TILE_SMALL,
-    RS_FOR_EACH_STRATEGY_TILE_MEDIUM,
-    RS_FOR_EACH_STRATEGY_TILE_LARGE
-};
-
-
-/**
- * Structure to provide extra information to a rsForEach call.  Primarly used to
- * restrict the call to a subset of cells in the allocation.
- */
-typedef struct rs_script_call {
-    enum rs_for_each_strategy strategy;
-    uint32_t xStart;
-    uint32_t xEnd;
-    uint32_t yStart;
-    uint32_t yEnd;
-    uint32_t zStart;
-    uint32_t zEnd;
-    uint32_t arrayStart;
-    uint32_t arrayEnd;
-} rs_script_call_t;
-
-/**
- * Make a script to script call to launch work. One of the input or output is
- * required to be a valid object. The input and output must be of the same
- * dimensions.
- * API 10-13
- *
- * @param script The target script to call
- * @param input The allocation to source data from
- * @param output the allocation to write date into
- * @param usrData The user definied params to pass to the root script.  May be
- *                NULL.
- * @param sc Extra control infomation used to select a sub-region of the
- *           allocation to be processed or suggest a walking strategy.  May be
- *           NULL.
- *
- *  */
-#if !defined(RS_VERSION) || (RS_VERSION < 14)
-extern void __attribute__((overloadable))
-    rsForEach(rs_script script script, rs_allocation input,
-              rs_allocation output, const void * usrData,
-              const rs_script_call_t *sc);
+_RS_RUNTIME ushort __attribute__((overloadable, always_inline)) rsClamp(ushort amount, ushort low, ushort high);
 /**
  * \overload
  */
-extern void __attribute__((overloadable))
-    rsForEach(rs_script script, rs_allocation input,
-              rs_allocation output, const void * usrData);
-#else
-
-/**
- * Make a script to script call to launch work. One of the input or output is
- * required to be a valid object. The input and output must be of the same
- * dimensions.
- * API 14+
- *
- * @param script The target script to call
- * @param input The allocation to source data from
- * @param output the allocation to write date into
- * @param usrData The user definied params to pass to the root script.  May be
- *                NULL.
- * @param usrDataLen The size of the userData structure.  This will be used to
- *                   perform a shallow copy of the data if necessary.
- * @param sc Extra control infomation used to select a sub-region of the
- *           allocation to be processed or suggest a walking strategy.  May be
- *           NULL.
- *
- */
-extern void __attribute__((overloadable))
-    rsForEach(rs_script script, rs_allocation input, rs_allocation output,
-              const void * usrData, size_t usrDataLen, const rs_script_call_t *);
+_RS_RUNTIME short __attribute__((overloadable, always_inline)) rsClamp(short amount, short low, short high);
 /**
  * \overload
  */
-extern void __attribute__((overloadable))
-    rsForEach(rs_script script, rs_allocation input, rs_allocation output,
-              const void * usrData, size_t usrDataLen);
+_RS_RUNTIME uchar __attribute__((overloadable, always_inline)) rsClamp(uchar amount, uchar low, uchar high);
 /**
  * \overload
  */
-extern void __attribute__((overloadable))
-    rsForEach(rs_script script, rs_allocation input, rs_allocation output);
-#endif
+_RS_RUNTIME char __attribute__((overloadable, always_inline)) rsClamp(char amount, char low, char high);
 
 
 /**
- * Atomic add one to the value at addr.
- * Equal to rsAtomicAdd(addr, 1)
- *
- * @param addr Address of value to increment
- *
- * @return old value
+ * Computes 6 frustum planes from the view projection matrix
+ * @param viewProj matrix to extract planes from
+ * @param left plane
+ * @param right plane
+ * @param top plane
+ * @param bottom plane
+ * @param near plane
+ * @param far plane
  */
-extern int32_t __attribute__((overloadable))
-    rsAtomicInc(volatile int32_t* addr);
-/**
- * Atomic add one to the value at addr.
- * Equal to rsAtomicAdd(addr, 1)
- *
- * @param addr Address of value to increment
- *
- * @return old value
- */
-extern uint32_t __attribute__((overloadable))
-    rsAtomicInc(volatile uint32_t* addr);
+__inline__ static void __attribute__((overloadable, always_inline))
+rsExtractFrustumPlanes(const rs_matrix4x4 *viewProj,
+                         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 = viewProj->m[3] + viewProj->m[0];
+    left->y = viewProj->m[7] + viewProj->m[4];
+    left->z = viewProj->m[11] + viewProj->m[8];
+    left->w = viewProj->m[15] + viewProj->m[12];
+
+    right->x = viewProj->m[3] - viewProj->m[0];
+    right->y = viewProj->m[7] - viewProj->m[4];
+    right->z = viewProj->m[11] - viewProj->m[8];
+    right->w = viewProj->m[15] - viewProj->m[12];
+
+    top->x = viewProj->m[3] - viewProj->m[1];
+    top->y = viewProj->m[7] - viewProj->m[5];
+    top->z = viewProj->m[11] - viewProj->m[9];
+    top->w = viewProj->m[15] - viewProj->m[13];
+
+    bottom->x = viewProj->m[3] + viewProj->m[1];
+    bottom->y = viewProj->m[7] + viewProj->m[5];
+    bottom->z = viewProj->m[11] + viewProj->m[9];
+    bottom->w = viewProj->m[15] + viewProj->m[13];
+
+    near->x = viewProj->m[3] + viewProj->m[2];
+    near->y = viewProj->m[7] + viewProj->m[6];
+    near->z = viewProj->m[11] + viewProj->m[10];
+    near->w = viewProj->m[15] + viewProj->m[14];
+
+    far->x = viewProj->m[3] - viewProj->m[2];
+    far->y = viewProj->m[7] - viewProj->m[6];
+    far->z = viewProj->m[11] - viewProj->m[10];
+    far->w = viewProj->m[15] - viewProj->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;
+}
 
 /**
- * Atomic subtract one from the value at addr. Equal to rsAtomicSub(addr, 1)
- *
- * @param addr Address of value to decrement
- *
- * @return old value
+ * Checks if a sphere is withing the 6 frustum planes
+ * @param sphere float4 representing the sphere
+ * @param left plane
+ * @param right plane
+ * @param top plane
+ * @param bottom plane
+ * @param near plane
+ * @param far plane
  */
-extern int32_t __attribute__((overloadable))
-    rsAtomicDec(volatile int32_t* addr);
-/**
- * Atomic subtract one from the value at addr. Equal to rsAtomicSub(addr, 1)
- *
- * @param addr Address of value to decrement
- *
- * @return old value
- */
-extern uint32_t __attribute__((overloadable))
-    rsAtomicDec(volatile uint32_t* addr);
+__inline__ 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;
+}
+
 
 /**
- * Atomic add a value to the value at addr.  addr[0] += value
+ * Pack floating point (0-1) RGB values into a uchar4.  The alpha component is
+ * set to 255 (1.0).
  *
- * @param addr Address of value to modify
- * @param value Amount to add to the value at addr
+ * @param r
+ * @param g
+ * @param b
  *
- * @return old value
+ * @return uchar4
  */
-extern int32_t __attribute__((overloadable))
-    rsAtomicAdd(volatile int32_t* addr, int32_t value);
-/**
- * Atomic add a value to the value at addr.  addr[0] += value
- *
- * @param addr Address of value to modify
- * @param value Amount to add to the value at addr
- *
- * @return old value
- */
-extern uint32_t __attribute__((overloadable))
-    rsAtomicAdd(volatile uint32_t* addr, uint32_t value);
+_RS_RUNTIME uchar4 __attribute__((overloadable)) rsPackColorTo8888(float r, float g, float b);
 
 /**
- * Atomic Subtract a value from the value at addr.  addr[0] -= value
+ * Pack floating point (0-1) RGBA values into a uchar4.
  *
- * @param addr Address of value to modify
- * @param value Amount to subtract from the value at addr
+ * @param r
+ * @param g
+ * @param b
+ * @param a
  *
- * @return old value
+ * @return uchar4
  */
-extern int32_t __attribute__((overloadable))
-    rsAtomicSub(volatile int32_t* addr, int32_t value);
-/**
- * Atomic Subtract a value from the value at addr.  addr[0] -= value
- *
- * @param addr Address of value to modify
- * @param value Amount to subtract from the value at addr
- *
- * @return old value
- */
-extern uint32_t __attribute__((overloadable))
-    rsAtomicSub(volatile uint32_t* addr, uint32_t value);
+_RS_RUNTIME uchar4 __attribute__((overloadable)) rsPackColorTo8888(float r, float g, float b, float a);
 
 /**
- * Atomic Bitwise and a value from the value at addr.  addr[0] &= value
+ * Pack floating point (0-1) RGB values into a uchar4.  The alpha component is
+ * set to 255 (1.0).
  *
- * @param addr Address of value to modify
- * @param value Amount to and with the value at addr
+ * @param color
  *
- * @return old value
+ * @return uchar4
  */
-extern int32_t __attribute__((overloadable))
-    rsAtomicAnd(volatile int32_t* addr, int32_t value);
-/**
- * Atomic Bitwise and a value from the value at addr.  addr[0] &= value
- *
- * @param addr Address of value to modify
- * @param value Amount to and with the value at addr
- *
- * @return old value
- */
-extern uint32_t __attribute__((overloadable))
-    rsAtomicAnd(volatile uint32_t* addr, uint32_t value);
+_RS_RUNTIME uchar4 __attribute__((overloadable)) rsPackColorTo8888(float3 color);
 
 /**
- * Atomic Bitwise or a value from the value at addr.  addr[0] |= value
+ * Pack floating point (0-1) RGBA values into a uchar4.
  *
- * @param addr Address of value to modify
- * @param value Amount to or with the value at addr
+ * @param color
  *
- * @return old value
+ * @return uchar4
  */
-extern int32_t __attribute__((overloadable))
-    rsAtomicOr(volatile int32_t* addr, int32_t value);
-/**
- * Atomic Bitwise or a value from the value at addr.  addr[0] |= value
- *
- * @param addr Address of value to modify
- * @param value Amount to or with the value at addr
- *
- * @return old value
- */
-extern uint32_t __attribute__((overloadable))
-    rsAtomicOr(volatile uint32_t* addr, uint32_t value);
+_RS_RUNTIME uchar4 __attribute__((overloadable)) rsPackColorTo8888(float4 color);
 
 /**
- * Atomic Bitwise xor a value from the value at addr.  addr[0] ^= value
+ * Unpack a uchar4 color to float4.  The resulting float range will be (0-1).
  *
- * @param addr Address of value to modify
- * @param value Amount to xor with the value at addr
+ * @param c
  *
- * @return old value
+ * @return float4
  */
-extern uint32_t __attribute__((overloadable))
-    rsAtomicXor(volatile uint32_t* addr, uint32_t value);
-/**
- * Atomic Bitwise xor a value from the value at addr.  addr[0] ^= value
- *
- * @param addr Address of value to modify
- * @param value Amount to xor with the value at addr
- *
- * @return old value
- */
-extern int32_t __attribute__((overloadable))
-    rsAtomicXor(volatile int32_t* addr, int32_t value);
-
-/**
- * Atomic Set the value at addr to the min of addr and value
- * addr[0] = rsMin(addr[0], value)
- *
- * @param addr Address of value to modify
- * @param value comparison value
- *
- * @return old value
- */
-extern uint32_t __attribute__((overloadable))
-    rsAtomicMin(volatile uint32_t* addr, uint32_t value);
-/**
- * Atomic Set the value at addr to the min of addr and value
- * addr[0] = rsMin(addr[0], value)
- *
- * @param addr Address of value to modify
- * @param value comparison value
- *
- * @return old value
- */
-extern int32_t __attribute__((overloadable))
-    rsAtomicMin(volatile int32_t* addr, int32_t value);
-
-/**
- * Atomic Set the value at addr to the max of addr and value
- * addr[0] = rsMax(addr[0], value)
- *
- * @param addr Address of value to modify
- * @param value comparison value
- *
- * @return old value
- */
-extern uint32_t __attribute__((overloadable))
-    rsAtomicMax(volatile uint32_t* addr, uint32_t value);
-/**
- * Atomic Set the value at addr to the max of addr and value
- * addr[0] = rsMin(addr[0], value)
- *
- * @param addr Address of value to modify
- * @param value comparison value
- *
- * @return old value
- */
-extern int32_t __attribute__((overloadable))
-    rsAtomicMax(volatile int32_t* addr, int32_t value);
-
-/**
- * Compare-and-set operation with a full memory barrier.
- *
- * If the value at addr matches compareValue then newValue is written.
- *
- * @param addr The address to compare and replace if the compare passes.
- * @param compareValue The value to test addr[0] against.
- * @param newValue The value to write if the test passes.
- *
- * @return old value
- */
-extern int32_t __attribute__((overloadable))
-    rsAtomicCas(volatile int32_t* addr, int32_t compareValue, int32_t newValue);
-
-/**
- * Compare-and-set operation with a full memory barrier.
- *
- * If the value at addr matches compareValue then newValue is written.
- *
- * @param addr The address to compare and replace if the compare passes.
- * @param compareValue The value to test addr[0] against.
- * @param newValue The value to write if the test passes.
- *
- * @return old value
- */
-extern uint32_t __attribute__((overloadable))
-    rsAtomicCas(volatile uint32_t* addr, int32_t compareValue, int32_t newValue);
+_RS_RUNTIME float4 rsUnpackColor8888(uchar4 c);
 
 
 #endif
diff --git a/libs/rs/scriptc/rs_matrix.rsh b/libs/rs/scriptc/rs_matrix.rsh
new file mode 100644
index 0000000..ab3cd3b
--- /dev/null
+++ b/libs/rs/scriptc/rs_matrix.rsh
@@ -0,0 +1,378 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/** @file rs_matrix.rsh
+ *  \brief Matrix routines
+ *
+ *
+ */
+
+#ifndef __RS_MATRIX_RSH__
+#define __RS_MATRIX_RSH__
+
+/**
+ * Set one element of a matrix.
+ *
+ * @param m The matrix to be set
+ * @param row
+ * @param col
+ * @param v
+ *
+ * @return void
+ */
+_RS_RUNTIME void __attribute__((overloadable))
+rsMatrixSet(rs_matrix4x4 *m, uint32_t row, uint32_t col, float v);
+/**
+ * \overload
+ */
+_RS_RUNTIME void __attribute__((overloadable))
+rsMatrixSet(rs_matrix3x3 *m, uint32_t row, uint32_t col, float v);
+/**
+ * \overload
+ */
+_RS_RUNTIME void __attribute__((overloadable))
+rsMatrixSet(rs_matrix2x2 *m, uint32_t row, uint32_t col, float v);
+
+/**
+ * Get one element of a matrix.
+ *
+ * @param m The matrix to read from
+ * @param row
+ * @param col
+ *
+ * @return float
+ */
+_RS_RUNTIME float __attribute__((overloadable))
+rsMatrixGet(const rs_matrix4x4 *m, uint32_t row, uint32_t col);
+/**
+ * \overload
+ */
+_RS_RUNTIME float __attribute__((overloadable))
+rsMatrixGet(const rs_matrix3x3 *m, uint32_t row, uint32_t col);
+/**
+ * \overload
+ */
+_RS_RUNTIME float __attribute__((overloadable))
+rsMatrixGet(const rs_matrix2x2 *m, uint32_t row, uint32_t col);
+
+/**
+ * Set the elements of a matrix to the identity matrix.
+ *
+ * @param m
+ */
+extern void __attribute__((overloadable)) rsMatrixLoadIdentity(rs_matrix4x4 *m);
+/**
+ * \overload
+ */
+extern void __attribute__((overloadable)) rsMatrixLoadIdentity(rs_matrix3x3 *m);
+/**
+ * \overload
+ */
+extern void __attribute__((overloadable)) rsMatrixLoadIdentity(rs_matrix2x2 *m);
+
+/**
+ * Set the elements of a matrix from an array of floats.
+ *
+ * @param m
+ */
+extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix4x4 *m, const float *v);
+/**
+ * \overload
+ */
+extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix3x3 *m, const float *v);
+/**
+ * \overload
+ */
+extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix2x2 *m, const float *v);
+/**
+ * \overload
+ */
+extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix4x4 *m, const rs_matrix4x4 *v);
+/**
+ * \overload
+ */
+extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix4x4 *m, const rs_matrix3x3 *v);
+
+/**
+ * Set the elements of a matrix from another matrix.
+ *
+ * @param m
+ */
+extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix4x4 *m, const rs_matrix2x2 *v);
+/**
+ * \overload
+ */
+extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix3x3 *m, const rs_matrix3x3 *v);
+/**
+ * \overload
+ */
+extern void __attribute__((overloadable)) rsMatrixLoad(rs_matrix2x2 *m, const rs_matrix2x2 *v);
+
+/**
+ * Load a rotation matrix.
+ *
+ * @param m
+ * @param rot
+ * @param x
+ * @param y
+ * @param z
+ */
+extern void __attribute__((overloadable))
+rsMatrixLoadRotate(rs_matrix4x4 *m, float rot, float x, float y, float z);
+
+/**
+ * Load a scale matrix.
+ *
+ * @param m
+ * @param x
+ * @param y
+ * @param z
+ */
+extern void __attribute__((overloadable))
+rsMatrixLoadScale(rs_matrix4x4 *m, float x, float y, float z);
+
+/**
+ * Load a translation matrix.
+ *
+ * @param m
+ * @param x
+ * @param y
+ * @param z
+ */
+extern void __attribute__((overloadable))
+rsMatrixLoadTranslate(rs_matrix4x4 *m, float x, float y, float z);
+
+/**
+ * Multiply two matrix (lhs, rhs) and place the result in m.
+ *
+ * @param m
+ * @param lhs
+ * @param rhs
+ */
+extern void __attribute__((overloadable))
+rsMatrixLoadMultiply(rs_matrix4x4 *m, const rs_matrix4x4 *lhs, const rs_matrix4x4 *rhs);
+/**
+ * \overload
+ */
+extern void __attribute__((overloadable))
+rsMatrixLoadMultiply(rs_matrix3x3 *m, const rs_matrix3x3 *lhs, const rs_matrix3x3 *rhs);
+/**
+ * \overload
+ */
+extern void __attribute__((overloadable))
+rsMatrixLoadMultiply(rs_matrix2x2 *m, const rs_matrix2x2 *lhs, const rs_matrix2x2 *rhs);
+
+/**
+ * Multiply the matrix m by rhs and place the result back into m.
+ *
+ * @param m (lhs)
+ * @param rhs
+ */
+extern void __attribute__((overloadable))
+rsMatrixMultiply(rs_matrix4x4 *m, const rs_matrix4x4 *rhs);
+/**
+ * \overload
+ */
+extern void __attribute__((overloadable))
+rsMatrixMultiply(rs_matrix3x3 *m, const rs_matrix3x3 *rhs);
+/**
+ * \overload
+ */
+extern void __attribute__((overloadable))
+rsMatrixMultiply(rs_matrix2x2 *m, const rs_matrix2x2 *rhs);
+
+/**
+ * Multiple matrix m with a rotation matrix
+ *
+ * @param m
+ * @param rot
+ * @param x
+ * @param y
+ * @param z
+ */
+extern void __attribute__((overloadable))
+rsMatrixRotate(rs_matrix4x4 *m, float rot, float x, float y, float z);
+
+/**
+ * Multiple matrix m with a scale matrix
+ *
+ * @param m
+ * @param x
+ * @param y
+ * @param z
+ */
+extern void __attribute__((overloadable))
+rsMatrixScale(rs_matrix4x4 *m, float x, float y, float z);
+
+/**
+ * Multiple matrix m with a translation matrix
+ *
+ * @param m
+ * @param x
+ * @param y
+ * @param z
+ */
+extern void __attribute__((overloadable))
+rsMatrixTranslate(rs_matrix4x4 *m, float x, float y, float z);
+
+/**
+ * Load an Ortho projection matrix constructed from the 6 planes
+ *
+ * @param m
+ * @param left
+ * @param right
+ * @param bottom
+ * @param top
+ * @param near
+ * @param far
+ */
+extern void __attribute__((overloadable))
+rsMatrixLoadOrtho(rs_matrix4x4 *m, float left, float right, float bottom, float top, float near, float far);
+
+/**
+ * Load an Frustum projection matrix constructed from the 6 planes
+ *
+ * @param m
+ * @param left
+ * @param right
+ * @param bottom
+ * @param top
+ * @param near
+ * @param far
+ */
+extern void __attribute__((overloadable))
+rsMatrixLoadFrustum(rs_matrix4x4 *m, float left, float right, float bottom, float top, float near, float far);
+
+/**
+ * Load an perspective projection matrix constructed from the 6 planes
+ *
+ * @param m
+ * @param fovy Field of view, in degrees along the Y axis.
+ * @param aspect Ratio of x / y.
+ * @param near
+ * @param far
+ */
+extern void __attribute__((overloadable))
+rsMatrixLoadPerspective(rs_matrix4x4* m, float fovy, float aspect, float near, float far);
+
+#if !defined(RS_VERSION) || (RS_VERSION < 14)
+/**
+ * Multiply a vector by a matrix and return the result vector.
+ * API version 10-13
+ */
+_RS_RUNTIME float4 __attribute__((overloadable))
+rsMatrixMultiply(rs_matrix4x4 *m, float4 in);
+
+/**
+ * \overload
+ */
+_RS_RUNTIME float4 __attribute__((overloadable))
+rsMatrixMultiply(rs_matrix4x4 *m, float3 in);
+
+/**
+ * \overload
+ */
+_RS_RUNTIME float4 __attribute__((overloadable))
+rsMatrixMultiply(rs_matrix4x4 *m, float2 in);
+
+/**
+ * \overload
+ */
+_RS_RUNTIME float3 __attribute__((overloadable))
+rsMatrixMultiply(rs_matrix3x3 *m, float3 in);
+
+/**
+ * \overload
+ */
+_RS_RUNTIME float3 __attribute__((overloadable))
+rsMatrixMultiply(rs_matrix3x3 *m, float2 in);
+
+/**
+ * \overload
+ */
+_RS_RUNTIME float2 __attribute__((overloadable))
+rsMatrixMultiply(rs_matrix2x2 *m, float2 in);
+#else
+/**
+ * Multiply a vector by a matrix and return the result vector.
+ * API version 10-13
+ */
+_RS_RUNTIME float4 __attribute__((overloadable))
+rsMatrixMultiply(const rs_matrix4x4 *m, float4 in);
+
+/**
+ * \overload
+ */
+_RS_RUNTIME float4 __attribute__((overloadable))
+rsMatrixMultiply(const rs_matrix4x4 *m, float3 in);
+
+/**
+ * \overload
+ */
+_RS_RUNTIME float4 __attribute__((overloadable))
+rsMatrixMultiply(const rs_matrix4x4 *m, float2 in);
+
+/**
+ * \overload
+ */
+_RS_RUNTIME float3 __attribute__((overloadable))
+rsMatrixMultiply(const rs_matrix3x3 *m, float3 in);
+
+/**
+ * \overload
+ */
+_RS_RUNTIME float3 __attribute__((overloadable))
+rsMatrixMultiply(const rs_matrix3x3 *m, float2 in);
+
+/**
+ * \overload
+ */
+_RS_RUNTIME float2 __attribute__((overloadable))
+rsMatrixMultiply(const rs_matrix2x2 *m, float2 in);
+#endif
+
+
+/**
+ * Returns true if the matrix was successfully inversed
+ *
+ * @param m
+ */
+extern bool __attribute__((overloadable)) rsMatrixInverse(rs_matrix4x4 *m);
+
+/**
+ * Returns true if the matrix was successfully inversed and transposed.
+ *
+ * @param m
+ */
+extern bool __attribute__((overloadable)) rsMatrixInverseTranspose(rs_matrix4x4 *m);
+
+/**
+ * Transpose the matrix m.
+ *
+ * @param m
+ */
+extern void __attribute__((overloadable)) rsMatrixTranspose(rs_matrix4x4 *m);
+/**
+ * \overload
+ */
+extern void __attribute__((overloadable)) rsMatrixTranspose(rs_matrix3x3 *m);
+/**
+ * \overload
+ */
+extern void __attribute__((overloadable)) rsMatrixTranspose(rs_matrix2x2 *m);
+
+
+#endif
diff --git a/libs/rs/scriptc/rs_object.rsh b/libs/rs/scriptc/rs_object.rsh
new file mode 100644
index 0000000..a431219
--- /dev/null
+++ b/libs/rs/scriptc/rs_object.rsh
@@ -0,0 +1,205 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/** @file rs_object.rsh
+ *  \brief Object routines
+ *
+ *
+ */
+
+#ifndef __RS_OBJECT_RSH__
+#define __RS_OBJECT_RSH__
+
+
+/**
+ * Copy reference to the specified object.
+ *
+ * @param dst
+ * @param src
+ */
+extern void __attribute__((overloadable))
+    rsSetObject(rs_element *dst, rs_element src);
+/**
+ * \overload
+ */
+extern void __attribute__((overloadable))
+    rsSetObject(rs_type *dst, rs_type src);
+/**
+ * \overload
+ */
+extern void __attribute__((overloadable))
+    rsSetObject(rs_allocation *dst, rs_allocation src);
+/**
+ * \overload
+ */
+extern void __attribute__((overloadable))
+    rsSetObject(rs_sampler *dst, rs_sampler src);
+/**
+ * \overload
+ */
+extern void __attribute__((overloadable))
+    rsSetObject(rs_script *dst, rs_script src);
+/**
+ * \overload
+ */
+extern void __attribute__((overloadable))
+    rsSetObject(rs_mesh *dst, rs_mesh src);
+/**
+ * \overload
+ */
+extern void __attribute__((overloadable))
+    rsSetObject(rs_program_fragment *dst, rs_program_fragment src);
+/**
+ * \overload
+ */
+extern void __attribute__((overloadable))
+    rsSetObject(rs_program_vertex *dst, rs_program_vertex src);
+/**
+ * \overload
+ */
+extern void __attribute__((overloadable))
+    rsSetObject(rs_program_raster *dst, rs_program_raster src);
+/**
+ * \overload
+ */
+extern void __attribute__((overloadable))
+    rsSetObject(rs_program_store *dst, rs_program_store src);
+/**
+ * \overload
+ */
+extern void __attribute__((overloadable))
+    rsSetObject(rs_font *dst, rs_font src);
+
+/**
+ * Sets the object to NULL.
+ *
+ * @return bool
+ */
+extern void __attribute__((overloadable))
+    rsClearObject(rs_element *dst);
+/**
+ * \overload
+ */
+extern void __attribute__((overloadable))
+    rsClearObject(rs_type *dst);
+/**
+ * \overload
+ */
+extern void __attribute__((overloadable))
+    rsClearObject(rs_allocation *dst);
+/**
+ * \overload
+ */
+extern void __attribute__((overloadable))
+    rsClearObject(rs_sampler *dst);
+/**
+ * \overload
+ */
+extern void __attribute__((overloadable))
+    rsClearObject(rs_script *dst);
+/**
+ * \overload
+ */
+extern void __attribute__((overloadable))
+    rsClearObject(rs_mesh *dst);
+/**
+ * \overload
+ */
+extern void __attribute__((overloadable))
+    rsClearObject(rs_program_fragment *dst);
+/**
+ * \overload
+ */
+extern void __attribute__((overloadable))
+    rsClearObject(rs_program_vertex *dst);
+/**
+ * \overload
+ */
+extern void __attribute__((overloadable))
+    rsClearObject(rs_program_raster *dst);
+/**
+ * \overload
+ */
+extern void __attribute__((overloadable))
+    rsClearObject(rs_program_store *dst);
+/**
+ * \overload
+ */
+extern void __attribute__((overloadable))
+    rsClearObject(rs_font *dst);
+
+
+
+/**
+ * Tests if the object is valid.  Returns true if the object is valid, false if
+ * it is NULL.
+ *
+ * @return bool
+ */
+extern bool __attribute__((overloadable))
+    rsIsObject(rs_element);
+/**
+ * \overload
+ */
+extern bool __attribute__((overloadable))
+    rsIsObject(rs_type);
+/**
+ * \overload
+ */
+extern bool __attribute__((overloadable))
+    rsIsObject(rs_allocation);
+/**
+ * \overload
+ */
+extern bool __attribute__((overloadable))
+    rsIsObject(rs_sampler);
+/**
+ * \overload
+ */
+extern bool __attribute__((overloadable))
+    rsIsObject(rs_script);
+/**
+ * \overload
+ */
+extern bool __attribute__((overloadable))
+    rsIsObject(rs_mesh);
+/**
+ * \overload
+ */
+extern bool __attribute__((overloadable))
+    rsIsObject(rs_program_fragment);
+/**
+ * \overload
+ */
+extern bool __attribute__((overloadable))
+    rsIsObject(rs_program_vertex);
+/**
+ * \overload
+ */
+extern bool __attribute__((overloadable))
+    rsIsObject(rs_program_raster);
+/**
+ * \overload
+ */
+extern bool __attribute__((overloadable))
+    rsIsObject(rs_program_store);
+/**
+ * \overload
+ */
+extern bool __attribute__((overloadable))
+    rsIsObject(rs_font);
+
+#endif
diff --git a/libs/rs/scriptc/rs_quaternion.rsh b/libs/rs/scriptc/rs_quaternion.rsh
new file mode 100644
index 0000000..36e6736
--- /dev/null
+++ b/libs/rs/scriptc/rs_quaternion.rsh
@@ -0,0 +1,257 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/** @file rs_matrix.rsh
+ *  \brief Quaternion routines
+ *
+ *
+ */
+
+#ifndef __RS_QUATERNION_RSH__
+#define __RS_QUATERNION_RSH__
+
+
+/**
+ * Set the quaternion components
+ * @param w component
+ * @param x component
+ * @param y component
+ * @param z component
+ */
+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;
+}
+
+/**
+ * Set the quaternion from another quaternion
+ * @param q destination quaternion
+ * @param rhs source quaternion
+ */
+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;
+}
+
+/**
+ * Multiply quaternion by a scalar
+ * @param q quaternion to multiply
+ * @param s scalar
+ */
+static void __attribute__((overloadable))
+rsQuaternionMultiply(rs_quaternion *q, float s) {
+    q->w *= s;
+    q->x *= s;
+    q->y *= s;
+    q->z *= s;
+}
+
+/**
+ * Multiply quaternion by another quaternion
+ * @param q destination quaternion
+ * @param rhs right hand side quaternion to multiply by
+ */
+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;
+}
+
+/**
+ * Add two quaternions
+ * @param q destination quaternion to add to
+ * @param rsh right hand side quaternion to add
+ */
+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;
+}
+
+/**
+ * Loads a quaternion that represents a rotation about an arbitrary unit vector
+ * @param q quaternion to set
+ * @param rot angle to rotate by
+ * @param x component of a vector
+ * @param y component of a vector
+ * @param x component of a vector
+ */
+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;
+}
+
+/**
+ * Loads a quaternion that represents a rotation about an arbitrary vector
+ * (doesn't have to be unit)
+ * @param q quaternion to set
+ * @param rot angle to rotate by
+ * @param x component of a vector
+ * @param y component of a vector
+ * @param x component of a vector
+ */
+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);
+}
+
+/**
+ * Conjugates the quaternion
+ * @param q quaternion to conjugate
+ */
+static void
+rsQuaternionConjugate(rs_quaternion *q) {
+    q->x = -q->x;
+    q->y = -q->y;
+    q->z = -q->z;
+}
+
+/**
+ * Dot product of two quaternions
+ * @param q0 first quaternion
+ * @param q1 second quaternion
+ * @return dot product between q0 and q1
+ */
+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;
+}
+
+/**
+ * Normalizes the quaternion
+ * @param q quaternion to normalize
+ */
+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);
+    }
+}
+
+/**
+ * Performs spherical linear interpolation between two quaternions
+ * @param q result quaternion from interpolation
+ * @param q0 first param
+ * @param q1 second param
+ * @param t how much to interpolate by
+ */
+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);
+}
+
+/**
+ * Computes rotation matrix from the normalized quaternion
+ * @param m resulting matrix
+ * @param p normalized quaternion
+ */
+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;
+}
+
+#endif
+
diff --git a/libs/rs/scriptc/rs_time.rsh b/libs/rs/scriptc/rs_time.rsh
index f1abed63..f8f297d 100644
--- a/libs/rs/scriptc/rs_time.rsh
+++ b/libs/rs/scriptc/rs_time.rsh
@@ -1,3 +1,25 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/** @file rs_time.rsh
+ *  \brief Time routines
+ *
+ *
+ */
+
 #ifndef __RS_TIME_RSH__
 #define __RS_TIME_RSH__
 
diff --git a/libs/rs/scriptc/rs_types.rsh b/libs/rs/scriptc/rs_types.rsh
index 9a79f5e..875beb9 100644
--- a/libs/rs/scriptc/rs_types.rsh
+++ b/libs/rs/scriptc/rs_types.rsh
@@ -1,4 +1,20 @@
-/** @file rs_time.rsh
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/** @file rs_types.rsh
  *
  *  Define the standard Renderscript types
  *
diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java
index 4e9f752..9bf8b2d 100644
--- a/media/java/android/media/AudioService.java
+++ b/media/java/android/media/AudioService.java
@@ -55,7 +55,6 @@
 import java.io.FileDescriptor;
 import java.io.IOException;
 import java.io.PrintWriter;
-import java.lang.ref.SoftReference;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -2159,7 +2158,7 @@
 
                 case MSG_RCDISPLAY_UPDATE:
                     synchronized(mCurrentRcLock) {
-                        if (mCurrentRcClientRef.get() == null) {
+                        if (mCurrentRcClient == null) {
                             // the remote control display owner has changed between the
                             // the message to update the display was sent, and the time it
                             // gets to be processed (now)
@@ -2848,11 +2847,10 @@
     private final Object mCurrentRcLock = new Object();
     /**
      * The one remote control client to be polled for display information.
-     * This object is never null, but its reference might.
+     * This object may be null.
      * Access protected by mCurrentRcLock.
      */
-    private SoftReference<IRemoteControlClient> mCurrentRcClientRef =
-            new SoftReference<IRemoteControlClient>(null);
+    private IRemoteControlClient mCurrentRcClient = null;
 
     private final static int RC_INFO_NONE = 0;
     private final static int RC_INFO_ALL =
@@ -2868,8 +2866,9 @@
     private int mCurrentRcClientInfoFlags = RC_INFO_ALL;
 
     /**
-     * A monotonically increasing generation counter for mCurrentRcClientRef.
+     * A monotonically increasing generation counter for mCurrentRcClient.
      * Only accessed with a lock on mCurrentRcLock.
+     * No value wrap-around issues as we only act on equal values.
      */
     private int mCurrentRcClientGen = 0;
 
@@ -2885,7 +2884,7 @@
     public IRemoteControlClient getRemoteControlClient(int rcClientId) {
         synchronized(mCurrentRcLock) {
             if (rcClientId == mCurrentRcClientGen) {
-                return mCurrentRcClientRef.get();
+                return mCurrentRcClient;
             } else {
                 return null;
             }
@@ -2945,13 +2944,13 @@
         public int mCallingUid;
 
         /** provides access to the information to display on the remote control */
-        public SoftReference<IRemoteControlClient> mRcClientRef;
+        public IRemoteControlClient mRcClient;
         public RcClientDeathHandler mRcClientDeathHandler;
 
         public RemoteControlStackEntry(ComponentName r) {
             mReceiverComponent = r;
             mCallingUid = -1;
-            mRcClientRef = new SoftReference<IRemoteControlClient>(null);
+            mRcClient = null;
         }
 
         public void unlinkToRcClientDeath() {
@@ -2986,7 +2985,7 @@
             while(stackIterator.hasNext()) {
                 RemoteControlStackEntry rcse = stackIterator.next();
                 pw.println("     receiver: " + rcse.mReceiverComponent +
-                        "  -- client: " + rcse.mRcClientRef.get() +
+                        "  -- client: " + rcse.mRcClient +
                         "  -- uid: " + rcse.mCallingUid);
             }
         }
@@ -3105,7 +3104,7 @@
      */
     private void clearRemoteControlDisplay() {
         synchronized(mCurrentRcLock) {
-            mCurrentRcClientRef.clear();
+            mCurrentRcClient = null;
             mCurrentRcClientInfoFlags = RC_INFO_NONE;
         }
         mAudioHandler.sendMessage( mAudioHandler.obtainMessage(MSG_RCDISPLAY_CLEAR) );
@@ -3120,18 +3119,17 @@
         RemoteControlStackEntry rcse = mRCStack.peek();
         // this is where we enforce opt-in for information display on the remote controls
         //   with the new AudioManager.registerRemoteControlClient() API
-        if (rcse.mRcClientRef.get() == null) {
-            // FIXME remove log before release: this warning will be displayed for every AF change
-            Log.w(TAG, "Can't update remote control display with null remote control client");
+        if (rcse.mRcClient == null) {
+            //Log.w(TAG, "Can't update remote control display with null remote control client");
             clearRemoteControlDisplay();
             return;
         }
         synchronized(mCurrentRcLock) {
-            if (!rcse.mRcClientRef.get().equals(mCurrentRcClientRef.get())) {
+            if (!rcse.mRcClient.equals(mCurrentRcClient)) {
                 // new RC client, assume every type of information shall be queried
                 mCurrentRcClientInfoFlags = RC_INFO_ALL;
             }
-            mCurrentRcClientRef = rcse.mRcClientRef;
+            mCurrentRcClient = rcse.mRcClient;
         }
         mAudioHandler.sendMessage( mAudioHandler.obtainMessage(MSG_RCDISPLAY_UPDATE, 0, 0, rcse) );
     }
@@ -3209,7 +3207,7 @@
                             rcse.unlinkToRcClientDeath();
                         }
                         // save the new remote control client
-                        rcse.mRcClientRef = new SoftReference<IRemoteControlClient>(rcClient);
+                        rcse.mRcClient = rcClient;
                         rcse.mCallingPackageName = callingPackageName;
                         rcse.mCallingUid = Binder.getCallingUid();
                         if (rcClient == null) {
@@ -3224,7 +3222,7 @@
                         } catch (RemoteException e) {
                             // remote control client is DOA, disqualify it
                             Log.w(TAG, "registerRemoteControlClient() has a dead client " + b);
-                            rcse.mRcClientRef.clear();
+                            rcse.mRcClient = null;
                         }
                         rcse.mRcClientDeathHandler = rcdh;
                         break;
diff --git a/media/java/android/media/MediaFile.java b/media/java/android/media/MediaFile.java
index 816d215..8793841 100644
--- a/media/java/android/media/MediaFile.java
+++ b/media/java/android/media/MediaFile.java
@@ -67,8 +67,9 @@
     public static final int FILE_TYPE_MKV     = 27;
     public static final int FILE_TYPE_MP2TS   = 28;
     public static final int FILE_TYPE_AVI     = 29;
+    public static final int FILE_TYPE_WEBM    = 30;
     private static final int FIRST_VIDEO_FILE_TYPE = FILE_TYPE_MP4;
-    private static final int LAST_VIDEO_FILE_TYPE = FILE_TYPE_AVI;
+    private static final int LAST_VIDEO_FILE_TYPE = FILE_TYPE_WEBM;
     
     // Image file types
     public static final int FILE_TYPE_JPEG    = 31;
@@ -198,7 +199,7 @@
         addFileType("3G2", FILE_TYPE_3GPP2, "video/3gpp2", MtpConstants.FORMAT_3GP_CONTAINER);
         addFileType("3GPP2", FILE_TYPE_3GPP2, "video/3gpp2", MtpConstants.FORMAT_3GP_CONTAINER);
         addFileType("MKV", FILE_TYPE_MKV, "video/x-matroska");
-        addFileType("WEBM", FILE_TYPE_MKV, "video/x-matroska");
+        addFileType("WEBM", FILE_TYPE_WEBM, "video/webm");
         addFileType("TS", FILE_TYPE_MP2TS, "video/mp2ts");
         addFileType("AVI", FILE_TYPE_AVI, "video/avi");
 
diff --git a/media/java/android/media/MediaPlayer.java b/media/java/android/media/MediaPlayer.java
index 1bacdbb..434ef14 100644
--- a/media/java/android/media/MediaPlayer.java
+++ b/media/java/android/media/MediaPlayer.java
@@ -607,13 +607,13 @@
 
     /**
      * Sets the {@link SurfaceHolder} to use for displaying the video
-     * portion of the media.  A surface must be set if a display is
-     * needed.  Not calling this method when playing back a video will
-     * result in only the audio track being played.
+     * portion of the media.
      *
      * Either a surface holder or surface must be set if a display or video sink
      * is needed.  Not calling this method or {@link #setTexture(SurfaceTexture)}
      * when playing back a video will result in only the audio track being played.
+     * A null surface holder or surface will result in only the audio track being
+     * played.
      *
      * @param sh the SurfaceHolder to use for video display
      */
@@ -634,6 +634,7 @@
      * the media. This is similar to {@link #setDisplay(SurfaceHolder)}, but does not
      * support {@link #setScreenOnWhilePlaying(boolean)} or {@link #updateSurfaceScreenOn()}.
      * Setting a Surface will un-set any Surface or SurfaceHolder that was previously set.
+     * A null surface will result in only the audio track being played.
      *
      * @param surface The {@link Surface} to be used for the video portion of the media.
      *
diff --git a/media/java/android/media/MediaScanner.java b/media/java/android/media/MediaScanner.java
index 02017a1..1ba4c4f 100644
--- a/media/java/android/media/MediaScanner.java
+++ b/media/java/android/media/MediaScanner.java
@@ -312,6 +312,18 @@
 
     private final String mExternalStoragePath;
 
+    // WARNING: Bulk inserts sounded like a great idea and gave us a good performance improvement,
+    // but unfortunately it also introduced a number of bugs.  Many of those bugs were fixed,
+    // but (at least) two problems are still outstanding:
+    //
+    // 1) Bulk inserts broke the code that sets the default ringtones on first boot
+    // 2) Bulk inserts broke file based playlists in the case where the playlist is processed
+    //    at the same time the files in the playlist are inserted in the database
+    //
+    // These problems might be solvable by moving the logic to the media provider instead,
+    // but for now we are disabling bulk inserts until we have solid fixes for these problems.
+    private static final boolean ENABLE_BULK_INSERTS = false;
+
     // used when scanning the image database so we know whether we have to prune
     // old thumbnail files
     private int mOriginalCount;
@@ -1166,25 +1178,29 @@
             prescan(null, true);
             long prescan = System.currentTimeMillis();
 
-            // create FileInserters for bulk inserts
-            mAudioInserter = new FileInserter(mAudioUri, 500);
-            mVideoInserter = new FileInserter(mVideoUri, 500);
-            mImageInserter = new FileInserter(mImagesUri, 500);
-            mFileInserter = new FileInserter(mFilesUri, 500);
+            if (ENABLE_BULK_INSERTS) {
+                // create FileInserters for bulk inserts
+                mAudioInserter = new FileInserter(mAudioUri, 500);
+                mVideoInserter = new FileInserter(mVideoUri, 500);
+                mImageInserter = new FileInserter(mImagesUri, 500);
+                mFileInserter = new FileInserter(mFilesUri, 500);
+            }
 
             for (int i = 0; i < directories.length; i++) {
                 processDirectory(directories[i], mClient);
             }
 
-            // flush remaining inserts
-            mAudioInserter.flush();
-            mVideoInserter.flush();
-            mImageInserter.flush();
-            mFileInserter.flush();
-            mAudioInserter = null;
-            mVideoInserter = null;
-            mImageInserter = null;
-            mFileInserter = null;
+            if (ENABLE_BULK_INSERTS) {
+                // flush remaining inserts
+                mAudioInserter.flush();
+                mVideoInserter.flush();
+                mImageInserter.flush();
+                mFileInserter.flush();
+                mAudioInserter = null;
+                mVideoInserter = null;
+                mImageInserter = null;
+                mFileInserter = null;
+            }
 
             long scan = System.currentTimeMillis();
             postscan(directories);
diff --git a/media/jni/android_media_MediaPlayer.cpp b/media/jni/android_media_MediaPlayer.cpp
index 5663683..9090daa 100644
--- a/media/jni/android_media_MediaPlayer.cpp
+++ b/media/jni/android_media_MediaPlayer.cpp
@@ -247,9 +247,8 @@
 static void setVideoSurfaceOrSurfaceTexture(
         const sp<MediaPlayer>& mp, JNIEnv *env, jobject thiz, const char *prefix)
 {
-    // The Java MediaPlayer class makes sure that at most one of mSurface and
-    // mParcelSurfaceTexture is non-null.  But just in case, we give priority to
-    // mSurface over mParcelSurfaceTexture.
+    // Both mSurface and mParcelSurfaceTexture could be null.
+    // We give priority to mSurface over mParcelSurfaceTexture.
     jobject surface = env->GetObjectField(thiz, fields.surface);
     if (surface != NULL) {
         sp<Surface> native_surface(get_surface(env, surface));
@@ -263,6 +262,8 @@
                     ParcelSurfaceTexture_getISurfaceTexture(env, parcelSurfaceTexture));
             LOGV("%s: texture=%p", prefix, native_surfaceTexture.get());
             mp->setVideoSurfaceTexture(native_surfaceTexture);
+        } else {
+            mp->setVideoSurfaceTexture(NULL);
         }
     }
 }
diff --git a/media/libmediaplayerservice/MediaPlayerService.cpp b/media/libmediaplayerservice/MediaPlayerService.cpp
index 1e7c969..8630ec1 100644
--- a/media/libmediaplayerservice/MediaPlayerService.cpp
+++ b/media/libmediaplayerservice/MediaPlayerService.cpp
@@ -255,8 +255,8 @@
             this, pid, connId, client, audioSessionId,
             IPCThreadState::self()->getCallingUid());
 
-    LOGV("Create new client(%d) from pid %d, url=%s, connId=%d, audioSessionId=%d",
-            connId, pid, url, connId, audioSessionId);
+    LOGV("Create new client(%d) from pid %d, uid %d, url=%s, connId=%d, audioSessionId=%d",
+            connId, pid, IPCThreadState::self()->getCallingUid(), url, connId, audioSessionId);
     if (NO_ERROR != c->setDataSource(url, headers))
     {
         c.clear();
@@ -277,8 +277,9 @@
             this, pid, connId, client, audioSessionId,
             IPCThreadState::self()->getCallingUid());
 
-    LOGV("Create new client(%d) from pid %d, fd=%d, offset=%lld, length=%lld, audioSessionId=%d",
-            connId, pid, fd, offset, length, audioSessionId);
+    LOGV("Create new client(%d) from pid %d, uid %d, fd=%d, offset=%lld, "
+         "length=%lld, audioSessionId=%d", connId, pid,
+         IPCThreadState::self()->getCallingUid(), fd, offset, length, audioSessionId);
     if (NO_ERROR != c->setDataSource(fd, offset, length)) {
         c.clear();
     } else {
diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp
index 67f6c79..9c9bc2d 100644
--- a/media/libstagefright/AwesomePlayer.cpp
+++ b/media/libstagefright/AwesomePlayer.cpp
@@ -1157,6 +1157,8 @@
     mSurface.clear();
     if (surfaceTexture != NULL) {
         setNativeWindow_l(new SurfaceTextureClient(surfaceTexture));
+    } else {
+        setNativeWindow_l(NULL);
     }
 }
 
@@ -1769,7 +1771,8 @@
         }
     }
 
-    if (mVideoRendererIsPreview || mVideoRenderer == NULL) {
+    if ((mNativeWindow != NULL)
+            && (mVideoRendererIsPreview || mVideoRenderer == NULL)) {
         mVideoRendererIsPreview = false;
 
         initRenderer_l();
diff --git a/media/libstagefright/HTTPBase.cpp b/media/libstagefright/HTTPBase.cpp
index f9d8501..3c5a8a5 100644
--- a/media/libstagefright/HTTPBase.cpp
+++ b/media/libstagefright/HTTPBase.cpp
@@ -39,7 +39,8 @@
       mPrevBandwidthMeasureTimeUs(0),
       mPrevEstimatedBandWidthKbps(0),
       mBandWidthCollectFreqMs(5000),
-      mUIDValid(false) {
+      mUIDValid(false),
+      mUID(0) {
 }
 
 // static
@@ -135,9 +136,19 @@
 }
 
 // static
-void HTTPBase::RegisterSocketUser(int s, uid_t uid) {
-    static const uint32_t kTag = 0xdeadbeef;
-    set_qtaguid(s, kTag, uid);
+void HTTPBase::RegisterSocketUserTag(int sockfd, uid_t uid, uint32_t kTag) {
+    int res = qtaguid_tagSocket(sockfd, kTag, uid);
+    if (res != 0) {
+        LOGE("Failed tagging socket %d for uid %d (My UID=%d)", sockfd, uid, geteuid());
+    }
+}
+
+// static
+void HTTPBase::UnRegisterSocketUserTag(int sockfd) {
+    int res = qtaguid_untagSocket(sockfd);
+    if (res != 0) {
+        LOGE("Failed untagging socket %d (My UID=%d)", sockfd, geteuid());
+    }
 }
 
 }  // namespace android
diff --git a/media/libstagefright/SurfaceMediaSource.cpp b/media/libstagefright/SurfaceMediaSource.cpp
index 3d8c56a..ddfd9ff 100644
--- a/media/libstagefright/SurfaceMediaSource.cpp
+++ b/media/libstagefright/SurfaceMediaSource.cpp
@@ -371,7 +371,8 @@
     return err;
 }
 
-status_t SurfaceMediaSource::connect(int api) {
+status_t SurfaceMediaSource::connect(int api,
+        uint32_t* outWidth, uint32_t* outHeight, uint32_t* outTransform) {
     LOGV("SurfaceMediaSource::connect");
     Mutex::Autolock lock(mMutex);
     status_t err = NO_ERROR;
@@ -384,6 +385,9 @@
                 err = -EINVAL;
             } else {
                 mConnectedApi = api;
+                *outWidth = mDefaultWidth;
+                *outHeight = mDefaultHeight;
+                *outTransform = 0;
             }
             break;
         default:
diff --git a/media/libstagefright/chromium_http/ChromiumHTTPDataSource.cpp b/media/libstagefright/chromium_http/ChromiumHTTPDataSource.cpp
index 887fe7c..180460b 100644
--- a/media/libstagefright/chromium_http/ChromiumHTTPDataSource.cpp
+++ b/media/libstagefright/chromium_http/ChromiumHTTPDataSource.cpp
@@ -61,6 +61,12 @@
         off64_t offset) {
     Mutex::Autolock autoLock(mLock);
 
+    uid_t uid;
+    if (getUID(&uid)) {
+        mDelegate->setUID(uid);
+    }
+    LOG_PRI(ANDROID_LOG_VERBOSE, LOG_TAG, "connect on behalf of uid %d", uid);
+
     return connect_l(uri, headers, offset);
 }
 
diff --git a/media/libstagefright/chromium_http/support.cpp b/media/libstagefright/chromium_http/support.cpp
index 26c3eda..de936c4 100644
--- a/media/libstagefright/chromium_http/support.cpp
+++ b/media/libstagefright/chromium_http/support.cpp
@@ -23,6 +23,7 @@
 #include "support.h"
 
 #include "android/net/android_network_library_impl.h"
+#include "base/logging.h"
 #include "base/threading/thread.h"
 #include "net/base/cert_verifier.h"
 #include "net/base/cookie_monster.h"
@@ -34,8 +35,10 @@
 
 #include "include/ChromiumHTTPDataSource.h"
 
+#include <cutils/log.h>
 #include <cutils/properties.h>
 #include <media/stagefright/MediaErrors.h>
+#include <string>
 
 namespace android {
 
@@ -44,6 +47,34 @@
 static scoped_refptr<net::URLRequestContext> gReqContext;
 static scoped_ptr<net::NetworkChangeNotifier> gNetworkChangeNotifier;
 
+bool logMessageHandler(
+        int severity,
+        const char* file,
+        int line,
+        size_t message_start,
+        const std::string& str) {
+    int androidSeverity = ANDROID_LOG_VERBOSE;
+    switch(severity) {
+    case logging::LOG_FATAL:
+        androidSeverity = ANDROID_LOG_FATAL;
+        break;
+    case logging::LOG_ERROR_REPORT:
+    case logging::LOG_ERROR:
+        androidSeverity = ANDROID_LOG_ERROR;
+        break;
+    case logging::LOG_WARNING:
+        androidSeverity = ANDROID_LOG_WARN;
+        break;
+    default:
+        androidSeverity = ANDROID_LOG_VERBOSE;
+        break;
+    }
+    android_printLog(androidSeverity, "chromium-libstagefright",
+                    "%s:%d: %s", file, line, str.c_str());
+    return false;
+}
+
+
 static void InitializeNetworkThreadIfNecessary() {
     Mutex::Autolock autoLock(gNetworkThreadLock);
     if (gNetworkThread == NULL) {
@@ -58,6 +89,7 @@
 
         net::AndroidNetworkLibrary::RegisterSharedInstance(
                 new SfNetworkLibrary);
+        logging::SetLogMessageHandler(logMessageHandler);
     }
 }
 
@@ -181,6 +213,14 @@
     mOwner = owner;
 }
 
+void SfDelegate::setUID(uid_t uid) {
+    gReqContext->setUID(uid);
+}
+
+bool SfDelegate::getUID(uid_t *uid) const {
+    return gReqContext->getUID(uid);
+}
+
 void SfDelegate::OnReceivedRedirect(
             net::URLRequest *request, const GURL &new_url, bool *defer_redirect) {
     MY_LOGV("OnReceivedRedirect");
diff --git a/media/libstagefright/chromium_http/support.h b/media/libstagefright/chromium_http/support.h
index 8fe8db1..d2c5bc0 100644
--- a/media/libstagefright/chromium_http/support.h
+++ b/media/libstagefright/chromium_http/support.h
@@ -91,6 +91,11 @@
 
     void setOwner(ChromiumHTTPDataSource *mOwner);
 
+    // Gets the UID of the calling process
+    bool getUID(uid_t *uid) const;
+
+    void setUID(uid_t uid);
+
     virtual void OnReceivedRedirect(
             net::URLRequest *request, const GURL &new_url, bool *defer_redirect);
 
diff --git a/media/libstagefright/include/HTTPBase.h b/media/libstagefright/include/HTTPBase.h
index 0e9af69..b8e10f7 100644
--- a/media/libstagefright/include/HTTPBase.h
+++ b/media/libstagefright/include/HTTPBase.h
@@ -53,7 +53,8 @@
 
     static sp<HTTPBase> Create(uint32_t flags = 0);
 
-    static void RegisterSocketUser(int s, uid_t uid);
+    static void RegisterSocketUserTag(int sockfd, uid_t uid, uint32_t kTag);
+    static void UnRegisterSocketUserTag(int sockfd);
 
 protected:
     void addBandwidthMeasurement(size_t numBytes, int64_t delayUs);
diff --git a/media/libstagefright/rtsp/ARTSPConnection.cpp b/media/libstagefright/rtsp/ARTSPConnection.cpp
index b398c9d..bd0e491 100644
--- a/media/libstagefright/rtsp/ARTSPConnection.cpp
+++ b/media/libstagefright/rtsp/ARTSPConnection.cpp
@@ -56,6 +56,9 @@
 ARTSPConnection::~ARTSPConnection() {
     if (mSocket >= 0) {
         LOGE("Connection is still open, closing the socket.");
+        if (mUIDValid) {
+            HTTPBase::UnRegisterSocketUserTag(mSocket);
+        }
         close(mSocket);
         mSocket = -1;
     }
@@ -202,6 +205,9 @@
     ++mConnectionID;
 
     if (mState != DISCONNECTED) {
+        if (mUIDValid) {
+            HTTPBase::UnRegisterSocketUserTag(mSocket);
+        }
         close(mSocket);
         mSocket = -1;
 
@@ -251,7 +257,8 @@
     mSocket = socket(AF_INET, SOCK_STREAM, 0);
 
     if (mUIDValid) {
-        HTTPBase::RegisterSocketUser(mSocket, mUID);
+        HTTPBase::RegisterSocketUserTag(mSocket, mUID,
+                                        (uint32_t)*(uint32_t*) "RTSP");
     }
 
     MakeSocketBlocking(mSocket, false);
@@ -279,6 +286,9 @@
         reply->setInt32("result", -errno);
         mState = DISCONNECTED;
 
+        if (mUIDValid) {
+            HTTPBase::UnRegisterSocketUserTag(mSocket);
+        }
         close(mSocket);
         mSocket = -1;
     } else {
@@ -294,6 +304,9 @@
 
 void ARTSPConnection::onDisconnect(const sp<AMessage> &msg) {
     if (mState == CONNECTED || mState == CONNECTING) {
+        if (mUIDValid) {
+            HTTPBase::UnRegisterSocketUserTag(mSocket);
+        }
         close(mSocket);
         mSocket = -1;
 
@@ -358,6 +371,9 @@
         reply->setInt32("result", -err);
 
         mState = DISCONNECTED;
+        if (mUIDValid) {
+            HTTPBase::UnRegisterSocketUserTag(mSocket);
+        }
         close(mSocket);
         mSocket = -1;
     } else {
diff --git a/media/libstagefright/rtsp/MyHandler.h b/media/libstagefright/rtsp/MyHandler.h
index 71d68f6..8128813 100644
--- a/media/libstagefright/rtsp/MyHandler.h
+++ b/media/libstagefright/rtsp/MyHandler.h
@@ -545,6 +545,12 @@
                 if (result != OK) {
                     if (track) {
                         if (!track->mUsingInterleavedTCP) {
+                            // Clear the tag
+                            if (mUIDValid) {
+                                HTTPBase::UnRegisterSocketUserTag(track->mRTPSocket);
+                                HTTPBase::UnRegisterSocketUserTag(track->mRTCPSocket);
+                            }
+
                             close(track->mRTPSocket);
                             close(track->mRTCPSocket);
                         }
@@ -618,6 +624,12 @@
                     if (!info->mUsingInterleavedTCP) {
                         mRTPConn->removeStream(info->mRTPSocket, info->mRTCPSocket);
 
+                        // Clear the tag
+                        if (mUIDValid) {
+                            HTTPBase::UnRegisterSocketUserTag(info->mRTPSocket);
+                            HTTPBase::UnRegisterSocketUserTag(info->mRTCPSocket);
+                        }
+
                         close(info->mRTPSocket);
                         close(info->mRTCPSocket);
                     }
@@ -1181,8 +1193,10 @@
                     &info->mRTPSocket, &info->mRTCPSocket, &rtpPort);
 
             if (mUIDValid) {
-                HTTPBase::RegisterSocketUser(info->mRTPSocket, mUID);
-                HTTPBase::RegisterSocketUser(info->mRTCPSocket, mUID);
+                HTTPBase::RegisterSocketUserTag(info->mRTPSocket, mUID,
+                                                (uint32_t)*(uint32_t*) "RTP_");
+                HTTPBase::RegisterSocketUserTag(info->mRTCPSocket, mUID,
+                                                (uint32_t)*(uint32_t*) "RTP_");
             }
 
             request.append("Transport: RTP/AVP/UDP;unicast;client_port=");
diff --git a/packages/SettingsProvider/res/values/defaults.xml b/packages/SettingsProvider/res/values/defaults.xml
index 12dbdf9..3920257 100644
--- a/packages/SettingsProvider/res/values/defaults.xml
+++ b/packages/SettingsProvider/res/values/defaults.xml
@@ -21,8 +21,8 @@
     <integer name="def_screen_off_timeout">60000</integer>
     <bool name="def_airplane_mode_on">false</bool>
     <!-- Comma-separated list of bluetooth, wifi, and cell. -->
-    <string name="def_airplane_mode_radios" translatable="false">cell,bluetooth,wifi</string>
-    <string name="airplane_mode_toggleable_radios" translatable="false">bluetooth,wifi</string>
+    <string name="def_airplane_mode_radios" translatable="false">cell,bluetooth,wifi,nfc</string>
+    <string name="airplane_mode_toggleable_radios" translatable="false">bluetooth,wifi,nfc</string>
     <bool name="def_auto_time">true</bool>
     <bool name="def_auto_time_zone">true</bool>
     <bool name="def_accelerometer_rotation">true</bool>
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
index f4890e0..5495d08 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
@@ -63,7 +63,7 @@
     // database gets upgraded properly. At a minimum, please confirm that 'upgradeVersion'
     // is properly propagated through your change.  Not doing so will result in a loss of user
     // settings.
-    private static final int DATABASE_VERSION = 69;
+    private static final int DATABASE_VERSION = 70;
 
     private Context mContext;
 
@@ -917,6 +917,25 @@
             upgradeVersion = 69;
         }
 
+        if (upgradeVersion == 69) {
+            // Add RADIO_NFC to AIRPLANE_MODE_RADIO and AIRPLANE_MODE_TOGGLEABLE_RADIOS
+            String airplaneRadios = mContext.getResources().getString(
+                    R.string.def_airplane_mode_radios);
+            String toggleableRadios = mContext.getResources().getString(
+                    R.string.airplane_mode_toggleable_radios);
+            db.beginTransaction();
+            try {
+                db.execSQL("UPDATE system SET value='" + airplaneRadios + "' " +
+                        "WHERE name='" + Settings.System.AIRPLANE_MODE_RADIOS + "'");
+                db.execSQL("UPDATE system SET value='" + toggleableRadios + "' " +
+                        "WHERE name='" + Settings.System.AIRPLANE_MODE_TOGGLEABLE_RADIOS + "'");
+                db.setTransactionSuccessful();
+            } finally {
+                db.endTransaction();
+            }
+            upgradeVersion = 70;
+        }
+
         // *** Remember to update DATABASE_VERSION above!
 
         if (upgradeVersion != currentVersion) {
diff --git a/packages/SystemUI/res/drawable-hdpi/status_bar_bg_tile.png b/packages/SystemUI/res/drawable-hdpi/status_bar_bg_tile.png
new file mode 100644
index 0000000..37cad22
--- /dev/null
+++ b/packages/SystemUI/res/drawable-hdpi/status_bar_bg_tile.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/status_bar_hr.9.png b/packages/SystemUI/res/drawable-hdpi/status_bar_hr.9.png
new file mode 100644
index 0000000..f5e6031
--- /dev/null
+++ b/packages/SystemUI/res/drawable-hdpi/status_bar_hr.9.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/status_bar_bg_tile.png b/packages/SystemUI/res/drawable-mdpi/status_bar_bg_tile.png
new file mode 100644
index 0000000..83d106d
--- /dev/null
+++ b/packages/SystemUI/res/drawable-mdpi/status_bar_bg_tile.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/status_bar_hr.9.png b/packages/SystemUI/res/drawable-mdpi/status_bar_hr.9.png
new file mode 100644
index 0000000..f5e6031
--- /dev/null
+++ b/packages/SystemUI/res/drawable-mdpi/status_bar_hr.9.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/status_bar_bg_tile.png b/packages/SystemUI/res/drawable-xhdpi/status_bar_bg_tile.png
new file mode 100644
index 0000000..9e21348
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xhdpi/status_bar_bg_tile.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/status_bar_hr.9.png b/packages/SystemUI/res/drawable-xhdpi/status_bar_hr.9.png
new file mode 100644
index 0000000..f5e6031
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xhdpi/status_bar_hr.9.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable/status_bar_bg.xml b/packages/SystemUI/res/drawable/status_bar_bg.xml
new file mode 100644
index 0000000..403493b
--- /dev/null
+++ b/packages/SystemUI/res/drawable/status_bar_bg.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+  
+          http://www.apache.org/licenses/LICENSE-2.0
+  
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<bitmap
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:tileMode="repeat"
+    android:src="@drawable/status_bar_bg_tile"
+    />
diff --git a/packages/SystemUI/res/layout/status_bar.xml b/packages/SystemUI/res/layout/status_bar.xml
index 0f5aa93..d8d5d6d 100644
--- a/packages/SystemUI/res/layout/status_bar.xml
+++ b/packages/SystemUI/res/layout/status_bar.xml
@@ -121,15 +121,4 @@
                 />
         </com.android.systemui.statusbar.phone.TickerView>
     </LinearLayout>
-
-    <com.android.systemui.statusbar.policy.DateView android:id="@+id/date"
-        android:textAppearance="@*android:style/TextAppearance.StatusBar.Icon"
-        android:layout_width="wrap_content"
-        android:layout_height="match_parent"
-        android:singleLine="true"
-        android:gravity="center_vertical|left"
-        android:paddingLeft="6px"
-        android:paddingRight="6px"
-        android:background="@drawable/status_bar_background"
-        />
 </com.android.systemui.statusbar.phone.PhoneStatusBarView>
diff --git a/packages/SystemUI/res/layout/status_bar_expanded.xml b/packages/SystemUI/res/layout/status_bar_expanded.xml
index 0cfcae1..dbbaf96 100644
--- a/packages/SystemUI/res/layout/status_bar_expanded.xml
+++ b/packages/SystemUI/res/layout/status_bar_expanded.xml
@@ -26,15 +26,24 @@
     android:descendantFocusability="afterDescendants"
     >
 
-    <LinearLayout
+    <RelativeLayout
         android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:orientation="horizontal"
+        android:layout_height="55dp"
         android:paddingTop="3dp"
         android:paddingBottom="5dp"
         android:paddingRight="3dp"
-        android:background="@drawable/shade_header_background"
         >
+        <com.android.systemui.statusbar.policy.DateView android:id="@+id/date"
+            android:textAppearance="@android:style/TextAppearance.StatusBar.EventContent.Title"
+            android:textColor="@android:color/holo_blue_bright"
+            android:layout_width="wrap_content"
+            android:layout_height="match_parent"
+            android:layout_alignParentLeft="true"
+            android:singleLine="true"
+            android:gravity="center_vertical|left"
+            android:paddingLeft="16dp"
+            />
+        <!--
         <com.android.systemui.statusbar.phone.CarrierLabel
             android:layout_width="0dp"
             android:layout_height="wrap_content"
@@ -47,15 +56,30 @@
             android:textAppearance="?android:attr/textAppearanceLarge"
             android:textColor="?android:attr/textColorSecondary"
             />
+        -->
+        <ImageView android:id="@+id/settings_button"
+            android:layout_width="wrap_content"
+            android:layout_height="match_parent"
+            android:layout_toRightOf="@id/date"
+            android:paddingLeft="16dp"
+            android:paddingRight="16dp"
+            android:src="@drawable/ic_sysbar_quicksettings"
+            />
         <ImageView android:id="@+id/clear_all_button"
             android:layout_width="wrap_content"
             android:layout_height="match_parent"
-            android:layout_gravity="center_vertical"
-            android:paddingLeft="15dp"
-            android:paddingRight="15dp"
+            android:layout_alignParentRight="true"
+            android:paddingLeft="16dp"
+            android:paddingRight="16dp"
             android:src="@drawable/ic_notify_clear"
             />
-    </LinearLayout>
+    </RelativeLayout>
+
+    <View
+        android:layout_width="match_parent"
+        android:layout_height="3dp"
+        android:background="@drawable/status_bar_hr"
+        />
 
     <FrameLayout
         android:layout_width="match_parent" 
@@ -79,9 +103,9 @@
                 <TextView android:id="@+id/noNotificationsTitle"
                     android:layout_width="match_parent"
                     android:layout_height="wrap_content"
-                    android:background="@drawable/title_bar_portrait"
-                    android:paddingLeft="5dp"
-                    android:textAppearance="@style/TextAppearance.StatusBar.Title"
+                    android:textAppearance="@android:style/TextAppearance.Large"
+                    android:padding="8dp"
+                    android:gravity="center"
                     android:text="@string/status_bar_no_notifications_title"
                     />
 
diff --git a/packages/SystemUI/res/layout/status_bar_tracking.xml b/packages/SystemUI/res/layout/status_bar_tracking.xml
index baa45c5..894248e 100644
--- a/packages/SystemUI/res/layout/status_bar_tracking.xml
+++ b/packages/SystemUI/res/layout/status_bar_tracking.xml
@@ -30,7 +30,7 @@
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_weight="1"
-         android:background="#ff000000"
+         android:background="@drawable/status_bar_bg"
          />
 
     <com.android.systemui.statusbar.phone.CloseDragHandle android:id="@+id/close"
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ExpandedView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ExpandedView.java
index 3276e1f..2d3ecae 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ExpandedView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ExpandedView.java
@@ -18,6 +18,7 @@
 
 import android.content.Context;
 import android.util.AttributeSet;
+import android.util.Slog;
 import android.widget.LinearLayout;
 
 public class ExpandedView extends LinearLayout {
@@ -44,8 +45,10 @@
          super.onLayout(changed, left, top, right, bottom);
          int height = bottom - top;
          if (height != mPrevHeight) {
-             //Slog.d(StatusBar.TAG, "height changed old=" + mPrevHeight
-             //     + " new=" + height);
+             if (PhoneStatusBar.DEBUG) {
+                 Slog.d(PhoneStatusBar.TAG, "ExpandedView height changed old=" + mPrevHeight
+                      + " new=" + height);
+             }
              mPrevHeight = height;
              mService.updateExpandedViewPos(PhoneStatusBar.EXPANDED_LEAVE_ALONE);
          }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index 7d1aedc..e14317b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -40,6 +40,7 @@
 import android.os.Message;
 import android.os.ServiceManager;
 import android.os.SystemClock;
+import android.provider.Settings;
 import android.text.TextUtils;
 import android.util.Slog;
 import android.util.Log;
@@ -140,6 +141,8 @@
     // top bar
     TextView mNoNotificationsTitle;
     View mClearButton;
+    View mSettingsButton;
+
     // drag bar
     CloseDragHandle mCloseView;
     
@@ -252,6 +255,9 @@
 
         ExpandedView expanded = (ExpandedView)View.inflate(context,
                 R.layout.status_bar_expanded, null);
+        if (DEBUG) {
+            expanded.setBackgroundColor(0x6000FF80);
+        }
         expanded.mService = this;
 
         mIntruderAlertView = View.inflate(context, R.layout.intruder_alert, null);
@@ -296,7 +302,6 @@
         mNotificationIcons = (IconMerger)sb.findViewById(R.id.notificationIcons);
         mIcons = (LinearLayout)sb.findViewById(R.id.icons);
         mTickerView = sb.findViewById(R.id.ticker);
-        mDateView = (DateView)sb.findViewById(R.id.date);
 
         mExpandedDialog = new ExpandedDialog(context);
         mExpandedView = expanded;
@@ -305,6 +310,9 @@
         mNoNotificationsTitle = (TextView)expanded.findViewById(R.id.noNotificationsTitle);
         mClearButton = expanded.findViewById(R.id.clear_all_button);
         mClearButton.setOnClickListener(mClearButtonListener);
+        mDateView = (DateView)expanded.findViewById(R.id.date);
+        mSettingsButton = expanded.findViewById(R.id.settings_button);
+        mSettingsButton.setOnClickListener(mSettingsButtonListener);
         mScrollView = (ScrollView)expanded.findViewById(R.id.scroll);
         mNotificationLinearLayout = expanded.findViewById(R.id.notificationLinearLayout);
 
@@ -322,7 +330,6 @@
 
         // set the inital view visibility
         setAreThereNotifications();
-        mDateView.setVisibility(View.INVISIBLE);
 
         // Other icons
         mLocationController = new LocationController(mContext); // will post a notification
@@ -1106,10 +1113,6 @@
         mExpandedDialog.getWindow().setAttributes(mExpandedParams);
         mExpandedView.requestFocus(View.FOCUS_FORWARD);
         mTrackingView.setVisibility(View.VISIBLE);
-
-        if (!mTicking) {
-            setDateViewVisibility(true, com.android.internal.R.anim.fade_in);
-        }
     }
 
     public void animateExpand() {
@@ -1194,7 +1197,6 @@
         if ((mDisabled & StatusBarManager.DISABLE_NOTIFICATION_ICONS) == 0) {
             setNotificationIconVisibility(true, com.android.internal.R.anim.fade_in);
         }
-        setDateViewVisibility(false, com.android.internal.R.anim.fade_out);
 
         if (!mExpanded) {
             return;
@@ -1268,6 +1270,10 @@
             Slog.d(TAG, "panel: beginning to track the user's touch, y=" + y + " opening=" + opening);
         }
 
+        // there are some race conditions that cause this to be inaccurate; let's recalculate it any
+        // time we're about to drag the panel
+        updateExpandedSize();
+
         mTracking = true;
         mVelocityTracker = VelocityTracker.obtain();
         if (opening) {
@@ -1578,9 +1584,6 @@
             mTickerView.setVisibility(View.VISIBLE);
             mTickerView.startAnimation(loadAnim(com.android.internal.R.anim.push_up_in, null));
             mIcons.startAnimation(loadAnim(com.android.internal.R.anim.push_up_out, null));
-            if (mExpandedVisible) {
-                setDateViewVisibility(false, com.android.internal.R.anim.push_up_out);
-            }
         }
 
         @Override
@@ -1590,9 +1593,6 @@
             mIcons.startAnimation(loadAnim(com.android.internal.R.anim.push_down_in, null));
             mTickerView.startAnimation(loadAnim(com.android.internal.R.anim.push_down_out,
                         mTickingDoneListener));
-            if (mExpandedVisible) {
-                setDateViewVisibility(true, com.android.internal.R.anim.push_down_in);
-            }
         }
 
         public void tickerHalting() {
@@ -1601,9 +1601,6 @@
             mIcons.startAnimation(loadAnim(com.android.internal.R.anim.fade_in, null));
             mTickerView.startAnimation(loadAnim(com.android.internal.R.anim.fade_out,
                         mTickingDoneListener));
-            if (mExpandedVisible) {
-                setDateViewVisibility(true, com.android.internal.R.anim.fade_in);
-            }
         }
     }
 
@@ -1764,11 +1761,6 @@
         mExpandedDialog.show();
     }
 
-    void setDateViewVisibility(boolean visible, int anim) {
-        mDateView.setVisibility(visible ? View.VISIBLE : View.INVISIBLE);
-        mDateView.startAnimation(loadAnim(anim, null));
-    }
-
     void setNotificationIconVisibility(boolean visible, int anim) {
         int old = mNotificationIcons.getVisibility();
         int v = visible ? View.VISIBLE : View.INVISIBLE;
@@ -1795,7 +1787,7 @@
     void updateExpandedViewPos(int expandedPosition) {
         if (SPEW) {
             Slog.d(TAG, "updateExpandedViewPos before expandedPosition=" + expandedPosition
-                    + " mTrackingParams.y=" + mTrackingParams.y
+                    + " mTrackingParams.y=" + ((mTrackingParams == null) ? "?" : mTrackingParams.y)
                     + " mTrackingPosition=" + mTrackingPosition);
         }
 
@@ -1839,6 +1831,16 @@
 
                 mExpandedParams.y = pos + mTrackingView.getHeight()
                         - (mTrackingParams.height-closePos) - contentsBottom;
+
+                if (SPEW) {
+                    Slog.d(PhoneStatusBar.TAG, 
+                            "pos=" + pos +
+                            " trackingHeight=" + mTrackingView.getHeight() +
+                            " (trackingParams.height - closePos)=" + 
+                                (mTrackingParams.height - closePos) +
+                            " contentsBottom=" + contentsBottom);
+                }
+
             } else {
                 // If the tracking view is not yet visible, then we can't have
                 // a good value of the close view location.  We need to wait for
@@ -1881,6 +1883,10 @@
     }
 
     int getExpandedHeight(int disph) {
+        if (DEBUG) {
+            Slog.d(TAG, "getExpandedHeight(" + disph + "): sbView="
+                    + mStatusBarView.getHeight() + " closeView=" + mCloseView.getHeight());
+        }
         return disph - mStatusBarView.getHeight() - mCloseView.getHeight();
     }
 
@@ -1890,6 +1896,9 @@
     }
 
     void updateExpandedSize() {
+        if (DEBUG) {
+            Slog.d(TAG, "updateExpandedSize()");
+        }
         if (mExpandedDialog != null && mExpandedParams != null && mDisplaySize != null) {
             mExpandedParams.width = mDisplaySize.x;
             mExpandedParams.height = getExpandedHeight(mDisplaySize.y);
@@ -1898,6 +1907,10 @@
             } else {
                 mExpandedDialog.getWindow().setAttributes(mExpandedParams);
             }
+            if (DEBUG) {
+                Slog.d(TAG, "updateExpandedSize: height=" + mExpandedParams.height + " " + 
+                    (mExpandedVisible ? "VISIBLE":"INVISIBLE"));
+            }
         }
     }
 
@@ -1979,6 +1992,14 @@
         }
     };
 
+    private View.OnClickListener mSettingsButtonListener = new View.OnClickListener() {
+        public void onClick(View v) {
+            v.getContext().startActivity(new Intent(Settings.ACTION_SETTINGS)
+                    .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
+            animateCollapse();
+        }
+    };
+
     private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
         public void onReceive(Context context, Intent intent) {
             String action = intent.getAction();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
index db6907c..809b742 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
@@ -42,8 +42,6 @@
     int mStartX, mStartY;
     ViewGroup mNotificationIcons;
     ViewGroup mStatusIcons;
-    View mDate;
-    FixedSizeDrawable mBackground;
     
     boolean mNightMode = false;
     int mStartAlpha = 0, mEndAlpha = 0;
@@ -61,11 +59,6 @@
         super.onFinishInflate();
         mNotificationIcons = (ViewGroup)findViewById(R.id.notificationIcons);
         mStatusIcons = (ViewGroup)findViewById(R.id.statusIcons);
-        mDate = findViewById(R.id.date);
-
-        mBackground = new FixedSizeDrawable(mDate.getBackground());
-        mBackground.setFixedBounds(0, 0, 0, 0);
-        mDate.setBackgroundDrawable(mBackground);
     }
 
     @Override
@@ -107,31 +100,6 @@
     @Override
     protected void onLayout(boolean changed, int l, int t, int r, int b) {
         super.onLayout(changed, l, t, r, b);
-
-        // put the date date view quantized to the icons
-        int oldDateRight = mDate.getRight();
-        int newDateRight;
-
-        newDateRight = getDateSize(mNotificationIcons, oldDateRight,
-                getViewOffset(mNotificationIcons));
-        if (newDateRight < 0) {
-            int offset = getViewOffset(mStatusIcons);
-            if (oldDateRight < offset) {
-                newDateRight = oldDateRight;
-            } else {
-                newDateRight = getDateSize(mStatusIcons, oldDateRight, offset);
-                if (newDateRight < 0) {
-                    newDateRight = r;
-                }
-            }
-        }
-        int max = r - getPaddingRight();
-        if (newDateRight > max) {
-            newDateRight = max;
-        }
-
-        mDate.layout(mDate.getLeft(), mDate.getTop(), newDateRight, mDate.getBottom());
-        mBackground.setFixedBounds(-mDate.getLeft(), -mDate.getTop(), (r-l), (b-t));
     }
 
     @Override
@@ -164,19 +132,6 @@
         return offset;
     }
 
-    private int getDateSize(ViewGroup g, int w, int offset) {
-        final int N = g.getChildCount();
-        for (int i=0; i<N; i++) {
-            View v = g.getChildAt(i);
-            int l = v.getLeft() + offset;
-            int r = v.getRight() + offset;
-            if (w >= l && w <= r) {
-                return r;
-            }
-        }
-        return -1;
-    }
-
     /**
      * Ensure that, if there is no target under us to receive the touch,
      * that we process it ourself.  This makes sure that onInterceptTouchEvent()
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindow.java b/policy/src/com/android/internal/policy/impl/PhoneWindow.java
index 6dd4948..3dcc297 100644
--- a/policy/src/com/android/internal/policy/impl/PhoneWindow.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindow.java
@@ -392,6 +392,14 @@
             // Preparing the panel menu can involve a lot of manipulation;
             // don't dispatch change events to presenters until we're done.
             st.menu.stopDispatchingItemsChanged();
+
+            // Restore action view state before we prepare. This gives apps
+            // an opportunity to override frozen/restored state in onPrepare.
+            if (st.frozenActionViewState != null) {
+                st.menu.restoreActionViewStates(st.frozenActionViewState);
+                st.frozenActionViewState = null;
+            }
+
             if (!cb.onPreparePanel(st.featureId, st.createdPanelView, st.menu)) {
                 st.menu.startDispatchingItemsChanged();
                 return false;
@@ -410,11 +418,6 @@
         st.isHandled = false;
         mPreparedPanel = st;
 
-        if (st.frozenActionViewState != null) {
-            st.menu.restoreActionViewStates(st.frozenActionViewState);
-            st.frozenActionViewState = null;
-        }
-
         return true;
     }
 
diff --git a/services/java/com/android/server/NetworkManagementService.java b/services/java/com/android/server/NetworkManagementService.java
index 30de385..cb5e968 100644
--- a/services/java/com/android/server/NetworkManagementService.java
+++ b/services/java/com/android/server/NetworkManagementService.java
@@ -188,10 +188,9 @@
 
         // only enable bandwidth control when support exists, and requested by
         // system setting.
-        // TODO: eventually migrate to be always enabled
         final boolean hasKernelSupport = new File("/proc/net/xt_qtaguid/ctrl").exists();
         final boolean shouldEnable =
-                Settings.Secure.getInt(mContext.getContentResolver(), NETSTATS_ENABLED, 0) != 0;
+                Settings.Secure.getInt(mContext.getContentResolver(), NETSTATS_ENABLED, 1) != 0;
 
         mBandwidthControlEnabled = false;
         if (hasKernelSupport && shouldEnable) {
diff --git a/services/java/com/android/server/pm/PackageManagerService.java b/services/java/com/android/server/pm/PackageManagerService.java
index 463f801..6ddd7bf 100644
--- a/services/java/com/android/server/pm/PackageManagerService.java
+++ b/services/java/com/android/server/pm/PackageManagerService.java
@@ -2814,7 +2814,23 @@
         return true;
     }
 
+    /**
+     * Enforces that only the system UID or root's UID can call a method exposed
+     * via Binder.
+     *
+     * @param message used as message if SecurityException is thrown
+     * @throws SecurityException if the caller is not system or root
+     */
+    private static final void enforceSystemOrRoot(String message) {
+        final int uid = Binder.getCallingUid();
+        if (uid != Process.SYSTEM_UID && uid != 0) {
+            throw new SecurityException(message);
+        }
+    }
+
     public boolean performDexOpt(String packageName) {
+        enforceSystemOrRoot("Only the system can request dexopt be performed");
+
         if (!mNoDexOpt) {
             return false;
         }
@@ -4687,8 +4703,13 @@
     }
 
     public void finishPackageInstall(int token) {
-        if (DEBUG_INSTALL) Log.v(TAG, "BM finishing package install for " + token);
-        Message msg = mHandler.obtainMessage(POST_INSTALL, token, 0);
+        enforceSystemOrRoot("Only the system is allowed to finish installs");
+
+        if (DEBUG_INSTALL) {
+            Slog.v(TAG, "BM finishing package install for " + token);
+        }
+
+        final Message msg = mHandler.obtainMessage(POST_INSTALL, token, 0);
         mHandler.sendMessage(msg);
     }
 
@@ -7184,6 +7205,8 @@
     }
 
     public void enterSafeMode() {
+        enforceSystemOrRoot("Only the system can request entering safe mode");
+
         if (!mSystemReady) {
             mSafeMode = true;
         }
@@ -8086,12 +8109,18 @@
     }
 
     public UserInfo createUser(String name, int flags) {
+        // TODO(kroot): Add a real permission for creating users
+        enforceSystemOrRoot("Only the system can create users");
+
         // TODO(kroot): fix this API
         UserInfo userInfo = mUserManager.createUser(name, flags, new ArrayList<ApplicationInfo>());
         return userInfo;
     }
 
     public boolean removeUser(int userId) {
+        // TODO(kroot): Add a real permission for removing users
+        enforceSystemOrRoot("Only the system can remove users");
+
         if (userId == 0) {
             return false;
         }
diff --git a/services/surfaceflinger/SurfaceTextureLayer.cpp b/services/surfaceflinger/SurfaceTextureLayer.cpp
index 5973e76..79cd0c3 100644
--- a/services/surfaceflinger/SurfaceTextureLayer.cpp
+++ b/services/surfaceflinger/SurfaceTextureLayer.cpp
@@ -86,9 +86,19 @@
     return res;
 }
 
-status_t SurfaceTextureLayer::connect(int api) {
-    status_t err = SurfaceTexture::connect(api);
+status_t SurfaceTextureLayer::connect(int api,
+        uint32_t* outWidth, uint32_t* outHeight, uint32_t* outTransform) {
+    status_t err = SurfaceTexture::connect(api,
+            outWidth, outHeight, outTransform);
     if (err == NO_ERROR) {
+        sp<Layer> layer(mLayer.promote());
+        if (layer != NULL) {
+            uint32_t orientation = layer->getOrientation();
+            if (orientation & Transform::ROT_INVALID) {
+                orientation = 0;
+            }
+            *outTransform = orientation;
+        }
         switch(api) {
             case NATIVE_WINDOW_API_MEDIA:
             case NATIVE_WINDOW_API_CAMERA:
diff --git a/services/surfaceflinger/SurfaceTextureLayer.h b/services/surfaceflinger/SurfaceTextureLayer.h
index 5d328b7..9508524 100644
--- a/services/surfaceflinger/SurfaceTextureLayer.h
+++ b/services/surfaceflinger/SurfaceTextureLayer.h
@@ -51,7 +51,8 @@
     virtual status_t dequeueBuffer(int *buf, uint32_t w, uint32_t h,
             uint32_t format, uint32_t usage);
 
-    virtual status_t connect(int api);
+    virtual status_t connect(int api,
+            uint32_t* outWidth, uint32_t* outHeight, uint32_t* outTransform);
 };
 
 // ---------------------------------------------------------------------------
diff --git a/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java b/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java
index be129d5..3236901 100644
--- a/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java
+++ b/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java
@@ -576,7 +576,6 @@
         boolean allowed =
                     (gprsState == ServiceState.STATE_IN_SERVICE || mAutoAttachOnCreation) &&
                     mPhone.mIccRecords.getRecordsLoaded() &&
-                    mPhone.mIccRecords.isProvisioned() &&
                     mPhone.getState() == Phone.State.IDLE &&
                     mInternalDataEnabled &&
                     (!mPhone.getServiceState().getRoaming() || getDataOnRoamingEnabled()) &&
@@ -588,7 +587,6 @@
                 reason += " - gprs= " + gprsState;
             }
             if (!mPhone.mIccRecords.getRecordsLoaded()) reason += " - SIM not loaded";
-            if (!mPhone.mIccRecords.isProvisioned()) reason += " - SIM not provisioned";
             if (mPhone.getState() != Phone.State.IDLE) {
                 reason += " - PhoneState= " + mPhone.getState();
             }
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/CanvasTextureViewActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/CanvasTextureViewActivity.java
index 81c22b8..bd2f68f 100644
--- a/tests/HwAccelerationTest/src/com/android/test/hwui/CanvasTextureViewActivity.java
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/CanvasTextureViewActivity.java
@@ -58,8 +58,9 @@
     }
 
     @Override
-    public void onSurfaceTextureDestroyed(SurfaceTexture surface) {
+    public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
         if (mThread != null) mThread.stopRendering();
+        return true;
     }
 
     @Override
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/GLTextureViewActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/GLTextureViewActivity.java
index 949589f..e77178d 100644
--- a/tests/HwAccelerationTest/src/com/android/test/hwui/GLTextureViewActivity.java
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/GLTextureViewActivity.java
@@ -110,13 +110,14 @@
     }
 
     @Override
-    public void onSurfaceTextureDestroyed(SurfaceTexture surface) {
+    public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
         mRenderThread.finish();
         try {
             mRenderThread.join();
         } catch (InterruptedException e) {
             Log.e(RenderThread.LOG_TAG, "Could not wait for render thread");
         }
+        return true;
     }
 
     @Override
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/GetBitmapActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/GetBitmapActivity.java
index f420fa0..038434a 100644
--- a/tests/HwAccelerationTest/src/com/android/test/hwui/GetBitmapActivity.java
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/GetBitmapActivity.java
@@ -96,9 +96,10 @@
     }
 
     @Override
-    public void onSurfaceTextureDestroyed(SurfaceTexture surface) {
+    public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
         mCamera.stopPreview();
         mCamera.release();
+        return true;
     }
 
     @Override
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/TextureViewActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/TextureViewActivity.java
index 634e7e3a..97e2108 100644
--- a/tests/HwAccelerationTest/src/com/android/test/hwui/TextureViewActivity.java
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/TextureViewActivity.java
@@ -92,9 +92,10 @@
     }
 
     @Override
-    public void onSurfaceTextureDestroyed(SurfaceTexture surface) {
+    public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
         mCamera.stopPreview();
         mCamera.release();
+        return true;
     }
 
     @Override
diff --git a/tools/layoutlib/bridge/src/android/util/Log_Delegate.java b/tools/layoutlib/bridge/src/android/util/Log_Delegate.java
new file mode 100755
index 0000000..7f432ab
--- /dev/null
+++ b/tools/layoutlib/bridge/src/android/util/Log_Delegate.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.util;
+
+import com.android.tools.layoutlib.annotations.LayoutlibDelegate;
+
+class Log_Delegate {
+    // to replicate prefix visible when using 'adb logcat'
+    private static char priorityChar(int priority) {
+        switch (priority) {
+            case Log.VERBOSE:
+                return 'V';
+            case Log.DEBUG:
+                return 'D';
+            case Log.INFO:
+                return 'I';
+            case Log.WARN:
+                return 'W';
+            case Log.ERROR:
+                return 'E';
+            case Log.ASSERT:
+                return 'A';
+            default:
+                return '?';
+        }
+    }
+
+    @LayoutlibDelegate
+    static int println_native(int bufID, int priority, String tag, String msgs) {
+        String prefix = priorityChar(priority) + "/" + tag + ": ";
+        for (String msg: msgs.split("\n")) {
+            System.out.println(prefix + msg);
+        }
+        return 0;
+    }
+
+}
diff --git a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/CreateInfo.java b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/CreateInfo.java
index 93a35cc..7c02f7e 100644
--- a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/CreateInfo.java
+++ b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/CreateInfo.java
@@ -108,6 +108,7 @@
         "android.view.LayoutInflater#parseInclude",
         "android.view.View#isInEditMode",
         "android.view.inputmethod.InputMethodManager#getInstance",
+        "android.util.Log#println_native",
         "com.android.internal.util.XmlUtils#convertValueToInt",
         // TODO: comment out once DelegateClass is working
     };
diff --git a/wifi/java/android/net/wifi/WifiConfigStore.java b/wifi/java/android/net/wifi/WifiConfigStore.java
index 9a51d5e..5b4bce2 100644
--- a/wifi/java/android/net/wifi/WifiConfigStore.java
+++ b/wifi/java/android/net/wifi/WifiConfigStore.java
@@ -954,7 +954,7 @@
                         netId,
                         WifiConfiguration.pskVarName,
                         config.preSharedKey)) {
-                Log.d(TAG, "failed to set psk: "+config.preSharedKey);
+                Log.d(TAG, "failed to set psk");
                 break setVariables;
             }
 
diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java
index 82ff0de..41af5ec 100644
--- a/wifi/java/android/net/wifi/WifiStateMachine.java
+++ b/wifi/java/android/net/wifi/WifiStateMachine.java
@@ -1101,13 +1101,11 @@
                         }
                     } catch (Exception e) {
                         Log.e(TAG, "Error configuring interface " + intf + ", :" + e);
-                        setWifiApEnabled(null, false);
                         return false;
                     }
 
                     if(mCm.tether(intf) != ConnectivityManager.TETHER_ERROR_NO_ERROR) {
                         Log.e(TAG, "Error tethering on " + intf);
-                        setWifiApEnabled(null, false);
                         return false;
                     }
                     return true;
diff --git a/wifi/java/android/net/wifi/WifiWatchdogStateMachine.java b/wifi/java/android/net/wifi/WifiWatchdogStateMachine.java
index 5c8926c..4dd856f 100644
--- a/wifi/java/android/net/wifi/WifiWatchdogStateMachine.java
+++ b/wifi/java/android/net/wifi/WifiWatchdogStateMachine.java
@@ -83,7 +83,7 @@
     private static final long DEFAULT_WALLED_GARDEN_INTERVAL_MS = 30 * 60 * 1000;
 
     private static final int DEFAULT_MAX_SSID_BLACKLISTS = 7;
-    private static final int DEFAULT_NUM_DNS_PINGS = 5;
+    private static final int DEFAULT_NUM_DNS_PINGS = 15; // Multiple pings to detect setup issues
     private static final int DEFAULT_MIN_DNS_RESPONSES = 3;
 
     private static final int DEFAULT_DNS_PING_TIMEOUT_MS = 2000;
@@ -94,7 +94,7 @@
     private static final String DEFAULT_WALLED_GARDEN_URL =
             "http://clients3.google.com/generate_204";
     private static final int WALLED_GARDEN_SOCKET_TIMEOUT_MS = 10000;
-    private static final int DNS_INTRATEST_PING_INTERVAL = 20;
+    private static final int DNS_INTRATEST_PING_INTERVAL = 200; // Long delay to detect setup issues
 
     private static final int BASE = Protocol.BASE_WIFI_WATCHDOG;