Merge "Fix issue #5016544: IME keyboard hides folder rename text field."
diff --git a/api/current.txt b/api/current.txt
index 72ba551..b291e4d 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -23,6 +23,7 @@
     field public static final java.lang.String BIND_INPUT_METHOD = "android.permission.BIND_INPUT_METHOD";
     field public static final java.lang.String BIND_REMOTEVIEWS = "android.permission.BIND_REMOTEVIEWS";
     field public static final java.lang.String BIND_TEXT_SERVICE = "android.permission.BIND_TEXT_SERVICE";
+    field public static final java.lang.String BIND_VPN_SERVICE = "android.permission.BIND_VPN_SERVICE";
     field public static final java.lang.String BIND_WALLPAPER = "android.permission.BIND_WALLPAPER";
     field public static final java.lang.String BLUETOOTH = "android.permission.BLUETOOTH";
     field public static final java.lang.String BLUETOOTH_ADMIN = "android.permission.BLUETOOTH_ADMIN";
@@ -2918,6 +2919,76 @@
     method public abstract void onActivityStopped(android.app.Activity);
   }
 
+  public class ApplicationErrorReport implements android.os.Parcelable {
+    ctor public ApplicationErrorReport();
+    method public int describeContents();
+    method public void dump(android.util.Printer, java.lang.String);
+    method public static android.content.ComponentName getErrorReportReceiver(android.content.Context, java.lang.String, int);
+    method public void readFromParcel(android.os.Parcel);
+    method public void writeToParcel(android.os.Parcel, int);
+    field public static final android.os.Parcelable.Creator CREATOR;
+    field public static final int TYPE_ANR = 2; // 0x2
+    field public static final int TYPE_BATTERY = 3; // 0x3
+    field public static final int TYPE_CRASH = 1; // 0x1
+    field public static final int TYPE_NONE = 0; // 0x0
+    field public static final int TYPE_RUNNING_SERVICE = 5; // 0x5
+    field public android.app.ApplicationErrorReport.AnrInfo anrInfo;
+    field public android.app.ApplicationErrorReport.BatteryInfo batteryInfo;
+    field public android.app.ApplicationErrorReport.CrashInfo crashInfo;
+    field public java.lang.String installerPackageName;
+    field public java.lang.String packageName;
+    field public java.lang.String processName;
+    field public android.app.ApplicationErrorReport.RunningServiceInfo runningServiceInfo;
+    field public boolean systemApp;
+    field public long time;
+    field public int type;
+  }
+
+  public static class ApplicationErrorReport.AnrInfo {
+    ctor public ApplicationErrorReport.AnrInfo();
+    ctor public ApplicationErrorReport.AnrInfo(android.os.Parcel);
+    method public void dump(android.util.Printer, java.lang.String);
+    method public void writeToParcel(android.os.Parcel, int);
+    field public java.lang.String activity;
+    field public java.lang.String cause;
+    field public java.lang.String info;
+  }
+
+  public static class ApplicationErrorReport.BatteryInfo {
+    ctor public ApplicationErrorReport.BatteryInfo();
+    ctor public ApplicationErrorReport.BatteryInfo(android.os.Parcel);
+    method public void dump(android.util.Printer, java.lang.String);
+    method public void writeToParcel(android.os.Parcel, int);
+    field public java.lang.String checkinDetails;
+    field public long durationMicros;
+    field public java.lang.String usageDetails;
+    field public int usagePercent;
+  }
+
+  public static class ApplicationErrorReport.CrashInfo {
+    ctor public ApplicationErrorReport.CrashInfo();
+    ctor public ApplicationErrorReport.CrashInfo(java.lang.Throwable);
+    ctor public ApplicationErrorReport.CrashInfo(android.os.Parcel);
+    method public void dump(android.util.Printer, java.lang.String);
+    method public void writeToParcel(android.os.Parcel, int);
+    field public java.lang.String exceptionClassName;
+    field public java.lang.String exceptionMessage;
+    field public java.lang.String stackTrace;
+    field public java.lang.String throwClassName;
+    field public java.lang.String throwFileName;
+    field public int throwLineNumber;
+    field public java.lang.String throwMethodName;
+  }
+
+  public static class ApplicationErrorReport.RunningServiceInfo {
+    ctor public ApplicationErrorReport.RunningServiceInfo();
+    ctor public ApplicationErrorReport.RunningServiceInfo(android.os.Parcel);
+    method public void dump(android.util.Printer, java.lang.String);
+    method public void writeToParcel(android.os.Parcel, int);
+    field public long durationMillis;
+    field public java.lang.String serviceDetails;
+  }
+
   public class DatePickerDialog extends android.app.AlertDialog implements android.widget.DatePicker.OnDateChangedListener android.content.DialogInterface.OnClickListener {
     ctor public DatePickerDialog(android.content.Context, android.app.DatePickerDialog.OnDateSetListener, int, int, int);
     ctor public DatePickerDialog(android.content.Context, int, android.app.DatePickerDialog.OnDateSetListener, int, int, int);
@@ -3558,6 +3629,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);
@@ -3655,6 +3727,7 @@
     field public static final java.lang.String EXTRA_DATA_KEY = "intent_extra_data_key";
     field public static final java.lang.String EXTRA_NEW_SEARCH = "new_search";
     field public static final java.lang.String EXTRA_SELECT_QUERY = "select_query";
+    field public static final java.lang.String EXTRA_WEB_SEARCH_PENDINGINTENT = "web_search_pendingintent";
     field public static final int FLAG_QUERY_REFINEMENT = 1; // 0x1
     field public static final java.lang.String INTENT_ACTION_GLOBAL_SEARCH = "android.search.action.GLOBAL_SEARCH";
     field public static final java.lang.String INTENT_ACTION_SEARCHABLES_CHANGED = "android.search.action.SEARCHABLES_CHANGED";
@@ -5267,6 +5340,7 @@
     field public static final java.lang.String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
     field public static final java.lang.String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
     field public static final java.lang.String ACTION_ANSWER = "android.intent.action.ANSWER";
+    field public static final java.lang.String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
     field public static final java.lang.String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
     field public static final java.lang.String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
     field public static final java.lang.String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
@@ -5298,6 +5372,7 @@
     field public static final java.lang.String ACTION_INPUT_METHOD_CHANGED = "android.intent.action.INPUT_METHOD_CHANGED";
     field public static final java.lang.String ACTION_INSERT = "android.intent.action.INSERT";
     field public static final java.lang.String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
+    field public static final java.lang.String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
     field public static final java.lang.String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
     field public static final java.lang.String ACTION_MAIN = "android.intent.action.MAIN";
     field public static final java.lang.String ACTION_MANAGE_NETWORK_USAGE = "android.intent.action.MANAGE_NETWORK_USAGE";
@@ -5321,7 +5396,8 @@
     field public static final java.lang.String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
     field public static final java.lang.String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
     field public static final java.lang.String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
-    field public static final java.lang.String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
+    field public static final java.lang.String ACTION_PACKAGE_FULLY_REMOVED = "android.intent.action.PACKAGE_FULLY_REMOVED";
+    field public static final deprecated java.lang.String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
     field public static final java.lang.String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
     field public static final java.lang.String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
     field public static final java.lang.String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
@@ -5351,6 +5427,7 @@
     field public static final java.lang.String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
     field public static final deprecated java.lang.String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
     field public static final deprecated java.lang.String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
+    field public static final java.lang.String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
     field public static final java.lang.String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
     field public static final java.lang.String ACTION_VIEW = "android.intent.action.VIEW";
     field public static final java.lang.String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
@@ -5381,7 +5458,9 @@
     field public static final java.lang.String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
     field public static final android.os.Parcelable.Creator CREATOR;
     field public static final java.lang.String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
+    field public static final java.lang.String EXTRA_ALLOW_REPLACE = "android.intent.extra.ALLOW_REPLACE";
     field public static final java.lang.String EXTRA_BCC = "android.intent.extra.BCC";
+    field public static final java.lang.String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
     field public static final java.lang.String EXTRA_CC = "android.intent.extra.CC";
     field public static final deprecated java.lang.String EXTRA_CHANGED_COMPONENT_NAME = "android.intent.extra.changed_component_name";
     field public static final java.lang.String EXTRA_CHANGED_COMPONENT_NAME_LIST = "android.intent.extra.changed_component_name_list";
@@ -5397,12 +5476,15 @@
     field public static final java.lang.String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
     field public static final java.lang.String EXTRA_EMAIL = "android.intent.extra.EMAIL";
     field public static final java.lang.String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
+    field public static final java.lang.String EXTRA_INSTALLER_PACKAGE_NAME = "android.intent.extra.INSTALLER_PACKAGE_NAME";
     field public static final java.lang.String EXTRA_INTENT = "android.intent.extra.INTENT";
     field public static final java.lang.String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
     field public static final java.lang.String EXTRA_LOCAL_ONLY = "android.intent.extra.LOCAL_ONLY";
+    field public static final java.lang.String EXTRA_NOT_UNKNOWN_SOURCE = "android.intent.extra.NOT_UNKNOWN_SOURCE";
     field public static final java.lang.String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
     field public static final java.lang.String EXTRA_REMOTE_INTENT_TOKEN = "android.intent.extra.remote_intent_token";
     field public static final java.lang.String EXTRA_REPLACING = "android.intent.extra.REPLACING";
+    field public static final java.lang.String EXTRA_RETURN_RESULT = "android.intent.extra.RETURN_RESULT";
     field public static final java.lang.String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON";
     field public static final java.lang.String EXTRA_SHORTCUT_ICON_RESOURCE = "android.intent.extra.shortcut.ICON_RESOURCE";
     field public static final java.lang.String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT";
@@ -9097,6 +9179,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 +9187,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 +9224,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 +9258,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();
@@ -11664,6 +11760,32 @@
     method public abstract java.lang.String sanitize(java.lang.String);
   }
 
