Merge "Fixing a bug with TTS that caused TTS to ignore the default settings unless the user had set the defaults to always override app settings."
diff --git a/api/current.xml b/api/current.xml
index 89af2ac..189835e 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -7819,6 +7819,39 @@
  visibility="public"
 >
 </field>
+<field name="stripEnabled"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16843454"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="stripLeft"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16843452"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="stripRight"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16843453"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="suggestActionMsg"
  type="int"
  transient="false"
@@ -71408,6 +71441,19 @@
 <exception name="IOException" type="java.io.IOException">
 </exception>
 </method>
+<method name="setZoomCallback"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="cb" type="android.hardware.Camera.ZoomCallback">
+</parameter>
+</method>
 <method name="startPreview"
  return="void"
  abstract="false"
@@ -71419,6 +71465,19 @@
  visibility="public"
 >
 </method>
+<method name="startSmoothZoom"
+ return="void"
+ abstract="false"
+ native="true"
+ synchronized="false"
+ static="false"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="value" type="int">
+</parameter>
+</method>
 <method name="stopPreview"
  return="void"
  abstract="false"
@@ -71430,6 +71489,17 @@
  visibility="public"
 >
 </method>
+<method name="stopSmoothZoom"
+ return="void"
+ abstract="false"
+ native="true"
+ synchronized="false"
+ static="false"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="takePicture"
  return="void"
  abstract="false"
@@ -71723,6 +71793,17 @@
  visibility="public"
 >
 </method>
+<method name="getMaxZoom"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="getMinExposureCompensation"
  return="int"
  abstract="false"
@@ -71954,6 +72035,50 @@
  visibility="public"
 >
 </method>
+<method name="getZoom"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getZoomRatios"
+ return="java.util.List&lt;java.lang.Integer&gt;"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="isSmoothZoomSupported"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="isZoomSupported"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="remove"
  return="void"
  abstract="false"
@@ -72274,6 +72399,19 @@
 <parameter name="value" type="java.lang.String">
 </parameter>
 </method>
+<method name="setZoom"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="value" type="int">
+</parameter>
+</method>
 <method name="unflatten"
  return="void"
  abstract="false"
@@ -72889,6 +73027,31 @@
 >
 </field>
 </class>
+<interface name="Camera.ZoomCallback"
+ abstract="true"
+ static="true"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<method name="onZoomUpdate"
+ return="void"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="zoomValue" type="int">
+</parameter>
+<parameter name="stopped" type="boolean">
+</parameter>
+<parameter name="camera" type="android.hardware.Camera">
+</parameter>
+</method>
+</interface>
 <class name="GeomagneticField"
  extends="java.lang.Object"
  abstract="false"
@@ -209334,6 +209497,17 @@
  visibility="public"
 >
 </method>
+<method name="isStripEnabled"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="onFocusChange"
  return="void"
  abstract="false"
@@ -209388,6 +209562,71 @@
 <parameter name="resId" type="int">
 </parameter>
 </method>
+<method name="setLeftStripDrawable"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="drawable" type="android.graphics.drawable.Drawable">
+</parameter>
+</method>
+<method name="setLeftStripDrawable"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="resId" type="int">
+</parameter>
+</method>
+<method name="setRightStripDrawable"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="drawable" type="android.graphics.drawable.Drawable">
+</parameter>
+</method>
+<method name="setRightStripDrawable"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="resId" type="int">
+</parameter>
+</method>
+<method name="setStripEnabled"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="drawBottomStrips" type="boolean">
+</parameter>
+</method>
 </class>
 <class name="TableLayout"
  extends="android.widget.LinearLayout"
diff --git a/core/java/android/accounts/AuthenticatorDescription.java b/core/java/android/accounts/AuthenticatorDescription.java
index 91c94e6..eddf7c1 100644
--- a/core/java/android/accounts/AuthenticatorDescription.java
+++ b/core/java/android/accounts/AuthenticatorDescription.java
@@ -91,7 +91,7 @@
         return "AuthenticatorDescription {type=" + type + "}";
     }
 