+  public class VpnService extends android.app.Service {
+    ctor public VpnService();
+    method public android.os.IBinder onBind(android.content.Intent);
+    method public void onRevoke();
+    method public static android.content.Intent prepare(android.content.Context);
+    method public boolean protect(int);
+    method public boolean protect(java.net.Socket);
+    method public boolean protect(java.net.DatagramSocket);
+    field public static final java.lang.String SERVICE_INTERFACE = "android.net.VpnService";
+  }
+
+  public class VpnService.Builder {
+    ctor public VpnService.Builder();
+    method public android.net.VpnService.Builder addAddress(java.net.InetAddress, int);
+    method public android.net.VpnService.Builder addAddress(java.lang.String, int);
+    method public android.net.VpnService.Builder addDnsServer(java.net.InetAddress);
+    method public android.net.VpnService.Builder addDnsServer(java.lang.String);
+    method public android.net.VpnService.Builder addRoute(java.net.InetAddress, int);
+    method public android.net.VpnService.Builder addRoute(java.lang.String, int);
+    method public android.net.VpnService.Builder addSearchDomain(java.lang.String);
+    method public android.os.ParcelFileDescriptor establish();
+    method public android.net.VpnService.Builder setConfigureIntent(android.app.PendingIntent);
+    method public android.net.VpnService.Builder setMtu(int);
+    method public android.net.VpnService.Builder setSession(java.lang.String);
+  }
+
 }
 
 package android.net.http {
@@ -17032,6 +17154,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 +18052,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 +22473,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 +26578,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/Activity.java b/core/java/android/app/Activity.java
index 98b867d..929867b 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -1445,10 +1445,6 @@
     }
     
     /**
-     * @deprecated Use the new {@link Fragment} API
-     * {@link Fragment#setRetainInstance(boolean)} instead; this is also
-     * available on older platforms through the Android compatibility package.
-     *
      * Retrieve the non-configuration instance data that was previously
      * returned by {@link #onRetainNonConfigurationInstance()}.  This will
      * be available from the initial {@link #onCreate} and
@@ -1464,6 +1460,10 @@
      * 
      * @return Returns the object previously returned by
      * {@link #onRetainNonConfigurationInstance()}.
+     *
+     * @deprecated Use the new {@link Fragment} API
+     * {@link Fragment#setRetainInstance(boolean)} instead; this is also
+     * available on older platforms through the Android compatibility package.
      */
     @Deprecated
     public Object getLastNonConfigurationInstance() {
@@ -1472,10 +1472,6 @@
     }
     
     /**
-     * @deprecated Use the new {@link Fragment} API
-     * {@link Fragment#setRetainInstance(boolean)} instead; this is also
-     * available on older platforms through the Android compatibility package.
-     *
      * Called by the system, as part of destroying an
      * activity due to a configuration change, when it is known that a new
      * instance will immediately be created for the new configuration.  You
@@ -1522,6 +1518,10 @@
      *
      * @return Return any Object holding the desired state to propagate to the
      * next activity instance.
+     *
+     * @deprecated Use the new {@link Fragment} API
+     * {@link Fragment#setRetainInstance(boolean)} instead; this is also
+     * available on older platforms through the Android compatibility package.
      */
     public Object onRetainNonConfigurationInstance() {
         return null;
@@ -1696,10 +1696,6 @@
     }
 
     /**
-     * @deprecated Use the new {@link android.content.CursorLoader} class with
-     * {@link LoaderManager} instead; this is also
-     * available on older platforms through the Android compatibility package.
-     *
      * This method allows the activity to take care of managing the given
      * {@link Cursor}'s lifecycle for you based on the activity's lifecycle.
      * That is, when the activity is stopped it will automatically call
@@ -1715,6 +1711,10 @@
      * 
      * @see #managedQuery(android.net.Uri , String[], String, String[], String)
      * @see #stopManagingCursor
+     *
+     * @deprecated Use the new {@link android.content.CursorLoader} class with
+     * {@link LoaderManager} instead; this is also
+     * available on older platforms through the Android compatibility package.
      */
     @Deprecated
     public void startManagingCursor(Cursor c) {
@@ -1724,10 +1724,6 @@
     }
 
     /**
-     * @deprecated Use the new {@link android.content.CursorLoader} class with
-     * {@link LoaderManager} instead; this is also
-     * available on older platforms through the Android compatibility package.
-     *
      * Given a Cursor that was previously given to
      * {@link #startManagingCursor}, stop the activity's management of that
      * cursor.
@@ -1735,6 +1731,10 @@
      * @param c The Cursor that was being managed.
      * 
      * @see #startManagingCursor
+     *
+     * @deprecated Use the new {@link android.content.CursorLoader} class with
+     * {@link LoaderManager} instead; this is also
+     * available on older platforms through the Android compatibility package.
      */
     @Deprecated
     public void stopManagingCursor(Cursor c) {
@@ -2746,10 +2746,6 @@
     }
 
     /**
-     * @deprecated Use the new {@link DialogFragment} class with
-     * {@link FragmentManager} instead; this is also
-     * available on older platforms through the Android compatibility package.
-     *
      * Callback for creating dialogs that are managed (saved and restored) for you
      * by the activity.  The default implementation calls through to
      * {@link #onCreateDialog(int)} for compatibility.
@@ -2777,6 +2773,10 @@
      * @see #showDialog(int, Bundle)
      * @see #dismissDialog(int)
      * @see #removeDialog(int)
+     *
+     * @deprecated Use the new {@link DialogFragment} class with
+     * {@link FragmentManager} instead; this is also
+     * available on older platforms through the Android compatibility package.
      */
     @Deprecated
     protected Dialog onCreateDialog(int id, Bundle args) {
@@ -2793,10 +2793,6 @@
     }
 
     /**
-     * @deprecated Use the new {@link DialogFragment} class with
-     * {@link FragmentManager} instead; this is also
-     * available on older platforms through the Android compatibility package.
-     *
      * Provides an opportunity to prepare a managed dialog before it is being
      * shown.  The default implementation calls through to
      * {@link #onPrepareDialog(int, Dialog)} for compatibility.
@@ -2815,6 +2811,10 @@
      * @see #showDialog(int)
      * @see #dismissDialog(int)
      * @see #removeDialog(int)
+     *
+     * @deprecated Use the new {@link DialogFragment} class with
+     * {@link FragmentManager} instead; this is also
+     * available on older platforms through the Android compatibility package.
      */
     @Deprecated
     protected void onPrepareDialog(int id, Dialog dialog, Bundle args) {
@@ -2822,13 +2822,13 @@
     }
 
     /**
-     * @deprecated Use the new {@link DialogFragment} class with
-     * {@link FragmentManager} instead; this is also
-     * available on older platforms through the Android compatibility package.
-     *
      * Simple version of {@link #showDialog(int, Bundle)} that does not
      * take any arguments.  Simply calls {@link #showDialog(int, Bundle)}
      * with null arguments.
+     *
+     * @deprecated Use the new {@link DialogFragment} class with
+     * {@link FragmentManager} instead; this is also
+     * available on older platforms through the Android compatibility package.
      */
     @Deprecated
     public final void showDialog(int id) {
@@ -2836,10 +2836,6 @@
     }
 
     /**
-     * @deprecated Use the new {@link DialogFragment} class with
-     * {@link FragmentManager} instead; this is also
-     * available on older platforms through the Android compatibility package.
-     *
      * Show a dialog managed by this activity.  A call to {@link #onCreateDialog(int, Bundle)}
      * will be made with the same id the first time this is called for a given
      * id.  From thereafter, the dialog will be automatically saved and restored.
@@ -2864,6 +2860,10 @@
      * @see #onPrepareDialog(int, Dialog, Bundle)
      * @see #dismissDialog(int)
      * @see #removeDialog(int)
+     *
+     * @deprecated Use the new {@link DialogFragment} class with
+     * {@link FragmentManager} instead; this is also
+     * available on older platforms through the Android compatibility package.
      */
     @Deprecated
     public final boolean showDialog(int id, Bundle args) {
@@ -2887,10 +2887,6 @@
     }
 
     /**
-     * @deprecated Use the new {@link DialogFragment} class with
-     * {@link FragmentManager} instead; this is also
-     * available on older platforms through the Android compatibility package.
-     *
      * Dismiss a dialog that was previously shown via {@link #showDialog(int)}.
      *
      * @param id The id of the managed dialog.
@@ -2902,6 +2898,10 @@
      * @see #onPrepareDialog(int, Dialog, Bundle)
      * @see #showDialog(int)
      * @see #removeDialog(int)
+     *
+     * @deprecated Use the new {@link DialogFragment} class with
+     * {@link FragmentManager} instead; this is also
+     * available on older platforms through the Android compatibility package.
      */
     @Deprecated
     public final void dismissDialog(int id) {
@@ -2926,10 +2926,6 @@
     }
 
     /**
-     * @deprecated Use the new {@link DialogFragment} class with
-     * {@link FragmentManager} instead; this is also
-     * available on older platforms through the Android compatibility package.
-     *
      * Removes any internal references to a dialog managed by this Activity.
      * If the dialog is showing, it will dismiss it as part of the clean up.
      *
@@ -2946,6 +2942,10 @@
      * @see #onPrepareDialog(int, Dialog, Bundle)
      * @see #showDialog(int)
      * @see #dismissDialog(int)
+     *
+     * @deprecated Use the new {@link DialogFragment} class with
+     * {@link FragmentManager} instead; this is also
+     * available on older platforms through the Android compatibility package.
      */
     @Deprecated
     public final void removeDialog(int id) {
diff --git a/core/java/android/app/ActivityGroup.java b/core/java/android/app/ActivityGroup.java
index fbd78be..78a4dfd 100644
--- a/core/java/android/app/ActivityGroup.java
+++ b/core/java/android/app/ActivityGroup.java
@@ -20,18 +20,16 @@
 
 import android.content.Intent;
 import android.os.Bundle;
-import android.util.Log;
 
 /**
+ * A screen that contains and runs multiple embedded activities.
+ *
  * @deprecated Use the new {@link Fragment} and {@link FragmentManager} APIs
  * instead; these are also
  * available on older platforms through the Android compatibility package.
- *
- * A screen that contains and runs multiple embedded activities.
  */
 @Deprecated
 public class ActivityGroup extends Activity {
-    private static final String TAG = "ActivityGroup";
     private static final String STATES_KEY = "android:states";
     static final String PARENT_NON_CONFIG_INSTANCE_KEY = "android:parent_non_config_instance";
 
diff --git a/core/java/android/app/ApplicationErrorReport.java b/core/java/android/app/ApplicationErrorReport.java
index 1e012eb..6524c9a 100644
--- a/core/java/android/app/ApplicationErrorReport.java
+++ b/core/java/android/app/ApplicationErrorReport.java
@@ -37,14 +37,17 @@
  *
  * A report has a type, which is one of
  * <ul>
+ * <li> {@link #TYPE_NONE} uninitialized instance of {@link ApplicationErrorReport}.
  * <li> {@link #TYPE_CRASH} application crash. Information about the crash
  * is stored in {@link #crashInfo}.
  * <li> {@link #TYPE_ANR} application not responding. Information about the
  * ANR is stored in {@link #anrInfo}.
- * <li> {@link #TYPE_NONE} uninitialized instance of {@link ApplicationErrorReport}.
+ * <li> {@link #TYPE_BATTERY} user reported application is using too much
+ * battery. Information about the battery use is stored in {@link #batteryInfo}.
+ * <li> {@link #TYPE_RUNNING_SERVICE} user reported application is leaving an
+ * unneeded serive running. Information about the battery use is stored in
+ * {@link #runningServiceInfo}.
  * </ul>
- *
- * @hide
  */
 
 public class ApplicationErrorReport implements Parcelable {
diff --git a/core/java/android/app/LocalActivityManager.java b/core/java/android/app/LocalActivityManager.java
index 0a6b804..b654a6a 100644
--- a/core/java/android/app/LocalActivityManager.java
+++ b/core/java/android/app/LocalActivityManager.java
@@ -28,15 +28,15 @@
 import java.util.Map;
 
 /**
- * @deprecated Use the new {@link Fragment} and {@link FragmentManager} APIs
- * instead; these are also
- * available on older platforms through the Android compatibility package.
- *
  * <p>Helper class for managing multiple running embedded activities in the same
  * process. This class is not normally used directly, but rather created for
  * you as part of the {@link android.app.ActivityGroup} implementation.
  *
  * @see ActivityGroup
+ *
+ * @deprecated Use the new {@link Fragment} and {@link FragmentManager} APIs
+ * instead; these are also
+ * available on older platforms through the Android compatibility package.
  */
 @Deprecated
 public class LocalActivityManager {
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/app/SearchManager.java b/core/java/android/app/SearchManager.java
index 7274362..5c4cc87 100644
--- a/core/java/android/app/SearchManager.java
+++ b/core/java/android/app/SearchManager.java
@@ -145,6 +145,14 @@
     public final static String EXTRA_NEW_SEARCH = "new_search";
 
     /**
+     * Extra data key for {@link Intent#ACTION_WEB_SEARCH}. If set, the value must be a
+     * {@link PendingIntent}. The search activity handling the {@link Intent#ACTION_WEB_SEARCH}
+     * intent will fill in and launch the pending intent. The data URI will be filled in with an
+     * http or https URI, and {@link android.provider.Browser#EXTRA_HEADERS} may be filled in.
+     */
+    public static final String EXTRA_WEB_SEARCH_PENDINGINTENT = "web_search_pendingintent";
+
+    /**
      * Boolean extra data key for a suggestion provider to return in {@link Cursor#getExtras} to
      * indicate that the search is not complete yet. This can be used by the search UI
      * to indicate that a search is in progress. The suggestion provider can return partial results
diff --git a/core/java/android/app/TabActivity.java b/core/java/android/app/TabActivity.java
index 0fd0c2c..882e55a 100644
--- a/core/java/android/app/TabActivity.java
+++ b/core/java/android/app/TabActivity.java
@@ -23,11 +23,6 @@
 import android.widget.TextView;
 
 /**
- * @deprecated New applications should use Fragments instead of this class;
- * to continue to run on older devices, you can use the v4 support library
- * which provides a version of the Fragment API that is compatible down to
- * {@link android.os.Build.VERSION_CODES#DONUT}.
- *
  * <p>For apps developing against {@link android.os.Build.VERSION_CODES#HONEYCOMB}
  * or later, tabs are typically presented in the UI using the new
  * {@link ActionBar#newTab() ActionBar.newTab()} and
@@ -49,6 +44,11 @@
  * <p>Also see the <a href="{@docRoot}resources/samples/Support4Demos/src/com/example/android/supportv4/app/FragmentTabsPager.html">
  * Fragment Tabs Pager</a> sample for an example of using the support library's ViewPager to
  * allow the user to swipe the content to switch between tabs.</p>
+ *
+ * @deprecated New applications should use Fragments instead of this class;
+ * to continue to run on older devices, you can use the v4 support library
+ * which provides a version of the Fragment API that is compatible down to
+ * {@link android.os.Build.VERSION_CODES#DONUT}.
  */
 @Deprecated
 public class TabActivity extends ActivityGroup {
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java
index 2f9627a..2579ced 100644
--- a/core/java/android/content/Intent.java
+++ b/core/java/android/content/Intent.java
@@ -1132,7 +1132,8 @@
      * <p>Input: No data is specified. The bug report is passed in using
      * an {@link #EXTRA_BUG_REPORT} field.
      * <p>Output: Nothing.
-     * @hide
+     *
+     * @see #EXTRA_BUG_REPORT
      */
     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
     public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
@@ -1169,6 +1170,80 @@
             "android.intent.action.MANAGE_NETWORK_USAGE";
 
     /**
+     * Activity Action: Launch application installer.
+     * <p>
+     * Input: The data must be a content: or file: URI at which the application
+     * can be retrieved.  You can optionally supply
+     * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
+     * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
+     * <p>
+     * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
+     * succeeded.
+     *
+     * @see #EXTRA_INSTALLER_PACKAGE_NAME
+     * @see #EXTRA_NOT_UNKNOWN_SOURCE
+     * @see #EXTRA_RETURN_RESULT
+     */
+    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
+    public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
+
+    /**
+     * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
+     * package.  Specifies the installer package name; this package will receive the
+     * {@link #ACTION_APP_ERROR} intent.
+     */
+    public static final String EXTRA_INSTALLER_PACKAGE_NAME
+            = "android.intent.extra.INSTALLER_PACKAGE_NAME";
+
+    /**
+     * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
+     * package.  Specifies that the application being installed should not be
+     * treated as coming from an unknown source, but as coming from the app
+     * invoking the Intent.  For this to work you must start the installer with
+     * startActivityForResult().
+     */
+    public static final String EXTRA_NOT_UNKNOWN_SOURCE
+            = "android.intent.extra.NOT_UNKNOWN_SOURCE";
+
+    /**
+     * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
+     * package.  Tells the installer UI to skip the confirmation with the user
+     * if the .apk is replacing an existing one.
+     */
+    public static final String EXTRA_ALLOW_REPLACE
+            = "android.intent.extra.ALLOW_REPLACE";
+
+    /**
+     * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
+     * {@link #ACTION_UNINSTALL_PACKAGE}.  Specifies that the installer UI should
+     * return to the application the result code of the install/uninstall.  The returned result
+     * code will be {@link android.app.Activity#RESULT_OK} on success or
+     * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
+     */
+    public static final String EXTRA_RETURN_RESULT
+            = "android.intent.extra.RETURN_RESULT";
+
+    /**
+     * Package manager install result code.  @hide because result codes are not
+     * yet ready to be exposed.
+     */
+    public static final String EXTRA_INSTALL_RESULT
+            = "android.intent.extra.INSTALL_RESULT";
+
+    /**
+     * Activity Action: Launch application uninstaller.
+     * <p>
+     * Input: The data must be a package: URI whose scheme specific part is
+     * the package name of the current installed package to be uninstalled.
+     * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
+     * <p>
+     * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
+     * succeeded.
+     */
+    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
+    public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
+
+    /**
      * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity
      * describing the last run version of the platform that was setup.
      * @hide
@@ -1287,7 +1362,10 @@
      *
      * <p class="note">This is a protected intent that can only be sent
      * by the system.
+     *
+     * @deprecated This constant has never been used.
      */
+    @Deprecated
     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
     public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
     /**
@@ -1350,6 +1428,24 @@
     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
     public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
     /**
+     * Broadcast Action: An existing application package has been completely
+     * removed from the device.  The data contains the name of the package.
+     * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
+     * {@link #EXTRA_DATA_REMOVED} is true and
+     * {@link #EXTRA_REPLACING} is false of that broadcast.
+     *
+     * <ul>
+     * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
+     * to the package.
+     * </ul>
+     *
+     * <p class="note">This is a protected intent that can only be sent
+     * by the system.
+     */
+    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
+    public static final String ACTION_PACKAGE_FULLY_REMOVED
+            = "android.intent.action.PACKAGE_FULLY_REMOVED";
+    /**
      * Broadcast Action: An existing application package has been changed (e.g.
      * a component has been enabled or disabled).  The data contains the name of
      * the package.
@@ -2380,22 +2476,10 @@
     /**
      * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
      * the bug report.
-     *
-     * @hide
      */
     public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
 
     /**
-     * Used as a string extra field when sending an intent to PackageInstaller to install a
-     * package. Specifies the installer package name; this package will receive the
-     * {@link #ACTION_APP_ERROR} intent.
-     *
-     * @hide
-     */
-    public static final String EXTRA_INSTALLER_PACKAGE_NAME
-            = "android.intent.extra.INSTALLER_PACKAGE_NAME";
-
-    /**
      * Used in the extra field in the remote intent. It's astring token passed with the
      * remote intent.
      */
diff --git a/core/java/android/content/IntentFilter.java b/core/java/android/content/IntentFilter.java
index f3b1d94..f9b3fd5 100644
--- a/core/java/android/content/IntentFilter.java
+++ b/core/java/android/content/IntentFilter.java
@@ -996,6 +996,8 @@
 
     /**
      * Return an iterator over the filter's categories.
+     *
+     * @return Iterator if this filter has categories or {@code null} if none.
      */
     public final Iterator<String> categoriesIterator() {
         return mCategories != null ? mCategories.iterator() : null;
diff --git a/core/java/android/content/pm/ManifestDigest.aidl b/core/java/android/content/pm/ManifestDigest.aidl
new file mode 100755
index 0000000..ebabab0
--- /dev/null
+++ b/core/java/android/content/pm/ManifestDigest.aidl
@@ -0,0 +1,19 @@
+/*
+ * Copyright 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.content.pm;
+
+parcelable ManifestDigest;
diff --git a/core/java/android/content/pm/ManifestDigest.java b/core/java/android/content/pm/ManifestDigest.java
new file mode 100644
index 0000000..f5e72e0
--- /dev/null
+++ b/core/java/android/content/pm/ManifestDigest.java
@@ -0,0 +1,114 @@
+package android.content.pm;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.util.Base64;
+
+import java.util.Arrays;
+import java.util.jar.Attributes;
+
+/**
+ * Represents the manifest digest for a package. This is suitable for comparison
+ * of two packages to know whether the manifests are identical.
+ *
+ * @hide
+ */
+public class ManifestDigest implements Parcelable {
+    /** The digest of the manifest in our preferred order. */
+    private final byte[] mDigest;
+
+    /** Digest field names to look for in preferred order. */
+    private static final String[] DIGEST_TYPES = {
+            "SHA1-Digest", "SHA-Digest", "MD5-Digest",
+    };
+
+    /** What we print out first when toString() is called. */
+    private static final String TO_STRING_PREFIX = "ManifestDigest {mDigest=";
+
+    ManifestDigest(byte[] digest) {
+        mDigest = digest;
+    }
+
+    private ManifestDigest(Parcel source) {
+        mDigest = source.createByteArray();
+    }
+
+    static ManifestDigest fromAttributes(Attributes attributes) {
+        if (attributes == null) {
+            return null;
+        }
+
+        String encodedDigest = null;
+
+        for (int i = 0; i < DIGEST_TYPES.length; i++) {
+            final String value = attributes.getValue(DIGEST_TYPES[i]);
+            if (value != null) {
+                encodedDigest = value;
+                break;
+            }
+        }
+
+        if (encodedDigest == null) {
+            return null;
+        }
+
+        final byte[] digest = Base64.decode(encodedDigest, Base64.DEFAULT);
+        return new ManifestDigest(digest);
+    }
+
+    @Override
+    public int describeContents() {
+        return 0;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (!(o instanceof ManifestDigest)) {
+            return false;
+        }
+
+        final ManifestDigest other = (ManifestDigest) o;
+
+        return this == other || Arrays.equals(mDigest, other.mDigest);
+    }
+
+    @Override
+    public int hashCode() {
+        return Arrays.hashCode(mDigest);
+    }
+
+    @Override
+    public String toString() {
+        final StringBuilder sb = new StringBuilder(TO_STRING_PREFIX.length()
+                + (mDigest.length * 3) + 1);
+
+        sb.append(TO_STRING_PREFIX);
+
+        final int N = mDigest.length;
+        for (int i = 0; i < N; i++) {
+            final byte b = mDigest[i];
+            IntegralToString.appendByteAsHex(sb, b, false);
+            sb.append(',');
+        }
+        sb.append('}');
+
+        return sb.toString();
+    }
+
+    @Override
+    public void writeToParcel(Parcel dest, int flags) {
+        dest.writeByteArray(mDigest);
+    }
+
+    public static final Parcelable.Creator<ManifestDigest> CREATOR
+            = new Parcelable.Creator<ManifestDigest>() {
+        public ManifestDigest createFromParcel(Parcel source) {
+            return new ManifestDigest(source);
+        }
+
+        public ManifestDigest[] newArray(int size) {
+            return new ManifestDigest[size];
+        }
+    };
+
+}
\ No newline at end of file
diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java
index 22fdc98..c61e32f 100644
--- a/core/java/android/content/pm/PackageParser.java
+++ b/core/java/android/content/pm/PackageParser.java
@@ -24,13 +24,12 @@
 import android.content.res.Resources;
 import android.content.res.TypedArray;
 import android.content.res.XmlResourceParser;
-import android.os.Binder;
 import android.os.Build;
 import android.os.Bundle;
 import android.os.PatternMatcher;
 import android.util.AttributeSet;
 import android.util.DisplayMetrics;
-import android.util.Log;
+import android.util.Slog;
 import android.util.TypedValue;
 import com.android.internal.util.XmlUtils;
 import org.xmlpull.v1.XmlPullParser;
@@ -46,8 +45,10 @@
 import java.util.ArrayList;
 import java.util.Enumeration;
 import java.util.Iterator;
+import java.util.jar.Attributes;
 import java.util.jar.JarEntry;
 import java.util.jar.JarFile;
+import java.util.jar.Manifest;
 
 /**
  * Package archive parsing
@@ -55,6 +56,13 @@
  * {@hide}
  */
 public class PackageParser {
+    private static final boolean DEBUG_JAR = false;
+    private static final boolean DEBUG_PARSER = false;
+    private static final boolean DEBUG_BACKUP = false;
+
+    /** File name in an APK for the Android manifest. */
+    private static final String ANDROID_MANIFEST_FILENAME = "AndroidManifest.xml";
+
     /** @hide */
     public static class NewPermissionInfo {
         public final String name;
@@ -342,10 +350,10 @@
             is.close();
             return je != null ? je.getCertificates() : null;
         } catch (IOException e) {
-            Log.w(TAG, "Exception reading " + je.getName() + " in "
+            Slog.w(TAG, "Exception reading " + je.getName() + " in "
                     + jarFile.getName(), e);
         } catch (RuntimeException e) {
-            Log.w(TAG, "Exception reading " + je.getName() + " in "
+            Slog.w(TAG, "Exception reading " + je.getName() + " in "
                     + jarFile.getName(), e);
         }
         return null;
@@ -369,7 +377,7 @@
 
         mArchiveSourcePath = sourceFile.getPath();
         if (!sourceFile.isFile()) {
-            Log.w(TAG, "Skipping dir: " + mArchiveSourcePath);
+            Slog.w(TAG, "Skipping dir: " + mArchiveSourcePath);
             mParseError = PackageManager.INSTALL_PARSE_FAILED_NOT_APK;
             return null;
         }
@@ -378,14 +386,14 @@
             if ((flags&PARSE_IS_SYSTEM) == 0) {
                 // We expect to have non-.apk files in the system dir,
                 // so don't warn about them.
-                Log.w(TAG, "Skipping non-package file: " + mArchiveSourcePath);
+                Slog.w(TAG, "Skipping non-package file: " + mArchiveSourcePath);
             }
             mParseError = PackageManager.INSTALL_PARSE_FAILED_NOT_APK;
             return null;
         }
 
-        if ((flags&PARSE_CHATTY) != 0 && false) Log.d(
-            TAG, "Scanning package: " + mArchiveSourcePath);
+        if (DEBUG_JAR)
+            Slog.d(TAG, "Scanning package: " + mArchiveSourcePath);
 
         XmlResourceParser parser = null;
         AssetManager assmgr = null;
@@ -398,13 +406,13 @@
                 res = new Resources(assmgr, metrics, null);
                 assmgr.setConfiguration(0, 0, null, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                         Build.VERSION.RESOURCES_SDK_INT);
-                parser = assmgr.openXmlResourceParser(cookie, "AndroidManifest.xml");
+                parser = assmgr.openXmlResourceParser(cookie, ANDROID_MANIFEST_FILENAME);
                 assetError = false;
             } else {
-                Log.w(TAG, "Failed adding asset path:"+mArchiveSourcePath);
+                Slog.w(TAG, "Failed adding asset path:"+mArchiveSourcePath);
             }
         } catch (Exception e) {
-            Log.w(TAG, "Unable to read AndroidManifest.xml of "
+            Slog.w(TAG, "Unable to read AndroidManifest.xml of "
                     + mArchiveSourcePath, e);
         }
         if (assetError) {
@@ -426,9 +434,9 @@
 
         if (pkg == null) {
             if (errorException != null) {
-                Log.w(TAG, mArchiveSourcePath, errorException);
+                Slog.w(TAG, mArchiveSourcePath, errorException);
             } else {
-                Log.w(TAG, mArchiveSourcePath + " (at "
+                Slog.w(TAG, mArchiveSourcePath + " (at "
                         + parser.getPositionDescription()
                         + "): " + errorText[0]);
             }
@@ -480,44 +488,54 @@
                 // can trust it...  we'll just use the AndroidManifest.xml
                 // to retrieve its signatures, not validating all of the
                 // files.
-                JarEntry jarEntry = jarFile.getJarEntry("AndroidManifest.xml");
+                JarEntry jarEntry = jarFile.getJarEntry(ANDROID_MANIFEST_FILENAME);
                 certs = loadCertificates(jarFile, jarEntry, readBuffer);
                 if (certs == null) {
-                    Log.e(TAG, "Package " + pkg.packageName
+                    Slog.e(TAG, "Package " + pkg.packageName
                             + " has no certificates at entry "
                             + jarEntry.getName() + "; ignoring!");
                     jarFile.close();
                     mParseError = PackageManager.INSTALL_PARSE_FAILED_NO_CERTIFICATES;
                     return false;
                 }
-                if (false) {
-                    Log.i(TAG, "File " + mArchiveSourcePath + ": entry=" + jarEntry
+                if (DEBUG_JAR) {
+                    Slog.i(TAG, "File " + mArchiveSourcePath + ": entry=" + jarEntry
                             + " certs=" + (certs != null ? certs.length : 0));
                     if (certs != null) {
                         final int N = certs.length;
                         for (int i=0; i<N; i++) {
-                            Log.i(TAG, "  Public key: "
+                            Slog.i(TAG, "  Public key: "
                                     + certs[i].getPublicKey().getEncoded()
                                     + " " + certs[i].getPublicKey());
                         }
                     }
                 }
-
             } else {
-                Enumeration entries = jarFile.entries();
+                Enumeration<JarEntry> entries = jarFile.entries();
+                final Manifest manifest = jarFile.getManifest();
                 while (entries.hasMoreElements()) {
-                    JarEntry je = (JarEntry)entries.nextElement();
+                    final JarEntry je = entries.nextElement();
                     if (je.isDirectory()) continue;
-                    if (je.getName().startsWith("META-INF/")) continue;
-                    Certificate[] localCerts = loadCertificates(jarFile, je,
-                            readBuffer);
-                    if (false) {
-                        Log.i(TAG, "File " + mArchiveSourcePath + " entry " + je.getName()
+
+                    final String name = je.getName();
+
+                    if (name.startsWith("META-INF/"))
+                        continue;
+
+                    if (ANDROID_MANIFEST_FILENAME.equals(name)) {
+                        final Attributes attributes = manifest.getAttributes(name);
+                        pkg.manifestDigest = ManifestDigest.fromAttributes(attributes);
+                    }
+
+                    final Certificate[] localCerts = loadCertificates(jarFile, je, readBuffer);
+                    if (DEBUG_JAR) {
+                        Slog.i(TAG, "File " + mArchiveSourcePath + " entry " + je.getName()
                                 + ": certs=" + certs + " ("
                                 + (certs != null ? certs.length : 0) + ")");
                     }
+
                     if (localCerts == null) {
-                        Log.e(TAG, "Package " + pkg.packageName
+                        Slog.e(TAG, "Package " + pkg.packageName
                                 + " has no certificates at entry "
                                 + je.getName() + "; ignoring!");
                         jarFile.close();
@@ -537,7 +555,7 @@
                                 }
                             }
                             if (!found || certs.length != localCerts.length) {
-                                Log.e(TAG, "Package " + pkg.packageName
+                                Slog.e(TAG, "Package " + pkg.packageName
                                         + " has mismatched certificates at entry "
                                         + je.getName() + "; ignoring!");
                                 jarFile.close();
@@ -562,21 +580,21 @@
                             certs[i].getEncoded());
                 }
             } else {
-                Log.e(TAG, "Package " + pkg.packageName
+                Slog.e(TAG, "Package " + pkg.packageName
                         + " has no certificates; ignoring!");
                 mParseError = PackageManager.INSTALL_PARSE_FAILED_NO_CERTIFICATES;
                 return false;
             }
         } catch (CertificateEncodingException e) {
-            Log.w(TAG, "Exception reading " + mArchiveSourcePath, e);
+            Slog.w(TAG, "Exception reading " + mArchiveSourcePath, e);
             mParseError = PackageManager.INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING;
             return false;
         } catch (IOException e) {
-            Log.w(TAG, "Exception reading " + mArchiveSourcePath, e);
+            Slog.w(TAG, "Exception reading " + mArchiveSourcePath, e);
             mParseError = PackageManager.INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING;
             return false;
         } catch (RuntimeException e) {
-            Log.w(TAG, "Exception reading " + mArchiveSourcePath, e);
+            Slog.w(TAG, "Exception reading " + mArchiveSourcePath, e);
             mParseError = PackageManager.INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION;
             return false;
         }
@@ -604,10 +622,10 @@
                 return null;
             }
 
-            parser = assmgr.openXmlResourceParser(cookie, "AndroidManifest.xml");
+            parser = assmgr.openXmlResourceParser(cookie, ANDROID_MANIFEST_FILENAME);
         } catch (Exception e) {
             if (assmgr != null) assmgr.close();
-            Log.w(TAG, "Unable to read AndroidManifest.xml of "
+            Slog.w(TAG, "Unable to read AndroidManifest.xml of "
                     + packageFilePath, e);
             return null;
         }
@@ -617,15 +635,15 @@
         try {
             packageLite = parsePackageLite(parser, attrs, flags, errors);
         } catch (IOException e) {
-            Log.w(TAG, packageFilePath, e);
+            Slog.w(TAG, packageFilePath, e);
         } catch (XmlPullParserException e) {
-            Log.w(TAG, packageFilePath, e);
+            Slog.w(TAG, packageFilePath, e);
         } finally {
             if (parser != null) parser.close();
             if (assmgr != null) assmgr.close();
         }
         if (packageLite == null) {
-            Log.e(TAG, "parsePackageLite error: " + errors[0]);
+            Slog.e(TAG, "parsePackageLite error: " + errors[0]);
             return null;
         }
         return packageLite;
@@ -662,17 +680,17 @@
             throws IOException, XmlPullParserException {
 
         int type;
-        while ((type=parser.next()) != parser.START_TAG
-                   && type != parser.END_DOCUMENT) {
+        while ((type = parser.next()) != XmlPullParser.START_TAG
+                && type != XmlPullParser.END_DOCUMENT) {
             ;
         }
 
-        if (type != parser.START_TAG) {
+        if (type != XmlPullParser.START_TAG) {
             outError[0] = "No start tag found";
             return null;
         }
-        if ((flags&PARSE_CHATTY) != 0 && false) Log.v(
-            TAG, "Root element name: '" + parser.getName() + "'");
+        if (DEBUG_PARSER)
+            Slog.v(TAG, "Root element name: '" + parser.getName() + "'");
         if (!parser.getName().equals("manifest")) {
             outError[0] = "No <manifest> tag";
             return null;
@@ -697,17 +715,17 @@
             throws IOException, XmlPullParserException {
 
         int type;
-        while ((type=parser.next()) != parser.START_TAG
-                   && type != parser.END_DOCUMENT) {
+        while ((type = parser.next()) != XmlPullParser.START_TAG
+                && type != XmlPullParser.END_DOCUMENT) {
             ;
         }
 
-        if (type != parser.START_TAG) {
+        if (type != XmlPullParser.START_TAG) {
             outError[0] = "No start tag found";
             return null;
         }
-        if ((flags&PARSE_CHATTY) != 0 && false) Log.v(
-            TAG, "Root element name: '" + parser.getName() + "'");
+        if (DEBUG_PARSER)
+            Slog.v(TAG, "Root element name: '" + parser.getName() + "'");
         if (!parser.getName().equals("manifest")) {
             outError[0] = "No <manifest> tag";
             return null;
@@ -806,9 +824,9 @@
         int anyDensity = 1;
         
         int outerDepth = parser.getDepth();
-        while ((type=parser.next()) != parser.END_DOCUMENT
-               && (type != parser.END_TAG || parser.getDepth() > outerDepth)) {
-            if (type == parser.END_TAG || type == parser.TEXT) {
+        while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
+                && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
+            if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
                 continue;
             }
 
@@ -820,7 +838,7 @@
                         mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
                         return null;
                     } else {
-                        Log.w(TAG, "<manifest> has more than one <application>");
+                        Slog.w(TAG, "<manifest> has more than one <application>");
                         XmlUtils.skipCurrentTag(parser);
                         continue;
                     }
@@ -1118,7 +1136,7 @@
                 return null;
 
             } else {
-                Log.w(TAG, "Unknown element under <manifest>: " + parser.getName()
+                Slog.w(TAG, "Unknown element under <manifest>: " + parser.getName()
                         + " at " + mArchiveSourcePath + " "
                         + parser.getPositionDescription());
                 XmlUtils.skipCurrentTag(parser);
@@ -1152,7 +1170,7 @@
             }
         }
         if (implicitPerms != null) {
-            Log.i(TAG, implicitPerms.toString());
+            Slog.i(TAG, implicitPerms.toString());
         }
         
         if (supportsSmallScreens < 0 || (supportsSmallScreens > 0
@@ -1504,8 +1522,8 @@
                     com.android.internal.R.styleable.AndroidManifestApplication_backupAgent, 0);
             if (backupAgent != null) {
                 ai.backupAgentName = buildClassName(pkgName, backupAgent, outError);
-                if (false) {
-                    Log.v(TAG, "android:backupAgent = " + ai.backupAgentName
+                if (DEBUG_BACKUP) {
+                    Slog.v(TAG, "android:backupAgent = " + ai.backupAgentName
                             + " from " + pkgName + "+" + backupAgent);
                 }
 
@@ -1663,9 +1681,9 @@
         final int innerDepth = parser.getDepth();
 
         int type;
-        while ((type=parser.next()) != parser.END_DOCUMENT
-               && (type != parser.END_TAG || parser.getDepth() > innerDepth)) {
-            if (type == parser.END_TAG || type == parser.TEXT) {
+        while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
+                && (type != XmlPullParser.END_TAG || parser.getDepth() > innerDepth)) {
+            if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
                 continue;
             }
 
@@ -1767,7 +1785,7 @@
 
             } else {
                 if (!RIGID_PARSER) {
-                    Log.w(TAG, "Unknown element under <application>: " + tagName
+                    Slog.w(TAG, "Unknown element under <application>: " + tagName
                             + " at " + mArchiveSourcePath + " "
                             + parser.getPositionDescription());
                     XmlUtils.skipCurrentTag(parser);
@@ -1990,7 +2008,7 @@
                     return null;
                 }
                 if (intent.countActions() == 0) {
-                    Log.w(TAG, "No actions in intent filter at "
+                    Slog.w(TAG, "No actions in intent filter at "
                             + mArchiveSourcePath + " "
                             + parser.getPositionDescription());
                 } else {
@@ -2003,25 +2021,26 @@
                 }
             } else {
                 if (!RIGID_PARSER) {
-                    Log.w(TAG, "Problem in package " + mArchiveSourcePath + ":");
+                    Slog.w(TAG, "Problem in package " + mArchiveSourcePath + ":");
                     if (receiver) {
-                        Log.w(TAG, "Unknown element under <receiver>: " + parser.getName()
+                        Slog.w(TAG, "Unknown element under <receiver>: " + parser.getName()
                                 + " at " + mArchiveSourcePath + " "
                                 + parser.getPositionDescription());
                     } else {
-                        Log.w(TAG, "Unknown element under <activity>: " + parser.getName()
+                        Slog.w(TAG, "Unknown element under <activity>: " + parser.getName()
                                 + " at " + mArchiveSourcePath + " "
                                 + parser.getPositionDescription());
                     }
                     XmlUtils.skipCurrentTag(parser);
                     continue;
-                }
-                if (receiver) {
-                    outError[0] = "Bad element under <receiver>: " + parser.getName();
                 } else {
-                    outError[0] = "Bad element under <activity>: " + parser.getName();
+                    if (receiver) {
+                        outError[0] = "Bad element under <receiver>: " + parser.getName();
+                    } else {
+                        outError[0] = "Bad element under <activity>: " + parser.getName();
+                    }
+                    return null;
                 }
-                return null;
             }
         }
 
@@ -2146,7 +2165,7 @@
                     return null;
                 }
                 if (intent.countActions() == 0) {
-                    Log.w(TAG, "No actions in intent filter at "
+                    Slog.w(TAG, "No actions in intent filter at "
                             + mArchiveSourcePath + " "
                             + parser.getPositionDescription());
                 } else {
@@ -2159,14 +2178,15 @@
                 }
             } else {
                 if (!RIGID_PARSER) {
-                    Log.w(TAG, "Unknown element under <activity-alias>: " + parser.getName()
+                    Slog.w(TAG, "Unknown element under <activity-alias>: " + parser.getName()
                             + " at " + mArchiveSourcePath + " "
                             + parser.getPositionDescription());
                     XmlUtils.skipCurrentTag(parser);
                     continue;
+                } else {
+                    outError[0] = "Bad element under <activity-alias>: " + parser.getName();
+                    return null;
                 }
-                outError[0] = "Bad element under <activity-alias>: " + parser.getName();
-                return null;
             }
         }
 
@@ -2335,14 +2355,15 @@
                     outInfo.info.grantUriPermissions = true;
                 } else {
                     if (!RIGID_PARSER) {
-                        Log.w(TAG, "Unknown element under <path-permission>: "
+                        Slog.w(TAG, "Unknown element under <path-permission>: "
                                 + parser.getName() + " at " + mArchiveSourcePath + " "
                                 + parser.getPositionDescription());
                         XmlUtils.skipCurrentTag(parser);
                         continue;
+                    } else {
+                        outError[0] = "No path, pathPrefix, or pathPattern for <path-permission>";
+                        return false;
                     }
-                    outError[0] = "No path, pathPrefix, or pathPattern for <path-permission>";
-                    return false;
                 }
                 XmlUtils.skipCurrentTag(parser);
 
@@ -2377,14 +2398,15 @@
 
                 if (!havePerm) {
                     if (!RIGID_PARSER) {
-                        Log.w(TAG, "No readPermission or writePermssion for <path-permission>: "
+                        Slog.w(TAG, "No readPermission or writePermssion for <path-permission>: "
                                 + parser.getName() + " at " + mArchiveSourcePath + " "
                                 + parser.getPositionDescription());
                         XmlUtils.skipCurrentTag(parser);
                         continue;
+                    } else {
+                        outError[0] = "No readPermission or writePermssion for <path-permission>";
+                        return false;
                     }
-                    outError[0] = "No readPermission or writePermssion for <path-permission>";
-                    return false;
                 }
                 
                 String path = sa.getNonConfigurationString(
@@ -2423,7 +2445,7 @@
                     }
                 } else {
                     if (!RIGID_PARSER) {
-                        Log.w(TAG, "No path, pathPrefix, or pathPattern for <path-permission>: "
+                        Slog.w(TAG, "No path, pathPrefix, or pathPattern for <path-permission>: "
                                 + parser.getName() + " at " + mArchiveSourcePath + " "
                                 + parser.getPositionDescription());
                         XmlUtils.skipCurrentTag(parser);
@@ -2436,15 +2458,15 @@
 
             } else {
                 if (!RIGID_PARSER) {
-                    Log.w(TAG, "Unknown element under <provider>: "
+                    Slog.w(TAG, "Unknown element under <provider>: "
                             + parser.getName() + " at " + mArchiveSourcePath + " "
                             + parser.getPositionDescription());
                     XmlUtils.skipCurrentTag(parser);
                     continue;
+                } else {
+                    outError[0] = "Bad element under <provider>: " + parser.getName();
+                    return false;
                 }
-                outError[0] = "Bad element under <provider>: "
-                    + parser.getName();
-                return false;
             }
         }
         return true;
@@ -2534,15 +2556,15 @@
                 }
             } else {
                 if (!RIGID_PARSER) {
-                    Log.w(TAG, "Unknown element under <service>: "
+                    Slog.w(TAG, "Unknown element under <service>: "
                             + parser.getName() + " at " + mArchiveSourcePath + " "
                             + parser.getPositionDescription());
                     XmlUtils.skipCurrentTag(parser);
                     continue;
+                } else {
+                    outError[0] = "Bad element under <service>: " + parser.getName();
+                    return null;
                 }
-                outError[0] = "Bad element under <service>: "
-                    + parser.getName();
-                return null;
             }
         }
 
@@ -2573,15 +2595,15 @@
                 }
             } else {
                 if (!RIGID_PARSER) {
-                    Log.w(TAG, "Unknown element under " + tag + ": "
+                    Slog.w(TAG, "Unknown element under " + tag + ": "
                             + parser.getName() + " at " + mArchiveSourcePath + " "
                             + parser.getPositionDescription());
                     XmlUtils.skipCurrentTag(parser);
                     continue;
+                } else {
+                    outError[0] = "Bad element under " + tag + ": " + parser.getName();
+                    return false;
                 }
-                outError[0] = "Bad element under " + tag + ": "
-                    + parser.getName();
-                return false;
             }
         }
         return true;
@@ -2612,12 +2634,12 @@
         TypedValue v = sa.peekValue(
                 com.android.internal.R.styleable.AndroidManifestMetaData_resource);
         if (v != null && v.resourceId != 0) {
-            //Log.i(TAG, "Meta data ref " + name + ": " + v);
+            //Slog.i(TAG, "Meta data ref " + name + ": " + v);
             data.putInt(name, v.resourceId);
         } else {
             v = sa.peekValue(
                     com.android.internal.R.styleable.AndroidManifestMetaData_value);
-            //Log.i(TAG, "Meta data " + name + ": " + v);
+            //Slog.i(TAG, "Meta data " + name + ": " + v);
             if (v != null) {
                 if (v.type == TypedValue.TYPE_STRING) {
                     CharSequence cs = v.coerceToString();
@@ -2631,7 +2653,7 @@
                     data.putFloat(name, v.getFloat());
                 } else {
                     if (!RIGID_PARSER) {
-                        Log.w(TAG, "<meta-data> only supports string, integer, float, color, boolean, and resource reference types: "
+                        Slog.w(TAG, "<meta-data> only supports string, integer, float, color, boolean, and resource reference types: "
                                 + parser.getName() + " at " + mArchiveSourcePath + " "
                                 + parser.getPositionDescription());
                     } else {
@@ -2683,9 +2705,9 @@
 
         int outerDepth = parser.getDepth();
         int type;
-        while ((type=parser.next()) != parser.END_DOCUMENT
-               && (type != parser.END_TAG || parser.getDepth() > outerDepth)) {
-            if (type == parser.END_TAG || type == parser.TEXT) {
+        while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
+                && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
+            if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
                 continue;
             }
 
@@ -2762,7 +2784,7 @@
                 sa.recycle();
                 XmlUtils.skipCurrentTag(parser);
             } else if (!RIGID_PARSER) {
-                Log.w(TAG, "Unknown element under <intent-filter>: "
+                Slog.w(TAG, "Unknown element under <intent-filter>: "
                         + parser.getName() + " at " + mArchiveSourcePath + " "
                         + parser.getPositionDescription());
                 XmlUtils.skipCurrentTag(parser);
@@ -2773,14 +2795,20 @@
         }
 
         outInfo.hasDefault = outInfo.hasCategory(Intent.CATEGORY_DEFAULT);
-        if (false) {
-            String cats = "";
-            Iterator<String> it = outInfo.categoriesIterator();
-            while (it != null && it.hasNext()) {
-                cats += " " + it.next();
+
+        if (DEBUG_PARSER) {
+            final StringBuilder cats = new StringBuilder("Intent d=");
+            cats.append(outInfo.hasDefault);
+            cats.append(", cat=");
+
+            final Iterator<String> it = outInfo.categoriesIterator();
+            if (it != null) {
+                while (it.hasNext()) {
+                    cats.append(' ');
+                    cats.append(it.next());
+                }
             }
-            System.out.println("Intent d=" +
-                    outInfo.hasDefault + ", cat=" + cats);
+            Slog.d(TAG, cats.toString());
         }
 
         return true;
@@ -2869,6 +2897,12 @@
 
         public int installLocation;
 
+        /**
+         * Digest suitable for comparing whether this package's manifest is the
+         * same as another.
+         */
+        public ManifestDigest manifestDigest;
+
         public Package(String _name) {
             packageName = _name;
             applicationInfo.packageName = _name;
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/net/VpnService.java b/core/java/android/net/VpnService.java
index 3e1b512..fb5263d 100644
--- a/core/java/android/net/VpnService.java
+++ b/core/java/android/net/VpnService.java
@@ -101,7 +101,6 @@
  * &lt;/service&gt;</pre>
  *
  * @see Builder
- * @hide
  */
 public class VpnService extends Service {
 
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/os/Handler.java b/core/java/android/os/Handler.java
index bc37244..af2fa9b 100644
--- a/core/java/android/os/Handler.java
+++ b/core/java/android/os/Handler.java
@@ -567,7 +567,7 @@
 
     @Override
     public String toString() {
-        return "Handler{"
+        return "Handler (" + getClass().getName() + ") {"
         + Integer.toHexString(System.identityHashCode(this))
         + "}";
     }
diff --git a/core/java/android/os/INetworkManagementService.aidl b/core/java/android/os/INetworkManagementService.aidl
index bc4e00c..0440923 100644
--- a/core/java/android/os/INetworkManagementService.aidl
+++ b/core/java/android/os/INetworkManagementService.aidl
@@ -64,6 +64,16 @@
     void clearInterfaceAddresses(String iface);
 
     /**
+     * Set interface down
+     */
+    void setInterfaceDown(String iface);
+
+    /**
+     * Set interface up
+     */
+    void setInterfaceUp(String iface);
+
+    /**
      * Retrieves the network routes currently configured on the specified
      * interface
      */
@@ -173,6 +183,12 @@
     void detachPppd(String tty);
 
     /**
+     * Load firmware for operation in the given mode. Currently the three
+     * modes supported are "AP", "STA" and "P2P".
+     */
+    void wifiFirmwareReload(String wlanIface, String mode);
+
+    /**
      * Start Wifi Access Point
      */
     void startAccessPoint(in WifiConfiguration wifiConfig, String wlanIface, String softapIface);
diff --git a/core/java/android/preference/RingtonePreference.java b/core/java/android/preference/RingtonePreference.java
index cf14097..2ebf294 100644
--- a/core/java/android/preference/RingtonePreference.java
+++ b/core/java/android/preference/RingtonePreference.java
@@ -164,6 +164,7 @@
 
         ringtonePickerIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, mShowSilent);
         ringtonePickerIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, mRingtoneType);
+        ringtonePickerIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, getTitle());
     }
     
     /**
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/view/VolumePanel.java b/core/java/android/view/VolumePanel.java
index 662137a..cb85e5f 100644
--- a/core/java/android/view/VolumePanel.java
+++ b/core/java/android/view/VolumePanel.java
@@ -35,6 +35,8 @@
 import android.os.Handler;
 import android.os.Message;
 import android.os.Vibrator;
+import android.provider.Settings;
+import android.provider.Settings.System;
 import android.util.Log;
 import android.widget.ImageView;
 import android.widget.SeekBar;
@@ -233,6 +235,10 @@
     }
 
     private void createSliders() {
+        final int silentableStreams = System.getInt(mContext.getContentResolver(),
+                System.MODE_RINGER_STREAMS_AFFECTED,
+                ((1 << AudioSystem.STREAM_NOTIFICATION) | (1 << AudioSystem.STREAM_RING)));
+
         LayoutInflater inflater = (LayoutInflater) mContext
                 .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
         mStreamControls = new HashMap<Integer,StreamControl>(STREAM_TYPES.length);
@@ -243,7 +249,9 @@
             sc.group = (ViewGroup) inflater.inflate(R.layout.volume_adjust_item, null);
             sc.group.setTag(sc);
             sc.icon = (ImageView) sc.group.findViewById(R.id.stream_icon);
-            sc.icon.setOnClickListener(this);
+            if ((silentableStreams & (1 << sc.streamType)) != 0) {
+                sc.icon.setOnClickListener(this);
+            }
             sc.icon.setTag(sc);
             sc.icon.setContentDescription(res.getString(CONTENT_DESCRIPTIONS[i]));
             sc.iconRes = STREAM_ICONS_NORMAL[i];
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/webkit/WebTextView.java b/core/java/android/webkit/WebTextView.java
index b8c4e22..2a79caa 100644
--- a/core/java/android/webkit/WebTextView.java
+++ b/core/java/android/webkit/WebTextView.java
@@ -1023,7 +1023,8 @@
                 break;
             case NUMBER:
                 // inputType needs to be overwritten because of the different class.
-                inputType = InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_NORMAL;
+                inputType = InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_NORMAL
+                        | InputType.TYPE_NUMBER_FLAG_SIGNED | InputType.TYPE_NUMBER_FLAG_DECIMAL;
                 // Number and telephone do not have both a Tab key and an
                 // action, so set the action to NEXT
                 imeOptions |= EditorInfo.IME_ACTION_NEXT;
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 8c288d1..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/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index ac6b3dd..efcd8ab 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -16,6 +16,11 @@
 
 package android.widget;
 
+import com.android.internal.util.FastMath;
+import com.android.internal.widget.EditableInputConnection;
+
+import org.xmlpull.v1.XmlPullParserException;
+
 import android.R;
 import android.content.ClipData;
 import android.content.ClipData.Item;
@@ -134,11 +139,6 @@
 import android.view.inputmethod.InputMethodManager;
 import android.widget.RemoteViews.RemoteView;
 
-import com.android.internal.util.FastMath;
-import com.android.internal.widget.EditableInputConnection;
-
-import org.xmlpull.v1.XmlPullParserException;
-
 import java.io.IOException;
 import java.lang.ref.WeakReference;
 import java.text.BreakIterator;
@@ -9721,6 +9721,10 @@
         @Override
         public void show() {
             mPasteTextView.setVisibility(canPaste() ? View.VISIBLE : View.GONE);
+            mReplaceTextView.setVisibility(mSuggestionsEnabled ? View.VISIBLE : View.GONE);
+
+            if (!canPaste() && !mSuggestionsEnabled) return;
+
             super.show();
         }
 
diff --git a/core/java/com/android/internal/app/ActionBarImpl.java b/core/java/com/android/internal/app/ActionBarImpl.java
index 008f400..0df7bcc 100644
--- a/core/java/com/android/internal/app/ActionBarImpl.java
+++ b/core/java/com/android/internal/app/ActionBarImpl.java
@@ -156,8 +156,6 @@
                     "with a compatible window decor layout");
         }
 
-        mHasEmbeddedTabs = mContext.getResources().getBoolean(
-                com.android.internal.R.bool.action_bar_embed_tabs);
         mActionView.setContextView(mContextView);
         mContextDisplayMode = mActionView.isSplitActionBar() ?
                 CONTEXT_DISPLAY_SPLIT : CONTEXT_DISPLAY_NORMAL;
@@ -166,25 +164,31 @@
         // Newer apps need to enable it explicitly.
         setHomeButtonEnabled(mContext.getApplicationInfo().targetSdkVersion <
                 Build.VERSION_CODES.ICE_CREAM_SANDWICH);
+
+        setHasEmbeddedTabs(mContext.getResources().getBoolean(
+                com.android.internal.R.bool.action_bar_embed_tabs));
     }
 
     public void onConfigurationChanged(Configuration newConfig) {
-        mHasEmbeddedTabs = mContext.getResources().getBoolean(
-                com.android.internal.R.bool.action_bar_embed_tabs);
+        setHasEmbeddedTabs(mContext.getResources().getBoolean(
+                com.android.internal.R.bool.action_bar_embed_tabs));
+    }
 
+    private void setHasEmbeddedTabs(boolean hasEmbeddedTabs) {
+        mHasEmbeddedTabs = hasEmbeddedTabs;
         // Switch tab layout configuration if needed
         if (!mHasEmbeddedTabs) {
             mActionView.setEmbeddedTabView(null);
             mContainerView.setTabContainer(mTabScrollView);
         } else {
             mContainerView.setTabContainer(null);
-            if (mTabScrollView != null) {
-                mTabScrollView.setVisibility(View.VISIBLE);
-            }
             mActionView.setEmbeddedTabView(mTabScrollView);
         }
-        mActionView.setCollapsable(!mHasEmbeddedTabs &&
-                getNavigationMode() == NAVIGATION_MODE_TABS);
+        final boolean isInTabMode = getNavigationMode() == NAVIGATION_MODE_TABS;
+        if (mTabScrollView != null) {
+            mTabScrollView.setVisibility(isInTabMode ? View.VISIBLE : View.GONE);
+        }
+        mActionView.setCollapsable(!mHasEmbeddedTabs && isInTabMode);
     }
 
     private void ensureTabsExist() {
@@ -192,7 +196,7 @@
             return;
         }
 
-        ScrollingTabContainerView tabScroller = mActionView.createTabContainer();
+        ScrollingTabContainerView tabScroller = new ScrollingTabContainerView(mContext);
 
         if (mHasEmbeddedTabs) {
             tabScroller.setVisibility(View.VISIBLE);
@@ -925,18 +929,14 @@
             case NAVIGATION_MODE_TABS:
                 mSavedTabPosition = getSelectedNavigationIndex();
                 selectTab(null);
-                if (!mActionView.hasEmbeddedTabs()) {
-                    mTabScrollView.setVisibility(View.GONE);
-                }
+                mTabScrollView.setVisibility(View.GONE);
                 break;
         }
         mActionView.setNavigationMode(mode);
         switch (mode) {
             case NAVIGATION_MODE_TABS:
                 ensureTabsExist();
-                if (!mActionView.hasEmbeddedTabs()) {
-                    mTabScrollView.setVisibility(View.VISIBLE);
-                }
+                mTabScrollView.setVisibility(View.VISIBLE);
                 if (mSavedTabPosition != INVALID_POSITION) {
                     setSelectedNavigationItem(mSavedTabPosition);
                     mSavedTabPosition = INVALID_POSITION;
diff --git a/core/java/com/android/internal/widget/ActionBarContainer.java b/core/java/com/android/internal/widget/ActionBarContainer.java
index a2d492b..b4d2d72 100644
--- a/core/java/com/android/internal/widget/ActionBarContainer.java
+++ b/core/java/com/android/internal/widget/ActionBarContainer.java
@@ -102,7 +102,7 @@
         return true;
     }
 
-    public void setTabContainer(View tabView) {
+    public void setTabContainer(ScrollingTabContainerView tabView) {
         if (mTabContainer != null) {
             removeView(mTabContainer);
         }
@@ -110,6 +110,7 @@
         if (tabView != null) {
             addView(tabView);
             tabView.getLayoutParams().width = LayoutParams.MATCH_PARENT;
+            tabView.setAllowCollapse(false);
         }
     }
 
diff --git a/core/java/com/android/internal/widget/ActionBarView.java b/core/java/com/android/internal/widget/ActionBarView.java
index 61df5c7..181958c 100644
--- a/core/java/com/android/internal/widget/ActionBarView.java
+++ b/core/java/com/android/internal/widget/ActionBarView.java
@@ -332,7 +332,10 @@
         mIncludeTabs = tabs != null;
         if (mIncludeTabs && mNavigationMode == ActionBar.NAVIGATION_MODE_TABS) {
             addView(mTabScrollView);
-            mTabScrollView.getLayoutParams().width = LayoutParams.WRAP_CONTENT;
+            ViewGroup.LayoutParams lp = mTabScrollView.getLayoutParams();
+            lp.width = LayoutParams.WRAP_CONTENT;
+            lp.height = LayoutParams.MATCH_PARENT;
+            tabs.setAllowCollapse(true);
         }
     }
 
@@ -649,18 +652,6 @@
         }
     }
 
-    public ScrollingTabContainerView createTabContainer() {
-        final LinearLayout tabLayout = new LinearLayout(getContext(), null,
-                com.android.internal.R.attr.actionBarTabBarStyle);
-        tabLayout.setMeasureWithLargestChildEnabled(true);
-        tabLayout.setLayoutParams(new LinearLayout.LayoutParams(
-                LinearLayout.LayoutParams.WRAP_CONTENT, mContentHeight));
-
-        final ScrollingTabContainerView scroller = new ScrollingTabContainerView(mContext);
-        scroller.setTabLayout(tabLayout);
-        return scroller;
-    }
-
     public void setDropdownAdapter(SpinnerAdapter adapter) {
         mSpinnerAdapter = adapter;
         if (mSpinner != null) {
diff --git a/core/java/com/android/internal/widget/ScrollingTabContainerView.java b/core/java/com/android/internal/widget/ScrollingTabContainerView.java
index 718d249..0e4c9ef 100644
--- a/core/java/com/android/internal/widget/ScrollingTabContainerView.java
+++ b/core/java/com/android/internal/widget/ScrollingTabContainerView.java
@@ -30,18 +30,32 @@
 import android.view.View;
 import android.view.ViewGroup;
 import android.view.animation.DecelerateInterpolator;
+import android.widget.AdapterView;
+import android.widget.BaseAdapter;
 import android.widget.HorizontalScrollView;
 import android.widget.ImageView;
 import android.widget.LinearLayout;
+import android.widget.ListView;
+import android.widget.Spinner;
 import android.widget.TextView;
 
-public class ScrollingTabContainerView extends HorizontalScrollView {
+/**
+ * This widget implements the dynamic action bar tab behavior that can change
+ * across different configurations or circumstances.
+ */
+public class ScrollingTabContainerView extends HorizontalScrollView
+        implements AdapterView.OnItemSelectedListener {
+    private static final String TAG = "ScrollingTabContainerView";
     Runnable mTabSelector;
     private TabClickListener mTabClickListener;
 
     private LinearLayout mTabLayout;
+    private Spinner mTabSpinner;
+    private boolean mAllowCollapse;
 
     int mMaxTabWidth;
+    private int mContentHeight;
+    private int mSelectedTabIndex;
 
     protected Animator mVisibilityAnim;
     protected final VisibilityAnimListener mVisAnimListener = new VisibilityAnimListener();
@@ -53,14 +67,19 @@
     public ScrollingTabContainerView(Context context) {
         super(context);
         setHorizontalScrollBarEnabled(false);
+
+        mTabLayout = createTabLayout();
+        addView(mTabLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
+                ViewGroup.LayoutParams.MATCH_PARENT));
     }
 
     @Override
     public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
         final int widthMode = MeasureSpec.getMode(widthMeasureSpec);
-        setFillViewport(widthMode == MeasureSpec.EXACTLY);
+        final boolean lockedExpanded = widthMode == MeasureSpec.EXACTLY;
+        setFillViewport(lockedExpanded);
 
-        final int childCount = getChildCount();
+        final int childCount = mTabLayout.getChildCount();
         if (childCount > 1 &&
                 (widthMode == MeasureSpec.EXACTLY || widthMode == MeasureSpec.AT_MOST)) {
             if (childCount > 2) {
@@ -72,14 +91,85 @@
             mMaxTabWidth = -1;
         }
 
+        int heightMode = MeasureSpec.getMode(heightMeasureSpec);
+        int heightSize = MeasureSpec.getSize(heightMeasureSpec);
+        if (heightMode != MeasureSpec.UNSPECIFIED) {
+            if (mContentHeight == 0 && heightMode == MeasureSpec.EXACTLY) {
+                // Use this as our content height.
+                mContentHeight = heightSize;
+            }
+            heightSize = Math.min(heightSize, mContentHeight);
+            heightMeasureSpec = MeasureSpec.makeMeasureSpec(heightSize, heightMode);
+        }
+
+        final boolean canCollapse = !lockedExpanded && mAllowCollapse;
+
+        if (canCollapse) {
+            // See if we should expand
+            mTabLayout.measure(MeasureSpec.UNSPECIFIED, heightMeasureSpec);
+            if (mTabLayout.getMeasuredWidth() > MeasureSpec.getSize(widthMeasureSpec)) {
+                performCollapse();
+            } else {
+                performExpand();
+            }
+        } else {
+            performExpand();
+        }
+
+        final int oldWidth = getMeasuredWidth();
         super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+        final int newWidth = getMeasuredWidth();
+
+        if (lockedExpanded && oldWidth != newWidth) {
+            // Recenter the tab display if we're at a new (scrollable) size.
+            setTabSelected(mSelectedTabIndex);
+        }
+    }
+
+    /**
+     * Indicates whether this view is collapsed into a dropdown menu instead
+     * of traditional tabs.
+     * @return true if showing as a spinner
+     */
+    private boolean isCollapsed() {
+        return mTabSpinner != null && mTabSpinner.getParent() == this;
+    }
+
+    public void setAllowCollapse(boolean allowCollapse) {
+        mAllowCollapse = allowCollapse;
+    }
+
+    private void performCollapse() {
+        if (isCollapsed()) return;
+
+        if (mTabSpinner == null) {
+            mTabSpinner = createSpinner();
+        }
+        removeView(mTabLayout);
+        addView(mTabSpinner, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
+                ViewGroup.LayoutParams.MATCH_PARENT));
+        if (mTabSpinner.getAdapter() == null) {
+            mTabSpinner.setAdapter(new TabAdapter());
+        }
+        if (mTabSelector != null) {
+            removeCallbacks(mTabSelector);
+            mTabSelector = null;
+        }
+        mTabSpinner.setSelection(mSelectedTabIndex);
+    }
+
+    private boolean performExpand() {
+        if (!isCollapsed()) return false;
+
+        removeView(mTabSpinner);
+        addView(mTabLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
+                ViewGroup.LayoutParams.MATCH_PARENT));
+        setTabSelected(mTabSpinner.getSelectedItemPosition());
+        return false;
     }
 
     public void setTabSelected(int position) {
-        if (mTabLayout == null) {
-            return;
-        }
-
+        mSelectedTabIndex = position;
         final int tabCount = mTabLayout.getChildCount();
         for (int i = 0; i < tabCount; i++) {
             final View child = mTabLayout.getChildAt(i);
@@ -92,10 +182,28 @@
     }
 
     public void setContentHeight(int contentHeight) {
-        mTabLayout.getLayoutParams().height = contentHeight;
+        mContentHeight = contentHeight;
         requestLayout();
     }
 
+    private LinearLayout createTabLayout() {
+        final LinearLayout tabLayout = new LinearLayout(getContext(), null,
+                com.android.internal.R.attr.actionBarTabBarStyle);
+        tabLayout.setMeasureWithLargestChildEnabled(true);
+        tabLayout.setLayoutParams(new LinearLayout.LayoutParams(
+                LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT));
+        return tabLayout;
+    }
+
+    private Spinner createSpinner() {
+        final Spinner spinner = new Spinner(getContext(), null,
+                com.android.internal.R.attr.actionDropDownStyle);
+        spinner.setLayoutParams(new LinearLayout.LayoutParams(
+                LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT));
+        spinner.setOnItemSelectedListener(this);
+        return spinner;
+    }
+
     @Override
     protected void onConfigurationChanged(Configuration newConfig) {
         super.onConfigurationChanged(newConfig);
@@ -132,7 +240,7 @@
         }
     }
 
-    public void animateToTab(int position) {
+    public void animateToTab(final int position) {
         final View tabView = mTabLayout.getChildAt(position);
         if (mTabSelector != null) {
             removeCallbacks(mTabSelector);
@@ -147,22 +255,15 @@
         post(mTabSelector);
     }
 
-    public void setTabLayout(LinearLayout tabLayout) {
-        if (mTabLayout != tabLayout) {
-            if (mTabLayout != null) {
-                ((ViewGroup) mTabLayout.getParent()).removeView(mTabLayout);
-            }
-            if (tabLayout != null) {
-                addView(tabLayout);
-            }
-            mTabLayout = tabLayout;
+    @Override
+    public void onAttachedToWindow() {
+        super.onAttachedToWindow();
+        if (mTabSelector != null) {
+            // Re-post the selector we saved
+            post(mTabSelector);
         }
     }
 
-    public LinearLayout getTabLayout() {
-        return mTabLayout;
-    }
-
     @Override
     public void onDetachedFromWindow() {
         super.onDetachedFromWindow();
@@ -171,49 +272,91 @@
         }
     }
 
-    private TabView createTabView(ActionBar.Tab tab) {
-        final TabView tabView = new TabView(getContext(), tab);
-        tabView.setFocusable(true);
+    private TabView createTabView(ActionBar.Tab tab, boolean forAdapter) {
+        final TabView tabView = new TabView(getContext(), tab, forAdapter);
+        if (forAdapter) {
+            tabView.setBackgroundDrawable(null);
+            tabView.setLayoutParams(new ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT,
+                    mContentHeight));
+        } else {
+            tabView.setFocusable(true);
 
-        if (mTabClickListener == null) {
-            mTabClickListener = new TabClickListener();
+            if (mTabClickListener == null) {
+                mTabClickListener = new TabClickListener();
+            }
+            tabView.setOnClickListener(mTabClickListener);
         }
-        tabView.setOnClickListener(mTabClickListener);
         return tabView;
     }
 
     public void addTab(ActionBar.Tab tab, boolean setSelected) {
-        View tabView = createTabView(tab);
+        TabView tabView = createTabView(tab, false);
         mTabLayout.addView(tabView, new LinearLayout.LayoutParams(0,
                 LayoutParams.MATCH_PARENT, 1));
+        if (mTabSpinner != null) {
+            ((TabAdapter) mTabSpinner.getAdapter()).notifyDataSetChanged();
+        }
         if (setSelected) {
             tabView.setSelected(true);
         }
+        if (mAllowCollapse) {
+            requestLayout();
+        }
     }
 
     public void addTab(ActionBar.Tab tab, int position, boolean setSelected) {
-        final TabView tabView = createTabView(tab);
+        final TabView tabView = createTabView(tab, false);
         mTabLayout.addView(tabView, position, new LinearLayout.LayoutParams(
                 0, LayoutParams.MATCH_PARENT, 1));
+        if (mTabSpinner != null) {
+            ((TabAdapter) mTabSpinner.getAdapter()).notifyDataSetChanged();
+        }
         if (setSelected) {
             tabView.setSelected(true);
         }
+        if (mAllowCollapse) {
+            requestLayout();
+        }
     }
 
     public void updateTab(int position) {
         ((TabView) mTabLayout.getChildAt(position)).update();
+        if (mTabSpinner != null) {
+            ((TabAdapter) mTabSpinner.getAdapter()).notifyDataSetChanged();
+        }
+        if (mAllowCollapse) {
+            requestLayout();
+        }
     }
 
     public void removeTabAt(int position) {
-        if (mTabLayout != null) {
-            mTabLayout.removeViewAt(position);
+        mTabLayout.removeViewAt(position);
+        if (mTabSpinner != null) {
+            ((TabAdapter) mTabSpinner.getAdapter()).notifyDataSetChanged();
+        }
+        if (mAllowCollapse) {
+            requestLayout();
         }
     }
 
     public void removeAllTabs() {
-        if (mTabLayout != null) {
-            mTabLayout.removeAllViews();
+        mTabLayout.removeAllViews();
+        if (mTabSpinner != null) {
+            ((TabAdapter) mTabSpinner.getAdapter()).notifyDataSetChanged();
         }
+        if (mAllowCollapse) {
+            requestLayout();
+        }
+    }
+
+    @Override
+    public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
+        TabView tabView = (TabView) view;
+        tabView.getTab().select();
+    }
+
+    @Override
+    public void onNothingSelected(AdapterView<?> parent) {
     }
 
     private class TabView extends LinearLayout {
@@ -222,10 +365,19 @@
         private ImageView mIconView;
         private View mCustomView;
 
-        public TabView(Context context, ActionBar.Tab tab) {
+        public TabView(Context context, ActionBar.Tab tab, boolean forList) {
             super(context, null, com.android.internal.R.attr.actionBarTabStyle);
             mTab = tab;
 
+            if (forList) {
+                setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
+            }
+
+            update();
+        }
+
+        public void bindTab(ActionBar.Tab tab) {
+            mTab = tab;
             update();
         }
 
@@ -303,6 +455,33 @@
         }
     }
 
+    private class TabAdapter extends BaseAdapter {
+        @Override
+        public int getCount() {
+            return mTabLayout.getChildCount();
+        }
+
+        @Override
+        public Object getItem(int position) {
+            return ((TabView) mTabLayout.getChildAt(position)).getTab();
+        }
+
+        @Override
+        public long getItemId(int position) {
+            return position;
+        }
+
+        @Override
+        public View getView(int position, View convertView, ViewGroup parent) {
+            if (convertView == null) {
+                convertView = createTabView((ActionBar.Tab) getItem(position), true);
+            } else {
+                ((TabView) convertView).bindTab((ActionBar.Tab) getItem(position));
+            }
+            return convertView;
+        }
+    }
+
     private class TabClickListener implements OnClickListener {
         public void onClick(View view) {
             TabView tabView = (TabView) view;
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/AndroidManifest.xml b/core/res/AndroidManifest.xml
index d54f852..dc0106c 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -37,6 +37,7 @@
     <protected-broadcast android:name="android.intent.action.PACKAGE_REPLACED" />
     <protected-broadcast android:name="android.intent.action.MY_PACKAGE_REPLACED" />
     <protected-broadcast android:name="android.intent.action.PACKAGE_REMOVED" />
+    <protected-broadcast android:name="android.intent.action.PACKAGE_FULLY_REMOVED" />
     <protected-broadcast android:name="android.intent.action.PACKAGE_CHANGED" />
     <protected-broadcast android:name="android.intent.action.PACKAGE_RESTARTED" />
     <protected-broadcast android:name="android.intent.action.PACKAGE_DATA_CLEARED" />
@@ -91,8 +92,6 @@
     <protected-broadcast android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
     <protected-broadcast android:name="android.hardware.usb.action.USB_DEVICE_DETACHED" />
 
-    <protected-broadcast android:name="android.net.vpn.action.REVOKED" />
-
     <protected-broadcast android:name="android.nfc.action.LLCP_LINK_STATE_CHANGED" />
     <protected-broadcast android:name="com.android.nfc_extras.action.RF_FIELD_ON_DETECTED" />
     <protected-broadcast android:name="com.android.nfc_extras.action.RF_FIELD_OFF_DETECTED" />
@@ -1119,8 +1118,7 @@
         android:protectionLevel="signature" />
 
     <!-- Must be required by an {@link android.net.VpnService},
-         to ensure that only the system can bind to it.
-         @hide -->
+         to ensure that only the system can bind to it. -->
     <permission android:name="android.permission.BIND_VPN_SERVICE"
         android:label="@string/permlab_bindVpnService"
         android:description="@string/permdesc_bindVpnService"
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..b285183 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..b285183 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 9fbd1e9..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..842d967 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..842d967 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 dab7eda..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..1d7948c 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 9ec3fe0..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 9ec3fe0..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..ee8329d 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..ee8329d 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 5b51072..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..1d0ea54 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/layout/text_edit_no_paste_window.xml b/core/res/res/layout/text_edit_no_paste_window.xml
index 5e9acc2..c4c0b8a 100644
--- a/core/res/res/layout/text_edit_no_paste_window.xml
+++ b/core/res/res/layout/text_edit_no_paste_window.xml
@@ -30,7 +30,6 @@
         android:textAppearance="?android:attr/textAppearanceMediumInverse"
         android:textColor="@android:color/dim_foreground_dark_inverse_disabled"
         android:background="@android:drawable/text_edit_paste_window"
-        android:text="@android:string/pasteDisabled"
         android:layout_marginBottom="12dip"
     />
 
diff --git a/core/res/res/layout/text_edit_side_no_paste_window.xml b/core/res/res/layout/text_edit_side_no_paste_window.xml
index dc411a1..78423a7 100644
--- a/core/res/res/layout/text_edit_side_no_paste_window.xml
+++ b/core/res/res/layout/text_edit_side_no_paste_window.xml
@@ -30,7 +30,6 @@
         android:textAppearance="?android:attr/textAppearanceMediumInverse"
         android:textColor="@android:color/dim_foreground_dark_inverse_disabled"
         android:background="@android:drawable/text_edit_side_paste_window"
-        android:text="@android:string/pasteDisabled"
         android:layout_marginBottom="12dip"
     />
 
diff --git a/core/res/res/layout/volume_adjust.xml b/core/res/res/layout/volume_adjust.xml
index 8c580c2..7303003 100644
--- a/core/res/res/layout/volume_adjust.xml
+++ b/core/res/res/layout/volume_adjust.xml
@@ -54,7 +54,6 @@
             android:padding="16dip"
             android:background="?attr/selectableItemBackground"
             android:src="@drawable/ic_sysbar_quicksettings"
-            android:contentDescription="@string/volume_panel_more_description"
             />
 
     </LinearLayout>
diff --git a/core/res/res/layout/volume_adjust_item.xml b/core/res/res/layout/volume_adjust_item.xml
index beb511d..fb900f7 100644
--- a/core/res/res/layout/volume_adjust_item.xml
+++ b/core/res/res/layout/volume_adjust_item.xml
@@ -38,7 +38,6 @@
         android:layout_height="wrap_content"
         android:layout_weight="1"
         android:padding="16dip"
-        android:layout_marginLeft="8dip"
         android:layout_marginRight="8dip" />
 
 </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/dimens.xml b/core/res/res/values/dimens.xml
index e534e9b..829f757 100644
--- a/core/res/res/values/dimens.xml
+++ b/core/res/res/values/dimens.xml
@@ -32,8 +32,12 @@
     <dimen name="toast_y_offset">64dip</dimen>
     <!-- Height of the status bar -->
     <dimen name="status_bar_height">25dip</dimen>
-    <!-- Height of the system bar -->
+    <!-- Height of the system bar (combined status + navigation, used on large screens) -->
     <dimen name="system_bar_height">48dip</dimen>
+    <!-- Height of the horizontal navigation bar on devices that require it -->
+    <dimen name="navigation_bar_height">48dp</dimen>
+    <!-- Width of the vertical navigation bar on devices that require it -->
+    <dimen name="navigation_bar_width">42dp</dimen>
     <!-- Height of notification icons in the status bar -->
     <dimen name="status_bar_icon_size">24dip</dimen>
     <!-- Size of the giant number (unread count) in the notifications -->
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 5618bfb..583310d 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>
@@ -2403,9 +2403,6 @@
     <!-- Item on EditText context menu. This action is used to paste from the clipboard into the eidt field -->
     <string name="paste">Paste</string>
 
-    <!-- Text displayed in a popup dialog in TextEdit when the clipboard is empty. 'paste' is used otherwise. [CHAR LIMIT=20] -->
-    <string name="pasteDisabled">Nothing to paste</string>
-
     <!-- Item on EditText context menu. This action is used to replace the current word by other suggested words, suggested by the IME or the spell checker -->
     <string name="replace">Replace</string>
 
@@ -2466,25 +2463,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. -->
@@ -2554,17 +2550,15 @@
     <string name="volume_unknown">Volume</string>
 
     <!-- Content description for bluetooth volume icon [CHAR LIMIT=100] -->
-    <string name="volume_icon_description_bluetooth">Bluetooth volume. Tap to toggle silent mode.</string>
+    <string name="volume_icon_description_bluetooth">Bluetooth volume</string>
     <!-- Content description for ringer volume icon [CHAR LIMIT=100] -->
-    <string name="volume_icon_description_ringer">Ringtone volume. Tap to toggle silent mode.</string>
+    <string name="volume_icon_description_ringer">Ringtone volume</string>
     <!-- Content description for in-call volume icon [CHAR LIMIT=100] -->
-    <string name="volume_icon_description_incall">Call volume. Tap to toggle silent mode.</string>
+    <string name="volume_icon_description_incall">Call volume</string>
     <!-- Content description for media volume icon [CHAR LIMIT=100] -->
-    <string name="volume_icon_description_media">Media volume. Tap to toggle silent mode.</string>
+    <string name="volume_icon_description_media">Media volume</string>
     <!-- Content description for notification volume icon [CHAR LIMIT=100] -->
-    <string name="volume_icon_description_notification">Notification volume. Tap to toggle silent mode.</string>
-    <!-- Content description for volume settings expansion button [CHAR LIMIT=100] -->
-    <string name="volume_panel_more_description">Tap to show more audio stream volumes.</string>
+    <string name="volume_icon_description_notification">Notification volume</string>
 
     <!-- Ringtone picker strings --> <skip />
     <!-- Choice in the ringtone picker.  If chosen, the default ringtone will be used. -->
diff --git a/core/tests/coretests/src/android/content/pm/ManifestDigestTest.java b/core/tests/coretests/src/android/content/pm/ManifestDigestTest.java
new file mode 100644
index 0000000..8922f27
--- /dev/null
+++ b/core/tests/coretests/src/android/content/pm/ManifestDigestTest.java
@@ -0,0 +1,74 @@
+package android.content.pm;
+
+import android.os.Parcel;
+import android.test.AndroidTestCase;
+import android.util.Base64;
+
+import java.util.jar.Attributes;
+
+public class ManifestDigestTest extends AndroidTestCase {
+    private static final byte[] DIGEST_1 = {
+            (byte) 0x00, (byte) 0xAA, (byte) 0x55, (byte) 0xFF
+    };
+
+    private static final String DIGEST_1_STR = Base64.encodeToString(DIGEST_1, Base64.DEFAULT);
+
+    private static final byte[] DIGEST_2 = {
+            (byte) 0x0A, (byte) 0xA5, (byte) 0xF0, (byte) 0x5A
+    };
+
+    private static final String DIGEST_2_STR = Base64.encodeToString(DIGEST_2, Base64.DEFAULT);
+
+    private static final Attributes.Name SHA1_DIGEST = new Attributes.Name("SHA1-Digest");
+
+    private static final Attributes.Name MD5_DIGEST = new Attributes.Name("MD5-Digest");
+
+    public void testManifestDigest_FromAttributes_Null() {
+        assertNull("Attributes were null, so ManifestDigest.fromAttributes should return null",
+                ManifestDigest.fromAttributes(null));
+    }
+
+    public void testManifestDigest_FromAttributes_NoAttributes() {
+        Attributes a = new Attributes();
+
+        assertNull("There were no attributes to extract, so ManifestDigest should be null",
+                ManifestDigest.fromAttributes(a));
+    }
+
+    public void testManifestDigest_FromAttributes_SHA1PreferredOverMD5() {
+        Attributes a = new Attributes();
+        a.put(SHA1_DIGEST, DIGEST_1_STR);
+
+        a.put(MD5_DIGEST, DIGEST_2_STR);
+
+        ManifestDigest fromAttributes = ManifestDigest.fromAttributes(a);
+
+        assertNotNull("A valid ManifestDigest should be returned", fromAttributes);
+
+        ManifestDigest created = new ManifestDigest(DIGEST_1);
+
+        assertEquals("SHA-1 should be preferred over MD5: " + created.toString() + " vs. "
+                + fromAttributes.toString(), created, fromAttributes);
+
+        assertEquals("Hash codes should be the same: " + created.toString() + " vs. "
+                + fromAttributes.toString(), created.hashCode(), fromAttributes
+                .hashCode());
+    }
+
+    public void testManifestDigest_Parcel() {
+        Attributes a = new Attributes();
+        a.put(SHA1_DIGEST, DIGEST_1_STR);
+
+        ManifestDigest digest = ManifestDigest.fromAttributes(a);
+
+        Parcel p = Parcel.obtain();
+        digest.writeToParcel(p, 0);
+        p.setDataPosition(0);
+
+        ManifestDigest fromParcel = ManifestDigest.CREATOR.createFromParcel(p);
+
+        assertEquals("ManifestDigest going through parceling should be the same as before: "
+                + digest.toString() + " and " + fromParcel.toString(), digest,
+                fromParcel);
+    }
+}
diff --git a/data/keyboards/Generic.kl b/data/keyboards/Generic.kl
index 68a158e..10de6ac 100644
--- a/data/keyboards/Generic.kl
+++ b/data/keyboards/Generic.kl
@@ -105,7 +105,7 @@
 key 83    NUMPAD_DOT
 # key 84 (undefined)
 # key 85 "KEY_ZENKAKUHANKAKU"
-# key 86 "KEY_102ND"
+key 86    BACKSLASH
 key 87    F11
 key 88    F12
 # key 89 "KEY_RO"
@@ -161,8 +161,8 @@
 key 139   MENU              WAKE_DROPPED
 # key 140 "KEY_CALC"
 # key 141 "KEY_SETUP"
-# key 142 "KEY_SLEEP"
-# key 143 "KEY_WAKEUP"
+key 142   POWER             WAKE
+key 143   POWER             WAKE
 # key 144 "KEY_FILE"
 # key 145 "KEY_SENDFILE"
 # key 146 "KEY_DELETEFILE"
@@ -171,7 +171,7 @@
 # key 149 "KEY_PROG2"
 key 150   EXPLORER
 # key 151 "KEY_MSDOS"
-# key 152 "KEY_COFFEE"
+key 152   POWER             WAKE
 # key 153 "KEY_DIRECTION"
 # key 154 "KEY_CYCLEWINDOWS"
 key 155   ENVELOPE
@@ -246,20 +246,6 @@
 # key 224 "KEY_BRIGHTNESSDOWN"
 # key 225 "KEY_BRIGHTNESSUP"
 key 226   HEADSETHOOK
-key 227   STAR
-key 228   POUND
-key 229   SOFT_LEFT
-key 230   SOFT_RIGHT
-key 231   CALL
-key 232   DPAD_CENTER
-key 233   HEADSETHOOK
-# key 234 "KEY_0_5" or "KEY_SAVE"
-# key 235 "KEY_2_5" or "KEY_DOCUMENTS"
-# key 236 "KEY_SWITCHVIDEOMODE" or "KEY_BATTERY"
-# key 237 "KEY_KBDILLUMTOGGLE"
-# key 238 "KEY_KBDILLUMDOWN"
-# key 239 "KEY_KBDILLUMUP"
-# key 240 "KEY_UNKNOWN"
 
 key 256   BUTTON_1
 key 257   BUTTON_2
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..a6fb12e 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
@@ -207,9 +208,28 @@
 
 protected:
 
-    // freeAllBuffers frees the resources (both GraphicBuffer and EGLImage) for
-    // all slots.
-    void freeAllBuffers();
+    // freeBufferLocked frees the resources (both GraphicBuffer and EGLImage)
+    // for the given slot.
+    void freeBufferLocked(int index);
+
+    // freeAllBuffersLocked frees the resources (both GraphicBuffer and
+    // EGLImage) for all slots.
+    void freeAllBuffersLocked();
+
+    // freeAllBuffersExceptHeadLocked frees the resources (both GraphicBuffer
+    // and EGLImage) for all slots except the head of mQueue
+    void freeAllBuffersExceptHeadLocked();
+
+    // drainQueueLocked drains the buffer queue if we're in synchronous mode
+    // returns immediately otherwise. return NO_INIT if SurfaceTexture
+    // became abandoned or disconnected during this call.
+    status_t drainQueueLocked();
+
+    // drainQueueAndFreeBuffersLocked drains the buffer queue if we're in
+    // synchronous mode and free all buffers. In asynchronous mode, all buffers
+    // are freed except the current buffer.
+    status_t drainQueueAndFreeBuffersLocked();
+
     static bool isExternalFormat(uint32_t format);
 
 private:
diff --git a/include/media/stagefright/HardwareAPI.h b/include/media/stagefright/HardwareAPI.h
index d785c48..32eed3f 100644
--- a/include/media/stagefright/HardwareAPI.h
+++ b/include/media/stagefright/HardwareAPI.h
@@ -73,16 +73,6 @@
     OMX_BOOL bStoreMetaData;
 };
 
-// A pointer to this struct is passed to OMX_SetParameter() when the extension
-// index "OMX.google.android.index.enableSecureMode"
-// is given.
-//
-struct EnableSecureModeParams {
-    OMX_U32 nSize;
-    OMX_VERSIONTYPE nVersion;
-    OMX_BOOL bEnableSecureMode;
-};
-
 // A pointer to this struct is passed to OMX_SetParameter when the extension
 // index for the 'OMX.google.android.index.useAndroidNativeBuffer' extension is
 // given.  This call will only be performed if a prior call was made with the
diff --git a/include/media/stagefright/OMXCodec.h b/include/media/stagefright/OMXCodec.h
index 2a1b3d8..2932744 100644
--- a/include/media/stagefright/OMXCodec.h
+++ b/include/media/stagefright/OMXCodec.h
@@ -319,8 +319,6 @@
     void initOutputFormat(const sp<MetaData> &inputFormat);
     status_t initNativeWindow();
 
-    status_t enableSecureMode();
-
     void dumpPortStatus(OMX_U32 portIndex);
 
     status_t configureCodec(const sp<MetaData> &meta);
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/include/utils/threads.h b/include/utils/threads.h
index c8e9c04..c84a9b4 100644
--- a/include/utils/threads.h
+++ b/include/utils/threads.h
@@ -20,6 +20,7 @@
 #include <stdint.h>
 #include <sys/types.h>
 #include <time.h>
+#include <system/graphics.h>
 
 #if defined(HAVE_PTHREADS)
 # include <pthread.h>
@@ -42,8 +43,8 @@
      * ** Keep in sync with android.os.Process.java **
      * ***********************************************
      * 
-     * This maps directly to the "nice" priorites we use in Android.
-     * A thread priority should be chosen inverse-proportinally to
+     * This maps directly to the "nice" priorities we use in Android.
+     * A thread priority should be chosen inverse-proportionally to
      * the amount of work the thread is expected to do. The more work
      * a thread will do, the less favorable priority it should get so that 
      * it doesn't starve the system. Threads not behaving properly might
@@ -66,7 +67,7 @@
     ANDROID_PRIORITY_DISPLAY        =  -4,
     
     /* ui service treads might want to run at a urgent display (uncommon) */
-    ANDROID_PRIORITY_URGENT_DISPLAY =  -8,
+    ANDROID_PRIORITY_URGENT_DISPLAY =  HAL_PRIORITY_URGENT_DISPLAY,
     
     /* all normal audio threads */
     ANDROID_PRIORITY_AUDIO          = -16,
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/Surface.cpp b/libs/gui/Surface.cpp
index ccf98e5..2c70251 100644
--- a/libs/gui/Surface.cpp
+++ b/libs/gui/Surface.cpp
@@ -277,6 +277,11 @@
     if (surface == 0) {
        surface = new Surface(data, binder);
        sCachedSurfaces.add(binder, surface);
+    } else {
+        // The Surface was found in the cache, but we still should clear any
+        // remaining data from the parcel.
+        data.readStrongBinder();  // ISurfaceTexture
+        data.readInt32();         // identity
     }
     if (surface->mSurface == NULL && surface->getISurfaceTexture() == NULL) {
         surface = 0;
diff --git a/libs/gui/SurfaceTexture.cpp b/libs/gui/SurfaceTexture.cpp
index be71c94..7ac4343 100644
--- a/libs/gui/SurfaceTexture.cpp
+++ b/libs/gui/SurfaceTexture.cpp
@@ -104,7 +104,7 @@
 
 SurfaceTexture::~SurfaceTexture() {
     LOGV("SurfaceTexture::~SurfaceTexture");
-    freeAllBuffers();
+    freeAllBuffersLocked();
 }
 
 status_t SurfaceTexture::setBufferCountServerLocked(int bufferCount) {
@@ -154,7 +154,6 @@
         LOGE("setBufferCount: SurfaceTexture has been abandoned!");
         return NO_INIT;
     }
-
     if (bufferCount > NUM_BUFFER_SLOTS) {
         LOGE("setBufferCount: bufferCount larger than slots available");
         return BAD_VALUE;
@@ -185,7 +184,7 @@
 
     // here we're guaranteed that the client doesn't have dequeued buffers
     // and will release all of its buffer references.
-    freeAllBuffers();
+    freeAllBuffersLocked();
     mBufferCount = bufferCount;
     mClientBufferCount = bufferCount;
     mCurrentTexture = INVALID_BUFFER_SLOT;
@@ -228,11 +227,6 @@
         uint32_t format, uint32_t usage) {
     LOGV("SurfaceTexture::dequeueBuffer");
 
-    if (mAbandoned) {
-        LOGE("dequeueBuffer: SurfaceTexture has been abandoned!");
-        return NO_INIT;
-    }
-
     if ((w && !h) || (!w && h)) {
         LOGE("dequeueBuffer: invalid size: w=%u, h=%u", w, h);
         return BAD_VALUE;
@@ -246,10 +240,15 @@
     int dequeuedCount = 0;
     bool tryAgain = true;
     while (tryAgain) {
+        if (mAbandoned) {
+            LOGE("dequeueBuffer: SurfaceTexture has been abandoned!");
+            return NO_INIT;
+        }
+
         // We need to wait for the FIFO to drain if the number of buffer
         // needs to change.
         //
-        // The condition "number of buffer needs to change" is true if
+        // The condition "number of buffers needs to change" is true if
         // - the client doesn't care about how many buffers there are
         // - AND the actual number of buffer is different from what was
         //   set in the last setBufferCountServer()
@@ -261,31 +260,24 @@
         // As long as this condition is true AND the FIFO is not empty, we
         // wait on mDequeueCondition.
 
-        int minBufferCountNeeded = mSynchronousMode ?
+        const int minBufferCountNeeded = mSynchronousMode ?
                 MIN_SYNC_BUFFER_SLOTS : MIN_ASYNC_BUFFER_SLOTS;
 
-        if (!mClientBufferCount &&
+        const bool numberOfBuffersNeedsToChange = !mClientBufferCount &&
                 ((mServerBufferCount != mBufferCount) ||
-                        (mServerBufferCount < minBufferCountNeeded))) {
+                        (mServerBufferCount < minBufferCountNeeded));
+
+        if (!mQueue.isEmpty() && numberOfBuffersNeedsToChange) {
             // wait for the FIFO to drain
-            while (!mQueue.isEmpty()) {
-                mDequeueCondition.wait(mMutex);
-                if (mAbandoned) {
-                    LOGE("dequeueBuffer: SurfaceTexture was abandoned while "
-                            "blocked!");
-                    return NO_INIT;
-                }
-            }
-            minBufferCountNeeded = mSynchronousMode ?
-                    MIN_SYNC_BUFFER_SLOTS : MIN_ASYNC_BUFFER_SLOTS;
+            mDequeueCondition.wait(mMutex);
+            // NOTE: we continue here because we need to reevaluate our
+            // whole state (eg: we could be abandoned or disconnected)
+            continue;
         }
 
-
-        if (!mClientBufferCount &&
-                ((mServerBufferCount != mBufferCount) ||
-                        (mServerBufferCount < minBufferCountNeeded))) {
+        if (numberOfBuffersNeedsToChange) {
             // here we're guaranteed that mQueue is empty
-            freeAllBuffers();
+            freeAllBuffersLocked();
             mBufferCount = mServerBufferCount;
             if (mBufferCount < minBufferCountNeeded)
                 mBufferCount = minBufferCountNeeded;
@@ -414,9 +406,9 @@
 
     if (!enabled) {
         // going to asynchronous mode, drain the queue
-        while (mSynchronousMode != enabled && !mQueue.isEmpty()) {
-            mDequeueCondition.wait(mMutex);
-        }
+        err = drainQueueLocked();
+        if (err != NO_ERROR)
+            return err;
     }
 
     if (mSynchronousMode != enabled) {
@@ -548,7 +540,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 +562,9 @@
                 err = -EINVAL;
             } else {
                 mConnectedApi = api;
+                *outWidth = mDefaultWidth;
+                *outHeight = mDefaultHeight;
+                *outTransform = 0;
             }
             break;
         default:
@@ -594,7 +590,9 @@
         case NATIVE_WINDOW_API_MEDIA:
         case NATIVE_WINDOW_API_CAMERA:
             if (mConnectedApi == api) {
+                drainQueueAndFreeBuffersLocked();
                 mConnectedApi = NO_CONNECTED_API;
+                mDequeueCondition.signal();
             } else {
                 LOGE("disconnect: connected to another api (cur=%d, req=%d)",
                         mConnectedApi, api);
@@ -630,7 +628,7 @@
 
     if (mAbandoned) {
         LOGE("calling updateTexImage() on an abandoned SurfaceTexture");
-        //return NO_INIT;
+        return NO_INIT;
     }
 
     // In asynchronous mode the list is guaranteed to be one buffer
@@ -639,21 +637,14 @@
         Fifo::iterator front(mQueue.begin());
         int buf = *front;
 
-        if (uint32_t(buf) >= NUM_BUFFER_SLOTS) {
-            LOGE("buffer index out of range (index=%d)", buf);
-            //return BAD_VALUE;
-        }
-
         // Update the GL texture object.
         EGLImageKHR image = mSlots[buf].mEglImage;
         if (image == EGL_NO_IMAGE_KHR) {
             EGLDisplay dpy = eglGetCurrentDisplay();
-
             if (mSlots[buf].mGraphicBuffer == 0) {
                 LOGE("buffer at slot %d is null", buf);
-                //return BAD_VALUE;
+                return BAD_VALUE;
             }
-
             image = createImage(dpy, mSlots[buf].mGraphicBuffer);
             mSlots[buf].mEglImage = image;
             mSlots[buf].mEglDisplay = dpy;
@@ -843,18 +834,66 @@
     mFrameAvailableListener = listener;
 }
 
-void SurfaceTexture::freeAllBuffers() {
+void SurfaceTexture::freeBufferLocked(int i) {
+    mSlots[i].mGraphicBuffer = 0;
+    mSlots[i].mBufferState = BufferSlot::FREE;
+    if (mSlots[i].mEglImage != EGL_NO_IMAGE_KHR) {
+        eglDestroyImageKHR(mSlots[i].mEglDisplay, mSlots[i].mEglImage);
+        mSlots[i].mEglImage = EGL_NO_IMAGE_KHR;
+        mSlots[i].mEglDisplay = EGL_NO_DISPLAY;
+    }
+}
+
+void SurfaceTexture::freeAllBuffersLocked() {
+    LOGW_IF(!mQueue.isEmpty(),
+            "freeAllBuffersLocked called but mQueue is not empty");
     for (int i = 0; i < NUM_BUFFER_SLOTS; i++) {
-        mSlots[i].mGraphicBuffer = 0;
-        mSlots[i].mBufferState = BufferSlot::FREE;
-        if (mSlots[i].mEglImage != EGL_NO_IMAGE_KHR) {
-            eglDestroyImageKHR(mSlots[i].mEglDisplay, mSlots[i].mEglImage);
-            mSlots[i].mEglImage = EGL_NO_IMAGE_KHR;
-            mSlots[i].mEglDisplay = EGL_NO_DISPLAY;
+        freeBufferLocked(i);
+    }
+}
+
+void SurfaceTexture::freeAllBuffersExceptHeadLocked() {
+    LOGW_IF(!mQueue.isEmpty(),
+            "freeAllBuffersExceptCurrentLocked called but mQueue is not empty");
+    int head = -1;
+    if (!mQueue.empty()) {
+        Fifo::iterator front(mQueue.begin());
+        head = *front;
+    }
+    for (int i = 0; i < NUM_BUFFER_SLOTS; i++) {
+        if (i != head) {
+            freeBufferLocked(i);
         }
     }
 }
 
+status_t SurfaceTexture::drainQueueLocked() {
+    while (mSynchronousMode && !mQueue.isEmpty()) {
+        mDequeueCondition.wait(mMutex);
+        if (mAbandoned) {
+            LOGE("drainQueueLocked: SurfaceTexture has been abandoned!");
+            return NO_INIT;
+        }
+        if (mConnectedApi == NO_CONNECTED_API) {
+            LOGE("drainQueueLocked: SurfaceTexture is not connected!");
+            return NO_INIT;
+        }
+    }
+    return NO_ERROR;
+}
+
+status_t SurfaceTexture::drainQueueAndFreeBuffersLocked() {
+    status_t err = drainQueueLocked();
+    if (err == NO_ERROR) {
+        if (mSynchronousMode) {
+            freeAllBuffersLocked();
+        } else {
+            freeAllBuffersExceptHeadLocked();
+        }
+    }
+    return err;
+}
+
 EGLImageKHR SurfaceTexture::createImage(EGLDisplay dpy,
         const sp<GraphicBuffer>& graphicBuffer) {
     EGLClientBuffer cbuf = (EGLClientBuffer)graphicBuffer->getNativeBuffer();
@@ -924,9 +963,10 @@
 
 void SurfaceTexture::abandon() {
     Mutex::Autolock lock(mMutex);
-    freeAllBuffers();
+    mQueue.clear();
     mAbandoned = true;
     mCurrentTextureBuf.clear();
+    freeAllBuffersLocked();
     mDequeueCondition.signal();
 }
 
@@ -981,19 +1021,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 f1abed6..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..b1b11a2 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;
@@ -753,10 +752,12 @@
 
     private class SetModeDeathHandler implements IBinder.DeathRecipient {
         private IBinder mCb; // To be notified of client's death
+        private int mPid;
         private int mMode = AudioSystem.MODE_NORMAL; // Current mode set by this client
 
         SetModeDeathHandler(IBinder cb) {
             mCb = cb;
+            mPid = Binder.getCallingPid();
         }
 
         public void binderDied() {
@@ -787,6 +788,10 @@
             }
         }
 
+        public int getPid() {
+            return mPid;
+        }
+
         public void setMode(int mode) {
             mMode = mode;
         }
@@ -1228,10 +1233,12 @@
 
     private class ScoClient implements IBinder.DeathRecipient {
         private IBinder mCb; // To be notified of client's death
+        private int mCreatorPid;
         private int mStartcount; // number of SCO connections started by this client
 
         ScoClient(IBinder cb) {
             mCb = cb;
+            mCreatorPid = Binder.getCallingPid();
             mStartcount = 0;
         }
 
@@ -1324,9 +1331,9 @@
                     // the connection.
                     broadcastScoConnectionState(AudioManager.SCO_AUDIO_STATE_CONNECTING);
                     // Accept SCO audio activation only in NORMAL audio mode or if the mode is
-                    // currently controlled by the same client.
+                    // currently controlled by the same client process.
                     if ((AudioService.this.mMode == AudioSystem.MODE_NORMAL ||
-                            mSetModeDeathHandlers.get(0).getBinder() == mCb) &&
+                            mSetModeDeathHandlers.get(0).getPid() == mCreatorPid) &&
                             mBluetoothHeadsetDevice != null &&
                             (mScoAudioState == SCO_STATE_INACTIVE ||
                              mScoAudioState == SCO_STATE_DEACTIVATE_REQ)) {
@@ -2159,7 +2166,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 +2855,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 +2874,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 +2892,7 @@
     public IRemoteControlClient getRemoteControlClient(int rcClientId) {
         synchronized(mCurrentRcLock) {
             if (rcClientId == mCurrentRcClientGen) {
-                return mCurrentRcClientRef.get();
+                return mCurrentRcClient;
             } else {
                 return null;
             }
@@ -2945,13 +2952,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 +2993,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 +3112,7 @@
      */
     private void clearRemoteControlDisplay() {
         synchronized(mCurrentRcLock) {
-            mCurrentRcClientRef.clear();
+            mCurrentRcClient = null;
             mCurrentRcClientInfoFlags = RC_INFO_NONE;
         }
         mAudioHandler.sendMessage( mAudioHandler.obtainMessage(MSG_RCDISPLAY_CLEAR) );
@@ -3120,18 +3127,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 +3215,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 +3230,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/Android.mk b/media/libstagefright/Android.mk
index 3f4dace..b9e4f9f 100644
--- a/media/libstagefright/Android.mk
+++ b/media/libstagefright/Android.mk
@@ -133,8 +133,9 @@
 LOCAL_STATIC_LIBRARIES += \
         libstagefright_chromium_http \
         libwebcore              \
+        libchromium_net \
 
-LOCAL_SHARED_LIBRARIES += libstlport libchromium_net
+LOCAL_SHARED_LIBRARIES += libstlport
 include external/stlport/libstlport.mk
 
 LOCAL_CPPFLAGS += -DCHROMIUM_AVAILABLE=1
diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp
index 67f6c79..0ea880b 100644
--- a/media/libstagefright/AwesomePlayer.cpp
+++ b/media/libstagefright/AwesomePlayer.cpp
@@ -63,7 +63,7 @@
 namespace android {
 
 static int64_t kLowWaterMarkUs = 2000000ll;  // 2secs
-static int64_t kHighWaterMarkUs = 10000000ll;  // 10secs
+static int64_t kHighWaterMarkUs = 5000000ll;  // 5secs
 static int64_t kHighWaterMarkRTSPUs = 4000000ll;  // 4secs
 static const size_t kLowWaterMarkBytes = 40000;
 static const size_t kHighWaterMarkBytes = 200000;
@@ -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/CameraSource.cpp b/media/libstagefright/CameraSource.cpp
index ea8eaa4..ac3565f 100755
--- a/media/libstagefright/CameraSource.cpp
+++ b/media/libstagefright/CameraSource.cpp
@@ -665,7 +665,7 @@
     LOGV("releaseRecordingFrame");
     if (mCameraRecordingProxy != NULL) {
         mCameraRecordingProxy->releaseRecordingFrame(frame);
-    } else {
+    } else if (mCamera != NULL) {
         int64_t token = IPCThreadState::self()->clearCallingIdentity();
         mCamera->releaseRecordingFrame(frame);
         IPCThreadState::self()->restoreCallingIdentity(token);
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/MPEG4Writer.cpp b/media/libstagefright/MPEG4Writer.cpp
index 8c9ff87..5f58090 100755
--- a/media/libstagefright/MPEG4Writer.cpp
+++ b/media/libstagefright/MPEG4Writer.cpp
@@ -1172,6 +1172,9 @@
 void MPEG4Writer::Track::addOneSttsTableEntry(
         size_t sampleCount, int32_t duration) {
 
+    if (duration == 0) {
+        LOGW("%d 0-duration samples found: %d", sampleCount);
+    }
     SttsTableEntry sttsEntry(sampleCount, duration);
     mSttsTableEntries.push_back(sttsEntry);
     ++mNumSttsTableEntries;
@@ -2001,17 +2004,18 @@
             mTrackDurationUs = timestampUs;
         }
 
+        // We need to use the time scale based ticks, rather than the
+        // timestamp itself to determine whether we have to use a new
+        // stts entry, since we may have rounding errors.
+        // The calculation is intended to reduce the accumulated
+        // rounding errors.
+        currDurationTicks =
+            ((timestampUs * mTimeScale + 500000LL) / 1000000LL -
+                (lastTimestampUs * mTimeScale + 500000LL) / 1000000LL);
+
         mSampleSizes.push_back(sampleSize);
         ++mNumSamples;
         if (mNumSamples > 2) {
-            // We need to use the time scale based ticks, rather than the
-            // timestamp itself to determine whether we have to use a new
-            // stts entry, since we may have rounding errors.
-            // The calculation is intended to reduce the accumulated
-            // rounding errors.
-            currDurationTicks =
-                     ((timestampUs * mTimeScale + 500000LL) / 1000000LL -
-                     (lastTimestampUs * mTimeScale + 500000LL) / 1000000LL);
 
             // Force the first sample to have its own stts entry so that
             // we can adjust its value later to maintain the A/V sync.
diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp
index 5327f3b..644c413 100755
--- a/media/libstagefright/OMXCodec.cpp
+++ b/media/libstagefright/OMXCodec.cpp
@@ -442,9 +442,17 @@
     sp<OMXCodecObserver> observer = new OMXCodecObserver;
     IOMX::node_id node = 0;
 
-    const char *componentName;
     for (size_t i = 0; i < matchingCodecs.size(); ++i) {
-        componentName = matchingCodecs[i].string();
+        const char *componentNameBase = matchingCodecs[i].string();
+        const char *componentName = componentNameBase;
+
+        AString tmp;
+        if (flags & kUseSecureInputBuffers) {
+            tmp = componentNameBase;
+            tmp.append(".secure");
+
+            componentName = tmp.c_str();
+        }
 
         if (createEncoder) {
             sp<MediaSource> softwareCodec =
@@ -459,7 +467,7 @@
 
         LOGV("Attempting to allocate OMX node '%s'", componentName);
 
-        uint32_t quirks = getComponentQuirks(componentName, createEncoder);
+        uint32_t quirks = getComponentQuirks(componentNameBase, createEncoder);
 
         if (!createEncoder
                 && (quirks & kOutputBuffersAreUnreadable)
@@ -720,32 +728,9 @@
         }
     }
 
-    if (mFlags & kUseSecureInputBuffers) {
-        (void)enableSecureMode();
-    }
-
     return OK;
 }
 
-status_t OMXCodec::enableSecureMode() {
-    OMX_INDEXTYPE index;
-
-    status_t err =
-        mOMX->getExtensionIndex(
-                mNode, "OMX.google.android.index.enableSecureMode", &index);
-
-    if (err != OK) {
-        return err;
-    }
-
-    EnableSecureModeParams params;
-    InitOMXParams(&params);
-
-    params.bEnableSecureMode = OMX_TRUE;
-
-    return mOMX->setConfig(mNode, index, &params, sizeof(params));
-}
-
 void OMXCodec::setMinBufferSize(OMX_U32 portIndex, OMX_U32 size) {
     OMX_PARAM_PORTDEFINITIONTYPE def;
     InitOMXParams(&def);
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/media/tests/ScoAudioTest/Android.mk b/media/tests/ScoAudioTest/Android.mk
new file mode 100755
index 0000000..ab12865
--- /dev/null
+++ b/media/tests/ScoAudioTest/Android.mk
@@ -0,0 +1,12 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+#LOCAL_SDK_VERSION := current
+
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_SRC_FILES := $(call all-subdir-java-files)
+
+LOCAL_PACKAGE_NAME := scoaudiotest
+
+include $(BUILD_PACKAGE)
diff --git a/media/tests/ScoAudioTest/AndroidManifest.xml b/media/tests/ScoAudioTest/AndroidManifest.xml
new file mode 100755
index 0000000..8ff973e
--- /dev/null
+++ b/media/tests/ScoAudioTest/AndroidManifest.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2010 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+  
+          http://www.apache.org/licenses/LICENSE-2.0
+  
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="com.android.scoaudiotest">
+   
+   <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
+   <uses-permission android:name="android.permission.RECORD_AUDIO" />
+   <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+   <uses-permission android:name="android.permission.BROADCAST_STICKY" />
+   <uses-permission android:name="android.permission.BLUETOOTH" />
+        
+   <application>    
+        <activity android:label="@string/app_name"
+                android:name="ScoAudioTest">         
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.LAUNCHER"/>
+            </intent-filter>
+        </activity>
+        
+    </application>   
+</manifest>
diff --git a/media/tests/ScoAudioTest/res/drawable/icon.png b/media/tests/ScoAudioTest/res/drawable/icon.png
new file mode 100755
index 0000000..64e3601
--- /dev/null
+++ b/media/tests/ScoAudioTest/res/drawable/icon.png
Binary files differ
diff --git a/media/tests/ScoAudioTest/res/drawable/record.png b/media/tests/ScoAudioTest/res/drawable/record.png
new file mode 100755
index 0000000..ae518d5
--- /dev/null
+++ b/media/tests/ScoAudioTest/res/drawable/record.png
Binary files differ
diff --git a/media/tests/ScoAudioTest/res/drawable/stop.png b/media/tests/ScoAudioTest/res/drawable/stop.png
new file mode 100755
index 0000000..83f012c
--- /dev/null
+++ b/media/tests/ScoAudioTest/res/drawable/stop.png
Binary files differ
diff --git a/media/tests/ScoAudioTest/res/layout/scoaudiotest.xml b/media/tests/ScoAudioTest/res/layout/scoaudiotest.xml
new file mode 100755
index 0000000..b769a0c
--- /dev/null
+++ b/media/tests/ScoAudioTest/res/layout/scoaudiotest.xml
@@ -0,0 +1,181 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2009 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.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent"
+    android:orientation="vertical">
+            
+    <LinearLayout
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+        android:orientation="vertical">
+
+        <LinearLayout android:id="@+id/playPause1Frame"
+            android:orientation="horizontal"
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginLeft="10dip"
+            android:layout_marginTop="3dip"
+            android:layout_marginRight="10dip"
+            android:layout_marginBottom="3dip" >
+
+            <TextView android:id="@+id/playPause1Text"
+                android:layout_width="fill_parent"
+                android:layout_height="fill_parent"
+                android:layout_weight="1.0"
+                android:text="@string/playback_name"
+                android:layout_gravity="center_vertical|left"
+                style="@android:style/TextAppearance.Medium" />
+
+            <ImageButton android:id="@+id/stop1"
+                android:layout_width="wrap_content"
+                android:layout_height="fill_parent"
+                android:layout_gravity="center_vertical|right"
+                android:layout_weight="0.0"
+                android:src="@drawable/stop"/>
+
+             <ImageButton android:id="@+id/playPause1"
+                android:layout_width="wrap_content"
+                android:layout_height="fill_parent"
+                android:layout_gravity="center_vertical|right"
+                android:layout_weight="0.0"
+                android:src="@android:drawable/ic_media_play"/>
+
+        </LinearLayout>
+
+    </LinearLayout>
+
+    <LinearLayout
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+        android:orientation="vertical">
+
+        <LinearLayout android:id="@+id/record1Frame"
+            android:orientation="horizontal"
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginLeft="10dip"
+            android:layout_marginTop="3dip"
+            android:layout_marginRight="10dip"
+            android:layout_marginBottom="3dip" >
+
+            <TextView android:id="@+id/record1Text"
+                android:layout_width="fill_parent"
+                android:layout_height="fill_parent"
+                android:layout_weight="1.0"
+                android:text="@string/record_name"
+                android:layout_gravity="center_vertical|left"
+                style="@android:style/TextAppearance.Medium" />
+
+            <ImageButton android:id="@+id/recStop1"
+                android:layout_width="wrap_content"
+                android:layout_height="fill_parent"
+                android:layout_gravity="center_vertical|right"
+                android:layout_weight="0.0"
+                android:src="@drawable/record"/>
+        </LinearLayout>
+
+    </LinearLayout>
+        
+    <LinearLayout
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+        android:orientation="vertical">
+    
+        <LinearLayout android:id="@+id/forceFrame"
+            android:orientation="horizontal"
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginLeft="10dip"
+            android:layout_marginTop="3dip"
+            android:layout_marginRight="10dip"
+            android:layout_marginBottom="3dip" >
+                       
+            <ToggleButton android:id="@+id/ForceScoButton"
+                    android:layout_width="wrap_content"
+                    android:layout_height="fill_parent"
+                    android:layout_gravity="center_vertical|left"
+                    android:layout_weight="0.0"
+                    android:textOff="@string/force_sco_off"
+                    android:textOn="@string/force_sco_on" />
+                     
+            <TextView android:id="@+id/scoStateTxt"
+                    android:layout_width="fill_parent"
+                    android:layout_height="fill_parent"
+                    android:layout_weight="1.0"
+                    android:layout_gravity="center_vertical|right"
+                    style="@android:style/TextAppearance.Medium" />
+        </LinearLayout>
+        <CheckBox
+            android:id="@+id/useSecondAudioManager"
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:text="@string/audiomanagertwo" />
+            
+    </LinearLayout>
+
+    <LinearLayout
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+        android:orientation="vertical">
+
+        <LinearLayout android:id="@+id/voiceDialerFrame"
+            android:orientation="horizontal"
+              android:layout_width="fill_parent"
+              android:layout_height="wrap_content"
+              android:layout_marginLeft="10dip"
+              android:layout_marginTop="3dip"
+              android:layout_marginRight="10dip"
+              android:layout_marginBottom="3dip" >
+                       
+               <ToggleButton android:id="@+id/VoiceDialerButton"
+                     android:layout_width="wrap_content"
+                     android:layout_height="fill_parent"
+                     android:layout_gravity="center_vertical|left"
+                     android:layout_weight="0.0"
+                     android:textOff="@string/vd_off"
+                     android:textOn="@string/vd_on" />
+                     
+              <TextView android:id="@+id/vdStateTxt"
+                      android:layout_width="fill_parent"
+                      android:layout_height="fill_parent"
+                      android:layout_weight="1.0"
+                      android:layout_gravity="center_vertical|right"
+                      style="@android:style/TextAppearance.Medium" />
+                     
+        </LinearLayout>
+
+    </LinearLayout>
+
+    <EditText android:id="@+id/speakTextEdit"
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content" />
+        
+    <ToggleButton android:id="@+id/TtsToFileButton"
+       android:layout_width="wrap_content"
+       android:layout_height="wrap_content"
+       android:textOff="@string/tts_speak"
+       android:textOn="@string/tts_to_file" />
+        
+        
+  <Spinner android:id="@+id/modeSpinner"
+              android:layout_width="fill_parent"
+              android:layout_height="wrap_content"
+              android:drawSelectorOnTop="true"
+   />
+        
+</LinearLayout>
diff --git a/media/tests/ScoAudioTest/res/raw/sine440_mo_16b_16k.wav b/media/tests/ScoAudioTest/res/raw/sine440_mo_16b_16k.wav
new file mode 100644
index 0000000..2538b4d6
--- /dev/null
+++ b/media/tests/ScoAudioTest/res/raw/sine440_mo_16b_16k.wav
Binary files differ
diff --git a/media/tests/ScoAudioTest/res/values/strings.xml b/media/tests/ScoAudioTest/res/values/strings.xml
new file mode 100755
index 0000000..c3ff6d5
--- /dev/null
+++ b/media/tests/ScoAudioTest/res/values/strings.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+    <string name="app_name">Sco Audio Test</string>
+    <string name="playback_name">Playback</string>
+    <string name="record_name">Record</string>    
+    <string name="force_sco_off">NO SCO</string>
+    <string name="force_sco_on">USE SCO</string>
+    <string name="vd_off">Start Voice Dialer</string>
+    <string name="vd_on">Voice Dialer On</string>
+    <string name="tts_speak">Speak TTS</string>
+    <string name="tts_to_file">TTS to file</string>
+    <string name="audiomanagertwo">Use different AudioManager for starting SCO</string>
+    
+</resources>
diff --git a/media/tests/ScoAudioTest/src/com/android/scoaudiotest/ScoAudioTest.java b/media/tests/ScoAudioTest/src/com/android/scoaudiotest/ScoAudioTest.java
new file mode 100644
index 0000000..fe3929d
--- /dev/null
+++ b/media/tests/ScoAudioTest/src/com/android/scoaudiotest/ScoAudioTest.java
@@ -0,0 +1,700 @@
+/*
+ * Copyright (C) 2009 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 com.android.scoaudiotest;
+
+import android.app.Activity;
+import android.bluetooth.BluetoothAdapter;
+import android.bluetooth.BluetoothDevice;
+import android.bluetooth.BluetoothHeadset;
+import android.bluetooth.BluetoothProfile;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.res.AssetFileDescriptor;
+import android.media.AudioManager;
+import android.media.MediaPlayer;
+import android.media.MediaRecorder;
+import android.os.Bundle;
+import android.os.Environment;
+import android.os.Handler;
+import android.speech.tts.TextToSpeech;
+import android.speech.tts.TextToSpeech.OnUtteranceCompletedListener;
+import android.util.Log;
+import android.view.KeyEvent;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.ArrayAdapter;
+import android.widget.CheckBox;
+import android.widget.CompoundButton;
+import android.widget.CompoundButton.OnCheckedChangeListener;
+import android.widget.EditText;
+import android.widget.ImageButton;
+import android.widget.ImageView;
+import android.widget.Spinner;
+import android.widget.TextView;
+import android.widget.ToggleButton;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+
+public class ScoAudioTest extends Activity {
+
+    final static String TAG = "ScoAudioTest";
+    
+    AudioManager mAudioManager;
+    AudioManager mAudioManager2;
+    boolean mForceScoOn;
+    ToggleButton mScoButton;
+    ToggleButton mVoiceDialerButton;
+    boolean mVoiceDialerOn;
+    String mLastRecordedFile;
+    SimpleMediaController mMediaControllers[] = new SimpleMediaController[2];
+    private TextToSpeech mTts;
+    private HashMap<String, String> mTtsParams;
+    private int mOriginalVoiceVolume;
+    EditText mSpeakText;
+    boolean mTtsInited;
+    private Handler mHandler;
+    private static final String UTTERANCE = "utterance";
+    private static Intent sVoiceCommandIntent;
+    private File mSampleFile;
+    ToggleButton mTtsToFileButton;
+    private boolean mTtsToFile;
+    private int mCurrentMode;
+    Spinner mModeSpinner;
+    private BluetoothHeadset mBluetoothHeadset;
+    private BluetoothDevice mBluetoothHeadsetDevice;
+    TextView mScoStateTxt;
+    TextView mVdStateTxt;
+    
+    private final BroadcastReceiver mReceiver = new ScoBroadcastReceiver();
+
+    public ScoAudioTest() {
+        Log.e(TAG, "contructor");
+    }
+        
+    /** Called when the activity is first created. */
+    @Override
+    public void onCreate(Bundle icicle) {
+        super.onCreate(icicle);
+        
+        setContentView(R.layout.scoaudiotest);
+
+        mScoStateTxt = (TextView) findViewById(R.id.scoStateTxt);
+        mVdStateTxt = (TextView) findViewById(R.id.vdStateTxt);
+
+        IntentFilter intentFilter =
+            new IntentFilter(BluetoothHeadset.ACTION_AUDIO_STATE_CHANGED);
+        intentFilter.addAction(AudioManager.ACTION_SCO_AUDIO_STATE_CHANGED);
+        intentFilter.addAction(AudioManager.ACTION_SCO_AUDIO_STATE_UPDATED);
+        registerReceiver(mReceiver, intentFilter);
+
+        mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
+        mAudioManager2 = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
+        mHandler = new Handler();
+        
+        mMediaControllers[0] = new SimplePlayerController(this, R.id.playPause1, R.id.stop1,
+                R.raw.sine440_mo_16b_16k, AudioManager.STREAM_BLUETOOTH_SCO);
+        TextView name = (TextView) findViewById(R.id.playPause1Text);
+        name.setText("VOICE_CALL stream");
+        
+        mScoButton = (ToggleButton)findViewById(R.id.ForceScoButton);
+        mScoButton.setOnCheckedChangeListener(mForceScoChanged);
+        mForceScoOn = false;
+        mScoButton.setChecked(mForceScoOn);
+
+        mVoiceDialerButton = (ToggleButton)findViewById(R.id.VoiceDialerButton);
+        mVoiceDialerButton.setOnCheckedChangeListener(mVoiceDialerChanged);
+        mVoiceDialerOn = false;
+        mVoiceDialerButton.setChecked(mVoiceDialerOn);
+
+        
+        mMediaControllers[1] = new SimpleRecordController(this, R.id.recStop1, 0, "Sco_record_");
+        mTtsInited = false;
+        mTts = new TextToSpeech(this, new TtsInitListener());
+        mTtsParams = new HashMap<String, String>();
+        mTtsParams.put(TextToSpeech.Engine.KEY_PARAM_STREAM,
+                String.valueOf(AudioManager.STREAM_BLUETOOTH_SCO));
+        mTtsParams.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID,
+                UTTERANCE);
+
+        mSpeakText = (EditText) findViewById(R.id.speakTextEdit);        
+        mSpeakText.setOnKeyListener(mSpeakKeyListener);
+        mSpeakText.setText("sco audio test sentence");
+        mTtsToFileButton = (ToggleButton)findViewById(R.id.TtsToFileButton);
+        mTtsToFileButton.setOnCheckedChangeListener(mTtsToFileChanged);
+        mTtsToFile = true;
+        mTtsToFileButton.setChecked(mTtsToFile);
+
+        mModeSpinner = (Spinner) findViewById(R.id.modeSpinner);
+        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
+                android.R.layout.simple_spinner_item, mModeStrings);
+        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+        mModeSpinner.setAdapter(adapter);
+        mModeSpinner.setOnItemSelectedListener(mModeChanged);
+        mCurrentMode = mAudioManager.getMode();
+        mModeSpinner.setSelection(mCurrentMode);
+
+        mBluetoothHeadsetDevice = null;
+        BluetoothAdapter btAdapter = BluetoothAdapter.getDefaultAdapter();
+        if (btAdapter != null) {
+            btAdapter.getProfileProxy(this, mBluetoothProfileServiceListener,
+                                    BluetoothProfile.HEADSET);
+        }
+
+        sVoiceCommandIntent = new Intent(Intent.ACTION_VOICE_COMMAND);
+        sVoiceCommandIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+    }
+
+    @Override
+    public void onDestroy() {
+        super.onDestroy();
+        mTts.shutdown();
+        unregisterReceiver(mReceiver);
+        if (mBluetoothHeadset != null) {
+            BluetoothAdapter btAdapter = BluetoothAdapter.getDefaultAdapter();
+            if (btAdapter != null) {
+                btAdapter.closeProfileProxy(BluetoothProfile.HEADSET, mBluetoothHeadset);
+            }
+        }
+    }
+    
+    @Override
+    protected void onPause() {
+        super.onPause();
+//        mForceScoOn = false;
+//        mScoButton.setChecked(mForceScoOn);
+        mMediaControllers[0].stop();        
+        mMediaControllers[1].stop();
+        mAudioManager.setStreamVolume(AudioManager.STREAM_BLUETOOTH_SCO,
+                mOriginalVoiceVolume, 0);
+    }
+
+    @Override
+    protected void onResume() {
+        super.onResume();
+        mLastRecordedFile = "";
+        mMediaControllers[0].mFileName = "";
+        mOriginalVoiceVolume = mAudioManager.getStreamVolume(
+                AudioManager.STREAM_BLUETOOTH_SCO);
+        setVolumeControlStream(AudioManager.STREAM_BLUETOOTH_SCO);
+        mCurrentMode = mAudioManager.getMode();
+        mModeSpinner.setSelection(mCurrentMode);
+    }
+
+    private OnCheckedChangeListener mForceScoChanged
+    = new OnCheckedChangeListener(){
+        @Override
+        public void onCheckedChanged(CompoundButton buttonView,
+                boolean isChecked) {
+            if (mForceScoOn != isChecked) {
+                mForceScoOn = isChecked;
+                AudioManager mngr = mAudioManager;
+                CheckBox box = (CheckBox) findViewById(R.id.useSecondAudioManager);
+                if (box.isChecked()) {
+                    Log.i(TAG, "Using 2nd audio manager");
+                    mngr = mAudioManager2;
+                }
+
+                if (mForceScoOn) {
+                    Log.e(TAG, "startBluetoothSco() IN");
+                    mngr.startBluetoothSco();
+                    Log.e(TAG, "startBluetoothSco() OUT");
+                } else {
+                    Log.e(TAG, "stopBluetoothSco() IN");
+                    mngr.stopBluetoothSco();
+                    Log.e(TAG, "stopBluetoothSco() OUT");
+                }
+            }
+        }
+    };
+
+    private OnCheckedChangeListener mVoiceDialerChanged
+    = new OnCheckedChangeListener(){
+        @Override
+        public void onCheckedChanged(CompoundButton buttonView,
+                boolean isChecked) {
+            if (mVoiceDialerOn != isChecked) {
+                mVoiceDialerOn = isChecked;
+                if (mBluetoothHeadset != null && mBluetoothHeadsetDevice != null) {
+                    if (mVoiceDialerOn) {
+                        mBluetoothHeadset.startVoiceRecognition(mBluetoothHeadsetDevice);
+                    } else {
+                        mBluetoothHeadset.stopVoiceRecognition(mBluetoothHeadsetDevice);                        
+                    }
+                }
+            }
+        }
+    };
+
+    private OnCheckedChangeListener mTtsToFileChanged
+    = new OnCheckedChangeListener(){
+        @Override
+        public void onCheckedChanged(CompoundButton buttonView,
+                boolean isChecked) {
+            mTtsToFile = isChecked;
+        }
+    };
+
+    private class SimpleMediaController implements OnClickListener {
+        int mPlayPauseButtonId;
+        int mStopButtonId;
+        Context mContext;
+        ImageView mPlayPauseButton;
+        int mPlayImageResource;
+        int mPauseImageResource;
+        String mFileNameBase;
+        String mFileName;
+        int mFileResId;
+        
+        SimpleMediaController(Context context, int playPausebuttonId, int stopButtonId, String fileName) {
+            mContext = context;
+            mPlayPauseButtonId = playPausebuttonId;
+            mStopButtonId = stopButtonId;
+            mFileNameBase = fileName;
+            mPlayPauseButton = (ImageButton) findViewById(playPausebuttonId);
+            ImageButton stop = (ImageButton) findViewById(stopButtonId);
+
+            mPlayPauseButton.setOnClickListener(this);
+            mPlayPauseButton.requestFocus();
+            if (stop != null) {
+                stop.setOnClickListener(this);
+            }
+        }
+
+        SimpleMediaController(Context context, int playPausebuttonId, int stopButtonId, int fileResId) {
+            mContext = context;
+            mPlayPauseButtonId = playPausebuttonId;
+            mStopButtonId = stopButtonId;
+            mFileNameBase = "";
+            mFileResId = fileResId;
+            mPlayPauseButton = (ImageButton) findViewById(playPausebuttonId);
+            ImageButton stop = (ImageButton) findViewById(stopButtonId);
+
+            mPlayPauseButton.setOnClickListener(this);
+            mPlayPauseButton.requestFocus();
+            if (stop != null) {
+                stop.setOnClickListener(this);
+            }
+        }
+
+        @Override
+        public void onClick(View v) {
+            if (v.getId() == mPlayPauseButtonId) {
+                playOrPause();
+            } else if (v.getId() == mStopButtonId) {
+                stop();
+            }
+        }
+        
+        public void playOrPause() {
+        }
+        
+        public void stop() {
+        }
+
+        public boolean isPlaying() {
+            return false;
+        }
+
+        public void updatePlayPauseButton() {
+            mPlayPauseButton.setImageResource(isPlaying() ? mPauseImageResource : mPlayImageResource);
+        }
+    }
+    
+    private class SimplePlayerController extends SimpleMediaController {
+        private MediaPlayer mMediaPlayer;
+        private int mStreamType;
+        SimplePlayerController(Context context, int playPausebuttonId, int stopButtonId, String fileName, int stream) {
+            super(context, playPausebuttonId, stopButtonId, fileName);
+            
+            mPlayImageResource = android.R.drawable.ic_media_play;
+            mPauseImageResource = android.R.drawable.ic_media_pause;
+            mStreamType = stream;
+            mFileName = Environment.getExternalStorageDirectory().toString() + "/music/" +
+                        mFileNameBase + "_" + ".wav";
+        }
+
+        SimplePlayerController(Context context, int playPausebuttonId, int stopButtonId, int fileResId, int stream) {
+            super(context, playPausebuttonId, stopButtonId, fileResId);
+            
+            mPlayImageResource = android.R.drawable.ic_media_play;
+            mPauseImageResource = android.R.drawable.ic_media_pause;
+            mStreamType = stream;
+            mFileName = "";
+        }
+
+        @Override
+        public void playOrPause() {
+            Log.e(TAG, "playOrPause playing: "+((mMediaPlayer == null)?false:!mMediaPlayer.isPlaying())+
+                    " mMediaPlayer: "+mMediaPlayer+
+                    " mFileName: "+mFileName+
+                    " mLastRecordedFile: "+mLastRecordedFile);
+            if (mMediaPlayer == null || !mMediaPlayer.isPlaying()){
+                if (mMediaPlayer == null) {
+                    if (mFileName != mLastRecordedFile) {
+                        mFileName = mLastRecordedFile;
+                        Log.e(TAG, "new recorded file: "+mFileName);
+                    }
+                    try {
+                        mMediaPlayer = new MediaPlayer();
+                        if (mFileName.equals("")) {
+                            Log.e(TAG, "Playing from resource");
+                            AssetFileDescriptor afd = mContext.getResources().openRawResourceFd(mFileResId);
+                            mMediaPlayer.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength());
+                            afd.close();
+                        } else {
+                            Log.e(TAG, "Playing file: "+mFileName);
+                            mMediaPlayer.setDataSource(mFileName);
+                        }
+                        mMediaPlayer.setAudioStreamType(mStreamType);
+                        mMediaPlayer.prepare();
+                        mMediaPlayer.setLooping(true);
+                    } catch (Exception ex) {
+                        Log.e(TAG, "mMediaPlayercreate failed:", ex);
+                        mMediaPlayer.release();
+                        mMediaPlayer = null;
+                    }
+
+                    if (mMediaPlayer != null) {
+                        mMediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
+                            @Override
+                            public void onCompletion(MediaPlayer mp) {
+                                updatePlayPauseButton();
+                            }
+                        });
+                    }
+                }
+                if (mMediaPlayer != null) {
+                    mMediaPlayer.start();
+                }
+            } else {
+                mMediaPlayer.pause();
+            }
+            updatePlayPauseButton();
+        }
+        @Override
+        public void stop() {
+            if (mMediaPlayer != null) {
+                mMediaPlayer.stop();
+                mMediaPlayer.release();
+                mMediaPlayer = null;
+            }
+            updatePlayPauseButton();
+        }
+        
+        @Override
+        public boolean isPlaying() {
+            if (mMediaPlayer != null) {
+                return mMediaPlayer.isPlaying();
+            } else {
+                return false;                
+            }
+        }
+    }
+    
+    private class SimpleRecordController extends SimpleMediaController {
+        private MediaRecorder mMediaRecorder;
+        private int mFileCount = 0;
+        private int mState = 0;
+        SimpleRecordController(Context context, int playPausebuttonId, int stopButtonId, String fileName) {
+            super(context, playPausebuttonId, stopButtonId, fileName);
+            Log.e(TAG, "SimpleRecordController cstor");
+            mPlayImageResource = R.drawable.record;
+            mPauseImageResource = R.drawable.stop;
+        }
+       
+        @Override
+        public void playOrPause() {
+            if (mState == 0) {
+                setup();
+                try {
+                    mMediaRecorder.start();
+                    mState = 1;
+                } catch (Exception e) {
+                    Log.e(TAG, "Could start MediaRecorder: " + e.toString());
+                    mMediaRecorder.release();
+                    mMediaRecorder = null;
+                    mState = 0;
+                }
+            } else {
+                try {
+                    mMediaRecorder.stop();
+                    mMediaRecorder.reset();
+                } catch (Exception e) {
+                    Log.e(TAG, "Could not stop MediaRecorder: " + e.toString());
+                    mMediaRecorder.release();
+                    mMediaRecorder = null;
+                } finally {
+                    mState = 0;
+                }
+            }
+            updatePlayPauseButton();
+        }
+
+        public void setup() {
+            Log.e(TAG, "SimpleRecordController setup()");
+            if (mMediaRecorder == null) {
+                mMediaRecorder = new MediaRecorder();
+            }
+            mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
+            mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
+            mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
+            mFileName = Environment.getExternalStorageDirectory().toString() + "/music/" +
+                        mFileNameBase + "_" + ++mFileCount + ".amr";
+            mLastRecordedFile = mFileName;
+            Log.e(TAG, "recording to file: "+mLastRecordedFile);
+            mMediaRecorder.setOutputFile(mFileName);
+            try {
+                mMediaRecorder.prepare();
+            }
+            catch (Exception e) {
+                Log.e(TAG, "Could not prepare MediaRecorder: " + e.toString());
+                mMediaRecorder.release();
+                mMediaRecorder = null;
+            }
+        }
+        
+        @Override
+        public void stop() {
+            if (mMediaRecorder != null) {
+                mMediaRecorder.stop();
+                mMediaRecorder.release();
+                mMediaRecorder = null;
+            }
+            updatePlayPauseButton();
+        }
+
+        @Override
+        public boolean isPlaying() {
+            if (mState == 1) {
+                return true;
+            } else {
+                return false;                
+            }
+        }
+    }
+    
+    class TtsInitListener implements TextToSpeech.OnInitListener {
+        @Override
+        public void onInit(int status) {
+            // status can be either TextToSpeech.SUCCESS or TextToSpeech.ERROR.
+            Log.e(TAG, "onInit for tts");
+            if (status != TextToSpeech.SUCCESS) {
+                // Initialization failed.
+                Log.e(TAG, "Could not initialize TextToSpeech.");
+                return;
+            }
+
+            if (mTts == null) {
+                Log.e(TAG, "null tts");
+                return;
+            }
+
+            int result = mTts.setLanguage(Locale.US);
+            if (result == TextToSpeech.LANG_MISSING_DATA ||
+                result == TextToSpeech.LANG_NOT_SUPPORTED) {
+               // Lanuage data is missing or the language is not supported.
+                Log.e(TAG, "Language is not available.");
+                return;
+            }
+            mTts.setOnUtteranceCompletedListener(new MyUtteranceCompletedListener(UTTERANCE));
+            mTtsInited = true;
+         }
+    }
+
+    class MyUtteranceCompletedListener implements OnUtteranceCompletedListener {
+        private final String mExpectedUtterance;
+        
+        public MyUtteranceCompletedListener(String expectedUtteranceId) {
+            mExpectedUtterance = expectedUtteranceId;
+        }
+        
+        @Override
+        public void onUtteranceCompleted(String utteranceId) {
+            Log.e(TAG, "onUtteranceCompleted " + utteranceId);
+            if (mTtsToFile) {
+                if (mSampleFile != null && mSampleFile.exists()) {
+                    MediaPlayer mediaPlayer = new MediaPlayer();
+                    try {
+                        mediaPlayer.setDataSource(mSampleFile.getPath());
+                        mediaPlayer.setAudioStreamType(AudioManager.STREAM_BLUETOOTH_SCO);
+                        mediaPlayer.prepare();
+                    } catch (Exception ex) {
+                        Log.e(TAG, "mMediaPlayercreate failed:", ex);
+                        mediaPlayer.release();
+                        mediaPlayer = null;
+                    }
+    
+                    if (mediaPlayer != null) {
+                        mediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
+                            @Override
+                            public void onCompletion(MediaPlayer mp) {
+                                mp.release();
+                                if (mSampleFile != null && mSampleFile.exists()) {
+                                    mSampleFile.delete();
+                                    mSampleFile = null;
+                                }
+                              mAudioManager.setStreamVolume(AudioManager.STREAM_BLUETOOTH_SCO,
+                              mOriginalVoiceVolume, 0);
+//                              Debug.stopMethodTracing();
+                            }
+                        });
+                        mediaPlayer.start();
+                    }
+                } else {
+                    Log.e(TAG, "synthesizeToFile did not create file");
+                }
+            } else {
+                mAudioManager.setStreamVolume(AudioManager.STREAM_BLUETOOTH_SCO,
+                        mOriginalVoiceVolume, 0);
+//                Debug.stopMethodTracing();
+            }
+            
+            Log.e(TAG, "end speak, volume: "+mOriginalVoiceVolume);
+        }
+    }
+
+    
+    private View.OnKeyListener mSpeakKeyListener
+    = new View.OnKeyListener() {
+        @Override
+        public boolean onKey(View v, int keyCode, KeyEvent event) {
+            if (event.getAction() == KeyEvent.ACTION_DOWN) {
+                switch (keyCode) {
+                    case KeyEvent.KEYCODE_DPAD_CENTER:
+                    case KeyEvent.KEYCODE_ENTER:
+                        if (!mTtsInited) {
+                            Log.e(TAG, "Tts not inited ");
+                            return false;
+                        }
+                        mOriginalVoiceVolume = mAudioManager.getStreamVolume(
+                                AudioManager.STREAM_BLUETOOTH_SCO);
+                        Log.e(TAG, "start speak, volume: "+mOriginalVoiceVolume);
+                        mAudioManager.setStreamVolume(AudioManager.STREAM_BLUETOOTH_SCO,
+                                mOriginalVoiceVolume/2, 0);
+
+                        // we now have SCO connection and TTS, so we can start.
+                        mHandler.post(new Runnable() {
+                            @Override
+                            public void run() {
+//                                Debug.startMethodTracing("tts");
+
+                                if (mTtsToFile) {
+                                    if (mSampleFile != null && mSampleFile.exists()) {
+                                        mSampleFile.delete();
+                                        mSampleFile = null;
+                                    }
+                                    mSampleFile = new File(Environment.getExternalStorageDirectory(), "mytts.wav");
+                                    mTts.synthesizeToFile(mSpeakText.getText().toString(), mTtsParams, mSampleFile.getPath());
+                                } else {
+                                    mTts.speak(mSpeakText.getText().toString(),
+                                        TextToSpeech.QUEUE_FLUSH,
+                                        mTtsParams);
+                                }
+                            }
+                        });
+                        return true;
+                }
+            }
+            return false;
+        }
+    };
+    
+    private static final String[] mModeStrings = {
+        "NORMAL", "RINGTONE", "IN_CALL", "IN_COMMUNICATION"
+    };
+    
+    private Spinner.OnItemSelectedListener mModeChanged
+        = new Spinner.OnItemSelectedListener() {
+        @Override
+        public void onItemSelected(android.widget.AdapterView av, View v,
+                    int position, long id) {
+            if (mCurrentMode != position) {
+                mCurrentMode = position;
+                mAudioManager.setMode(mCurrentMode);
+            }
+        }
+        
+        @Override
+        public void onNothingSelected(android.widget.AdapterView av) {
+        }
+    };
+
+    private BluetoothProfile.ServiceListener mBluetoothProfileServiceListener =
+        new BluetoothProfile.ServiceListener() {
+        @Override
+        public void onServiceConnected(int profile, BluetoothProfile proxy) {
+            mBluetoothHeadset = (BluetoothHeadset) proxy;
+            List<BluetoothDevice> deviceList = mBluetoothHeadset.getConnectedDevices();
+            if (deviceList.size() > 0) {
+                mBluetoothHeadsetDevice = deviceList.get(0);
+            } else {
+                mBluetoothHeadsetDevice = null;
+            }
+        }
+        @Override
+        public void onServiceDisconnected(int profile) {
+            if (mBluetoothHeadset != null) {
+                List<BluetoothDevice> devices = mBluetoothHeadset.getConnectedDevices();
+                if (devices.size() == 0) {
+                    mBluetoothHeadsetDevice = null;
+                }
+                mBluetoothHeadset = null;
+            }
+        }
+    };
+
+    private int mChangedState = -1;
+    private int mUpdatedState = -1;
+    private int mUpdatedPrevState = -1;
+    
+    private class ScoBroadcastReceiver extends BroadcastReceiver {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            String action = intent.getAction();
+
+            if (action.equals(BluetoothHeadset.ACTION_AUDIO_STATE_CHANGED)) {
+                int state = intent.getIntExtra(BluetoothProfile.EXTRA_STATE, -1);
+                mVdStateTxt.setText(Integer.toString(state));
+                Log.e(TAG, "BluetoothHeadset.ACTION_AUDIO_STATE_CHANGED: "+state);
+            } else if (action.equals(AudioManager.ACTION_SCO_AUDIO_STATE_CHANGED)) {
+                mChangedState = intent.getIntExtra(AudioManager.EXTRA_SCO_AUDIO_STATE, -1);
+                Log.e(TAG, "ACTION_SCO_AUDIO_STATE_CHANGED: "+mChangedState);
+                mScoStateTxt.setText("changed: "+Integer.toString(mChangedState)+ 
+                        " updated: "+Integer.toString(mUpdatedState)+
+                        " prev updated: "+Integer.toString(mUpdatedPrevState));
+            } else if (action.equals(AudioManager.ACTION_SCO_AUDIO_STATE_UPDATED)) {
+                mUpdatedState = intent.getIntExtra(AudioManager.EXTRA_SCO_AUDIO_STATE, -1);
+                mUpdatedPrevState = intent.getIntExtra(AudioManager.EXTRA_SCO_AUDIO_PREVIOUS_STATE, -1);
+                Log.e(TAG, "ACTION_SCO_AUDIO_STATE_UPDATED, state: "+mUpdatedState+" prev state: "+mUpdatedPrevState);
+                mScoStateTxt.setText("changed: "+Integer.toString(mChangedState)+ 
+                        " updated: "+Integer.toString(mUpdatedState)+
+                        " prev updated: "+Integer.toString(mUpdatedPrevState));
+                if (mForceScoOn && mUpdatedState == AudioManager.SCO_AUDIO_STATE_DISCONNECTED) {
+                    mForceScoOn = false;
+                    mScoButton.setChecked(mForceScoOn);
+                    mAudioManager.stopBluetoothSco();
+                }
+            }
+        }
+    }
+
+}
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/notify_panel_bg.9.png b/packages/SystemUI/res/drawable-hdpi/notify_panel_bg.9.png
deleted file mode 100644
index d5503f7..0000000
--- a/packages/SystemUI/res/drawable-hdpi/notify_panel_bg.9.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/notify_panel_bg_protect.png b/packages/SystemUI/res/drawable-hdpi/notify_panel_bg_protect.png
deleted file mode 100644
index a8f2236..0000000
--- a/packages/SystemUI/res/drawable-hdpi/notify_panel_bg_protect.png
+++ /dev/null
Binary files differ
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/notify_panel_bg.9.png b/packages/SystemUI/res/drawable-mdpi/notify_panel_bg.9.png
deleted file mode 100644
index 8725e58..0000000
--- a/packages/SystemUI/res/drawable-mdpi/notify_panel_bg.9.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/notify_panel_bg_protect.png b/packages/SystemUI/res/drawable-mdpi/notify_panel_bg_protect.png
deleted file mode 100644
index f7225ed..0000000
--- a/packages/SystemUI/res/drawable-mdpi/notify_panel_bg_protect.png
+++ /dev/null
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-nodpi/notify_panel_bg.png b/packages/SystemUI/res/drawable-nodpi/notify_panel_bg.png
deleted file mode 100644
index 1ea924f..0000000
--- a/packages/SystemUI/res/drawable-nodpi/notify_panel_bg.png
+++ /dev/null
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/notify_panel_bg_protect_tiled.xml b/packages/SystemUI/res/drawable/status_bar_bg.xml
similarity index 93%
rename from packages/SystemUI/res/drawable/notify_panel_bg_protect_tiled.xml
rename to packages/SystemUI/res/drawable/status_bar_bg.xml
index 0371322..403493b 100644
--- a/packages/SystemUI/res/drawable/notify_panel_bg_protect_tiled.xml
+++ b/packages/SystemUI/res/drawable/status_bar_bg.xml
@@ -16,7 +16,6 @@
 
 <bitmap
     xmlns:android="http://schemas.android.com/apk/res/android"
-    android:src="@drawable/notify_panel_bg_protect"
     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..b63afbe 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,21 +56,46 @@
             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" 
         android:layout_height="wrap_content"
         android:layout_weight="1"
         >
+        <TextView android:id="@+id/noNotificationsTitle"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:textAppearance="@android:style/TextAppearance.Large"
+            android:padding="8dp"
+            android:layout_gravity="top"
+            android:gravity="center"
+            android:text="@string/status_bar_no_notifications_title"
+            />
+
         <ScrollView
             android:id="@+id/scroll"
             android:layout_width="match_parent"
@@ -69,29 +103,12 @@
             android:fadingEdge="none"
             android:overScrollMode="ifContentScrolls"
             >
-            <LinearLayout
-                android:id="@+id/notificationLinearLayout"
+            <com.android.systemui.statusbar.policy.NotificationRowLayout
+                android:id="@+id/latestItems"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
-                android:orientation="vertical"
-                >
-                
-                <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:text="@string/status_bar_no_notifications_title"
-                    />
-
-                <com.android.systemui.statusbar.policy.NotificationRowLayout
-                    android:id="@+id/latestItems"
-                    android:layout_width="match_parent"
-                    android:layout_height="wrap_content"
-                    systemui:rowHeight="@dimen/notification_height"
-                    />
-            </LinearLayout>
+                systemui:rowHeight="@dimen/notification_height"
+                />
         </ScrollView>
 
         <ImageView
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/res/values-land/dimens.xml b/packages/SystemUI/res/values-land/dimens.xml
index 0219a77..3919685 100644
--- a/packages/SystemUI/res/values-land/dimens.xml
+++ b/packages/SystemUI/res/values-land/dimens.xml
@@ -17,7 +17,7 @@
 -->
 <resources>
     <!-- thickness (width) of the navigation bar on phones that require it -->
-    <dimen name="navigation_bar_size">42dp</dimen>
+    <dimen name="navigation_bar_size">@*android:dimen/navigation_bar_width</dimen>
 
     <!-- Recent Applications parameters -->
     <!-- Width of a recent app view, including all content -->
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml
index ba1aea3..ef9b8dd 100644
--- a/packages/SystemUI/res/values/dimens.xml
+++ b/packages/SystemUI/res/values/dimens.xml
@@ -40,7 +40,7 @@
     <dimen name="peek_window_y_offset">-12dp</dimen>
 
     <!-- thickness (height) of the navigation bar on phones that require it -->
-    <dimen name="navigation_bar_size">48dp</dimen>
+    <dimen name="navigation_bar_size">@*android:dimen/navigation_bar_height</dimen>
 
     <!-- thickness (height) of the dead zone at the top of the navigation bar,
          reducing false presses on navbar buttons; approx 2mm -->
diff --git a/packages/SystemUI/src/com/android/systemui/SwipeHelper.java b/packages/SystemUI/src/com/android/systemui/SwipeHelper.java
index 6ecfd94..2818f87 100644
--- a/packages/SystemUI/src/com/android/systemui/SwipeHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/SwipeHelper.java
@@ -43,6 +43,7 @@
 
     private float SWIPE_ESCAPE_VELOCITY = 100f; // dp/sec
     private int MAX_ESCAPE_ANIMATION_DURATION = 500; // ms
+    private int MAX_DISMISS_VELOCITY = 1000; // dp/sec
     private static final int SNAP_ANIM_LEN = SLOW_ANIMATIONS ? 1000 : 250; // ms
 
     public static float ALPHA_FADE_START = 0.8f; // fraction of thumbnail width
@@ -281,7 +282,7 @@
             case MotionEvent.ACTION_UP:
             case MotionEvent.ACTION_CANCEL:
                 if (mCurrView != null) {
-                    float maxVelocity = 1000; // px/sec
+                    float maxVelocity = MAX_DISMISS_VELOCITY * mDensityScale;
                     mVelocityTracker.computeCurrentVelocity(1000 /* px/sec */, maxVelocity);
                     float escapeVelocity = SWIPE_ESCAPE_VELOCITY * mDensityScale;
                     float velocity = getVelocity(mVelocityTracker);
diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentsHorizontalScrollView.java b/packages/SystemUI/src/com/android/systemui/recent/RecentsHorizontalScrollView.java
index 14efdd0..36f1659 100644
--- a/packages/SystemUI/src/com/android/systemui/recent/RecentsHorizontalScrollView.java
+++ b/packages/SystemUI/src/com/android/systemui/recent/RecentsHorizontalScrollView.java
@@ -165,6 +165,13 @@
     @Override
     protected void onSizeChanged(int w, int h, int oldw, int oldh) {
         super.onSizeChanged(w, h, oldw, oldh);
+
+        // Skip this work if a transition is running; it sets the scroll values independently
+        // and should not have those animated values clobbered by this logic
+        LayoutTransition transition = mLinearLayout.getLayoutTransition();
+        if (transition != null && transition.isRunning()) {
+            return;
+        }
         // Keep track of the last visible item in the list so we can restore it
         // to the bottom when the orientation changes.
         mLastScrollPosition = scrollPositionOfMostRecent();
@@ -172,7 +179,12 @@
         // This has to happen post-layout, so run it "in the future"
         post(new Runnable() {
             public void run() {
-                scrollTo(mLastScrollPosition, 0);
+                // Make sure we're still not clobbering the transition-set values, since this
+                // runnable launches asynchronously
+                LayoutTransition transition = mLinearLayout.getLayoutTransition();
+                if (transition == null || !transition.isRunning()) {
+                    scrollTo(mLastScrollPosition, 0);
+                }
             }
         });
     }
diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentsVerticalScrollView.java b/packages/SystemUI/src/com/android/systemui/recent/RecentsVerticalScrollView.java
index 1bcc413..89900a1 100644
--- a/packages/SystemUI/src/com/android/systemui/recent/RecentsVerticalScrollView.java
+++ b/packages/SystemUI/src/com/android/systemui/recent/RecentsVerticalScrollView.java
@@ -166,6 +166,13 @@
     @Override
     protected void onSizeChanged(int w, int h, int oldw, int oldh) {
         super.onSizeChanged(w, h, oldw, oldh);
+
+        // Skip this work if a transition is running; it sets the scroll values independently
+        // and should not have those animated values clobbered by this logic
+        LayoutTransition transition = mLinearLayout.getLayoutTransition();
+        if (transition != null && transition.isRunning()) {
+            return;
+        }
         // Keep track of the last visible item in the list so we can restore it
         // to the bottom when the orientation changes.
         mLastScrollPosition = scrollPositionOfMostRecent();
@@ -173,7 +180,12 @@
         // This has to happen post-layout, so run it "in the future"
         post(new Runnable() {
             public void run() {
-                scrollTo(0, mLastScrollPosition);
+                // Make sure we're still not clobbering the transition-set values, since this
+                // runnable launches asynchronously
+                LayoutTransition transition = mLinearLayout.getLayoutTransition();
+                if (transition == null || !transition.isRunning()) {
+                    scrollTo(0, mLastScrollPosition);
+                }
             }
         });
     }
diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java
index fc21929..86dc9a6 100644
--- a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java
+++ b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java
@@ -91,7 +91,7 @@
 
         try {
             long currentTime = System.currentTimeMillis();
-            String date = new SimpleDateFormat("yyyy-MM-dd-kk-mm-ss").format(new Date(currentTime));
+            String date = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(new Date(currentTime));
             String imageDir = Environment.getExternalStoragePublicDirectory(
                     Environment.DIRECTORY_PICTURES).getAbsolutePath();
             String imageFileName = String.format(SCREENSHOT_FILE_NAME_TEMPLATE, date);
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/NavigationBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
index 2740898..abf505c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
@@ -112,7 +112,7 @@
             public void onAnimationEnd(Animator _a) {
                 mLastAnimator = null;
                 if (hide) {
-                    setVisibility(View.INVISIBLE);
+                    setVisibility(View.GONE);
                 }
             }
         });
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..a54c5c2 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -16,6 +16,7 @@
 
 package com.android.systemui.statusbar.phone;
 
+import android.animation.ObjectAnimator;
 import android.app.ActivityManagerNative;
 import android.app.Dialog;
 import android.app.Notification;
@@ -40,7 +41,9 @@
 import android.os.Message;
 import android.os.ServiceManager;
 import android.os.SystemClock;
+import android.provider.Settings;
 import android.text.TextUtils;
+import android.util.DisplayMetrics;
 import android.util.Slog;
 import android.util.Log;
 import android.view.Display;
@@ -84,8 +87,8 @@
 
 public class PhoneStatusBar extends StatusBar {
     static final String TAG = "PhoneStatusBar";
-    static final boolean SPEW = false;
     public static final boolean DEBUG = false;
+    public static final boolean SPEW = false;
 
     // additional instrumentation for testing purposes; intended to be left on during development
     public static final boolean CHATTY = DEBUG || true;
@@ -135,11 +138,12 @@
     ExpandedView mExpandedView;
     WindowManager.LayoutParams mExpandedParams;
     ScrollView mScrollView;
-    View mNotificationLinearLayout;
     View mExpandedContents;
     // top bar
     TextView mNoNotificationsTitle;
     View mClearButton;
+    View mSettingsButton;
+
     // drag bar
     CloseDragHandle mCloseView;
     
@@ -198,11 +202,11 @@
     // tracking calls to View.setSystemUiVisibility()
     int mSystemUiVisibility = View.SYSTEM_UI_FLAG_VISIBLE;
 
-    final Point mDisplaySize = new Point();
+    DisplayMetrics mDisplayMetrics = new DisplayMetrics();
 
     private class ExpandedDialog extends Dialog {
         ExpandedDialog(Context context) {
-            super(context, com.android.internal.R.style.Theme_Light_NoTitleBar);
+            super(context, com.android.internal.R.style.Theme_Translucent_NoTitleBar);
         }
 
         @Override
@@ -245,13 +249,21 @@
 
         Resources res = context.getResources();
 
-        mDisplay.getSize(mDisplaySize);
+        mDisplay.getMetrics(mDisplayMetrics);
+        if (DEBUG) {
+            Slog.d(TAG, "makeStatusBarView: mDisplayMetrics=" + mDisplayMetrics);
+            mDisplayMetrics = res.getDisplayMetrics();
+            Slog.d(TAG, "makeStatusBarView: mDisplayMetrics2=" + mDisplayMetrics);
+        }
         loadDimens();
 
         mIconSize = res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_icon_size);
 
         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,17 +308,21 @@
         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;
-        mExpandedContents = expanded.findViewById(R.id.notificationLinearLayout);
         mPile = (ViewGroup)expanded.findViewById(R.id.latestItems);
+        mExpandedContents = mPile; // was: expanded.findViewById(R.id.notificationLinearLayout);
         mNoNotificationsTitle = (TextView)expanded.findViewById(R.id.noNotificationsTitle);
+        mNoNotificationsTitle.setAlpha(0f);
+        mNoNotificationsTitle.setVisibility(View.VISIBLE);
         mClearButton = expanded.findViewById(R.id.clear_all_button);
         mClearButton.setOnClickListener(mClearButtonListener);
+        mClearButton.setAlpha(0f);
+        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);
 
         mTicker = new MyTicker(context, sb);
 
@@ -322,7 +338,6 @@
 
         // set the inital view visibility
         setAreThereNotifications();
-        mDateView.setVisibility(View.INVISIBLE);
 
         // Other icons
         mLocationController = new LocationController(mContext); // will post a notification
@@ -542,7 +557,9 @@
         boolean immersive = false;
         try {
             immersive = ActivityManagerNative.getDefault().isTopActivityImmersive();
-            Slog.d(TAG, "Top activity is " + (immersive?"immersive":"not immersive"));
+            if (DEBUG) {
+                Slog.d(TAG, "Top activity is " + (immersive?"immersive":"not immersive"));
+            }
         } catch (RemoteException ex) {
         }
         if (immersive) {
@@ -572,8 +589,7 @@
             }
         } else if (notification.notification.fullScreenIntent != null) {
             // not immersive & a full-screen alert should be shown
-            Slog.d(TAG, "Notification has fullScreenIntent and activity is not immersive;"
-                    + " sending fullScreenIntent");
+            Slog.d(TAG, "Notification has fullScreenIntent; sending fullScreenIntent");
             try {
                 notification.notification.fullScreenIntent.send();
             } catch (PendingIntent.CanceledException e) {
@@ -694,9 +710,10 @@
             mTicker.removeEntry(old);
 
             // Recalculate the position of the sliding windows and the titles.
-            setAreThereNotifications();
             updateExpandedViewPos(EXPANDED_LEAVE_ALONE);
         }
+
+        setAreThereNotifications();
     }
 
     @Override
@@ -1001,13 +1018,37 @@
     }
 
     private void setAreThereNotifications() {
-        mClearButton.setVisibility(mNotificationData.hasClearableItems() 
-                ? View.VISIBLE 
-                : View.INVISIBLE);
+        final boolean any = mNotificationData.size() > 0;
 
-        mNoNotificationsTitle.setVisibility(mNotificationData.size() > 0
-                ? View.GONE
-                : View.VISIBLE);
+        final boolean clearable = any && mNotificationData.hasClearableItems();
+
+        if (DEBUG) {
+            Slog.d(TAG, "setAreThereNotifications: N=" + mNotificationData.size()
+                    + " any=" + any + " clearable=" + clearable);
+        }
+
+        if (mClearButton.isShown()) {
+            if (clearable != (mClearButton.getAlpha() == 1.0f)) {
+                ObjectAnimator.ofFloat(mClearButton, "alpha",
+                        clearable ? 1.0f : 0.0f)
+                    .setDuration(250)
+                    .start();
+            }
+        } else {
+            mClearButton.setAlpha(clearable ? 1.0f : 0.0f);
+        }
+
+        if (mNoNotificationsTitle.isShown()) {
+            if (any != (mNoNotificationsTitle.getAlpha() == 0.0f)) {
+                ObjectAnimator a = ObjectAnimator.ofFloat(mNoNotificationsTitle, "alpha",
+                            (any ? 0.0f : 0.75f));
+                a.setDuration(any ? 0 : 500);
+                a.setStartDelay(any ? 250 : 1000);
+                a.start();
+            }
+        } else {
+            mNoNotificationsTitle.setAlpha(any ? 0.0f : 0.75f);
+        }
     }
 
 
@@ -1103,13 +1144,12 @@
         updateExpandedViewPos(EXPANDED_LEAVE_ALONE);
         mExpandedParams.flags &= ~WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
         mExpandedParams.flags |= WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
+        if (DEBUG) {
+            Slog.d(TAG, "makeExpandedVisible: expanded params = " + mExpandedParams);
+        }
         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() {
@@ -1152,7 +1192,7 @@
         if (mAnimating) {
             y = (int)mAnimY;
         } else {
-            y = mDisplaySize.y-1;
+            y = mDisplayMetrics.heightPixels-1;
         }
         // Let the fling think that we're open so it goes in the right direction
         // and doesn't try to re-open the windowshade.
@@ -1194,7 +1234,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;
@@ -1208,7 +1247,7 @@
             if (SPEW) Slog.d(TAG, "doAnimation before mAnimY=" + mAnimY);
             incrementAnim();
             if (SPEW) Slog.d(TAG, "doAnimation after  mAnimY=" + mAnimY);
-            if (mAnimY >= mDisplaySize.y-1) {
+            if (mAnimY >= mDisplayMetrics.heightPixels-1) {
                 if (SPEW) Slog.d(TAG, "Animation completed to expanded state.");
                 mAnimating = false;
                 updateExpandedViewPos(EXPANDED_FULL_OPEN);
@@ -1268,6 +1307,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) {
@@ -1311,7 +1354,7 @@
         if (mExpanded) {
             if (!always && (
                     vel > 200.0f
-                    || (y > (mDisplaySize.y-25) && vel > -200.0f))) {
+                    || (y > (mDisplayMetrics.heightPixels-25) && vel > -200.0f))) {
                 // We are expanded, but they didn't move sufficiently to cause
                 // us to retract.  Animate back to the expanded position.
                 mAnimAccel = 2000.0f;
@@ -1329,7 +1372,7 @@
         } else {
             if (always || (
                     vel > 200.0f
-                    || (y > (mDisplaySize.y/2) && vel > -200.0f))) {
+                    || (y > (mDisplayMetrics.heightPixels/2) && vel > -200.0f))) {
                 // We are collapsed, and they moved enough to allow us to
                 // expand.  Animate in the notifications.
                 mAnimAccel = 2000.0f;
@@ -1387,14 +1430,14 @@
                 mViewDelta = mAbsPos[1] + mTrackingView.getHeight() - y;
             }
             if ((!mExpanded && y < hitSize) ||
-                    (mExpanded && y > (mDisplaySize.y-hitSize))) {
+                    (mExpanded && y > (mDisplayMetrics.heightPixels-hitSize))) {
 
                 // We drop events at the edge of the screen to make the windowshade come
                 // down by accident less, especially when pushing open a device with a keyboard
                 // that rotates (like g1 and droid)
                 int x = (int)event.getRawX();
                 final int edgeBorder = mEdgeBorder;
-                if (x >= edgeBorder && x < mDisplaySize.x - edgeBorder) {
+                if (x >= edgeBorder && x < mDisplayMetrics.widthPixels - edgeBorder) {
                     prepareTracking(y, !mExpanded);// opening if we're not already fully visible
                     mVelocityTracker.addMovement(event);
                 }
@@ -1578,9 +1621,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 +1630,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 +1638,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);
-            }
         }
     }
 
@@ -1644,7 +1678,7 @@
                     + " mAnimLastTime=" + mAnimLastTime);
             pw.println("  mAnimatingReveal=" + mAnimatingReveal
                     + " mViewDelta=" + mViewDelta);
-            pw.println("  mDisplaySize=" + mDisplaySize);
+            pw.println("  mDisplayMetrics=" + mDisplayMetrics);
             pw.println("  mExpandedParams: " + mExpandedParams);
             pw.println("  mExpandedView: " + viewInfo(mExpandedView));
             pw.println("  mExpandedDialog: " + mExpandedDialog);
@@ -1656,7 +1690,6 @@
             pw.println("  mTickerView: " + viewInfo(mTickerView));
             pw.println("  mScrollView: " + viewInfo(mScrollView)
                     + " scroll " + mScrollView.getScrollX() + "," + mScrollView.getScrollY());
-            pw.println("mNotificationLinearLayout: " + viewInfo(mNotificationLinearLayout));
         }
         /*
         synchronized (mNotificationData) {
@@ -1720,7 +1753,8 @@
                 ViewGroup.LayoutParams.MATCH_PARENT,
                 ViewGroup.LayoutParams.MATCH_PARENT,
                 WindowManager.LayoutParams.TYPE_STATUS_BAR_SUB_PANEL,
-                WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
+                0
+                | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
                 | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
                 | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM,
                 pixelFormat);
@@ -1742,9 +1776,10 @@
 
         lp = mExpandedDialog.getWindow().getAttributes();
         lp.x = 0;
-        mTrackingPosition = lp.y = mDisplaySize.y; // sufficiently large negative
+        mTrackingPosition = lp.y = mDisplayMetrics.heightPixels; // sufficiently large negative
         lp.type = WindowManager.LayoutParams.TYPE_STATUS_BAR_SUB_PANEL;
-        lp.flags = WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
+        lp.flags = 0
+                | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
                 | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
                 | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
                 | WindowManager.LayoutParams.FLAG_DITHER
@@ -1764,11 +1799,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;
@@ -1780,14 +1810,14 @@
 
     void updateExpandedInvisiblePosition() {
         if (mTrackingView != null) {
-            mTrackingPosition = -mDisplaySize.y;
+            mTrackingPosition = -mDisplayMetrics.heightPixels;
             if (mTrackingParams != null) {
                 mTrackingParams.y = mTrackingPosition;
                 WindowManagerImpl.getDefault().updateViewLayout(mTrackingView, mTrackingParams);
             }
         }
         if (mExpandedParams != null) {
-            mExpandedParams.y = -mDisplaySize.y;
+            mExpandedParams.y = -mDisplayMetrics.heightPixels;
             mExpandedDialog.getWindow().setAttributes(mExpandedParams);
         }
     }
@@ -1795,12 +1825,12 @@
     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);
         }
 
         int h = mStatusBarView.getHeight();
-        int disph = mDisplaySize.y;
+        int disph = mDisplayMetrics.heightPixels;
 
         // If the expanded view is not visible, make sure they're still off screen.
         // Maybe the view was resized.
@@ -1839,11 +1869,21 @@
 
                 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
                 // it to be visible to do a layout.
-                mExpandedParams.y = -mDisplaySize.y;
+                mExpandedParams.y = -mDisplayMetrics.heightPixels;
             }
             int max = h;
             if (mExpandedParams.y > max) {
@@ -1881,23 +1921,37 @@
     }
 
     int getExpandedHeight(int disph) {
+        if (DEBUG) {
+            Slog.d(TAG, "getExpandedHeight(" + disph + "): sbView="
+                    + mStatusBarView.getHeight() + " closeView=" + mCloseView.getHeight());
+        }
         return disph - mStatusBarView.getHeight() - mCloseView.getHeight();
     }
 
     void updateDisplaySize() {
-        mDisplay.getSize(mDisplaySize);
+        mDisplay.getMetrics(mDisplayMetrics);
+        if (DEBUG) {
+            Slog.d(TAG, "updateDisplaySize: " + mDisplayMetrics);
+        }
         updateExpandedSize();
     }
 
     void updateExpandedSize() {
-        if (mExpandedDialog != null && mExpandedParams != null && mDisplaySize != null) {
-            mExpandedParams.width = mDisplaySize.x;
-            mExpandedParams.height = getExpandedHeight(mDisplaySize.y);
+        if (DEBUG) {
+            Slog.d(TAG, "updateExpandedSize()");
+        }
+        if (mExpandedDialog != null && mExpandedParams != null && mDisplayMetrics != null) {
+            mExpandedParams.width = mDisplayMetrics.widthPixels;
+            mExpandedParams.height = getExpandedHeight(mDisplayMetrics.heightPixels);
             if (!mExpandedVisible) {
                 updateExpandedInvisiblePosition();
             } else {
                 mExpandedDialog.getWindow().setAttributes(mExpandedParams);
             }
+            if (DEBUG) {
+                Slog.d(TAG, "updateExpandedSize: height=" + mExpandedParams.height + " " + 
+                    (mExpandedVisible ? "VISIBLE":"INVISIBLE"));
+            }
         }
     }
 
@@ -1979,6 +2033,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/packages/SystemUI/src/com/android/systemui/statusbar/phone/TrackingView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/TrackingView.java
index fc0f332..cc23afc 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/TrackingView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/TrackingView.java
@@ -26,7 +26,6 @@
 
 
 public class TrackingView extends LinearLayout {
-    final Display mDisplay;
     PhoneStatusBar mService;
     boolean mTracking;
     int mStartX, mStartY;
@@ -34,8 +33,6 @@
 
     public TrackingView(Context context, AttributeSet attrs) {
         super(context, attrs);
-        mDisplay = ((WindowManager)context.getSystemService(
-                Context.WINDOW_SERVICE)).getDefaultDisplay();
     }
     
     @Override
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NotificationRowLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NotificationRowLayout.java
index 2a0dfb5..469b462 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NotificationRowLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NotificationRowLayout.java
@@ -166,20 +166,16 @@
             mAppearingViews.add(child);
 
             child.setPivotY(0);
-            AnimatorSet a = new AnimatorSet();
-            a.playTogether(
-                    ObjectAnimator.ofFloat(child, "alpha", 0f, 1f)
-//                    ,ObjectAnimator.ofFloat(child, "scaleY", 0f, 1f)
-            );
-            a.setDuration(APPEAR_ANIM_LEN);
-            a.addListener(new AnimatorListenerAdapter() {
+            final ObjectAnimator alphaFade = ObjectAnimator.ofFloat(child, "alpha", 0f, 1f);
+            alphaFade.setDuration(APPEAR_ANIM_LEN);
+            alphaFade.addListener(new AnimatorListenerAdapter() {
                 @Override
                 public void onAnimationEnd(Animator animation) {
                     mAppearingViews.remove(childF);
                     requestLayout(); // pick up any final changes in position
                 }
             });
-            a.start();
+            alphaFade.start();
             requestLayout(); // start the container animation
         }
     }
@@ -195,23 +191,10 @@
 
             child.setPivotY(0);
 
-            //final float velocity = (mSlidingChild == child)
-             //       ? Math.min(mLiftoffVelocity, SWIPE_ANIM_VELOCITY_MIN)
-            //        : SWIPE_ESCAPE_VELOCITY;
-            final float velocity = 0f;
-            final TimeAnimator zoom = new TimeAnimator();
-            zoom.setTimeListener(new TimeAnimator.TimeListener() {
-                @Override
-                public void onTimeUpdate(TimeAnimator animation, long totalTime, long deltaTime) {
-                    childF.setTranslationX(childF.getTranslationX() + deltaTime / 1000f * velocity);
-                }
-            });
-
             final ObjectAnimator alphaFade = ObjectAnimator.ofFloat(child, "alpha", 0f);
             alphaFade.addListener(new AnimatorListenerAdapter() {
                 @Override
                 public void onAnimationEnd(Animator animation) {
-                    zoom.cancel(); // it won't end on its own
                     if (DEBUG) Slog.d(TAG, "actually removing child: " + childF);
                     NotificationRowLayout.super.removeView(childF);
                     childF.setAlpha(1f);
@@ -220,14 +203,8 @@
                 }
             });
 
-            AnimatorSet a = new AnimatorSet();
-            a.playTogether(alphaFade, zoom);
-                    
-//                    ,ObjectAnimator.ofFloat(child, "scaleY", 0f)
-//                    ,ObjectAnimator.ofFloat(child, "translationX", child.getTranslationX() + 300f)
-
-            a.setDuration(DISAPPEAR_ANIM_LEN);
-            a.start();
+            alphaFade.setDuration(DISAPPEAR_ANIM_LEN);
+            alphaFade.start();
             requestLayout(); // start the container animation
         } else {
             super.removeView(child);
diff --git a/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java b/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java
index ee6d2ee..4abb9eb 100644
--- a/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java
+++ b/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java
@@ -143,6 +143,12 @@
      */
     private static final int KEYGUARD_DONE_DRAWING_TIMEOUT_MS = 2000;
 
+    /**
+     * Allow the user to operate the status bar when the keyguard is engaged (without a pattern or
+     * password).
+     */
+    private static final boolean ENABLE_STATUS_BAR_IN_KEYGUARD = true;
+
     private Context mContext;
     private AlarmManager mAlarmManager;
     private StatusBarManager mStatusBarManager;
@@ -1137,7 +1143,7 @@
             boolean enable = !mShowing || (mHidden && !isSecure());
             mStatusBarManager.disable(enable ?
                          StatusBarManager.DISABLE_NONE :
-                         ( StatusBarManager.DISABLE_EXPAND
+                         ( (ENABLE_STATUS_BAR_IN_KEYGUARD ? 0 : StatusBarManager.DISABLE_EXPAND)
                          | StatusBarManager.DISABLE_NAVIGATION
                          | StatusBarManager.DISABLE_CLOCK));
         }
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/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
index a2dbb78..ff8dc92 100755
--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -243,6 +243,8 @@
     int mStatusBarHeight;
     final ArrayList<WindowState> mStatusBarPanels = new ArrayList<WindowState>();
     WindowState mNavigationBar = null;
+    boolean mHasNavigationBar = false;
+    int mNavigationBarWidth = 0, mNavigationBarHeight = 0;
 
     WindowState mKeyguard = null;
     KeyguardViewMediator mKeyguardMediator;
@@ -796,6 +798,17 @@
                 mStatusBarCanHide
                 ? com.android.internal.R.dimen.status_bar_height
                 : com.android.internal.R.dimen.system_bar_height);
+
+        mHasNavigationBar = mContext.getResources().getBoolean(
+                com.android.internal.R.bool.config_showNavigationBar);
+        mNavigationBarHeight = mHasNavigationBar
+                ? mContext.getResources().getDimensionPixelSize(
+                    com.android.internal.R.dimen.navigation_bar_height)
+                : 0;
+        mNavigationBarWidth = mHasNavigationBar
+                ? mContext.getResources().getDimensionPixelSize(
+                    com.android.internal.R.dimen.navigation_bar_width)
+                : 0;
     }
 
     public void updateSettings() {
@@ -1110,19 +1123,26 @@
     }
 
     public int getNonDecorDisplayWidth(int rotation, int fullWidth) {
-        return fullWidth;
+        // Assumes that the navigation bar appears on the side of the display in landscape.
+        final boolean horizontal
+            = (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90);
+        return fullWidth - (horizontal ? mNavigationBarWidth : 0);
     }
 
     public int getNonDecorDisplayHeight(int rotation, int fullHeight) {
-        return mStatusBarCanHide ? fullHeight : (fullHeight - mStatusBarHeight);
+        final boolean horizontal
+            = (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90);
+        return fullHeight
+            - (mStatusBarCanHide ? 0 : mStatusBarHeight)
+            - (horizontal ? 0 : mNavigationBarHeight);
     }
 
     public int getConfigDisplayWidth(int rotation, int fullWidth) {
-        return fullWidth;
+        return getNonDecorDisplayWidth(rotation, fullWidth);
     }
 
     public int getConfigDisplayHeight(int rotation, int fullHeight) {
-        return fullHeight - mStatusBarHeight;
+        return getNonDecorDisplayHeight(rotation, fullHeight);
     }
 
     public boolean doesForceHide(WindowState win, WindowManager.LayoutParams attrs) {
@@ -1851,7 +1871,8 @@
         final Rect cf = mTmpContentFrame;
         final Rect vf = mTmpVisibleFrame;
         
-        final boolean hasNavBar = (mNavigationBar != null && mNavigationBar.isVisibleLw());
+        final boolean hasNavBar = (mHasNavigationBar 
+                && mNavigationBar != null && mNavigationBar.isVisibleLw());
 
         if (attrs.type == TYPE_INPUT_METHOD) {
             pf.left = df.left = cf.left = vf.left = mDockLeft;
@@ -1943,6 +1964,11 @@
                                           ? mRestrictedScreenTop+mRestrictedScreenHeight
                                           : mUnrestrictedScreenTop+mUnrestrictedScreenHeight;
 
+                    if (DEBUG_LAYOUT) {
+                        Log.v(TAG, String.format(
+                                    "Laying out IN_SCREEN status bar window: (%d,%d - %d,%d)",
+                                    pf.left, pf.top, pf.right, pf.bottom));
+                    }
                 } else if (attrs.type == TYPE_NAVIGATION_BAR) {
                     // The navigation bar has Real Ultimate Power.
                     pf.left = df.left = mUnrestrictedScreenLeft;
diff --git a/services/input/EventHub.cpp b/services/input/EventHub.cpp
index 7ea3de2..960e414 100644
--- a/services/input/EventHub.cpp
+++ b/services/input/EventHub.cpp
@@ -205,27 +205,30 @@
         RawAbsoluteAxisInfo* outAxisInfo) const {
     outAxisInfo->clear();
 
-    AutoMutex _l(mLock);
-    Device* device = getDeviceLocked(deviceId);
-    if (device == NULL) return -1;
+    if (axis >= 0 && axis <= ABS_MAX) {
+        AutoMutex _l(mLock);
 
-    struct input_absinfo info;
+        Device* device = getDeviceLocked(deviceId);
+        if (device && test_bit(axis, device->absBitmask)) {
+            struct input_absinfo info;
+            if(ioctl(device->fd, EVIOCGABS(axis), &info)) {
+                LOGW("Error reading absolute controller %d for device %s fd %d, errno=%d",
+                     axis, device->identifier.name.string(), device->fd, errno);
+                return -errno;
+            }
 
-    if(ioctl(device->fd, EVIOCGABS(axis), &info)) {
-        LOGW("Error reading absolute controller %d for device %s fd %d, errno=%d",
-             axis, device->identifier.name.string(), device->fd, errno);
-        return -errno;
+            if (info.minimum != info.maximum) {
+                outAxisInfo->valid = true;
+                outAxisInfo->minValue = info.minimum;
+                outAxisInfo->maxValue = info.maximum;
+                outAxisInfo->flat = info.flat;
+                outAxisInfo->fuzz = info.fuzz;
+                outAxisInfo->resolution = info.resolution;
+            }
+            return OK;
+        }
     }
-
-    if (info.minimum != info.maximum) {
-        outAxisInfo->valid = true;
-        outAxisInfo->minValue = info.minimum;
-        outAxisInfo->maxValue = info.maximum;
-        outAxisInfo->flat = info.flat;
-        outAxisInfo->fuzz = info.fuzz;
-        outAxisInfo->resolution = info.resolution;
-    }
-    return OK;
+    return -1;
 }
 
 bool EventHub::hasRelativeAxis(int32_t deviceId, int axis) const {
@@ -233,7 +236,7 @@
         AutoMutex _l(mLock);
 
         Device* device = getDeviceLocked(deviceId);
-        if (device && device->relBitmask) {
+        if (device) {
             return test_bit(axis, device->relBitmask);
         }
     }
@@ -245,7 +248,7 @@
         AutoMutex _l(mLock);
 
         Device* device = getDeviceLocked(deviceId);
-        if (device && device->propBitmask) {
+        if (device) {
             return test_bit(property, device->propBitmask);
         }
     }
@@ -257,58 +260,37 @@
         AutoMutex _l(mLock);
 
         Device* device = getDeviceLocked(deviceId);
-        if (device != NULL) {
-            return getScanCodeStateLocked(device, scanCode);
+        if (device && test_bit(scanCode, device->keyBitmask)) {
+            uint8_t keyState[sizeof_bit_array(KEY_MAX + 1)];
+            memset(keyState, 0, sizeof(keyState));
+            if (ioctl(device->fd, EVIOCGKEY(sizeof(keyState)), keyState) >= 0) {
+                return test_bit(scanCode, keyState) ? AKEY_STATE_DOWN : AKEY_STATE_UP;
+            }
         }
     }
     return AKEY_STATE_UNKNOWN;
 }
 
-int32_t EventHub::getScanCodeStateLocked(Device* device, int32_t scanCode) const {
-    uint8_t key_bitmask[sizeof_bit_array(KEY_MAX + 1)];
-    memset(key_bitmask, 0, sizeof(key_bitmask));
-    if (ioctl(device->fd,
-               EVIOCGKEY(sizeof(key_bitmask)), key_bitmask) >= 0) {
-        return test_bit(scanCode, key_bitmask) ? AKEY_STATE_DOWN : AKEY_STATE_UP;
-    }
-    return AKEY_STATE_UNKNOWN;
-}
-
 int32_t EventHub::getKeyCodeState(int32_t deviceId, int32_t keyCode) const {
     AutoMutex _l(mLock);
 
     Device* device = getDeviceLocked(deviceId);
-    if (device != NULL) {
-        return getKeyCodeStateLocked(device, keyCode);
-    }
-    return AKEY_STATE_UNKNOWN;
-}
-
-int32_t EventHub::getKeyCodeStateLocked(Device* device, int32_t keyCode) const {
-    if (!device->keyMap.haveKeyLayout()) {
-        return AKEY_STATE_UNKNOWN;
-    }
-
-    Vector<int32_t> scanCodes;
-    device->keyMap.keyLayoutMap->findScanCodesForKey(keyCode, &scanCodes);
-
-    uint8_t key_bitmask[sizeof_bit_array(KEY_MAX + 1)];
-    memset(key_bitmask, 0, sizeof(key_bitmask));
-    if (ioctl(device->fd, EVIOCGKEY(sizeof(key_bitmask)), key_bitmask) >= 0) {
-        #if 0
-        for (size_t i=0; i<=KEY_MAX; i++) {
-            LOGI("(Scan code %d: down=%d)", i, test_bit(i, key_bitmask));
-        }
-        #endif
-        const size_t N = scanCodes.size();
-        for (size_t i=0; i<N && i<=KEY_MAX; i++) {
-            int32_t sc = scanCodes.itemAt(i);
-            //LOGI("Code %d: down=%d", sc, test_bit(sc, key_bitmask));
-            if (sc >= 0 && sc <= KEY_MAX && test_bit(sc, key_bitmask)) {
-                return AKEY_STATE_DOWN;
+    if (device && device->keyMap.haveKeyLayout()) {
+        Vector<int32_t> scanCodes;
+        device->keyMap.keyLayoutMap->findScanCodesForKey(keyCode, &scanCodes);
+        if (scanCodes.size() != 0) {
+            uint8_t keyState[sizeof_bit_array(KEY_MAX + 1)];
+            memset(keyState, 0, sizeof(keyState));
+            if (ioctl(device->fd, EVIOCGKEY(sizeof(keyState)), keyState) >= 0) {
+                for (size_t i = 0; i < scanCodes.size(); i++) {
+                    int32_t sc = scanCodes.itemAt(i);
+                    if (sc >= 0 && sc <= KEY_MAX && test_bit(sc, keyState)) {
+                        return AKEY_STATE_DOWN;
+                    }
+                }
+                return AKEY_STATE_UP;
             }
         }
-        return AKEY_STATE_UP;
     }
     return AKEY_STATE_UNKNOWN;
 }
@@ -318,85 +300,64 @@
         AutoMutex _l(mLock);
 
         Device* device = getDeviceLocked(deviceId);
-        if (device != NULL) {
-            return getSwitchStateLocked(device, sw);
+        if (device && test_bit(sw, device->swBitmask)) {
+            uint8_t swState[sizeof_bit_array(SW_MAX + 1)];
+            memset(swState, 0, sizeof(swState));
+            if (ioctl(device->fd, EVIOCGSW(sizeof(swState)), swState) >= 0) {
+                return test_bit(sw, swState) ? AKEY_STATE_DOWN : AKEY_STATE_UP;
+            }
         }
     }
     return AKEY_STATE_UNKNOWN;
 }
 
-int32_t EventHub::getSwitchStateLocked(Device* device, int32_t sw) const {
-    uint8_t sw_bitmask[sizeof_bit_array(SW_MAX + 1)];
-    memset(sw_bitmask, 0, sizeof(sw_bitmask));
-    if (ioctl(device->fd,
-               EVIOCGSW(sizeof(sw_bitmask)), sw_bitmask) >= 0) {
-        return test_bit(sw, sw_bitmask) ? AKEY_STATE_DOWN : AKEY_STATE_UP;
-    }
-    return AKEY_STATE_UNKNOWN;
-}
-
 status_t EventHub::getAbsoluteAxisValue(int32_t deviceId, int32_t axis, int32_t* outValue) const {
     if (axis >= 0 && axis <= ABS_MAX) {
         AutoMutex _l(mLock);
 
         Device* device = getDeviceLocked(deviceId);
-        if (device != NULL) {
-            return getAbsoluteAxisValueLocked(device, axis, outValue);
+        if (device && test_bit(axis, device->absBitmask)) {
+            struct input_absinfo info;
+            if(ioctl(device->fd, EVIOCGABS(axis), &info)) {
+                LOGW("Error reading absolute controller %d for device %s fd %d, errno=%d",
+                     axis, device->identifier.name.string(), device->fd, errno);
+                return -errno;
+            }
+
+            *outValue = info.value;
+            return OK;
         }
     }
     *outValue = 0;
     return -1;
 }
 
-status_t EventHub::getAbsoluteAxisValueLocked(Device* device, int32_t axis,
-        int32_t* outValue) const {
-    struct input_absinfo info;
-
-     if(ioctl(device->fd, EVIOCGABS(axis), &info)) {
-         LOGW("Error reading absolute controller %d for device %s fd %d, errno=%d",
-              axis, device->identifier.name.string(), device->fd, errno);
-         return -errno;
-     }
-
-     *outValue = info.value;
-     return OK;
-}
-
 bool EventHub::markSupportedKeyCodes(int32_t deviceId, size_t numCodes,
         const int32_t* keyCodes, uint8_t* outFlags) const {
     AutoMutex _l(mLock);
 
     Device* device = getDeviceLocked(deviceId);
-    if (device != NULL) {
-        return markSupportedKeyCodesLocked(device, numCodes, keyCodes, outFlags);
-    }
-    return false;
-}
+    if (device && device->keyMap.haveKeyLayout()) {
+        Vector<int32_t> scanCodes;
+        for (size_t codeIndex = 0; codeIndex < numCodes; codeIndex++) {
+            scanCodes.clear();
 
-bool EventHub::markSupportedKeyCodesLocked(Device* device, size_t numCodes,
-        const int32_t* keyCodes, uint8_t* outFlags) const {
-    if (!device->keyMap.haveKeyLayout()) {
-        return false;
-    }
-
-    Vector<int32_t> scanCodes;
-    for (size_t codeIndex = 0; codeIndex < numCodes; codeIndex++) {
-        scanCodes.clear();
-
-        status_t err = device->keyMap.keyLayoutMap->findScanCodesForKey(
-                keyCodes[codeIndex], &scanCodes);
-        if (! err) {
-            // check the possible scan codes identified by the layout map against the
-            // map of codes actually emitted by the driver
-            for (size_t sc = 0; sc < scanCodes.size(); sc++) {
-                if (test_bit(scanCodes[sc], device->keyBitmask)) {
-                    outFlags[codeIndex] = 1;
-                    break;
+            status_t err = device->keyMap.keyLayoutMap->findScanCodesForKey(
+                    keyCodes[codeIndex], &scanCodes);
+            if (! err) {
+                // check the possible scan codes identified by the layout map against the
+                // map of codes actually emitted by the driver
+                for (size_t sc = 0; sc < scanCodes.size(); sc++) {
+                    if (test_bit(scanCodes[sc], device->keyBitmask)) {
+                        outFlags[codeIndex] = 1;
+                        break;
+                    }
                 }
             }
         }
+        return true;
     }
-    return true;
+    return false;
 }
 
 status_t EventHub::mapKey(int32_t deviceId, int scancode,
@@ -1333,4 +1294,11 @@
     } // release lock
 }
 
+void EventHub::monitor() {
+    // Acquire and release the lock to ensure that the event hub has not deadlocked.
+    mLock.lock();
+    mLock.unlock();
+}
+
+
 }; // namespace android
diff --git a/services/input/EventHub.h b/services/input/EventHub.h
index 293a1a0..fae5d4f 100644
--- a/services/input/EventHub.h
+++ b/services/input/EventHub.h
@@ -208,7 +208,11 @@
     /* Wakes up getEvents() if it is blocked on a read. */
     virtual void wake() = 0;
 
+    /* Dump EventHub state to a string. */
     virtual void dump(String8& dump) = 0;
+
+    /* Called by the heatbeat to ensures that the reader has not deadlocked. */
+    virtual void monitor() = 0;
 };
 
 class EventHub : public EventHubInterface
@@ -259,6 +263,7 @@
     virtual void wake();
 
     virtual void dump(String8& dump);
+    virtual void monitor();
 
 protected:
     virtual ~EventHub();
@@ -307,13 +312,6 @@
 
     bool hasKeycodeLocked(Device* device, int keycode) const;
 
-    int32_t getScanCodeStateLocked(Device* device, int32_t scanCode) const;
-    int32_t getKeyCodeStateLocked(Device* device, int32_t keyCode) const;
-    int32_t getSwitchStateLocked(Device* device, int32_t sw) const;
-    int32_t getAbsoluteAxisValueLocked(Device* device, int32_t axis, int32_t* outValue) const;
-    bool markSupportedKeyCodesLocked(Device* device, size_t numCodes,
-            const int32_t* keyCodes, uint8_t* outFlags) const;
-
     void loadConfigurationLocked(Device* device);
     status_t loadVirtualKeyMapLocked(Device* device);
     status_t loadKeyMapLocked(Device* device);
diff --git a/services/input/InputDispatcher.cpp b/services/input/InputDispatcher.cpp
index ce9e14f..22372cf 100644
--- a/services/input/InputDispatcher.cpp
+++ b/services/input/InputDispatcher.cpp
@@ -3919,6 +3919,8 @@
 }
 
 void InputDispatcher::dump(String8& dump) {
+    AutoMutex _l(mLock);
+
     dump.append("Input Dispatcher State:\n");
     dumpDispatchStateLocked(dump);
 
@@ -3928,6 +3930,12 @@
     dump.appendFormat(INDENT2 "KeyRepeatTimeout: %0.1fms\n", mConfig.keyRepeatTimeout * 0.000001f);
 }
 
+void InputDispatcher::monitor() {
+    // Acquire and release the lock to ensure that the dispatcher has not deadlocked.
+    mLock.lock();
+    mLock.unlock();
+}
+
 
 // --- InputDispatcher::Queue ---
 
diff --git a/services/input/InputDispatcher.h b/services/input/InputDispatcher.h
index 01c7b35..cae1610 100644
--- a/services/input/InputDispatcher.h
+++ b/services/input/InputDispatcher.h
@@ -282,6 +282,9 @@
      * This method may be called on any thread (usually by the input manager). */
     virtual void dump(String8& dump) = 0;
 
+    /* Called by the heatbeat to ensures that the dispatcher has not deadlocked. */
+    virtual void monitor() = 0;
+
     /* Runs a single iteration of the dispatch loop.
      * Nominally processes one queued event, a timeout, or a response from an input consumer.
      *
@@ -370,6 +373,7 @@
     explicit InputDispatcher(const sp<InputDispatcherPolicyInterface>& policy);
 
     virtual void dump(String8& dump);
+    virtual void monitor();
 
     virtual void dispatchOnce();
 
diff --git a/services/input/InputReader.cpp b/services/input/InputReader.cpp
index 8786c24..2eacbeb 100644
--- a/services/input/InputReader.cpp
+++ b/services/input/InputReader.cpp
@@ -731,6 +731,15 @@
             mConfig.pointerGestureZoomSpeedRatio);
 }
 
+void InputReader::monitor() {
+    // Acquire and release the lock to ensure that the reader has not deadlocked.
+    mLock.lock();
+    mLock.unlock();
+
+    // Check the EventHub
+    mEventHub->monitor();
+}
+
 
 // --- InputReader::ContextImpl ---
 
@@ -1170,9 +1179,8 @@
     return AMOTION_EVENT_TOOL_TYPE_UNKNOWN;
 }
 
-bool TouchButtonAccumulator::isActive() const {
-    return mBtnTouch || mBtnToolFinger || mBtnToolPen
-            || mBtnToolRubber || mBtnStylus || mBtnStylus2;
+bool TouchButtonAccumulator::isToolActive() const {
+    return mBtnTouch || mBtnToolFinger || mBtnToolPen || mBtnToolRubber;
 }
 
 bool TouchButtonAccumulator::isHovering() const {
@@ -5144,7 +5152,7 @@
     mCurrentRawPointerData.clear();
     mCurrentButtonState = 0;
 
-    if (mTouchButtonAccumulator.isActive()) {
+    if (mTouchButtonAccumulator.isToolActive()) {
         mCurrentRawPointerData.pointerCount = 1;
         mCurrentRawPointerData.idToIndex[0] = 0;
 
@@ -5168,11 +5176,11 @@
             outPointer.toolType = AMOTION_EVENT_TOOL_TYPE_FINGER;
         }
         outPointer.isHovering = isHovering;
-
-        mCurrentButtonState = mTouchButtonAccumulator.getButtonState()
-                | mCursorButtonAccumulator.getButtonState();
     }
 
+    mCurrentButtonState = mTouchButtonAccumulator.getButtonState()
+            | mCursorButtonAccumulator.getButtonState();
+
     syncTouch(when, true);
 }
 
diff --git a/services/input/InputReader.h b/services/input/InputReader.h
index f5d095d..e9daef5 100644
--- a/services/input/InputReader.h
+++ b/services/input/InputReader.h
@@ -210,6 +210,9 @@
      * This method may be called on any thread (usually by the input manager). */
     virtual void dump(String8& dump) = 0;
 
+    /* Called by the heatbeat to ensures that the reader has not deadlocked. */
+    virtual void monitor() = 0;
+
     /* Runs a single iteration of the processing loop.
      * Nominally reads and processes one incoming message from the EventHub.
      *
@@ -297,6 +300,7 @@
     virtual ~InputReader();
 
     virtual void dump(String8& dump);
+    virtual void monitor();
 
     virtual void loopOnce();
 
@@ -526,7 +530,7 @@
 
     uint32_t getButtonState() const;
     int32_t getToolType() const;
-    bool isActive() const;
+    bool isToolActive() const;
     bool isHovering() const;
 
 private:
diff --git a/services/input/tests/InputReader_test.cpp b/services/input/tests/InputReader_test.cpp
index 4a866a8..87f212b 100644
--- a/services/input/tests/InputReader_test.cpp
+++ b/services/input/tests/InputReader_test.cpp
@@ -631,6 +631,9 @@
     virtual void dump(String8& dump) {
     }
 
+    virtual void monitor() {
+    }
+
     virtual void requestReopenDevices() {
     }
 
diff --git a/services/java/com/android/server/ConnectivityService.java b/services/java/com/android/server/ConnectivityService.java
index 3ae7a3f..acfc7a4 100644
--- a/services/java/com/android/server/ConnectivityService.java
+++ b/services/java/com/android/server/ConnectivityService.java
@@ -1831,6 +1831,19 @@
         for (RouteInfo r :  routeDiff.added) {
             if (isLinkDefault || ! r.isDefaultRoute()) {
                 addRoute(newLp, r);
+            } else {
+                // many radios add a default route even when we don't want one.
+                // remove the default route unless somebody else has asked for it
+                String ifaceName = newLp.getInterfaceName();
+                if (TextUtils.isEmpty(ifaceName) == false && mAddedRoutes.contains(r) == false) {
+                    if (DBG) log("Removing " + r + " for interface " + ifaceName);
+                    try {
+                        mNetd.removeRoute(ifaceName, r);
+                    } catch (Exception e) {
+                        // never crash - catch them all
+                        loge("Exception trying to remove a route: " + e);
+                    }
+                }
             }
         }
 
diff --git a/services/java/com/android/server/NetworkManagementService.java b/services/java/com/android/server/NetworkManagementService.java
index 30de385..782e7d7 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) {
@@ -447,6 +446,28 @@
         }
     }
 
+    public void setInterfaceDown(String iface) throws IllegalStateException {
+        try {
+            InterfaceConfiguration ifcg = getInterfaceConfig(iface);
+            ifcg.interfaceFlags = ifcg.interfaceFlags.replace("up", "down");
+            setInterfaceConfig(iface, ifcg);
+        } catch (NativeDaemonConnectorException e) {
+            throw new IllegalStateException(
+                    "Unable to communicate with native daemon for interface down - " + e);
+        }
+    }
+
+    public void setInterfaceUp(String iface) throws IllegalStateException {
+        try {
+            InterfaceConfiguration ifcg = getInterfaceConfig(iface);
+            ifcg.interfaceFlags = ifcg.interfaceFlags.replace("down", "up");
+            setInterfaceConfig(iface, ifcg);
+        } catch (NativeDaemonConnectorException e) {
+            throw new IllegalStateException(
+                    "Unable to communicate with native daemon for interface up - " + e);
+        }
+    }
+
     /* TODO: This is right now a IPv4 only function. Works for wifi which loses its
        IPv6 addresses on interface down, but we need to do full clean up here */
     public void clearInterfaceAddresses(String iface) throws IllegalStateException {
@@ -855,7 +876,7 @@
         mContext.enforceCallingOrSelfPermission(
                 android.Manifest.permission.CHANGE_WIFI_STATE, "NetworkManagementService");
         try {
-            mConnector.doCommand(String.format("softap fwreload " + wlanIface + " AP"));
+            wifiFirmwareReload(wlanIface, "AP");
             mConnector.doCommand(String.format("softap start " + wlanIface));
             if (wifiConfig == null) {
                 mConnector.doCommand(String.format("softap set " + wlanIface + " " + softapIface));
@@ -902,6 +923,20 @@
         }
     }
 
+    /* @param mode can be "AP", "STA" or "P2P" */
+    public void wifiFirmwareReload(String wlanIface, String mode) throws IllegalStateException {
+        mContext.enforceCallingOrSelfPermission(
+                android.Manifest.permission.CHANGE_NETWORK_STATE, "NetworkManagementService");
+        mContext.enforceCallingOrSelfPermission(
+                android.Manifest.permission.CHANGE_WIFI_STATE, "NetworkManagementService");
+
+        try {
+            mConnector.doCommand(String.format("softap fwreload " + wlanIface + " " + mode));
+        } catch (NativeDaemonConnectorException e) {
+            throw new IllegalStateException("Error communicating to native daemon ", e);
+        }
+    }
+
     public void stopAccessPoint(String wlanIface) throws IllegalStateException {
         mContext.enforceCallingOrSelfPermission(
                 android.Manifest.permission.CHANGE_NETWORK_STATE, "NetworkManagementService");
@@ -910,7 +945,7 @@
         try {
             mConnector.doCommand("softap stopap");
             mConnector.doCommand("softap stop " + wlanIface);
-            mConnector.doCommand(String.format("softap fwreload " + wlanIface + " STA"));
+            wifiFirmwareReload(wlanIface, "STA");
         } catch (NativeDaemonConnectorException e) {
             throw new IllegalStateException("Error communicating to native daemon to stop soft AP",
                     e);
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
index 4a0dcdf..77d0457 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -315,6 +315,7 @@
                 ServiceManager.addService(Context.CONNECTIVITY_SERVICE, connectivity);
                 networkStats.bindConnectivityManager(connectivity);
                 networkPolicy.bindConnectivityManager(connectivity);
+                wifiP2p.connectivityServiceReady();
             } catch (Throwable e) {
                 Slog.e(TAG, "Failure starting Connectivity Service", e);
             }
diff --git a/services/java/com/android/server/pm/PackageManagerService.java b/services/java/com/android/server/pm/PackageManagerService.java
index 463f801..a57f68d 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);
     }
 
@@ -6436,6 +6457,10 @@
             if (removedPackage != null) {
                 sendPackageBroadcast(Intent.ACTION_PACKAGE_REMOVED, removedPackage,
                         extras, null, null);
+                if (fullRemove && !replacing) {
+                    sendPackageBroadcast(Intent.ACTION_PACKAGE_FULLY_REMOVED, removedPackage,
+                            extras, null, null);
+                }
             }
             if (removedUid >= 0) {
                 sendPackageBroadcast(Intent.ACTION_UID_REMOVED, null, extras, null, null);
@@ -7184,6 +7209,8 @@
     }
 
     public void enterSafeMode() {
+        enforceSystemOrRoot("Only the system can request entering safe mode");
+
         if (!mSystemReady) {
             mSafeMode = true;
         }
@@ -8086,12 +8113,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/java/com/android/server/wm/InputManager.java b/services/java/com/android/server/wm/InputManager.java
index 1d0857b..c8b18c8 100644
--- a/services/java/com/android/server/wm/InputManager.java
+++ b/services/java/com/android/server/wm/InputManager.java
@@ -17,6 +17,7 @@
 package com.android.server.wm;
 
 import com.android.internal.util.XmlUtils;
+import com.android.server.Watchdog;
 
 import org.xmlpull.v1.XmlPullParser;
 
@@ -52,7 +53,7 @@
 /*
  * Wraps the C++ InputManager and provides its callbacks.
  */
-public class InputManager {
+public class InputManager implements Watchdog.Monitor {
     static final String TAG = "InputManager";
     
     private static final boolean DEBUG = false;
@@ -94,6 +95,7 @@
             InputChannel toChannel);
     private static native void nativeSetPointerSpeed(int speed);
     private static native String nativeDump();
+    private static native void nativeMonitor();
     
     // Input event injection constants defined in InputDispatcher.h.
     static final int INPUT_EVENT_INJECTION_SUCCEEDED = 0;
@@ -135,6 +137,9 @@
 
         Slog.i(TAG, "Initializing input manager");
         nativeInit(mContext, mCallbacks, looper.getQueue());
+
+        // Add ourself to the Watchdog monitors.
+        Watchdog.getInstance().addMonitor(this);
     }
 
     public void start() {
@@ -456,6 +461,12 @@
         }
     }
 
+    // Called by the heartbeat to ensure locks are not held indefnitely (for deadlock detection).
+    public void monitor() {
+        synchronized (mInputFilterLock) { }
+        nativeMonitor();
+    }
+
     private final class InputFilterHost implements InputFilter.Host {
         private boolean mDisconnected;
 
diff --git a/services/jni/com_android_server_InputManager.cpp b/services/jni/com_android_server_InputManager.cpp
index 3414eea..7c84e43 100644
--- a/services/jni/com_android_server_InputManager.cpp
+++ b/services/jni/com_android_server_InputManager.cpp
@@ -1288,6 +1288,15 @@
     return env->NewStringUTF(dump.string());
 }
 
+static void android_server_InputManager_nativeMonitor(JNIEnv* env, jclass clazz) {
+    if (checkInputManagerUnitialized(env)) {
+        return;
+    }
+
+    gNativeInputManager->getInputManager()->getReader()->monitor();
+    gNativeInputManager->getInputManager()->getDispatcher()->monitor();
+}
+
 // ----------------------------------------------------------------------------
 
 static JNINativeMethod gInputManagerMethods[] = {
@@ -1338,6 +1347,8 @@
             (void*) android_server_InputManager_nativeSetPointerSpeed },
     { "nativeDump", "()Ljava/lang/String;",
             (void*) android_server_InputManager_nativeDump },
+    { "nativeMonitor", "()V",
+            (void*) android_server_InputManager_nativeMonitor },
 };
 
 #define FIND_CLASS(var, className) \
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 634e7e3..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/tests/StatusBar/src/com/android/statusbartest/StatusBarTest.java b/tests/StatusBar/src/com/android/statusbartest/StatusBarTest.java
index da5f488..ad3073a 100644
--- a/tests/StatusBar/src/com/android/statusbartest/StatusBarTest.java
+++ b/tests/StatusBar/src/com/android/statusbartest/StatusBarTest.java
@@ -167,10 +167,13 @@
         },
         new Test("Priority notification") {
             public void run() {
-                Notification not = new Notification(
-                                R.drawable.stat_sys_phone,
-                                "Incoming call from: Imperious Leader",
-                                System.currentTimeMillis()-(1000*60*60*24)
+                Notification not = new Notification();
+                not.icon = R.drawable.stat_sys_phone;
+                not.when = System.currentTimeMillis()-(1000*60*60*24);
+                not.setLatestEventInfo(StatusBarTest.this,
+                                "Incoming call",
+                                "from: Imperious Leader",
+                                null
                                 );
                 not.flags |= Notification.FLAG_HIGH_PRIORITY;
                 Intent fullScreenIntent = new Intent(StatusBarTest.this, TestAlertActivity.class);
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..c6f7da2 100644
--- a/wifi/java/android/net/wifi/WifiStateMachine.java
+++ b/wifi/java/android/net/wifi/WifiStateMachine.java
@@ -114,7 +114,7 @@
     private static final String SOFTAP_IFACE = "wl0.1";
 
     private WifiMonitor mWifiMonitor;
-    private INetworkManagementService nwService;
+    private INetworkManagementService mNwService;
     private ConnectivityManager mCm;
 
     /* Scan results handling */
@@ -500,7 +500,7 @@
         mBatteryStats = IBatteryStats.Stub.asInterface(ServiceManager.getService("batteryinfo"));
 
         IBinder b = ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE);
-        nwService = INetworkManagementService.Stub.asInterface(b);
+        mNwService = INetworkManagementService.Stub.asInterface(b);
 
         mWifiMonitor = new WifiMonitor(this);
         mDhcpInfoInternal = new DhcpInfoInternal();
@@ -1090,24 +1090,22 @@
 
                     InterfaceConfiguration ifcg = null;
                     try {
-                        ifcg = nwService.getInterfaceConfig(intf);
+                        ifcg = mNwService.getInterfaceConfig(intf);
                         if (ifcg != null) {
                             /* IP/netmask: 192.168.43.1/255.255.255.0 */
                             ifcg.addr = new LinkAddress(NetworkUtils.numericToInetAddress(
                                     "192.168.43.1"), 24);
                             ifcg.interfaceFlags = "[up]";
 
-                            nwService.setInterfaceConfig(intf, ifcg);
+                            mNwService.setInterfaceConfig(intf, ifcg);
                         }
                     } 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;
@@ -1126,11 +1124,11 @@
            ip settings */
         InterfaceConfiguration ifcg = null;
         try {
-            ifcg = nwService.getInterfaceConfig(mInterfaceName);
+            ifcg = mNwService.getInterfaceConfig(mInterfaceName);
             if (ifcg != null) {
                 ifcg.addr = new LinkAddress(NetworkUtils.numericToInetAddress(
                             "0.0.0.0"), 0);
-                nwService.setInterfaceConfig(mInterfaceName, ifcg);
+                mNwService.setInterfaceConfig(mInterfaceName, ifcg);
             }
         } catch (Exception e) {
             Log.e(TAG, "Error resetting interface " + mInterfaceName + ", :" + e);
@@ -1536,7 +1534,7 @@
         }
 
         try {
-            nwService.clearInterfaceAddresses(mInterfaceName);
+            mNwService.clearInterfaceAddresses(mInterfaceName);
         } catch (Exception e) {
             Log.e(TAG, "Failed to clear IP addresses on disconnect" + e);
         }
@@ -1671,12 +1669,12 @@
             WifiApConfigStore.setApConfiguration(config);
         }
         try {
-            nwService.startAccessPoint(config, mInterfaceName, SOFTAP_IFACE);
+            mNwService.startAccessPoint(config, mInterfaceName, SOFTAP_IFACE);
         } catch (Exception e) {
             Log.e(TAG, "Exception in softap start " + e);
             try {
-                nwService.stopAccessPoint(mInterfaceName);
-                nwService.startAccessPoint(config, mInterfaceName, SOFTAP_IFACE);
+                mNwService.stopAccessPoint(mInterfaceName);
+                mNwService.startAccessPoint(config, mInterfaceName, SOFTAP_IFACE);
             } catch (Exception e1) {
                 Log.e(TAG, "Exception in softap re-start " + e1);
                 return false;
@@ -1913,6 +1911,17 @@
                     transitionTo(mDriverUnloadingState);
                     break;
                 case CMD_START_SUPPLICANT:
+                    //A runtime crash can leave the interface up and
+                    //this affects connectivity when supplicant starts up.
+                    //Ensure interface is down before a supplicant start.
+                    try {
+                        mNwService.setInterfaceDown(mInterfaceName);
+                    } catch (RemoteException re) {
+                        if (DBG) Log.w(TAG, "Unable to bring down wlan interface: " + re);
+                    } catch (IllegalStateException ie) {
+                        if (DBG) Log.w(TAG, "Unable to bring down wlan interface: " + ie);
+                    }
+
                     if(WifiNative.startSupplicant()) {
                         Log.d(TAG, "Supplicant start successful");
                         mWifiMonitor.startMonitoring();
@@ -2700,7 +2709,7 @@
                 ifcg.addr = dhcpInfoInternal.makeLinkAddress();
                 ifcg.interfaceFlags = "[up]";
                 try {
-                    nwService.setInterfaceConfig(mInterfaceName, ifcg);
+                    mNwService.setInterfaceConfig(mInterfaceName, ifcg);
                     Log.v(TAG, "Static IP configuration succeeded");
                     sendMessage(CMD_STATIC_IP_SUCCESS, dhcpInfoInternal);
                 } catch (RemoteException re) {
@@ -3160,7 +3169,7 @@
                     setWifiApState(WIFI_AP_STATE_DISABLING);
                     stopTethering();
                     try {
-                        nwService.stopAccessPoint(mInterfaceName);
+                        mNwService.stopAccessPoint(mInterfaceName);
                     } catch(Exception e) {
                         Log.e(TAG, "Exception in stopAccessPoint()");
                     }
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;
 
diff --git a/wifi/java/android/net/wifi/p2p/WifiP2pService.java b/wifi/java/android/net/wifi/p2p/WifiP2pService.java
index 28afd44..3678cfc 100644
--- a/wifi/java/android/net/wifi/p2p/WifiP2pService.java
+++ b/wifi/java/android/net/wifi/p2p/WifiP2pService.java
@@ -34,10 +34,13 @@
 import android.net.wifi.p2p.WifiP2pDevice.Status;
 import android.os.Binder;
 import android.os.IBinder;
+import android.os.INetworkManagementService;
 import android.os.Handler;
 import android.os.HandlerThread;
 import android.os.Message;
 import android.os.Messenger;
+import android.os.ServiceManager;
+import android.os.SystemProperties;
 import android.util.Slog;
 import android.view.LayoutInflater;
 import android.view.View;
@@ -69,6 +72,9 @@
     private static final boolean DBG = true;
 
     private Context mContext;
+    private String mInterface;
+
+    INetworkManagementService mNwService;
 
     // Tracked to notify the user about wifi client/hotspot being shut down
     // during p2p bring up
@@ -94,6 +100,7 @@
     public WifiP2pService(Context context) {
         mContext = context;
 
+        mInterface = SystemProperties.get("wifi.interface", "wlan0");
         mP2pSupported = mContext.getResources().getBoolean(
                 com.android.internal.R.bool.config_wifi_p2p_support);
 
@@ -108,6 +115,11 @@
 
    }
 
+    public void connectivityServiceReady() {
+        IBinder b = ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE);
+        mNwService = INetworkManagementService.Stub.asInterface(b);
+    }
+
     private class WifiStateReceiver extends BroadcastReceiver {
         @Override
         public void onReceive(Context context, Intent intent) {
@@ -324,8 +336,6 @@
         @Override
         public void enter() {
             if (DBG) Slog.d(TAG, getName());
-            // TODO: fix later
-            WifiNative.unloadDriver();
             transitionTo(mP2pDisabledState);
         }
 
@@ -334,7 +344,6 @@
             if (DBG) Slog.d(TAG, getName() + message.toString());
             switch (message.what) {
                 case WifiMonitor.SUP_DISCONNECTION_EVENT:
-                    WifiNative.unloadDriver();
                     transitionTo(mP2pDisabledState);
                     break;
                 default:
@@ -411,9 +420,13 @@
             if (DBG) Slog.d(TAG, getName() + message.toString());
             switch (message.what) {
                 case WifiStateMachine.P2P_ENABLE_PROCEED:
-                    // TODO: fix this for p2p
-                    if (WifiNative.loadDriver() &&
-                            WifiNative.startSupplicant()) {
+                    try {
+                        mNwService.wifiFirmwareReload(mInterface, "P2P");
+                    } catch (Exception e) {
+                        Slog.e(TAG, "Failed to reload p2p firmware " + e);
+                        // continue
+                    }
+                    if (WifiNative.startSupplicant()) {
                         Slog.d(TAG, "Wi-fi Direct start successful");
                         mWifiMonitor.startMonitoring();
                         transitionTo(mP2pEnablingState);