-    /** @inhericDoc */
+    /** @inheritDoc */
     public void writeToParcel(Parcel dest, int flags) {
         dest.writeString(type);
         dest.writeString(packageName);
diff --git a/core/java/android/accounts/ChooseAccountActivity.java b/core/java/android/accounts/ChooseAccountActivity.java
index 4a0018e..0bbb6fc 100644
--- a/core/java/android/accounts/ChooseAccountActivity.java
+++ b/core/java/android/accounts/ChooseAccountActivity.java
@@ -36,14 +36,15 @@
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
-        if (savedInstanceState == null) {
-            mAccounts = getIntent().getParcelableArrayExtra(AccountManager.KEY_ACCOUNTS);
-            mAccountManagerResponse =
-                    getIntent().getParcelableExtra(AccountManager.KEY_ACCOUNT_MANAGER_RESPONSE);
-        } else {
-            mAccounts = savedInstanceState.getParcelableArray(AccountManager.KEY_ACCOUNTS);
-            mAccountManagerResponse =
-                    savedInstanceState.getParcelable(AccountManager.KEY_ACCOUNT_MANAGER_RESPONSE);
+        mAccounts = getIntent().getParcelableArrayExtra(AccountManager.KEY_ACCOUNTS);
+        mAccountManagerResponse =
+                getIntent().getParcelableExtra(AccountManager.KEY_ACCOUNT_MANAGER_RESPONSE);
+
+        // KEY_ACCOUNTS is a required parameter
+        if (mAccounts == null) {
+            setResult(RESULT_CANCELED);
+            finish();
+            return;
         }
 
         String[] mAccountNames = new String[mAccounts.length];
diff --git a/core/java/android/app/Dialog.java b/core/java/android/app/Dialog.java
index 0ed5eb8..981c237 100644
--- a/core/java/android/app/Dialog.java
+++ b/core/java/android/app/Dialog.java
@@ -27,7 +27,6 @@
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.Message;
-import android.util.Config;
 import android.util.Log;
 import android.view.ContextMenu;
 import android.view.ContextThemeWrapper;
@@ -72,8 +71,6 @@
  */
 public class Dialog implements DialogInterface, Window.Callback,
         KeyEvent.Callback, OnCreateContextMenuListener {
-    private static final String LOG_TAG = "Dialog";
-
     private Activity mOwnerActivity;
     
     final Context mContext;
@@ -104,6 +101,12 @@
     private final Thread mUiThread;
     private final Handler mHandler = new Handler();
 
+    private static final int DISMISS = 0x43;
+    private static final int CANCEL = 0x44;
+    private static final int SHOW = 0x45;
+
+    private Handler mListenersHandler;
+
     private final Runnable mDismissAction = new Runnable() {
         public void run() {
             dismissDialog();
@@ -213,8 +216,6 @@
      */
     public void show() {
         if (mShowing) {
-            if (Config.LOGV) Log.v(LOG_TAG,
-                    "[Dialog] start: already showing, ignore");
             if (mDecor != null) {
                 mDecor.setVisibility(View.VISIBLE);
             }
@@ -266,14 +267,7 @@
     }
 
     private void dismissDialog() {
-        if (mDecor == null) {
-            if (Config.LOGV) Log.v(LOG_TAG,
-                    "[Dialog] dismiss: already dismissed, ignore");
-            return;
-        }
-        if (!mShowing) {
-            if (Config.LOGV) Log.v(LOG_TAG,
-                    "[Dialog] dismiss: not showing, ignore");
+        if (mDecor == null || !mShowing || mDecor.getWindowToken() == null) {
             return;
         }
 
@@ -1034,12 +1028,6 @@
         mOnKeyListener = onKeyListener;
     }
 
-    private static final int DISMISS = 0x43;
-    private static final int CANCEL = 0x44;
-    private static final int SHOW = 0x45;
-
-    private Handler mListenersHandler;
-
     private static final class ListenersHandler extends Handler {
         private WeakReference<DialogInterface> mDialog;
 
diff --git a/core/java/android/hardware/Camera.java b/core/java/android/hardware/Camera.java
index da5fa49..cddbec9 100644
--- a/core/java/android/hardware/Camera.java
+++ b/core/java/android/hardware/Camera.java
@@ -524,21 +524,24 @@
 
     /**
      * Zooms to the requested value smoothly. Driver will generate {@link
-     * #ZoomCallback} for the current zoom value and whether zoom is stopped.
-     * The applications can call {@link #stopSmoothZoom} to stop the zoom
-     * earlier. The applications should not call startSmoothZoom again or {@link
-     * android.hardware.Camera.Parameters#setZoom(int)} before the zoom stops.
+     * ZoomCallback} for the zoom value and whether zoom is stopped at the
+     * time. For example, suppose the current zoom is 0 and startSmoothZoom is
+     * called with value 3. Three ZoomCallback will be generated with zoom value
+     * 1, 2, and 3. The applications can call {@link #stopSmoothZoom} to stop
+     * the zoom earlier. The applications should not call startSmoothZoom again
+     * or change the zoom value before zoom stops. This method is supported if
+     * {@link android.hardware.Camera.Parameters#isSmoothZoomSupported} is true.
      *
      * @param value zoom value. The valid range is 0 to {@link
      *              android.hardware.Camera.Parameters#getMaxZoom}.
-     * @hide
      */
     public native final void startSmoothZoom(int value);
 
     /**
      * Stops the smooth zoom. The applications should wait for the {@link
-     * #ZoomCallback} to know when the zoom is actually stopped.
-     * @hide
+     * ZoomCallback} to know when the zoom is actually stopped. This method is
+     * supported if {@link
+     * android.hardware.Camera.Parameters#isSmoothZoomSupported} is true.
      */
     public native final void stopSmoothZoom();
 
@@ -560,7 +563,6 @@
     /**
      * Handles the zoom callback.
      *
-     * @hide
      */
     public interface ZoomCallback
     {
@@ -573,7 +575,7 @@
          *                this is the last zoom update for the application.
          *
          * @param camera  the Camera service object
-         * @see android.hardware.Camera.Parameters#startSmoothZoom
+         * @see #startSmoothZoom(int)
          */
         void onZoomUpdate(int zoomValue, boolean stopped, Camera camera);
     };
@@ -581,8 +583,9 @@
     /**
      * Registers a callback to be invoked when the zoom value is updated by the
      * camera driver during smooth zoom.
+     *
      * @param cb the callback to run
-     * @hide
+     * @see #startSmoothZoom(int)
      */
     public final void setZoomCallback(ZoomCallback cb)
     {
@@ -727,9 +730,16 @@
         private static final String KEY_MAX_EXPOSURE_COMPENSATION = "max-exposure-compensation";
         private static final String KEY_MIN_EXPOSURE_COMPENSATION = "min-exposure-compensation";
         private static final String KEY_EXPOSURE_COMPENSATION_STEP = "exposure-compensation-step";
+        private static final String KEY_ZOOM = "zoom";
+        private static final String KEY_MAX_ZOOM = "max-zoom";
+        private static final String KEY_ZOOM_RATIOS = "zoom-ratios";
+        private static final String KEY_ZOOM_SUPPORTED = "zoom-supported";
+        private static final String KEY_SMOOTH_ZOOM_SUPPORTED = "smooth-zoom-supported";
         // Parameter key suffix for supported values.
         private static final String SUPPORTED_VALUES_SUFFIX = "-values";
 
+        private static final String TRUE = "true";
+
         // Values for white balance settings.
         public static final String WHITE_BALANCE_AUTO = "auto";
         public static final String WHITE_BALANCE_INCANDESCENT = "incandescent";
@@ -1607,26 +1617,28 @@
 
         /**
          * Gets current zoom value. This also works when smooth zoom is in
-         * progress.
+         * progress. Applications should check {@link #isZoomSupported} before
+         * using this method.
          *
          * @return the current zoom value. The range is 0 to {@link
-         *          #getMaxZoom}.
-         * @hide
+         *         #getMaxZoom}. 0 means the camera is not zoomed.
          */
         public int getZoom() {
-            return getInt("zoom");
+            return getInt(KEY_ZOOM, 0);
         }
 
         /**
-         * Sets current zoom value. If {@link #startSmoothZoom(int)} has been
-         * called and zoom is not stopped yet, applications should not call this
-         * method.
+         * Sets current zoom value. If the camera is zoomed (value > 0), the
+         * actual picture size may be smaller than picture size setting.
+         * Applications can check the actual picture size after picture is
+         * returned from {@link PictureCallback}. The preview size remains the
+         * same in zoom. Applications should check {@link #isZoomSupported}
+         * before using this method.
          *
          * @param value zoom value. The valid range is 0 to {@link #getMaxZoom}.
-         * @hide
          */
         public void setZoom(int value) {
-            set("zoom", value);
+            set(KEY_ZOOM, value);
         }
 
         /**
@@ -1634,37 +1646,37 @@
          * before using other zoom methods.
          *
          * @return true if zoom is supported.
-         * @hide
          */
         public boolean isZoomSupported() {
-            String str = get("zoom-supported");
-            return "true".equals(str);
+            String str = get(KEY_ZOOM_SUPPORTED);
+            return TRUE.equals(str);
         }
 
         /**
          * Gets the maximum zoom value allowed for snapshot. This is the maximum
          * value that applications can set to {@link #setZoom(int)}.
+         * Applications should call {@link #isZoomSupported} before using this
+         * method. This value may change in different preview size. Applications
+         * should call this again after setting preview size.
          *
          * @return the maximum zoom value supported by the camera.
-         * @hide
          */
         public int getMaxZoom() {
-            return getInt("max-zoom");
+            return getInt(KEY_MAX_ZOOM, 0);
         }
 
         /**
-         * Gets the zoom factors of all zoom values.
+         * Gets the zoom ratios of all zoom values. Applications should check
+         * {@link #isZoomSupported} before using this method.
          *
-         * @return the zoom factors in 1/100 increments. Ex: a zoom of 3.2x is
-         *         returned as 320. Accuracy of the value is dependent on the
-         *         hardware implementation. The first element of the list is the
-         *         zoom factor of first zoom value. If the first zoom value is
-         *         0, the zoom factor should be 100. The last element is the
-         *         zoom factor of zoom value {@link #getMaxZoom}.
-         * @hide
+         * @return the zoom ratios in 1/100 increments. Ex: a zoom of 3.2x is
+         *         returned as 320. The number of elements is {@link
+         *         #getMaxZoom} + 1. The list is sorted from small to large. The
+         *         first element is always 100. The last element is the zoom
+         *         ratio of the maximum zoom value.
          */
-        public List<Integer> getZoomFactors() {
-            return splitInt(get("zoom-factors"));
+        public List<Integer> getZoomRatios() {
+            return splitInt(get(KEY_ZOOM_RATIOS));
         }
 
         /**
@@ -1672,11 +1684,10 @@
          * this before using other smooth zoom methods.
          *
          * @return true if smooth zoom is supported.
-         * @hide
          */
         public boolean isSmoothZoomSupported() {
-            String str = get("smooth-zoom-supported");
-            return "true".equals(str);
+            String str = get(KEY_SMOOTH_ZOOM_SUPPORTED);
+            return TRUE.equals(str);
         }
 
         // Splits a comma delimited string to an ArrayList of String.
diff --git a/core/java/android/provider/Browser.java b/core/java/android/provider/Browser.java
index f7c3148..10b9371 100644
--- a/core/java/android/provider/Browser.java
+++ b/core/java/android/provider/Browser.java
@@ -145,14 +145,6 @@
     }
 
     /**
-     * Stores a String extra in an {@link Intent} representing the title of a
-     * page to share.  When receiving an {@link Intent#ACTION_SEND} from the
-     * Browser, use this to access the title.
-     * @hide
-     */
-    public final static String EXTRA_SHARE_TITLE = "share_title";
-
-    /**
      * Stores a Bitmap extra in an {@link Intent} representing the screenshot of
      * a page to share.  When receiving an {@link Intent#ACTION_SEND} from the
      * Browser, use this to access the screenshot.
diff --git a/core/java/android/provider/Calendar.java b/core/java/android/provider/Calendar.java
index fbaf5f6..509317d 100644
--- a/core/java/android/provider/Calendar.java
+++ b/core/java/android/provider/Calendar.java
@@ -168,10 +168,13 @@
         public static final String _SYNC_VERSION = "_sync_version";
 
         /**
-         * Used in temporary provider while syncing, always NULL for rows in persistent providers.
+         * For use by sync adapter at its discretion; not modified by CalendarProvider
+         * Note that this column was formerly named _SYNC_LOCAL_ID.  We are using it to avoid a
+         * schema change.
+         * TODO Replace this with something more general in the future.
          * <P>Type: INTEGER (long)</P>
          */
-        public static final String _SYNC_LOCAL_ID = "_sync_local_id";
+        public static final String _SYNC_DATA = "_sync_local_id";
 
         /**
          * Used only in persistent providers, and only during merging.
@@ -690,7 +693,7 @@
                 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, GUESTS_CAN_SEE_GUESTS);
                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ORGANIZER);
                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, _SYNC_ID);
-                DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, _SYNC_LOCAL_ID);
+                DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, _SYNC_DATA);
                 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, _SYNC_DIRTY);
                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, _SYNC_VERSION);
                 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, DELETED);
@@ -803,123 +806,6 @@
             return null;
         }
 
-        public static final Uri insertVEvent(ContentResolver cr,
-            ICalendar.Component event, long calendarId, int status,
-            ContentValues values) {
-
-            // TODO: define VEVENT component names as constants in some
-            // appropriate class (ICalendar.Component?).
-
-            values.clear();
-
-            // title
-            String title = extractValue(event, "SUMMARY");
-            if (TextUtils.isEmpty(title)) {
-                if (Config.LOGD) {
-                    Log.d(TAG, "No SUMMARY provided for event.  "
-                            + "Cannot import.");
-                }
-                return null;
-            }
-            values.put(TITLE, title);
-
-            // status
-            values.put(STATUS, status);
-
-            // description
-            String description = extractValue(event, "DESCRIPTION");
-            if (!TextUtils.isEmpty(description)) {
-                values.put(DESCRIPTION, description);
-            }
-
-            // where
-            String where = extractValue(event, "LOCATION");
-            if (!TextUtils.isEmpty(where)) {
-                values.put(EVENT_LOCATION, where);
-            }
-
-            // Calendar ID
-            values.put(CALENDAR_ID, calendarId);
-
-            boolean timesSet = false;
-
-            // TODO: deal with VALARMs
-
-            // dtstart & dtend
-            Time time = new Time(Time.TIMEZONE_UTC);
-            String dtstart = null;
-            String dtend = null;
-            String duration = null;
-            ICalendar.Property dtstartProp = event.getFirstProperty("DTSTART");
-            // TODO: handle "floating" timezone (no timezone specified).
-            if (dtstartProp != null) {
-                dtstart = dtstartProp.getValue();
-                if (!TextUtils.isEmpty(dtstart)) {
-                    ICalendar.Parameter tzidParam =
-                            dtstartProp.getFirstParameter("TZID");
-                    if (tzidParam != null && tzidParam.value != null) {
-                        time.clear(tzidParam.value);
-                    }
-                    try {
-                        time.parse(dtstart);
-                    } catch (Exception e) {
-                        if (Config.LOGD) {
-                            Log.d(TAG, "Cannot parse dtstart " + dtstart, e);
-                        }
-                        return null;
-                    }
-                    if (time.allDay) {
-                        values.put(ALL_DAY, 1);
-                    }
-                    values.put(DTSTART, time.toMillis(false /* use isDst */));
-                    values.put(EVENT_TIMEZONE, time.timezone);
-                }
-
-                ICalendar.Property dtendProp = event.getFirstProperty("DTEND");
-                if (dtendProp != null) {
-                    dtend = dtendProp.getValue();
-                    if (!TextUtils.isEmpty(dtend)) {
-                        // TODO: make sure the timezones are the same for
-                        // start, end.
-                        try {
-                            time.parse(dtend);
-                        } catch (Exception e) {
-                            if (Config.LOGD) {
-                                Log.d(TAG, "Cannot parse dtend " + dtend, e);
-                            }
-                            return null;
-                        }
-                        values.put(DTEND, time.toMillis(false /* use isDst */));
-                    }
-                } else {
-                    // look for a duration
-                    ICalendar.Property durationProp =
-                            event.getFirstProperty("DURATION");
-                    if (durationProp != null) {
-                        duration = durationProp.getValue();
-                        if (!TextUtils.isEmpty(duration)) {
-                            // TODO: check that it is valid?
-                            values.put(DURATION, duration);
-                        }
-                    }
-                }
-            }
-            if (TextUtils.isEmpty(dtstart) ||
-                    (TextUtils.isEmpty(dtend) && TextUtils.isEmpty(duration))) {
-                if (Config.LOGD) {
-                    Log.d(TAG, "No DTSTART or DTEND/DURATION defined.");
-                }
-                return null;
-            }
-
-            // rrule
-            if (!RecurrenceSet.populateContentValues(event, values)) {
-                return null;
-            }
-
-            return cr.insert(CONTENT_URI, values);
-        }
-
         /**
          * The content:// style URL for this table
          */
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 081cf32..18e2647 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -1279,6 +1279,17 @@
             "notifications_use_ring_volume";
 
         /**
+         * Whether silent mode should allow vibration feedback. This is used
+         * internally in AudioService and the Sound settings activity to
+         * coordinate decoupling of vibrate and silent modes. This setting
+         * will likely be removed in a future release with support for
+         * audio/vibe feedback profiles.
+         *
+         * @hide
+         */
+        public static final String VIBRATE_IN_SILENT = "vibrate_in_silent";
+
+        /**
          * The mapping of stream type (integer) to its setting.
          */
         public static final String[] VOLUME_SETTINGS = {
diff --git a/core/java/android/view/Surface.java b/core/java/android/view/Surface.java
index b85667b..183fce3 100644
--- a/core/java/android/view/Surface.java
+++ b/core/java/android/view/Surface.java
@@ -182,7 +182,18 @@
             int pid, int display, int w, int h, int format, int flags)
         throws OutOfResourcesException {
         mCanvas = new CompatibleCanvas();
-        init(s,pid,display,w,h,format,flags);
+        init(s,pid,null,display,w,h,format,flags);
+    }
+
+    /**
+     * create a surface with a name
+     * {@hide}
+     */
+    public Surface(SurfaceSession s,
+            int pid, String name, int display, int w, int h, int format, int flags)
+        throws OutOfResourcesException {
+        mCanvas = new CompatibleCanvas();
+        init(s,pid,name,display,w,h,format,flags);
     }
 
     /**
@@ -400,7 +411,7 @@
     }
     
     private native void init(SurfaceSession s,
-            int pid, int display, int w, int h, int format, int flags)
+            int pid, String name, int display, int w, int h, int format, int flags)
             throws OutOfResourcesException;
 
     private native void init(Parcel source);
diff --git a/core/java/android/widget/ImageView.java b/core/java/android/widget/ImageView.java
index 233ce30..c81a907 100644
--- a/core/java/android/widget/ImageView.java
+++ b/core/java/android/widget/ImageView.java
@@ -183,6 +183,7 @@
             int scale = alpha + (alpha >> 7);
             if (mViewAlphaScale != scale) {
                 mViewAlphaScale = scale;
+                mColorMod = true;
                 applyColorMod();
             }
             return true;
diff --git a/core/java/android/widget/TabHost.java b/core/java/android/widget/TabHost.java
index d4d9063..02cd6a8 100644
--- a/core/java/android/widget/TabHost.java
+++ b/core/java/android/widget/TabHost.java
@@ -204,7 +204,7 @@
         // If this is a custom view, then do not draw the bottom strips for
         // the tab indicators.
         if (tabSpec.mIndicatorStrategy instanceof ViewIndicatorStrategy) {
-            mTabWidget.setDrawBottomStrips(false);
+            mTabWidget.setStripEnabled(false);
         }
         mTabWidget.addView(tabIndicator);
         mTabSpecs.add(tabSpec);
diff --git a/core/java/android/widget/TabWidget.java b/core/java/android/widget/TabWidget.java
index aa47e6d..3328c13 100644
--- a/core/java/android/widget/TabWidget.java
+++ b/core/java/android/widget/TabWidget.java
@@ -16,6 +16,7 @@
 
 package android.widget;
 
+import android.R;
 import android.content.Context;
 import android.content.res.Resources;
 import android.content.res.TypedArray;
@@ -28,8 +29,6 @@
 import android.view.ViewGroup;
 import android.view.View.OnFocusChangeListener;
 
-
-
 /**
  *
  * Displays a list of tab labels representing each page in the parent's tab
@@ -41,17 +40,26 @@
  * handler, and manage callbacks. You might call this object to iterate the list
  * of tabs, or to tweak the layout of the tab list, but most methods should be
  * called on the containing TabHost object.
+ * 
+ * @attr ref android.R.styleable#TabWidget_divider
+ * @attr ref android.R.styleable#TabWidget_stripEnabled
+ * @attr ref android.R.styleable#TabWidget_stripLeft
+ * @attr ref android.R.styleable#TabWidget_stripRight
  */
 public class TabWidget extends LinearLayout implements OnFocusChangeListener {
-
-
     private OnTabSelectionChanged mSelectionChangedListener;
+
     private int mSelectedTab = 0;
+
     private Drawable mBottomLeftStrip;
     private Drawable mBottomRightStrip;
-    private boolean mStripMoved;
-    private Drawable mDividerDrawable;
+
     private boolean mDrawBottomStrips = true;
+    private boolean mStripMoved;
+
+    private Drawable mDividerDrawable;
+
+    private final Rect mBounds = new Rect();
 
     public TabWidget(Context context) {
         this(context, null);
@@ -63,13 +71,19 @@
 
     public TabWidget(Context context, AttributeSet attrs, int defStyle) {
         super(context, attrs);
-        initTabWidget();
 
         TypedArray a =
             context.obtainStyledAttributes(attrs, com.android.internal.R.styleable.TabWidget,
                     defStyle, 0);
 
+        mDrawBottomStrips = a.getBoolean(R.styleable.TabWidget_stripEnabled, true);
+        mDividerDrawable = a.getDrawable(R.styleable.TabWidget_divider);
+        mBottomLeftStrip = a.getDrawable(R.styleable.TabWidget_stripLeft);
+        mBottomRightStrip = a.getDrawable(R.styleable.TabWidget_stripRight);
+
         a.recycle();
+
+        initTabWidget();
     }
 
     @Override
@@ -100,19 +114,26 @@
         
         if (context.getApplicationInfo().targetSdkVersion <= Build.VERSION_CODES.DONUT) {
             // Donut apps get old color scheme
-            mBottomLeftStrip = resources.getDrawable(
-                    com.android.internal.R.drawable.tab_bottom_left_v4);
-            mBottomRightStrip = resources.getDrawable(
-                    com.android.internal.R.drawable.tab_bottom_right_v4); 
+            if (mBottomLeftStrip == null) {
+                mBottomLeftStrip = resources.getDrawable(
+                        com.android.internal.R.drawable.tab_bottom_left_v4);
+            }
+            if (mBottomRightStrip == null) {
+                mBottomRightStrip = resources.getDrawable(
+                        com.android.internal.R.drawable.tab_bottom_right_v4);
+            }
         } else {
             // Use modern color scheme for Eclair and beyond
-            mBottomLeftStrip = resources.getDrawable(
-                    com.android.internal.R.drawable.tab_bottom_left);
-            mBottomRightStrip = resources.getDrawable(
-                    com.android.internal.R.drawable.tab_bottom_right); 
+            if (mBottomLeftStrip == null) {
+                mBottomLeftStrip = resources.getDrawable(
+                        com.android.internal.R.drawable.tab_bottom_left);
+            }
+            if (mBottomRightStrip == null) {
+                mBottomRightStrip = resources.getDrawable(
+                        com.android.internal.R.drawable.tab_bottom_right);
+            }
         }
 
-
         // Deal with focus, as we don't want the focus to go by default
         // to a tab other than the current tab
         setFocusable(true);
@@ -156,6 +177,8 @@
      */
     public void setDividerDrawable(Drawable drawable) {
         mDividerDrawable = drawable;
+        requestLayout();
+        invalidate();
     }
 
     /**
@@ -165,17 +188,73 @@
      */
     public void setDividerDrawable(int resId) {
         mDividerDrawable = mContext.getResources().getDrawable(resId);
+        requestLayout();
+        invalidate();
+    }
+    
+    /**
+     * Sets the drawable to use as the left part of the strip below the
+     * tab indicators.
+     * @param drawable the left strip drawable
+     */
+    public void setLeftStripDrawable(Drawable drawable) {
+        mBottomLeftStrip = drawable;
+        requestLayout();
+        invalidate();
     }
 
     /**
+     * Sets the drawable to use as the left part of the strip below the
+     * tab indicators.
+     * @param resId the resource identifier of the drawable to use as the
+     * left strip drawable
+     */
+    public void setLeftStripDrawable(int resId) {
+        mBottomLeftStrip = mContext.getResources().getDrawable(resId);
+        requestLayout();
+        invalidate();
+    }
+
+    /**
+     * Sets the drawable to use as the left part of the strip below the
+     * tab indicators.
+     * @param drawable the left strip drawable
+     */
+    public void setRightStripDrawable(Drawable drawable) {
+        mBottomLeftStrip = drawable;
+        requestLayout();
+        invalidate();    }
+
+    /**
+     * Sets the drawable to use as the left part of the strip below the
+     * tab indicators.
+     * @param resId the resource identifier of the drawable to use as the
+     * left strip drawable
+     */
+    public void setRightStripDrawable(int resId) {
+        mBottomLeftStrip = mContext.getResources().getDrawable(resId);
+        requestLayout();
+        invalidate();
+    }
+    
+    /**
      * Controls whether the bottom strips on the tab indicators are drawn or
      * not.  The default is to draw them.  If the user specifies a custom
      * view for the tab indicators, then the TabHost class calls this method
      * to disable drawing of the bottom strips.
-     * @param drawBottomStrips true if the bottom strips should be drawn.
+     * @param stripEnabled true if the bottom strips should be drawn.
      */
-    void setDrawBottomStrips(boolean drawBottomStrips) {
-        mDrawBottomStrips = drawBottomStrips;
+    public void setStripEnabled(boolean stripEnabled) {
+        mDrawBottomStrips = stripEnabled;
+        invalidate();
+    }
+
+    /**
+     * Indicates whether the bottom strips on the tab indicators are drawn
+     * or not.
+     */
+    public boolean isStripEnabled() {
+        return mDrawBottomStrips;
     }
 
     @Override
@@ -201,33 +280,28 @@
             return;
         }
 
-        View selectedChild = getChildTabViewAt(mSelectedTab);
+        final View selectedChild = getChildTabViewAt(mSelectedTab);
 
-        mBottomLeftStrip.setState(selectedChild.getDrawableState());
-        mBottomRightStrip.setState(selectedChild.getDrawableState());
+        final Drawable leftStrip = mBottomLeftStrip;
+        final Drawable rightStrip = mBottomRightStrip;
+
+        leftStrip.setState(selectedChild.getDrawableState());
+        rightStrip.setState(selectedChild.getDrawableState());
 
         if (mStripMoved) {
-            Rect selBounds = new Rect(); // Bounds of the selected tab indicator
-            selBounds.left = selectedChild.getLeft();
-            selBounds.right = selectedChild.getRight();
+            final Rect bounds = mBounds;
+            bounds.left = selectedChild.getLeft();
+            bounds.right = selectedChild.getRight();
             final int myHeight = getHeight();
-            mBottomLeftStrip.setBounds(
-                    Math.min(0, selBounds.left
-                                 - mBottomLeftStrip.getIntrinsicWidth()),
-                    myHeight - mBottomLeftStrip.getIntrinsicHeight(),
-                    selBounds.left,
-                    getHeight());
-            mBottomRightStrip.setBounds(
-                    selBounds.right,
-                    myHeight - mBottomRightStrip.getIntrinsicHeight(),
-                    Math.max(getWidth(),
-                            selBounds.right + mBottomRightStrip.getIntrinsicWidth()),
-                    myHeight);
+            leftStrip.setBounds(Math.min(0, bounds.left - leftStrip.getIntrinsicWidth()),
+                    myHeight - leftStrip.getIntrinsicHeight(), bounds.left, myHeight);
+            rightStrip.setBounds(bounds.right, myHeight - rightStrip.getIntrinsicHeight(),
+                    Math.max(getWidth(), bounds.right + rightStrip.getIntrinsicWidth()), myHeight);
             mStripMoved = false;
         }
 
-        mBottomLeftStrip.draw(canvas);
-        mBottomRightStrip.draw(canvas);
+        leftStrip.draw(canvas);
+        rightStrip.draw(canvas);
     }
 
     /**
diff --git a/core/jni/android_database_SQLiteDatabase.cpp b/core/jni/android_database_SQLiteDatabase.cpp
index 26d0e86..0bee8c0 100644
--- a/core/jni/android_database_SQLiteDatabase.cpp
+++ b/core/jni/android_database_SQLiteDatabase.cpp
@@ -63,6 +63,26 @@
 
 static jfieldID offset_db_handle;
 
+static void sqlLogger(void *databaseName, int iErrCode, const char *zMsg) {
+    LOGI("sqlite returned: error code = %d, msg = %s\n", iErrCode, zMsg);
+}
+
+// register the logging func on sqlite. needs to be done BEFORE any sqlite3 func is called.
+static void registerLoggingFunc() {
+    static bool loggingFuncSet = false;
+    if (loggingFuncSet) {
+        return;
+    }
+
+    LOGV("Registering sqlite logging func \n");
+    //int err = sqlite3_config(SQLITE_CONFIG_LOG, &sqlLogger, 0);
+    //if (err != SQLITE_OK) {
+        //LOGE("sqlite_config failed error_code = %d. THIS SHOULD NEVER occur.\n", err);
+        //#return;
+    //}
+    loggingFuncSet = true;
+}
+
 /* public native void dbopen(String path, int flags, String locale); */
 static void dbopen(JNIEnv* env, jobject object, jstring pathString, jint flags)
 {
@@ -72,6 +92,9 @@
     char const * path8 = env->GetStringUTFChars(pathString, NULL);
     int sqliteFlags;
 
+    // register the logging func on sqlite. needs to be done BEFORE any sqlite3 func is called.
+    registerLoggingFunc();
+
     // convert our flags into the sqlite flags
     if (flags & CREATE_IF_NECESSARY) {
         sqliteFlags = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE;
@@ -143,7 +166,21 @@
     if (handle != NULL) sqlite3_close(handle);
 }
 
-void sqlTrace(void *databaseName, const char *sql) {
+static char *getDatabaseName(JNIEnv* env, sqlite3 * handle, jstring databaseName) {
+    char const *path = env->GetStringUTFChars(databaseName, NULL);
+    if (path == NULL) {
+        LOGE("Failure in getDatabaseName(). VM ran out of memory?\n");
+        return NULL; // VM would have thrown OutOfMemoryError
+    }
+    int len = strlen(path);
+    char *dbNameStr = (char *)malloc(len + 1);
+    strncpy(dbNameStr, path, len);
+    dbNameStr[len-1] = NULL;
+    env->ReleaseStringUTFChars(databaseName, path);
+    return dbNameStr;
+}
+
+static void sqlTrace(void *databaseName, const char *sql) {
     LOGI("sql_statement|%s|%s\n", (char *)databaseName, sql);
 }
 
@@ -151,21 +188,10 @@
 static void enableSqlTracing(JNIEnv* env, jobject object, jstring databaseName)
 {
     sqlite3 * handle = (sqlite3 *)env->GetIntField(object, offset_db_handle);
-    char const *path = env->GetStringUTFChars(databaseName, NULL);
-    if (path == NULL) {
-        LOGE("Failure in enableSqlTracing(). VM ran out of memory?\n");
-        return; // VM would have thrown OutOfMemoryError
-    }
-    int len = strlen(path);
-    char *traceFuncArg = (char *)malloc(len + 1);
-    strncpy(traceFuncArg, path, len);
-    traceFuncArg[len-1] = NULL;
-    env->ReleaseStringUTFChars(databaseName, path);
-    sqlite3_trace(handle, &sqlTrace, (void *)traceFuncArg);
-    LOGI("will be printing all sql statements executed on database = %s\n", traceFuncArg);
+    sqlite3_trace(handle, &sqlTrace, (void *)getDatabaseName(env, handle, databaseName));
 }
 
-void sqlProfile(void *databaseName, const char *sql, sqlite3_uint64 tm) {
+static void sqlProfile(void *databaseName, const char *sql, sqlite3_uint64 tm) {
     double d = tm/1000000.0;
     LOGI("elapsedTime4Sql|%s|%.3f ms|%s\n", (char *)databaseName, d, sql);
 }
@@ -174,21 +200,10 @@
 static void enableSqlProfiling(JNIEnv* env, jobject object, jstring databaseName)
 {
     sqlite3 * handle = (sqlite3 *)env->GetIntField(object, offset_db_handle);
-    char const *path = env->GetStringUTFChars(databaseName, NULL);
-    if (path == NULL) {
-        LOGE("Failure in enableSqlProfiling(). VM ran out of memory?\n");
-        return; // VM would have thrown OutOfMemoryError
-    }
-    int len = strlen(path);
-    char *traceFuncArg = (char *)malloc(len + 1);
-    strncpy(traceFuncArg, path, len);
-    traceFuncArg[len-1] = NULL;
-    env->ReleaseStringUTFChars(databaseName, path);
-    sqlite3_profile(handle, &sqlProfile, (void *)traceFuncArg);
-    LOGI("will be printing execution time of all sql statements executed on database = %s\n",
-            traceFuncArg);
+    sqlite3_profile(handle, &sqlProfile, (void *)getDatabaseName(env, handle, databaseName));
 }
 
+
 /* public native void close(); */
 static void dbclose(JNIEnv* env, jobject object)
 {
diff --git a/core/jni/android_view_Surface.cpp b/core/jni/android_view_Surface.cpp
index 723205a..060ca50 100644
--- a/core/jni/android_view_Surface.cpp
+++ b/core/jni/android_view_Surface.cpp
@@ -185,7 +185,8 @@
 
 static void Surface_init(
         JNIEnv* env, jobject clazz, 
-        jobject session, jint pid, jint dpy, jint w, jint h, jint format, jint flags)
+        jobject session,
+        jint pid, jstring jname, jint dpy, jint w, jint h, jint format, jint flags)
 {
     if (session == NULL) {
         doThrow(env, "java/lang/NullPointerException");
@@ -195,7 +196,16 @@
     SurfaceComposerClient* client =
             (SurfaceComposerClient*)env->GetIntField(session, sso.client);
 
-    sp<SurfaceControl> surface(client->createSurface(pid, dpy, w, h, format, flags));
+    sp<SurfaceControl> surface;
+    if (jname == NULL) {
+        surface = client->createSurface(pid, dpy, w, h, format, flags);
+    } else {
+        const jchar* str = env->GetStringCritical(jname, 0);
+        const String8 name(str, env->GetStringLength(jname));
+        env->ReleaseStringCritical(jname, str);
+        surface = client->createSurface(pid, name, dpy, w, h, format, flags);
+    }
+
     if (surface == 0) {
         doThrow(env, OutOfResourcesException);
         return;
@@ -620,7 +630,7 @@
 
 static JNINativeMethod gSurfaceMethods[] = {
     {"nativeClassInit",     "()V",  (void*)nativeClassInit },
-    {"init",                "(Landroid/view/SurfaceSession;IIIIII)V",  (void*)Surface_init },
+    {"init",                "(Landroid/view/SurfaceSession;ILjava/lang/String;IIIII)V",  (void*)Surface_init },
     {"init",                "(Landroid/os/Parcel;)V",  (void*)Surface_initParcel },
     {"destroy",             "()V",  (void*)Surface_destroy },
     {"release",             "()V",  (void*)Surface_release },
diff --git a/core/res/res/drawable-hdpi/ic_jog_dial_vibrate_on.png b/core/res/res/drawable-hdpi/ic_jog_dial_vibrate_on.png
new file mode 100644
index 0000000..86caa07
--- /dev/null
+++ b/core/res/res/drawable-hdpi/ic_jog_dial_vibrate_on.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/ic_jog_dial_vibrate_on.png b/core/res/res/drawable-mdpi/ic_jog_dial_vibrate_on.png
new file mode 100644
index 0000000..9aa9b13
--- /dev/null
+++ b/core/res/res/drawable-mdpi/ic_jog_dial_vibrate_on.png
Binary files differ
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index 79bd41e..1ced121 100644
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -1867,6 +1867,14 @@
         <attr name="layout_span" format="integer" />
     </declare-styleable>
     <declare-styleable name="TabWidget">
+        <!-- Drawable used to draw the divider between tabs. -->
+        <attr name="divider" />
+        <!-- Determines whether the strip under the tab indicators is drawn or not. -->
+        <attr name="stripEnabled" format="boolean" />
+        <!-- Drawable used to draw the left part of the strip underneath the tabs. -->
+        <attr name="stripLeft" format="reference" />
+        <!-- Drawable used to draw the right part of the strip underneath the tabs. -->
+        <attr name="stripRight" format="reference" />
     </declare-styleable>
     <declare-styleable name="TextAppearance">
         <!-- Text color. -->
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index 5da8e85..36a8f5b 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -1232,6 +1232,9 @@
   <public type="attr" name="webTextViewStyle" id="0x010102b9" />
   <public type="attr" name="overscrollMode" id="0x010102ba" />
   <public type="attr" name="restoreAnyVersion" id="0x010102bb" />
+  <public type="attr" name="stripLeft" id="0x010102bc" />
+  <public type="attr" name="stripRight" id="0x010102bd" />
+  <public type="attr" name="stripEnabled" id="0x010102be" />
 
   <public type="anim" name="cycle_interpolator" id="0x010a000c" />
     
diff --git a/graphics/java/android/renderscript/Allocation.java b/graphics/java/android/renderscript/Allocation.java
index e5cf38e..17c0778 100644
--- a/graphics/java/android/renderscript/Allocation.java
+++ b/graphics/java/android/renderscript/Allocation.java
@@ -32,6 +32,7 @@
  **/
 public class Allocation extends BaseObj {
     Type mType;
+    Bitmap mBitmap;
 
     Allocation(int id, RenderScript rs, Type t) {
         super(rs);
@@ -45,7 +46,12 @@
 
     public void uploadToTexture(int baseMipLevel) {
         mRS.validate();
-        mRS.nAllocationUploadToTexture(mID, baseMipLevel);
+        mRS.nAllocationUploadToTexture(mID, false, baseMipLevel);
+    }
+
+    public void uploadToTexture(boolean genMips, int baseMipLevel) {
+        mRS.validate();
+        mRS.nAllocationUploadToTexture(mID, genMips, baseMipLevel);
     }
 
     public void uploadToBufferObject() {
@@ -257,15 +263,58 @@
         return new Allocation(id, rs, t);
     }
 
+    static private Element elementFromBitmap(RenderScript rs, Bitmap b) {
+        final Bitmap.Config bc = b.getConfig();
+        if (bc == Bitmap.Config.ALPHA_8) {
+            return Element.A_8(rs);
+        }
+        if (bc == Bitmap.Config.ARGB_4444) {
+            return Element.RGBA_4444(rs);
+        }
+        if (bc == Bitmap.Config.ARGB_8888) {
+            return Element.RGBA_8888(rs);
+        }
+        if (bc == Bitmap.Config.RGB_565) {
+            return Element.RGB_565(rs);
+        }
+        throw new IllegalStateException("Bad bitmap type.");
+    }
+
+    static private Type typeFromBitmap(RenderScript rs, Bitmap b) {
+        Element e = elementFromBitmap(rs, b);
+        Type.Builder tb = new Type.Builder(rs, e);
+        tb.add(Dimension.X, b.getWidth());
+        tb.add(Dimension.Y, b.getHeight());
+        return tb.create();
+    }
+
     static public Allocation createFromBitmap(RenderScript rs, Bitmap b, Element dstFmt, boolean genMips)
         throws IllegalArgumentException {
 
         rs.validate();
+        Type t = typeFromBitmap(rs, b);
+
         int id = rs.nAllocationCreateFromBitmap(dstFmt.mID, genMips, b);
         if(id == 0) {
             throw new IllegalStateException("Load failed.");
         }
-        return new Allocation(id, rs, null);
+        return new Allocation(id, rs, t);
+    }
+
+    static public Allocation createBitmapRef(RenderScript rs, Bitmap b)
+        throws IllegalArgumentException {
+
+        rs.validate();
+        Type t = typeFromBitmap(rs, b);
+
+        int id = rs.nAllocationCreateBitmapRef(t.getID(), b);
+        if(id == 0) {
+            throw new IllegalStateException("Load failed.");
+        }
+
+        Allocation a = new Allocation(id, rs, t);
+        a.mBitmap = b;
+        return a;
     }
 
     static Allocation createFromBitmapBoxed(RenderScript rs, Bitmap b, Element dstFmt, boolean genMips)
diff --git a/graphics/java/android/renderscript/RenderScript.java b/graphics/java/android/renderscript/RenderScript.java
index 84b1a70..a935243 100644
--- a/graphics/java/android/renderscript/RenderScript.java
+++ b/graphics/java/android/renderscript/RenderScript.java
@@ -98,10 +98,11 @@
 
     native int  nAllocationCreateTyped(int type);
     native int  nAllocationCreateFromBitmap(int dstFmt, boolean genMips, Bitmap bmp);
+    native int  nAllocationCreateBitmapRef(int type, Bitmap bmp);
     native int  nAllocationCreateFromBitmapBoxed(int dstFmt, boolean genMips, Bitmap bmp);
     native int  nAllocationCreateFromAssetStream(int dstFmt, boolean genMips, int assetStream);
 
-    native void nAllocationUploadToTexture(int alloc, int baseMioLevel);
+    native void nAllocationUploadToTexture(int alloc, boolean genMips, int baseMioLevel);
     native void nAllocationUploadToBufferObject(int alloc);
 
     native void nAllocationSubData1D(int id, int off, int count, int[] d, int sizeBytes);
diff --git a/graphics/jni/android_renderscript_RenderScript.cpp b/graphics/jni/android_renderscript_RenderScript.cpp
index 0ffdf71..d8e0393 100644
--- a/graphics/jni/android_renderscript_RenderScript.cpp
+++ b/graphics/jni/android_renderscript_RenderScript.cpp
@@ -444,11 +444,11 @@
 }
 
 static void
-nAllocationUploadToTexture(JNIEnv *_env, jobject _this, jint a, jint mip)
+nAllocationUploadToTexture(JNIEnv *_env, jobject _this, jint a, jboolean genMip, jint mip)
 {
     RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
-    LOG_API("nAllocationUploadToTexture, con(%p), a(%p), mip(%i)", con, (RsAllocation)a, mip);
-    rsAllocationUploadToTexture(con, (RsAllocation)a, mip);
+    LOG_API("nAllocationUploadToTexture, con(%p), a(%p), genMip(%i), mip(%i)", con, (RsAllocation)a, genMip, mip);
+    rsAllocationUploadToTexture(con, (RsAllocation)a, genMip, mip);
 }
 
 static void
@@ -501,6 +501,26 @@
     return 0;
 }
 
+static void ReleaseBitmapCallback(void *bmp)
+{
+    SkBitmap const * nativeBitmap = (SkBitmap const *)bmp;
+    nativeBitmap->unlockPixels();
+}
+
+static int
+nAllocationCreateBitmapRef(JNIEnv *_env, jobject _this, jint type, jobject jbitmap)
+{
+    RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
+    SkBitmap * nativeBitmap =
+            (SkBitmap *)_env->GetIntField(jbitmap, gNativeBitmapID);
+
+
+    nativeBitmap->lockPixels();
+    void* ptr = nativeBitmap->getPixels();
+    jint id = (jint)rsAllocationCreateBitmapRef(con, (RsType)type, ptr, nativeBitmap, ReleaseBitmapCallback);
+    return id;
+}
+
 static int
 nAllocationCreateFromAssetStream(JNIEnv *_env, jobject _this, jint dstFmt, jboolean genMips, jint native_asset)
 {
@@ -1367,9 +1387,10 @@
 
 {"nAllocationCreateTyped",         "(I)I",                                 (void*)nAllocationCreateTyped },
 {"nAllocationCreateFromBitmap",    "(IZLandroid/graphics/Bitmap;)I",       (void*)nAllocationCreateFromBitmap },
+{"nAllocationCreateBitmapRef",     "(ILandroid/graphics/Bitmap;)I",        (void*)nAllocationCreateBitmapRef },
 {"nAllocationCreateFromBitmapBoxed","(IZLandroid/graphics/Bitmap;)I",      (void*)nAllocationCreateFromBitmapBoxed },
 {"nAllocationCreateFromAssetStream","(IZI)I",                              (void*)nAllocationCreateFromAssetStream },
-{"nAllocationUploadToTexture",     "(II)V",                                (void*)nAllocationUploadToTexture },
+{"nAllocationUploadToTexture",     "(IZI)V",                               (void*)nAllocationUploadToTexture },
 {"nAllocationUploadToBufferObject","(I)V",                                 (void*)nAllocationUploadToBufferObject },
 {"nAllocationSubData1D",           "(III[II)V",                            (void*)nAllocationSubData1D_i },
 {"nAllocationSubData1D",           "(III[SI)V",                            (void*)nAllocationSubData1D_s },
diff --git a/include/camera/CameraParameters.h b/include/camera/CameraParameters.h
index 9df2695..752afc2 100644
--- a/include/camera/CameraParameters.h
+++ b/include/camera/CameraParameters.h
@@ -201,7 +201,29 @@
     // 0.3333, EV is -2.
     // Example value: "0.333333333" or "0.5". Read only.
     static const char KEY_EXPOSURE_COMPENSATION_STEP[];
-
+    // Current zoom value.
+    // Example value: "0" or "6". Read/write.
+    static const char KEY_ZOOM[];
+    // Maximum zoom value.
+    // Example value: "6". Read only.
+    static const char KEY_MAX_ZOOM[];
+    // The zoom ratios of all zoom values. The zoom ratio is in 1/100
+    // increments. Ex: a zoom of 3.2x is returned as 320. The number of list
+    // elements is KEY_MAX_ZOOM + 1. The first element is always 100. The last
+    // element is the zoom ratio of zoom value KEY_MAX_ZOOM.
+    // Example value: "100,150,200,250,300,350,400". Read only.
+    static const char KEY_ZOOM_RATIOS[];
+    // Whether zoom is supported. Zoom is supported if the value is "true". Zoom
+    // is not supported if the value is not "true" or the key does not exist.
+    // Example value: "true". Read only.
+    static const char KEY_ZOOM_SUPPORTED[];
+    // Whether if smooth zoom is supported. Smooth zoom is supported if the
+    // value is "true". It is not supported if the value is not "true" or the
+    // key does not exist.
+    // See CAMERA_CMD_START_SMOOTH_ZOOM, CAMERA_CMD_STOP_SMOOTH_ZOOM, and
+    // CAMERA_MSG_ZOOM in frameworks/base/include/camera/Camera.h.
+    // Example value: "true". Read only.
+    static const char KEY_SMOOTH_ZOOM_SUPPORTED[];
 
     // Values for white balance settings.
     static const char WHITE_BALANCE_AUTO[];
diff --git a/include/surfaceflinger/ISurfaceFlingerClient.h b/include/surfaceflinger/ISurfaceFlingerClient.h
index 1fba162..d257645 100644
--- a/include/surfaceflinger/ISurfaceFlingerClient.h
+++ b/include/surfaceflinger/ISurfaceFlingerClient.h
@@ -61,6 +61,7 @@
 
     virtual sp<ISurface> createSurface( surface_data_t* data,
                                         int pid, 
+                                        const String8& name,
                                         DisplayID display,
                                         uint32_t w,
                                         uint32_t h,
diff --git a/include/surfaceflinger/SurfaceComposerClient.h b/include/surfaceflinger/SurfaceComposerClient.h
index 49e83c0..9d0f0cb 100644
--- a/include/surfaceflinger/SurfaceComposerClient.h
+++ b/include/surfaceflinger/SurfaceComposerClient.h
@@ -65,6 +65,7 @@
     //! Create a surface
     sp<SurfaceControl> createSurface(
             int pid,            // pid of the process the surface is for
+            const String8& name,// name of the surface
             DisplayID display,  // Display to create this surface on
             uint32_t w,         // width in pixel
             uint32_t h,         // height in pixel
@@ -72,6 +73,16 @@
             uint32_t flags = 0  // usage flags
     );
 
+    sp<SurfaceControl> createSurface(
+            int pid,            // pid of the process the surface is for
+            DisplayID display,  // Display to create this surface on
+            uint32_t w,         // width in pixel
+            uint32_t h,         // height in pixel
+            PixelFormat format, // pixel-format desired
+            uint32_t flags = 0  // usage flags
+    );
+
+
     // ------------------------------------------------------------------------
     // Composer parameters
     // All composer parameters must be changed within a transaction
diff --git a/libs/camera/CameraParameters.cpp b/libs/camera/CameraParameters.cpp
index 8439e2b..cf4cbfa 100644
--- a/libs/camera/CameraParameters.cpp
+++ b/libs/camera/CameraParameters.cpp
@@ -63,6 +63,11 @@
 const char CameraParameters::KEY_MAX_EXPOSURE_COMPENSATION[] = "max-exposure-compensation";
 const char CameraParameters::KEY_MIN_EXPOSURE_COMPENSATION[] = "min-exposure-compensation";
 const char CameraParameters::KEY_EXPOSURE_COMPENSATION_STEP[] = "exposure-compensation-step";
+const char CameraParameters::KEY_ZOOM[] = "zoom";
+const char CameraParameters::KEY_MAX_ZOOM[] = "max-zoom";
+const char CameraParameters::KEY_ZOOM_RATIOS[] = "zoom-ratios";
+const char CameraParameters::KEY_ZOOM_SUPPORTED[] = "zoom-supported";
+const char CameraParameters::KEY_SMOOTH_ZOOM_SUPPORTED[] = "smooth-zoom-supported";
 
 // Values for white balance settings.
 const char CameraParameters::WHITE_BALANCE_AUTO[] = "auto";
diff --git a/libs/rs/RenderScript.h b/libs/rs/RenderScript.h
index 02667d8..cd8361c 100644
--- a/libs/rs/RenderScript.h
+++ b/libs/rs/RenderScript.h
@@ -46,6 +46,8 @@
 typedef void * RsProgramFragmentStore;
 typedef void * RsProgramRaster;
 
+typedef void (* RsBitmapCallback_t)(void *);
+
 enum RsDeviceParam {
     RS_DEVICE_PARAM_FORCE_SOFTWARE_GL,
     RS_DEVICE_PARAM_COUNT
@@ -200,8 +202,9 @@
     RS_PRIMITIVE_TRIANGLE_FAN
 };
 
-
+#ifndef NO_RS_FUNCS
 #include "rsgApiFuncDecl.h"
+#endif
 
 #ifdef __cplusplus
 };
diff --git a/libs/rs/rs.spec b/libs/rs/rs.spec
index 10e5285..4d97c0f 100644
--- a/libs/rs/rs.spec
+++ b/libs/rs/rs.spec
@@ -90,6 +90,14 @@
 	ret RsAllocation
 	}
 
+AllocationCreateBitmapRef {
+	param RsType type
+	param void * bmpPtr
+	param void * callbackData
+	param RsBitmapCallback_t callback
+	ret RsAllocation
+	}
+
 AllocationCreateFromBitmap {
 	param uint32_t width
 	param uint32_t height
@@ -113,6 +121,7 @@
 
 AllocationUploadToTexture {
 	param RsAllocation alloc
+	param bool genMipMaps
 	param uint32_t baseMipLevel
 	}
 
diff --git a/libs/rs/rsAllocation.cpp b/libs/rs/rsAllocation.cpp
index 1ae2317..4e8278d 100644
--- a/libs/rs/rsAllocation.cpp
+++ b/libs/rs/rsAllocation.cpp
@@ -17,6 +17,7 @@
 #include "rsContext.h"
 
 #include <GLES/gl.h>
+#include <GLES2/gl2.h>
 #include <GLES/glext.h>
 
 using namespace android;
@@ -24,6 +25,27 @@
 
 Allocation::Allocation(Context *rsc, const Type *type) : ObjectBase(rsc)
 {
+    init(rsc, type);
+
+    mPtr = malloc(mType->getSizeBytes());
+    if (!mPtr) {
+        LOGE("Allocation::Allocation, alloc failure");
+    }
+}
+
+Allocation::Allocation(Context *rsc, const Type *type, void *bmp,
+                       void *callbackData, RsBitmapCallback_t callback)
+: ObjectBase(rsc)
+{
+    init(rsc, type);
+
+    mPtr = bmp;
+    mUserBitmapCallback = callback;
+    mUserBitmapCallbackData = callbackData;
+}
+
+void Allocation::init(Context *rsc, const Type *type)
+{
     mAllocFile = __FILE__;
     mAllocLine = __LINE__;
     mPtr = NULL;
@@ -42,17 +64,22 @@
     mBufferID = 0;
     mUploadDefered = false;
 
+    mUserBitmapCallback = NULL;
+    mUserBitmapCallbackData = NULL;
+
     mType.set(type);
     rsAssert(type);
-    mPtr = malloc(mType->getSizeBytes());
-    if (!mPtr) {
-        LOGE("Allocation::Allocation, alloc failure");
-    }
+
+    mPtr = NULL;
 }
 
 Allocation::~Allocation()
 {
-    free(mPtr);
+    if (mUserBitmapCallback != NULL) {
+        mUserBitmapCallback(mUserBitmapCallbackData);
+    } else {
+        free(mPtr);
+    }
     mPtr = NULL;
 
     if (mBufferID) {
@@ -88,12 +115,13 @@
     return false;
 }
 
-void Allocation::deferedUploadToTexture(const Context *rsc, uint32_t lodOffset)
+void Allocation::deferedUploadToTexture(const Context *rsc, bool genMipmap, uint32_t lodOffset)
 {
     rsAssert(lodOffset < mType->getLODCount());
     mIsTexture = true;
     mTextureLOD = lodOffset;
     mUploadDefered = true;
+    mTextureGenMipmap = !mType->getDimLOD() && genMipmap;
 }
 
 void Allocation::uploadToTexture(const Context *rsc)
@@ -138,6 +166,10 @@
                      adapt.getDimX(), adapt.getDimY(),
                      0, format, type, ptr);
     }
+    if (mTextureGenMipmap) {
+        glGenerateMipmap(GL_TEXTURE_2D);
+    }
+
 }
 
 void Allocation::deferedUploadToBufferObject(const Context *rsc)
@@ -316,10 +348,10 @@
     return rsi_AllocationCreateTyped(rsc, type);
 }
 
-void rsi_AllocationUploadToTexture(Context *rsc, RsAllocation va, uint32_t baseMipLevel)
+void rsi_AllocationUploadToTexture(Context *rsc, RsAllocation va, bool genmip, uint32_t baseMipLevel)
 {
     Allocation *alloc = static_cast<Allocation *>(va);
-    alloc->deferedUploadToTexture(rsc, baseMipLevel);
+    alloc->deferedUploadToTexture(rsc, genmip, baseMipLevel);
 }
 
 void rsi_AllocationUploadToBufferObject(Context *rsc, RsAllocation va)
@@ -480,6 +512,14 @@
     return 0;
 }
 
+RsAllocation rsi_AllocationCreateBitmapRef(Context *rsc, RsType vtype,
+                                           void *bmp, void *callbackData, RsBitmapCallback_t callback)
+{
+    const Type * type = static_cast<const Type *>(vtype);
+    Allocation * alloc = new Allocation(rsc, type, bmp, callbackData, callback);
+    alloc->incUserRef();
+    return alloc;
+}
 
 RsAllocation rsi_AllocationCreateFromBitmap(Context *rsc, uint32_t w, uint32_t h, RsElement _dst, RsElement _src,  bool genMips, const void *data)
 {
diff --git a/libs/rs/rsAllocation.h b/libs/rs/rsAllocation.h
index f0b2122..516f8b7 100644
--- a/libs/rs/rsAllocation.h
+++ b/libs/rs/rsAllocation.h
@@ -29,11 +29,12 @@
 {
     // The graphics equilivent of malloc.  The allocation contains a structure of elements.
 
-
 public:
     // By policy this allocation will hold a pointer to the type
     // but will not destroy it on destruction.
     Allocation(Context *rsc, const Type *);
+    Allocation(Context *rsc, const Type *, void *bmp, void *callbackData, RsBitmapCallback_t callback);
+
     virtual ~Allocation();
 
     void setCpuWritable(bool);
@@ -46,7 +47,7 @@
     void * getPtr() const {return mPtr;}
     const Type * getType() const {return mType.get();}
 
-    void deferedUploadToTexture(const Context *rsc, uint32_t lodOffset);
+    void deferedUploadToTexture(const Context *rsc, bool genMipmap, uint32_t lodOffset);
     void uploadToTexture(const Context *rsc);
     uint32_t getTextureID() const {return mTextureID;}
 
@@ -82,6 +83,11 @@
 
     Vector<const Program *> mToDirtyList;
 
+    // Is we have a non-null user bitmap callback we do not own the bits and
+    // instead call this function to free the memort when its time.
+    RsBitmapCallback_t mUserBitmapCallback;
+    void *mUserBitmapCallbackData;
+
     // Usage restrictions
     bool mCpuWrite;
     bool mCpuRead;
@@ -98,6 +104,7 @@
     // Is this a legal structure to be used as a texture source.
     // Initially this will require 1D or 2D and color data
     bool mIsTexture;
+    bool mTextureGenMipmap;
     uint32_t mTextureLOD;
     uint32_t mTextureID;
 
@@ -108,6 +115,10 @@
     uint32_t mBufferID;
 
     bool mUploadDefered;
+
+private:
+    void init(Context *rsc, const Type *);
+
 };
 
 }
diff --git a/libs/rs/rsScriptC_Lib.cpp b/libs/rs/rsScriptC_Lib.cpp
index 6b8ed0d..235c153 100644
--- a/libs/rs/rsScriptC_Lib.cpp
+++ b/libs/rs/rsScriptC_Lib.cpp
@@ -975,7 +975,7 @@
 static void SC_uploadToTexture(RsAllocation va, uint32_t baseMipLevel)
 {
     GET_TLS();
-    rsi_AllocationUploadToTexture(rsc, va, baseMipLevel);
+    rsi_AllocationUploadToTexture(rsc, va, false, baseMipLevel);
 }
 
 static void SC_uploadToBufferObject(RsAllocation va)
diff --git a/libs/rs/rsg_ScriptJavaClass.cpp b/libs/rs/rsg_ScriptJavaClass.cpp
new file mode 100644
index 0000000..cee9f52
--- /dev/null
+++ b/libs/rs/rsg_ScriptJavaClass.cpp
@@ -0,0 +1,254 @@
+#define NO_RS_FUNCS 1
+
+#include "stdio.h"
+#include "RenderScript.h"
+#include <vector>
+
+struct Element;
+
+struct ElementField {
+    const char *name;
+    Element *e;
+    ElementField(const char *n, Element *_e) {
+        name = n;
+        e = _e;
+    }
+    ElementField() {
+        name = NULL;
+        e = NULL;
+    }
+};
+
+struct Element {
+    ElementField *fields;
+    size_t fieldCount;
+    const char *name;
+    bool generated;
+
+    RsDataType compType;
+    uint32_t compVectorSize;
+
+    Element() {
+        fields = NULL;
+        fieldCount = 0;
+        name = NULL;
+        generated = false;
+        compType = RS_TYPE_ELEMENT;
+        compVectorSize = 0;
+    }
+
+    Element(uint32_t _fieldCount, const char *_name) {
+        fields = new ElementField[_fieldCount];
+        fieldCount = _fieldCount;
+        name = _name;
+        generated = false;
+        compType = RS_TYPE_ELEMENT;
+        compVectorSize = 0;
+    }
+
+    Element(RsDataType t, uint32_t s) {
+        fields = NULL;
+        fieldCount = 0;
+        name = NULL;
+        generated = false;
+        compType = t;
+        compVectorSize = s;
+    }
+
+};
+
+
+static void genHeader(FILE *f, const char *packageName)
+{
+    fprintf(f, "package %s;\n", packageName);
+    fprintf(f, "\n");
+    fprintf(f, "import android.renderscript.*;\n");
+    fprintf(f, "\n");
+    fprintf(f, "\n");
+}
+
+static const char * RSTypeToJava(RsDataType dt)
+{
+    switch(dt) {
+    //case RS_TYPE_FLOAT_16:         return "float";
+    case RS_TYPE_FLOAT_32:         return "float";
+    //case RS_TYPE_FLOAT_64:         return "double";
+
+    case RS_TYPE_SIGNED_8:         return "byte";
+    case RS_TYPE_SIGNED_16:        return "short";
+    case RS_TYPE_SIGNED_32:        return "int";
+    //case RS_TYPE_SIGNED_64:        return "long";
+
+    case RS_TYPE_UNSIGNED_8:       return "short";
+    case RS_TYPE_UNSIGNED_16:      return "int";
+    case RS_TYPE_UNSIGNED_32:      return "long";
+    //case RS_TYPE_UNSIGNED_64:      return NULL;
+
+    //case RS_TYPE_ELEMENT:          return "android.renderscript.Element";
+    //case RS_TYPE_TYPE:             return "android.renderscript.Type";
+    //case RS_TYPE_ALLOCATION:       return "android.renderscript.Allocation";
+    //case RS_TYPE_SAMPLER:          return "android.renderscript.Sampler";
+    //case RS_TYPE_SCRIPT:           return "android.renderscript.Script";
+    //case RS_TYPE_MESH:             return "android.renderscript.Mesh";
+    //case RS_TYPE_PROGRAM_FRAGMENT: return "android.renderscript.ProgramFragment";
+    //case RS_TYPE_PROGRAM_VERTEX:   return "android.renderscript.ProgramVertex";
+    //case RS_TYPE_PROGRAM_RASTER:   return "android.renderscript.ProgramRaster";
+    //case RS_TYPE_PROGRAM_STORE:    return "android.renderscript.ProgramStore";
+    default: return NULL;
+    }
+    return NULL;
+}
+
+static const char * RSTypeToString(RsDataType dt)
+{
+    switch(dt) {
+    case RS_TYPE_FLOAT_16:         return "F16";
+    case RS_TYPE_FLOAT_32:         return "F32";
+    case RS_TYPE_FLOAT_64:         return "F64";
+
+    case RS_TYPE_SIGNED_8:         return "I8";
+    case RS_TYPE_SIGNED_16:        return "I16";
+    case RS_TYPE_SIGNED_32:        return "I32";
+    case RS_TYPE_SIGNED_64:        return "I64";
+
+    case RS_TYPE_UNSIGNED_8:       return "U8";
+    case RS_TYPE_UNSIGNED_16:      return "U16";
+    case RS_TYPE_UNSIGNED_32:      return "U32";
+    case RS_TYPE_UNSIGNED_64:      return "U64";
+
+    //case RS_TYPE_ELEMENT:          return "android.renderscript.Element";
+    //case RS_TYPE_TYPE:             return "android.renderscript.Type";
+    //case RS_TYPE_ALLOCATION:       return "android.renderscript.Allocation";
+    //case RS_TYPE_SAMPLER:          return "android.renderscript.Sampler";
+    //case RS_TYPE_SCRIPT:           return "android.renderscript.Script";
+    //case RS_TYPE_MESH:             return "android.renderscript.Mesh";
+    //case RS_TYPE_PROGRAM_FRAGMENT: return "android.renderscript.ProgramFragment";
+    //case RS_TYPE_PROGRAM_VERTEX:   return "android.renderscript.ProgramVertex";
+    //case RS_TYPE_PROGRAM_RASTER:   return "android.renderscript.ProgramRaster";
+    //case RS_TYPE_PROGRAM_STORE:    return "android.renderscript.ProgramStore";
+    default: return NULL;
+    }
+    return NULL;
+}
+
+bool rsGenerateElementClass(const Element *e, const char *packageName, FILE *f)
+{
+    genHeader(f, packageName);
+
+    fprintf(f, "class Element_%s {\n", e->name);
+
+    for (size_t ct=0; ct < e->fieldCount; ct++) {
+        const char *ts = RSTypeToJava(e->fields[ct].e->compType);
+        if (ts == NULL) {
+            return false;
+        }
+        fprintf(f, "    public %s %s;\n", ts, e->fields[ct].name);
+    }
+
+    fprintf(f, "\n");
+    fprintf(f, "    static Element getElement(RenderScript rs) {\n");
+    fprintf(f, "        Element.Builder eb = new Element.Builder(rs);\n");
+    for (size_t ct=0; ct < e->fieldCount; ct++) {
+        const char *ts = RSTypeToString(e->fields[ct].e->compType);
+        fprintf(f, "         eb.add(Element.USER_%s(rs), \"%s\");\n", ts, e->fields[ct].name);
+    }
+    fprintf(f, "        return eb.create();\n");
+    fprintf(f, "    }\n");
+
+    fprintf(f, "    static Allocation createAllocation(RenderScript rs) {\n");
+    fprintf(f, "        Element e = getElement(rs);\n");
+    fprintf(f, "        Allocation a = Allocation.createSized(rs, e, 1);\n");
+    fprintf(f, "        return a;\n");
+    fprintf(f, "    }\n");
+
+
+    fprintf(f, "    void copyToAllocation(Allocation a) {\n");
+    fprintf(f, "        mIOBuffer.reset();\n");
+    for (size_t ct=0; ct < e->fieldCount; ct++) {
+        const char *ts = RSTypeToString(e->fields[ct].e->compType);
+        fprintf(f, "         mIOBuffer.add%s(%s);\n", ts, e->fields[ct].name);
+    }
+    fprintf(f, "        a.data(mIOBuffer.getData());\n");
+    fprintf(f, "    }\n");
+
+
+
+    fprintf(f, "    private FieldPacker mIOBuffer[];\n");
+    fprintf(f, "    public Element_%s() {\n", e->name);
+    fprintf(f, "        mIOBuffer = new FieldPacker(%i);\n", 100/*element->getSizeBytes()*/);
+    fprintf(f, "    }\n");
+
+
+    fprintf(f, "}\n");
+
+    return true;
+}
+
+bool rsGenerateElementClassFile(Element *e, const char *packageName)
+{
+    char buf[1024];
+    sprintf(buf, "Element_%s.java", e->name);
+    printf("Creating file %s \n", buf);
+    FILE *f = fopen(buf, "w");
+    bool ret = rsGenerateElementClass(e, packageName, f);
+    fclose(f);
+    return ret;
+}
+
+
+
+
+/*
+bool rsGenerateScriptClass(const ScriptC *script, const char *packageName, FILE *f)
+{
+    genHeader(f, packageName);
+
+    fprintf(f, "class ScriptC_%s {\n", script->getName());
+
+
+
+        ObjectBaseRef<const Type> mTypes[MAX_SCRIPT_BANKS];
+    String8 mSlotNames[MAX_SCRIPT_BANKS];
+    bool mSlotWritable[MAX_SCRIPT_BANKS];
+
+
+}
+*/
+
+
+
+int main(int argc, const char *argv)
+{
+    Element *u8 = new Element(RS_TYPE_UNSIGNED_8, 1);
+    Element *i32 = new Element(RS_TYPE_SIGNED_32, 1);
+    Element *f32 = new Element(RS_TYPE_FLOAT_32, 1);
+
+    Element *e_Pixel = new Element(4, "Pixel");
+    e_Pixel->fields[0].e = u8;
+    e_Pixel->fields[0].name = "a";
+    e_Pixel->fields[1].e = u8;
+    e_Pixel->fields[1].name = "b";
+    e_Pixel->fields[2].e = u8;
+    e_Pixel->fields[2].name = "g";
+    e_Pixel->fields[3].e = u8;
+    e_Pixel->fields[3].name = "r";
+
+    Element *e_Params = new Element(5, "Params");
+    e_Params->fields[0].e = i32;
+    e_Params->fields[0].name = "inHeight";
+    e_Params->fields[1].e = i32;
+    e_Params->fields[1].name = "inWidth";
+    e_Params->fields[2].e = i32;
+    e_Params->fields[2].name = "outHeight";
+    e_Params->fields[3].e = i32;
+    e_Params->fields[3].name = "outWidth";
+    e_Params->fields[4].e = f32;
+    e_Params->fields[4].name = "threshold";
+
+
+    printf("1\n");
+    rsGenerateElementClassFile(e_Pixel, "android");
+    rsGenerateElementClassFile(e_Params, "android");
+
+}
+
diff --git a/libs/rs/rsg_generator.c b/libs/rs/rsg_generator.c
index 74ba248..f4e8c68 100644
--- a/libs/rs/rsg_generator.c
+++ b/libs/rs/rsg_generator.c
@@ -5,7 +5,7 @@
 void printFileHeader(FILE *f)
 {
     fprintf(f, "/*\n");
-    fprintf(f, " * Copyright (C) 2009 The Android Open Source Project\n");
+    fprintf(f, " * Copyright (C) 2010 The Android Open Source Project\n");
     fprintf(f, " *\n");
     fprintf(f, " * Licensed under the Apache License, Version 2.0 (the \"License\");\n");
     fprintf(f, " * you may not use this file except in compliance with the License.\n");
diff --git a/libs/surfaceflinger/LayerBase.cpp b/libs/surfaceflinger/LayerBase.cpp
index a3d293f..b0109ca 100644
--- a/libs/surfaceflinger/LayerBase.cpp
+++ b/libs/surfaceflinger/LayerBase.cpp
@@ -728,6 +728,14 @@
     delete lcblk;
 }
 
+void LayerBaseClient::setName(const String8& name) {
+    mName = name;
+}
+
+String8 LayerBaseClient::getName() const {
+    return mName;
+}
+
 int32_t LayerBaseClient::serverIndex() const 
 {
     sp<Client> client(this->client.promote());
diff --git a/libs/surfaceflinger/LayerBase.h b/libs/surfaceflinger/LayerBase.h
index 6aacd82..7ac8bc5 100644
--- a/libs/surfaceflinger/LayerBase.h
+++ b/libs/surfaceflinger/LayerBase.h
@@ -320,6 +320,8 @@
             const sp<Client>& client, int32_t i);
     virtual ~LayerBaseClient();
     virtual void onFirstRef();
+    void setName(const String8& name);
+    String8 getName() const;
 
     const wp<Client>    client;
 
@@ -333,6 +335,7 @@
     
     virtual void onRemoved();
 
+
     class Surface : public BnSurface 
     {
     public:
@@ -371,6 +374,7 @@
     mutable     Mutex           mLock;
     mutable     wp<Surface>     mClientSurface;
     // only read
+                String8         mName;
     const       uint32_t        mIdentity;
     static      int32_t         sIdentity;
 };
diff --git a/libs/surfaceflinger/SurfaceFlinger.cpp b/libs/surfaceflinger/SurfaceFlinger.cpp
index 4555b3c..2598440 100644
--- a/libs/surfaceflinger/SurfaceFlinger.cpp
+++ b/libs/surfaceflinger/SurfaceFlinger.cpp
@@ -625,12 +625,13 @@
 
             mVisibleRegionsDirty = true;
             mDirtyRegion.set(hw.bounds());
-            mFreezeDisplayTime = 0;
         }
 
         if (mCurrentState.freezeDisplay != mDrawingState.freezeDisplay) {
             // freezing or unfreezing the display -> trigger animation if needed
             mFreezeDisplay = mCurrentState.freezeDisplay;
+            if (mFreezeDisplay)
+                 mFreezeDisplayTime = 0;
         }
 
         if (currentLayers.size() > mDrawingState.layersSortedByZ.size()) {
@@ -1186,7 +1187,7 @@
 }
 
 sp<ISurface> SurfaceFlinger::createSurface(ClientID clientId, int pid,
-        ISurfaceFlingerClient::surface_data_t* params,
+        const String8& name, ISurfaceFlingerClient::surface_data_t* params,
         DisplayID d, uint32_t w, uint32_t h, PixelFormat format,
         uint32_t flags)
 {
@@ -1232,6 +1233,7 @@
     }
 
     if (layer != 0) {
+        layer->setName(name);
         setTransactionFlags(eTransactionNeeded);
         surfaceHandle = layer->getSurface();
         if (surfaceHandle != 0) { 
@@ -1506,8 +1508,10 @@
             if (lbc != 0) {
                 sp<Client> client(lbc->client.promote());
                 snprintf(buffer, SIZE,
-                        "      "
-                        "id=0x%08x, client=0x%08x, identity=%u\n",
+                        "      name=%s\n", lbc->getName().string());
+                result.append(buffer);
+                snprintf(buffer, SIZE,
+                        "      id=0x%08x, client=0x%08x, identity=%u\n",
                         lbc->clientIndex(), client.get() ? client->cid : 0,
                         lbc->getIdentity());
 
@@ -1760,10 +1764,12 @@
 
 sp<ISurface> BClient::createSurface(
         ISurfaceFlingerClient::surface_data_t* params, int pid,
+        const String8& name,
         DisplayID display, uint32_t w, uint32_t h, PixelFormat format,
         uint32_t flags)
 {
-    return mFlinger->createSurface(mId, pid, params, display, w, h, format, flags);
+    return mFlinger->createSurface(mId, pid, name, params, display, w, h,
+            format, flags);
 }
 
 status_t BClient::destroySurface(SurfaceID sid)
diff --git a/libs/surfaceflinger/SurfaceFlinger.h b/libs/surfaceflinger/SurfaceFlinger.h
index 4520c0e..d75dc15 100644
--- a/libs/surfaceflinger/SurfaceFlinger.h
+++ b/libs/surfaceflinger/SurfaceFlinger.h
@@ -189,7 +189,7 @@
     friend class LayerBlur;
     friend class LayerDim;
 
-    sp<ISurface> createSurface(ClientID client, int pid, 
+    sp<ISurface> createSurface(ClientID client, int pid, const String8& name,
             ISurfaceFlingerClient::surface_data_t* params,
             DisplayID display, uint32_t w, uint32_t h, PixelFormat format,
             uint32_t flags);
@@ -401,7 +401,7 @@
     virtual sp<IMemoryHeap> getControlBlock() const;
 
     virtual sp<ISurface> createSurface(
-            surface_data_t* params, int pid,
+            surface_data_t* params, int pid, const String8& name,
             DisplayID display, uint32_t w, uint32_t h,PixelFormat format,
             uint32_t flags);
 
diff --git a/libs/surfaceflinger_client/ISurfaceFlingerClient.cpp b/libs/surfaceflinger_client/ISurfaceFlingerClient.cpp
index e636c52..def96d7 100644
--- a/libs/surfaceflinger_client/ISurfaceFlingerClient.cpp
+++ b/libs/surfaceflinger_client/ISurfaceFlingerClient.cpp
@@ -74,6 +74,7 @@
 
     virtual sp<ISurface> createSurface( surface_data_t* params,
                                         int pid,
+                                        const String8& name,
                                         DisplayID display,
                                         uint32_t w,
                                         uint32_t h,
@@ -83,6 +84,7 @@
         Parcel data, reply;
         data.writeInterfaceToken(ISurfaceFlingerClient::getInterfaceDescriptor());
         data.writeInt32(pid);
+        data.writeString8(name);
         data.writeInt32(display);
         data.writeInt32(w);
         data.writeInt32(h);
@@ -154,12 +156,14 @@
             CHECK_INTERFACE(ISurfaceFlingerClient, data, reply);
             surface_data_t params;
             int32_t pid = data.readInt32();
+            String8 name = data.readString8();
             DisplayID display = data.readInt32();
             uint32_t w = data.readInt32();
             uint32_t h = data.readInt32();
             PixelFormat format = data.readInt32();
             uint32_t flags = data.readInt32();
-            sp<ISurface> s = createSurface(&params, pid, display, w, h, format, flags);
+            sp<ISurface> s = createSurface(&params, pid, name, display, w, h,
+                    format, flags);
             params.writeToParcel(reply);
             reply->writeStrongBinder(s->asBinder());
             return NO_ERROR;
diff --git a/libs/surfaceflinger_client/SurfaceComposerClient.cpp b/libs/surfaceflinger_client/SurfaceComposerClient.cpp
index 0b5e504..3117495 100644
--- a/libs/surfaceflinger_client/SurfaceComposerClient.cpp
+++ b/libs/surfaceflinger_client/SurfaceComposerClient.cpp
@@ -319,10 +319,30 @@
         PixelFormat format,
         uint32_t flags)
 {
+    String8 name;
+    const size_t SIZE = 128;
+    char buffer[SIZE];
+    snprintf(buffer, SIZE, "<pid_%d>", getpid());
+    name.append(buffer);
+
+    return SurfaceComposerClient::createSurface(pid, name, display,
+            w, h, format, flags);
+
+}
+
+sp<SurfaceControl> SurfaceComposerClient::createSurface(
+        int pid,
+        const String8& name,
+        DisplayID display,
+        uint32_t w,
+        uint32_t h,
+        PixelFormat format,
+        uint32_t flags)
+{
     sp<SurfaceControl> result;
     if (mStatus == NO_ERROR) {
         ISurfaceFlingerClient::surface_data_t data;
-        sp<ISurface> surface = mClient->createSurface(&data, pid,
+        sp<ISurface> surface = mClient->createSurface(&data, pid, name,
                 display, w, h, format, flags);
         if (surface != 0) {
             if (uint32_t(data.token) < NUM_LAYERS_MAX) {
diff --git a/libs/utils/ResourceTypes.cpp b/libs/utils/ResourceTypes.cpp
index 38600b9..5f89788 100644
--- a/libs/utils/ResourceTypes.cpp
+++ b/libs/utils/ResourceTypes.cpp
@@ -1850,7 +1850,7 @@
         if (Res_GETPACKAGE(resID)+1 == 0) {
             LOGW("No package identifier when getting name for resource number 0x%08x", resID);
         } else {
-            LOGW("Resources don't contain package for resource number 0x%08x", resID);
+            LOGV("Resources don't contain package for resource number 0x%08x", resID);
         }
         return false;
     }
@@ -1900,7 +1900,7 @@
         if (Res_GETPACKAGE(resID)+1 == 0) {
             LOGW("No package identifier when getting name for resource number 0x%08x", resID);
         } else {
-            LOGW("Resources don't contain package for resource number 0x%08x", resID);
+            LOGV("Resources don't contain package for resource number 0x%08x", resID);
         }
         return BAD_INDEX;
     }
diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java
index 668917e..947307d 100644
--- a/media/java/android/media/AudioService.java
+++ b/media/java/android/media/AudioService.java
@@ -901,18 +901,20 @@
         boolean adjustVolumeIndex = true;
         int newRingerMode = mRingerMode;
 
-        if (mRingerMode == AudioManager.RINGER_MODE_NORMAL && (oldIndex + 5) / 10 == 1
-                && direction == AudioManager.ADJUST_LOWER) {
-            newRingerMode = AudioManager.RINGER_MODE_VIBRATE;
-        } else if (mRingerMode == AudioManager.RINGER_MODE_VIBRATE) {
-            if (direction == AudioManager.ADJUST_RAISE) {
-                newRingerMode = AudioManager.RINGER_MODE_NORMAL;
-            } else if (direction == AudioManager.ADJUST_LOWER) {
-                newRingerMode = AudioManager.RINGER_MODE_SILENT;
+        if (mRingerMode == AudioManager.RINGER_MODE_NORMAL) {
+            // audible mode, at the bottom of the scale
+            if (direction == AudioManager.ADJUST_LOWER
+                    && (oldIndex + 5) / 10 == 1) {
+                // "silent mode", but which one?
+                newRingerMode = System.getInt(mContentResolver, System.VIBRATE_IN_SILENT, 1) == 1
+                    ? AudioManager.RINGER_MODE_VIBRATE
+                    : AudioManager.RINGER_MODE_SILENT;
             }
-        } else if (direction == AudioManager.ADJUST_RAISE
-                && mRingerMode == AudioManager.RINGER_MODE_SILENT) {
-            newRingerMode = AudioManager.RINGER_MODE_VIBRATE;
+        } else {
+            if (direction == AudioManager.ADJUST_RAISE) {
+                // exiting silent mode
+                newRingerMode = AudioManager.RINGER_MODE_NORMAL;
+            }
         }
 
         if (newRingerMode != mRingerMode) {
diff --git a/media/libstagefright/AudioPlayer.cpp b/media/libstagefright/AudioPlayer.cpp
index 57f58be..5e6e0da 100644
--- a/media/libstagefright/AudioPlayer.cpp
+++ b/media/libstagefright/AudioPlayer.cpp
@@ -18,6 +18,7 @@
 #define LOG_TAG "AudioPlayer"
 #include <utils/Log.h>
 
+#include <binder/IPCThreadState.h>
 #include <media/AudioTrack.h>
 #include <media/stagefright/AudioPlayer.h>
 #include <media/stagefright/MediaDebug.h>
@@ -164,6 +165,16 @@
 
     mSource->stop();
 
+    // The following hack is necessary to ensure that the OMX
+    // component is completely released by the time we may try
+    // to instantiate it again.
+    wp<MediaSource> tmp = mSource;
+    mSource.clear();
+    while (tmp.promote() != NULL) {
+        usleep(1000);
+    }
+    IPCThreadState::self()->flushCommands();
+
     mNumFramesPlayed = 0;
     mPositionTimeMediaUs = -1;
     mPositionTimeRealUs = -1;
diff --git a/services/java/com/android/server/SensorService.java b/services/java/com/android/server/SensorService.java
index 01d64a7..9f5718f 100644
--- a/services/java/com/android/server/SensorService.java
+++ b/services/java/com/android/server/SensorService.java
@@ -24,7 +24,11 @@
 import android.os.IBinder;
 import android.util.Config;
 import android.util.Slog;
+import android.util.PrintWriterPrinter;
+import android.util.Printer;
 
+import java.io.FileDescriptor;
+import java.io.PrintWriter;
 import java.util.ArrayList;
 
 import com.android.internal.app.IBatteryStats;
@@ -43,6 +47,7 @@
     private static final boolean DEBUG = false;
     private static final boolean localLOGV = DEBUG ? Config.LOGD : Config.LOGV;
     private static final int SENSOR_DISABLE = -1;
+    private int mCurrentDelay = 0;
     
     /**
      * Battery statistics to be updated when sensors are enabled and disabled.
@@ -51,17 +56,19 @@
 
     private final class Listener implements IBinder.DeathRecipient {
         final IBinder mToken;
+        final int mUid;
 
         int mSensors = 0;
         int mDelay = 0x7FFFFFFF;
         
-        Listener(IBinder token) {
+        Listener(IBinder token, int uid) {
             mToken = token;
+            mUid = uid;
         }
         
         void addSensor(int sensor, int delay) {
             mSensors |= (1<<sensor);
-            if (mDelay > delay)
+            if (delay < mDelay)
             	mDelay = delay;
         }
         
@@ -83,16 +90,20 @@
                 for (int sensor=0 ; sensor<32 && mSensors!=0 ; sensor++) {
                     if (hasSensor(sensor)) {
                         removeSensor(sensor);
+                        deactivateIfUnusedLocked(sensor);
                         try {
-                            deactivateIfUnusedLocked(sensor);
+                            mBatteryStats.noteStopSensor(mUid, sensor);
                         } catch (RemoteException e) {
-                            Slog.w(TAG, "RemoteException in binderDied");
+                            // oops. not a big deal.
                         }
                     }
                 }
                 if (mListeners.size() == 0) {
                     _sensors_control_wake();
                     _sensors_control_close();
+                } else {
+                    // TODO: we should recalculate the delay, since removing
+                    // a listener may increase the overall rate.
                 }
                 mListeners.notify();
             }
@@ -113,86 +124,151 @@
     }
 
     public boolean enableSensor(IBinder binder, String name, int sensor, int enable)
-             throws RemoteException {
-        if (localLOGV) Slog.d(TAG, "enableSensor " + name + "(#" + sensor + ") " + enable);
+            throws RemoteException {
         
-        // Inform battery statistics service of status change
-        int uid = Binder.getCallingUid();
-        long identity = Binder.clearCallingIdentity();
-        if (enable == SENSOR_DISABLE) {
-            mBatteryStats.noteStopSensor(uid, sensor);
-        } else {
-            mBatteryStats.noteStartSensor(uid, sensor);
-        }
-        Binder.restoreCallingIdentity(identity);
+        if (localLOGV) Slog.d(TAG, "enableSensor " + name + "(#" + sensor + ") " + enable);
 
         if (binder == null) {
-            Slog.w(TAG, "listener is null (sensor=" + name + ", id=" + sensor + ")");
+            Slog.e(TAG, "listener is null (sensor=" + name + ", id=" + sensor + ")");
             return false;
         }
 
+        if (enable < 0 && (enable != SENSOR_DISABLE)) {
+            Slog.e(TAG, "invalid enable parameter (enable=" + enable +
+                    ", sensor=" + name + ", id=" + sensor + ")");
+            return false;
+        }
+
+        boolean res;
+        int uid = Binder.getCallingUid();
         synchronized(mListeners) {
-            if (enable!=SENSOR_DISABLE && !_sensors_control_activate(sensor, true)) {
+            res = enableSensorInternalLocked(binder, uid, name, sensor, enable);
+            if (res == true) {
+                // Inform battery statistics service of status change
+                long identity = Binder.clearCallingIdentity();
+                if (enable == SENSOR_DISABLE) {
+                    mBatteryStats.noteStopSensor(uid, sensor);
+                } else {
+                    mBatteryStats.noteStartSensor(uid, sensor);
+                }
+                Binder.restoreCallingIdentity(identity);
+            }
+        }
+        return res;
+    }
+
+    private boolean enableSensorInternalLocked(IBinder binder, int uid,
+            String name, int sensor, int enable) throws RemoteException {
+
+        // check if we have this listener
+        Listener l = null;
+        for (Listener listener : mListeners) {
+            if (binder == listener.mToken) {
+                l = listener;
+                break;
+            }
+        }
+
+        if (enable != SENSOR_DISABLE) {
+            // Activate the requested sensor
+            if (_sensors_control_activate(sensor, true) == false) {
                 Slog.w(TAG, "could not enable sensor " + sensor);
                 return false;
             }
-                    
-            Listener l = null;
-            int minDelay = enable;
-            for (Listener listener : mListeners) {
-                if (binder == listener.mToken) {
-                    l = listener;
-                }
-                if (minDelay > listener.mDelay)
-                    minDelay = listener.mDelay;
-            }
-            
-            if (l == null && enable!=SENSOR_DISABLE) {
-                l = new Listener(binder);
+
+            if (l == null) {
+                /*
+                 * we don't have a listener for this binder yet, so
+                 * create a new one and add it to the list.
+                 */
+                l = new Listener(binder, uid);
                 binder.linkToDeath(l, 0);
                 mListeners.add(l);
                 mListeners.notify();
             }
-            
+
+            // take note that this sensor is now used by this client
+            l.addSensor(sensor, enable);
+
+        } else {
+
             if (l == null) {
-                // by construction, this means we're disabling a listener we
-                // don't know about...
-                Slog.w(TAG, "listener with binder " + binder + 
-                        ", doesn't exist (sensor=" + name + ", id=" + sensor + ")");
+                /*
+                 *  This client isn't in the list, this usually happens
+                 *  when enabling the sensor failed, but the client
+                 *  didn't handle the error and later tries to shut that
+                 *  sensor off.
+                 */
+                Slog.w(TAG, "listener with binder " + binder +
+                        ", doesn't exist (sensor=" + name +
+                        ", id=" + sensor + ")");
                 return false;
             }
-            
-            if (minDelay >= 0) {
-                _sensors_control_set_delay(minDelay);
-            }
-            
-            if (enable != SENSOR_DISABLE) {
-                l.addSensor(sensor, enable);
-            } else {
-                l.removeSensor(sensor);
-                deactivateIfUnusedLocked(sensor);
-                if (l.mSensors == 0) {
-                    mListeners.remove(l);
-                    binder.unlinkToDeath(l, 0);
-                    mListeners.notify();
+
+            // remove this sensor from this client
+            l.removeSensor(sensor);
+
+            // see if we need to deactivate this sensors=
+            deactivateIfUnusedLocked(sensor);
+
+            // if the listener doesn't have any more sensors active
+            // we can get rid of it
+            if (l.mSensors == 0) {
+                // we won't need this death notification anymore
+                binder.unlinkToDeath(l, 0);
+                // remove the listener from the list
+                mListeners.remove(l);
+                // and if the list is empty, turn off the whole sensor h/w
+                if (mListeners.size() == 0) {
+                    _sensors_control_wake();
+                    _sensors_control_close();
                 }
+                mListeners.notify();
             }
-            
-            if (mListeners.size() == 0) {
-                _sensors_control_wake();
-                _sensors_control_close();
-            }
-        }        
+        }
+
+        // calculate and set the new delay
+        int minDelay = 0x7FFFFFFF;
+        for (Listener listener : mListeners) {
+            if (listener.mDelay < minDelay)
+                minDelay = listener.mDelay;
+        }
+        if (minDelay != 0x7FFFFFFF) {
+            mCurrentDelay = minDelay;
+            _sensors_control_set_delay(minDelay);
+        }
+
         return true;
     }
 
-    private void deactivateIfUnusedLocked(int sensor) throws RemoteException {
+    private void deactivateIfUnusedLocked(int sensor) {
         int size = mListeners.size();
         for (int i=0 ; i<size ; i++) {
-            if (mListeners.get(i).hasSensor(sensor))
+            if (mListeners.get(i).hasSensor(sensor)) {
+                // this sensor is still in use, don't turn it off
                 return;
+            }
         }
-        _sensors_control_activate(sensor, false);
+        if (_sensors_control_activate(sensor, false) == false) {
+            Slog.w(TAG, "could not disable sensor " + sensor);
+        }
+    }
+
+    @Override
+    protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
+        synchronized (mListeners) {
+            Printer pr = new PrintWriterPrinter(pw);
+            int c = 0;
+            pr.println(mListeners.size() + " listener(s), delay=" + mCurrentDelay + " ms");
+            for (Listener l : mListeners) {
+                pr.println("listener[" + c + "] " +
+                        "sensors=0x" + Integer.toString(l.mSensors, 16) +
+                        ", uid=" + l.mUid +
+                        ", delay=" +
+                        l.mDelay + " ms");
+                c++;
+            }
+        }
     }
 
     private ArrayList<Listener> mListeners = new ArrayList<Listener>();
diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java
index a75e05d..ba1efb9 100644
--- a/services/java/com/android/server/WindowManagerService.java
+++ b/services/java/com/android/server/WindowManagerService.java
@@ -7292,6 +7292,7 @@
                 try {
                     mSurface = new Surface(
                             mSession.mSurfaceSession, mSession.mPid,
+                            mAttrs.getTitle().toString(),
                             0, w, h, mAttrs.format, flags);
                     if (SHOW_TRANSACTIONS) Slog.i(TAG, "  CREATE SURFACE "
                             + mSurface + " IN SESSION "
@@ -10248,6 +10249,7 @@
                         if (mBackgroundFillerSurface == null) {
                             try {
                                 mBackgroundFillerSurface = new Surface(mFxSession, 0,
+                                        "BackGroundFiller",
                                         0, dw, dh,
                                         PixelFormat.OPAQUE,
                                         Surface.FX_SURFACE_NORMAL);
@@ -10294,6 +10296,7 @@
                                             + mBlurSurface + ": CREATE");
                                     try {
                                         mBlurSurface = new Surface(mFxSession, 0,
+                                                "BlurSurface",
                                                 -1, 16, 16,
                                                 PixelFormat.OPAQUE,
                                                 Surface.FX_SURFACE_BLUR);
@@ -11073,7 +11076,9 @@
                 if (SHOW_TRANSACTIONS) Slog.i(TAG, "  DIM "
                         + mDimSurface + ": CREATE");
                 try {
-                    mDimSurface = new Surface(session, 0, -1, 16, 16, PixelFormat.OPAQUE,
+                    mDimSurface = new Surface(session, 0,
+                            "DimSurface",
+                            -1, 16, 16, PixelFormat.OPAQUE,
                             Surface.FX_SURFACE_DIM);
                 } catch (Exception e) {
                     Slog.e(TAG, "Exception creating Dim surface", e);