Merge "Up our DNS server support from 2 > 4"
diff --git a/Android.mk b/Android.mk
index 294a2fe..462d6ac 100644
--- a/Android.mk
+++ b/Android.mk
@@ -166,6 +166,7 @@
 	core/java/android/speech/IRecognitionService.aidl \
 	core/java/android/speech/tts/ITextToSpeechCallback.aidl \
 	core/java/android/speech/tts/ITextToSpeechService.aidl \
+	core/java/com/android/internal/app/IAppOpsService.aidl \
 	core/java/com/android/internal/app/IBatteryStats.aidl \
 	core/java/com/android/internal/app/IUsageStats.aidl \
 	core/java/com/android/internal/app/IMediaContainerService.aidl \
diff --git a/api/current.txt b/api/current.txt
index 111bd65..1cf14aa 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -13785,12 +13785,18 @@
     method public void setNdefPushMessage(android.nfc.NdefMessage, android.app.Activity, android.app.Activity...);
     method public void setNdefPushMessageCallback(android.nfc.NfcAdapter.CreateNdefMessageCallback, android.app.Activity, android.app.Activity...);
     method public void setOnNdefPushCompleteCallback(android.nfc.NfcAdapter.OnNdefPushCompleteCallback, android.app.Activity, android.app.Activity...);
+    field public static final java.lang.String ACTION_ADAPTER_STATE_CHANGED = "android.nfc.action.ADAPTER_STATE_CHANGED";
     field public static final java.lang.String ACTION_NDEF_DISCOVERED = "android.nfc.action.NDEF_DISCOVERED";
     field public static final java.lang.String ACTION_TAG_DISCOVERED = "android.nfc.action.TAG_DISCOVERED";
     field public static final java.lang.String ACTION_TECH_DISCOVERED = "android.nfc.action.TECH_DISCOVERED";
+    field public static final java.lang.String EXTRA_ADAPTER_STATE = "android.nfc.extra.ADAPTER_STATE";
     field public static final java.lang.String EXTRA_ID = "android.nfc.extra.ID";
     field public static final java.lang.String EXTRA_NDEF_MESSAGES = "android.nfc.extra.NDEF_MESSAGES";
     field public static final java.lang.String EXTRA_TAG = "android.nfc.extra.TAG";
+    field public static final int STATE_OFF = 1; // 0x1
+    field public static final int STATE_ON = 3; // 0x3
+    field public static final int STATE_TURNING_OFF = 4; // 0x4
+    field public static final int STATE_TURNING_ON = 2; // 0x2
   }
 
   public static abstract interface NfcAdapter.CreateBeamUrisCallback {
@@ -17360,6 +17366,7 @@
     field public static final java.lang.String CAN_PARTIALLY_UPDATE = "canPartiallyUpdate";
     field public static final java.lang.String DELETED = "deleted";
     field public static final java.lang.String DIRTY = "dirty";
+    field public static final java.lang.String MUTATORS = "mutators";
     field public static final java.lang.String _SYNC_ID = "_sync_id";
   }
 
@@ -29099,7 +29106,7 @@
     method public void setRelativeScrollPosition(int, int);
     method public deprecated void setRemoteAdapter(int, int, android.content.Intent);
     method public void setRemoteAdapter(int, android.content.Intent);
-    method public void setRemoteAdapter(int, java.util.ArrayList<android.widget.RemoteViews>);
+    method public void setRemoteAdapter(int, java.util.ArrayList<android.widget.RemoteViews>, int);
     method public void setScrollPosition(int, int);
     method public void setShort(int, java.lang.String, short);
     method public void setString(int, java.lang.String, java.lang.String);
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index 3bdadc3..d6ddeb6 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -2844,7 +2844,7 @@
      * item has been selected.
      * <p>
      * It is not safe to hold onto the context menu after this method returns.
-     * {@inheritDoc}
+     *
      */
     public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
     }
diff --git a/core/java/android/app/AppOpsManager.java b/core/java/android/app/AppOpsManager.java
new file mode 100644
index 0000000..7210df4
--- /dev/null
+++ b/core/java/android/app/AppOpsManager.java
@@ -0,0 +1,110 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.app;
+
+import com.android.internal.app.IAppOpsService;
+
+import android.content.Context;
+import android.os.Process;
+import android.os.RemoteException;
+
+/** @hide */
+public class AppOpsManager {
+    final Context mContext;
+    final IAppOpsService mService;
+
+    public static final int MODE_ALLOWED = 0;
+    public static final int MODE_IGNORED = 1;
+    public static final int MODE_ERRORED = 2;
+
+    public static final int OP_LOCATION = 0;
+    public static final int OP_GPS = 1;
+    public static final int OP_VIBRATE = 2;
+
+    public static String opToString(int op) {
+        switch (op) {
+            case OP_LOCATION: return "LOCATION";
+            case OP_GPS: return "GPS";
+            case OP_VIBRATE: return "VIBRATE";
+            default: return "Unknown(" + op + ")";
+        }
+    }
+
+    public AppOpsManager(Context context, IAppOpsService service) {
+        mContext = context;
+        mService = service;
+    }
+
+    public int noteOp(int op, int uid, String packageName) {
+        try {
+            int mode = mService.noteOperation(op, uid, packageName);
+            if (mode == MODE_ERRORED) {
+                throw new SecurityException("Operation not allowed");
+            }
+            return mode;
+        } catch (RemoteException e) {
+        }
+        return MODE_IGNORED;
+    }
+
+    public int noteOpNoThrow(int op, int uid, String packageName) {
+        try {
+            return mService.noteOperation(op, uid, packageName);
+        } catch (RemoteException e) {
+        }
+        return MODE_IGNORED;
+    }
+
+    public int noteOp(int op) {
+        return noteOp(op, Process.myUid(), mContext.getPackageName());
+    }
+
+    public int startOp(int op, int uid, String packageName) {
+        try {
+            int mode = mService.startOperation(op, uid, packageName);
+            if (mode == MODE_ERRORED) {
+                throw new SecurityException("Operation not allowed");
+            }
+            return mode;
+        } catch (RemoteException e) {
+        }
+        return MODE_IGNORED;
+    }
+
+    public int startOpNoThrow(int op, int uid, String packageName) {
+        try {
+            return mService.startOperation(op, uid, packageName);
+        } catch (RemoteException e) {
+        }
+        return MODE_IGNORED;
+    }
+
+    public int startOp(int op) {
+        return startOp(op, Process.myUid(), mContext.getPackageName());
+    }
+
+    public void finishOp(int op, int uid, String packageName) {
+        try {
+            mService.finishOperation(op, uid, packageName);
+        } catch (RemoteException e) {
+        }
+    }
+
+    public void finishOp(int op) {
+        finishOp(op, Process.myUid(), mContext.getPackageName());
+    }
+}
diff --git a/core/java/android/app/ApplicationPackageManager.java b/core/java/android/app/ApplicationPackageManager.java
index 7431765..03d1a3f 100644
--- a/core/java/android/app/ApplicationPackageManager.java
+++ b/core/java/android/app/ApplicationPackageManager.java
@@ -142,6 +142,21 @@
     }
 
     @Override
+    public int getPackageUid(String packageName, int userHandle)
+            throws NameNotFoundException {
+        try {
+            int uid = mPM.getPackageUid(packageName, userHandle);
+            if (uid >= 0) {
+                return uid;
+            }
+        } catch (RemoteException e) {
+            throw new RuntimeException("Package manager has died", e);
+        }
+
+        throw new NameNotFoundException(packageName);
+    }
+
+    @Override
     public PermissionInfo getPermissionInfo(String name, int flags)
             throws NameNotFoundException {
         try {
diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java
index f895ccc..8ef708c 100644
--- a/core/java/android/app/ContextImpl.java
+++ b/core/java/android/app/ContextImpl.java
@@ -47,11 +47,9 @@
 import android.graphics.Bitmap;
 import android.graphics.drawable.Drawable;
 import android.hardware.ISerialManager;
-import android.hardware.SensorManager;
 import android.hardware.SerialManager;
 import android.hardware.SystemSensorManager;
 import android.hardware.display.DisplayManager;
-import android.hardware.input.IInputManager;
 import android.hardware.input.InputManager;
 import android.hardware.usb.IUsbManager;
 import android.hardware.usb.UsbManager;
@@ -109,6 +107,8 @@
 import android.accounts.AccountManager;
 import android.accounts.IAccountManager;
 import android.app.admin.DevicePolicyManager;
+
+import com.android.internal.app.IAppOpsService;
 import com.android.internal.os.IDropBoxManagerService;
 
 import java.io.File;
@@ -499,7 +499,7 @@
 
         registerService(VIBRATOR_SERVICE, new ServiceFetcher() {
                 public Object createService(ContextImpl ctx) {
-                    return new SystemVibrator();
+                    return new SystemVibrator(ctx);
                 }});
 
         registerService(WALLPAPER_SERVICE, WALLPAPER_FETCHER);
@@ -530,11 +530,18 @@
                 }});
 
         registerService(USER_SERVICE, new ServiceFetcher() {
-            public Object getService(ContextImpl ctx) {
+            public Object createService(ContextImpl ctx) {
                 IBinder b = ServiceManager.getService(USER_SERVICE);
                 IUserManager service = IUserManager.Stub.asInterface(b);
                 return new UserManager(ctx, service);
             }});
+
+        registerService(APP_OPS_SERVICE, new ServiceFetcher() {
+            public Object createService(ContextImpl ctx) {
+                IBinder b = ServiceManager.getService(APP_OPS_SERVICE);
+                IAppOpsService service = IAppOpsService.Stub.asInterface(b);
+                return new AppOpsManager(ctx, service);
+            }});
     }
 
     static ContextImpl getImpl(Context context) {
diff --git a/core/java/android/app/DownloadManager.java b/core/java/android/app/DownloadManager.java
index 6cf4dd0..32e40ee 100644
--- a/core/java/android/app/DownloadManager.java
+++ b/core/java/android/app/DownloadManager.java
@@ -499,7 +499,7 @@
                             " already exists and is not a directory");
                 }
             } else {
-                if (!file.mkdir()) {
+                if (!file.mkdirs()) {
                     throw new IllegalStateException("Unable to create directory: "+
                             file.getAbsolutePath());
                 }
diff --git a/core/java/android/app/PendingIntent.java b/core/java/android/app/PendingIntent.java
index 5c75aff..2897ee0 100644
--- a/core/java/android/app/PendingIntent.java
+++ b/core/java/android/app/PendingIntent.java
@@ -289,7 +289,7 @@
 
     /**
      * Like {@link #getActivity(Context, int, Intent, int)}, but allows an
-     * array of Intents to be supplied.  The first Intent in the array is
+     * array of Intents to be supplied.  The last Intent in the array is
      * taken as the primary key for the PendingIntent, like the single Intent
      * given to {@link #getActivity(Context, int, Intent, int)}.  Upon sending
      * the resulting PendingIntent, all of the Intents are started in the same
@@ -335,7 +335,7 @@
 
     /**
      * Like {@link #getActivity(Context, int, Intent, int)}, but allows an
-     * array of Intents to be supplied.  The first Intent in the array is
+     * array of Intents to be supplied.  The last Intent in the array is
      * taken as the primary key for the PendingIntent, like the single Intent
      * given to {@link #getActivity(Context, int, Intent, int)}.  Upon sending
      * the resulting PendingIntent, all of the Intents are started in the same
diff --git a/core/java/android/appwidget/AppWidgetManager.java b/core/java/android/appwidget/AppWidgetManager.java
index 9c19766..6b1c3e2 100644
--- a/core/java/android/appwidget/AppWidgetManager.java
+++ b/core/java/android/appwidget/AppWidgetManager.java
@@ -239,7 +239,7 @@
     public static final String EXTRA_CUSTOM_SORT = "customSort";
 
     /**
-     * A sentiel value that the AppWidget manager will never return as a appWidgetId.
+     * A sentinel value that the AppWidget manager will never return as a appWidgetId.
      */
     public static final int INVALID_APPWIDGET_ID = 0;
 
diff --git a/core/java/android/content/AsyncTaskLoader.java b/core/java/android/content/AsyncTaskLoader.java
index f9025d9..188c786 100644
--- a/core/java/android/content/AsyncTaskLoader.java
+++ b/core/java/android/content/AsyncTaskLoader.java
@@ -78,7 +78,7 @@
                     // So we treat this case as an unhandled exception.
                     throw ex;
                 }
-                if (DEBUG) Slog.v(TAG, this + "  <<< doInBackground (was canceled)");
+                if (DEBUG) Slog.v(TAG, this + "  <<< doInBackground (was canceled)", ex);
                 return null;
             }
         }
diff --git a/core/java/android/content/ContentProviderNative.java b/core/java/android/content/ContentProviderNative.java
index 550a1c9..384ba57 100644
--- a/core/java/android/content/ContentProviderNative.java
+++ b/core/java/android/content/ContentProviderNative.java
@@ -113,13 +113,21 @@
                     Cursor cursor = query(url, projection, selection, selectionArgs, sortOrder,
                             cancellationSignal);
                     if (cursor != null) {
-                        CursorToBulkCursorAdaptor adaptor = new CursorToBulkCursorAdaptor(
-                                cursor, observer, getProviderName());
-                        BulkCursorDescriptor d = adaptor.getBulkCursorDescriptor();
+                        try {
+                            CursorToBulkCursorAdaptor adaptor = new CursorToBulkCursorAdaptor(
+                                    cursor, observer, getProviderName());
+                            BulkCursorDescriptor d = adaptor.getBulkCursorDescriptor();
+                            cursor = null;
 
-                        reply.writeNoException();
-                        reply.writeInt(1);
-                        d.writeToParcel(reply, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
+                            reply.writeNoException();
+                            reply.writeInt(1);
+                            d.writeToParcel(reply, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
+                        } finally {
+                            // Close cursor if an exception was thrown while constructing the adaptor.
+                            if (cursor != null) {
+                                cursor.close();
+                            }
+                        }
                     } else {
                         reply.writeNoException();
                         reply.writeInt(0);
diff --git a/core/java/android/content/ContentResolver.java b/core/java/android/content/ContentResolver.java
index e34c827..86bf8c2 100644
--- a/core/java/android/content/ContentResolver.java
+++ b/core/java/android/content/ContentResolver.java
@@ -381,6 +381,7 @@
             return null;
         }
         IContentProvider stableProvider = null;
+        Cursor qCursor = null;
         try {
             long startTime = SystemClock.uptimeMillis();
 
@@ -390,7 +391,6 @@
                 remoteCancellationSignal = unstableProvider.createCancellationSignal();
                 cancellationSignal.setRemote(remoteCancellationSignal);
             }
-            Cursor qCursor;
             try {
                 qCursor = unstableProvider.query(uri, projection,
                         selection, selectionArgs, sortOrder, remoteCancellationSignal);
@@ -409,20 +409,26 @@
             if (qCursor == null) {
                 return null;
             }
-            // force query execution
+
+            // Force query execution.  Might fail and throw a runtime exception here.
             qCursor.getCount();
             long durationMillis = SystemClock.uptimeMillis() - startTime;
             maybeLogQueryToEventLog(durationMillis, uri, projection, selection, sortOrder);
-            // Wrap the cursor object into CursorWrapperInner object
+
+            // Wrap the cursor object into CursorWrapperInner object.
             CursorWrapperInner wrapper = new CursorWrapperInner(qCursor,
                     stableProvider != null ? stableProvider : acquireProvider(uri));
             stableProvider = null;
+            qCursor = null;
             return wrapper;
         } catch (RemoteException e) {
             // Arbitrary and not worth documenting, as Activity
             // Manager will kill this process shortly anyway.
             return null;
         } finally {
+            if (qCursor != null) {
+                qCursor.close();
+            }
             if (unstableProvider != null) {
                 releaseUnstableProvider(unstableProvider);
             }
diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java
index 257f84e..41d470b 100644
--- a/core/java/android/content/Context.java
+++ b/core/java/android/content/Context.java
@@ -64,44 +64,30 @@
      */
     public static final int MODE_PRIVATE = 0x0000;
     /**
+     * @deprecated Creating world-readable files is very dangerous, and likely
+     * to cause security holes in applications.  It is strongly discouraged;
+     * instead, applications should use more formal mechanism for interactions
+     * such as {@link ContentProvider}, {@link BroadcastReceiver}, and
+     * {@link android.app.Service}.  There are no guarantees that this
+     * access mode will remain on a file, such as when it goes through a
+     * backup and restore.
      * File creation mode: allow all other applications to have read access
      * to the created file.
-     *
-     * <b>Note:</b> Applications with {@code targetSdkVersion}
-     * {@link android.os.Build.VERSION_CODES#K} or greater have home directories
-     * with {@code 0700} permissions. Because an application's home directory
-     * is no longer world-accessible, world-readable files created within the
-     * application's home directory will not be accessible to other applications.
-     *
-     * @deprecated Creating world-readable files is very dangerous, and likely
-     *     to cause security holes in applications.  It is strongly discouraged;
-     *     instead, applications should use more formal mechanism for interactions
-     *     such as {@link ContentProvider}, {@link BroadcastReceiver}, and
-     *     {@link android.app.Service}.  There are no guarantees that this
-     *     access mode will remain on a file, such as when it goes through a
-     *     backup and restore.
      * @see #MODE_PRIVATE
      * @see #MODE_WORLD_WRITEABLE
      */
     @Deprecated
     public static final int MODE_WORLD_READABLE = 0x0001;
     /**
+     * @deprecated Creating world-writable files is very dangerous, and likely
+     * to cause security holes in applications.  It is strongly discouraged;
+     * instead, applications should use more formal mechanism for interactions
+     * such as {@link ContentProvider}, {@link BroadcastReceiver}, and
+     * {@link android.app.Service}.  There are no guarantees that this
+     * access mode will remain on a file, such as when it goes through a
+     * backup and restore.
      * File creation mode: allow all other applications to have write access
      * to the created file.
-     *
-     * <b>Note:</b> Applications with {@code targetSdkVersion}
-     * {@link android.os.Build.VERSION_CODES#K} or greater have home directories
-     * with {@code 0700} permissions. Because an application's home directory
-     * is no longer world-accessible, world-writable files created within the
-     * application's home directory will not be accessible to other applications.
-     *
-     * @deprecated Creating world-writable files is very dangerous, and likely
-     *     to cause security holes in applications.  It is strongly discouraged;
-     *     instead, applications should use more formal mechanism for interactions
-     *     such as {@link ContentProvider}, {@link BroadcastReceiver}, and
-     *     {@link android.app.Service}.  There are no guarantees that this
-     *     access mode will remain on a file, such as when it goes through a
-     *     backup and restore.
      * @see #MODE_PRIVATE
      * @see #MODE_WORLD_READABLE
      */
@@ -515,22 +501,18 @@
         throws FileNotFoundException;
 
     /**
-     * Open a file associated with this Context's application package
+     * Open a private file associated with this Context's application package
      * for writing.  Creates the file if it doesn't already exist.
      *
-     * <b>Note:</b> Applications with {@code targetSdkVersion}
-     * {@link android.os.Build.VERSION_CODES#K} or greater have home directories
-     * with {@code 0700} permissions. Because an application's home directory
-     * is no longer world-accessible, files created with {@code mode}
-     * {@link #MODE_WORLD_READABLE} or {@link #MODE_WORLD_WRITEABLE} will not be
-     * accessible to other applications.
-     *
-     * @param name The name of the file to open; can not contain path separators.
+     * @param name The name of the file to open; can not contain path
+     *             separators.
      * @param mode Operating mode.  Use 0 or {@link #MODE_PRIVATE} for the
-     *     default operation, {@link #MODE_APPEND} to append to an existing file,
-     *     {@link #MODE_WORLD_READABLE} and {@link #MODE_WORLD_WRITEABLE} to control
-     *     permissions.
+     * default operation, {@link #MODE_APPEND} to append to an existing file,
+     * {@link #MODE_WORLD_READABLE} and {@link #MODE_WORLD_WRITEABLE} to control
+     * permissions.
+     *
      * @return FileOutputStream Resulting output stream.
+     *
      * @see #MODE_APPEND
      * @see #MODE_PRIVATE
      * @see #MODE_WORLD_READABLE
@@ -756,19 +738,14 @@
      * application; you can only set the mode of the entire directory, not
      * of individual files.
      *
-     * <b>Note:</b> Applications with {@code targetSdkVersion}
-     * {@link android.os.Build.VERSION_CODES#K} or greater have home directories
-     * with {@code 0700} permissions. Because an application's home directory
-     * is no longer world-accessible, world-readable / world-writable directories
-     * created using this method will not be accessible to other applications.
-     *
      * @param name Name of the directory to retrieve.  This is a directory
-     *     that is created as part of your application data.
+     * that is created as part of your application data.
      * @param mode Operating mode.  Use 0 or {@link #MODE_PRIVATE} for the
-     *     default operation, {@link #MODE_WORLD_READABLE} and
-     *     {@link #MODE_WORLD_WRITEABLE} to control permissions.
+     * default operation, {@link #MODE_WORLD_READABLE} and
+     * {@link #MODE_WORLD_WRITEABLE} to control permissions.
+     *
      * @return Returns a File object for the requested directory.  The directory
-     *     will have been created if it does not already exist.
+     * will have been created if it does not already exist.
      *
      * @see #openFileOutput(String, int)
      */
@@ -778,13 +755,6 @@
      * Open a new private SQLiteDatabase associated with this Context's
      * application package.  Create the database file if it doesn't exist.
      *
-     * <b>Note:</b> Applications with {@code targetSdkVersion}
-     * {@link android.os.Build.VERSION_CODES#K} or greater have home directories
-     * with {@code 0700} permissions. Because an application's home directory
-     * is no longer world-accessible, {@code SQLiteDatabase}s created with {@code mode}
-     * {@link #MODE_WORLD_READABLE} or {@link #MODE_WORLD_WRITEABLE} will not be
-     * accessible to other applications.
-     *
      * @param name The name (unique in the application package) of the database.
      * @param mode Operating mode.  Use 0 or {@link #MODE_PRIVATE} for the
      *     default operation, {@link #MODE_WORLD_READABLE}
@@ -792,8 +762,10 @@
      *     Use {@link #MODE_ENABLE_WRITE_AHEAD_LOGGING} to enable write-ahead logging by default.
      * @param factory An optional factory class that is called to instantiate a
      *     cursor when query is called.
+     *
      * @return The contents of a newly created database with the given name.
      * @throws android.database.sqlite.SQLiteException if the database file could not be opened.
+     *
      * @see #MODE_PRIVATE
      * @see #MODE_WORLD_READABLE
      * @see #MODE_WORLD_WRITEABLE
@@ -810,13 +782,6 @@
      * <p>Accepts input param: a concrete instance of {@link DatabaseErrorHandler} to be
      * used to handle corruption when sqlite reports database corruption.</p>
      *
-     * <b>Note:</b> Applications with {@code targetSdkVersion}
-     * {@link android.os.Build.VERSION_CODES#K} or greater have home directories
-     * with {@code 0700} permissions. Because an application's home directory
-     * is no longer world-accessible, {@code SQLiteDatabase}s created with {@code mode}
-     * {@link #MODE_WORLD_READABLE} or {@link #MODE_WORLD_WRITEABLE} will not be
-     * accessible to other applications.
-     *
      * @param name The name (unique in the application package) of the database.
      * @param mode Operating mode.  Use 0 or {@link #MODE_PRIVATE} for the
      *     default operation, {@link #MODE_WORLD_READABLE}
@@ -825,9 +790,10 @@
      * @param factory An optional factory class that is called to instantiate a
      *     cursor when query is called.
      * @param errorHandler the {@link DatabaseErrorHandler} to be used when sqlite reports database
-     *     corruption. if null, {@link android.database.DefaultDatabaseErrorHandler} is assumed.
+     * corruption. if null, {@link android.database.DefaultDatabaseErrorHandler} is assumed.
      * @return The contents of a newly created database with the given name.
      * @throws android.database.sqlite.SQLiteException if the database file could not be opened.
+     *
      * @see #MODE_PRIVATE
      * @see #MODE_WORLD_READABLE
      * @see #MODE_WORLD_WRITEABLE
@@ -2289,6 +2255,18 @@
     public static final String USER_SERVICE = "user";
 
     /**
+     * Use with {@link #getSystemService} to retrieve a
+     * {@link android.app.AppOpsManager} for tracking application operations
+     * on the device.
+     *
+     * @see #getSystemService
+     * @see android.app.AppOpsManager
+     *
+     * @hide
+     */
+    public static final String APP_OPS_SERVICE = "appops";
+
+    /**
      * Determine whether the given permission is allowed for a particular
      * process and user ID running in the system.
      *
diff --git a/core/java/android/content/CursorLoader.java b/core/java/android/content/CursorLoader.java
index 9f7a104..4e89dec 100644
--- a/core/java/android/content/CursorLoader.java
+++ b/core/java/android/content/CursorLoader.java
@@ -65,9 +65,14 @@
             Cursor cursor = getContext().getContentResolver().query(mUri, mProjection, mSelection,
                     mSelectionArgs, mSortOrder, mCancellationSignal);
             if (cursor != null) {
-                // Ensure the cursor window is filled
-                cursor.getCount();
-                registerContentObserver(cursor, mObserver);
+                try {
+                    // Ensure the cursor window is filled.
+                    cursor.getCount();
+                    registerContentObserver(cursor, mObserver);
+                } catch (RuntimeException ex) {
+                    cursor.close();
+                    throw ex;
+                }
             }
             return cursor;
         } finally {
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java
index cf0603e..89b1bbd 100644
--- a/core/java/android/content/Intent.java
+++ b/core/java/android/content/Intent.java
@@ -1950,7 +1950,7 @@
 
     /**
      * Broadcast Action:  External media is present, but not mounted at its mount point.
-     * The path to the mount point for the removed media is contained in the Intent.mData field.
+     * The path to the mount point for the unmounted media is contained in the Intent.mData field.
      */
     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
     public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
@@ -1971,7 +1971,7 @@
 
     /**
      * Broadcast Action:  External media is present and mounted at its mount point.
-     * The path to the mount point for the removed media is contained in the Intent.mData field.
+     * The path to the mount point for the mounted media is contained in the Intent.mData field.
      * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
      * media was mounted read only.
      */
@@ -2002,7 +2002,7 @@
 
     /**
      * Broadcast Action:  External media is present but cannot be mounted.
-     * The path to the mount point for the removed media is contained in the Intent.mData field.
+     * The path to the mount point for the unmountable media is contained in the Intent.mData field.
      */
     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
     public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java
index 8ba1988..cdd9195 100644
--- a/core/java/android/content/pm/PackageManager.java
+++ b/core/java/android/content/pm/PackageManager.java
@@ -1280,6 +1280,22 @@
             throws NameNotFoundException;
 
     /**
+     * @hide Return the uid associated with the given package name for the
+     * given user.
+     *
+     * <p>Throws {@link NameNotFoundException} if a package with the given
+     * name can not be found on the system.
+     *
+     * @param packageName The full name (i.e. com.google.apps.contacts) of the
+     *                    desired package.
+     * @param userHandle The user handle identifier to look up the package under.
+     *
+     * @return Returns an integer uid who owns the given package name.
+     */
+    public abstract int getPackageUid(String packageName, int userHandle)
+            throws NameNotFoundException;
+
+    /**
      * Retrieve all of the information we know about a particular permission.
      *
      * <p>Throws {@link NameNotFoundException} if a permission with the given
diff --git a/core/java/android/database/CursorToBulkCursorAdaptor.java b/core/java/android/database/CursorToBulkCursorAdaptor.java
index 525be96..82a61d4 100644
--- a/core/java/android/database/CursorToBulkCursorAdaptor.java
+++ b/core/java/android/database/CursorToBulkCursorAdaptor.java
@@ -132,6 +132,11 @@
         }
     }
 
+    /**
+     * Returns an object that contains sufficient metadata to reconstruct
+     * the cursor remotely.  May throw if an error occurs when executing the query
+     * and obtaining the row count.
+     */
     public BulkCursorDescriptor getBulkCursorDescriptor() {
         synchronized (mLock) {
             throwIfCursorIsClosed();
diff --git a/core/java/android/database/sqlite/SQLiteCursor.java b/core/java/android/database/sqlite/SQLiteCursor.java
index b29897e..5a1a8e2 100644
--- a/core/java/android/database/sqlite/SQLiteCursor.java
+++ b/core/java/android/database/sqlite/SQLiteCursor.java
@@ -138,17 +138,26 @@
     private void fillWindow(int requiredPos) {
         clearOrCreateWindow(getDatabase().getPath());
 
-        if (mCount == NO_COUNT) {
-            int startPos = DatabaseUtils.cursorPickFillWindowStartPosition(requiredPos, 0);
-            mCount = mQuery.fillWindow(mWindow, startPos, requiredPos, true);
-            mCursorWindowCapacity = mWindow.getNumRows();
-            if (Log.isLoggable(TAG, Log.DEBUG)) {
-                Log.d(TAG, "received count(*) from native_fill_window: " + mCount);
+        try {
+            if (mCount == NO_COUNT) {
+                int startPos = DatabaseUtils.cursorPickFillWindowStartPosition(requiredPos, 0);
+                mCount = mQuery.fillWindow(mWindow, startPos, requiredPos, true);
+                mCursorWindowCapacity = mWindow.getNumRows();
+                if (Log.isLoggable(TAG, Log.DEBUG)) {
+                    Log.d(TAG, "received count(*) from native_fill_window: " + mCount);
+                }
+            } else {
+                int startPos = DatabaseUtils.cursorPickFillWindowStartPosition(requiredPos,
+                        mCursorWindowCapacity);
+                mQuery.fillWindow(mWindow, startPos, requiredPos, false);
             }
-        } else {
-            int startPos = DatabaseUtils.cursorPickFillWindowStartPosition(requiredPos,
-                    mCursorWindowCapacity);
-            mQuery.fillWindow(mWindow, startPos, requiredPos, false);
+        } catch (RuntimeException ex) {
+            // Close the cursor window if the query failed and therefore will
+            // not produce any results.  This helps to avoid accidentally leaking
+            // the cursor window if the client does not correctly handle exceptions
+            // and fails to close the cursor.
+            closeWindow();
+            throw ex;
         }
     }
 
diff --git a/core/java/android/net/NetworkInfo.java b/core/java/android/net/NetworkInfo.java
index 0b23cb7..689dae5 100644
--- a/core/java/android/net/NetworkInfo.java
+++ b/core/java/android/net/NetworkInfo.java
@@ -19,6 +19,8 @@
 import android.os.Parcelable;
 import android.os.Parcel;
 
+import com.android.internal.annotations.VisibleForTesting;
+
 import java.util.EnumMap;
 
 /**
@@ -312,7 +314,9 @@
         }
     }
 
-    void setRoaming(boolean isRoaming) {
+    /** {@hide} */
+    @VisibleForTesting
+    public void setRoaming(boolean isRoaming) {
         synchronized (this) {
             mIsRoaming = isRoaming;
         }
diff --git a/core/java/android/net/http/SslCertificate.java b/core/java/android/net/http/SslCertificate.java
index fe6d4eb..5b60c0d 100644
--- a/core/java/android/net/http/SslCertificate.java
+++ b/core/java/android/net/http/SslCertificate.java
@@ -334,9 +334,11 @@
 
     /**
      * A distinguished name helper class: a 3-tuple of:
-     * - common name (CN),
-     * - organization (O),
-     * - organizational unit (OU)
+     * <ul>
+     *   <li>the most specific common name (CN)</li>
+     *   <li>the most specific organization (O)</li>
+     *   <li>the most specific organizational unit (OU)</li>
+     * <ul>
      */
     public class DName {
         /**
@@ -360,8 +362,15 @@
         private String mUName;
 
         /**
-         * Creates a new distinguished name
-         * @param dName The distinguished name
+         * Creates a new {@code DName} from a string. The attributes
+         * are assumed to come in most significant to least
+         * significant order which is true of human readable values
+         * returned by methods such as {@code X500Principal.getName()}.
+         * Be aware that the underlying sources of distinguished names
+         * such as instances of {@code X509Certificate} are encoded in
+         * least significant to most significant order, so make sure
+         * the value passed here has the expected ordering of
+         * attributes.
          */
         public DName(String dName) {
             if (dName != null) {
@@ -374,18 +383,24 @@
 
                     for (int i = 0; i < oid.size(); i++) {
                         if (oid.elementAt(i).equals(X509Name.CN)) {
-                            mCName = (String) val.elementAt(i);
+                            if (mCName == null) {
+                                mCName = (String) val.elementAt(i);
+                            }
                             continue;
                         }
 
                         if (oid.elementAt(i).equals(X509Name.O)) {
-                            mOName = (String) val.elementAt(i);
-                            continue;
+                            if (mOName == null) {
+                                mOName = (String) val.elementAt(i);
+                                continue;
+                            }
                         }
 
                         if (oid.elementAt(i).equals(X509Name.OU)) {
-                            mUName = (String) val.elementAt(i);
-                            continue;
+                            if (mUName == null) {
+                                mUName = (String) val.elementAt(i);
+                                continue;
+                            }
                         }
                     }
                 } catch (IllegalArgumentException ex) {
@@ -402,21 +417,21 @@
         }
 
         /**
-         * @return The Common-name (CN) component of this name
+         * @return The most specific Common-name (CN) component of this name
          */
         public String getCName() {
             return mCName != null ? mCName : "";
         }
 
         /**
-         * @return The Organization (O) component of this name
+         * @return The most specific Organization (O) component of this name
          */
         public String getOName() {
             return mOName != null ? mOName : "";
         }
 
         /**
-         * @return The Organizational Unit (OU) component of this name
+         * @return The most specific Organizational Unit (OU) component of this name
          */
         public String getUName() {
             return mUName != null ? mUName : "";
diff --git a/core/java/android/nfc/NfcActivityManager.java b/core/java/android/nfc/NfcActivityManager.java
index 53b41d5..7c3123f 100644
--- a/core/java/android/nfc/NfcActivityManager.java
+++ b/core/java/android/nfc/NfcActivityManager.java
@@ -197,7 +197,7 @@
             isResumed = state.resumed;
         }
         if (isResumed) {
-            requestNfcServiceCallback(true);
+            requestNfcServiceCallback();
         }
     }
 
@@ -211,7 +211,7 @@
             isResumed = state.resumed;
         }
         if (isResumed) {
-            requestNfcServiceCallback(true);
+            requestNfcServiceCallback();
         }
     }
 
@@ -223,7 +223,7 @@
             isResumed = state.resumed;
         }
         if (isResumed) {
-            requestNfcServiceCallback(true);
+            requestNfcServiceCallback();
         }
     }
 
@@ -236,7 +236,7 @@
             isResumed = state.resumed;
         }
         if (isResumed) {
-            requestNfcServiceCallback(true);
+            requestNfcServiceCallback();
         }
     }
 
@@ -249,18 +249,17 @@
             isResumed = state.resumed;
         }
         if (isResumed) {
-            requestNfcServiceCallback(true);
+            requestNfcServiceCallback();
         }
     }
 
     /**
      * Request or unrequest NFC service callbacks for NDEF push.
      * Makes IPC call - do not hold lock.
-     * TODO: Do not do IPC on every onPause/onResume
      */
-    void requestNfcServiceCallback(boolean request) {
+    void requestNfcServiceCallback() {
         try {
-            NfcAdapter.sService.setNdefPushCallback(request ? this : null);
+            NfcAdapter.sService.setNdefPushCallback(this);
         } catch (RemoteException e) {
             mAdapter.attemptDeadServiceRecovery(e);
         }
@@ -355,7 +354,7 @@
             if (state == null) return;
             state.resumed = true;
         }
-        requestNfcServiceCallback(true);
+        requestNfcServiceCallback();
     }
 
     /** Callback from Activity life-cycle, on main thread */
@@ -367,7 +366,6 @@
             if (state == null) return;
             state.resumed = false;
         }
-        requestNfcServiceCallback(false);
     }
 
     /** Callback from Activity life-cycle, on main thread */
diff --git a/core/java/android/nfc/NfcAdapter.java b/core/java/android/nfc/NfcAdapter.java
index 4baceed..6ad382b 100644
--- a/core/java/android/nfc/NfcAdapter.java
+++ b/core/java/android/nfc/NfcAdapter.java
@@ -174,31 +174,25 @@
      * Broadcast Action: The state of the local NFC adapter has been
      * changed.
      * <p>For example, NFC has been turned on or off.
-     * <p>Always contains the extra field {@link #EXTRA_STATE}
-     * @hide
+     * <p>Always contains the extra field {@link #EXTRA_ADAPTER_STATE}
      */
     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
     public static final String ACTION_ADAPTER_STATE_CHANGED =
             "android.nfc.action.ADAPTER_STATE_CHANGED";
 
     /**
-     * Used as an int extra field in {@link #ACTION_STATE_CHANGED}
+     * Used as an int extra field in {@link #ACTION_ADAPTER_STATE_CHANGED}
      * intents to request the current power state. Possible values are:
      * {@link #STATE_OFF},
      * {@link #STATE_TURNING_ON},
      * {@link #STATE_ON},
      * {@link #STATE_TURNING_OFF},
-     * @hide
      */
     public static final String EXTRA_ADAPTER_STATE = "android.nfc.extra.ADAPTER_STATE";
 
-    /** @hide */
     public static final int STATE_OFF = 1;
-    /** @hide */
     public static final int STATE_TURNING_ON = 2;
-    /** @hide */
     public static final int STATE_ON = 3;
-    /** @hide */
     public static final int STATE_TURNING_OFF = 4;
 
     /** @hide */
diff --git a/core/java/android/os/BatteryStats.java b/core/java/android/os/BatteryStats.java
index 9821824..abbb6a1 100644
--- a/core/java/android/os/BatteryStats.java
+++ b/core/java/android/os/BatteryStats.java
@@ -93,6 +93,11 @@
     public static final int VIDEO_TURNED_ON = 8;
 
     /**
+     * A constant indicating a vibrator on timer
+     */
+    public static final int VIBRATOR_ON = 9;
+
+    /**
      * Include all of the data in the stats, including previously saved data.
      */
     public static final int STATS_SINCE_CHARGED = 0;
@@ -131,6 +136,7 @@
     private static final String APK_DATA = "apk";
     private static final String PROCESS_DATA = "pr";
     private static final String SENSOR_DATA = "sr";
+    private static final String VIBRATOR_DATA = "vib";
     private static final String WAKELOCK_DATA = "wl";
     private static final String KERNEL_WAKELOCK_DATA = "kwl";
     private static final String NETWORK_DATA = "nt";
@@ -277,6 +283,7 @@
                                                   int which);
         public abstract long getAudioTurnedOnTime(long batteryRealtime, int which);
         public abstract long getVideoTurnedOnTime(long batteryRealtime, int which);
+        public abstract Timer getVibratorOnTimer();
 
         /**
          * Note that these must match the constants in android.os.PowerManager.
@@ -1395,6 +1402,16 @@
                 }
             }
 
+            Timer vibTimer = u.getVibratorOnTimer();
+            if (vibTimer != null) {
+                // Convert from microseconds to milliseconds with rounding
+                long totalTime = (vibTimer.getTotalTimeLocked(batteryRealtime, which) + 500) / 1000;
+                int count = vibTimer.getCountLocked(which);
+                if (totalTime != 0) {
+                    dumpLine(pw, uid, category, VIBRATOR_DATA, totalTime, count);
+                }
+            }
+
             Map<String, ? extends BatteryStats.Uid.Proc> processStats = u.getProcessStats();
             if (processStats.size() > 0) {
                 for (Map.Entry<String, ? extends BatteryStats.Uid.Proc> ent
@@ -1919,6 +1936,26 @@
                 }
             }
 
+            Timer vibTimer = u.getVibratorOnTimer();
+            if (vibTimer != null) {
+                // Convert from microseconds to milliseconds with rounding
+                long totalTime = (vibTimer.getTotalTimeLocked(
+                        batteryRealtime, which) + 500) / 1000;
+                int count = vibTimer.getCountLocked(which);
+                //timer.logState();
+                if (totalTime != 0) {
+                    sb.setLength(0);
+                    sb.append(prefix);
+                    sb.append("    Vibrator: ");
+                    formatTimeMs(sb, totalTime);
+                    sb.append("realtime (");
+                    sb.append(count);
+                    sb.append(" times)");
+                    pw.println(sb.toString());
+                    uidActivity = true;
+                }
+            }
+
             Map<String, ? extends BatteryStats.Uid.Proc> processStats = u.getProcessStats();
             if (processStats.size() > 0) {
                 for (Map.Entry<String, ? extends BatteryStats.Uid.Proc> ent
diff --git a/core/java/android/os/Build.java b/core/java/android/os/Build.java
index d69d2a6..52c89e8 100644
--- a/core/java/android/os/Build.java
+++ b/core/java/android/os/Build.java
@@ -434,12 +434,6 @@
 
         /**
          * Android X.X: "K".  Just "K"
-         *
-         * <p>Applications targeting this or a later release will get these
-         * new changes in behavior:</p>
-         * <ul>
-         * <li>Application home directory permissions are now {@code 0700}.</li>
-         * </ul>
          */
         public static final int K = CUR_DEVELOPMENT;
     }
diff --git a/core/java/android/os/FileObserver.java b/core/java/android/os/FileObserver.java
index 667ce68..d633486 100644
--- a/core/java/android/os/FileObserver.java
+++ b/core/java/android/os/FileObserver.java
@@ -32,7 +32,7 @@
  *
  * <p>Each FileObserver instance monitors a single file or directory.
  * If a directory is monitored, events will be triggered for all files and
- * subdirectories (recursively) inside the monitored directory.</p>
+ * subdirectories inside the monitored directory.</p>
  *
  * <p>An event mask is used to specify which changes or actions to report.
  * Event type constants are used to describe the possible changes in the
diff --git a/core/java/android/os/IVibratorService.aidl b/core/java/android/os/IVibratorService.aidl
index 2c2fe8a..15cedf9 100644
--- a/core/java/android/os/IVibratorService.aidl
+++ b/core/java/android/os/IVibratorService.aidl
@@ -20,8 +20,8 @@
 interface IVibratorService
 {
     boolean hasVibrator();
-    void vibrate(long milliseconds, IBinder token);
-    void vibratePattern(in long[] pattern, int repeat, IBinder token);
+    void vibrate(String packageName, long milliseconds, IBinder token);
+    void vibratePattern(String packageName, in long[] pattern, int repeat, IBinder token);
     void cancelVibrate(IBinder token);
 }
 
diff --git a/core/java/android/os/SystemVibrator.java b/core/java/android/os/SystemVibrator.java
index 7c5a47e..54ea385 100644
--- a/core/java/android/os/SystemVibrator.java
+++ b/core/java/android/os/SystemVibrator.java
@@ -16,6 +16,7 @@
 
 package android.os;
 
+import android.content.Context;
 import android.util.Log;
 
 /**
@@ -26,10 +27,18 @@
 public class SystemVibrator extends Vibrator {
     private static final String TAG = "Vibrator";
 
+    private final String mPackageName;
     private final IVibratorService mService;
     private final Binder mToken = new Binder();
 
     public SystemVibrator() {
+        mPackageName = null;
+        mService = IVibratorService.Stub.asInterface(
+                ServiceManager.getService("vibrator"));
+    }
+
+    public SystemVibrator(Context context) {
+        mPackageName = context.getPackageName();
         mService = IVibratorService.Stub.asInterface(
                 ServiceManager.getService("vibrator"));
     }
@@ -54,7 +63,7 @@
             return;
         }
         try {
-            mService.vibrate(milliseconds, mToken);
+            mService.vibrate(mPackageName, milliseconds, mToken);
         } catch (RemoteException e) {
             Log.w(TAG, "Failed to vibrate.", e);
         }
@@ -71,7 +80,7 @@
         // anyway
         if (repeat < pattern.length) {
             try {
-                mService.vibratePattern(pattern, repeat, mToken);
+                mService.vibratePattern(mPackageName, pattern, repeat, mToken);
             } catch (RemoteException e) {
                 Log.w(TAG, "Failed to vibrate.", e);
             }
diff --git a/core/java/android/os/UserHandle.java b/core/java/android/os/UserHandle.java
index cc96152..d205253 100644
--- a/core/java/android/os/UserHandle.java
+++ b/core/java/android/os/UserHandle.java
@@ -16,6 +16,8 @@
 
 package android.os;
 
+import java.io.PrintWriter;
+
 /**
  * Representation of a user on the device.
  */
@@ -152,6 +154,50 @@
     }
 
     /**
+     * Generate a text representation of the uid, breaking out its individual
+     * components -- user, app, isolated, etc.
+     * @hide
+     */
+    public static void formatUid(StringBuilder sb, int uid) {
+        if (uid < Process.FIRST_APPLICATION_UID) {
+            sb.append(uid);
+        } else {
+            sb.append('u');
+            sb.append(getUserId(uid));
+            final int appId = getAppId(uid);
+            if (appId >= Process.FIRST_ISOLATED_UID && appId <= Process.LAST_ISOLATED_UID) {
+                sb.append('i');
+                sb.append(appId - Process.FIRST_ISOLATED_UID);
+            } else {
+                sb.append('a');
+                sb.append(appId);
+            }
+        }
+    }
+
+    /**
+     * Generate a text representation of the uid, breaking out its individual
+     * components -- user, app, isolated, etc.
+     * @hide
+     */
+    public static void formatUid(PrintWriter pw, int uid) {
+        if (uid < Process.FIRST_APPLICATION_UID) {
+            pw.print(uid);
+        } else {
+            pw.print('u');
+            pw.print(getUserId(uid));
+            final int appId = getAppId(uid);
+            if (appId >= Process.FIRST_ISOLATED_UID && appId <= Process.LAST_ISOLATED_UID) {
+                pw.print('i');
+                pw.print(appId - Process.FIRST_ISOLATED_UID);
+            } else {
+                pw.print('a');
+                pw.print(appId);
+            }
+        }
+    }
+
+    /**
      * Returns the user id of the current process
      * @return user id of the current process
      * @hide
diff --git a/core/java/android/provider/CalendarContract.java b/core/java/android/provider/CalendarContract.java
index af6e88e9..5fdca86 100644
--- a/core/java/android/provider/CalendarContract.java
+++ b/core/java/android/provider/CalendarContract.java
@@ -302,9 +302,16 @@
          * Used to indicate that local, unsynced, changes are present.
          * <P>Type: INTEGER (long)</P>
          */
+
         public static final String DIRTY = "dirty";
 
         /**
+         * Used in conjunction with {@link #DIRTY} to indicate what packages wrote local changes.
+         * <P>Type: TEXT</P>
+         */
+        public static final String MUTATORS = "mutators";
+
+        /**
          * Whether the row has been deleted but not synced to the server. A
          * deleted row should be ignored.
          * <P>
@@ -525,6 +532,7 @@
 
                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, _SYNC_ID);
                 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DIRTY);
+                DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, MUTATORS);
 
                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC1);
                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, CAL_SYNC2);
@@ -647,6 +655,7 @@
      * <li>{@link #CALENDAR_COLOR}</li>
      * <li>{@link #_SYNC_ID}</li>
      * <li>{@link #DIRTY}</li>
+     * <li>{@link #MUTATORS}</li>
      * <li>{@link #OWNER_ACCOUNT}</li>
      * <li>{@link #MAX_REMINDERS}</li>
      * <li>{@link #ALLOWED_REMINDERS}</li>
@@ -714,6 +723,7 @@
             ACCOUNT_TYPE,
             _SYNC_ID,
             DIRTY,
+            MUTATORS,
             OWNER_ACCOUNT,
             MAX_REMINDERS,
             ALLOWED_REMINDERS,
@@ -1393,6 +1403,7 @@
                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, IS_ORGANIZER);
                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, _SYNC_ID);
                 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DIRTY);
+                DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, MUTATORS);
                 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, LAST_SYNCED);
                 DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, DELETED);
                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC_DATA1);
@@ -1599,6 +1610,7 @@
      * The following Events columns are writable only by a sync adapter
      * <ul>
      * <li>{@link #DIRTY}</li>
+     * <li>{@link #MUTATORS}</li>
      * <li>{@link #_SYNC_ID}</li>
      * <li>{@link #SYNC_DATA1}</li>
      * <li>{@link #SYNC_DATA2}</li>
@@ -1688,6 +1700,7 @@
         public static final String[] SYNC_WRITABLE_COLUMNS = new String[] {
             _SYNC_ID,
             DIRTY,
+            MUTATORS,
             SYNC_DATA1,
             SYNC_DATA2,
             SYNC_DATA3,
diff --git a/core/java/android/text/DynamicLayout.java b/core/java/android/text/DynamicLayout.java
index d909362..122f8a1 100644
--- a/core/java/android/text/DynamicLayout.java
+++ b/core/java/android/text/DynamicLayout.java
@@ -503,8 +503,15 @@
 
         mNumberOfBlocks = newNumberOfBlocks;
         final int deltaLines = newLineCount - (endLine - startLine + 1);
-        for (int i = firstBlock + numAddedBlocks; i < mNumberOfBlocks; i++) {
-            mBlockEndLines[i] += deltaLines;
+        if (deltaLines != 0) {
+            // Display list whose index is >= mIndexFirstChangedBlock is valid
+            // but it needs to update its drawing location.
+            mIndexFirstChangedBlock = firstBlock + numAddedBlocks;
+            for (int i = mIndexFirstChangedBlock; i < mNumberOfBlocks; i++) {
+                mBlockEndLines[i] += deltaLines;
+            }
+        } else {
+            mIndexFirstChangedBlock = mNumberOfBlocks;
         }
 
         int blockIndex = firstBlock;
@@ -559,6 +566,20 @@
         return mNumberOfBlocks;
     }
 
+    /**
+     * @hide
+     */
+    public int getIndexFirstChangedBlock() {
+        return mIndexFirstChangedBlock;
+    }
+
+    /**
+     * @hide
+     */
+    public void setIndexFirstChangedBlock(int i) {
+        mIndexFirstChangedBlock = i;
+    }
+
     @Override
     public int getLineCount() {
         return mInts.size() - 1;
@@ -697,6 +718,8 @@
     private int[] mBlockIndices;
     // Number of items actually currently being used in the above 2 arrays
     private int mNumberOfBlocks;
+    // The first index of the blocks whose locations are changed
+    private int mIndexFirstChangedBlock;
 
     private int mTopPadding, mBottomPadding;
 
diff --git a/core/java/android/text/format/DateFormat.java b/core/java/android/text/format/DateFormat.java
index 3c984b5..352cb22 100644
--- a/core/java/android/text/format/DateFormat.java
+++ b/core/java/android/text/format/DateFormat.java
@@ -452,6 +452,16 @@
      * @hide
      */
     public static boolean hasSeconds(CharSequence inFormat) {
+        return hasDesignator(inFormat, SECONDS);
+    }
+
+    /**
+     * Test if a format string contains the given designator. Always returns
+     * {@code false} if the input format is {@code null}.
+     *
+     * @hide
+     */
+    public static boolean hasDesignator(CharSequence inFormat, char designator) {
         if (inFormat == null) return false;
 
         final int length = inFormat.length();
@@ -465,7 +475,7 @@
 
             if (c == QUOTE) {
                 count = skipQuotedText(inFormat, i, length);
-            } else if (c == SECONDS) {
+            } else if (c == designator) {
                 return true;
             }
         }
diff --git a/core/java/android/view/GLES20Canvas.java b/core/java/android/view/GLES20Canvas.java
index b64a06e..7739ff7 100644
--- a/core/java/android/view/GLES20Canvas.java
+++ b/core/java/android/view/GLES20Canvas.java
@@ -1013,6 +1013,17 @@
     private static native void nDrawPath(int renderer, int path, int paint);
     private static native void nDrawRects(int renderer, int region, int paint);
 
+    void drawRects(float[] rects, int count, Paint paint) {
+        int modifiers = setupModifiers(paint, MODIFIER_COLOR_FILTER | MODIFIER_SHADER);
+        try {
+            nDrawRects(mRenderer, rects, count, paint.mNativePaint);
+        } finally {
+            if (modifiers != MODIFIER_NONE) nResetModifiers(mRenderer, modifiers);
+        }
+    }
+
+    private static native void nDrawRects(int renderer, float[] rects, int count, int paint);
+
     @Override
     public void drawPicture(Picture picture) {
         if (picture.createdFromStream) {
diff --git a/core/java/android/view/HardwareRenderer.java b/core/java/android/view/HardwareRenderer.java
index 157c321..7ecdcbe 100644
--- a/core/java/android/view/HardwareRenderer.java
+++ b/core/java/android/view/HardwareRenderer.java
@@ -29,6 +29,7 @@
 import android.os.SystemClock;
 import android.os.SystemProperties;
 import android.os.Trace;
+import android.util.DisplayMetrics;
 import android.util.Log;
 import com.google.android.gles_jni.EGLImpl;
 
@@ -42,6 +43,7 @@
 
 import java.io.File;
 import java.io.PrintWriter;
+import java.util.Arrays;
 import java.util.concurrent.locks.ReentrantLock;
 
 import static javax.microedition.khronos.egl.EGL10.*;
@@ -87,13 +89,34 @@
      *
      * Possible values:
      * "true", to enable profiling
+     * "visual_bars", to enable profiling and visualize the results on screen
+     * "visual_lines", to enable profiling and visualize the results on screen
      * "false", to disable profiling
-     * 
+     *
+     * @see #PROFILE_PROPERTY_VISUALIZE_BARS
+     * @see #PROFILE_PROPERTY_VISUALIZE_LINES
+     *
      * @hide
      */
     public static final String PROFILE_PROPERTY = "debug.hwui.profile";
 
     /**
+     * Value for {@link #PROFILE_PROPERTY}. When the property is set to this
+     * value, profiling data will be visualized on screen as a bar chart.
+     *
+     * @hide
+     */
+    public static final String PROFILE_PROPERTY_VISUALIZE_BARS = "visual_bars";
+
+    /**
+     * Value for {@link #PROFILE_PROPERTY}. When the property is set to this
+     * value, profiling data will be visualized on screen as a line chart.
+     *
+     * @hide
+     */
+    public static final String PROFILE_PROPERTY_VISUALIZE_LINES = "visual_lines";
+
+    /**
      * System property used to specify the number of frames to be used
      * when doing hardware rendering profiling.
      * The default value of this property is #PROFILE_MAX_FRAMES.
@@ -342,7 +365,7 @@
      * Notifies EGL that the frame is about to be rendered.
      * @param size
      */
-    private static void beginFrame(int[] size) {
+    static void beginFrame(int[] size) {
         nBeginFrame(size);
     }
 
@@ -607,6 +630,100 @@
         mRequested = requested;
     }
 
+    /**
+     * Describes a series of frames that should be drawn on screen as a graph.
+     * Each frame is composed of 1 or more elements.
+     */
+    abstract class GraphDataProvider {
+        /**
+         * Draws the graph as bars. Frame elements are stacked on top of
+         * each other.
+         */
+        public static final int GRAPH_TYPE_BARS = 0;
+        /**
+         * Draws the graph as lines. The number of series drawn corresponds
+         * to the number of elements.
+         */
+        public static final int GRAPH_TYPE_LINES = 1;
+
+        /**
+         * Returns the type of graph to render.
+         *
+         * @return {@link #GRAPH_TYPE_BARS} or {@link #GRAPH_TYPE_LINES}
+         */
+        abstract int getGraphType();
+
+        /**
+         * This method is invoked before the graph is drawn. This method
+         * can be used to compute sizes, etc.
+         *
+         * @param metrics The display metrics
+         */
+        abstract void prepare(DisplayMetrics metrics);
+
+        /**
+         * @return The size in pixels of a vertical unit.
+         */
+        abstract int getVerticalUnitSize();
+
+        /**
+         * @return The size in pixels of a horizontal unit.
+         */
+        abstract int getHorizontalUnitSize();
+
+        /**
+         * @return The size in pixels of the margin between horizontal units.
+         */
+        abstract int getHorizontaUnitMargin();
+
+        /**
+         * An optional threshold value.
+         *
+         * @return A value >= 0 to draw the threshold, a negative value
+         *         to ignore it.
+         */
+        abstract float getThreshold();
+
+        /**
+         * The data to draw in the graph. The number of elements in the
+         * array must be at least {@link #getFrameCount()} * {@link #getElementCount()}.
+         * If a value is negative the following values will be ignored.
+         */
+        abstract float[] getData();
+
+        /**
+         * Returns the number of frames to render in the graph.
+         */
+        abstract int getFrameCount();
+
+        /**
+         * Returns the number of elements in each frame. This directly affects
+         * the number of series drawn in the graph.
+         */
+        abstract int getElementCount();
+
+        /**
+         * Returns the current frame, if any. If the returned value is negative
+         * the current frame is ignored.
+         */
+        abstract int getCurrentFrame();
+
+        /**
+         * Prepares the paint to draw the specified element (or series.)
+         */
+        abstract void setupGraphPaint(Paint paint, int elementIndex);
+
+        /**
+         * Prepares the paint to draw the threshold.
+         */
+        abstract void setupThresholdPaint(Paint paint);
+
+        /**
+         * Prepares the paint to draw the current frame indicator.
+         */
+        abstract void setupCurrentFramePaint(Paint paint);
+    }
+
     @SuppressWarnings({"deprecation"})
     static abstract class GlRenderer extends HardwareRenderer {
         static final int SURFACE_STATE_ERROR = 0;
@@ -615,6 +732,14 @@
 
         static final int FUNCTOR_PROCESS_DELAY = 4;
 
+        private static final int PROFILE_DRAW_MARGIN = 0;
+        private static final int PROFILE_DRAW_WIDTH = 3;
+        private static final int[] PROFILE_DRAW_COLORS = { 0xcf3e66cc, 0xcfdc3912, 0xcfe69800 };
+        private static final int PROFILE_DRAW_CURRENT_FRAME_COLOR = 0xcf5faa4d;
+        private static final int PROFILE_DRAW_THRESHOLD_COLOR = 0xff5faa4d;
+        private static final int PROFILE_DRAW_THRESHOLD_STROKE_WIDTH = 2;
+        private static final int PROFILE_DRAW_DP_PER_MS = 7;
+
         static EGL10 sEgl;
         static EGLDisplay sEglDisplay;
         static EGLConfig sEglConfig;
@@ -648,10 +773,15 @@
         boolean mUpdateDirtyRegions;
 
         boolean mProfileEnabled;
+        int mProfileVisualizerType = -1;
         float[] mProfileData;
         ReentrantLock mProfileLock;
         int mProfileCurrentFrame = -PROFILE_FRAME_DATA_COUNT;
-        
+
+        GraphDataProvider mDebugDataProvider;
+        float[][] mProfileShapes;
+        Paint mProfilePaint;
+
         boolean mDebugDirtyRegions;
         boolean mShowOverdraw;
 
@@ -672,20 +802,47 @@
             loadSystemProperties(null);
         }
 
+        private static final String[] VISUALIZERS = {
+                PROFILE_PROPERTY_VISUALIZE_BARS,
+                PROFILE_PROPERTY_VISUALIZE_LINES
+        };
+
         @Override
         boolean loadSystemProperties(Surface surface) {
+            boolean value;
             boolean changed = false;
 
-            boolean value = SystemProperties.getBoolean(PROFILE_PROPERTY, false);
+            String profiling = SystemProperties.get(PROFILE_PROPERTY);
+            int graphType = Arrays.binarySearch(VISUALIZERS, profiling);
+            value = graphType >= 0;
+
+            if (graphType != mProfileVisualizerType) {
+                changed = true;
+                mProfileVisualizerType = graphType;
+
+                mProfileShapes = null;
+                mProfilePaint = null;
+
+                if (value) {
+                    mDebugDataProvider = new DrawPerformanceDataProvider(graphType);
+                } else {
+                    mDebugDataProvider = null;
+                }
+            }
+
+            // If on-screen profiling is not enabled, we need to check whether
+            // console profiling only is enabled
+            if (!value) {
+                value = Boolean.parseBoolean(profiling);
+            }
+
             if (value != mProfileEnabled) {
                 changed = true;
                 mProfileEnabled = value;
 
                 if (mProfileEnabled) {
                     Log.d(LOG_TAG, "Profiling hardware renderer");
-                }
 
-                if (mProfileEnabled) {
                     int maxProfileFrames = SystemProperties.getInt(PROFILE_MAXFRAMES_PROPERTY,
                             PROFILE_MAX_FRAMES);
                     mProfileData = new float[maxProfileFrames * PROFILE_FRAME_DATA_COUNT];
@@ -697,7 +854,10 @@
                 } else {
                     mProfileData = null;
                     mProfileLock = null;
+                    mProfileVisualizerType = -1;
                 }
+
+                mProfileCurrentFrame = -PROFILE_FRAME_DATA_COUNT;
             }
 
             value = SystemProperties.getBoolean(DEBUG_DIRTY_REGIONS_PROPERTY, false);
@@ -1175,23 +1335,7 @@
                         mProfileLock.lock();
                     }
 
-                    // We had to change the current surface and/or context, redraw everything
-                    if (surfaceState == SURFACE_STATE_UPDATED) {
-                        dirty = null;
-                        beginFrame(null);
-                    } else {
-                        int[] size = mSurfaceSize;
-                        beginFrame(size);
-
-                        if (size[1] != mHeight || size[0] != mWidth) {
-                            mWidth = size[0];
-                            mHeight = size[1];
-
-                            canvas.setViewport(mWidth, mHeight);
-
-                            dirty = null;
-                        }
-                    }
+                    dirty = beginFrame(canvas, dirty, surfaceState);
 
                     int saveCount = 0;
                     int status = DisplayList.STATUS_DONE;
@@ -1201,63 +1345,19 @@
                                 == View.PFLAG_INVALIDATED;
                         view.mPrivateFlags &= ~View.PFLAG_INVALIDATED;
 
-                        long getDisplayListStartTime = 0;
-                        if (mProfileEnabled) {
-                            mProfileCurrentFrame += PROFILE_FRAME_DATA_COUNT;
-                            if (mProfileCurrentFrame >= mProfileData.length) {
-                                mProfileCurrentFrame = 0;
-                            }
-
-                            getDisplayListStartTime = System.nanoTime();
-                        }
-
+                        long buildDisplayListStartTime = startBuildDisplayListProfiling();
                         canvas.clearLayerUpdates();
 
-                        DisplayList displayList;
-                        Trace.traceBegin(Trace.TRACE_TAG_VIEW, "getDisplayList");
-                        try {
-                            displayList = view.getDisplayList();
-                        } finally {
-                            Trace.traceEnd(Trace.TRACE_TAG_VIEW);
-                        }
+                        DisplayList displayList = buildDisplayList(view);
+                        status = prepareFrame(dirty);
 
-                        Trace.traceBegin(Trace.TRACE_TAG_VIEW, "prepareFrame");
-                        try {
-                            status = onPreDraw(dirty);
-                        } finally {
-                            Trace.traceEnd(Trace.TRACE_TAG_VIEW);
-                        }
                         saveCount = canvas.save();
                         callbacks.onHardwarePreDraw(canvas);
 
-                        if (mProfileEnabled) {
-                            long now = System.nanoTime();
-                            float total = (now - getDisplayListStartTime) * 0.000001f;
-                            //noinspection PointlessArithmeticExpression
-                            mProfileData[mProfileCurrentFrame] = total;
-                        }
+                        endBuildDisplayListProfiling(buildDisplayListStartTime);
 
                         if (displayList != null) {
-                            long drawDisplayListStartTime = 0;
-                            if (mProfileEnabled) {
-                                drawDisplayListStartTime = System.nanoTime();
-                            }
-
-                            Trace.traceBegin(Trace.TRACE_TAG_VIEW, "drawDisplayList");
-                            try {
-                                status |= canvas.drawDisplayList(displayList, mRedrawClip,
-                                        DisplayList.FLAG_CLIP_CHILDREN);
-                            } finally {
-                                Trace.traceEnd(Trace.TRACE_TAG_VIEW);
-                            }
-
-                            if (mProfileEnabled) {
-                                long now = System.nanoTime();
-                                float total = (now - drawDisplayListStartTime) * 0.000001f;
-                                mProfileData[mProfileCurrentFrame + 1] = total;
-                            }
-
-                            handleFunctorStatus(attachInfo, status);
+                            status = drawDisplayList(attachInfo, canvas, displayList, status);
                         } else {
                             // Shouldn't reach here
                             view.draw(canvas);
@@ -1269,43 +1369,19 @@
 
                         mFrameCount++;
 
-                        if (mDebugDirtyRegions) {
-                            if (mDebugPaint == null) {
-                                mDebugPaint = new Paint();
-                                mDebugPaint.setColor(0x7fff0000);
-                            }
-
-                            if (dirty != null && (mFrameCount & 1) == 0) {
-                                canvas.drawRect(dirty, mDebugPaint);
-                            }
-                        }
+                        debugDirtyRegions(dirty, canvas);
+                        drawProfileData(attachInfo);
                     }
 
                     onPostDraw();
 
-                    attachInfo.mIgnoreDirtyState = false;
-                    
-                    if ((status & DisplayList.STATUS_DREW) == DisplayList.STATUS_DREW) {
-                        long eglSwapBuffersStartTime = 0;
-                        if (mProfileEnabled) {
-                            eglSwapBuffersStartTime = System.nanoTime();
-                        }
-    
-                        sEgl.eglSwapBuffers(sEglDisplay, mEglSurface);
-    
-                        if (mProfileEnabled) {
-                            long now = System.nanoTime();
-                            float total = (now - eglSwapBuffersStartTime) * 0.000001f;
-                            mProfileData[mProfileCurrentFrame + 2] = total;
-                        }
-    
-                        checkEglErrors();
-                    }
+                    swapBuffers(status);
 
                     if (mProfileEnabled) {
                         mProfileLock.unlock();
                     }
 
+                    attachInfo.mIgnoreDirtyState = false;
                     return dirty == null;
                 }
             }
@@ -1313,6 +1389,133 @@
             return false;
         }
 
+        abstract void drawProfileData(View.AttachInfo attachInfo);
+
+        private Rect beginFrame(HardwareCanvas canvas, Rect dirty, int surfaceState) {
+            // We had to change the current surface and/or context, redraw everything
+            if (surfaceState == SURFACE_STATE_UPDATED) {
+                dirty = null;
+                beginFrame(null);
+            } else {
+                int[] size = mSurfaceSize;
+                beginFrame(size);
+
+                if (size[1] != mHeight || size[0] != mWidth) {
+                    mWidth = size[0];
+                    mHeight = size[1];
+
+                    canvas.setViewport(mWidth, mHeight);
+
+                    dirty = null;
+                }
+            }
+
+            if (mDebugDataProvider != null) dirty = null;
+
+            return dirty;
+        }
+
+        private long startBuildDisplayListProfiling() {
+            if (mProfileEnabled) {
+                mProfileCurrentFrame += PROFILE_FRAME_DATA_COUNT;
+                if (mProfileCurrentFrame >= mProfileData.length) {
+                    mProfileCurrentFrame = 0;
+                }
+
+                return System.nanoTime();
+            }
+            return 0;
+        }
+
+        private void endBuildDisplayListProfiling(long getDisplayListStartTime) {
+            if (mProfileEnabled) {
+                long now = System.nanoTime();
+                float total = (now - getDisplayListStartTime) * 0.000001f;
+                //noinspection PointlessArithmeticExpression
+                mProfileData[mProfileCurrentFrame] = total;
+            }
+        }
+
+        private static DisplayList buildDisplayList(View view) {
+            DisplayList displayList;
+            Trace.traceBegin(Trace.TRACE_TAG_VIEW, "getDisplayList");
+            try {
+                displayList = view.getDisplayList();
+            } finally {
+                Trace.traceEnd(Trace.TRACE_TAG_VIEW);
+            }
+            return displayList;
+        }
+
+        private int prepareFrame(Rect dirty) {
+            int status;
+            Trace.traceBegin(Trace.TRACE_TAG_VIEW, "prepareFrame");
+            try {
+                status = onPreDraw(dirty);
+            } finally {
+                Trace.traceEnd(Trace.TRACE_TAG_VIEW);
+            }
+            return status;
+        }
+
+        private int drawDisplayList(View.AttachInfo attachInfo, HardwareCanvas canvas,
+                DisplayList displayList, int status) {
+
+            long drawDisplayListStartTime = 0;
+            if (mProfileEnabled) {
+                drawDisplayListStartTime = System.nanoTime();
+            }
+
+            Trace.traceBegin(Trace.TRACE_TAG_VIEW, "drawDisplayList");
+            try {
+                status |= canvas.drawDisplayList(displayList, mRedrawClip,
+                        DisplayList.FLAG_CLIP_CHILDREN);
+            } finally {
+                Trace.traceEnd(Trace.TRACE_TAG_VIEW);
+            }
+
+            if (mProfileEnabled) {
+                long now = System.nanoTime();
+                float total = (now - drawDisplayListStartTime) * 0.000001f;
+                mProfileData[mProfileCurrentFrame + 1] = total;
+            }
+
+            handleFunctorStatus(attachInfo, status);
+            return status;
+        }
+
+        private void swapBuffers(int status) {
+            if ((status & DisplayList.STATUS_DREW) == DisplayList.STATUS_DREW) {
+                long eglSwapBuffersStartTime = 0;
+                if (mProfileEnabled) {
+                    eglSwapBuffersStartTime = System.nanoTime();
+                }
+
+                sEgl.eglSwapBuffers(sEglDisplay, mEglSurface);
+
+                if (mProfileEnabled) {
+                    long now = System.nanoTime();
+                    float total = (now - eglSwapBuffersStartTime) * 0.000001f;
+                    mProfileData[mProfileCurrentFrame + 2] = total;
+                }
+
+                checkEglErrors();
+            }
+        }
+
+        private void debugDirtyRegions(Rect dirty, HardwareCanvas canvas) {
+            if (mDebugDirtyRegions) {
+                if (mDebugPaint == null) {
+                    mDebugPaint = new Paint();
+                    mDebugPaint.setColor(0x7fff0000);
+                }
+
+                if (dirty != null && (mFrameCount & 1) == 0) {
+                    canvas.drawRect(dirty, mDebugPaint);
+                }
+            }
+        }
+
         private void handleFunctorStatus(View.AttachInfo attachInfo, int status) {
             // If the draw flag is set, functors will be invoked while executing
             // the tree of display lists
@@ -1383,6 +1586,96 @@
             }
             return SURFACE_STATE_SUCCESS;
         }
+
+        private static int dpToPx(int dp, float density) {
+            return (int) (dp * density + 0.5f);
+        }
+
+        class DrawPerformanceDataProvider extends GraphDataProvider {
+            private final int mGraphType;
+
+            private int mVerticalUnit;
+            private int mHorizontalUnit;
+            private int mHorizontalMargin;
+            private int mThresholdStroke;
+
+            DrawPerformanceDataProvider(int graphType) {
+                mGraphType = graphType;
+            }
+
+            @Override
+            void prepare(DisplayMetrics metrics) {
+                final float density = metrics.density;
+
+                mVerticalUnit = dpToPx(PROFILE_DRAW_DP_PER_MS, density);
+                mHorizontalUnit = dpToPx(PROFILE_DRAW_WIDTH, density);
+                mHorizontalMargin = dpToPx(PROFILE_DRAW_MARGIN, density);
+                mThresholdStroke = dpToPx(PROFILE_DRAW_THRESHOLD_STROKE_WIDTH, density);
+            }
+
+            @Override
+            int getGraphType() {
+                return mGraphType;
+            }
+
+            @Override
+            int getVerticalUnitSize() {
+                return mVerticalUnit;
+            }
+
+            @Override
+            int getHorizontalUnitSize() {
+                return mHorizontalUnit;
+            }
+
+            @Override
+            int getHorizontaUnitMargin() {
+                return mHorizontalMargin;
+            }
+
+            @Override
+            float[] getData() {
+                return mProfileData;
+            }
+
+            @Override
+            float getThreshold() {
+                return 16;
+            }
+
+            @Override
+            int getFrameCount() {
+                return mProfileData.length / PROFILE_FRAME_DATA_COUNT;
+            }
+
+            @Override
+            int getElementCount() {
+                return PROFILE_FRAME_DATA_COUNT;
+            }
+
+            @Override
+            int getCurrentFrame() {
+                return mProfileCurrentFrame / PROFILE_FRAME_DATA_COUNT;
+            }
+
+            @Override
+            void setupGraphPaint(Paint paint, int elementIndex) {
+                paint.setColor(PROFILE_DRAW_COLORS[elementIndex]);
+                if (mGraphType == GRAPH_TYPE_LINES) paint.setStrokeWidth(mThresholdStroke);
+            }
+
+            @Override
+            void setupThresholdPaint(Paint paint) {
+                paint.setColor(PROFILE_DRAW_THRESHOLD_COLOR);
+                paint.setStrokeWidth(mThresholdStroke);
+            }
+
+            @Override
+            void setupCurrentFramePaint(Paint paint) {
+                paint.setColor(PROFILE_DRAW_CURRENT_FRAME_COLOR);
+                if (mGraphType == GRAPH_TYPE_LINES) paint.setStrokeWidth(mThresholdStroke);
+            }
+        }
     }
 
     /**
@@ -1391,6 +1684,8 @@
     static class Gl20Renderer extends GlRenderer {
         private GLES20Canvas mGlCanvas;
 
+        private DisplayMetrics mDisplayMetrics;
+
         private static EGLSurface sPbuffer;
         private static final Object[] sPbufferLock = new Object[0];
 
@@ -1494,6 +1789,153 @@
         }
 
         @Override
+        void drawProfileData(View.AttachInfo attachInfo) {
+            if (mDebugDataProvider != null) {
+                final GraphDataProvider provider = mDebugDataProvider;
+                initProfileDrawData(attachInfo, provider);
+
+                final int height = provider.getVerticalUnitSize();
+                final int margin = provider.getHorizontaUnitMargin();
+                final int width = provider.getHorizontalUnitSize();
+
+                int x = 0;
+                int count = 0;
+                int current = 0;
+
+                final float[] data = provider.getData();
+                final int elementCount = provider.getElementCount();
+                final int graphType = provider.getGraphType();
+
+                int totalCount = provider.getFrameCount() * elementCount;
+                if (graphType == GraphDataProvider.GRAPH_TYPE_LINES) {
+                    totalCount -= elementCount;
+                }
+
+                for (int i = 0; i < totalCount; i += elementCount) {
+                    if (data[i] < 0.0f) break;
+
+                    int index = count * 4;
+                    if (i == provider.getCurrentFrame() * elementCount) current = index;
+
+                    x += margin;
+                    int x2 = x + width;
+
+                    int y2 = mHeight;
+                    int y1 = (int) (y2 - data[i] * height);
+
+                    switch (graphType) {
+                        case GraphDataProvider.GRAPH_TYPE_BARS: {
+                            for (int j = 0; j < elementCount; j++) {
+                                //noinspection MismatchedReadAndWriteOfArray
+                                final float[] r = mProfileShapes[j];
+                                r[index] = x;
+                                r[index + 1] = y1;
+                                r[index + 2] = x2;
+                                r[index + 3] = y2;
+
+                                y2 = y1;
+                                if (j < elementCount - 1) {
+                                    y1 = (int) (y2 - data[i + j + 1] * height);
+                                }
+                            }
+                        } break;
+                        case GraphDataProvider.GRAPH_TYPE_LINES: {
+                            for (int j = 0; j < elementCount; j++) {
+                                //noinspection MismatchedReadAndWriteOfArray
+                                final float[] r = mProfileShapes[j];
+                                r[index] = (x + x2) * 0.5f;
+                                r[index + 1] = index == 0 ? y1 : r[index - 1];
+                                r[index + 2] = r[index] + width;
+                                r[index + 3] = y1;
+
+                                y2 = y1;
+                                if (j < elementCount - 1) {
+                                    y1 = (int) (y2 - data[i + j + 1] * height);
+                                }
+                            }
+                        } break;
+                    }
+
+
+                    x += width;
+                    count++;
+                }
+
+                x += margin;
+
+                drawGraph(graphType, count);
+                drawCurrentFrame(graphType, current);
+                drawThreshold(x, height);
+            }
+        }
+
+        private void drawGraph(int graphType, int count) {
+            for (int i = 0; i < mProfileShapes.length; i++) {
+                mDebugDataProvider.setupGraphPaint(mProfilePaint, i);
+                switch (graphType) {
+                    case GraphDataProvider.GRAPH_TYPE_BARS:
+                        mGlCanvas.drawRects(mProfileShapes[i], count, mProfilePaint);
+                        break;
+                    case GraphDataProvider.GRAPH_TYPE_LINES:
+                        mGlCanvas.drawLines(mProfileShapes[i], 0, count * 4, mProfilePaint);
+                        break;
+                }
+            }
+        }
+
+        private void drawCurrentFrame(int graphType, int index) {
+            if (index >= 0) {
+                mDebugDataProvider.setupCurrentFramePaint(mProfilePaint);
+                switch (graphType) {
+                    case GraphDataProvider.GRAPH_TYPE_BARS:
+                        mGlCanvas.drawRect(mProfileShapes[2][index], mProfileShapes[2][index + 1],
+                                mProfileShapes[2][index + 2], mProfileShapes[0][index + 3],
+                                mProfilePaint);
+                        break;
+                    case GraphDataProvider.GRAPH_TYPE_LINES:
+                        mGlCanvas.drawLine(mProfileShapes[2][index], mProfileShapes[2][index + 1],
+                                mProfileShapes[2][index], mHeight, mProfilePaint);
+                        break;
+                }
+            }
+        }
+
+        private void drawThreshold(int x, int height) {
+            float threshold = mDebugDataProvider.getThreshold();
+            if (threshold > 0.0f) {
+                mDebugDataProvider.setupThresholdPaint(mProfilePaint);
+                int y = (int) (mHeight - threshold * height);
+                mGlCanvas.drawLine(0.0f, y, x, y, mProfilePaint);
+            }
+        }
+
+        private void initProfileDrawData(View.AttachInfo attachInfo, GraphDataProvider provider) {
+            if (mProfileShapes == null) {
+                final int elementCount = provider.getElementCount();
+                final int frameCount = provider.getFrameCount();
+
+                mProfileShapes = new float[elementCount][];
+                for (int i = 0; i < elementCount; i++) {
+                    mProfileShapes[i] = new float[frameCount * 4];
+                }
+
+                mProfilePaint = new Paint();
+            }
+
+            mProfilePaint.reset();
+            if (provider.getGraphType() == GraphDataProvider.GRAPH_TYPE_LINES) {
+                mProfilePaint.setAntiAlias(true);
+            }
+
+            if (mDisplayMetrics == null) {
+                mDisplayMetrics = new DisplayMetrics();
+            }
+
+            attachInfo.mDisplay.getMetrics(mDisplayMetrics);
+            provider.prepare(mDisplayMetrics);
+        }
+
+        @Override
         void destroy(boolean full) {
             try {
                 super.destroy(full);
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 97287c3..a4e4f37 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -4376,10 +4376,16 @@
         if ((mPrivateFlags & PFLAG_FOCUSED) == 0) {
             mPrivateFlags |= PFLAG_FOCUSED;
 
+            View oldFocus = (mAttachInfo != null) ? getRootView().findFocus() : null;
+
             if (mParent != null) {
                 mParent.requestChildFocus(this, this);
             }
 
+            if (mAttachInfo != null) {
+                mAttachInfo.mTreeObserver.dispatchOnGlobalFocusChange(oldFocus, this);
+            }
+
             onFocusChanged(true, direction, previouslyFocusedRect);
             refreshDrawableState();
 
@@ -4486,7 +4492,9 @@
 
             refreshDrawableState();
 
-            ensureInputFocusOnFirstFocusable();
+            if (!rootViewRequestFocus()) {
+                notifyGlobalFocusCleared(this);
+            }
 
             if (AccessibilityManager.getInstance(mContext).isEnabled()) {
                 notifyAccessibilityStateChanged();
@@ -4494,11 +4502,18 @@
         }
     }
 
-    void ensureInputFocusOnFirstFocusable() {
+    void notifyGlobalFocusCleared(View oldFocus) {
+        if (oldFocus != null && mAttachInfo != null) {
+            mAttachInfo.mTreeObserver.dispatchOnGlobalFocusChange(oldFocus, null);
+        }
+    }
+
+    boolean rootViewRequestFocus() {
         View root = getRootView();
         if (root != null) {
-            root.requestFocus();
+            return root.requestFocus();
         }
+        return false;
     }
 
     /**
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java
index c274f27..a4898fc 100644
--- a/core/java/android/view/ViewGroup.java
+++ b/core/java/android/view/ViewGroup.java
@@ -3697,7 +3697,9 @@
             clearChildFocus = true;
         }
 
-        view.clearAccessibilityFocus();
+        if (view.isAccessibilityFocused()) {
+            view.clearAccessibilityFocus();
+        }
 
         cancelTouchTarget(view);
         cancelHoverTarget(view);
@@ -3719,11 +3721,9 @@
 
         if (clearChildFocus) {
             clearChildFocus(view);
-            ensureInputFocusOnFirstFocusable();
-        }
-
-        if (view.isAccessibilityFocused()) {
-            view.clearAccessibilityFocus();
+            if (!rootViewRequestFocus()) {
+                notifyGlobalFocusCleared(this);
+            }
         }
 
         onViewRemoved(view);
@@ -3765,7 +3765,7 @@
     private void removeViewsInternal(int start, int count) {
         final View focused = mFocused;
         final boolean detach = mAttachInfo != null;
-        View clearChildFocus = null;
+        boolean clearChildFocus = false;
 
         final View[] children = mChildren;
         final int end = start + count;
@@ -3779,10 +3779,12 @@
 
             if (view == focused) {
                 view.unFocus();
-                clearChildFocus = view;
+                clearChildFocus = true;
             }
 
-            view.clearAccessibilityFocus();
+            if (view.isAccessibilityFocused()) {
+                view.clearAccessibilityFocus();
+            }
 
             cancelTouchTarget(view);
             cancelHoverTarget(view);
@@ -3805,9 +3807,11 @@
 
         removeFromArray(start, count);
 
-        if (clearChildFocus != null) {
-            clearChildFocus(clearChildFocus);
-            ensureInputFocusOnFirstFocusable();
+        if (clearChildFocus) {
+            clearChildFocus(focused);
+            if (!rootViewRequestFocus()) {
+                notifyGlobalFocusCleared(focused);
+            }
         }
     }
 
@@ -3849,7 +3853,7 @@
 
         final View focused = mFocused;
         final boolean detach = mAttachInfo != null;
-        View clearChildFocus = null;
+        boolean clearChildFocus = false;
 
         needGlobalAttributesUpdate(false);
 
@@ -3862,10 +3866,12 @@
 
             if (view == focused) {
                 view.unFocus();
-                clearChildFocus = view;
+                clearChildFocus = true;
             }
 
-            view.clearAccessibilityFocus();
+            if (view.isAccessibilityFocused()) {
+                view.clearAccessibilityFocus();
+            }
 
             cancelTouchTarget(view);
             cancelHoverTarget(view);
@@ -3887,9 +3893,11 @@
             children[i] = null;
         }
 
-        if (clearChildFocus != null) {
-            clearChildFocus(clearChildFocus);
-            ensureInputFocusOnFirstFocusable();
+        if (clearChildFocus) {
+            clearChildFocus(focused);
+            if (!rootViewRequestFocus()) {
+                notifyGlobalFocusCleared(focused);
+            }
         }
     }
 
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index f9f955e..6a96893 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -169,9 +169,6 @@
     int mSeq;
 
     View mView;
-    View mFocusedView;
-    View mRealFocusedView;  // this is not set to null in touch mode
-    View mOldFocusedView;
 
     View mAccessibilityFocusedHost;
     AccessibilityNodeInfo mAccessibilityFocusedVirtualView;
@@ -269,7 +266,7 @@
 
     boolean mScrollMayChange;
     int mSoftInputMode;
-    View mLastScrolledFocus;
+    WeakReference<View> mLastScrolledFocus;
     int mScrollY;
     int mCurScrollY;
     Scroller mScroller;
@@ -1526,7 +1523,9 @@
                 } else if (!mSurface.isValid()) {
                     // If the surface has been removed, then reset the scroll
                     // positions.
-                    mLastScrolledFocus = null;
+                    if (mLastScrolledFocus != null) {
+                        mLastScrolledFocus.clear();
+                    }
                     mScrollY = mCurScrollY = 0;
                     if (mScroller != null) {
                         mScroller.abortAnimation();
@@ -1802,13 +1801,11 @@
             if (mView != null) {
                 if (!mView.hasFocus()) {
                     mView.requestFocus(View.FOCUS_FORWARD);
-                    mFocusedView = mRealFocusedView = mView.findFocus();
                     if (DEBUG_INPUT_RESIZE) Log.v(TAG, "First: requested focused view="
-                            + mFocusedView);
+                            + mView.findFocus());
                 } else {
-                    mRealFocusedView = mView.findFocus();
                     if (DEBUG_INPUT_RESIZE) Log.v(TAG, "First: existing focused view="
-                            + mRealFocusedView);
+                            + mView.findFocus());
                 }
             }
             if ((relayoutResult & WindowManagerGlobal.RELAYOUT_RES_ANIMATING) != 0) {
@@ -2514,17 +2511,12 @@
             // requestChildRectangleOnScreen() call (in which case 'rectangle'
             // is non-null and we just want to scroll to whatever that
             // rectangle is).
-            View focus = mRealFocusedView;
-
-            // When in touch mode, focus points to the previously focused view,
-            // which may have been removed from the view hierarchy. The following
-            // line checks whether the view is still in our hierarchy.
-            if (focus == null || focus.mAttachInfo != mAttachInfo) {
-                mRealFocusedView = null;
+            View focus = mView.findFocus();
+            if (focus == null) {
                 return false;
             }
-
-            if (focus != mLastScrolledFocus) {
+            View lastScrolledFocus = (mLastScrolledFocus != null) ? mLastScrolledFocus.get() : null;
+            if (lastScrolledFocus != null && focus != lastScrolledFocus) {
                 // If the focus has changed, then ignore any requests to scroll
                 // to a rectangle; first we want to make sure the entire focus
                 // view is visible.
@@ -2533,8 +2525,7 @@
             if (DEBUG_INPUT_RESIZE) Log.v(TAG, "Eval scroll: focus=" + focus
                     + " rectangle=" + rectangle + " ci=" + ci
                     + " vi=" + vi);
-            if (focus == mLastScrolledFocus && !mScrollMayChange
-                    && rectangle == null) {
+            if (focus == lastScrolledFocus && !mScrollMayChange && rectangle == null) {
                 // Optimization: if the focus hasn't changed since last
                 // time, and no layout has happened, then just leave things
                 // as they are.
@@ -2544,7 +2535,7 @@
                 // We need to determine if the currently focused view is
                 // within the visible part of the window and, if not, apply
                 // a pan so it can be seen.
-                mLastScrolledFocus = focus;
+                mLastScrolledFocus = new WeakReference<View>(focus);
                 mScrollMayChange = false;
                 if (DEBUG_INPUT_RESIZE) Log.v(TAG, "Need to scroll?");
                 // Try to find the rectangle from the focus view.
@@ -2671,33 +2662,19 @@
     }
 
     public void requestChildFocus(View child, View focused) {
-        checkThread();
-
         if (DEBUG_INPUT_RESIZE) {
             Log.v(TAG, "Request child focus: focus now " + focused);
         }
-
-        mAttachInfo.mTreeObserver.dispatchOnGlobalFocusChange(mOldFocusedView, focused);
+        checkThread();
         scheduleTraversals();
-
-        mFocusedView = mRealFocusedView = focused;
     }
 
     public void clearChildFocus(View child) {
-        checkThread();
-
         if (DEBUG_INPUT_RESIZE) {
             Log.v(TAG, "Clearing child focus");
         }
-
-        mOldFocusedView = mFocusedView;
-
-        // Invoke the listener only if there is no view to take focus
-        if (focusSearch(null, View.FOCUS_FORWARD) == null) {
-            mAttachInfo.mTreeObserver.dispatchOnGlobalFocusChange(mOldFocusedView, null);
-        }
-
-        mFocusedView = mRealFocusedView = null;
+        checkThread();
+        scheduleTraversals();
     }
 
     @Override
@@ -2714,14 +2691,13 @@
                 // the one case where will transfer focus away from the current one
                 // is if the current view is a view group that prefers to give focus
                 // to its children first AND the view is a descendant of it.
-                mFocusedView = mView.findFocus();
-                boolean descendantsHaveDibsOnFocus =
-                        (mFocusedView instanceof ViewGroup) &&
-                            (((ViewGroup) mFocusedView).getDescendantFocusability() ==
-                                    ViewGroup.FOCUS_AFTER_DESCENDANTS);
-                if (descendantsHaveDibsOnFocus && isViewDescendantOf(v, mFocusedView)) {
-                    // If a view gets the focus, the listener will be invoked from requestChildFocus()
-                    v.requestFocus();
+                View focused = mView.findFocus();
+                if (focused instanceof ViewGroup) {
+                    ViewGroup group = (ViewGroup) focused;
+                    if (group.getDescendantFocusability() == ViewGroup.FOCUS_AFTER_DESCENDANTS
+                            && isViewDescendantOf(v, focused)) {
+                        v.requestFocus();
+                    }
                 }
             }
         }
@@ -3199,7 +3175,6 @@
                 // set yet.
                 final View focused = mView.findFocus();
                 if (focused != null && !focused.isFocusableInTouchMode()) {
-
                     final ViewGroup ancestorToTakeFocus =
                             findAncestorToTakeFocusInTouchMode(focused);
                     if (ancestorToTakeFocus != null) {
@@ -3208,10 +3183,7 @@
                         return ancestorToTakeFocus.requestFocus();
                     } else {
                         // nothing appropriate to have focus in touch mode, clear it out
-                        mView.unFocus();
-                        mAttachInfo.mTreeObserver.dispatchOnGlobalFocusChange(focused, null);
-                        mFocusedView = null;
-                        mOldFocusedView = null;
+                        focused.unFocus();
                         return true;
                     }
                 }
@@ -3246,12 +3218,11 @@
     private boolean leaveTouchMode() {
         if (mView != null) {
             if (mView.hasFocus()) {
-                // i learned the hard way to not trust mFocusedView :)
-                mFocusedView = mView.findFocus();
-                if (!(mFocusedView instanceof ViewGroup)) {
+                View focusedView = mView.findFocus();
+                if (!(focusedView instanceof ViewGroup)) {
                     // some view has focus, let it keep it
                     return false;
-                } else if (((ViewGroup)mFocusedView).getDescendantFocusability() !=
+                } else if (((ViewGroup) focusedView).getDescendantFocusability() !=
                         ViewGroup.FOCUS_AFTER_DESCENDANTS) {
                     // some view group has focus, and doesn't prefer its children
                     // over itself for focus, so let them keep it.
diff --git a/core/java/android/view/VolumePanel.java b/core/java/android/view/VolumePanel.java
index 6251c45..e711b94 100644
--- a/core/java/android/view/VolumePanel.java
+++ b/core/java/android/view/VolumePanel.java
@@ -309,6 +309,7 @@
         lp.type = LayoutParams.TYPE_VOLUME_OVERLAY;
         lp.width = LayoutParams.WRAP_CONTENT;
         lp.height = LayoutParams.WRAP_CONTENT;
+        lp.privateFlags |= LayoutParams.PRIVATE_FLAG_FORCE_SHOW_NAV_BAR;
         window.setAttributes(lp);
         window.addFlags(LayoutParams.FLAG_NOT_FOCUSABLE | LayoutParams.FLAG_NOT_TOUCH_MODAL
                 | LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH);
@@ -336,6 +337,11 @@
         listenToRingerMode();
     }
 
+    public void setLayoutDirection(int layoutDirection) {
+        mPanel.setLayoutDirection(layoutDirection);
+        updateStates();
+    }
+
     private void listenToRingerMode() {
         final IntentFilter filter = new IntentFilter();
         filter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION);
@@ -459,6 +465,8 @@
     private void updateSlider(StreamControl sc) {
         sc.seekbarView.setProgress(getStreamVolume(sc.streamType));
         final boolean muted = isMuted(sc.streamType);
+        // Force reloading the image resource
+        sc.icon.setImageDrawable(null);
         sc.icon.setImageResource(muted ? sc.iconMuteRes : sc.iconRes);
         if (sc.streamType == AudioManager.STREAM_RING &&
                 mAudioManager.getRingerMode() == AudioManager.RINGER_MODE_VIBRATE) {
diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java
index 3b31ff6..6a67d8b 100644
--- a/core/java/android/view/WindowManager.java
+++ b/core/java/android/view/WindowManager.java
@@ -946,6 +946,13 @@
         public static final int PRIVATE_FLAG_SHOW_FOR_ALL_USERS = 0x00000010;
 
         /**
+         * Special flag for the volume overlay: force the window manager out of "hide nav bar"
+         * mode while the window is on screen.
+         *
+         * {@hide} */
+        public static final int PRIVATE_FLAG_FORCE_SHOW_NAV_BAR = 0x00000020;
+
+        /**
          * Control flags that are private to the platform.
          * @hide
          */
diff --git a/core/java/android/view/WindowManagerPolicy.java b/core/java/android/view/WindowManagerPolicy.java
index 47ef638..9377cfa 100644
--- a/core/java/android/view/WindowManagerPolicy.java
+++ b/core/java/android/view/WindowManagerPolicy.java
@@ -401,61 +401,19 @@
         public void rebootSafeMode(boolean confirm);
     }
 
-    /**
-     * Bit mask that is set for all enter transition.
-     */
-    public final int TRANSIT_ENTER_MASK = 0x1000;
-    
-    /**
-     * Bit mask that is set for all exit transitions.
-     */
-    public final int TRANSIT_EXIT_MASK = 0x2000;
-    
-    /** Not set up for a transition. */
-    public final int TRANSIT_UNSET = -1;
-    /** No animation for transition. */
-    public final int TRANSIT_NONE = 0;
     /** Window has been added to the screen. */
-    public final int TRANSIT_ENTER = 1 | TRANSIT_ENTER_MASK;
+    public static final int TRANSIT_ENTER = 1;
     /** Window has been removed from the screen. */
-    public final int TRANSIT_EXIT = 2 | TRANSIT_EXIT_MASK;
+    public static final int TRANSIT_EXIT = 2;
     /** Window has been made visible. */
-    public final int TRANSIT_SHOW = 3 | TRANSIT_ENTER_MASK;
-    /** Window has been made invisible. */
-    public final int TRANSIT_HIDE = 4 | TRANSIT_EXIT_MASK;
+    public static final int TRANSIT_SHOW = 3;
+    /** Window has been made invisible.
+     * TODO: Consider removal as this is unused. */
+    public static final int TRANSIT_HIDE = 4;
     /** The "application starting" preview window is no longer needed, and will
      * animate away to show the real window. */
-    public final int TRANSIT_PREVIEW_DONE = 5;
-    /** A window in a new activity is being opened on top of an existing one
-     * in the same task. */
-    public final int TRANSIT_ACTIVITY_OPEN = 6 | TRANSIT_ENTER_MASK;
-    /** The window in the top-most activity is being closed to reveal the
-     * previous activity in the same task. */
-    public final int TRANSIT_ACTIVITY_CLOSE = 7 | TRANSIT_EXIT_MASK;
-    /** A window in a new task is being opened on top of an existing one
-     * in another activity's task. */
-    public final int TRANSIT_TASK_OPEN = 8 | TRANSIT_ENTER_MASK;
-    /** A window in the top-most activity is being closed to reveal the
-     * previous activity in a different task. */
-    public final int TRANSIT_TASK_CLOSE = 9 | TRANSIT_EXIT_MASK;
-    /** A window in an existing task is being displayed on top of an existing one
-     * in another activity's task. */
-    public final int TRANSIT_TASK_TO_FRONT = 10 | TRANSIT_ENTER_MASK;
-    /** A window in an existing task is being put below all other tasks. */
-    public final int TRANSIT_TASK_TO_BACK = 11 | TRANSIT_EXIT_MASK;
-    /** A window in a new activity that doesn't have a wallpaper is being
-     * opened on top of one that does, effectively closing the wallpaper. */
-    public final int TRANSIT_WALLPAPER_CLOSE = 12 | TRANSIT_EXIT_MASK;
-    /** A window in a new activity that does have a wallpaper is being
-     * opened on one that didn't, effectively opening the wallpaper. */
-    public final int TRANSIT_WALLPAPER_OPEN = 13 | TRANSIT_ENTER_MASK;
-    /** A window in a new activity is being opened on top of an existing one,
-     * and both are on top of the wallpaper. */
-    public final int TRANSIT_WALLPAPER_INTRA_OPEN = 14 | TRANSIT_ENTER_MASK;
-    /** The window in the top-most activity is being closed to reveal the
-     * previous activity, and both are on top of he wallpaper. */
-    public final int TRANSIT_WALLPAPER_INTRA_CLOSE = 15 | TRANSIT_EXIT_MASK;
-    
+    public static final int TRANSIT_PREVIEW_DONE = 5;
+
     // NOTE: screen off reasons are in order of significance, with more
     // important ones lower than less important ones.
     
diff --git a/core/java/android/webkit/WebSettings.java b/core/java/android/webkit/WebSettings.java
index 114ec42..728bcd3 100644
--- a/core/java/android/webkit/WebSettings.java
+++ b/core/java/android/webkit/WebSettings.java
@@ -594,18 +594,25 @@
     }
 
     /**
-     * Tells the WebView to use a wide viewport. The default is false.
+     * Sets whether the WebView should enable support for the &quot;viewport&quot;
+     * HTML meta tag or should use a wide viewport.
+     * When the value of the setting is false, the layout width is always set to the
+     * width of the WebView control in device-independent (CSS) pixels.
+     * When the value is true and the page contains the viewport meta tag, the value
+     * of the width specified in the tag is used. If the page does not contain the tag or
+     * does not provide a width, then a wide viewport will be used.
      *
-     * @param use whether to use a wide viewport
+     * @param use whether to enable support for the viewport meta tag
      */
     public synchronized void setUseWideViewPort(boolean use) {
         throw new MustOverrideException();
     }
 
     /**
-     * Gets whether the WebView is using a wide viewport.
+     * Gets whether the WebView supports the &quot;viewport&quot;
+     * HTML meta tag or will use a wide viewport.
      *
-     * @return true if the WebView is using a wide viewport
+     * @return true if the WebView supports the viewport meta tag
      * @see #setUseWideViewPort
      */
     public synchronized boolean getUseWideViewPort() {
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index 441b7b0..1abea2b 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -1865,9 +1865,6 @@
     }
 
     private static synchronized WebViewFactoryProvider getFactory() {
-        // For now the main purpose of this function (and the factory abstration) is to keep
-        // us honest and minimize usage of WebViewClassic internals when binding the proxy.
-        checkThread();
         return WebViewFactory.getProvider();
     }
 
diff --git a/core/java/android/webkit/package.html b/core/java/android/webkit/package.html
index 4ed08da..7182488 100644
--- a/core/java/android/webkit/package.html
+++ b/core/java/android/webkit/package.html
@@ -1,7 +1,7 @@
 <html>
 <body>
-Provides tools for browsing the web.
-<p>The only classes or interfaces in this package intended for use by SDK
-developers are WebView, BroswerCallbackAdapter, BrowserCallback, and CookieManager.
+<p>Provides tools for browsing the web.
+<p>For more information about building apps with web-based content, see the
+<a href="{@docRoot}guide/webapps/overview.html">Web Apps Overview</a>.
 </body>
 </html>
\ No newline at end of file
diff --git a/core/java/android/widget/ArrayAdapter.java b/core/java/android/widget/ArrayAdapter.java
index 44f04db..97926a7 100644
--- a/core/java/android/widget/ArrayAdapter.java
+++ b/core/java/android/widget/ArrayAdapter.java
@@ -97,11 +97,11 @@
      * Constructor
      *
      * @param context The current context.
-     * @param textViewResourceId The resource ID for a layout file containing a TextView to use when
+     * @param resource The resource ID for a layout file containing a TextView to use when
      *                 instantiating views.
      */
-    public ArrayAdapter(Context context, int textViewResourceId) {
-        init(context, textViewResourceId, 0, new ArrayList<T>());
+    public ArrayAdapter(Context context, int resource) {
+        init(context, resource, 0, new ArrayList<T>());
     }
 
     /**
@@ -120,12 +120,12 @@
      * Constructor
      *
      * @param context The current context.
-     * @param textViewResourceId The resource ID for a layout file containing a TextView to use when
+     * @param resource The resource ID for a layout file containing a TextView to use when
      *                 instantiating views.
      * @param objects The objects to represent in the ListView.
      */
-    public ArrayAdapter(Context context, int textViewResourceId, T[] objects) {
-        init(context, textViewResourceId, 0, Arrays.asList(objects));
+    public ArrayAdapter(Context context, int resource, T[] objects) {
+        init(context, resource, 0, Arrays.asList(objects));
     }
 
     /**
@@ -145,12 +145,12 @@
      * Constructor
      *
      * @param context The current context.
-     * @param textViewResourceId The resource ID for a layout file containing a TextView to use when
+     * @param resource The resource ID for a layout file containing a TextView to use when
      *                 instantiating views.
      * @param objects The objects to represent in the ListView.
      */
-    public ArrayAdapter(Context context, int textViewResourceId, List<T> objects) {
-        init(context, textViewResourceId, 0, objects);
+    public ArrayAdapter(Context context, int resource, List<T> objects) {
+        init(context, resource, 0, objects);
     }
 
     /**
diff --git a/core/java/android/widget/Editor.java b/core/java/android/widget/Editor.java
index 41d6033..4eaa78a 100644
--- a/core/java/android/widget/Editor.java
+++ b/core/java/android/widget/Editor.java
@@ -124,7 +124,6 @@
     InputMethodState mInputMethodState;
 
     DisplayList[] mTextDisplayLists;
-    int mLastLayoutHeight;
 
     boolean mFrozenWithFocus;
     boolean mSelectionMoved;
@@ -1289,20 +1288,11 @@
                 mTextDisplayLists = new DisplayList[ArrayUtils.idealObjectArraySize(0)];
             }
 
-            // If the height of the layout changes (usually when inserting or deleting a line,
-            // but could be changes within a span), invalidate everything. We could optimize
-            // more aggressively (for example, adding offsets to blocks) but it would be more
-            // complex and we would only get the benefit in some cases.
-            int layoutHeight = layout.getHeight();
-            if (mLastLayoutHeight != layoutHeight) {
-                invalidateTextDisplayList();
-                mLastLayoutHeight = layoutHeight;
-            }
-
             DynamicLayout dynamicLayout = (DynamicLayout) layout;
             int[] blockEndLines = dynamicLayout.getBlockEndLines();
             int[] blockIndices = dynamicLayout.getBlockIndices();
             final int numberOfBlocks = dynamicLayout.getNumberOfBlocks();
+            final int indexFirstChangedBlock = dynamicLayout.getIndexFirstChangedBlock();
 
             int endOfPreviousBlock = -1;
             int searchStartIndex = 0;
@@ -1327,7 +1317,8 @@
                     if (blockIsInvalid) blockDisplayList.invalidate();
                 }
 
-                if (!blockDisplayList.isValid()) {
+                final boolean blockDisplayListIsInvalid = !blockDisplayList.isValid();
+                if (i >= indexFirstChangedBlock || blockDisplayListIsInvalid) {
                     final int blockBeginLine = endOfPreviousBlock + 1;
                     final int top = layout.getLineTop(blockBeginLine);
                     final int bottom = layout.getLineBottom(blockEndLine);
@@ -1344,24 +1335,30 @@
                         right = (int) (max + 0.5f);
                     }
 
-                    final HardwareCanvas hardwareCanvas = blockDisplayList.start();
-                    try {
-                        // Tighten the bounds of the viewport to the actual text size
-                        hardwareCanvas.setViewport(right - left, bottom - top);
-                        // The dirty rect should always be null for a display list
-                        hardwareCanvas.onPreDraw(null);
-                        // drawText is always relative to TextView's origin, this translation brings
-                        // this range of text back to the top left corner of the viewport
-                        hardwareCanvas.translate(-left, -top);
-                        layout.drawText(hardwareCanvas, blockBeginLine, blockEndLine);
-                        // No need to untranslate, previous context is popped after drawDisplayList
-                    } finally {
-                        hardwareCanvas.onPostDraw();
-                        blockDisplayList.end();
-                        blockDisplayList.setLeftTopRightBottom(left, top, right, bottom);
-                        // Same as drawDisplayList below, handled by our TextView's parent
-                        blockDisplayList.setClipChildren(false);
+                    // Rebuild display list if it is invalid
+                    if (blockDisplayListIsInvalid) {
+                        final HardwareCanvas hardwareCanvas = blockDisplayList.start();
+                        try {
+                            // Tighten the bounds of the viewport to the actual text size
+                            hardwareCanvas.setViewport(right - left, bottom - top);
+                            // The dirty rect should always be null for a display list
+                            hardwareCanvas.onPreDraw(null);
+                            // drawText is always relative to TextView's origin, this translation brings
+                            // this range of text back to the top left corner of the viewport
+                            hardwareCanvas.translate(-left, -top);
+                            layout.drawText(hardwareCanvas, blockBeginLine, blockEndLine);
+                            // No need to untranslate, previous context is popped after drawDisplayList
+                        } finally {
+                            hardwareCanvas.onPostDraw();
+                            blockDisplayList.end();
+                            // Same as drawDisplayList below, handled by our TextView's parent
+                            blockDisplayList.setClipChildren(false);
+                        }
                     }
+
+                    // Valid disply list whose index is >= indexFirstChangedBlock
+                    // only needs to update its drawing location.
+                    blockDisplayList.setLeftTopRightBottom(left, top, right, bottom);
                 }
 
                 ((HardwareCanvas) canvas).drawDisplayList(blockDisplayList, null,
@@ -1369,6 +1366,8 @@
 
                 endOfPreviousBlock = blockEndLine;
             }
+
+            dynamicLayout.setIndexFirstChangedBlock(numberOfBlocks);
         } else {
             // Boring layout is used for empty and hint text
             layout.drawText(canvas, firstLine, lastLine);
diff --git a/core/java/android/widget/ImageView.java b/core/java/android/widget/ImageView.java
index b40260c..8c710ce 100644
--- a/core/java/android/widget/ImageView.java
+++ b/core/java/android/widget/ImageView.java
@@ -567,7 +567,10 @@
         applied to the drawable, be sure to call setImageMatrix().
     */
     public Matrix getImageMatrix() {
-        return mMatrix;
+        if (mDrawMatrix == null) {
+            return Matrix.IDENTITY_MATRIX;
+        }
+        return mDrawMatrix;
     }
 
     public void setImageMatrix(Matrix matrix) {
diff --git a/core/java/android/widget/RemoteViews.java b/core/java/android/widget/RemoteViews.java
index 57e3c8b..79fc51e 100644
--- a/core/java/android/widget/RemoteViews.java
+++ b/core/java/android/widget/RemoteViews.java
@@ -487,13 +487,15 @@
     }
 
     private class SetRemoteViewsAdapterList extends Action {
-        public SetRemoteViewsAdapterList(int id, ArrayList<RemoteViews> list) {
+        public SetRemoteViewsAdapterList(int id, ArrayList<RemoteViews> list, int viewTypeCount) {
             this.viewId = id;
             this.list = list;
+            this.viewTypeCount = viewTypeCount;
         }
 
         public SetRemoteViewsAdapterList(Parcel parcel) {
             viewId = parcel.readInt();
+            viewTypeCount = parcel.readInt();
             int count = parcel.readInt();
             list = new ArrayList<RemoteViews>();
 
@@ -506,6 +508,7 @@
         public void writeToParcel(Parcel dest, int flags) {
             dest.writeInt(TAG);
             dest.writeInt(viewId);
+            dest.writeInt(viewTypeCount);
 
             if (list == null || list.size() == 0) {
                 dest.writeInt(0);
@@ -540,18 +543,18 @@
             if (target instanceof AbsListView) {
                 AbsListView v = (AbsListView) target;
                 Adapter a = v.getAdapter();
-                if (a instanceof RemoteViewsListAdapter) {
+                if (a instanceof RemoteViewsListAdapter && viewTypeCount <= a.getViewTypeCount()) {
                     ((RemoteViewsListAdapter) a).setViewsList(list);
                 } else {
-                    v.setAdapter(new RemoteViewsListAdapter(v.getContext(), list));
+                    v.setAdapter(new RemoteViewsListAdapter(v.getContext(), list, viewTypeCount));
                 }
             } else if (target instanceof AdapterViewAnimator) {
                 AdapterViewAnimator v = (AdapterViewAnimator) target;
                 Adapter a = v.getAdapter();
-                if (a instanceof RemoteViewsListAdapter) {
+                if (a instanceof RemoteViewsListAdapter && viewTypeCount <= a.getViewTypeCount()) {
                     ((RemoteViewsListAdapter) a).setViewsList(list);
                 } else {
-                    v.setAdapter(new RemoteViewsListAdapter(v.getContext(), list));
+                    v.setAdapter(new RemoteViewsListAdapter(v.getContext(), list, viewTypeCount));
                 }
             }
         }
@@ -560,6 +563,7 @@
             return "SetRemoteViewsAdapterList";
         }
 
+        int viewTypeCount;
         ArrayList<RemoteViews> list;
         public final static int TAG = 15;
     }
@@ -2099,9 +2103,13 @@
      *
      * @param viewId The id of the {@link AdapterView}
      * @param list The list of RemoteViews which will populate the view specified by viewId.
+     * @param viewTypeCount The maximum number of unique layout id's used to construct the list of
+     *      RemoteViews. This count cannot change during the life-cycle of a given widget, so this
+     *      parameter should account for the maximum possible number of types that may appear in the
+     *      See {@link Adapter#getViewTypeCount()}.
      */
-    public void setRemoteAdapter(int viewId, ArrayList<RemoteViews> list) {
-        addAction(new SetRemoteViewsAdapterList(viewId, list));
+    public void setRemoteAdapter(int viewId, ArrayList<RemoteViews> list, int viewTypeCount) {
+        addAction(new SetRemoteViewsAdapterList(viewId, list, viewTypeCount));
     }
 
     /**
diff --git a/core/java/android/widget/RemoteViewsListAdapter.java b/core/java/android/widget/RemoteViewsListAdapter.java
index 9598771..e490458 100644
--- a/core/java/android/widget/RemoteViewsListAdapter.java
+++ b/core/java/android/widget/RemoteViewsListAdapter.java
@@ -30,10 +30,13 @@
     private Context mContext;
     private ArrayList<RemoteViews> mRemoteViewsList;
     private ArrayList<Integer> mViewTypes = new ArrayList<Integer>();
+    private int mViewTypeCount;
 
-    public RemoteViewsListAdapter(Context context, ArrayList<RemoteViews> remoteViews) {
+    public RemoteViewsListAdapter(Context context, ArrayList<RemoteViews> remoteViews,
+            int viewTypeCount) {
         mContext = context;
         mRemoteViewsList = remoteViews;
+        mViewTypeCount = viewTypeCount;
         init();
     }
 
@@ -52,6 +55,11 @@
                 mViewTypes.add(rv.getLayoutId());
             }
         }
+
+        if (mViewTypes.size() > mViewTypeCount || mViewTypeCount < 1) {
+            throw new RuntimeException("Invalid view type count -- view type count must be >= 1" +
+                    "and must be as large as the total number of distinct view types");
+        }
     }
 
     @Override
@@ -77,6 +85,7 @@
     public View getView(int position, View convertView, ViewGroup parent) {
         if (position < getCount()) {
             RemoteViews rv = mRemoteViewsList.get(position);
+            rv.setIsWidgetCollectionChild(true);
             View v;
             if (convertView != null && rv != null &&
                     convertView.getId() == rv.getLayoutId()) {
@@ -102,7 +111,7 @@
     }
 
     public int getViewTypeCount() {
-        return mViewTypes.size();
+        return mViewTypeCount;
     }
 
     @Override
diff --git a/core/java/android/widget/TextClock.java b/core/java/android/widget/TextClock.java
index 290d9b5..5bf21c0 100644
--- a/core/java/android/widget/TextClock.java
+++ b/core/java/android/widget/TextClock.java
@@ -386,6 +386,16 @@
     }
 
     /**
+     * Returns the current format string. Always valid after constructor has
+     * finished, and will never be {@code null}.
+     *
+     * @hide
+     */
+    public CharSequence getFormat() {
+        return mFormat;
+    }
+
+    /**
      * Selects either one of {@link #getFormat12Hour()} or {@link #getFormat24Hour()}
      * depending on whether the user has selected 24-hour format.
      * 
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index d635de6..f8db622 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -6459,7 +6459,6 @@
             mDeferScroll = -1;
             bringPointIntoView(Math.min(curs, mText.length()));
         }
-        if (changed && mEditor != null) mEditor.invalidateTextDisplayList();
     }
 
     private boolean isShowingHint() {
diff --git a/core/java/com/android/internal/app/IAppOpsService.aidl b/core/java/com/android/internal/app/IAppOpsService.aidl
new file mode 100644
index 0000000..c934587
--- /dev/null
+++ b/core/java/com/android/internal/app/IAppOpsService.aidl
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.internal.app;
+
+interface IAppOpsService {
+    int noteOperation(int code, int uid, String packageName);
+    int startOperation(int code, int uid, String packageName);
+    void finishOperation(int code, int uid, String packageName);
+    int noteTimedOperation(int code, int uid, String packageName, int duration);
+    void earlyFinishOperation(int code, int uid, String packageName);
+}
diff --git a/core/java/com/android/internal/app/IBatteryStats.aidl b/core/java/com/android/internal/app/IBatteryStats.aidl
index 1a76461..823e19f 100644
--- a/core/java/com/android/internal/app/IBatteryStats.aidl
+++ b/core/java/com/android/internal/app/IBatteryStats.aidl
@@ -37,6 +37,8 @@
     void noteStartWakelockFromSource(in WorkSource ws, int pid, String name, int type);
     void noteStopWakelockFromSource(in WorkSource ws, int pid, String name, int type);
 
+    void noteVibratorOn(int uid, long durationMillis);
+    void noteVibratorOff(int uid);
     void noteStartGps(int uid);
     void noteStopGps(int uid);
     void noteScreenOn();
diff --git a/core/java/com/android/internal/os/BatteryStatsImpl.java b/core/java/com/android/internal/os/BatteryStatsImpl.java
index 94e7a06..4d35a6b 100644
--- a/core/java/com/android/internal/os/BatteryStatsImpl.java
+++ b/core/java/com/android/internal/os/BatteryStatsImpl.java
@@ -16,14 +16,11 @@
 
 package com.android.internal.os;
 
-import static android.net.NetworkStats.IFACE_ALL;
-import static android.net.NetworkStats.UID_ALL;
 import static android.text.format.DateUtils.SECOND_IN_MILLIS;
 import static com.android.server.NetworkManagementSocketTagger.PROP_QTAGUID_ENABLED;
 
 import android.bluetooth.BluetoothDevice;
 import android.bluetooth.BluetoothHeadset;
-import android.content.res.Resources;
 import android.net.ConnectivityManager;
 import android.net.NetworkStats;
 import android.os.BatteryManager;
@@ -49,7 +46,6 @@
 import android.util.SparseArray;
 import android.util.TimeUtils;
 
-import com.android.internal.R;
 import com.android.internal.net.NetworkStatsFactory;
 import com.android.internal.util.JournaledFile;
 import com.google.android.collect.Sets;
@@ -87,7 +83,7 @@
     private static final int MAGIC = 0xBA757475; // 'BATSTATS'
 
     // Current on-disk Parcel version
-    private static final int VERSION = 62 + (USE_OLD_HISTORY ? 1000 : 0);
+    private static final int VERSION = 64 + (USE_OLD_HISTORY ? 1000 : 0);
 
     // Maximum number of items we will record in the history.
     private static final int MAX_HISTORY_ITEMS = 2000;
@@ -356,8 +352,8 @@
     }
 
     public static interface Unpluggable {
-        void unplug(long batteryUptime, long batteryRealtime);
-        void plug(long batteryUptime, long batteryRealtime);
+        void unplug(long elapsedRealtime, long batteryUptime, long batteryRealtime);
+        void plug(long elapsedRealtime, long batteryUptime, long batteryRealtime);
     }
 
     /**
@@ -392,12 +388,12 @@
             out.writeInt(mUnpluggedCount);
         }
 
-        public void unplug(long batteryUptime, long batteryRealtime) {
+        public void unplug(long elapsedRealtime, long batteryUptime, long batteryRealtime) {
             mUnpluggedCount = mPluggedCount;
             mCount.set(mPluggedCount);
         }
 
-        public void plug(long batteryUptime, long batteryRealtime) {
+        public void plug(long elapsedRealtime, long batteryUptime, long batteryRealtime) {
             mPluggedCount = mCount.get();
         }
 
@@ -587,7 +583,7 @@
             out.writeLong(mUnpluggedTime);
         }
 
-        public void unplug(long batteryUptime, long batteryRealtime) {
+        public void unplug(long elapsedRealtime, long batteryUptime, long batteryRealtime) {
             if (DEBUG && mType < 0) {
                 Log.v(TAG, "unplug #" + mType + ": realtime=" + batteryRealtime
                         + " old mUnpluggedTime=" + mUnpluggedTime
@@ -602,7 +598,7 @@
             }
         }
 
-        public void plug(long batteryUptime, long batteryRealtime) {
+        public void plug(long elapsedRealtime, long batteryUptime, long batteryRealtime) {
             if (DEBUG && mType < 0) {
                 Log.v(TAG, "plug #" + mType + ": realtime=" + batteryRealtime
                         + " old mTotalTime=" + mTotalTime);
@@ -731,7 +727,7 @@
         boolean mTrackingReportedValues;
 
         /*
-         * A sequnce counter, incremented once for each update of the stats.
+         * A sequence counter, incremented once for each update of the stats.
          */
         int mUpdateVersion;
 
@@ -786,8 +782,8 @@
             mCurrentReportedTotalTime = totalTime;
         }
 
-        public void unplug(long batteryUptime, long batteryRealtime) {
-            super.unplug(batteryUptime, batteryRealtime);
+        public void unplug(long elapsedRealtime, long batteryUptime, long batteryRealtime) {
+            super.unplug(elapsedRealtime, batteryUptime, batteryRealtime);
             if (mTrackingReportedValues) {
                 mUnpluggedReportedTotalTime = mCurrentReportedTotalTime;
                 mUnpluggedReportedCount = mCurrentReportedCount;
@@ -795,8 +791,8 @@
             mInDischarge = true;
         }
 
-        public void plug(long batteryUptime, long batteryRealtime) {
-            super.plug(batteryUptime, batteryRealtime);
+        public void plug(long elapsedRealtime, long batteryUptime, long batteryRealtime) {
+            super.plug(elapsedRealtime, batteryUptime, batteryRealtime);
             mInDischarge = false;
         }
 
@@ -849,6 +845,141 @@
     }
 
     /**
+     * A timer that increments in batches.  It does not run for durations, but just jumps
+     * for a pre-determined amount.
+     */
+    public static final class BatchTimer extends Timer {
+        final Uid mUid;
+
+        /**
+         * The last time at which we updated the timer.  This is in elapsed realtime microseconds.
+         */
+        long mLastAddedTime;
+
+        /**
+         * The last duration that we added to the timer.  This is in microseconds.
+         */
+        long mLastAddedDuration;
+
+        /**
+         * Whether we are currently in a discharge cycle.
+         */
+        boolean mInDischarge;
+
+        BatchTimer(Uid uid, int type, ArrayList<Unpluggable> unpluggables,
+                boolean inDischarge, Parcel in) {
+            super(type, unpluggables, in);
+            mUid = uid;
+            mLastAddedTime = in.readLong();
+            mLastAddedDuration = in.readLong();
+            mInDischarge = inDischarge;
+        }
+
+        BatchTimer(Uid uid, int type, ArrayList<Unpluggable> unpluggables,
+                boolean inDischarge) {
+            super(type, unpluggables);
+            mUid = uid;
+            mInDischarge = inDischarge;
+        }
+
+        @Override
+        public void writeToParcel(Parcel out, long batteryRealtime) {
+            super.writeToParcel(out, batteryRealtime);
+            out.writeLong(mLastAddedTime);
+            out.writeLong(mLastAddedDuration);
+        }
+
+        @Override
+        public void plug(long elapsedRealtime, long batteryUptime, long batteryRealtime) {
+            recomputeLastDuration(SystemClock.elapsedRealtime() * 1000, false);
+            mInDischarge = false;
+            super.plug(elapsedRealtime, batteryUptime, batteryRealtime);
+        }
+
+        @Override
+        public void unplug(long elapsedRealtime, long batteryUptime, long batteryRealtime) {
+            recomputeLastDuration(elapsedRealtime, false);
+            mInDischarge = true;
+            // If we are still within the last added duration, then re-added whatever remains.
+            if (mLastAddedTime == elapsedRealtime) {
+                mTotalTime += mLastAddedDuration;
+            }
+            super.unplug(elapsedRealtime, batteryUptime, batteryRealtime);
+        }
+
+        @Override
+        public void logState(Printer pw, String prefix) {
+            super.logState(pw, prefix);
+            pw.println(prefix + "mLastAddedTime=" + mLastAddedTime
+                    + " mLastAddedDuration=" + mLastAddedDuration);
+        }
+
+        private long computeOverage(long curTime) {
+            if (mLastAddedTime > 0) {
+                return mLastTime + mLastAddedDuration - curTime;
+            }
+            return 0;
+        }
+
+        private void recomputeLastDuration(long curTime, boolean abort) {
+            final long overage = computeOverage(curTime);
+            if (overage > 0) {
+                // Aborting before the duration ran out -- roll back the remaining
+                // duration.  Only do this if currently discharging; otherwise we didn't
+                // actually add the time.
+                if (mInDischarge) {
+                    mTotalTime -= overage;
+                }
+                if (abort) {
+                    mLastAddedTime = 0;
+                } else {
+                    mLastAddedTime = curTime;
+                    mLastAddedDuration -= overage;
+                }
+            }
+        }
+
+        public void addDuration(BatteryStatsImpl stats, long durationMillis) {
+            final long now = SystemClock.elapsedRealtime() * 1000;
+            recomputeLastDuration(now, true);
+            mLastAddedTime = now;
+            mLastAddedDuration = durationMillis * 1000;
+            if (mInDischarge) {
+                mTotalTime += mLastAddedDuration;
+                mCount++;
+            }
+        }
+
+        public void abortLastDuration(BatteryStatsImpl stats) {
+            final long now = SystemClock.elapsedRealtime() * 1000;
+            recomputeLastDuration(now, true);
+        }
+
+        @Override
+        protected int computeCurrentCountLocked() {
+            return mCount;
+        }
+
+        @Override
+        protected long computeRunTimeLocked(long curBatteryRealtime) {
+            final long overage = computeOverage(SystemClock.elapsedRealtime() * 1000);
+            if (overage > 0) {
+                return mTotalTime = overage;
+            }
+            return mTotalTime;
+        }
+
+        @Override
+        boolean reset(BatteryStatsImpl stats, boolean detachIfReset) {
+            final long now = SystemClock.elapsedRealtime() * 1000;
+            recomputeLastDuration(now, true);
+            boolean stillActive = mLastAddedTime == now;
+            super.reset(stats, !stillActive && detachIfReset);
+            return !stillActive;
+        }
+    }
+
+    /**
      * State for keeping track of timing information.
      */
     public static final class StopwatchTimer extends Timer {
@@ -902,12 +1033,12 @@
             out.writeLong(mUpdateTime);
         }
 
-        public void plug(long batteryUptime, long batteryRealtime) {
+        public void plug(long elapsedRealtime, long batteryUptime, long batteryRealtime) {
             if (mNesting > 0) {
                 if (DEBUG && mType < 0) {
                     Log.v(TAG, "old mUpdateTime=" + mUpdateTime);
                 }
-                super.plug(batteryUptime, batteryRealtime);
+                super.plug(elapsedRealtime, batteryUptime, batteryRealtime);
                 mUpdateTime = batteryRealtime;
                 if (DEBUG && mType < 0) {
                     Log.v(TAG, "new mUpdateTime=" + mUpdateTime);
@@ -1443,7 +1574,7 @@
         mHistoryOverflow = false;
     }
 
-    public void doUnplugLocked(long batteryUptime, long batteryRealtime) {
+    public void doUnplugLocked(long elapsedRealtime, long batteryUptime, long batteryRealtime) {
         NetworkStats.Entry entry = null;
 
         // Track UID data usage
@@ -1462,7 +1593,7 @@
         }
 
         for (int i = mUnpluggables.size() - 1; i >= 0; i--) {
-            mUnpluggables.get(i).unplug(batteryUptime, batteryRealtime);
+            mUnpluggables.get(i).unplug(elapsedRealtime, batteryUptime, batteryRealtime);
         }
 
         // Track both mobile and total overall data
@@ -1483,7 +1614,7 @@
         mBluetoothPingCount = 0;
     }
 
-    public void doPlugLocked(long batteryUptime, long batteryRealtime) {
+    public void doPlugLocked(long elapsedRealtime, long batteryUptime, long batteryRealtime) {
         NetworkStats.Entry entry = null;
 
         for (int iu = mUidStats.size() - 1; iu >= 0; iu--) {
@@ -1498,7 +1629,7 @@
             }
         }
         for (int i = mUnpluggables.size() - 1; i >= 0; i--) {
-            mUnpluggables.get(i).plug(batteryUptime, batteryRealtime);
+            mUnpluggables.get(i).plug(elapsedRealtime, batteryUptime, batteryRealtime);
         }
 
         // Track both mobile and total overall data
@@ -2109,6 +2240,14 @@
         getUidStatsLocked(uid).noteVideoTurnedOffLocked();
     }
 
+    public void noteVibratorOnLocked(int uid, long durationMillis) {
+        getUidStatsLocked(uid).noteVibratorOnLocked(durationMillis);
+    }
+
+    public void noteVibratorOffLocked(int uid) {
+        getUidStatsLocked(uid).noteVibratorOffLocked();
+    }
+
     public void noteWifiRunningLocked(WorkSource ws) {
         if (!mGlobalWifiRunning) {
             mHistoryCur.states |= HistoryItem.STATE_WIFI_RUNNING_FLAG;
@@ -2402,6 +2541,8 @@
         boolean mVideoTurnedOn;
         StopwatchTimer mVideoTurnedOnTimer;
 
+        BatchTimer mVibratorOnTimer;
+
         Counter[] mUserActivityCounters;
 
         /**
@@ -2439,10 +2580,6 @@
                     mWifiScanTimers, mUnpluggables);
             mWifiMulticastTimer = new StopwatchTimer(Uid.this, WIFI_MULTICAST_ENABLED,
                     mWifiMulticastTimers, mUnpluggables);
-            mAudioTurnedOnTimer = new StopwatchTimer(Uid.this, AUDIO_TURNED_ON,
-                    null, mUnpluggables);
-            mVideoTurnedOnTimer = new StopwatchTimer(Uid.this, VIDEO_TURNED_ON,
-                    null, mUnpluggables);
         }
 
         @Override
@@ -2587,15 +2724,19 @@
             }
         }
 
+        public StopwatchTimer createAudioTurnedOnTimerLocked() {
+            if (mAudioTurnedOnTimer == null) {
+                mAudioTurnedOnTimer = new StopwatchTimer(Uid.this, AUDIO_TURNED_ON,
+                        null, mUnpluggables);
+            }
+            return mAudioTurnedOnTimer;
+        }
+
         @Override
         public void noteAudioTurnedOnLocked() {
             if (!mAudioTurnedOn) {
                 mAudioTurnedOn = true;
-                if (mAudioTurnedOnTimer == null) {
-                    mAudioTurnedOnTimer = new StopwatchTimer(Uid.this, AUDIO_TURNED_ON,
-                            null, mUnpluggables);
-                }
-                mAudioTurnedOnTimer.startRunningLocked(BatteryStatsImpl.this);
+                createAudioTurnedOnTimerLocked().startRunningLocked(BatteryStatsImpl.this);
             }
         }
 
@@ -2603,19 +2744,25 @@
         public void noteAudioTurnedOffLocked() {
             if (mAudioTurnedOn) {
                 mAudioTurnedOn = false;
-                mAudioTurnedOnTimer.stopRunningLocked(BatteryStatsImpl.this);
+                if (mAudioTurnedOnTimer != null) {
+                    mAudioTurnedOnTimer.stopRunningLocked(BatteryStatsImpl.this);
+                }
             }
         }
 
+        public StopwatchTimer createVideoTurnedOnTimerLocked() {
+            if (mVideoTurnedOnTimer == null) {
+                mVideoTurnedOnTimer = new StopwatchTimer(Uid.this, VIDEO_TURNED_ON,
+                        null, mUnpluggables);
+            }
+            return mVideoTurnedOnTimer;
+        }
+
         @Override
         public void noteVideoTurnedOnLocked() {
             if (!mVideoTurnedOn) {
                 mVideoTurnedOn = true;
-                if (mVideoTurnedOnTimer == null) {
-                    mVideoTurnedOnTimer = new StopwatchTimer(Uid.this, VIDEO_TURNED_ON,
-                            null, mUnpluggables);
-                }
-                mVideoTurnedOnTimer.startRunningLocked(BatteryStatsImpl.this);
+                createVideoTurnedOnTimerLocked().startRunningLocked(BatteryStatsImpl.this);
             }
         }
 
@@ -2623,7 +2770,27 @@
         public void noteVideoTurnedOffLocked() {
             if (mVideoTurnedOn) {
                 mVideoTurnedOn = false;
-                mVideoTurnedOnTimer.stopRunningLocked(BatteryStatsImpl.this);
+                if (mVideoTurnedOnTimer != null) {
+                    mVideoTurnedOnTimer.stopRunningLocked(BatteryStatsImpl.this);
+                }
+            }
+        }
+
+        public BatchTimer createVibratorOnTimerLocked() {
+            if (mVibratorOnTimer == null) {
+                mVibratorOnTimer = new BatchTimer(Uid.this, VIBRATOR_ON,
+                        mUnpluggables, BatteryStatsImpl.this.mOnBatteryInternal);
+            }
+            return mVibratorOnTimer;
+        }
+
+        public void noteVibratorOnLocked(long durationMillis) {
+            createVibratorOnTimerLocked().addDuration(BatteryStatsImpl.this, durationMillis);
+        }
+
+        public void noteVibratorOffLocked() {
+            if (mVibratorOnTimer != null) {
+                mVibratorOnTimer.abortLastDuration(BatteryStatsImpl.this);
             }
         }
 
@@ -2677,6 +2844,11 @@
         }
 
         @Override
+        public Timer getVibratorOnTimer() {
+            return mVibratorOnTimer;
+        }
+
+        @Override
         public void noteUserActivityLocked(int type) {
             if (mUserActivityCounters == null) {
                 initUserActivityLocked();
@@ -2747,6 +2919,14 @@
                 active |= !mVideoTurnedOnTimer.reset(BatteryStatsImpl.this, false);
                 active |= mVideoTurnedOn;
             }
+            if (mVibratorOnTimer != null) {
+                if (mVibratorOnTimer.reset(BatteryStatsImpl.this, false)) {
+                    mVibratorOnTimer.detach();
+                    mVibratorOnTimer = null;
+                } else {
+                    active = true;
+                }
+            }
 
             mLoadedTcpBytesReceived = mLoadedTcpBytesSent = 0;
             mCurrentTcpBytesReceived = mCurrentTcpBytesSent = 0;
@@ -2832,9 +3012,11 @@
                 }
                 if (mAudioTurnedOnTimer != null) {
                     mAudioTurnedOnTimer.detach();
+                    mAudioTurnedOnTimer = null;
                 }
                 if (mVideoTurnedOnTimer != null) {
                     mVideoTurnedOnTimer.detach();
+                    mVideoTurnedOnTimer = null;
                 }
                 if (mUserActivityCounters != null) {
                     for (int i=0; i<NUM_USER_ACTIVITY_TYPES; i++) {
@@ -2917,6 +3099,12 @@
             } else {
                 out.writeInt(0);
             }
+            if (mVibratorOnTimer != null) {
+                out.writeInt(1);
+                mVibratorOnTimer.writeToParcel(out, batteryRealtime);
+            } else {
+                out.writeInt(0);
+            }
             if (mUserActivityCounters != null) {
                 out.writeInt(1);
                 for (int i=0; i<NUM_USER_ACTIVITY_TYPES; i++) {
@@ -3016,6 +3204,12 @@
                 mVideoTurnedOnTimer = null;
             }
             if (in.readInt() != 0) {
+                mVibratorOnTimer = new BatchTimer(Uid.this, VIBRATOR_ON,
+                        mUnpluggables, BatteryStatsImpl.this.mOnBatteryInternal, in);
+            } else {
+                mVibratorOnTimer = null;
+            }
+            if (in.readInt() != 0) {
                 mUserActivityCounters = new Counter[NUM_USER_ACTIVITY_TYPES];
                 for (int i=0; i<NUM_USER_ACTIVITY_TYPES; i++) {
                     mUserActivityCounters[i] = new Counter(mUnpluggables, in);
@@ -3256,14 +3450,14 @@
                 mSpeedBins = new SamplingCounter[getCpuSpeedSteps()];
             }
 
-            public void unplug(long batteryUptime, long batteryRealtime) {
+            public void unplug(long elapsedRealtime, long batteryUptime, long batteryRealtime) {
                 mUnpluggedUserTime = mUserTime;
                 mUnpluggedSystemTime = mSystemTime;
                 mUnpluggedStarts = mStarts;
                 mUnpluggedForegroundTime = mForegroundTime;
             }
 
-            public void plug(long batteryUptime, long batteryRealtime) {
+            public void plug(long elapsedRealtime, long batteryUptime, long batteryRealtime) {
             }
 
             void detach() {
@@ -3550,11 +3744,11 @@
                 mUnpluggables.add(this);
             }
 
-            public void unplug(long batteryUptime, long batteryRealtime) {
+            public void unplug(long elapsedRealtime, long batteryUptime, long batteryRealtime) {
                 mUnpluggedWakeups = mWakeups;
             }
 
-            public void plug(long batteryUptime, long batteryRealtime) {
+            public void plug(long elapsedRealtime, long batteryUptime, long batteryRealtime) {
             }
 
             void detach() {
@@ -3712,13 +3906,13 @@
                     mUnpluggables.add(this);
                 }
 
-                public void unplug(long batteryUptime, long batteryRealtime) {
+                public void unplug(long elapsedRealtime, long batteryUptime, long batteryRealtime) {
                     mUnpluggedStartTime = getStartTimeToNowLocked(batteryUptime);
                     mUnpluggedStarts = mStarts;
                     mUnpluggedLaunches = mLaunches;
                 }
 
-                public void plug(long batteryUptime, long batteryRealtime) {
+                public void plug(long elapsedRealtime, long batteryUptime, long batteryRealtime) {
                 }
 
                 void detach() {
@@ -4367,7 +4561,7 @@
             }
             mDischargeAmountScreenOn = 0;
             mDischargeAmountScreenOff = 0;
-            doUnplugLocked(mUnpluggedBatteryUptime, mUnpluggedBatteryRealtime);
+            doUnplugLocked(realtime, mUnpluggedBatteryUptime, mUnpluggedBatteryRealtime);
         } else {
             updateKernelWakelocksLocked();
             mHistoryCur.batteryLevel = (byte)level;
@@ -4383,7 +4577,7 @@
                 mHighDischargeAmountSinceCharge += mDischargeUnplugLevel-level;
             }
             updateDischargeScreenLevelsLocked(mScreenOn, mScreenOn);
-            doPlugLocked(getBatteryUptimeLocked(uptime), getBatteryRealtimeLocked(realtime));
+            doPlugLocked(realtime, getBatteryUptimeLocked(uptime), getBatteryRealtimeLocked(realtime));
         }
         if (doWrite || (mLastWriteTime + (60 * 1000)) < mSecRealtime) {
             if (mFile != null) {
@@ -5161,11 +5355,14 @@
             }
             u.mAudioTurnedOn = false;
             if (in.readInt() != 0) {
-                u.mAudioTurnedOnTimer.readSummaryFromParcelLocked(in);
+                u.createAudioTurnedOnTimerLocked().readSummaryFromParcelLocked(in);
             }
             u.mVideoTurnedOn = false;
             if (in.readInt() != 0) {
-                u.mVideoTurnedOnTimer.readSummaryFromParcelLocked(in);
+                u.createVideoTurnedOnTimerLocked().readSummaryFromParcelLocked(in);
+            }
+            if (in.readInt() != 0) {
+                u.createVibratorOnTimerLocked().readSummaryFromParcelLocked(in);
             }
 
             if (in.readInt() != 0) {
@@ -5367,6 +5564,12 @@
             } else {
                 out.writeInt(0);
             }
+            if (u.mVibratorOnTimer != null) {
+                out.writeInt(1);
+                u.mVibratorOnTimer.writeSummaryFromParcelLocked(out, NOWREAL);
+            } else {
+                out.writeInt(0);
+            }
 
             if (u.mUserActivityCounters == null) {
                 out.writeInt(0);
diff --git a/core/java/com/android/internal/widget/ActionBarView.java b/core/java/com/android/internal/widget/ActionBarView.java
index 61bc002..8ccc612 100644
--- a/core/java/com/android/internal/widget/ActionBarView.java
+++ b/core/java/com/android/internal/widget/ActionBarView.java
@@ -1052,6 +1052,7 @@
                     (mDisplayOptions & ActionBar.DISPLAY_SHOW_TITLE) != 0;
             if (showTitle) {
                 x += positionChild(mTitleLayout, x, y, contentHeight, isLayoutRtl);
+                homeSlop = mTitleLayout.getWidth();
             }
 
             switch (mNavigationMode) {
diff --git a/core/jni/android_view_GLES20Canvas.cpp b/core/jni/android_view_GLES20Canvas.cpp
index d8d55b2..7d886da 100644
--- a/core/jni/android_view_GLES20Canvas.cpp
+++ b/core/jni/android_view_GLES20Canvas.cpp
@@ -449,16 +449,40 @@
     renderer->drawArc(left, top, right, bottom, startAngle, sweepAngle, useCenter, paint);
 }
 
-static void android_view_GLES20Canvas_drawRects(JNIEnv* env, jobject clazz,
+static void android_view_GLES20Canvas_drawRegionAsRects(JNIEnv* env, jobject clazz,
         OpenGLRenderer* renderer, SkRegion* region, SkPaint* paint) {
-    SkRegion::Iterator it(*region);
-    while (!it.done()) {
-        const SkIRect& r = it.rect();
-        renderer->drawRect(r.fLeft, r.fTop, r.fRight, r.fBottom, paint);
-        it.next();
+    if (paint->getStyle() != SkPaint::kFill_Style ||
+            (paint->isAntiAlias() && !renderer->isCurrentTransformSimple())) {
+        SkRegion::Iterator it(*region);
+        while (!it.done()) {
+            const SkIRect& r = it.rect();
+            renderer->drawRect(r.fLeft, r.fTop, r.fRight, r.fBottom, paint);
+            it.next();
+        }
+    } else {
+        int count = 0;
+        Vector<float> rects;
+        SkRegion::Iterator it(*region);
+        while (!it.done()) {
+            const SkIRect& r = it.rect();
+            rects.push(r.fLeft);
+            rects.push(r.fTop);
+            rects.push(r.fRight);
+            rects.push(r.fBottom);
+            count++;
+            it.next();
+        }
+        renderer->drawRects(rects.array(), count, paint);
     }
 }
 
+static void android_view_GLES20Canvas_drawRects(JNIEnv* env, jobject clazz,
+        OpenGLRenderer* renderer, jfloatArray rects, jint count, SkPaint* paint) {
+    jfloat* storage = env->GetFloatArrayElements(rects, NULL);
+    renderer->drawRects(storage, count, paint);
+    env->ReleaseFloatArrayElements(rects, storage, 0);
+}
+
 static void android_view_GLES20Canvas_drawPoints(JNIEnv* env, jobject clazz,
         OpenGLRenderer* renderer, jfloatArray points, jint offset, jint count, SkPaint* paint) {
     jfloat* storage = env->GetFloatArrayElements(points, NULL);
@@ -958,7 +982,8 @@
 
     { "nDrawColor",         "(III)V",          (void*) android_view_GLES20Canvas_drawColor },
     { "nDrawRect",          "(IFFFFI)V",       (void*) android_view_GLES20Canvas_drawRect },
-    { "nDrawRects",         "(III)V",          (void*) android_view_GLES20Canvas_drawRects },
+    { "nDrawRects",         "(III)V",          (void*) android_view_GLES20Canvas_drawRegionAsRects },
+    { "nDrawRects",         "(I[FII)V",        (void*) android_view_GLES20Canvas_drawRects },
     { "nDrawRoundRect",     "(IFFFFFFI)V",     (void*) android_view_GLES20Canvas_drawRoundRect },
     { "nDrawCircle",        "(IFFFI)V",        (void*) android_view_GLES20Canvas_drawCircle },
     { "nDrawOval",          "(IFFFFI)V",       (void*) android_view_GLES20Canvas_drawOval },
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index 9822e63..e357255 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -1327,21 +1327,6 @@
         android:label="@string/permlab_writeGservices"
         android:description="@string/permdesc_writeGservices" />
 
-    <!-- @hide Change the screen compatibility mode of applications -->
-    <permission android:name="android.permission.SET_SCREEN_COMPATIBILITY"
-        android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
-        android:protectionLevel="signature"
-        android:label="@string/permlab_setScreenCompatibility"
-        android:description="@string/permdesc_setScreenCompatibility" />
-
-    <!-- Allows an application to modify the current configuration, such
-         as locale. -->
-    <permission android:name="android.permission.CHANGE_CONFIGURATION"
-        android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
-        android:protectionLevel="system|signature"
-        android:label="@string/permlab_changeConfiguration"
-        android:description="@string/permdesc_changeConfiguration" />
-
     <!-- Allows an application to call
         {@link android.app.ActivityManager#forceStopPackage}.
         @hide -->
@@ -1621,6 +1606,13 @@
         android:description="@string/permdesc_updateBatteryStats"
         android:protectionLevel="signature|system" />
 
+    <!-- Allows an application to update application operation statistics. Not for
+         use by third party apps. @hide -->
+    <permission android:name="android.permission.UPDATE_APP_OPS_STATS"
+        android:label="@string/permlab_updateAppOpsStats"
+        android:description="@string/permdesc_updateAppOpsStats"
+        android:protectionLevel="signature|system" />
+
     <!-- Allows an application to open windows that are for use by parts
          of the system user interface.  Not for use by third party apps. -->
     <permission android:name="android.permission.INTERNAL_SYSTEM_WINDOW"
diff --git a/core/res/res/drawable-ldrtl-hdpi/ic_audio_notification.png b/core/res/res/drawable-ldrtl-hdpi/ic_audio_notification.png
new file mode 100644
index 0000000..62ef692
--- /dev/null
+++ b/core/res/res/drawable-ldrtl-hdpi/ic_audio_notification.png
Binary files differ
diff --git a/core/res/res/drawable-ldrtl-hdpi/ic_audio_notification_mute.png b/core/res/res/drawable-ldrtl-hdpi/ic_audio_notification_mute.png
new file mode 100644
index 0000000..40123e3
--- /dev/null
+++ b/core/res/res/drawable-ldrtl-hdpi/ic_audio_notification_mute.png
Binary files differ
diff --git a/core/res/res/drawable-ldrtl-hdpi/ic_audio_phone.png b/core/res/res/drawable-ldrtl-hdpi/ic_audio_phone.png
new file mode 100644
index 0000000..968f5ee
--- /dev/null
+++ b/core/res/res/drawable-ldrtl-hdpi/ic_audio_phone.png
Binary files differ
diff --git a/core/res/res/drawable-ldrtl-hdpi/ic_audio_ring_notif.png b/core/res/res/drawable-ldrtl-hdpi/ic_audio_ring_notif.png
new file mode 100644
index 0000000..e5f0dcf
--- /dev/null
+++ b/core/res/res/drawable-ldrtl-hdpi/ic_audio_ring_notif.png
Binary files differ
diff --git a/core/res/res/drawable-ldrtl-hdpi/ic_audio_ring_notif_mute.png b/core/res/res/drawable-ldrtl-hdpi/ic_audio_ring_notif_mute.png
new file mode 100644
index 0000000..371e32f
--- /dev/null
+++ b/core/res/res/drawable-ldrtl-hdpi/ic_audio_ring_notif_mute.png
Binary files differ
diff --git a/core/res/res/drawable-ldrtl-hdpi/ic_audio_ring_notif_vibrate.png b/core/res/res/drawable-ldrtl-hdpi/ic_audio_ring_notif_vibrate.png
new file mode 100644
index 0000000..e05e8f5
--- /dev/null
+++ b/core/res/res/drawable-ldrtl-hdpi/ic_audio_ring_notif_vibrate.png
Binary files differ
diff --git a/core/res/res/drawable-ldrtl-hdpi/ic_audio_vol.png b/core/res/res/drawable-ldrtl-hdpi/ic_audio_vol.png
new file mode 100644
index 0000000..81a8422
--- /dev/null
+++ b/core/res/res/drawable-ldrtl-hdpi/ic_audio_vol.png
Binary files differ
diff --git a/core/res/res/drawable-ldrtl-hdpi/ic_audio_vol_mute.png b/core/res/res/drawable-ldrtl-hdpi/ic_audio_vol_mute.png
new file mode 100644
index 0000000..371e32f
--- /dev/null
+++ b/core/res/res/drawable-ldrtl-hdpi/ic_audio_vol_mute.png
Binary files differ
diff --git a/core/res/res/drawable-ldrtl-mdpi/ic_audio_notification.png b/core/res/res/drawable-ldrtl-mdpi/ic_audio_notification.png
new file mode 100644
index 0000000..d9843e0
--- /dev/null
+++ b/core/res/res/drawable-ldrtl-mdpi/ic_audio_notification.png
Binary files differ
diff --git a/core/res/res/drawable-ldrtl-mdpi/ic_audio_notification_mute.png b/core/res/res/drawable-ldrtl-mdpi/ic_audio_notification_mute.png
new file mode 100644
index 0000000..2159cab
--- /dev/null
+++ b/core/res/res/drawable-ldrtl-mdpi/ic_audio_notification_mute.png
Binary files differ
diff --git a/core/res/res/drawable-ldrtl-mdpi/ic_audio_phone.png b/core/res/res/drawable-ldrtl-mdpi/ic_audio_phone.png
new file mode 100644
index 0000000..b5af351
--- /dev/null
+++ b/core/res/res/drawable-ldrtl-mdpi/ic_audio_phone.png
Binary files differ
diff --git a/core/res/res/drawable-ldrtl-mdpi/ic_audio_ring_notif.png b/core/res/res/drawable-ldrtl-mdpi/ic_audio_ring_notif.png
new file mode 100644
index 0000000..6341be6
--- /dev/null
+++ b/core/res/res/drawable-ldrtl-mdpi/ic_audio_ring_notif.png
Binary files differ
diff --git a/core/res/res/drawable-ldrtl-mdpi/ic_audio_ring_notif_mute.png b/core/res/res/drawable-ldrtl-mdpi/ic_audio_ring_notif_mute.png
new file mode 100644
index 0000000..b4c3a54
--- /dev/null
+++ b/core/res/res/drawable-ldrtl-mdpi/ic_audio_ring_notif_mute.png
Binary files differ
diff --git a/core/res/res/drawable-ldrtl-mdpi/ic_audio_ring_notif_vibrate.png b/core/res/res/drawable-ldrtl-mdpi/ic_audio_ring_notif_vibrate.png
new file mode 100644
index 0000000..835773e
--- /dev/null
+++ b/core/res/res/drawable-ldrtl-mdpi/ic_audio_ring_notif_vibrate.png
Binary files differ
diff --git a/core/res/res/drawable-ldrtl-mdpi/ic_audio_vol.png b/core/res/res/drawable-ldrtl-mdpi/ic_audio_vol.png
new file mode 100644
index 0000000..947d1f9
--- /dev/null
+++ b/core/res/res/drawable-ldrtl-mdpi/ic_audio_vol.png
Binary files differ
diff --git a/core/res/res/drawable-ldrtl-mdpi/ic_audio_vol_mute.png b/core/res/res/drawable-ldrtl-mdpi/ic_audio_vol_mute.png
new file mode 100644
index 0000000..b4c3a54
--- /dev/null
+++ b/core/res/res/drawable-ldrtl-mdpi/ic_audio_vol_mute.png
Binary files differ
diff --git a/core/res/res/drawable-ldrtl-xhdpi/ic_audio_notification.png b/core/res/res/drawable-ldrtl-xhdpi/ic_audio_notification.png
new file mode 100644
index 0000000..43aedea
--- /dev/null
+++ b/core/res/res/drawable-ldrtl-xhdpi/ic_audio_notification.png
Binary files differ
diff --git a/core/res/res/drawable-ldrtl-xhdpi/ic_audio_notification_mute.png b/core/res/res/drawable-ldrtl-xhdpi/ic_audio_notification_mute.png
new file mode 100644
index 0000000..4e87f77
--- /dev/null
+++ b/core/res/res/drawable-ldrtl-xhdpi/ic_audio_notification_mute.png
Binary files differ
diff --git a/core/res/res/drawable-ldrtl-xhdpi/ic_audio_phone.png b/core/res/res/drawable-ldrtl-xhdpi/ic_audio_phone.png
new file mode 100644
index 0000000..1066d03
--- /dev/null
+++ b/core/res/res/drawable-ldrtl-xhdpi/ic_audio_phone.png
Binary files differ
diff --git a/core/res/res/drawable-ldrtl-xhdpi/ic_audio_ring_notif.png b/core/res/res/drawable-ldrtl-xhdpi/ic_audio_ring_notif.png
new file mode 100644
index 0000000..daf9213
--- /dev/null
+++ b/core/res/res/drawable-ldrtl-xhdpi/ic_audio_ring_notif.png
Binary files differ
diff --git a/core/res/res/drawable-ldrtl-xhdpi/ic_audio_ring_notif_mute.png b/core/res/res/drawable-ldrtl-xhdpi/ic_audio_ring_notif_mute.png
new file mode 100644
index 0000000..83d3bdd
--- /dev/null
+++ b/core/res/res/drawable-ldrtl-xhdpi/ic_audio_ring_notif_mute.png
Binary files differ
diff --git a/core/res/res/drawable-ldrtl-xhdpi/ic_audio_ring_notif_vibrate.png b/core/res/res/drawable-ldrtl-xhdpi/ic_audio_ring_notif_vibrate.png
new file mode 100644
index 0000000..4de95aa
--- /dev/null
+++ b/core/res/res/drawable-ldrtl-xhdpi/ic_audio_ring_notif_vibrate.png
Binary files differ
diff --git a/core/res/res/drawable-ldrtl-xhdpi/ic_audio_vol.png b/core/res/res/drawable-ldrtl-xhdpi/ic_audio_vol.png
new file mode 100644
index 0000000..8132926
--- /dev/null
+++ b/core/res/res/drawable-ldrtl-xhdpi/ic_audio_vol.png
Binary files differ
diff --git a/core/res/res/drawable-ldrtl-xhdpi/ic_audio_vol_mute.png b/core/res/res/drawable-ldrtl-xhdpi/ic_audio_vol_mute.png
new file mode 100644
index 0000000..83d3bdd
--- /dev/null
+++ b/core/res/res/drawable-ldrtl-xhdpi/ic_audio_vol_mute.png
Binary files differ
diff --git a/core/res/res/values-sv/strings.xml b/core/res/res/values-sv/strings.xml
index 73031e0..ddf2863 100644
--- a/core/res/res/values-sv/strings.xml
+++ b/core/res/res/values-sv/strings.xml
@@ -246,7 +246,7 @@
     <string name="permlab_sendSmsNoConfirmation" msgid="4781483105951730228">"skicka SMS utan bekräftelse"</string>
     <string name="permdesc_sendSmsNoConfirmation" msgid="402569800862935907">"Tillåter att appen skickar SMS. Detta kan leda till oväntade avgifter. Skadliga appar kan skicka meddelanden utan ditt godkännande vilket kan kosta pengar."</string>
     <string name="permlab_readSms" msgid="8745086572213270480">"läsa dina textmeddelanden (SMS eller MMS)"</string>
-    <string name="permdesc_readSms" product="tablet" msgid="2467981548684735522">"Tillåter att appen läser SMS som sparats på pekdatorn eller på SIM-kortet. Med den här behörigheten tillåts appen att läsa alla SMS oavsett innehåll eller sekretess."</string>
+    <string name="permdesc_readSms" product="tablet" msgid="2467981548684735522">"Tillåter att appen läser SMS som sparats på surfplattan eller på SIM-kortet. Med den här behörigheten tillåts appen att läsa alla SMS oavsett innehåll eller sekretess."</string>
     <string name="permdesc_readSms" product="default" msgid="3695967533457240550">"Tillåter att appen läser SMS som sparats på mobilen eller på SIM-kortet. Med den här behörigheten tillåts appen att läsa alla SMS oavsett innehåll eller sekretess."</string>
     <string name="permlab_writeSms" msgid="3216950472636214774">"redigera dina textmeddelanden (SMS eller MMS)"</string>
     <string name="permdesc_writeSms" product="tablet" msgid="5160413947794501538">"Tillåter att appen skriver till SMS som lagras på surfplattan eller SIM-kortet. Skadliga appar kan radera dina meddelanden."</string>
@@ -330,7 +330,7 @@
     <string name="permlab_freezeScreen" msgid="4708181184441880175">"frysa skärmen"</string>
     <string name="permdesc_freezeScreen" msgid="8558923789222670064">"Tillåter att appen tillfälligt fryser skärmen för övergång till helskärm."</string>
     <string name="permlab_injectEvents" msgid="1378746584023586600">"trycka på knappar och styrknappar"</string>
-    <string name="permdesc_injectEvents" product="tablet" msgid="206352565599968632">"Tillåter att appen levererar egna inmatningshändelser (knapptryckningar osv.) till andra appar. Skadliga appar kan använda detta för att kapa pekdatorn."</string>
+    <string name="permdesc_injectEvents" product="tablet" msgid="206352565599968632">"Tillåter att appen levererar egna inmatningshändelser (knapptryckningar osv.) till andra appar. Skadliga appar kan använda detta för att kapa surfplattan."</string>
     <string name="permdesc_injectEvents" product="default" msgid="653128057572326253">"Tillåter att appen levererar egna inmatningshändelser (knapptryckningar osv.) till andra appar. Skadliga appar kan använda detta för att kapa mobilen."</string>
     <string name="permlab_readInputState" msgid="469428900041249234">"registrera vad du skriver och vilka åtgärder du vidtar"</string>
     <string name="permdesc_readInputState" msgid="8387754901688728043">"Tillåter att appen övervakar knapparna som du trycker på, till och med när du använder andra appar (till exempel när du anger ett lösenord). Ska inte behövas för vanliga appar."</string>
@@ -357,7 +357,7 @@
     <string name="permlab_signalPersistentProcesses" msgid="4539002991947376659">"skicka Linux-signaler till appar"</string>
     <string name="permdesc_signalPersistentProcesses" msgid="4896992079182649141">"Tillåter att appen begär att den angivna signalen skickas till alla beständiga processer."</string>
     <string name="permlab_persistentActivity" msgid="8841113627955563938">"se till att appen alltid körs"</string>
-    <string name="permdesc_persistentActivity" product="tablet" msgid="8525189272329086137">"Tillåter att delar av appen läggs beständigt i minnet. Detta kan innebära att det tillgängliga minnet för andra appar begränsas, vilket gör pekdatorn långsam."</string>
+    <string name="permdesc_persistentActivity" product="tablet" msgid="8525189272329086137">"Tillåter att delar av appen läggs beständigt i minnet. Detta kan innebära att det tillgängliga minnet för andra appar begränsas, vilket gör surfplattan långsam."</string>
     <string name="permdesc_persistentActivity" product="default" msgid="4384760047508278272">"Tillåter att delar av appen läggs beständigt i minnet. Detta kan innebära att det tillgängliga minnet för andra appar begränsas, vilket gör mobilen långsam."</string>
     <string name="permlab_deletePackages" msgid="184385129537705938">"ta bort appar"</string>
     <string name="permdesc_deletePackages" msgid="7411480275167205081">"Tillåter att appen tar bort Android-paket. Skadliga appar kan använda detta för att ta bort viktiga appar."</string>
@@ -375,15 +375,15 @@
     <string name="permlab_movePackage" msgid="3289890271645921411">"flytta appresurser"</string>
     <string name="permdesc_movePackage" msgid="319562217778244524">"Tillåter att appen flyttar appresurser från interna till externa medier och tvärtom."</string>
     <string name="permlab_readLogs" msgid="6615778543198967614">"läsa känsliga loggdata"</string>
-    <string name="permdesc_readLogs" product="tablet" msgid="82061313293455151">"Tillåter att appen läser från systemets olika loggfiler. Det innebär att appen kan upptäcka allmän information om vad du gör med pekdatorn, vilket kan inkludera personlig eller privat information."</string>
+    <string name="permdesc_readLogs" product="tablet" msgid="82061313293455151">"Tillåter att appen läser från systemets olika loggfiler. Det innebär att appen kan upptäcka allmän information om vad du gör med surfplattan, vilket kan inkludera personlig eller privat information."</string>
     <string name="permdesc_readLogs" product="default" msgid="2063438140241560443">"Tillåter att appen läser från systemets olika loggfiler. Det innebär att appen kan upptäcka allmän information om vad du gör med mobilen, vilket kan inkludera personlig eller privat information."</string>
     <string name="permlab_anyCodecForPlayback" msgid="715805555823881818">"använda alla medieavkodare för uppspelning"</string>
     <string name="permdesc_anyCodecForPlayback" msgid="8283912488433189010">"Tillåter att appen använder installerade medieavkodare för att avkoda media för uppspelning."</string>
     <string name="permlab_diagnostic" msgid="8076743953908000342">"läsa/skriva till resurser som ägs av diag"</string>
     <string name="permdesc_diagnostic" msgid="6608295692002452283">"Tillåter att appen läser och skriver till en resurs som ägs av diag-gruppen, till exempel filer i /dev. Detta kan eventuellt påverka systemets stabilitet och säkerhet. Detta bör ENDAST användas av tillverkaren eller operatören för maskinvaruspecifik diagnostik."</string>
     <string name="permlab_changeComponentState" msgid="6335576775711095931">"aktivera eller inaktivera appkomponenter"</string>
-    <string name="permdesc_changeComponentState" product="tablet" msgid="8887435740982237294">"Tillåter att appen ändrar inställningen för om en komponent i en annan app ska aktiveras eller inte. Skadliga appar kan använda detta för att inaktivera viktiga funktioner i pekdatorn. Var försiktig med behörigheten, eftersom appkomponenter kan bli oanvändbara, inkonsekventa eller instabila."</string>
-    <string name="permdesc_changeComponentState" product="default" msgid="1827232484416505615">"Tillåter att appen ändrar inställningen för om en komponent i en annan app ska aktiveras eller inte. Skadliga appar kan använda detta för att inaktivera viktiga funktioner i pekdatorn. Var försiktig med behörigheten, eftersom programkomponenter kan bli oanvändbara, inkonsekventa eller instabila."</string>
+    <string name="permdesc_changeComponentState" product="tablet" msgid="8887435740982237294">"Tillåter att appen ändrar inställningen för om en komponent i en annan app ska aktiveras eller inte. Skadliga appar kan använda detta för att inaktivera viktiga funktioner i surfplattan. Var försiktig med behörigheten, eftersom appkomponenter kan bli oanvändbara, inkonsekventa eller instabila."</string>
+    <string name="permdesc_changeComponentState" product="default" msgid="1827232484416505615">"Tillåter att appen ändrar inställningen för om en komponent i en annan app ska aktiveras eller inte. Skadliga appar kan använda detta för att inaktivera viktiga funktioner i surfplattan. Var försiktig med behörigheten, eftersom programkomponenter kan bli oanvändbara, inkonsekventa eller instabila."</string>
     <string name="permlab_grantRevokePermissions" msgid="4627315351093508795">"bevilja eller återkalla behörighet"</string>
     <string name="permdesc_grantRevokePermissions" msgid="4088642654085850662">"Tillåter att en app beviljar eller återkallar specifik behörighet, för sig själv eller andra appar. Skadlig programvara kan utnyttja detta för att få åtkomst till funktioner som du inte har beviljat behörighet till."</string>
     <string name="permlab_setPreferredApplications" msgid="8463181628695396391">"ange önskade appar"</string>
@@ -401,10 +401,10 @@
     <string name="permdesc_broadcastSticky" product="tablet" msgid="7749760494399915651">"Tillåter att appen skickar sticky broadcasts, som finns kvar när sändningen är slut. Vid intensiv användning kan mobilen bli långsam eller instabil eftersom minnet överbelastas."</string>
     <string name="permdesc_broadcastSticky" product="default" msgid="2825803764232445091">"Tillåter att appen skickar sticky broadcast, som finns kvar när sändningen är slut. Vid intensiv användning kan mobilen bli långsam eller instabil eftersom minnet överbelastas."</string>
     <string name="permlab_readContacts" msgid="8348481131899886131">"läsa dina kontakter"</string>
-    <string name="permdesc_readContacts" product="tablet" msgid="5294866856941149639">"Tillåter att appen läser kontaktuppgifter som sparats på pekdatorn, inklusive information om hur ofta du har ringt, skickat e-post till eller på andra sätt kommunicerat med specifika personer. Med den här behörigheten tillåts appen att spara kontaktuppgifter. Skadliga appar kan dela uppgifterna med andra utan din vetskap."</string>
+    <string name="permdesc_readContacts" product="tablet" msgid="5294866856941149639">"Tillåter att appen läser kontaktuppgifter som sparats på surfplattan, inklusive information om hur ofta du har ringt, skickat e-post till eller på andra sätt kommunicerat med specifika personer. Med den här behörigheten tillåts appen att spara kontaktuppgifter. Skadliga appar kan dela uppgifterna med andra utan din vetskap."</string>
     <string name="permdesc_readContacts" product="default" msgid="8440654152457300662">"Tillåter att appen läser kontaktuppgifter som sparats på mobilen, inklusive information om hur ofta du har ringt, skickat e-post till eller på andra sätt kommunicerat med specifika personer. Med den här behörigheten tillåts appen att spara kontaktuppgifter. Skadliga appar kan dela uppgifterna med andra utan din vetskap."</string>
     <string name="permlab_writeContacts" msgid="5107492086416793544">"ändra kontakterna"</string>
-    <string name="permdesc_writeContacts" product="tablet" msgid="897243932521953602">"Tillåter att appen ändrar kontaktuppgifter som sparats på pekdatorn, inklusive information om hur ofta du har ringt, skickat e-post till eller på andra sätt kommunicerat med specifika personer. Med den här behörigheten tillåts appar att ta bort kontaktuppgifter."</string>
+    <string name="permdesc_writeContacts" product="tablet" msgid="897243932521953602">"Tillåter att appen ändrar kontaktuppgifter som sparats på surfplattan, inklusive information om hur ofta du har ringt, skickat e-post till eller på andra sätt kommunicerat med specifika personer. Med den här behörigheten tillåts appar att ta bort kontaktuppgifter."</string>
     <string name="permdesc_writeContacts" product="default" msgid="589869224625163558">"Tillåter att appen ändrar kontaktuppgifter som sparats på mobilen, inklusive information om hur ofta du har ringt, skickat e-post till eller på andra sätt kommunicerat med specifika personer. Med den här behörigheten tillåts appar att ta bort kontaktuppgifter."</string>
     <string name="permlab_readCallLog" msgid="3478133184624102739">"läs samtalslogg"</string>
     <string name="permdesc_readCallLog" product="tablet" msgid="3700645184870760285">"Tillåter att appen läser pekdatorns samtalslista, inklusive uppgifter om inkommande och utgående samtal. Med den här behörigheten tillåts appen att spara samtalshistoriken. Skadliga appar kan dela uppgifterna med andra utan din vetskap."</string>
@@ -421,10 +421,10 @@
     <string name="permlab_writeSocialStream" product="default" msgid="3504179222493235645">"skriv till mitt sociala flöde"</string>
     <string name="permdesc_writeSocialStream" product="default" msgid="3086557552204114849">"Tillåter att appen visar sociala uppdateringar från dina vänner. Var försiktig när du delar information – med den här behörigheten tillåts appen att generera meddelanden som kan se ut att komma från en vän. Observera att den här behörigheten kanske inte är tillämplig på alla sociala nätverk."</string>
     <string name="permlab_readCalendar" msgid="5972727560257612398">"läsa kalenderuppgifter plus konfidentiell information"</string>
-    <string name="permdesc_readCalendar" product="tablet" msgid="4216462049057658723">"Tillåter att appen läser alla kalenderuppgifter som sparats på pekdatorn, inklusive dina vänners eller kollegors uppgifter. Med den här behörigheten kan appen tillåtas att dela eller spara kalenderuppgifter även om de är sekretessbelagda eller känsliga."</string>
+    <string name="permdesc_readCalendar" product="tablet" msgid="4216462049057658723">"Tillåter att appen läser alla kalenderuppgifter som sparats på surfplattan, inklusive dina vänners eller kollegors uppgifter. Med den här behörigheten kan appen tillåtas att dela eller spara kalenderuppgifter även om de är sekretessbelagda eller känsliga."</string>
     <string name="permdesc_readCalendar" product="default" msgid="7434548682470851583">"Tillåter att appen läser alla kalenderuppgifter som sparats på mobilen, inklusive dina vänners eller kollegors uppgifter. Med den här behörigheten kan appen tillåtas att dela eller spara kalenderuppgifter även om de är sekretessbelagda eller känsliga."</string>
     <string name="permlab_writeCalendar" msgid="8438874755193825647">"lägga till eller ändra kalenderuppgifter och skicka e-post till gäster utan ägarens vetskap"</string>
-    <string name="permdesc_writeCalendar" product="tablet" msgid="6679035520113668528">"Tillåter att appen lägger till, tar bort och ändrar sådana händelser som du kan ändra på pekdatorn, inklusive dina vänners eller kollegors uppgifter. Detta kan innebära att appen tillåts skicka meddelanden som ser ut att komma från kalenderns ägare eller ändra händelser utan ägarens vetskap."</string>
+    <string name="permdesc_writeCalendar" product="tablet" msgid="6679035520113668528">"Tillåter att appen lägger till, tar bort och ändrar sådana händelser som du kan ändra på surfplattan, inklusive dina vänners eller kollegors uppgifter. Detta kan innebära att appen tillåts skicka meddelanden som ser ut att komma från kalenderns ägare eller ändra händelser utan ägarens vetskap."</string>
     <string name="permdesc_writeCalendar" product="default" msgid="2324469496327249376">"Tillåter att appen lägger till, tar bort och ändrar sådana händelser som du kan ändra på mobilen, inklusive dina vänners eller kollegors uppgifter. Detta kan innebära att appen tillåts skicka meddelanden som ser ut att komma från kalenderns ägare eller ändra händelser utan ägarens vetskap."</string>
     <string name="permlab_accessMockLocation" msgid="8688334974036823330">"skenplatser för att testa"</string>
     <string name="permdesc_accessMockLocation" msgid="5808711039482051824">"Skapa skenplatser för tester eller installera en ny platsleverantör. Detta innebär att appen tillåts åsidosätta den plats och/eller status som returneras av andra platskällor, till exempel GPS eller platsleverantörer."</string>
@@ -452,7 +452,7 @@
     <string name="permdesc_camera" msgid="8497216524735535009">"Tillåter att appen tar bilder och spelar in videor med kameran. Med den här behörigheten tillåts appen att använda kameran när som helst utan ditt godkännande."</string>
     <string name="permlab_brick" product="tablet" msgid="2961292205764488304">"inaktivera surfplattan permanent"</string>
     <string name="permlab_brick" product="default" msgid="8337817093326370537">"inaktivera telefonen permanent"</string>
-    <string name="permdesc_brick" product="tablet" msgid="4334818808001699530">"Tillåter att appen inaktiverar hela pekdatorn permanent. Detta är mycket farligt."</string>
+    <string name="permdesc_brick" product="tablet" msgid="4334818808001699530">"Tillåter att appen inaktiverar hela surfplattan permanent. Detta är mycket farligt."</string>
     <string name="permdesc_brick" product="default" msgid="5788903297627283099">"Tillåter att appen inaktiverar hela mobilen permanent. Detta är mycket farligt."</string>
     <string name="permlab_reboot" product="tablet" msgid="3436634972561795002">"tvinga omstart av surfplatta"</string>
     <string name="permlab_reboot" product="default" msgid="2898560872462638242">"tvinga omstart av telefon"</string>
@@ -503,7 +503,7 @@
     <string name="permdesc_readPhoneState" msgid="1639212771826125528">"Tillåter att appen kommer åt enhetens telefonfunktioner. Med den här behörigheten tillåts appen att identifiera mobilens telefonnummer och enhets-ID, om ett samtal pågår och vilket nummer samtalet är kopplat till."</string>
     <string name="permlab_wakeLock" product="tablet" msgid="1531731435011495015">"förhindra att surfplattan går in i viloläge"</string>
     <string name="permlab_wakeLock" product="default" msgid="573480187941496130">"förhindra att telefonen sätts i viloläge"</string>
-    <string name="permdesc_wakeLock" product="tablet" msgid="7311319824400447868">"Tillåter att appen förhindrar att pekdatorn går in i viloläge."</string>
+    <string name="permdesc_wakeLock" product="tablet" msgid="7311319824400447868">"Tillåter att appen förhindrar att surfplattan går in i viloläge."</string>
     <string name="permdesc_wakeLock" product="default" msgid="8559100677372928754">"Tillåter att appen förhindrar att mobilen går in i viloläge."</string>
     <string name="permlab_devicePower" product="tablet" msgid="2787034722616350417">"slå på eller stänga av surfplattan"</string>
     <string name="permlab_devicePower" product="default" msgid="4928622470980943206">"sätta på eller stänga av telefonen"</string>
@@ -527,7 +527,7 @@
     <string name="permlab_accountManagerService" msgid="4829262349691386986">"fungera som AccountManagerService"</string>
     <string name="permdesc_accountManagerService" msgid="1948455552333615954">"Tillåter att appen anropar AccountAuthenticators."</string>
     <string name="permlab_getAccounts" msgid="1086795467760122114">"hitta konton på enheten"</string>
-    <string name="permdesc_getAccounts" product="tablet" msgid="2741496534769660027">"Tillåter att appen hämtar en lista över alla kända konton på pekdatorn. Detta kan inkludera konton som har skapats av appar som du har installerat."</string>
+    <string name="permdesc_getAccounts" product="tablet" msgid="2741496534769660027">"Tillåter att appen hämtar en lista över alla kända konton på surfplattan. Detta kan inkludera konton som har skapats av appar som du har installerat."</string>
     <string name="permdesc_getAccounts" product="default" msgid="3448316822451807382">"Tillåter att appen hämtar en lista över alla kända konton på mobilen. Detta kan inkludera konton som har skapats av appar som du har installerat."</string>
     <string name="permlab_authenticateAccounts" msgid="5265908481172736933">"skapa konton och ange lösenord"</string>
     <string name="permdesc_authenticateAccounts" msgid="5472124296908977260">"Tillåter att appen använder AccountManagers kontoautentiseringsfunktioner, bland annat funktioner för att skapa konton samt hämta och ange lösenord för dem."</string>
@@ -552,15 +552,15 @@
     <string name="permlab_changeWifiState" msgid="6550641188749128035">"anslut och koppla från Wi-Fi"</string>
     <string name="permdesc_changeWifiState" msgid="7137950297386127533">"Tillåter att appen ansluter till och kopplar från Wi-Fi-åtkomstpunkter samt gör ändringar i enhetens konfiguration för Wi-Fi-nätverk."</string>
     <string name="permlab_changeWifiMulticastState" msgid="1368253871483254784">"tillåt Wi-Fi multicast-mottagning"</string>
-    <string name="permdesc_changeWifiMulticastState" product="tablet" msgid="7969774021256336548">"Tillåter att appen tar emot paket som skickats med multicast-adress till alla enheter i ett Wi-Fi-nätverk och inte bara till den här pekdatorn. Detta drar mer batteri än när multicastläget inte används."</string>
+    <string name="permdesc_changeWifiMulticastState" product="tablet" msgid="7969774021256336548">"Tillåter att appen tar emot paket som skickats med multicast-adress till alla enheter i ett Wi-Fi-nätverk och inte bara till den här surfplattan. Detta drar mer batteri än när multicastläget inte används."</string>
     <string name="permdesc_changeWifiMulticastState" product="default" msgid="6851949706025349926">"Tillåter att appen tar emot paket som skickats med multicast-adress till alla enheter i ett Wi-Fi-nätverk och inte bara till den här mobilen. Detta drar mer batteri än när multicastläget inte används."</string>
     <string name="permlab_bluetoothAdmin" msgid="6006967373935926659">"få åtkomst till Bluetooth-inställningar"</string>
-    <string name="permdesc_bluetoothAdmin" product="tablet" msgid="6921177471748882137">"Tillåter att appen konfigurerar den lokala Bluetooth-pekdatorn samt upptäcker och parkopplar den med fjärranslutna enheter."</string>
+    <string name="permdesc_bluetoothAdmin" product="tablet" msgid="6921177471748882137">"Tillåter att appen konfigurerar den lokala Bluetooth-surfplattan samt upptäcker och parkopplar den med fjärranslutna enheter."</string>
     <string name="permdesc_bluetoothAdmin" product="default" msgid="8931682159331542137">"Tillåter att appen konfigurerar den lokala Bluetooth-mobilen samt upptäcker och parkopplar den med fjärranslutna enheter."</string>
     <string name="permlab_accessWimaxState" msgid="4195907010610205703">"ansluta till och koppla från WiMAX"</string>
     <string name="permdesc_accessWimaxState" msgid="6360102877261978887">"Tillåter att appen avgör om WiMAX är aktiverat och kommer åt information om eventuella anslutna WiMAX-nätverk."</string>
     <string name="permlab_changeWimaxState" msgid="2405042267131496579">"ändra WiMAX-status"</string>
-    <string name="permdesc_changeWimaxState" product="tablet" msgid="3156456504084201805">"Tillåter att appen ansluter pekdatorn till eller kopplar från WiMAX-nätverk."</string>
+    <string name="permdesc_changeWimaxState" product="tablet" msgid="3156456504084201805">"Tillåter att appen ansluter surfplattan till eller kopplar från WiMAX-nätverk."</string>
     <string name="permdesc_changeWimaxState" product="default" msgid="697025043004923798">"Tillåter att appen ansluter mobilen till eller kopplar från WiMAX-nätverk."</string>
     <string name="permlab_bluetooth" msgid="6127769336339276828">"koppla till Bluetooth-enheter"</string>
     <string name="permdesc_bluetooth" product="tablet" msgid="3480722181852438628">"Tillåter att appen kommer åt pekdatorns Bluetooth-konfiguration och upprättar och godkänner anslutningar till parkopplade enheter."</string>
@@ -615,7 +615,7 @@
     <string name="policylab_forceLock" msgid="2274085384704248431">"Lås skärmen"</string>
     <string name="policydesc_forceLock" msgid="1141797588403827138">"Kontrollera hur och när skärmlåset aktiveras."</string>
     <string name="policylab_wipeData" msgid="3910545446758639713">"Radera alla data"</string>
-    <string name="policydesc_wipeData" product="tablet" msgid="4306184096067756876">"Ta bort data från pekdatorn utan förvarning genom att återställa standardinställningarna."</string>
+    <string name="policydesc_wipeData" product="tablet" msgid="4306184096067756876">"Ta bort data från surfplattan utan förvarning genom att återställa standardinställningarna."</string>
     <string name="policydesc_wipeData" product="default" msgid="5096895604574188391">"Ta bort data från mobilen utan förvarning genom att återställa standardinställningarna."</string>
     <string name="policylab_setGlobalProxy" msgid="2784828293747791446">"Ange global proxyserver"</string>
     <string name="policydesc_setGlobalProxy" msgid="6387497466660154931">"Ange vilken global proxyserver som ska användas när policyn är aktiverad. Endast den första enhetsadministratören anger den faktiska globala proxyservern."</string>
@@ -786,7 +786,7 @@
     <string name="lockscreen_too_many_failed_attempts_dialog_message" msgid="6481623830344107222">"Du har ritat ditt grafiska lösenord fel <xliff:g id="NUMBER_0">%d</xliff:g> gånger. "\n\n"Försök igen om <xliff:g id="NUMBER_1">%d</xliff:g> sekunder."</string>
     <string name="lockscreen_too_many_failed_password_attempts_dialog_message" msgid="2725973286239344555">"Du har angett fel lösenord <xliff:g id="NUMBER_0">%d</xliff:g> gånger. "\n\n"Försök igen om <xliff:g id="NUMBER_1">%d</xliff:g> sekunder."</string>
     <string name="lockscreen_too_many_failed_pin_attempts_dialog_message" msgid="6216672706545696955">"Du har angett fel lösenord <xliff:g id="NUMBER_0">%d</xliff:g> gånger. "\n\n"Försök igen om <xliff:g id="NUMBER_1">%d</xliff:g> sekunder."</string>
-    <string name="lockscreen_failed_attempts_almost_glogin" product="tablet" msgid="9191611984625460820">"Du har ritat ditt grafiska lösenord fel <xliff:g id="NUMBER_0">%d</xliff:g> gånger. Efter <xliff:g id="NUMBER_1">%d</xliff:g> försök till ombeds du att låsa upp pekdatorn med din Google-inloggning."\n\n" Försök igen om  <xliff:g id="NUMBER_2">%d</xliff:g> sekunder."</string>
+    <string name="lockscreen_failed_attempts_almost_glogin" product="tablet" msgid="9191611984625460820">"Du har ritat ditt grafiska lösenord fel <xliff:g id="NUMBER_0">%d</xliff:g> gånger. Efter <xliff:g id="NUMBER_1">%d</xliff:g> försök till ombeds du att låsa upp surfplattan med din Google-inloggning."\n\n" Försök igen om  <xliff:g id="NUMBER_2">%d</xliff:g> sekunder."</string>
     <string name="lockscreen_failed_attempts_almost_glogin" product="default" msgid="2590227559763762751">"Du har ritat ditt grafiska lösenord fel <xliff:g id="NUMBER_0">%d</xliff:g> gånger. Efter <xliff:g id="NUMBER_1">%d</xliff:g> försök till ombeds du att låsa upp mobilen med uppgifterna som du använder när du loggar in på Google."\n\n" Försök igen om  <xliff:g id="NUMBER_2">%d</xliff:g> sekunder."</string>
     <string name="lockscreen_failed_attempts_almost_at_wipe" product="tablet" msgid="6128106399745755604">"Du har försökt låsa upp surfplattan på fel sätt <xliff:g id="NUMBER_0">%d</xliff:g> gånger. Efter <xliff:g id="NUMBER_1">%d</xliff:g> misslyckade försök till kommer surfplattan att återställas till fabriksinställningarna. Du förlorar då alla användardata."</string>
     <string name="lockscreen_failed_attempts_almost_at_wipe" product="default" msgid="8603565142156826565">"Du har försökt låsa upp mobilen på fel sätt <xliff:g id="NUMBER_0">%d</xliff:g> gånger. Efter <xliff:g id="NUMBER_1">%d</xliff:g> misslyckade försök till kommer mobilen att återställas till fabriksinställningarna. Du förlorar då alla användardata."</string>
@@ -870,7 +870,7 @@
     <string name="permlab_readHistoryBookmarks" msgid="3775265775405106983">"läsa dina bokmärken och din historik på webben"</string>
     <string name="permdesc_readHistoryBookmarks" msgid="8462378226600439658">"Tillåter att appen läser historiken för besökta sidor och alla bokmärken i webbläsaren. Observera att den här behörigheten kanske inte är tillämplig för webbläsare från tredje part eller andra appar med surffunktion."</string>
     <string name="permlab_writeHistoryBookmarks" msgid="3714785165273314490">"skriva bokmärken och historik på webben"</string>
-    <string name="permdesc_writeHistoryBookmarks" product="tablet" msgid="6825527469145760922">"Tillåter att appen ändrar historiken för besökta sidor i webbläsaren eller bokmärken som sparats på pekdatorn. Det kan innebära att appen kan ta bort eller ändra webbläsarinformation. Observera att den här behörigheten kanske inte är tillämplig för webbläsare från tredje part eller andra appar med surffunktion."</string>
+    <string name="permdesc_writeHistoryBookmarks" product="tablet" msgid="6825527469145760922">"Tillåter att appen ändrar historiken för besökta sidor i webbläsaren eller bokmärken som sparats på surfplattan. Det kan innebära att appen kan ta bort eller ändra webbläsarinformation. Observera att den här behörigheten kanske inte är tillämplig för webbläsare från tredje part eller andra appar med surffunktion."</string>
     <string name="permdesc_writeHistoryBookmarks" product="default" msgid="8497389531014185509">"Tillåter att appen ändrar historiken för besökta sidor i webbläsaren eller bokmärken som sparats på telefonen. Det kan innebära att appen kan ta bort eller ändra webbläsarinformation. Observera att den här behörigheten kanske inte är tillämplig för webbläsare från tredje part eller andra appar med surffunktion."</string>
     <string name="permlab_setAlarm" msgid="1379294556362091814">"ställa in ett alarm"</string>
     <string name="permdesc_setAlarm" msgid="316392039157473848">"Tillåter att appen ställer in ett alarm i en befintlig alarmapp. Vissa alarmappar har inte den här funktionen."</string>
@@ -906,7 +906,7 @@
     <string name="searchview_description_submit" msgid="2688450133297983542">"Skicka fråga"</string>
     <string name="searchview_description_voice" msgid="2453203695674994440">"Röstsökning"</string>
     <string name="enable_explore_by_touch_warning_title" msgid="7460694070309730149">"Aktivera Explore by Touch?"</string>
-    <string name="enable_explore_by_touch_warning_message" product="tablet" msgid="8655887539089910577">"<xliff:g id="ACCESSIBILITY_SERVICE_NAME">%1$s</xliff:g> vill aktivera Explore by Touch. När funktionen är aktiv kan du höra eller se beskrivningar av vad du har under fingret eller utföra gester för att göra saker med pekdatorn."</string>
+    <string name="enable_explore_by_touch_warning_message" product="tablet" msgid="8655887539089910577">"<xliff:g id="ACCESSIBILITY_SERVICE_NAME">%1$s</xliff:g> vill aktivera Explore by Touch. När funktionen är aktiv kan du höra eller se beskrivningar av vad du har under fingret eller utföra gester för att göra saker med surfplattan."</string>
     <string name="enable_explore_by_touch_warning_message" product="default" msgid="2708199672852373195">"<xliff:g id="ACCESSIBILITY_SERVICE_NAME">%1$s</xliff:g> vill aktivera Explore by Touch. När funktionen är aktiv kan du höra eller se beskrivningar av vad du har under fingret eller utföra gester för att göra saker med telefonen."</string>
     <string name="oneMonthDurationPast" msgid="7396384508953779925">"för 1 månad sedan"</string>
     <string name="beforeOneMonthDurationPast" msgid="909134546836499826">"För mer än en månad sedan"</string>
diff --git a/core/res/res/values-zh-rTW/strings.xml b/core/res/res/values-zh-rTW/strings.xml
index 21c4a64..a574468 100644
--- a/core/res/res/values-zh-rTW/strings.xml
+++ b/core/res/res/values-zh-rTW/strings.xml
@@ -321,7 +321,7 @@
     <string name="permdesc_confirm_full_backup" msgid="1748762171637699562">"允許應用程式啟動完整備份確認使用者介面 (不建議任何應用程式使用)。"</string>
     <string name="permlab_internalSystemWindow" msgid="2148563628140193231">"顯示未授權視窗"</string>
     <string name="permdesc_internalSystemWindow" msgid="7458387759461466397">"允許應用程式為內部系統使用者介面建立視窗 (不建議一般應用程式使用)。"</string>
-    <string name="permlab_systemAlertWindow" msgid="3543347980839518613">"描繪其他應用程式"</string>
+    <string name="permlab_systemAlertWindow" msgid="3543347980839518613">"在其他應用程式之上顯示内容"</string>
     <string name="permdesc_systemAlertWindow" msgid="8584678381972820118">"允許應用程式在其他應用程式頂層或使用者介面的特定部分繪圖。這可能會干擾您在所有應用程式中的介面使用行為,或是使您在其他應用程式中預期看到的內容發生變化。"</string>
     <string name="permlab_setAnimationScale" msgid="2805103241153907174">"編輯全域動畫速度"</string>
     <string name="permdesc_setAnimationScale" msgid="7690063428924343571">"允許應用程式隨時變更全域的動畫速度 (更快或更慢)。"</string>
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index cb8d0e5..6a93860 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -842,6 +842,12 @@
     <string name="permdesc_updateBatteryStats">Allows the app to modify
         collected battery statistics. Not for use by normal apps.</string>
 
+    <!-- [CHAR LIMIT=NONE] Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
+    <string name="permlab_updateAppOpsStats">modify app ops statistics</string>
+    <!-- [CHAR LIMIT=NONE] Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
+    <string name="permdesc_updateAppOpsStats">Allows the app to modify
+        collected application operation statistics. Not for use by normal apps.</string>
+    
     <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
     <string name="permlab_backup">control system backup and restore</string>
     <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
diff --git a/core/tests/coretests/src/android/net/http/SslCertificateTest.java b/core/tests/coretests/src/android/net/http/SslCertificateTest.java
index 147816b..6a30c6c 100644
--- a/core/tests/coretests/src/android/net/http/SslCertificateTest.java
+++ b/core/tests/coretests/src/android/net/http/SslCertificateTest.java
@@ -45,11 +45,70 @@
 
     @LargeTest
     public void testSslCertificateWithEmptyIssuer() throws Exception {
-        CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
-        X509Certificate x509Certificate = (X509Certificate)
-            certificateFactory.generateCertificate(new ByteArrayInputStream(Issue1597Certificate.getBytes()));
-        assertEquals(x509Certificate.getIssuerDN().getName(), "");
+        X509Certificate x509Certificate = generateCertificate(Issue1597Certificate);
+        assertEquals("", x509Certificate.getSubjectDN().getName());
         SslCertificate sslCertificate = new SslCertificate(x509Certificate);
-        assertEquals(sslCertificate.getIssuedBy().getDName(), "");
+        assertEquals("", sslCertificate.getIssuedBy().getDName());
     }
+
+    /**
+     * Problematic certificate from Issue 41662
+     * http://code.google.com/p/android/issues/detail?id=41662
+     */
+    private static final String Issue41662Certificate =
+        "-----BEGIN CERTIFICATE-----\n"+
+        "MIIG6jCCBdKgAwIBAgIESPx/LDANBgkqhkiG9w0BAQUFADCBrjESMBAGCgmSJomT\n"+
+        "8ixkARkWAnJzMRUwEwYKCZImiZPyLGQBGRYFcG9zdGExEjAQBgoJkiaJk/IsZAEZ\n"+
+        "FgJjYTEWMBQGA1UEAxMNQ29uZmlndXJhdGlvbjERMA8GA1UEAxMIU2VydmljZXMx\n"+
+        "HDAaBgNVBAMTE1B1YmxpYyBLZXkgU2VydmljZXMxDDAKBgNVBAMTA0FJQTEWMBQG\n"+
+        "A1UEAxMNUG9zdGEgQ0EgUm9vdDAeFw0wODEwMjAxNDExMzBaFw0yODEwMTQyMjAw\n"+
+        "MDBaMIGrMRIwEAYKCZImiZPyLGQBGRYCcnMxFTATBgoJkiaJk/IsZAEZFgVwb3N0\n"+
+        "YTESMBAGCgmSJomT8ixkARkWAmNhMRYwFAYDVQQDEw1Db25maWd1cmF0aW9uMREw\n"+
+        "DwYDVQQDEwhTZXJ2aWNlczEcMBoGA1UEAxMTUHVibGljIEtleSBTZXJ2aWNlczEM\n"+
+        "MAoGA1UEAxMDQUlBMRMwEQYDVQQDEwpQb3N0YSBDQSAxMIIBIjANBgkqhkiG9w0B\n"+
+        "AQEFAAOCAQ8AMIIBCgKCAQEAl5msW5MdLW/2aDlezrjU3jW58MKrcMPHs2szlGdL\n"+
+        "nsAcSyYFF1JbyA8iuqLp7mhvcTz9m4jK82XBz/1mPq8wJMU9ekGnLhgbKLGKXRBA\n"+
+        "sY9wzCvwpweQV6ui4vr2eOkS1j9Mk7ikatH8tNiIzkNrTj3npDpZv1w4G37iwtpb\n"+
+        "yjg+lkNIDY2nWV9roBsAZM8Lvbyi4vxP41YEQZ3hxaGGG0/RKHbugvGatgckxfin\n"+
+        "4gpFG2mDhS9uafGgqnLHLwpxgBbi3g6+2TsxOKatTxwxx9/4MND1GjhxKTjDNYPl\n"+
+        "5JHUvr9fcvQMxP21/jbO4EsCWG+F38R90kT37hFL3l1qiQIDAQABo4IDDzCCAwsw\n"+
+        "DwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwgcwGA1UdIASBxDCBwTCB\n"+
+        "vgYLKwYBBAH6OAoyAQEwga4wMAYIKwYBBQUHAgEWJGh0dHA6Ly93d3cuY2EucG9z\n"+
+        "dGEucnMvZG9rdW1lbnRhY2lqYTB6BggrBgEFBQcCAjBuGmxPdm8gamUgZWxla3Ry\n"+
+        "b25za2kgc2VydGlmaWthdCBpemRhdmFja29nIChwcm9kdWtjaW9ub2cpIENBIHNl\n"+
+        "cnZlcmEgU2VydGlmaWthY2lvbm9nIHRlbGEgUG9zdGU6ICJQb3N0YSBDQSAxIi4w\n"+
+        "ggG8BgNVHR8EggGzMIIBrzCByaCBxqCBw6SBwDCBvTESMBAGCgmSJomT8ixkARkW\n"+
+        "AnJzMRUwEwYKCZImiZPyLGQBGRYFcG9zdGExEjAQBgoJkiaJk/IsZAEZFgJjYTEW\n"+
+        "MBQGA1UEAxMNQ29uZmlndXJhdGlvbjERMA8GA1UEAxMIU2VydmljZXMxHDAaBgNV\n"+
+        "BAMTE1B1YmxpYyBLZXkgU2VydmljZXMxDDAKBgNVBAMTA0FJQTEWMBQGA1UEAxMN\n"+
+        "UG9zdGEgQ0EgUm9vdDENMAsGA1UEAxMEQ1JMMTCB4KCB3aCB2oaBo2xkYXA6Ly9s\n"+
+        "ZGFwLmNhLnBvc3RhLnJzL2NuPVBvc3RhJTIwQ0ElMjBSb290LGNuPUFJQSxjbj1Q\n"+
+        "dWJsaWMlMjBLZXklMjBTZXJ2aWNlcyxjbj1TZXJ2aWNlcyxjbj1Db25maWd1cmF0\n"+
+        "aW9uLGRjPWNhLGRjPXBvc3RhLGRjPXJzP2NlcnRpZmljYXRlUmV2b2NhdGlvbkxp\n"+
+        "c3QlM0JiaW5hcnmGMmh0dHA6Ly9zZXJ0aWZpa2F0aS5jYS5wb3N0YS5ycy9jcmwv\n"+
+        "UG9zdGFDQVJvb3QuY3JsMB8GA1UdIwQYMBaAFPLLjeI17xBDxNp7yvrriQOhIq+4\n"+
+        "MB0GA1UdDgQWBBQuZ6cm1uhncOeq+pAsMLzXYWUfhjAZBgkqhkiG9n0HQQAEDDAK\n"+
+        "GwRWNy4xAwIAgTANBgkqhkiG9w0BAQUFAAOCAQEAjpmoaebsvfjgwgCYArou/s8k\n"+
+        "Tr50TUdcJYxAYmCFQp531E1F+qUCWM/7bZApqByR3+EUz8goI5O2Cp/6ISxTR1HC\n"+
+        "Dn71ESg7/c8Bs2Obx0LGYPnlRPvw7LH31dYXpj4EMNAamhOfBXgY2htXHCd7daIe\n"+
+        "thvNkqWGDzmcoaGw/2BMNadlYkdXxudDBaiPDFm27yR7fPRibjxwkQVknzFezX/y\n"+
+        "46j+20LoGJ/IpneT209XzytiaqtZBy3yqz2qImVDqvn5doHw63LOUqt8vfDS1sbd\n"+
+        "zi3acAmPK1nERdCMJYJEEGNiGbkbw2cghwLw/4eYGXlj1VLXD3GU42uBr8QftA==\n"+
+        "-----END CERTIFICATE-----\n";
+
+    @LargeTest
+    public void testSslCertificateWithMultipleCN() throws Exception {
+        X509Certificate x509Certificate = generateCertificate(Issue41662Certificate);
+        String dn = x509Certificate.getSubjectDN().getName();
+        assertTrue(dn, dn.contains("Posta CA 1"));
+        assertTrue(dn, dn.contains("Configuration"));
+        SslCertificate sslCertificate = new SslCertificate(x509Certificate);
+        assertEquals(dn, "Posta CA 1", sslCertificate.getIssuedTo().getCName());
+    }
+
+    private static X509Certificate generateCertificate(String pem) throws Exception {
+        CertificateFactory cf = CertificateFactory.getInstance("X.509");
+        return (X509Certificate) cf.generateCertificate(new ByteArrayInputStream(pem.getBytes()));
+    }
+
 }
diff --git a/core/tests/coretests/src/android/text/format/DateFormatTest.java b/core/tests/coretests/src/android/text/format/DateFormatTest.java
new file mode 100644
index 0000000..5f36cfd
--- /dev/null
+++ b/core/tests/coretests/src/android/text/format/DateFormatTest.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.text.format;
+
+import android.test.suitebuilder.annotation.SmallTest;
+
+import junit.framework.TestCase;
+
+public class DateFormatTest extends TestCase {
+    @SmallTest
+    public void testHasDesignator() throws Exception {
+        assertTrue(DateFormat.hasDesignator("hh:mm:ss", DateFormat.MINUTE));
+        assertTrue(DateFormat.hasDesignator("myyyy", DateFormat.MINUTE));
+        assertTrue(DateFormat.hasDesignator("mmm", DateFormat.MINUTE));
+
+        assertFalse(DateFormat.hasDesignator("hh:MM:ss", DateFormat.MINUTE));
+    }
+
+    @SmallTest
+    public void testHasDesignatorEscaped() throws Exception {
+        assertTrue(DateFormat.hasDesignator("hh:mm 'LOL'", DateFormat.MINUTE));
+
+        assertFalse(DateFormat.hasDesignator("hh:mm 'yyyy'", DateFormat.YEAR));
+    }
+}
diff --git a/docs/downloads/brand/af_generic_rgb_wo.ai b/docs/downloads/brand/af_generic_rgb_wo.ai
new file mode 100644
index 0000000..2cec2e97
--- /dev/null
+++ b/docs/downloads/brand/af_generic_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/brand/ar_generic_rgb_wo.ai b/docs/downloads/brand/ar_generic_rgb_wo.ai
new file mode 100644
index 0000000..0eeb4f7
--- /dev/null
+++ b/docs/downloads/brand/ar_generic_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/brand/be_generic_rgb_wo.ai b/docs/downloads/brand/be_generic_rgb_wo.ai
new file mode 100644
index 0000000..3b82926
--- /dev/null
+++ b/docs/downloads/brand/be_generic_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/brand/bg_generic_rgb_wo.ai b/docs/downloads/brand/bg_generic_rgb_wo.ai
new file mode 100644
index 0000000..51e2a5d
--- /dev/null
+++ b/docs/downloads/brand/bg_generic_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/brand/ca_generic_rgb_wo.ai b/docs/downloads/brand/ca_generic_rgb_wo.ai
new file mode 100644
index 0000000..07b7fc5
--- /dev/null
+++ b/docs/downloads/brand/ca_generic_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/brand/cs_generic_rgb_wo.ai b/docs/downloads/brand/cs_generic_rgb_wo.ai
new file mode 100644
index 0000000..a998cb6
--- /dev/null
+++ b/docs/downloads/brand/cs_generic_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/brand/da_generic_rgb_wo.ai b/docs/downloads/brand/da_generic_rgb_wo.ai
new file mode 100644
index 0000000..d1bdc08
--- /dev/null
+++ b/docs/downloads/brand/da_generic_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/brand/de_app_rgb_wo.ai b/docs/downloads/brand/de_app_rgb_wo.ai
new file mode 100644
index 0000000..c0e8da3
--- /dev/null
+++ b/docs/downloads/brand/de_app_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/brand/de_generic_rgb_wo.ai b/docs/downloads/brand/de_generic_rgb_wo.ai
new file mode 100644
index 0000000..e1463ef
--- /dev/null
+++ b/docs/downloads/brand/de_generic_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/brand/el_generic_rgb_wo.ai b/docs/downloads/brand/el_generic_rgb_wo.ai
new file mode 100644
index 0000000..0f7581b
--- /dev/null
+++ b/docs/downloads/brand/el_generic_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/brand/en_app_rgb_wo.ai b/docs/downloads/brand/en_app_rgb_wo.ai
new file mode 100644
index 0000000..db27314
--- /dev/null
+++ b/docs/downloads/brand/en_app_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/brand/en_generic_rgb_wo.ai b/docs/downloads/brand/en_generic_rgb_wo.ai
new file mode 100644
index 0000000..57c1e47
--- /dev/null
+++ b/docs/downloads/brand/en_generic_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/brand/es-419_app_rgb_wo.ai b/docs/downloads/brand/es-419_app_rgb_wo.ai
new file mode 100644
index 0000000..9285921
--- /dev/null
+++ b/docs/downloads/brand/es-419_app_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/brand/es-419_generic_rgb_wo.ai b/docs/downloads/brand/es-419_generic_rgb_wo.ai
new file mode 100644
index 0000000..1629e3e
--- /dev/null
+++ b/docs/downloads/brand/es-419_generic_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/brand/es_app_rgb_wo.ai b/docs/downloads/brand/es_app_rgb_wo.ai
new file mode 100644
index 0000000..78a3e5a4
--- /dev/null
+++ b/docs/downloads/brand/es_app_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/brand/es_generic_rgb_wo.ai b/docs/downloads/brand/es_generic_rgb_wo.ai
new file mode 100644
index 0000000..bc839bc
--- /dev/null
+++ b/docs/downloads/brand/es_generic_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/brand/et_generic_rgb_wo.ai b/docs/downloads/brand/et_generic_rgb_wo.ai
new file mode 100644
index 0000000..693a73e
--- /dev/null
+++ b/docs/downloads/brand/et_generic_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/brand/fa_generic_rgb_wo.ai b/docs/downloads/brand/fa_generic_rgb_wo.ai
new file mode 100644
index 0000000..d6a0a8b
--- /dev/null
+++ b/docs/downloads/brand/fa_generic_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/brand/fi_generic_rgb_wo.ai b/docs/downloads/brand/fi_generic_rgb_wo.ai
new file mode 100644
index 0000000..1b18681
--- /dev/null
+++ b/docs/downloads/brand/fi_generic_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/brand/fil_generic_rgb_wo.ai b/docs/downloads/brand/fil_generic_rgb_wo.ai
new file mode 100644
index 0000000..958568a
--- /dev/null
+++ b/docs/downloads/brand/fil_generic_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/brand/fr_app_rgb_wo.ai b/docs/downloads/brand/fr_app_rgb_wo.ai
new file mode 100644
index 0000000..288c6da
--- /dev/null
+++ b/docs/downloads/brand/fr_app_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/brand/fr_generic_rgb_wo.ai b/docs/downloads/brand/fr_generic_rgb_wo.ai
new file mode 100644
index 0000000..a542afc
--- /dev/null
+++ b/docs/downloads/brand/fr_generic_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/brand/hr_generic_rgb_wo.ai b/docs/downloads/brand/hr_generic_rgb_wo.ai
new file mode 100644
index 0000000..266257e
--- /dev/null
+++ b/docs/downloads/brand/hr_generic_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/brand/hu_generic_rgb_wo.ai b/docs/downloads/brand/hu_generic_rgb_wo.ai
new file mode 100644
index 0000000..dd436b6
--- /dev/null
+++ b/docs/downloads/brand/hu_generic_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/brand/id-in_generic_rgb_wo.ai b/docs/downloads/brand/id-in_generic_rgb_wo.ai
new file mode 100644
index 0000000..62d0be1
--- /dev/null
+++ b/docs/downloads/brand/id-in_generic_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/brand/it_app_rgb_wo.ai b/docs/downloads/brand/it_app_rgb_wo.ai
new file mode 100644
index 0000000..32024e4
--- /dev/null
+++ b/docs/downloads/brand/it_app_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/brand/it_generic_rgb_wo.ai b/docs/downloads/brand/it_generic_rgb_wo.ai
new file mode 100644
index 0000000..a483b36
--- /dev/null
+++ b/docs/downloads/brand/it_generic_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/brand/iw-he_generic_rgb_wo.ai b/docs/downloads/brand/iw-he_generic_rgb_wo.ai
new file mode 100644
index 0000000..52c9641
--- /dev/null
+++ b/docs/downloads/brand/iw-he_generic_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/brand/ja_app_rgb_wo.ai b/docs/downloads/brand/ja_app_rgb_wo.ai
new file mode 100644
index 0000000..dacf38d
--- /dev/null
+++ b/docs/downloads/brand/ja_app_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/brand/ja_generic_rgb_wo.ai b/docs/downloads/brand/ja_generic_rgb_wo.ai
new file mode 100644
index 0000000..fdfb9545
--- /dev/null
+++ b/docs/downloads/brand/ja_generic_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/brand/ko_app_rgb_wo.ai b/docs/downloads/brand/ko_app_rgb_wo.ai
new file mode 100644
index 0000000..4463149
--- /dev/null
+++ b/docs/downloads/brand/ko_app_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/brand/ko_generic_rgb_wo.ai b/docs/downloads/brand/ko_generic_rgb_wo.ai
new file mode 100644
index 0000000..0d2d8bd
--- /dev/null
+++ b/docs/downloads/brand/ko_generic_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/brand/lt_generic_rgb_wo.ai b/docs/downloads/brand/lt_generic_rgb_wo.ai
new file mode 100644
index 0000000..fc679c7
--- /dev/null
+++ b/docs/downloads/brand/lt_generic_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/brand/lv_generic_rgb_wo.ai b/docs/downloads/brand/lv_generic_rgb_wo.ai
new file mode 100644
index 0000000..b07b28b
--- /dev/null
+++ b/docs/downloads/brand/lv_generic_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/brand/ms_generic_rgb_wo.ai b/docs/downloads/brand/ms_generic_rgb_wo.ai
new file mode 100644
index 0000000..c2f052e
--- /dev/null
+++ b/docs/downloads/brand/ms_generic_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/brand/nl_app_rgb_wo.ai b/docs/downloads/brand/nl_app_rgb_wo.ai
new file mode 100644
index 0000000..60d1ad8
--- /dev/null
+++ b/docs/downloads/brand/nl_app_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/brand/nl_generic_rgb_wo.ai b/docs/downloads/brand/nl_generic_rgb_wo.ai
new file mode 100644
index 0000000..03eed23
--- /dev/null
+++ b/docs/downloads/brand/nl_generic_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/brand/no_generic_rgb_wo.ai b/docs/downloads/brand/no_generic_rgb_wo.ai
new file mode 100644
index 0000000..703e99a
--- /dev/null
+++ b/docs/downloads/brand/no_generic_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/brand/pl_generic_rgb_wo.ai b/docs/downloads/brand/pl_generic_rgb_wo.ai
new file mode 100644
index 0000000..fac15d2
--- /dev/null
+++ b/docs/downloads/brand/pl_generic_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/brand/pt-br_app_rgb_wo.ai b/docs/downloads/brand/pt-br_app_rgb_wo.ai
new file mode 100644
index 0000000..686455d
--- /dev/null
+++ b/docs/downloads/brand/pt-br_app_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/brand/pt-br_generic_rgb_wo.ai b/docs/downloads/brand/pt-br_generic_rgb_wo.ai
new file mode 100644
index 0000000..00379cc
--- /dev/null
+++ b/docs/downloads/brand/pt-br_generic_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/brand/pt-pt_app_rgb_wo.ai b/docs/downloads/brand/pt-pt_app_rgb_wo.ai
new file mode 100644
index 0000000..bd19a28
--- /dev/null
+++ b/docs/downloads/brand/pt-pt_app_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/brand/pt-pt_generic_rgb_wo.ai b/docs/downloads/brand/pt-pt_generic_rgb_wo.ai
new file mode 100644
index 0000000..29476cc
--- /dev/null
+++ b/docs/downloads/brand/pt-pt_generic_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/brand/ro_generic_rgb_wo.ai b/docs/downloads/brand/ro_generic_rgb_wo.ai
new file mode 100644
index 0000000..6152a94
--- /dev/null
+++ b/docs/downloads/brand/ro_generic_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/brand/ru_generic_rgb_wo.ai b/docs/downloads/brand/ru_generic_rgb_wo.ai
new file mode 100644
index 0000000..1e73a61
--- /dev/null
+++ b/docs/downloads/brand/ru_generic_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/brand/sk_generic_rgb_wo.ai b/docs/downloads/brand/sk_generic_rgb_wo.ai
new file mode 100644
index 0000000..50735bd
--- /dev/null
+++ b/docs/downloads/brand/sk_generic_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/brand/sl_generic_rgb_wo.ai b/docs/downloads/brand/sl_generic_rgb_wo.ai
new file mode 100644
index 0000000..96f4708
--- /dev/null
+++ b/docs/downloads/brand/sl_generic_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/brand/sr_generic_rgb_wo.ai b/docs/downloads/brand/sr_generic_rgb_wo.ai
new file mode 100644
index 0000000..53dacd9
--- /dev/null
+++ b/docs/downloads/brand/sr_generic_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/brand/sv_generic_rgb_wo.ai b/docs/downloads/brand/sv_generic_rgb_wo.ai
new file mode 100644
index 0000000..f148dd3
--- /dev/null
+++ b/docs/downloads/brand/sv_generic_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/brand/sw_generic_rgb_wo.ai b/docs/downloads/brand/sw_generic_rgb_wo.ai
new file mode 100644
index 0000000..00d660c
--- /dev/null
+++ b/docs/downloads/brand/sw_generic_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/brand/th_generic_rgb_wo.ai b/docs/downloads/brand/th_generic_rgb_wo.ai
new file mode 100644
index 0000000..b24eff6
--- /dev/null
+++ b/docs/downloads/brand/th_generic_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/brand/tr_generic_rgb_wo.ai b/docs/downloads/brand/tr_generic_rgb_wo.ai
new file mode 100644
index 0000000..39db427
--- /dev/null
+++ b/docs/downloads/brand/tr_generic_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/brand/uk_generic_rgb_wo.ai b/docs/downloads/brand/uk_generic_rgb_wo.ai
new file mode 100644
index 0000000..81f510f
--- /dev/null
+++ b/docs/downloads/brand/uk_generic_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/brand/vi_generic_rgb_wo.ai b/docs/downloads/brand/vi_generic_rgb_wo.ai
new file mode 100644
index 0000000..5a0c796
--- /dev/null
+++ b/docs/downloads/brand/vi_generic_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/brand/zh-cn_generic_rgb_wo.ai b/docs/downloads/brand/zh-cn_generic_rgb_wo.ai
new file mode 100644
index 0000000..078b024
--- /dev/null
+++ b/docs/downloads/brand/zh-cn_generic_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/brand/zh-hk_generic_rgb_wo.ai b/docs/downloads/brand/zh-hk_generic_rgb_wo.ai
new file mode 100644
index 0000000..6d3bf0e
--- /dev/null
+++ b/docs/downloads/brand/zh-hk_generic_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/brand/zh-tw_generic_rgb_wo.ai b/docs/downloads/brand/zh-tw_generic_rgb_wo.ai
new file mode 100644
index 0000000..55d34ba
--- /dev/null
+++ b/docs/downloads/brand/zh-tw_generic_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/brand/zu_generic_rgb_wo.ai b/docs/downloads/brand/zu_generic_rgb_wo.ai
new file mode 100644
index 0000000..cfc14d1
--- /dev/null
+++ b/docs/downloads/brand/zu_generic_rgb_wo.ai
Binary files differ
diff --git a/docs/downloads/training/BitmapFun.zip b/docs/downloads/training/BitmapFun.zip
index e48bfd3..c4ea7aa 100644
--- a/docs/downloads/training/BitmapFun.zip
+++ b/docs/downloads/training/BitmapFun.zip
Binary files differ
diff --git a/docs/downloads/training/NetworkUsage.zip b/docs/downloads/training/NetworkUsage.zip
index 8c7fbef..6dbeb33 100644
--- a/docs/downloads/training/NetworkUsage.zip
+++ b/docs/downloads/training/NetworkUsage.zip
Binary files differ
diff --git a/docs/html/shareables/training/nsdchat.zip b/docs/downloads/training/NsdChat.zip
similarity index 100%
rename from docs/html/shareables/training/nsdchat.zip
rename to docs/downloads/training/NsdChat.zip
Binary files differ
diff --git a/docs/html/design/patterns/notifications.jd b/docs/html/design/patterns/notifications.jd
index 1a15a64..0665774 100644
--- a/docs/html/design/patterns/notifications.jd
+++ b/docs/html/design/patterns/notifications.jd
@@ -153,8 +153,13 @@
 <p>To create an app that feels streamlined, pleasant, and respectful, it is important to design your notifications carefully. Notifications embody your app's voice, and contribute to your app's personality. Unwanted or unimportant notifications can annoy the user, so use them judiciously.</p>
 
 <h4>When to display a notification</h4>
-<p>To create an application that people love, it's important to recognize that the user's attention and focus is a resource that must be protected. While Android's notification system has been designed to minimize the impact of notifications on the users attention, it is nonetheless still important to be aware of the fact that notifications are potentially interrupting the users task flow. As you plan your notifications, ask yourself if they are important enough to warrant an interruption. If you are unsure, allow the user to opt into a notification using your apps notification settings or adjust the notifications priority flag.</p>
-<p>Time sensitive events are great opportunities for valuable notifications with high priority, especially if these synchronous events involve other people. For instance, an incoming chat is a real time and synchronous form of communication: there is another user actively waiting on you to respond. Calendar events are another good example of when to use a notification and grab the user's attention, because the event is imminent, and calendar events often involve other people.</p>
+<p>To create an application that people love, it's important to recognize that the user's attention and
+focus is a resource that must be protected. While Android's notification system has been designed
+to minimize the impact of notifications on the users attention, it is nonetheless still important
+to be aware of the fact that notifications are potentially interrupting the users task flow. As you
+plan your notifications, ask yourself if they are important enough to warrant an interruption. If
+you are unsure, allow the user to opt into a notification using your apps notification settings or
+adjust the notifications priority flag.</p>
 <p>While well behaved apps generally only speak when spoken to, there are some limited cases where an
 app actually should interrupt the user with an unprompted notification.</p>
 <p>Notifications should be used primarily for <strong>time sensitive events</strong>, and especially if these
diff --git a/docs/html/distribute/googleplay/promote/badge-files.jd b/docs/html/distribute/googleplay/promote/badge-files.jd
new file mode 100644
index 0000000..92001ed
--- /dev/null
+++ b/docs/html/distribute/googleplay/promote/badge-files.jd
@@ -0,0 +1,289 @@
+page.title=Google Play Badge Files
+@jd:body
+
+
+
+
+<style>
+table tr td {border:0}
+</style>
+
+<p>The following links provide the Adobe&reg; Illustrator&reg; (.ai) file for the
+two Google Play badges.</p>
+
+<hr>
+<img src="{@docRoot}images/brand/en_generic_rgb_wo_60.png" alt="Get It On Google Play">
+
+<div style="clear:left">&nbsp;</div>
+
+<div class="col-4" style="margin-left:0">
+
+       <a href="{@docRoot}downloads/brand/en_generic_rgb_wo.ai">English (English)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/af_generic_rgb_wo.ai">Afrikaans (Afrikaans)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/ar_generic_rgb_wo.ai">العربية (Arabic)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/be_generic_rgb_wo.ai">Беларуская (Belarusian)</a><br/>
+       
+       <a href="{@docRoot}downloads/brand/bg_generic_rgb_wo.ai">български (Bulgarian)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/ca_generic_rgb_wo.ai">Català (Catalan)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/zh-cn_generic_rgb_wo.ai">中文 (中国) (Chinese)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/zh-hk_generic_rgb_wo.ai">中文(香港) (Chinese Hong Kong)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/zh-tw_generic_rgb_wo.ai">中文 (台灣) (Chinese Taiwan)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/hr_generic_rgb_wo.ai">Hrvatski (Croatian)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/cs_generic_rgb_wo.ai">Česky (Czech)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/da_generic_rgb_wo.ai">Dansk (Danish)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/nl_generic_rgb_wo.ai">Nederlands (Dutch)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/et_generic_rgb_wo.ai">Eesti keel (Estonian)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/fa_generic_rgb_wo.ai">فارسی (Farsi Persian)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/fil_generic_rgb_wo.ai">Tagalog (Filipino)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/fi_generic_rgb_wo.ai">Suomi (Finnish)</a><br/>
+
+</div>
+
+<div class="col-4">
+
+       <a href="{@docRoot}downloads/brand/fr_generic_rgb_wo.ai">Français (French)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/de_generic_rgb_wo.ai">Deutsch (German)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/el_generic_rgb_wo.ai">Ελληνικά (Greek)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/iw-he_generic_rgb_wo.ai">עברית (Hebrew)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/hu_generic_rgb_wo.ai">Magyar (Hungarian)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/id-in_generic_rgb_wo.ai">Bahasa Indonesia (Indonesian)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/it_generic_rgb_wo.ai">Italiano (Italian)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/ja_generic_rgb_wo.ai">日本語 (Japanese)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/ko_generic_rgb_wo.ai">한국어 (Korean)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/lv_generic_rgb_wo.ai">Latviski (Latvian)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/lt_generic_rgb_wo.ai">Lietuviškai (Lithuanian)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/ms_generic_rgb_wo.ai">Bahasa Melayu (Malay)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/no_generic_rgb_wo.ai">Norsk (Norwegian)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/pl_generic_rgb_wo.ai">Polski (Polish)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/pt-pt_generic_rgb_wo.ai">Português (Portuguese)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/pt-br_generic_rgb_wo.ai">Português Brasil (Portuguese Brazil)</a><br/>
+
+</div>
+
+<div class="col-4" style="margin-right:0">
+
+       <a href="{@docRoot}downloads/brand/ro_generic_rgb_wo.ai">Românã (Romanian)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/ru_generic_rgb_wo.ai">Pусский (Russian)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/sr_generic_rgb_wo.ai">Српски / srpski (Serbian)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/sk_generic_rgb_wo.ai">Slovenčina (Slovak)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/sl_generic_rgb_wo.ai">Slovenščina (Slovenian)</a><br/>
+       
+       <a href="{@docRoot}downloads/brand/es_generic_rgb_wo.ai">Español (Spanish)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/es-419_generic_rgb_wo.ai">Español Latinoamérica (Spanish Latin America)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/sv_generic_rgb_wo.ai">Svenska (Swedish)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/sw_generic_rgb_wo.ai">Kiswahili (Swahili)</a><br/>
+       
+       <a href="{@docRoot}downloads/brand/th_generic_rgb_wo.ai">ภาษาไทย (Thai)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/tr_generic_rgb_wo.ai">Türkçe (Turkish)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/uk_generic_rgb_wo.ai">Українська (Ukrainian)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/vi_generic_rgb_wo.ai">Tiếng Việt (Vietnamese)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/zu_generic_rgb_wo.ai">isiZulu (Zulu)</a><br/>
+
+</div>
+<div style="clear:left">&nbsp;</div>
+
+
+
+
+
+
+<hr>
+<img src="{@docRoot}images/brand/en_app_rgb_wo_60.png" alt="Android App On Google Play">
+
+<div style="clear:left">&nbsp;</div>
+
+<div class="col-8" style="margin-left:0">
+
+       <a href="{@docRoot}downloads/brand/en_app_rgb_wo.ai">English (English)</a><br/>
+       
+<!--
+       <a href="{@docRoot}downloads/brand/af_app_rgb_wo.ai">Afrikaans (Afrikaans)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/ar_app_rgb_wo.ai">العربية (Arabic)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/be_app_rgb_wo.ai">Беларуская (Belarusian)</a><br/>
+       
+       <a href="{@docRoot}downloads/brand/bg_app_rgb_wo.ai">български (Bulgarian)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/ca_app_rgb_wo.ai">Català (Catalan)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/zh-cn_app_rgb_wo.ai">中文 (中国) (Chinese)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/zh-hk_app_rgb_wo.ai">中文(香港) (Chinese Hong Kong)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/zh-tw_app_rgb_wo.ai">中文 (台灣) (Chinese Taiwan)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/hr_app_rgb_wo.ai">Hrvatski (Croatian)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/cs_app_rgb_wo.ai">Česky (Czech)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/da_app_rgb_wo.ai">Dansk (Danish)</a><br/>
+-->
+
+       <a href="{@docRoot}downloads/brand/nl_app_rgb_wo.ai">Nederlands (Dutch)</a><br/>
+
+<!--
+       <a href="{@docRoot}downloads/brand/et_app_rgb_wo.ai">Eesti keel (Estonian)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/fa_app_rgb_wo.ai">فارسی (Farsi Persian)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/fil_app_rgb_wo.ai">Tagalog (Filipino)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/fi_app_rgb_wo.ai">Suomi (Finnish)</a><br/>
+
+</div>
+
+<div class="col-4">
+-->
+
+       <a href="{@docRoot}downloads/brand/fr_app_rgb_wo.ai">Français (French)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/de_app_rgb_wo.ai">Deutsch (German)</a><br/>
+
+<!--
+       <a href="{@docRoot}downloads/brand/el_app_rgb_wo.ai">Ελληνικά (Greek)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/iw-he_app_rgb_wo.ai">עברית (Hebrew)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/hu_app_rgb_wo.ai">Magyar (Hungarian)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/id-in_app_rgb_wo.ai">Bahasa Indonesia (Indonesian)</a><br/>
+-->
+
+       <a href="{@docRoot}downloads/brand/it_app_rgb_wo.ai">Italiano (Italian)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/ja_app_rgb_wo.ai">日本語 (Japanese)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/ko_app_rgb_wo.ai">한국어 (Korean)</a><br/>
+
+<!--
+       <a href="{@docRoot}downloads/brand/lv_app_rgb_wo.ai">Latviski (Latvian)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/lt_app_rgb_wo.ai">Lietuviškai (Lithuanian)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/ms_app_rgb_wo.ai">Bahasa Melayu (Malay)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/no_app_rgb_wo.ai">Norsk (Norwegian)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/pl_app_rgb_wo.ai">Polski (Polish)</a><br/>
+-->
+
+       <a href="{@docRoot}downloads/brand/pt-pt_app_rgb_wo.ai">Português (Portuguese)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/pt-br_app_rgb_wo.ai">Português Brasil (Portuguese Brazil)</a><br/>
+
+
+<!--
+</div>
+
+<div class="col-4" style="margin-right:0">
+       <a href="{@docRoot}downloads/brand/ro_app_rgb_wo.ai">Românã (Romanian)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/ru_app_rgb_wo.ai">Pусский (Russian)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/sr_app_rgb_wo.ai">Српски / srpski (Serbian)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/sk_app_rgb_wo.ai">Slovenčina (Slovak)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/sl_app_rgb_wo.ai">Slovenščina (Slovenian)</a><br/>
+-->
+
+       <a href="{@docRoot}downloads/brand/es_app_rgb_wo.ai">Español (Spanish)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/es-419_app_rgb_wo.ai">Español Latinoamérica (Spanish Latin America)</a><br/>
+
+<!--
+       <a href="{@docRoot}downloads/brand/sv_app_rgb_wo.ai">Svenska (Swedish)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/sw_app_rgb_wo.ai">Kiswahili (Swahili)</a><br/>
+       
+       <a href="{@docRoot}downloads/brand/th_app_rgb_wo.ai">ภาษาไทย (Thai)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/tr_app_rgb_wo.ai">Türkçe (Turkish)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/uk_app_rgb_wo.ai">Українська (Ukrainian)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/vi_app_rgb_wo.ai">Tiếng Việt (Vietnamese)</a><br/>
+
+       <a href="{@docRoot}downloads/brand/zu_app_rgb_wo.ai">isiZulu (Zulu)</a><br/>
+-->
+
+</div>
+<div style="clear:left">&nbsp;</div>
+
+
+
+
+
+  
+<h2>Guidelines</h2>
+
+  <ul>
+    <li>Do not modify the color, proportions, spacing or any other aspect of the badge image.
+    </li>
+    <li>When used alongside logos for other application marketplaces, the Google Play logo
+    should be of equal or greater size.</li>
+    <li>When used online, the badge should link to either:
+      <ul>
+        <li>A list of products published by you, for example:<br />
+        <span style="margin-left:1em;">http://play.google.com/store/search?q=<em>publisherName</em></span>
+        </li>
+        <li>A specific app product details page within Google Play, for example:<br />
+        <span style="margin-left:1em;">http://play.google.com/store/apps/details?id=<em>packageName</em></span>
+        </li>
+      </ul>
+    </li>
+  </ul>
+  
+<p>For more information, see the
+<a href="{@docRoot}distribute/googleplay/promote/brand.html#brand-google_play">Brand
+Guidelines</a>.
+
+
+<p>To quickly create a badge that links to your apps on Google Play,
+use the <a
+href="{@docRoot}distribute/googleplay/promote/badges.html">Googe Play badge generator</a>.</p>
+    
+    
+    
\ No newline at end of file
diff --git a/docs/html/distribute/googleplay/promote/badges.jd b/docs/html/distribute/googleplay/promote/badges.jd
index 90e8c0d..0027f59 100644
--- a/docs/html/distribute/googleplay/promote/badges.jd
+++ b/docs/html/distribute/googleplay/promote/badges.jd
@@ -13,7 +13,7 @@
 wraps your screenshots in real device artwork.</p>
 
 <p>For guidelines when using the Google Play badge and other brand assets,
-see the <a href="{@docRoot}distribute/googleplay/promote/brand.html">Brand
+see the <a href="{@docRoot}distribute/googleplay/promote/brand.html#brand-google_play">Brand
 Guidelines</a>.</p>
 
 <style type="text/css">
@@ -56,9 +56,12 @@
 
 <script type="text/javascript">
 
+// locales for which we have the 'app' badge
+var APP_LANGS = ['it','pt-br','pt-pt','nl','ko','ja','fr','es','es-419','en','de'];
+
 // variables for creating 'try it out' demo button
-var imagePath = "http://developer.android.com/images/brand/"
-var linkStart = "<a href=\"http://play.google.com/store/";
+var imagePath = "https://developer.android.com/images/brand/"
+var linkStart = "<a href=\"https://play.google.com/store/";
 var imageStart = "\">\n"
         + "  <img alt=\"";
   // leaves opening for the alt text value
@@ -67,7 +70,7 @@
 var imageEnd = ".png\" />\n</a>";
 
 // variables for creating code snippet
-var linkStartCode = "&lt;a href=\"http://play.google.com/store/";
+var linkStartCode = "&lt;a href=\"https://play.google.com/store/";
 var imageStartCode = "\"&gt;\n"
         + "  &lt;img alt=\"";
   // leaves opening for the alt text value
@@ -77,8 +80,9 @@
 
 /** Generate the HTML snippet and demo based on form values */
 function buildButton(form) {
-  var selectedValue = $('form input[type=radio]:checked').val();
-  var altText = selectedValue.indexOf("get_it") != -1 ? "Get it on Google Play" : "Android app on Google Play";
+  var lang = $('#locale option:selected').val();
+  var selectedValue = lang + $('form input[type=radio]:checked').val();
+  var altText = selectedValue.indexOf("generic") != -1 ? "Get it on Google Play" : "Android app on Google Play";
 
   if (form["package"].value != "com.example.android") {
     $("#preview").show();
@@ -144,6 +148,33 @@
   return false;
 }
 
+/** Switch the badge urls for selected language */
+function changeBadgeLang() {
+  var lang = $('#locale option:selected').val();
+  
+  // check if we have the 'app' badge for this lang and show notice if not
+  $("div.button-row.error").remove();  // remove any existing instance of error message
+  if ($.inArray(lang,APP_LANGS) == -1) {
+    $("div.button-row.app").hide();
+    $("div.button-row.app").after('<div class="button-row error"><p class="note" style="margin:1em 0 -1em">'
+        + 'Sorry, we currently don\'t have the '
+        + '<em>Android app on Google Play</em> badge translated for '
+        + $("select#locale option[value="+lang+"]").attr("title")
+        + '.<br>Please check back later or instead use the <em>Get it on Google Play</em> badge below.'
+        + '</p></div>');
+  } else {
+    $("div.button-row.app").show(); // show the 'app' badge row
+  }
+  
+  $('.button-row img').each(function() {
+    var id = $(this).parent().attr('for');
+    var imgName = lang + $('input#'+id).attr('value') + '.png';
+    var lastSlash = $(this).attr('src').lastIndexOf('/');
+    var imgPath = $(this).attr('src').substring(0, lastSlash+1);
+    $(this).attr('src', imgPath + imgName);
+  });
+}
+
 /** When the doc is ready, find the inputs and color the input grey if the value is the example
     text. This is necessary to handle back-navigation, which can auto-fill the form with previous
     values (and text should not be grey) */
@@ -163,7 +194,106 @@
 </script>
 
 <form class="button-form">
-  <label class="block" for="package">Package name:</label>
+  <label class="block" for="locale">Language:</label>
+  <select id="locale" style="display:block;float:left;margin:0"
+          onchange="changeBadgeLang()">
+    <option title="Afrikaans"
+            value="af">Afrikaans</option>
+    <option title="Arabic"
+            value="ar">العربية</option>
+    <option title="Belarusian"
+            value="be">Беларуская</option>
+    <option title="Bulgarian"
+            value="bg">Български</option>
+    <option title="Catalan"
+            value="ca">Català</option>
+    <option title="Chinese (China)"
+            value="zh-cn">中文 (中国)</option>
+    <option title="Chinese (Hong Kong)"
+            value="zh-hk">中文(香港)</option>
+    <option title="Chinese (Taiwan)"
+            value="zh-tw">中文 (台灣)</option>
+    <option title="Croatian"
+            value="hr">Hrvatski</option>
+    <option title="Czech"
+            value="cs">Česky</option>
+    <option title="Danish"
+            value="da">Dansk</option>
+    <option title="Dutch"
+            value="nl">Nederlands</option>
+    <option title="Estonian"
+            value="et">Eesti</option>
+    <option title="Farsi - Persian"
+            value="fa">فارسی</option>
+    <option title="Filipino"
+            value="fil">Tagalog</option>
+    <option title="Finnish"
+            value="fi">Suomi</option>
+    <option title="French"
+            value="fr">Français</option>
+    <option title="German"
+            value="de">Deutsch</option>
+    <option title="Greek"
+            value="el">Ελληνικά</option>
+    <option title="English"
+            value="en" selected="true">English</option>
+    <option title="Hebrew"
+            value="iw-he">עברית</option>
+    <option title="Hungarian"
+            value="hu">Magyar</option>
+    <option title="Indonesian"
+            value="id-in">Bahasa Indonesia</option>
+    <option title="Italian"
+            value="it">Italiano</option>
+    <option title="Japanese"
+            value="ja">日本語</option>
+    <option title="Korean"
+            value="ko">한국어</option>
+    <option title="Latvian"
+            value="lv">Latviešu</option>
+    <option title="Lithuanian"
+            value="lt">Lietuviškai</option>
+    <option title="Malay"
+            value="ms">Bahasa Melayu</option>
+    <option title="Norwegian"
+            value="no">Norsk (bokmål)‎</option>
+    <option title="Polish"
+            value="pl">Polski</option>
+    <option title="Portuguese (Brazil)"
+            value="pt-br">Português (Brasil)</option>
+    <option title="Portuguese (Portugal)"
+            value="pt-pt">Português (Portugal)</option>
+    <option title="Romanian"
+            value="ro">Română</option>
+    <option title="Russian"
+            value="ru">Русский</option>
+    <option title="Serbian"
+            value="sr">Српски / srpski</option>
+    <option title="Slovak"
+            value="sk">Slovenčina</option>
+    <option title="Slovenian"
+            value="sl">Slovenščina</option>
+    <option title="Spanish (Spain)"
+            value="es">Español (España)</option>
+    <option title="Spanish (Latin America)"
+            value="es-419">Español (Latinoamérica)</option>
+    <option title="Swedish"
+            value="sv">Svenska</option>
+    <option title="Swahili"
+            value="sw">Kiswahili</option>
+    <option title="Thai"
+            value="th">ไทย</option>
+    <option title="Turkish"
+            value="tr">Türkçe</option>
+    <option title="Ukrainian"
+            value="uk">Українська</option>
+    <option title="Vietnamese"
+            value="vi">Tiếng Việt</option>
+    <option title="Zulu"
+            value="zu">isiZulu</option>
+  </select>
+  <p style="clear:both;margin:0">&nbsp;</p>
+  <label class="block" for="package" style="clear:left">Package name:</label>
   <input class="text" type="text" id="package" name="package"
          value="com.example.android"
          default="com.example.android"
@@ -185,27 +315,27 @@
          <br/><br/>
 
 
-<div class="button-row">
-  <input type="radio" name="buttonStyle" value="en_app_rgb_wo_45" id="ws" checked="checked" />
+<div class="button-row app">
+  <input type="radio" name="buttonStyle" value="_app_rgb_wo_45" id="ws" />
     <label for="ws"><img src="{@docRoot}images/brand/en_app_rgb_wo_45.png"
 alt="Android app on Google Play (small)" /></label>
     &nbsp;&nbsp;&nbsp;&nbsp;
-  <input type="radio" name="buttonStyle" value="en_app_rgb_wo_60" id="wm" />
+  <input type="radio" name="buttonStyle" value="_app_rgb_wo_60" id="wm" />
     <label for="wm"><img src="{@docRoot}images/brand/en_app_rgb_wo_60.png"
 alt="Android app on Google Play (large)" /></label>
 </div>
 
 <div class="button-row">
-  <input type="radio" name="buttonStyle" value="en_generic_rgb_wo_45" id="ns" />
+  <input type="radio" name="buttonStyle" value="_generic_rgb_wo_45" id="ns" checked="checked" />
     <label for="ns"><img src="{@docRoot}images/brand/en_generic_rgb_wo_45.png"
 alt="Get it on Google Play (small)" /></label>
     &nbsp;&nbsp;&nbsp;&nbsp;
-  <input type="radio" name="buttonStyle" value="en_generic_rgb_wo_60" id="nm" />
+  <input type="radio" name="buttonStyle" value="_generic_rgb_wo_60" id="nm" />
     <label for="nm"><img src="{@docRoot}images/brand/en_generic_rgb_wo_60.png"
 alt="Get it on Google Play (large)" /></label>
 </div>
 
-  <input onclick="return buildButton(this.parentNode);"
+  <input class="button" onclick="return buildButton(this.parentNode);"
     type="button" value="Build my badge" style="padding:10px" />
   <br/>
 </form>
diff --git a/docs/html/distribute/googleplay/promote/brand.jd b/docs/html/distribute/googleplay/promote/brand.jd
index 63b1f03..cea6d2c 100644
--- a/docs/html/distribute/googleplay/promote/brand.jd
+++ b/docs/html/distribute/googleplay/promote/brand.jd
@@ -118,8 +118,8 @@
 <p>You may use the Google Play Store icon, but you may not modify it.</p>
 
 <p>As mentioned above, when referring to the Google Play Store app in copy, use the full name:
-"Google Play Store." However, when labelling the Google Play Store icon directly, it's OK to use
-"Play Store" without "Google" (which is how the icon is labelled on a device).</p>
+"Google Play Store." However, when labeling the Google Play Store icon directly, it's OK to use
+"Play Store" alone to accurately reflect the icon label as it appears on a device.</p>
 
         
 <h4>Google Play badge</h4>
@@ -128,16 +128,14 @@
     <img src="{@docRoot}images/brand/en_app_rgb_wo_60.png" alt="">
     <p style="text-align:center">
        <a href="{@docRoot}images/brand/en_app_rgb_wo_45.png">129x45</a> |
-       <a href="{@docRoot}images/brand/en_app_rgb_wo_60.png">172x60</a><br>
-       <a href="{@docRoot}downloads/brand/en_app_rgb_wo.ai">Illustrator (.ai)</a></p>
+       <a href="{@docRoot}images/brand/en_app_rgb_wo_60.png">172x60</a></p>
   </div>
       
   <div style="float:right;clear:right;width:172px;margin-left:30px">
     <img src="{@docRoot}images/brand/en_generic_rgb_wo_60.png" alt="">
     <p style="text-align:center">
        <a href="{@docRoot}images/brand/en_generic_rgb_wo_45.png">129x45</a> |
-       <a href="{@docRoot}images/brand/en_generic_rgb_wo_60.png">172x60</a><br>
-       <a href="{@docRoot}downloads/brand/en_generic_rgb_wo.ai">Illustrator (.ai)</a></p>
+       <a href="{@docRoot}images/brand/en_generic_rgb_wo_60.png">172x60</a></p>
   </div>
          
   <p>The "Get it on Google Play" and "Android App on Google Play" logos are badges that you
@@ -160,14 +158,19 @@
       </ul>
     </li>
   </ul>
-
-  <p>For your convenience, you can use the 
-    <a href="{@docRoot}distribute/googleplay/promote/badges.html">Googe Play badge generator</a>
-    to create badges that link to your apps on Google Play.</p>
+  
+  <p>To quickly create a badge that links to your apps on Google Play,
+  use the <a
+  href="{@docRoot}distribute/googleplay/promote/badges.html">Googe Play badge generator</a>
+  (provides the badge in over 40 languages).</p>
+  
+  <p>To create your own size, download an Adobe&reg; Illustrator&reg; (.ai) file for the
+  <a href="{@docRoot}distribute/googleplay/promote/badge-files.html">Google Play
+  badge in over 40 languages</a>.</p>
     
   <p>For details on all the ways that you can link to your product details page in Google Play, 
     see <a href="{@docRoot}distribute/googleplay/promote/linking.html">Linking to your products</a></p>
 
 
-<p>If you are not sure you meet these criteria, <a href=
+<p>If you are not sure you meet these brand guidelines, <a href=
             "http://services.google.com/permissions/application">please contact us</a>. </p>
diff --git a/docs/html/google/play/billing/billing_integrate.jd b/docs/html/google/play/billing/billing_integrate.jd
index 554866d..3f6df927 100644
--- a/docs/html/google/play/billing/billing_integrate.jd
+++ b/docs/html/google/play/billing/billing_integrate.jd
@@ -111,24 +111,27 @@
 <pre>
 &#64;Override
 public void onCreate(Bundle savedInstanceState) {    
-   super.onCreate(savedInstanceState);
-   setContentView(R.layout.activity_main);        
-   bindService(new 
-      Intent("com.android.vending.billing.InAppBillingService.BIND"),
-          mServiceConn, Context.BIND_AUTO_CREATE);
+    super.onCreate(savedInstanceState);
+    setContentView(R.layout.activity_main);        
+    bindService(new 
+        Intent("com.android.vending.billing.InAppBillingService.BIND"),
+                mServiceConn, Context.BIND_AUTO_CREATE);
 </pre>
 <p>You can now use the mService reference to communicate with the Google Play service.</p>
 <p class="note"><strong>Important:</strong> Remember to unbind from the In-app Billing service when you are done with your {@link android.app.Activity}. If you don’t unbind, the open service connection could cause your device’s performance to degrade. This example shows how to perform the unbind operation on a service connection to In-app Billing called {@code mServiceConn} by overriding the activity’s {@link android.app.Activity#onDestroy onDestroy} method.</p>
 <pre>
 &#64;Override
 public void onDestroy() {
-   if (mServiceConn != null) {
-      unbindService(mServiceConn);
-   }	
+    super.onDestroy();
+    if (mServiceConn != null) {
+        unbindService(mServiceConn);
+    }	
 }
 </pre>
 
-<p>For a complete implementation of a service connection that binds to the {@code IInAppBillingService}, see the <a href="{@docRoot}/training/in-app-billing/preparing-iab-app.html#Connect">Selling In-app Products</a> training class.</p>
+<p>For a complete implementation of a service connection that binds to the {@code IInAppBillingService},
+see the <a href="{@docRoot}training/in-app-billing/preparing-iab-app.html">Selling In-app
+Products</a> training class and associated sample.</p>
 
 <h2 id="billing-requests">Making In-app Billing Requests</h2>
 <p>Once your application is connected to Google Play, you can initiate purchase requests for in-app products. Google Play provides a checkout interface for users to enter their payment method, so your application does not need to handle payment transactions directly. When an item is purchased, Google Play recognizes that the user has ownership of that item and prevents the user from purchasing another item with the same product ID until it is consumed. You can control how the item is consumed in your application, and notify Google Play to make the item available for purchase again. You can also query Google Play to quickly retrieve the list of purchases that were made by the user. This is useful, for example, when you want to restore the user's purchases when your user launches your app.
diff --git a/docs/html/google/play/licensing/adding-licensing.jd b/docs/html/google/play/licensing/adding-licensing.jd
index 15d1e92..8ecbe9e 100644
--- a/docs/html/google/play/licensing/adding-licensing.jd
+++ b/docs/html/google/play/licensing/adding-licensing.jd
@@ -93,7 +93,7 @@
 element as a child of <code>&lt;manifest&gt;</code>, as follows: </p>
 
 <p style="margin-left:2em;"><code>&lt;uses-permission
-android:name="com.android.vending.CHECK_LICENSE"&gt;</code></p>
+android:name="com.android.vending.CHECK_LICENSE" /&gt;</code></p>
 
 <p>For example, here's how the LVL sample application declares the permission:
 </p>
diff --git a/docs/html/google/play/licensing/setting-up.jd b/docs/html/google/play/licensing/setting-up.jd
index 77e9d09..1d4e775 100644
--- a/docs/html/google/play/licensing/setting-up.jd
+++ b/docs/html/google/play/licensing/setting-up.jd
@@ -290,7 +290,7 @@
 system, add and track the sources that are in the working location rather
 than those in default location in the SDK. </p>
 
-<p>Moving the library sources is important is because, when you later update the
+<p>Moving the library sources is important because when you later update the
 Licensing package, the SDK installs the new files to the same location as
 the older files. Moving your working library files to a safe location ensures
 that your work won't be inadvertently overwritten should you download a new
diff --git a/docs/html/guide/components/aidl.jd b/docs/html/guide/components/aidl.jd
index 805b7ec..0be6e6f 100644
--- a/docs/html/guide/components/aidl.jd
+++ b/docs/html/guide/components/aidl.jd
@@ -208,7 +208,7 @@
 defines a few helper methods, most notably {@code asInterface()}, which takes an {@link
 android.os.IBinder} (usually the one passed to a client's {@link
 android.content.ServiceConnection#onServiceConnected onServiceConnected()} callback method) and
-returns an instance of the stub interface. See the section <a href="#calling">Calling an IPC
+returns an instance of the stub interface. See the section <a href="#Calling">Calling an IPC
 Method</a> for more details on how to make this cast.</p>
 
 <p>To implement the interface generated from the {@code .aidl}, extend the generated {@link
diff --git a/docs/html/guide/topics/connectivity/wifip2p.jd b/docs/html/guide/topics/connectivity/wifip2p.jd
index 82c9abd..bbf30fd 100644
--- a/docs/html/guide/topics/connectivity/wifip2p.jd
+++ b/docs/html/guide/topics/connectivity/wifip2p.jd
@@ -237,16 +237,16 @@
  */
 public class WiFiDirectBroadcastReceiver extends BroadcastReceiver {
 
-    private WifiP2pManager manager;
-    private Channel channel;
-    private MyWiFiActivity activity;
+    private WifiP2pManager mManager;
+    private Channel mChannel;
+    private MyWiFiActivity mActivity;
 
     public WiFiDirectBroadcastReceiver(WifiP2pManager manager, Channel channel,
             MyWifiActivity activity) {
         super();
-        this.manager = manager;
-        this.channel = channel;
-        this.activity = activity;
+        this.mManager = manager;
+        this.mChannel = channel;
+        this.mActivity = activity;
     }
 
     &#064;Override
@@ -333,7 +333,7 @@
     ...
     mManager = (WifiP2pManager) getSystemService(Context.WIFI_P2P_SERVICE);
     mChannel = mManager.initialize(this, getMainLooper(), null);
-    mReceiver = new WiFiDirectBroadcastReceiver(manager, channel, this);
+    mReceiver = new WiFiDirectBroadcastReceiver(mManager, mChannel, this);
     ...
 }
 </pre>
@@ -397,7 +397,7 @@
   that the discovery process succeeded and does not provide any information about the actual peers
   that it discovered, if any:</p>
   <pre>
-manager.discoverPeers(channel, new WifiP2pManager.ActionListener() {
+mManager.discoverPeers(channel, new WifiP2pManager.ActionListener() {
     &#064;Override
     public void onSuccess() {
         ...
@@ -425,8 +425,8 @@
     // request available peers from the wifi p2p manager. This is an
     // asynchronous call and the calling activity is notified with a
     // callback on PeerListListener.onPeersAvailable()
-    if (manager != null) {
-        manager.requestPeers(channel, myPeerListListener);
+    if (mManager != null) {
+        mManager.requestPeers(mChannel, myPeerListListener);
     }
 }
 </pre>
@@ -453,7 +453,7 @@
 WifiP2pDevice device;
 WifiP2pConfig config = new WifiP2pConfig();
 config.deviceAddress = device.deviceAddress;
-manager.connect(channel, config, new ActionListener() {
+mManager.connect(mChannel, config, new ActionListener() {
 
     &#064;Override
     public void onSuccess() {
diff --git a/docs/html/guide/topics/manifest/manifest-intro.jd b/docs/html/guide/topics/manifest/manifest-intro.jd
index a130f7d..d25a513 100644
--- a/docs/html/guide/topics/manifest/manifest-intro.jd
+++ b/docs/html/guide/topics/manifest/manifest-intro.jd
@@ -115,6 +115,7 @@
         <a href="{@docRoot}guide/topics/manifest/provider-element.html">&lt;provider&gt;</a>
             <a href="{@docRoot}guide/topics/manifest/grant-uri-permission-element.html">&lt;grant-uri-permission /&gt;</a>
             <a href="{@docRoot}guide/topics/manifest/meta-data-element.html">&lt;meta-data /&gt;</a>
+            <a href="{@docRoot}guide/topics/manifest/path-permission-element.html">&lt;path-permission /&gt;</a>
         <a href="{@docRoot}guide/topics/manifest/provider-element.html">&lt;/provider&gt;</a>
 
         <a href="{@docRoot}guide/topics/manifest/uses-library-element.html">&lt;uses-library /&gt;</a>
diff --git a/docs/html/guide/topics/manifest/uses-feature-element.jd b/docs/html/guide/topics/manifest/uses-feature-element.jd
index c25dff8..3d6f18b 100644
--- a/docs/html/guide/topics/manifest/uses-feature-element.jd
+++ b/docs/html/guide/topics/manifest/uses-feature-element.jd
@@ -708,9 +708,9 @@
   <td>Television</td>
   <td><code>android.hardware.type.television</code></td>
   <td>The application is designed for a television user experience.</td>
-  <td>>This feature defines "television" to be a typical living room television experience: 
+  <td>This feature defines "television" to be a typical living room television experience: 
   displayed on a big screen, where the user is sitting far away and the dominant form of 
-  input is be something like a d-pad, and generally not through touch or a 
+  input is something like a d-pad, and generally not through touch or a 
   mouse/pointer-device.</td>
 </tr>
 
diff --git a/docs/html/guide/topics/ui/layout/gridview.jd b/docs/html/guide/topics/ui/layout/gridview.jd
index 67bdd0f0..84c3dab 100644
--- a/docs/html/guide/topics/ui/layout/gridview.jd
+++ b/docs/html/guide/topics/ui/layout/gridview.jd
@@ -170,7 +170,7 @@
 be cropped toward the center (if necessary).</li>
   <li>{@link android.widget.ImageView#setPadding(int,int,int,int)} defines the padding for all
 sides. (Note that, if the images have different aspect-ratios, then less
-padding will cause for more cropping of the image if it does not match
+padding will cause more cropping of the image if it does not match
 the dimensions given to the ImageView.)</li>
 </ul>
 
diff --git a/docs/html/guide/topics/ui/notifiers/notifications.jd b/docs/html/guide/topics/ui/notifiers/notifications.jd
index 77cce18..e70987b 100644
--- a/docs/html/guide/topics/ui/notifiers/notifications.jd
+++ b/docs/html/guide/topics/ui/notifiers/notifications.jd
@@ -921,7 +921,7 @@
 </p>
 <pre>
  // Sets an activity indicator for an operation of indeterminate length
-mBuilder.setProgress(0, 0, false);
+mBuilder.setProgress(0, 0, true);
 // Issues the notification
 mNotifyManager.notify(0, mBuilder.build());
 </pre>
diff --git a/docs/html/guide/webapps/webview.jd b/docs/html/guide/webapps/webview.jd
index ce7fe27..f8b2a1d 100644
--- a/docs/html/guide/webapps/webview.jd
+++ b/docs/html/guide/webapps/webview.jd
@@ -314,7 +314,7 @@
 &#64;Override
 public boolean {@link android.app.Activity#onKeyDown(int,KeyEvent) onKeyDown}(int keyCode, KeyEvent event) {
     // Check if the key event was the Back button and if there's history
-    if ((keyCode == KeyEvent.KEYCODE_BACK) &amp;&amp; myWebView.{@link android.webkit.WebView#canGoBack() canGoBack}() {
+    if ((keyCode == KeyEvent.KEYCODE_BACK) &amp;&amp; myWebView.{@link android.webkit.WebView#canGoBack() canGoBack}()) {
         myWebView.{@link android.webkit.WebView#goBack() goBack}();
         return true;
     }
diff --git a/docs/html/images/brand/af_generic_rgb_wo_45.png b/docs/html/images/brand/af_generic_rgb_wo_45.png
new file mode 100644
index 0000000..bf774ab
--- /dev/null
+++ b/docs/html/images/brand/af_generic_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/af_generic_rgb_wo_60.png b/docs/html/images/brand/af_generic_rgb_wo_60.png
new file mode 100644
index 0000000..0487c7f
--- /dev/null
+++ b/docs/html/images/brand/af_generic_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/images/brand/ar_generic_rgb_wo_45.png b/docs/html/images/brand/ar_generic_rgb_wo_45.png
new file mode 100644
index 0000000..bdb0ff6
--- /dev/null
+++ b/docs/html/images/brand/ar_generic_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/ar_generic_rgb_wo_60.png b/docs/html/images/brand/ar_generic_rgb_wo_60.png
new file mode 100644
index 0000000..ba9fc69
--- /dev/null
+++ b/docs/html/images/brand/ar_generic_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/images/brand/be_generic_rgb_wo_45.png b/docs/html/images/brand/be_generic_rgb_wo_45.png
new file mode 100644
index 0000000..bec6c7a
--- /dev/null
+++ b/docs/html/images/brand/be_generic_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/be_generic_rgb_wo_60.png b/docs/html/images/brand/be_generic_rgb_wo_60.png
new file mode 100644
index 0000000..53ad2a11
--- /dev/null
+++ b/docs/html/images/brand/be_generic_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/images/brand/bg_generic_rgb_wo_45.png b/docs/html/images/brand/bg_generic_rgb_wo_45.png
new file mode 100644
index 0000000..9a27471
--- /dev/null
+++ b/docs/html/images/brand/bg_generic_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/bg_generic_rgb_wo_60.png b/docs/html/images/brand/bg_generic_rgb_wo_60.png
new file mode 100644
index 0000000..5143a66
--- /dev/null
+++ b/docs/html/images/brand/bg_generic_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/images/brand/ca_generic_rgb_wo_45.png b/docs/html/images/brand/ca_generic_rgb_wo_45.png
new file mode 100644
index 0000000..698a4cd
--- /dev/null
+++ b/docs/html/images/brand/ca_generic_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/ca_generic_rgb_wo_60.png b/docs/html/images/brand/ca_generic_rgb_wo_60.png
new file mode 100644
index 0000000..e943de1
--- /dev/null
+++ b/docs/html/images/brand/ca_generic_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/images/brand/cs_generic_rgb_wo_45.png b/docs/html/images/brand/cs_generic_rgb_wo_45.png
new file mode 100644
index 0000000..b97b805
--- /dev/null
+++ b/docs/html/images/brand/cs_generic_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/cs_generic_rgb_wo_60.png b/docs/html/images/brand/cs_generic_rgb_wo_60.png
new file mode 100644
index 0000000..9656c2e
--- /dev/null
+++ b/docs/html/images/brand/cs_generic_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/images/brand/da_generic_rgb_wo_45.png b/docs/html/images/brand/da_generic_rgb_wo_45.png
new file mode 100644
index 0000000..541ba29
--- /dev/null
+++ b/docs/html/images/brand/da_generic_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/da_generic_rgb_wo_60.png b/docs/html/images/brand/da_generic_rgb_wo_60.png
new file mode 100644
index 0000000..d974154
--- /dev/null
+++ b/docs/html/images/brand/da_generic_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/images/brand/de_app_rgb_wo_45.png b/docs/html/images/brand/de_app_rgb_wo_45.png
new file mode 100644
index 0000000..db48df2
--- /dev/null
+++ b/docs/html/images/brand/de_app_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/de_app_rgb_wo_60.png b/docs/html/images/brand/de_app_rgb_wo_60.png
new file mode 100644
index 0000000..9e0f757
--- /dev/null
+++ b/docs/html/images/brand/de_app_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/images/brand/de_generic_rgb_wo_45.png b/docs/html/images/brand/de_generic_rgb_wo_45.png
new file mode 100644
index 0000000..1396f79
--- /dev/null
+++ b/docs/html/images/brand/de_generic_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/de_generic_rgb_wo_60.png b/docs/html/images/brand/de_generic_rgb_wo_60.png
new file mode 100644
index 0000000..f2df4a4
--- /dev/null
+++ b/docs/html/images/brand/de_generic_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/images/brand/el_generic_rgb_wo_45.png b/docs/html/images/brand/el_generic_rgb_wo_45.png
new file mode 100644
index 0000000..adaea5f
--- /dev/null
+++ b/docs/html/images/brand/el_generic_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/el_generic_rgb_wo_60.png b/docs/html/images/brand/el_generic_rgb_wo_60.png
new file mode 100644
index 0000000..37ae3bc
--- /dev/null
+++ b/docs/html/images/brand/el_generic_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/images/brand/es-419_app_rgb_wo_45.png b/docs/html/images/brand/es-419_app_rgb_wo_45.png
new file mode 100644
index 0000000..3fb9a3f
--- /dev/null
+++ b/docs/html/images/brand/es-419_app_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/es-419_app_rgb_wo_60.png b/docs/html/images/brand/es-419_app_rgb_wo_60.png
new file mode 100644
index 0000000..1dfb820
--- /dev/null
+++ b/docs/html/images/brand/es-419_app_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/images/brand/es-419_generic_rgb_wo_45.png b/docs/html/images/brand/es-419_generic_rgb_wo_45.png
new file mode 100644
index 0000000..b89274d
--- /dev/null
+++ b/docs/html/images/brand/es-419_generic_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/es-419_generic_rgb_wo_60.png b/docs/html/images/brand/es-419_generic_rgb_wo_60.png
new file mode 100644
index 0000000..23d7705
--- /dev/null
+++ b/docs/html/images/brand/es-419_generic_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/images/brand/es_app_rgb_wo_45.png b/docs/html/images/brand/es_app_rgb_wo_45.png
new file mode 100644
index 0000000..ad5e61a
--- /dev/null
+++ b/docs/html/images/brand/es_app_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/es_app_rgb_wo_60.png b/docs/html/images/brand/es_app_rgb_wo_60.png
new file mode 100644
index 0000000..6796ad3
--- /dev/null
+++ b/docs/html/images/brand/es_app_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/images/brand/es_generic_rgb_wo_45.png b/docs/html/images/brand/es_generic_rgb_wo_45.png
new file mode 100644
index 0000000..b89274d
--- /dev/null
+++ b/docs/html/images/brand/es_generic_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/es_generic_rgb_wo_60.png b/docs/html/images/brand/es_generic_rgb_wo_60.png
new file mode 100644
index 0000000..23d7705
--- /dev/null
+++ b/docs/html/images/brand/es_generic_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/images/brand/et_generic_rgb_wo_45.png b/docs/html/images/brand/et_generic_rgb_wo_45.png
new file mode 100644
index 0000000..0e267381
--- /dev/null
+++ b/docs/html/images/brand/et_generic_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/et_generic_rgb_wo_60.png b/docs/html/images/brand/et_generic_rgb_wo_60.png
new file mode 100644
index 0000000..a99dee1
--- /dev/null
+++ b/docs/html/images/brand/et_generic_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/images/brand/fa_generic_rgb_wo_45.png b/docs/html/images/brand/fa_generic_rgb_wo_45.png
new file mode 100644
index 0000000..25827f6
--- /dev/null
+++ b/docs/html/images/brand/fa_generic_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/fa_generic_rgb_wo_60.png b/docs/html/images/brand/fa_generic_rgb_wo_60.png
new file mode 100644
index 0000000..5118909
--- /dev/null
+++ b/docs/html/images/brand/fa_generic_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/images/brand/fi_generic_rgb_wo_45.png b/docs/html/images/brand/fi_generic_rgb_wo_45.png
new file mode 100644
index 0000000..93dc4fc
--- /dev/null
+++ b/docs/html/images/brand/fi_generic_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/fi_generic_rgb_wo_60.png b/docs/html/images/brand/fi_generic_rgb_wo_60.png
new file mode 100644
index 0000000..95eff07
--- /dev/null
+++ b/docs/html/images/brand/fi_generic_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/images/brand/fil_generic_rgb_wo_45.png b/docs/html/images/brand/fil_generic_rgb_wo_45.png
new file mode 100644
index 0000000..7e74e62
--- /dev/null
+++ b/docs/html/images/brand/fil_generic_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/fil_generic_rgb_wo_60.png b/docs/html/images/brand/fil_generic_rgb_wo_60.png
new file mode 100644
index 0000000..8f02743
--- /dev/null
+++ b/docs/html/images/brand/fil_generic_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/images/brand/fr_app_rgb_wo_45.png b/docs/html/images/brand/fr_app_rgb_wo_45.png
new file mode 100644
index 0000000..14219e3
--- /dev/null
+++ b/docs/html/images/brand/fr_app_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/fr_app_rgb_wo_60.png b/docs/html/images/brand/fr_app_rgb_wo_60.png
new file mode 100644
index 0000000..af58843
--- /dev/null
+++ b/docs/html/images/brand/fr_app_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/images/brand/fr_generic_rgb_wo_45.png b/docs/html/images/brand/fr_generic_rgb_wo_45.png
new file mode 100644
index 0000000..3e1768f
--- /dev/null
+++ b/docs/html/images/brand/fr_generic_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/fr_generic_rgb_wo_60.png b/docs/html/images/brand/fr_generic_rgb_wo_60.png
new file mode 100644
index 0000000..5c307f5
--- /dev/null
+++ b/docs/html/images/brand/fr_generic_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/images/brand/hr_generic_rgb_wo_45.png b/docs/html/images/brand/hr_generic_rgb_wo_45.png
new file mode 100644
index 0000000..b8acaac
--- /dev/null
+++ b/docs/html/images/brand/hr_generic_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/hr_generic_rgb_wo_60.png b/docs/html/images/brand/hr_generic_rgb_wo_60.png
new file mode 100644
index 0000000..4fe6c7b
--- /dev/null
+++ b/docs/html/images/brand/hr_generic_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/images/brand/hu_generic_rgb_wo_45.png b/docs/html/images/brand/hu_generic_rgb_wo_45.png
new file mode 100644
index 0000000..3b2184d
--- /dev/null
+++ b/docs/html/images/brand/hu_generic_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/hu_generic_rgb_wo_60.png b/docs/html/images/brand/hu_generic_rgb_wo_60.png
new file mode 100644
index 0000000..d6572be
--- /dev/null
+++ b/docs/html/images/brand/hu_generic_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/images/brand/id-in_generic_rgb_wo_45.png b/docs/html/images/brand/id-in_generic_rgb_wo_45.png
new file mode 100644
index 0000000..17ce069
--- /dev/null
+++ b/docs/html/images/brand/id-in_generic_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/id-in_generic_rgb_wo_60.png b/docs/html/images/brand/id-in_generic_rgb_wo_60.png
new file mode 100644
index 0000000..ad067ce
--- /dev/null
+++ b/docs/html/images/brand/id-in_generic_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/images/brand/it_app_rgb_wo_45.png b/docs/html/images/brand/it_app_rgb_wo_45.png
new file mode 100644
index 0000000..16a137e
--- /dev/null
+++ b/docs/html/images/brand/it_app_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/it_app_rgb_wo_60.png b/docs/html/images/brand/it_app_rgb_wo_60.png
new file mode 100644
index 0000000..27123dc
--- /dev/null
+++ b/docs/html/images/brand/it_app_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/images/brand/it_generic_rgb_wo_45.png b/docs/html/images/brand/it_generic_rgb_wo_45.png
new file mode 100644
index 0000000..ee5f85e
--- /dev/null
+++ b/docs/html/images/brand/it_generic_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/it_generic_rgb_wo_60.png b/docs/html/images/brand/it_generic_rgb_wo_60.png
new file mode 100644
index 0000000..03ea5ba
--- /dev/null
+++ b/docs/html/images/brand/it_generic_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/images/brand/iw-he_generic_rgb_wo_45.png b/docs/html/images/brand/iw-he_generic_rgb_wo_45.png
new file mode 100644
index 0000000..1d03c77
--- /dev/null
+++ b/docs/html/images/brand/iw-he_generic_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/iw-he_generic_rgb_wo_60.png b/docs/html/images/brand/iw-he_generic_rgb_wo_60.png
new file mode 100644
index 0000000..decfdae
--- /dev/null
+++ b/docs/html/images/brand/iw-he_generic_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/images/brand/ja_app_rgb_wo_45.png b/docs/html/images/brand/ja_app_rgb_wo_45.png
new file mode 100644
index 0000000..6af7582
--- /dev/null
+++ b/docs/html/images/brand/ja_app_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/ja_app_rgb_wo_60.png b/docs/html/images/brand/ja_app_rgb_wo_60.png
new file mode 100644
index 0000000..e197e12
--- /dev/null
+++ b/docs/html/images/brand/ja_app_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/images/brand/ja_generic_rgb_wo_45.png b/docs/html/images/brand/ja_generic_rgb_wo_45.png
new file mode 100644
index 0000000..5f5281a
--- /dev/null
+++ b/docs/html/images/brand/ja_generic_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/ja_generic_rgb_wo_60.png b/docs/html/images/brand/ja_generic_rgb_wo_60.png
new file mode 100644
index 0000000..fcb4c9c
--- /dev/null
+++ b/docs/html/images/brand/ja_generic_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/images/brand/ko_app_rgb_wo_45.png b/docs/html/images/brand/ko_app_rgb_wo_45.png
new file mode 100644
index 0000000..f0b427e
--- /dev/null
+++ b/docs/html/images/brand/ko_app_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/ko_app_rgb_wo_60.png b/docs/html/images/brand/ko_app_rgb_wo_60.png
new file mode 100644
index 0000000..6ccb673
--- /dev/null
+++ b/docs/html/images/brand/ko_app_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/images/brand/ko_generic_rgb_wo_45.png b/docs/html/images/brand/ko_generic_rgb_wo_45.png
new file mode 100644
index 0000000..61ae04a
--- /dev/null
+++ b/docs/html/images/brand/ko_generic_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/ko_generic_rgb_wo_60.png b/docs/html/images/brand/ko_generic_rgb_wo_60.png
new file mode 100644
index 0000000..9c14e36
--- /dev/null
+++ b/docs/html/images/brand/ko_generic_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/images/brand/lt_generic_rgb_wo_45.png b/docs/html/images/brand/lt_generic_rgb_wo_45.png
new file mode 100644
index 0000000..96564d5
--- /dev/null
+++ b/docs/html/images/brand/lt_generic_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/lt_generic_rgb_wo_60.png b/docs/html/images/brand/lt_generic_rgb_wo_60.png
new file mode 100644
index 0000000..2c6c1bf
--- /dev/null
+++ b/docs/html/images/brand/lt_generic_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/images/brand/lv_generic_rgb_wo_45.png b/docs/html/images/brand/lv_generic_rgb_wo_45.png
new file mode 100644
index 0000000..8182ca5
--- /dev/null
+++ b/docs/html/images/brand/lv_generic_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/lv_generic_rgb_wo_60.png b/docs/html/images/brand/lv_generic_rgb_wo_60.png
new file mode 100644
index 0000000..5c0b3d2
--- /dev/null
+++ b/docs/html/images/brand/lv_generic_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/images/brand/ms_generic_rgb_wo_45.png b/docs/html/images/brand/ms_generic_rgb_wo_45.png
new file mode 100644
index 0000000..d6ccc6b
--- /dev/null
+++ b/docs/html/images/brand/ms_generic_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/ms_generic_rgb_wo_60.png b/docs/html/images/brand/ms_generic_rgb_wo_60.png
new file mode 100644
index 0000000..6e1c34d
--- /dev/null
+++ b/docs/html/images/brand/ms_generic_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/images/brand/nl_app_rgb_wo_45.png b/docs/html/images/brand/nl_app_rgb_wo_45.png
new file mode 100644
index 0000000..f06ed04
--- /dev/null
+++ b/docs/html/images/brand/nl_app_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/nl_app_rgb_wo_60.png b/docs/html/images/brand/nl_app_rgb_wo_60.png
new file mode 100644
index 0000000..f2c797d
--- /dev/null
+++ b/docs/html/images/brand/nl_app_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/images/brand/nl_generic_rgb_wo_45.png b/docs/html/images/brand/nl_generic_rgb_wo_45.png
new file mode 100644
index 0000000..6b5826d
--- /dev/null
+++ b/docs/html/images/brand/nl_generic_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/nl_generic_rgb_wo_60.png b/docs/html/images/brand/nl_generic_rgb_wo_60.png
new file mode 100644
index 0000000..cb11afda
--- /dev/null
+++ b/docs/html/images/brand/nl_generic_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/images/brand/no_generic_rgb_wo_45.png b/docs/html/images/brand/no_generic_rgb_wo_45.png
new file mode 100644
index 0000000..fb390d8
--- /dev/null
+++ b/docs/html/images/brand/no_generic_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/no_generic_rgb_wo_60.png b/docs/html/images/brand/no_generic_rgb_wo_60.png
new file mode 100644
index 0000000..e83dce7
--- /dev/null
+++ b/docs/html/images/brand/no_generic_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/images/brand/pl_generic_rgb_wo_45.png b/docs/html/images/brand/pl_generic_rgb_wo_45.png
new file mode 100644
index 0000000..78caded
--- /dev/null
+++ b/docs/html/images/brand/pl_generic_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/pl_generic_rgb_wo_60.png b/docs/html/images/brand/pl_generic_rgb_wo_60.png
new file mode 100644
index 0000000..2d956fb
--- /dev/null
+++ b/docs/html/images/brand/pl_generic_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/images/brand/pt-br_app_rgb_wo_45.png b/docs/html/images/brand/pt-br_app_rgb_wo_45.png
new file mode 100644
index 0000000..065998b
--- /dev/null
+++ b/docs/html/images/brand/pt-br_app_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/pt-br_app_rgb_wo_60.png b/docs/html/images/brand/pt-br_app_rgb_wo_60.png
new file mode 100644
index 0000000..1ce0a6c
--- /dev/null
+++ b/docs/html/images/brand/pt-br_app_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/images/brand/pt-br_generic_rgb_wo_45.png b/docs/html/images/brand/pt-br_generic_rgb_wo_45.png
new file mode 100644
index 0000000..a661d44
--- /dev/null
+++ b/docs/html/images/brand/pt-br_generic_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/pt-br_generic_rgb_wo_60.png b/docs/html/images/brand/pt-br_generic_rgb_wo_60.png
new file mode 100644
index 0000000..402af71
--- /dev/null
+++ b/docs/html/images/brand/pt-br_generic_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/images/brand/pt-pt_app_rgb_wo_45.png b/docs/html/images/brand/pt-pt_app_rgb_wo_45.png
new file mode 100644
index 0000000..0b50959
--- /dev/null
+++ b/docs/html/images/brand/pt-pt_app_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/pt-pt_app_rgb_wo_60.png b/docs/html/images/brand/pt-pt_app_rgb_wo_60.png
new file mode 100644
index 0000000..65dd887
--- /dev/null
+++ b/docs/html/images/brand/pt-pt_app_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/images/brand/pt-pt_generic_rgb_wo_45.png b/docs/html/images/brand/pt-pt_generic_rgb_wo_45.png
new file mode 100644
index 0000000..a616cf1
--- /dev/null
+++ b/docs/html/images/brand/pt-pt_generic_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/pt-pt_generic_rgb_wo_60.png b/docs/html/images/brand/pt-pt_generic_rgb_wo_60.png
new file mode 100644
index 0000000..36a7b83
--- /dev/null
+++ b/docs/html/images/brand/pt-pt_generic_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/images/brand/ro_generic_rgb_wo_45.png b/docs/html/images/brand/ro_generic_rgb_wo_45.png
new file mode 100644
index 0000000..c18a548
--- /dev/null
+++ b/docs/html/images/brand/ro_generic_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/ro_generic_rgb_wo_60.png b/docs/html/images/brand/ro_generic_rgb_wo_60.png
new file mode 100644
index 0000000..b8f3433
--- /dev/null
+++ b/docs/html/images/brand/ro_generic_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/images/brand/ru_generic_rgb_wo_45.png b/docs/html/images/brand/ru_generic_rgb_wo_45.png
new file mode 100644
index 0000000..c049ddb
--- /dev/null
+++ b/docs/html/images/brand/ru_generic_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/ru_generic_rgb_wo_60.png b/docs/html/images/brand/ru_generic_rgb_wo_60.png
new file mode 100644
index 0000000..e00c276
--- /dev/null
+++ b/docs/html/images/brand/ru_generic_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/images/brand/sk_generic_rgb_wo_45.png b/docs/html/images/brand/sk_generic_rgb_wo_45.png
new file mode 100644
index 0000000..27ce06a
--- /dev/null
+++ b/docs/html/images/brand/sk_generic_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/sk_generic_rgb_wo_60.png b/docs/html/images/brand/sk_generic_rgb_wo_60.png
new file mode 100644
index 0000000..8591f2c
--- /dev/null
+++ b/docs/html/images/brand/sk_generic_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/images/brand/sl_generic_rgb_wo_45.png b/docs/html/images/brand/sl_generic_rgb_wo_45.png
new file mode 100644
index 0000000..115a99d
--- /dev/null
+++ b/docs/html/images/brand/sl_generic_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/sl_generic_rgb_wo_60.png b/docs/html/images/brand/sl_generic_rgb_wo_60.png
new file mode 100644
index 0000000..37c2e52
--- /dev/null
+++ b/docs/html/images/brand/sl_generic_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/images/brand/sr_generic_rgb_wo_45.png b/docs/html/images/brand/sr_generic_rgb_wo_45.png
new file mode 100644
index 0000000..86dba47
--- /dev/null
+++ b/docs/html/images/brand/sr_generic_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/sr_generic_rgb_wo_60.png b/docs/html/images/brand/sr_generic_rgb_wo_60.png
new file mode 100644
index 0000000..67806da
--- /dev/null
+++ b/docs/html/images/brand/sr_generic_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/images/brand/sv_generic_rgb_wo_45.png b/docs/html/images/brand/sv_generic_rgb_wo_45.png
new file mode 100644
index 0000000..fb390d8
--- /dev/null
+++ b/docs/html/images/brand/sv_generic_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/sv_generic_rgb_wo_60.png b/docs/html/images/brand/sv_generic_rgb_wo_60.png
new file mode 100644
index 0000000..e83dce7
--- /dev/null
+++ b/docs/html/images/brand/sv_generic_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/images/brand/sw_generic_rgb_wo_45.png b/docs/html/images/brand/sw_generic_rgb_wo_45.png
new file mode 100644
index 0000000..c7deecc
--- /dev/null
+++ b/docs/html/images/brand/sw_generic_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/sw_generic_rgb_wo_60.png b/docs/html/images/brand/sw_generic_rgb_wo_60.png
new file mode 100644
index 0000000..9c0d057
--- /dev/null
+++ b/docs/html/images/brand/sw_generic_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/images/brand/th_generic_rgb_wo_45.png b/docs/html/images/brand/th_generic_rgb_wo_45.png
new file mode 100644
index 0000000..803b6c5
--- /dev/null
+++ b/docs/html/images/brand/th_generic_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/th_generic_rgb_wo_60.png b/docs/html/images/brand/th_generic_rgb_wo_60.png
new file mode 100644
index 0000000..6e36e02
--- /dev/null
+++ b/docs/html/images/brand/th_generic_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/images/brand/tr_generic_rgb_wo_45.png b/docs/html/images/brand/tr_generic_rgb_wo_45.png
new file mode 100644
index 0000000..baa8394
--- /dev/null
+++ b/docs/html/images/brand/tr_generic_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/tr_generic_rgb_wo_60.png b/docs/html/images/brand/tr_generic_rgb_wo_60.png
new file mode 100644
index 0000000..63fa31f
--- /dev/null
+++ b/docs/html/images/brand/tr_generic_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/images/brand/uk_generic_rgb_wo_45.png b/docs/html/images/brand/uk_generic_rgb_wo_45.png
new file mode 100644
index 0000000..68c111f
--- /dev/null
+++ b/docs/html/images/brand/uk_generic_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/uk_generic_rgb_wo_60.png b/docs/html/images/brand/uk_generic_rgb_wo_60.png
new file mode 100644
index 0000000..918d70a
--- /dev/null
+++ b/docs/html/images/brand/uk_generic_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/images/brand/vi_generic_rgb_wo_45.png b/docs/html/images/brand/vi_generic_rgb_wo_45.png
new file mode 100644
index 0000000..e39d00a
--- /dev/null
+++ b/docs/html/images/brand/vi_generic_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/vi_generic_rgb_wo_60.png b/docs/html/images/brand/vi_generic_rgb_wo_60.png
new file mode 100644
index 0000000..ba1e9a0
--- /dev/null
+++ b/docs/html/images/brand/vi_generic_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/images/brand/zh-cn_generic_rgb_wo_45.png b/docs/html/images/brand/zh-cn_generic_rgb_wo_45.png
new file mode 100644
index 0000000..c7748de
--- /dev/null
+++ b/docs/html/images/brand/zh-cn_generic_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/zh-cn_generic_rgb_wo_60.png b/docs/html/images/brand/zh-cn_generic_rgb_wo_60.png
new file mode 100644
index 0000000..0a0f91a
--- /dev/null
+++ b/docs/html/images/brand/zh-cn_generic_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/images/brand/zh-hk_generic_rgb_wo_45.png b/docs/html/images/brand/zh-hk_generic_rgb_wo_45.png
new file mode 100644
index 0000000..c3d064c
--- /dev/null
+++ b/docs/html/images/brand/zh-hk_generic_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/zh-hk_generic_rgb_wo_60.png b/docs/html/images/brand/zh-hk_generic_rgb_wo_60.png
new file mode 100644
index 0000000..2b072de
--- /dev/null
+++ b/docs/html/images/brand/zh-hk_generic_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/images/brand/zh-tw_generic_rgb_wo_45.png b/docs/html/images/brand/zh-tw_generic_rgb_wo_45.png
new file mode 100644
index 0000000..7bb2b09
--- /dev/null
+++ b/docs/html/images/brand/zh-tw_generic_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/zh-tw_generic_rgb_wo_60.png b/docs/html/images/brand/zh-tw_generic_rgb_wo_60.png
new file mode 100644
index 0000000..0797c84b
--- /dev/null
+++ b/docs/html/images/brand/zh-tw_generic_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/images/brand/zu_generic_rgb_wo_45.png b/docs/html/images/brand/zu_generic_rgb_wo_45.png
new file mode 100644
index 0000000..1e9f7c7
--- /dev/null
+++ b/docs/html/images/brand/zu_generic_rgb_wo_45.png
Binary files differ
diff --git a/docs/html/images/brand/zu_generic_rgb_wo_60.png b/docs/html/images/brand/zu_generic_rgb_wo_60.png
new file mode 100644
index 0000000..09f521b
--- /dev/null
+++ b/docs/html/images/brand/zu_generic_rgb_wo_60.png
Binary files differ
diff --git a/docs/html/training/basics/activity-lifecycle/recreating.jd b/docs/html/training/basics/activity-lifecycle/recreating.jd
index 1a65e71..71fd5dd 100644
--- a/docs/html/training/basics/activity-lifecycle/recreating.jd
+++ b/docs/html/training/basics/activity-lifecycle/recreating.jd
@@ -126,7 +126,7 @@
 state from the {@link android.os.Bundle} that the system
 passes your activity. Both the {@link android.app.Activity#onCreate onCreate()} and {@link
 android.app.Activity#onRestoreInstanceState onRestoreInstanceState()} callback methods receive
-the same {@link android.os.Bundle} that containes the instance state information.</p>
+the same {@link android.os.Bundle} that contains the instance state information.</p>
 
 <p>Because the {@link android.app.Activity#onCreate onCreate()} method is called whether the
 system is creating a new instance of your activity or recreating a previous one, you must check
diff --git a/docs/html/training/basics/activity-lifecycle/starting.jd b/docs/html/training/basics/activity-lifecycle/starting.jd
index dd17304..dce6e30 100644
--- a/docs/html/training/basics/activity-lifecycle/starting.jd
+++ b/docs/html/training/basics/activity-lifecycle/starting.jd
@@ -265,7 +265,7 @@
 with the activity and your activity should perform most cleanup during {@link
 android.app.Activity#onPause} and {@link android.app.Activity#onStop}. However, if your
 activity includes background threads that you created during {@link
-android.app.Activity#onCreate onCreate()} or other other long-running resources that could
+android.app.Activity#onCreate onCreate()} or other long-running resources that could
 potentially leak memory if not properly closed, you should kill them during  {@link
 android.app.Activity#onDestroy}.</p>
 
diff --git a/docs/html/training/basics/data-storage/databases.jd b/docs/html/training/basics/data-storage/databases.jd
index 3a717dd..8b11983 100644
--- a/docs/html/training/basics/data-storage/databases.jd
+++ b/docs/html/training/basics/data-storage/databases.jd
@@ -288,7 +288,7 @@
 // Specify arguments in placeholder order.
 String[] selelectionArgs = { String.valueOf(rowId) };
 // Issue SQL statement.
-db.delete(table_name, mySelection, selectionArgs);
+db.delete(table_name, selection, selectionArgs);
 </pre>
 
 
diff --git a/docs/html/training/basics/data-storage/shared-preferences.jd b/docs/html/training/basics/data-storage/shared-preferences.jd
index 67f45cb..099da67 100644
--- a/docs/html/training/basics/data-storage/shared-preferences.jd
+++ b/docs/html/training/basics/data-storage/shared-preferences.jd
@@ -115,7 +115,7 @@
 
 <pre>
 SharedPreferences sharedPref = getActivity().getPreferences(Context.MODE_PRIVATE);
-long default = getResources().getInteger(R.string.saved_high_score_default));
-long highScore = sharedPref.getInt(getString(R.string.saved_high_score), default);
+int defaultValue = getResources().getInteger(R.string.saved_high_score_default);
+long highScore = sharedPref.getInt(getString(R.string.saved_high_score), defaultValue);
 </pre>
 
diff --git a/docs/html/training/basics/firstapp/running-app.jd b/docs/html/training/basics/firstapp/running-app.jd
index 7866083..999d399 100644
--- a/docs/html/training/basics/firstapp/running-app.jd
+++ b/docs/html/training/basics/firstapp/running-app.jd
@@ -52,7 +52,27 @@
   <dd>The <a href="{@docRoot}guide/topics/manifest/manifest-intro.html">manifest file</a> describes
 the fundamental characteristics of the app and defines each of
 its components. You'll learn about various declarations in this file as you read more training
-classes.</dd>
+classes.
+  <p>One of the most important elements your manifest should include is the <a
+href="{@docRoot}guide/topics/manifest/uses-sdk-element.html">{@code &lt;uses-sdk>}</a>
+element. This declares your app's compatibility with different Android versions using the <a
+href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#min">{@code android:minSdkVersion}</a>
+and <a
+href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#target">{@code android:targetSdkVersion}</a>
+attributes. For your first app, it should look like this:</p>
+<pre>
+&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" ... >
+    &lt;uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" />
+    ...
+&lt;/manifest>
+</pre>
+<p>You should always set the <a
+href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#target">{@code android:targetSdkVersion}</a>
+as high as possible and test your app on the corresponding platform version. For more information,
+read <a href="{@docRoot}training/basics/supporting-devices/platforms.html">Supporting Different
+Platform Versions</a>.</p>
+
+  </dd>
   <dt><code>src/</code></dt>
   <dd>Directory for your app's main source files. By default, it includes an {@link
 android.app.Activity} class that runs when your app is launched using the app icon.</dd>
diff --git a/docs/html/training/basics/firstapp/starting-activity.jd b/docs/html/training/basics/firstapp/starting-activity.jd
index 8943c9d..65f22901 100644
--- a/docs/html/training/basics/firstapp/starting-activity.jd
+++ b/docs/html/training/basics/firstapp/starting-activity.jd
@@ -249,16 +249,29 @@
   Keep this one the way it is.</li>
 </ul>
 
-<p>The class should look like this:</p>
+<p>Because the {@link android.app.ActionBar} APIs are available only on {@link
+android.os.Build.VERSION_CODES#HONEYCOMB} (API level 11) and higher, you must add a condition
+around the {@link android.app.Activity#getActionBar()} method to check the current platform version.
+Additionally, you must add the {@code &#64;SuppressLint("NewApi")} tag to the
+{@link android.app.Activity#onCreate onCreate()} method to avoid <a
+href="{@docRoot}tools/help/lint.html">lint</a> errors.</p>
+
+<p>The {@code DisplayMessageActivity} class should now look like this:</p>
 
 <pre>
 public class DisplayMessageActivity extends Activity {
+
+    &#64;SuppressLint("NewApi")
     &#64;Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_display_message);
-        // Show the Up button in the action bar.
-        getActionBar().setDisplayHomeAsUpEnabled(true);
+
+        // Make sure we're running on Honeycomb or higher to use ActionBar APIs
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
+            // Show the Up button in the action bar.
+            getActionBar().setDisplayHomeAsUpEnabled(true);
+        }
     }
 
     &#64;Override
diff --git a/docs/html/training/basics/network-ops/xml.jd b/docs/html/training/basics/network-ops/xml.jd
index b148257..0ea696d 100644
--- a/docs/html/training/basics/network-ops/xml.jd
+++ b/docs/html/training/basics/network-ops/xml.jd
@@ -551,5 +551,5 @@
     conn.setDoInput(true);
     // Starts the query
     conn.connect();
-    InputStream stream = conn.getInputStream();      
+    return conn.getInputStream();
 }</pre>
diff --git a/docs/html/training/basics/supporting-devices/screens.jd b/docs/html/training/basics/supporting-devices/screens.jd
index 8697cd5..1114f21 100644
--- a/docs/html/training/basics/supporting-devices/screens.jd
+++ b/docs/html/training/basics/supporting-devices/screens.jd
@@ -108,7 +108,7 @@
 
 <p>By default, the <code>layout/main.xml</code> file is used for portrait orientation.</p>
 
-<p>If you want a provide a special layout for landscape, including while on large screens, then
+<p>If you want to provide a special layout for landscape, including while on large screens, then
 you need to use both the <code>large</code> and <code>land</code> qualifier:</p>
 
 <pre class="classic no-pretty-print">
diff --git a/docs/html/training/connect-devices-wirelessly/nsd.jd b/docs/html/training/connect-devices-wirelessly/nsd.jd
index d2b01a1..30f5c49 100644
--- a/docs/html/training/connect-devices-wirelessly/nsd.jd
+++ b/docs/html/training/connect-devices-wirelessly/nsd.jd
@@ -28,9 +28,9 @@
 <h2>Try it out</h2>
 
 <div class="download-box">
-  <a href="{@docRoot}shareables/training/nsdchat.zip" class="button">Download
+  <a href="{@docRoot}shareables/training/NsdChat.zip" class="button">Download
     the sample app</a>
-  <p class="filename">nsdchat.zip</p>
+  <p class="filename">NsdChat.zip</p>
 </div>
 </p>
 
diff --git a/docs/html/training/connect-devices-wirelessly/wifi-direct.jd b/docs/html/training/connect-devices-wirelessly/wifi-direct.jd
index 99bb243..b8ed664 100644
--- a/docs/html/training/connect-devices-wirelessly/wifi-direct.jd
+++ b/docs/html/training/connect-devices-wirelessly/wifi-direct.jd
@@ -263,7 +263,7 @@
         // asynchronous call and the calling activity is notified with a
         // callback on PeerListListener.onPeersAvailable()
         if (mManager != null) {
-            mManager.requestPeers(mChannel, peerListener);
+            mManager.requestPeers(mChannel, peerListListener);
         }
         Log.d(WiFiDirectActivity.TAG, "P2P peers changed");
     }...
diff --git a/docs/html/training/custom-views/create-view.jd b/docs/html/training/custom-views/create-view.jd
index 674bcc9..b849cb3 100644
--- a/docs/html/training/custom-views/create-view.jd
+++ b/docs/html/training/custom-views/create-view.jd
@@ -68,8 +68,8 @@
 
 <pre class="prettyprint">
 class PieChart extends View {
-    public PieChart(Context ctx, AttributeSet attrs) {
-        super(ctx, attrs);
+    public PieChart(Context context, AttributeSet attrs) {
+        super(context, attrs);
     }
 }
 </pre>
@@ -104,7 +104,7 @@
 </p>
 
 <pre>
-&lt;resources>;
+&lt;resources>
    &lt;declare-styleable name="PieChart">
        &lt;attr name="showText" format="boolean" />
        &lt;attr name="labelPosition" format="enum">
@@ -189,8 +189,8 @@
             reads its attributes:</p>
 
 <pre>
-public PieChart(Context ctx, AttributeSet attrs) {
-   super(ctx, attrs);
+public PieChart(Context context, AttributeSet attrs) {
+   super(context, attrs);
    TypedArray a = context.getTheme().obtainStyledAttributes(
         attrs,
         R.styleable.PieChart,
diff --git a/docs/html/training/custom-views/index.jd b/docs/html/training/custom-views/index.jd
index 0661c05..cec75b4 100644
--- a/docs/html/training/custom-views/index.jd
+++ b/docs/html/training/custom-views/index.jd
@@ -17,12 +17,12 @@
 
         <h2>You should also read</h2>
         <ul>
-            <li><a href="{@docRoot}/guide/topics/ui/custom-components.html">Custom Components</a>
+            <li><a href="{@docRoot}guide/topics/ui/custom-components.html">Custom Components</a>
             </li>
-            <li><a href="{@docRoot}/guide/topics/ui/ui-events.html">Input Events</a></li>
-            <li><a href="{@docRoot}/guide/topics/graphics/prop-animation.html">Property
+            <li><a href="{@docRoot}guide/topics/ui/ui-events.html">Input Events</a></li>
+            <li><a href="{@docRoot}guide/topics/graphics/prop-animation.html">Property
                 Animation</a></li>
-            <li><a href="{@docRoot}/guide/topics/graphics/hardware-accel.html">Hardware
+            <li><a href="{@docRoot}guide/topics/graphics/hardware-accel.html">Hardware
                 Acceleration</a></li>
             <li><a href="{@docRoot}guide/topics/ui/accessibility/index.html">
                 Accessibility</a> developer guide</li>
diff --git a/docs/html/training/displaying-bitmaps/load-bitmap.jd b/docs/html/training/displaying-bitmaps/load-bitmap.jd
index c0a5709..283f272 100644
--- a/docs/html/training/displaying-bitmaps/load-bitmap.jd
+++ b/docs/html/training/displaying-bitmaps/load-bitmap.jd
@@ -110,12 +110,17 @@
     int inSampleSize = 1;
 
     if (height > reqHeight || width > reqWidth) {
-        if (width > height) {
-            inSampleSize = Math.round((float)height / (float)reqHeight);
-        } else {
-            inSampleSize = Math.round((float)width / (float)reqWidth);
-        }
+
+        // Calculate ratios of height and width to requested height and width
+        final int heightRatio = Math.round((float) height / (float) reqHeight);
+        final int widthRatio = Math.round((float) width / (float) reqWidth);
+
+        // Choose the smallest ratio as inSampleSize value, this will guarantee
+        // a final image with both dimensions larger than or equal to the
+        // requested height and width.
+        inSampleSize = heightRatio < widthRatio ? heightRatio : widthRatio;
     }
+
     return inSampleSize;
 }
 </pre>
diff --git a/docs/html/training/managing-audio/volume-playback.jd b/docs/html/training/managing-audio/volume-playback.jd
index 76abbb6..be0f583 100644
--- a/docs/html/training/managing-audio/volume-playback.jd
+++ b/docs/html/training/managing-audio/volume-playback.jd
@@ -153,4 +153,4 @@
 UI.</p>
 
 <p>A better approach is to register and unregister the media button event receiver when your
-application gains and losses the audio focus. This is covered in detail in the next lesson.</p>
+application gains and loses the audio focus. This is covered in detail in the next lesson.</p>
diff --git a/docs/html/training/multiple-apks/texture.jd b/docs/html/training/multiple-apks/texture.jd
index e4ea72b..c49cc95 100644
--- a/docs/html/training/multiple-apks/texture.jd
+++ b/docs/html/training/multiple-apks/texture.jd
@@ -90,8 +90,8 @@
   <tbody>
     <tr>
       <td class="blueCell">ETC1</td>
-      <td class="greenCell">ATI</td>
-      <td class="redCell">PowerVR</td>
+      <td class="redCell">ATI</td>
+      <td class="greenCell">PowerVR</td>
     </tr>
   </tbody>
 </table>
diff --git a/docs/html/training/sharing/send.jd b/docs/html/training/sharing/send.jd
index 741c017..9cb8eac 100644
--- a/docs/html/training/sharing/send.jd
+++ b/docs/html/training/sharing/send.jd
@@ -32,7 +32,7 @@
 <p>When you construct an intent, you must specify the action you want the intent to "trigger." 
 Android defines several actions, including {@link android.content.Intent#ACTION_SEND} which, as 
 you can probably guess, indicates that the intent is sending data from one activity to another, 
-even across process boundaries. To send data to another activity, all you need to do is speicify 
+even across process boundaries. To send data to another activity, all you need to do is specify 
 the data and its type, the system will identify compatible receiving activities and display them 
 to the user (if there are multiple options) or immediately start the activity (if there is only 
 one option). Similarly, you can advertise the data types that your activities support receiving 
@@ -95,7 +95,7 @@
 sendIntent.setAction(Intent.ACTION_SEND);
 sendIntent.putExtra(Intent.EXTRA_TEXT, &quot;This is my text to send.&quot;);
 sendIntent.setType(&quot;text/plain&quot;);
-startActivity(<strong>Intent.createChooser(sendIntent, getResources().getText(R.string.send_to)</strong>);
+startActivity(<strong>Intent.createChooser(sendIntent, getResources().getText(R.string.send_to))</strong>);
 </pre>
 
 <p>The resulting dialog is shown in figure 1.</p>
diff --git a/graphics/java/android/renderscript/RenderScript.java b/graphics/java/android/renderscript/RenderScript.java
index 900720a..fa115ff 100644
--- a/graphics/java/android/renderscript/RenderScript.java
+++ b/graphics/java/android/renderscript/RenderScript.java
@@ -240,10 +240,10 @@
         rsnElementGetSubElements(mContext, id, IDs, names, arraySizes);
     }
 
-    native int rsnTypeCreate(int con, int eid, int x, int y, int z, boolean mips, boolean faces);
-    synchronized int nTypeCreate(int eid, int x, int y, int z, boolean mips, boolean faces) {
+    native int rsnTypeCreate(int con, int eid, int x, int y, int z, boolean mips, boolean faces, int yuv);
+    synchronized int nTypeCreate(int eid, int x, int y, int z, boolean mips, boolean faces, int yuv) {
         validate();
-        return rsnTypeCreate(mContext, eid, x, y, z, mips, faces);
+        return rsnTypeCreate(mContext, eid, x, y, z, mips, faces, yuv);
     }
     native void rsnTypeGetNativeData(int con, int id, int[] typeData);
     synchronized void nTypeGetNativeData(int id, int[] typeData) {
diff --git a/graphics/java/android/renderscript/ScriptIntrinsic3DLUT.java b/graphics/java/android/renderscript/ScriptIntrinsic3DLUT.java
new file mode 100644
index 0000000..24af6ea
--- /dev/null
+++ b/graphics/java/android/renderscript/ScriptIntrinsic3DLUT.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.renderscript;
+
+import android.util.Log;
+
+/**
+ *
+ * @hide
+ **/
+public final class ScriptIntrinsic3DLUT extends ScriptIntrinsic {
+    private Allocation mLUT;
+    private Element mElement;
+
+    private ScriptIntrinsic3DLUT(int id, RenderScript rs, Element e) {
+        super(id, rs);
+        mElement = e;
+    }
+
+    /**
+     * Supported elements types are {@link Element#U8_4}
+     *
+     * The defaults tables are identity.
+     *
+     * @param rs The Renderscript context
+     * @param e Element type for intputs and outputs
+     *
+     * @return ScriptIntrinsic3DLUT
+     */
+    public static ScriptIntrinsic3DLUT create(RenderScript rs, Element e) {
+        int id = rs.nScriptIntrinsicCreate(8, e.getID(rs));
+
+        if (!e.isCompatible(Element.U8_4(rs))) {
+            throw new RSIllegalArgumentException("Element must be compatibile with uchar4.");
+        }
+
+        return new ScriptIntrinsic3DLUT(id, rs, e);
+    }
+
+    public void setLUT(Allocation lut) {
+        final Type t = lut.getType();
+
+        if (t.getZ() == 0) {
+            throw new RSIllegalArgumentException("LUT must be 3d.");
+        }
+
+        if (!t.getElement().isCompatible(mElement)) {
+            throw new RSIllegalArgumentException("LUT element type must match.");
+        }
+
+        mLUT = lut;
+        setVar(0, mLUT);
+    }
+
+
+    /**
+     * Invoke the kernel and apply the lookup to each cell of ain
+     * and copy to aout.
+     *
+     * @param ain Input allocation
+     * @param aout Output allocation
+     */
+    public void forEach(Allocation ain, Allocation aout) {
+        forEach(0, ain, aout, null);
+    }
+
+    /**
+     * Get a KernelID for this intrinsic kernel.
+     *
+     * @return Script.KernelID The KernelID object.
+     */
+    public Script.KernelID getKernelID() {
+        return createKernelID(0, 3, null, null);
+    }
+}
+
diff --git a/graphics/java/android/renderscript/Type.java b/graphics/java/android/renderscript/Type.java
index 93d8b4b..cb12594 100644
--- a/graphics/java/android/renderscript/Type.java
+++ b/graphics/java/android/renderscript/Type.java
@@ -18,6 +18,8 @@
 
 
 import java.lang.reflect.Field;
+
+import android.graphics.ImageFormat;
 import android.util.Log;
 
 /**
@@ -208,6 +210,7 @@
         int mDimZ;
         boolean mDimMipmaps;
         boolean mDimFaces;
+        int mYuv;
 
         Element mElement;
 
@@ -263,6 +266,25 @@
             return this;
         }
 
+        /**
+         * @hide
+         *
+         * only NV21, YV12.  Enums from ImageFormat
+         */
+        public Builder setYuvFormat(int yuvFormat) {
+            switch (yuvFormat) {
+            case android.graphics.ImageFormat.NV21:
+            case android.graphics.ImageFormat.YV12:
+                break;
+
+            default:
+                throw new RSIllegalArgumentException("Only NV21 and YV12 are supported..");
+            }
+
+            mYuv = yuvFormat;
+            return this;
+        }
+
 
         /**
          * Validate structure and create a new type.
@@ -289,8 +311,14 @@
                 }
             }
 
+            if (mYuv != 0) {
+                if ((mDimZ != 0) || mDimFaces || mDimMipmaps) {
+                    throw new RSInvalidStateException("YUV only supports basic 2D.");
+                }
+            }
+
             int id = mRS.nTypeCreate(mElement.getID(mRS),
-                                     mDimX, mDimY, mDimZ, mDimMipmaps, mDimFaces);
+                                     mDimX, mDimY, mDimZ, mDimMipmaps, mDimFaces, mYuv);
             Type t = new Type(id, mRS);
             t.mElement = mElement;
             t.mDimX = mDimX;
@@ -298,6 +326,7 @@
             t.mDimZ = mDimZ;
             t.mDimMipmaps = mDimMipmaps;
             t.mDimFaces = mDimFaces;
+            t.mDimYuv = mYuv;
 
             t.calcElementCount();
             return t;
diff --git a/graphics/jni/android_renderscript_RenderScript.cpp b/graphics/jni/android_renderscript_RenderScript.cpp
index 75c7903..54413b4 100644
--- a/graphics/jni/android_renderscript_RenderScript.cpp
+++ b/graphics/jni/android_renderscript_RenderScript.cpp
@@ -427,12 +427,12 @@
 
 static int
 nTypeCreate(JNIEnv *_env, jobject _this, RsContext con, RsElement eid,
-            jint dimx, jint dimy, jint dimz, jboolean mips, jboolean faces)
+            jint dimx, jint dimy, jint dimz, jboolean mips, jboolean faces, jint yuv)
 {
-    LOG_API("nTypeCreate, con(%p) eid(%p), x(%i), y(%i), z(%i), mips(%i), faces(%i)",
-            con, eid, dimx, dimy, dimz, mips, faces);
+    LOG_API("nTypeCreate, con(%p) eid(%p), x(%i), y(%i), z(%i), mips(%i), faces(%i), yuv(%i)",
+            con, eid, dimx, dimy, dimz, mips, faces, yuv);
 
-    jint id = (jint)rsTypeCreate(con, (RsElement)eid, dimx, dimy, dimz, mips, faces);
+    jint id = (jint)rsTypeCreate(con, (RsElement)eid, dimx, dimy, dimz, mips, faces, yuv);
     return (jint)id;
 }
 
@@ -1454,7 +1454,7 @@
 {"rsnElementGetNativeData",          "(II[I)V",                               (void*)nElementGetNativeData },
 {"rsnElementGetSubElements",         "(II[I[Ljava/lang/String;[I)V",          (void*)nElementGetSubElements },
 
-{"rsnTypeCreate",                    "(IIIIIZZ)I",                            (void*)nTypeCreate },
+{"rsnTypeCreate",                    "(IIIIIZZI)I",                           (void*)nTypeCreate },
 {"rsnTypeGetNativeData",             "(II[I)V",                               (void*)nTypeGetNativeData },
 
 {"rsnAllocationCreateTyped",         "(IIIII)I",                               (void*)nAllocationCreateTyped },
diff --git a/libs/hwui/DisplayListRenderer.cpp b/libs/hwui/DisplayListRenderer.cpp
index 7a38b40..06574cd 100644
--- a/libs/hwui/DisplayListRenderer.cpp
+++ b/libs/hwui/DisplayListRenderer.cpp
@@ -64,6 +64,7 @@
     "DrawTextOnPath",
     "DrawPosText",
     "DrawText",
+    "DrawRects",
     "ResetShader",
     "SetupShader",
     "ResetColorFilter",
@@ -633,6 +634,13 @@
                         text.text(), text.length(), count, paint);
             }
             break;
+            case DrawRects: {
+                int32_t count = 0;
+                float* rects = getFloats(count);
+                SkPaint* paint = getPaint(renderer);
+                ALOGD("%s%s %d, %p", (char*) indent, OP_NAMES[op], count / 4, paint);
+            }
+            break;
             case ResetShader: {
                 ALOGD("%s%s", (char*) indent, OP_NAMES[op]);
             }
@@ -1277,6 +1285,14 @@
                         x, y, positions, paint, length);
             }
             break;
+            case DrawRects: {
+                int32_t count = 0;
+                float* rects = getFloats(count);
+                SkPaint* paint = getPaint(renderer);
+                DISPLAY_LIST_LOGD("%s%s %d, %p", (char*) indent, OP_NAMES[op], count, paint);
+                drawGlStatus |= renderer.drawRects(rects, count / 4, paint);
+            }
+            break;
             case ResetShader: {
                 DISPLAY_LIST_LOGD("%s%s", (char*) indent, OP_NAMES[op]);
                 renderer.resetShader();
@@ -1759,7 +1775,7 @@
     paint->setAntiAlias(true);
     SkPaint* addedPaint = addPaint(paint);
     FontRenderer& fontRenderer = mCaches.fontRenderer->getFontRenderer(addedPaint);
-    fontRenderer.precache(addedPaint, text, count);
+    fontRenderer.precache(addedPaint, text, count, *mSnapshot->transform);
     return DrawGlInfo::kStatusDone;
 }
 
@@ -1773,7 +1789,7 @@
     paint->setAntiAlias(true);
     SkPaint* addedPaint = addPaint(paint);
     FontRenderer& fontRenderer = mCaches.fontRenderer->getFontRenderer(addedPaint);
-    fontRenderer.precache(addedPaint, text, count);
+    fontRenderer.precache(addedPaint, text, count, *mSnapshot->transform);
     return DrawGlInfo::kStatusDone;
 }
 
@@ -1807,13 +1823,22 @@
     SkPaint* addedPaint = addPaint(paint);
     if (!reject) {
         FontRenderer& fontRenderer = mCaches.fontRenderer->getFontRenderer(addedPaint);
-        fontRenderer.precache(addedPaint, text, count);
+        fontRenderer.precache(addedPaint, text, count, *mSnapshot->transform);
     }
     addFloat(length);
     addSkip(location);
     return DrawGlInfo::kStatusDone;
 }
 
+status_t DisplayListRenderer::drawRects(const float* rects, int count, SkPaint* paint) {
+    if (count <= 0) return DrawGlInfo::kStatusDone;
+
+    addOp(DisplayList::DrawRects);
+    addFloats(rects, count * 4);
+    addPaint(paint);
+    return DrawGlInfo::kStatusDone;
+}
+
 void DisplayListRenderer::resetShader() {
     addOp(DisplayList::ResetShader);
 }
diff --git a/libs/hwui/DisplayListRenderer.h b/libs/hwui/DisplayListRenderer.h
index e42def5..fb01753 100644
--- a/libs/hwui/DisplayListRenderer.h
+++ b/libs/hwui/DisplayListRenderer.h
@@ -106,6 +106,7 @@
         DrawTextOnPath,
         DrawPosText,
         DrawText,
+        DrawRects,
         ResetShader,
         SetupShader,
         ResetColorFilter,
@@ -608,6 +609,7 @@
             const float* positions, SkPaint* paint);
     virtual status_t drawText(const char* text, int bytesCount, int count,
             float x, float y, const float* positions, SkPaint* paint, float length);
+    virtual status_t drawRects(const float* rects, int count, SkPaint* paint);
 
     virtual void resetShader();
     virtual void setupShader(SkiaShader* shader);
diff --git a/libs/hwui/FontRenderer.cpp b/libs/hwui/FontRenderer.cpp
index 47784a4..5c1eb38 100644
--- a/libs/hwui/FontRenderer.cpp
+++ b/libs/hwui/FontRenderer.cpp
@@ -36,7 +36,9 @@
 
 static bool sLogFontRendererCreate = true;
 
-FontRenderer::FontRenderer() {
+FontRenderer::FontRenderer() :
+        mActiveFonts(LruCache<Font::FontDescription, Font*>::kUnlimitedCapacity) {
+
     if (sLogFontRendererCreate) {
         INIT_LOGD("Creating FontRenderer");
     }
@@ -107,10 +109,11 @@
         delete[] mTextMesh;
     }
 
-    Vector<Font*> fontsToDereference = mActiveFonts;
-    for (uint32_t i = 0; i < fontsToDereference.size(); i++) {
-        delete fontsToDereference[i];
+    LruCache<Font::FontDescription, Font*>::Iterator it(mActiveFonts);
+    while (it.next()) {
+        delete it.value();
     }
+    mActiveFonts.clear();
 }
 
 void FontRenderer::flushAllAndInvalidate() {
@@ -118,8 +121,9 @@
         issueDrawCommand();
     }
 
-    for (uint32_t i = 0; i < mActiveFonts.size(); i++) {
-        mActiveFonts[i]->invalidateTextureCache();
+    LruCache<Font::FontDescription, Font*>::Iterator it(mActiveFonts);
+    while (it.next()) {
+        it.value()->invalidateTextureCache();
     }
 
     for (uint32_t i = 0; i < mCacheTextures.size(); i++) {
@@ -146,8 +150,9 @@
         CacheTexture* cacheTexture = mCacheTextures[i];
         if (cacheTexture->getTexture()) {
             cacheTexture->init();
-            for (uint32_t j = 0; j < mActiveFonts.size(); j++) {
-                mActiveFonts[j]->invalidateTextureCache(cacheTexture);
+            LruCache<Font::FontDescription, Font*>::Iterator it(mActiveFonts);
+            while (it.next()) {
+                it.value()->invalidateTextureCache(cacheTexture);
             }
             cacheTexture->releaseTexture();
         }
@@ -480,22 +485,8 @@
     }
 }
 
-void FontRenderer::setFont(SkPaint* paint, uint32_t fontId, float fontSize) {
-    int flags = 0;
-    if (paint->isFakeBoldText()) {
-        flags |= Font::kFakeBold;
-    }
-
-    const float skewX = paint->getTextSkewX();
-    uint32_t italicStyle = *(uint32_t*) &skewX;
-    const float scaleXFloat = paint->getTextScaleX();
-    uint32_t scaleX = *(uint32_t*) &scaleXFloat;
-    SkPaint::Style style = paint->getStyle();
-    const float strokeWidthFloat = paint->getStrokeWidth();
-    uint32_t strokeWidth = *(uint32_t*) &strokeWidthFloat;
-    mCurrentFont = Font::create(this, fontId, fontSize, flags, italicStyle,
-            scaleX, style, strokeWidth);
-
+void FontRenderer::setFont(SkPaint* paint, const mat4& matrix) {
+    mCurrentFont = Font::create(this, paint, matrix);
 }
 
 FontRenderer::DropShadow FontRenderer::renderDropShadow(SkPaint* paint, const char *text,
@@ -561,39 +552,11 @@
     }
 }
 
-void FontRenderer::precache(SkPaint* paint, const char* text, int numGlyphs) {
-    int flags = 0;
-    if (paint->isFakeBoldText()) {
-        flags |= Font::kFakeBold;
-    }
-    const float skewX = paint->getTextSkewX();
-    uint32_t italicStyle = *(uint32_t*) &skewX;
-    const float scaleXFloat = paint->getTextScaleX();
-    uint32_t scaleX = *(uint32_t*) &scaleXFloat;
-    SkPaint::Style style = paint->getStyle();
-    const float strokeWidthFloat = paint->getStrokeWidth();
-    uint32_t strokeWidth = *(uint32_t*) &strokeWidthFloat;
-    float fontSize = paint->getTextSize();
-    Font* font = Font::create(this, SkTypeface::UniqueID(paint->getTypeface()),
-            fontSize, flags, italicStyle, scaleX, style, strokeWidth);
-
+void FontRenderer::precache(SkPaint* paint, const char* text, int numGlyphs, const mat4& matrix) {
+    Font* font = Font::create(this, paint, matrix);
     font->precache(paint, text, numGlyphs);
 }
 
-bool FontRenderer::renderText(SkPaint* paint, const Rect* clip, const char *text,
-        uint32_t startIndex, uint32_t len, int numGlyphs, int x, int y, Rect* bounds) {
-    if (!mCurrentFont) {
-        ALOGE("No font set");
-        return false;
-    }
-
-    initRender(clip, bounds);
-    mCurrentFont->render(paint, text, startIndex, len, numGlyphs, x, y);
-    finishRender();
-
-    return mDrawn;
-}
-
 bool FontRenderer::renderPosText(SkPaint* paint, const Rect* clip, const char *text,
         uint32_t startIndex, uint32_t len, int numGlyphs, int x, int y,
         const float* positions, Rect* bounds) {
@@ -625,12 +588,7 @@
 }
 
 void FontRenderer::removeFont(const Font* font) {
-    for (uint32_t ct = 0; ct < mActiveFonts.size(); ct++) {
-        if (mActiveFonts[ct] == font) {
-            mActiveFonts.removeAt(ct);
-            break;
-        }
-    }
+    mActiveFonts.remove(font->getDescription());
 
     if (mCurrentFont == font) {
         mCurrentFont = NULL;
diff --git a/libs/hwui/FontRenderer.h b/libs/hwui/FontRenderer.h
index 09a3c25..3964bca 100644
--- a/libs/hwui/FontRenderer.h
+++ b/libs/hwui/FontRenderer.h
@@ -17,6 +17,7 @@
 #ifndef ANDROID_HWUI_FONT_RENDERER_H
 #define ANDROID_HWUI_FONT_RENDERER_H
 
+#include <utils/LruCache.h>
 #include <utils/Vector.h>
 
 #include <SkPaint.h>
@@ -27,6 +28,7 @@
 #include "font/CacheTexture.h"
 #include "font/CachedGlyphInfo.h"
 #include "font/Font.h"
+#include "Matrix.h"
 #include "Properties.h"
 
 namespace android {
@@ -47,14 +49,11 @@
         mGammaTable = gammaTable;
     }
 
-    void setFont(SkPaint* paint, uint32_t fontId, float fontSize);
+    void setFont(SkPaint* paint, const mat4& matrix);
 
-    void precache(SkPaint* paint, const char* text, int numGlyphs);
+    void precache(SkPaint* paint, const char* text, int numGlyphs, const mat4& matrix);
 
     // bounds is an out parameter
-    bool renderText(SkPaint* paint, const Rect* clip, const char *text, uint32_t startIndex,
-            uint32_t len, int numGlyphs, int x, int y, Rect* bounds);
-    // bounds is an out parameter
     bool renderPosText(SkPaint* paint, const Rect* clip, const char *text, uint32_t startIndex,
             uint32_t len, int numGlyphs, int x, int y, const float* positions, Rect* bounds);
     // bounds is an out parameter
@@ -153,7 +152,7 @@
     Vector<CacheTexture*> mCacheTextures;
 
     Font* mCurrentFont;
-    Vector<Font*> mActiveFonts;
+    LruCache<Font::FontDescription, Font*> mActiveFonts;
 
     CacheTexture* mCurrentCacheTexture;
 
diff --git a/libs/hwui/LayerCache.cpp b/libs/hwui/LayerCache.cpp
index ce74cee..cfc5b04 100644
--- a/libs/hwui/LayerCache.cpp
+++ b/libs/hwui/LayerCache.cpp
@@ -67,6 +67,14 @@
 // Caching
 ///////////////////////////////////////////////////////////////////////////////
 
+int LayerCache::LayerEntry::compare(const LayerCache::LayerEntry& lhs,
+        const LayerCache::LayerEntry& rhs) {
+    int deltaInt = int(lhs.mWidth) - int(rhs.mWidth);
+    if (deltaInt != 0) return deltaInt;
+
+    return int(lhs.mHeight) - int(rhs.mHeight);
+}
+
 void LayerCache::deleteLayer(Layer* layer) {
     if (layer) {
         LAYER_LOGD("Destroying layer %dx%d, fbo %d", layer->getWidth(), layer->getHeight(),
diff --git a/libs/hwui/LayerCache.h b/libs/hwui/LayerCache.h
index fd698e2..fc2cd91 100644
--- a/libs/hwui/LayerCache.h
+++ b/libs/hwui/LayerCache.h
@@ -102,9 +102,6 @@
      */
     void dump();
 
-private:
-    void deleteLayer(Layer* layer);
-
     struct LayerEntry {
         LayerEntry():
             mLayer(NULL), mWidth(0), mHeight(0) {
@@ -119,15 +116,14 @@
             mLayer(layer), mWidth(layer->getWidth()), mHeight(layer->getHeight()) {
         }
 
-        bool operator<(const LayerEntry& rhs) const {
-            if (mWidth == rhs.mWidth) {
-                return mHeight < rhs.mHeight;
-            }
-            return mWidth < rhs.mWidth;
+        static int compare(const LayerEntry& lhs, const LayerEntry& rhs);
+
+        bool operator==(const LayerEntry& other) const {
+            return compare(*this, other) == 0;
         }
 
-        bool operator==(const LayerEntry& rhs) const {
-            return mWidth == rhs.mWidth && mHeight == rhs.mHeight;
+        bool operator!=(const LayerEntry& other) const {
+            return compare(*this, other) != 0;
         }
 
         Layer* mLayer;
@@ -135,12 +131,24 @@
         uint32_t mHeight;
     }; // struct LayerEntry
 
+private:
+    void deleteLayer(Layer* layer);
+
     SortedList<LayerEntry> mCache;
 
     uint32_t mSize;
     uint32_t mMaxSize;
 }; // class LayerCache
 
+inline int strictly_order_type(const LayerCache::LayerEntry& lhs,
+        const LayerCache::LayerEntry& rhs) {
+    return LayerCache::LayerEntry::compare(lhs, rhs) < 0;
+}
+
+inline int compare_type(const LayerCache::LayerEntry& lhs, const LayerCache::LayerEntry& rhs) {
+    return LayerCache::LayerEntry::compare(lhs, rhs);
+}
+
 }; // namespace uirenderer
 }; // namespace android
 
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index 094e9ab..8cda729 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -1254,7 +1254,8 @@
     return !clip.intersects(transformed);
 }
 
-bool OpenGLRenderer::quickRejectPreStroke(float left, float top, float right, float bottom, SkPaint* paint) {
+bool OpenGLRenderer::quickRejectPreStroke(float left, float top, float right, float bottom,
+        SkPaint* paint) {
     if (paint->getStyle() != SkPaint::kFill_Style) {
         float outset = paint->getStrokeWidth() * 0.5f;
         return quickReject(left - outset, top - outset, right + outset, bottom + outset);
@@ -1715,7 +1716,6 @@
         return DrawGlInfo::kStatusDone;
     }
 
-    // TODO: We should compute the bounding box when recording the display list
     float left = FLT_MAX;
     float top = FLT_MAX;
     float right = FLT_MIN;
@@ -1753,7 +1753,6 @@
             TextureVertex::set(vertex++, vertices[cx], vertices[cy], u2, v1);
             TextureVertex::set(vertex++, vertices[dx], vertices[dy], u2, v2);
 
-            // TODO: This could be optimized to avoid unnecessary ops
             left = fminf(left, fminf(vertices[ax], fminf(vertices[bx], vertices[cx])));
             top = fminf(top, fminf(vertices[ay], fminf(vertices[by], vertices[cy])));
             right = fmaxf(right, fmaxf(vertices[ax], fmaxf(vertices[bx], vertices[cx])));
@@ -2452,7 +2451,8 @@
     }
 
     // TODO: support fills (accounting for concavity if useCenter && sweepAngle > 180)
-    if (p->getStyle() != SkPaint::kStroke_Style || p->getPathEffect() != 0 || p->getStrokeCap() != SkPaint::kButt_Cap || useCenter) {
+    if (p->getStyle() != SkPaint::kStroke_Style || p->getPathEffect() != 0 ||
+            p->getStrokeCap() != SkPaint::kButt_Cap || useCenter) {
         mCaches.activeTexture(0);
         const PathTexture* texture = mCaches.arcShapeCache.getArc(right - left, bottom - top,
                 startAngle, sweepAngle, useCenter, p);
@@ -2576,16 +2576,15 @@
     }
 
     FontRenderer& fontRenderer = mCaches.fontRenderer->getFontRenderer(paint);
-    fontRenderer.setFont(paint, SkTypeface::UniqueID(paint->getTypeface()),
-            paint->getTextSize());
+    fontRenderer.setFont(paint, *mSnapshot->transform);
 
     int alpha;
     SkXfermode::Mode mode;
     getAlphaAndMode(paint, &alpha, &mode);
 
     if (CC_UNLIKELY(mHasShadow)) {
-        drawTextShadow(paint, text, bytesCount, count, positions, fontRenderer, alpha, mode,
-                0.0f, 0.0f);
+        drawTextShadow(paint, text, bytesCount, count, positions, fontRenderer,
+                alpha, mode, 0.0f, 0.0f);
     }
 
     // Pick the appropriate texture filtering
@@ -2654,6 +2653,14 @@
         return DrawGlInfo::kStatusDone;
     }
 
+#if DEBUG_GLYPHS
+    ALOGD("OpenGLRenderer drawText() with FontID=%d",
+            SkTypeface::UniqueID(paint->getTypeface()));
+#endif
+
+    FontRenderer& fontRenderer = mCaches.fontRenderer->getFontRenderer(paint);
+    fontRenderer.setFont(paint, *mSnapshot->transform);
+
     const float oldX = x;
     const float oldY = y;
     const bool pureTranslate = mSnapshot->transform->isPureTranslate();
@@ -2662,15 +2669,6 @@
         y = (int) floorf(y + mSnapshot->transform->getTranslateY() + 0.5f);
     }
 
-#if DEBUG_GLYPHS
-    ALOGD("OpenGLRenderer drawText() with FontID=%d",
-            SkTypeface::UniqueID(paint->getTypeface()));
-#endif
-
-    FontRenderer& fontRenderer = mCaches.fontRenderer->getFontRenderer(paint);
-    fontRenderer.setFont(paint, SkTypeface::UniqueID(paint->getTypeface()),
-            paint->getTextSize());
-
     int alpha;
     SkXfermode::Mode mode;
     getAlphaAndMode(paint, &alpha, &mode);
@@ -2743,8 +2741,7 @@
     }
 
     FontRenderer& fontRenderer = mCaches.fontRenderer->getFontRenderer(paint);
-    fontRenderer.setFont(paint, SkTypeface::UniqueID(paint->getTypeface()),
-            paint->getTextSize());
+    fontRenderer.setFont(paint, *mSnapshot->transform);
 
     int alpha;
     SkXfermode::Mode mode;
@@ -2788,7 +2785,6 @@
 
     mCaches.activeTexture(0);
 
-    // TODO: Perform early clip test before we rasterize the path
     const PathTexture* texture = mCaches.pathCache.get(path, paint);
     if (!texture) return DrawGlInfo::kStatusDone;
     const AutoTexture autoCleanup(texture);
@@ -3045,6 +3041,76 @@
     }
 }
 
+status_t OpenGLRenderer::drawRects(const float* rects, int count, SkPaint* paint) {
+    if (mSnapshot->isIgnored()) {
+        return DrawGlInfo::kStatusDone;
+    }
+
+    float left = FLT_MAX;
+    float top = FLT_MAX;
+    float right = FLT_MIN;
+    float bottom = FLT_MIN;
+
+    int vertexCount = 0;
+    Vertex mesh[count * 6];
+    Vertex* vertex = mesh;
+
+    for (int i = 0; i < count; i++) {
+        int index = i * 4;
+        float l = rects[index + 0];
+        float t = rects[index + 1];
+        float r = rects[index + 2];
+        float b = rects[index + 3];
+
+        if (!quickRejectNoScissor(left, top, right, bottom)) {
+            Vertex::set(vertex++, l, b);
+            Vertex::set(vertex++, l, t);
+            Vertex::set(vertex++, r, t);
+            Vertex::set(vertex++, l, b);
+            Vertex::set(vertex++, r, t);
+            Vertex::set(vertex++, r, b);
+
+            vertexCount += 6;
+
+            left = fminf(left, l);
+            top = fminf(top, t);
+            right = fmaxf(right, r);
+            bottom = fmaxf(bottom, b);
+        }
+    }
+
+    if (count == 0) return DrawGlInfo::kStatusDone;
+
+    int color = paint->getColor();
+    // If a shader is set, preserve only the alpha
+    if (mShader) {
+        color |= 0x00ffffff;
+    }
+    SkXfermode::Mode mode = getXfermode(paint->getXfermode());
+
+    setupDraw();
+    setupDrawNoTexture();
+    setupDrawColor(color, ((color >> 24) & 0xFF) * mSnapshot->alpha);
+    setupDrawShader();
+    setupDrawColorFilter();
+    setupDrawBlending(mode);
+    setupDrawProgram();
+    setupDrawDirtyRegionsDisabled();
+    setupDrawModelView(0.0f, 0.0f, 1.0f, 1.0f);
+    setupDrawColorUniforms();
+    setupDrawShaderUniforms();
+    setupDrawColorFilterUniforms();
+    setupDrawVertices((GLvoid*) &mesh[0].position[0]);
+
+    if (hasLayer()) {
+        dirtyLayer(left, top, right, bottom, *mSnapshot->transform);
+    }
+
+    glDrawArrays(GL_TRIANGLES, 0, vertexCount);
+
+    return DrawGlInfo::kStatusDrew;
+}
+
 void OpenGLRenderer::drawColorRect(float left, float top, float right, float bottom,
         int color, SkXfermode::Mode mode, bool ignoreTransform) {
     // If a shader is set, preserve only the alpha
diff --git a/libs/hwui/OpenGLRenderer.h b/libs/hwui/OpenGLRenderer.h
index 3cafed3..5520edb 100644
--- a/libs/hwui/OpenGLRenderer.h
+++ b/libs/hwui/OpenGLRenderer.h
@@ -201,6 +201,7 @@
             const float* positions, SkPaint* paint);
     virtual status_t drawText(const char* text, int bytesCount, int count, float x, float y,
             const float* positions, SkPaint* paint, float length = -1.0f);
+    virtual status_t drawRects(const float* rects, int count, SkPaint* paint);
 
     virtual void resetShader();
     virtual void setupShader(SkiaShader* shader);
@@ -216,6 +217,10 @@
 
     SkPaint* filterPaint(SkPaint* paint);
 
+    ANDROID_API bool isCurrentTransformSimple() {
+        return mSnapshot->transform->isSimple();
+    }
+
     /**
      * Sets the alpha on the current snapshot. This alpha value will be modulated
      * with other alpha values when drawing primitives.
diff --git a/libs/hwui/Patch.cpp b/libs/hwui/Patch.cpp
index 902c82f..e490151 100644
--- a/libs/hwui/Patch.cpp
+++ b/libs/hwui/Patch.cpp
@@ -37,7 +37,7 @@
     // 2 triangles per patch, 3 vertices per triangle
     uint32_t maxVertices = ((xCount + 1) * (yCount + 1) - emptyQuads) * 2 * 3;
     mVertices = new TextureVertex[maxVertices];
-    mUploaded = false;
+    mAllocatedVerticesCount = 0;
 
     verticesCount = 0;
     hasEmptyQuads = emptyQuads > 0;
@@ -68,38 +68,37 @@
     memcpy(mYDivs, yDivs, mYCount * sizeof(int32_t));
 }
 
-void Patch::copy(const int32_t* yDivs) {
-    memcpy(mYDivs, yDivs, mYCount * sizeof(int32_t));
-}
-
 void Patch::updateColorKey(const uint32_t colorKey) {
     mColorKey = colorKey;
 }
 
-bool Patch::matches(const int32_t* xDivs, const int32_t* yDivs, const uint32_t colorKey) {
+bool Patch::matches(const int32_t* xDivs, const int32_t* yDivs,
+        const uint32_t colorKey, const int8_t emptyQuads) {
+
+    bool matches = true;
+
+    if (mEmptyQuads != emptyQuads) {
+        mEmptyQuads = emptyQuads;
+        hasEmptyQuads = emptyQuads > 0;
+        matches = false;
+    }
+
     if (mColorKey != colorKey) {
         updateColorKey(colorKey);
-        copy(xDivs, yDivs);
-        return false;
+        matches = false;
     }
 
-    for (uint32_t i = 0; i < mXCount; i++) {
-        if (mXDivs[i] != xDivs[i]) {
-            // The Y divs may or may not match, copy everything
-            copy(xDivs, yDivs);
-            return false;
-        }
+    if (memcmp(mXDivs, xDivs, mXCount * sizeof(int32_t))) {
+        memcpy(mXDivs, xDivs, mXCount * sizeof(int32_t));
+        matches = false;
     }
 
-    for (uint32_t i = 0; i < mYCount; i++) {
-        if (mYDivs[i] != yDivs[i]) {
-            // We know all the X divs match, copy only Y divs
-            copy(yDivs);
-            return false;
-        }
+    if (memcmp(mYDivs, yDivs, mYCount * sizeof(int32_t))) {
+        memcpy(mYDivs, yDivs, mYCount * sizeof(int32_t));
+        matches = false;
     }
 
-    return true;
+    return matches;
 }
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -203,10 +202,10 @@
     if (verticesCount > 0) {
         Caches& caches = Caches::getInstance();
         caches.bindMeshBuffer(meshBuffer);
-        if (!mUploaded) {
+        if (mAllocatedVerticesCount < verticesCount) {
             glBufferData(GL_ARRAY_BUFFER, sizeof(TextureVertex) * verticesCount,
                     mVertices, GL_DYNAMIC_DRAW);
-            mUploaded = true;
+            mAllocatedVerticesCount = verticesCount;
         } else {
             glBufferSubData(GL_ARRAY_BUFFER, 0,
                     sizeof(TextureVertex) * verticesCount, mVertices);
diff --git a/libs/hwui/Patch.h b/libs/hwui/Patch.h
index 0518d91..cab0e54 100644
--- a/libs/hwui/Patch.h
+++ b/libs/hwui/Patch.h
@@ -45,7 +45,7 @@
  * indices to render the vertices.
  */
 struct Patch {
-    Patch(const uint32_t xCount, const uint32_t yCount, const int8_t emptyQuads = 0);
+    Patch(const uint32_t xCount, const uint32_t yCount, const int8_t emptyQuads);
     ~Patch();
 
     void updateVertices(const float bitmapWidth, const float bitmapHeight,
@@ -53,7 +53,8 @@
 
     void updateColorKey(const uint32_t colorKey);
     void copy(const int32_t* xDivs, const int32_t* yDivs);
-    bool matches(const int32_t* xDivs, const int32_t* yDivs, const uint32_t colorKey);
+    bool matches(const int32_t* xDivs, const int32_t* yDivs,
+            const uint32_t colorKey, const int8_t emptyQuads);
 
     GLuint meshBuffer;
     uint32_t verticesCount;
@@ -62,7 +63,7 @@
 
 private:
     TextureVertex* mVertices;
-    bool mUploaded;
+    uint32_t mAllocatedVerticesCount;
 
     int32_t* mXDivs;
     int32_t* mYDivs;
@@ -72,8 +73,6 @@
     uint32_t mYCount;
     int8_t mEmptyQuads;
 
-    void copy(const int32_t* yDivs);
-
     void generateRow(TextureVertex*& vertex, float y1, float y2,
             float v1, float v2, float stretchX, float rescaleX,
             float width, float bitmapWidth, uint32_t& quadCount);
diff --git a/libs/hwui/PatchCache.cpp b/libs/hwui/PatchCache.cpp
index 9702c3d..8ee8f5c 100644
--- a/libs/hwui/PatchCache.cpp
+++ b/libs/hwui/PatchCache.cpp
@@ -97,7 +97,7 @@
         }
 
         mCache.add(description, mesh);
-    } else if (!mesh->matches(xDivs, yDivs, colorKey)) {
+    } else if (!mesh->matches(xDivs, yDivs, colorKey, transparentQuads)) {
         PATCH_LOGD("Patch mesh does not match, refreshing vertices");
         mesh->updateVertices(bitmapWidth, bitmapHeight, 0.0f, 0.0f, pixelWidth, pixelHeight);
     }
diff --git a/libs/hwui/PathCache.cpp b/libs/hwui/PathCache.cpp
index 03ddf59..4f682ed 100644
--- a/libs/hwui/PathCache.cpp
+++ b/libs/hwui/PathCache.cpp
@@ -93,9 +93,6 @@
     PathCacheEntry entry(path, paint);
     PathTexture* texture = mCache.get(entry);
 
-    float left, top, offset;
-    uint32_t width, height;
-
     if (!texture) {
         texture = addTexture(entry, path, paint);
     } else if (path->getGenerationID() != texture->generation) {
diff --git a/libs/hwui/font/Font.cpp b/libs/hwui/font/Font.cpp
index 7bfa63d..34afe97 100644
--- a/libs/hwui/font/Font.cpp
+++ b/libs/hwui/font/Font.cpp
@@ -18,6 +18,8 @@
 
 #include <cutils/compiler.h>
 
+#include <utils/JenkinsHash.h>
+
 #include <SkUtils.h>
 
 #include "Debug.h"
@@ -33,14 +35,22 @@
 // Font
 ///////////////////////////////////////////////////////////////////////////////
 
-Font::Font(FontRenderer* state, uint32_t fontId, float fontSize,
-        int flags, uint32_t italicStyle, uint32_t scaleX,
-        SkPaint::Style style, uint32_t strokeWidth) :
-        mState(state), mFontId(fontId), mFontSize(fontSize),
-        mFlags(flags), mItalicStyle(italicStyle), mScaleX(scaleX),
-        mStyle(style), mStrokeWidth(mStrokeWidth) {
+Font::Font(FontRenderer* state, const Font::FontDescription& desc) :
+        mState(state), mDescription(desc) {
 }
 
+Font::FontDescription::FontDescription(const SkPaint* paint, const mat4& matrix) {
+    mFontId = SkTypeface::UniqueID(paint->getTypeface());
+    mFontSize = paint->getTextSize();
+    mFlags = 0;
+    if (paint->isFakeBoldText()) {
+        mFlags |= Font::kFakeBold;
+    }
+    mItalicStyle = paint->getTextSkewX();
+    mScaleX = paint->getTextScaleX();
+    mStyle = paint->getStyle();
+    mStrokeWidth = paint->getStrokeWidth();
+}
 
 Font::~Font() {
     mState->removeFont(this);
@@ -50,6 +60,43 @@
     }
 }
 
+hash_t Font::FontDescription::hash() const {
+    uint32_t hash = JenkinsHashMix(0, mFontId);
+    hash = JenkinsHashMix(hash, android::hash_type(mFontSize));
+    hash = JenkinsHashMix(hash, android::hash_type(mFlags));
+    hash = JenkinsHashMix(hash, android::hash_type(mItalicStyle));
+    hash = JenkinsHashMix(hash, android::hash_type(mScaleX));
+    hash = JenkinsHashMix(hash, android::hash_type(mStyle));
+    hash = JenkinsHashMix(hash, android::hash_type(mStrokeWidth));
+    return JenkinsHashWhiten(hash);
+}
+
+int Font::FontDescription::compare(const Font::FontDescription& lhs,
+        const Font::FontDescription& rhs) {
+    int deltaInt = int(lhs.mFontId) - int(rhs.mFontId);
+    if (deltaInt != 0) return deltaInt;
+
+    if (lhs.mFontSize < rhs.mFontSize) return -1;
+    if (lhs.mFontSize > rhs.mFontSize) return +1;
+
+    if (lhs.mItalicStyle < rhs.mItalicStyle) return -1;
+    if (lhs.mItalicStyle > rhs.mItalicStyle) return +1;
+
+    deltaInt = int(lhs.mFlags) - int(rhs.mFlags);
+    if (deltaInt != 0) return deltaInt;
+
+    if (lhs.mScaleX < rhs.mScaleX) return -1;
+    if (lhs.mScaleX > rhs.mScaleX) return +1;
+
+    deltaInt = int(lhs.mStyle) - int(rhs.mStyle);
+    if (deltaInt != 0) return deltaInt;
+
+    if (lhs.mStrokeWidth < rhs.mStrokeWidth) return -1;
+    if (lhs.mStrokeWidth > rhs.mStrokeWidth) return +1;
+
+    return 0;
+}
+
 void Font::invalidateTextureCache(CacheTexture* cacheTexture) {
     for (uint32_t i = 0; i < mCachedGlyphs.size(); i++) {
         CachedGlyphInfo* cachedGlyph = mCachedGlyphs.valueAt(i);
@@ -83,17 +130,17 @@
 
 void Font::drawCachedGlyph(CachedGlyphInfo* glyph, int x, int y,
         uint8_t* bitmap, uint32_t bitmapW, uint32_t bitmapH, Rect* bounds, const float* pos) {
-    int nPenX = x + glyph->mBitmapLeft;
-    int nPenY = y + glyph->mBitmapTop + glyph->mBitmapHeight;
+    float nPenX = x + glyph->mBitmapLeft;
+    float nPenY = y + (glyph->mBitmapTop + glyph->mBitmapHeight);
+
+    float width = (float) glyph->mBitmapWidth;
+    float height = (float) glyph->mBitmapHeight;
 
     float u1 = glyph->mBitmapMinU;
     float u2 = glyph->mBitmapMaxU;
     float v1 = glyph->mBitmapMinV;
     float v2 = glyph->mBitmapMaxV;
 
-    int width = (int) glyph->mBitmapWidth;
-    int height = (int) glyph->mBitmapHeight;
-
     mState->appendMeshQuad(nPenX, nPenY, u1, v2,
             nPenX + width, nPenY, u2, v2,
             nPenX + width, nPenY - height, u2, v1,
@@ -136,7 +183,7 @@
     vOffset += glyph->mBitmapTop + height;
 
     SkPoint destination[4];
-    measure.getPosTan(x + hOffset +  glyph->mBitmapLeft + halfWidth, position, tangent);
+    measure.getPosTan(x + hOffset + glyph->mBitmapLeft + halfWidth, position, tangent);
 
     // Move along the tangent and offset by the normal
     destination[0].set(-tangent->fX * halfWidth - tangent->fY * vOffset,
@@ -176,24 +223,13 @@
 
     // Is the glyph still in texture cache?
     if (!cachedGlyph->mIsValid) {
-        const SkGlyph& skiaGlyph = GET_METRICS(paint, textUnit);
+        const SkGlyph& skiaGlyph = GET_METRICS(paint, textUnit, NULL);
         updateGlyphCache(paint, skiaGlyph, cachedGlyph, precaching);
     }
 
     return cachedGlyph;
 }
 
-void Font::render(SkPaint* paint, const char* text, uint32_t start, uint32_t len,
-        int numGlyphs, int x, int y, uint8_t *bitmap, uint32_t bitmapW, uint32_t bitmapH) {
-    if (bitmap != NULL && bitmapW > 0 && bitmapH > 0) {
-        render(paint, text, start, len, numGlyphs, x, y, BITMAP, bitmap,
-                bitmapW, bitmapH, NULL, NULL);
-    } else {
-        render(paint, text, start, len, numGlyphs, x, y, FRAMEBUFFER, NULL,
-                0, 0, NULL, NULL);
-    }
-}
-
 void Font::render(SkPaint* paint, const char *text, uint32_t start, uint32_t len,
             int numGlyphs, int x, int y, const float* positions) {
     render(paint, text, start, len, numGlyphs, x, y, FRAMEBUFFER, NULL,
@@ -298,71 +334,40 @@
     text += start;
     int glyphsCount = 0;
 
-    if (CC_LIKELY(positions == NULL)) {
-        SkFixed prevRsbDelta = 0;
+    const SkPaint::Align align = paint->getTextAlign();
 
-        float penX = x + 0.5f;
-        int penY = y;
+    while (glyphsCount < numGlyphs) {
+        glyph_t glyph = GET_GLYPH(text);
 
-        while (glyphsCount < numGlyphs) {
-            glyph_t glyph = GET_GLYPH(text);
-
-            // Reached the end of the string
-            if (IS_END_OF_STRING(glyph)) {
-                break;
-            }
-
-            CachedGlyphInfo* cachedGlyph = getCachedGlyph(paint, glyph);
-            penX += SkFixedToFloat(AUTO_KERN(prevRsbDelta, cachedGlyph->mLsbDelta));
-            prevRsbDelta = cachedGlyph->mRsbDelta;
-
-            // If it's still not valid, we couldn't cache it, so we shouldn't draw garbage
-            if (cachedGlyph->mIsValid) {
-                (*this.*render)(cachedGlyph, (int) floorf(penX), penY,
-                        bitmap, bitmapW, bitmapH, bounds, positions);
-            }
-
-            penX += SkFixedToFloat(cachedGlyph->mAdvanceX);
-
-            glyphsCount++;
+        // Reached the end of the string
+        if (IS_END_OF_STRING(glyph)) {
+            break;
         }
-    } else {
-        const SkPaint::Align align = paint->getTextAlign();
 
-        // This is for renderPosText()
-        while (glyphsCount < numGlyphs) {
-            glyph_t glyph = GET_GLYPH(text);
+        CachedGlyphInfo* cachedGlyph = getCachedGlyph(paint, glyph);
 
-            // Reached the end of the string
-            if (IS_END_OF_STRING(glyph)) {
-                break;
+        // If it's still not valid, we couldn't cache it, so we shouldn't draw garbage
+        if (cachedGlyph->mIsValid) {
+            int penX = x + positions[(glyphsCount << 1)];
+            int penY = y + positions[(glyphsCount << 1) + 1];
+
+            switch (align) {
+                case SkPaint::kRight_Align:
+                    penX -= SkFixedToFloat(cachedGlyph->mAdvanceX);
+                    penY -= SkFixedToFloat(cachedGlyph->mAdvanceY);
+                    break;
+                case SkPaint::kCenter_Align:
+                    penX -= SkFixedToFloat(cachedGlyph->mAdvanceX >> 1);
+                    penY -= SkFixedToFloat(cachedGlyph->mAdvanceY >> 1);
+                default:
+                    break;
             }
 
-            CachedGlyphInfo* cachedGlyph = getCachedGlyph(paint, glyph);
-
-            // If it's still not valid, we couldn't cache it, so we shouldn't draw garbage
-            if (cachedGlyph->mIsValid) {
-                int penX = x + positions[(glyphsCount << 1)];
-                int penY = y + positions[(glyphsCount << 1) + 1];
-
-                switch (align) {
-                    case SkPaint::kRight_Align:
-                        penX -= SkFixedToFloat(cachedGlyph->mAdvanceX);
-                        penY -= SkFixedToFloat(cachedGlyph->mAdvanceY);
-                        break;
-                    case SkPaint::kCenter_Align:
-                        penX -= SkFixedToFloat(cachedGlyph->mAdvanceX >> 1);
-                        penY -= SkFixedToFloat(cachedGlyph->mAdvanceY >> 1);
-                    default:
-                        break;
-                }
-
-                (*this.*render)(cachedGlyph, penX, penY,
-                        bitmap, bitmapW, bitmapH, bounds, positions);
-            }
-
-            glyphsCount++;
+            (*this.*render)(cachedGlyph, penX, penY,
+                    bitmap, bitmapW, bitmapH, bounds, positions);
         }
+
+        glyphsCount++;
     }
 }
 
@@ -379,7 +384,7 @@
     uint32_t startY = 0;
 
     // Get the bitmap for the glyph
-    paint->findImage(skiaGlyph);
+    paint->findImage(skiaGlyph, NULL);
     mState->cacheBitmap(skiaGlyph, glyph, &startX, &startY, precaching);
 
     if (!glyph->mIsValid) {
@@ -409,7 +414,7 @@
     CachedGlyphInfo* newGlyph = new CachedGlyphInfo();
     mCachedGlyphs.add(glyph, newGlyph);
 
-    const SkGlyph& skiaGlyph = GET_METRICS(paint, glyph);
+    const SkGlyph& skiaGlyph = GET_METRICS(paint, glyph, NULL);
     newGlyph->mGlyphIndex = skiaGlyph.fID;
     newGlyph->mIsValid = false;
 
@@ -418,24 +423,16 @@
     return newGlyph;
 }
 
-Font* Font::create(FontRenderer* state, uint32_t fontId, float fontSize,
-        int flags, uint32_t italicStyle, uint32_t scaleX,
-        SkPaint::Style style, uint32_t strokeWidth) {
-    Vector<Font*> &activeFonts = state->mActiveFonts;
+Font* Font::create(FontRenderer* state, const SkPaint* paint, const mat4& matrix) {
+    FontDescription description(paint, matrix);
+    Font* font = state->mActiveFonts.get(description);
 
-    for (uint32_t i = 0; i < activeFonts.size(); i++) {
-        Font* font = activeFonts[i];
-        if (font->mFontId == fontId && font->mFontSize == fontSize &&
-                font->mFlags == flags && font->mItalicStyle == italicStyle &&
-                font->mScaleX == scaleX && font->mStyle == style &&
-                (style == SkPaint::kFill_Style || font->mStrokeWidth == strokeWidth)) {
-            return font;
-        }
+    if (font) {
+        return font;
     }
 
-    Font* newFont = new Font(state, fontId, fontSize, flags, italicStyle,
-            scaleX, style, strokeWidth);
-    activeFonts.push(newFont);
+    Font* newFont = new Font(state, description);
+    state->mActiveFonts.put(description, newFont);
     return newFont;
 }
 
diff --git a/libs/hwui/font/Font.h b/libs/hwui/font/Font.h
index 7cab31e..6ddf162 100644
--- a/libs/hwui/font/Font.h
+++ b/libs/hwui/font/Font.h
@@ -25,6 +25,7 @@
 
 #include "CachedGlyphInfo.h"
 #include "../Rect.h"
+#include "../Matrix.h"
 
 namespace android {
 namespace uirenderer {
@@ -45,31 +46,52 @@
         kFakeBold = 1
     };
 
+    struct FontDescription {
+        FontDescription(const SkPaint* paint, const mat4& matrix);
+
+        static int compare(const FontDescription& lhs, const FontDescription& rhs);
+
+        hash_t hash() const;
+
+        bool operator==(const FontDescription& other) const {
+            return compare(*this, other) == 0;
+        }
+
+        bool operator!=(const FontDescription& other) const {
+            return compare(*this, other) != 0;
+        }
+
+        SkFontID mFontId;
+        float mFontSize;
+        int mFlags;
+        float mItalicStyle;
+        float mScaleX;
+        uint8_t mStyle;
+        float mStrokeWidth;
+    };
+
     ~Font();
 
-    /**
-     * Renders the specified string of text.
-     * If bitmap is specified, it will be used as the render target
-     */
-    void render(SkPaint* paint, const char *text, uint32_t start, uint32_t len,
-            int numGlyphs, int x, int y, uint8_t *bitmap = NULL,
-            uint32_t bitmapW = 0, uint32_t bitmapH = 0);
-
-    void render(SkPaint* paint, const char *text, uint32_t start, uint32_t len,
+    void render(SkPaint* paint, const char* text, uint32_t start, uint32_t len,
             int numGlyphs, int x, int y, const float* positions);
 
-    void render(SkPaint* paint, const char *text, uint32_t start, uint32_t len,
+    void render(SkPaint* paint, const char* text, uint32_t start, uint32_t len,
             int numGlyphs, SkPath* path, float hOffset, float vOffset);
 
+    const Font::FontDescription& getDescription() const {
+        return mDescription;
+    }
+
     /**
      * Creates a new font associated with the specified font state.
      */
-    static Font* create(FontRenderer* state, uint32_t fontId, float fontSize,
-            int flags, uint32_t italicStyle, uint32_t scaleX, SkPaint::Style style,
-            uint32_t strokeWidth);
+    static Font* create(FontRenderer* state, const SkPaint* paint, const mat4& matrix);
 
 private:
     friend class FontRenderer;
+
+    Font(FontRenderer* state, const Font::FontDescription& desc);
+
     typedef void (Font::*RenderGlyph)(CachedGlyphInfo*, int, int, uint8_t*,
             uint32_t, uint32_t, Rect*, const float*);
 
@@ -88,12 +110,6 @@
     void measure(SkPaint* paint, const char* text, uint32_t start, uint32_t len,
             int numGlyphs, Rect *bounds, const float* positions);
 
-    Font(FontRenderer* state, uint32_t fontId, float fontSize, int flags, uint32_t italicStyle,
-            uint32_t scaleX, SkPaint::Style style, uint32_t strokeWidth);
-
-    // Cache of glyphs
-    DefaultKeyedVector<glyph_t, CachedGlyphInfo*> mCachedGlyphs;
-
     void invalidateTextureCache(CacheTexture* cacheTexture = NULL);
 
     CachedGlyphInfo* cacheGlyph(SkPaint* paint, glyph_t glyph, bool precaching);
@@ -115,15 +131,25 @@
     CachedGlyphInfo* getCachedGlyph(SkPaint* paint, glyph_t textUnit, bool precaching = false);
 
     FontRenderer* mState;
-    uint32_t mFontId;
-    float mFontSize;
-    int mFlags;
-    uint32_t mItalicStyle;
-    uint32_t mScaleX;
-    SkPaint::Style mStyle;
-    uint32_t mStrokeWidth;
+    FontDescription mDescription;
+
+    // Cache of glyphs
+    DefaultKeyedVector<glyph_t, CachedGlyphInfo*> mCachedGlyphs;
 };
 
+inline int strictly_order_type(const Font::FontDescription& lhs,
+        const Font::FontDescription& rhs) {
+    return Font::FontDescription::compare(lhs, rhs) < 0;
+}
+
+inline int compare_type(const Font::FontDescription& lhs, const Font::FontDescription& rhs) {
+    return Font::FontDescription::compare(lhs, rhs);
+}
+
+inline hash_t hash_type(const Font::FontDescription& entry) {
+    return entry.hash();
+}
+
 }; // namespace uirenderer
 }; // namespace android
 
diff --git a/libs/hwui/font/FontUtil.h b/libs/hwui/font/FontUtil.h
index 12247ba..4f9c46b 100644
--- a/libs/hwui/font/FontUtil.h
+++ b/libs/hwui/font/FontUtil.h
@@ -37,7 +37,7 @@
 #if RENDER_TEXT_AS_GLYPHS
     typedef uint16_t glyph_t;
     #define TO_GLYPH(g) g
-    #define GET_METRICS(paint, glyph) paint->getGlyphMetrics(glyph)
+    #define GET_METRICS(paint, glyph, matrix) paint->getGlyphMetrics(glyph, matrix)
     #define GET_GLYPH(text) nextGlyph((const uint16_t**) &text)
     #define IS_END_OF_STRING(glyph) false
 
@@ -50,7 +50,7 @@
 #else
     typedef SkUnichar glyph_t;
     #define TO_GLYPH(g) ((SkUnichar) g)
-    #define GET_METRICS(paint, glyph) paint->getUnicharMetrics(glyph)
+    #define GET_METRICS(paint, glyph, matrix) paint->getUnicharMetrics(glyph, matrix)
     #define GET_GLYPH(text) SkUTF16_NextUnichar((const uint16_t**) &text)
     #define IS_END_OF_STRING(glyph) glyph < 0
 #endif
diff --git a/location/java/android/location/ILocationManager.aidl b/location/java/android/location/ILocationManager.aidl
index f663e0a..c353ec6 100644
--- a/location/java/android/location/ILocationManager.aidl
+++ b/location/java/android/location/ILocationManager.aidl
@@ -47,7 +47,7 @@
 
     Location getLastLocation(in LocationRequest request, String packageName);
 
-    boolean addGpsStatusListener(IGpsStatusListener listener);
+    boolean addGpsStatusListener(IGpsStatusListener listener, String packageName);
     void removeGpsStatusListener(IGpsStatusListener listener);
 
     boolean geocoderIsPresent();
diff --git a/location/java/android/location/LocationManager.java b/location/java/android/location/LocationManager.java
index 5a2f71b..0b9286e 100644
--- a/location/java/android/location/LocationManager.java
+++ b/location/java/android/location/LocationManager.java
@@ -1461,7 +1461,7 @@
         }
         try {
             GpsStatusListenerTransport transport = new GpsStatusListenerTransport(listener);
-            result = mService.addGpsStatusListener(transport);
+            result = mService.addGpsStatusListener(transport, mContext.getPackageName());
             if (result) {
                 mGpsStatusListeners.put(listener, transport);
             }
@@ -1507,7 +1507,7 @@
         }
         try {
             GpsStatusListenerTransport transport = new GpsStatusListenerTransport(listener);
-            result = mService.addGpsStatusListener(transport);
+            result = mService.addGpsStatusListener(transport, mContext.getPackageName());
             if (result) {
                 mNmeaListeners.put(listener, transport);
             }
diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java
index 9aac0e6..ed2a8da 100644
--- a/media/java/android/media/AudioService.java
+++ b/media/java/android/media/AudioService.java
@@ -5708,17 +5708,19 @@
     private void onRegisterVolumeObserverForRcc(int rccId, IRemoteVolumeObserver rvo) {
         synchronized(mRCStack) {
             // The stack traversal order doesn't matter because there is only one stack entry
-            //  with this RCC ID, and we can stop iterating over the stack entries once the matching
-            //  ID has been found.
-            // FIXME optimize by traversing stack from top to bottom, the matching ID is more likely
-            //  at the top of the stack
-            Iterator<RemoteControlStackEntry> stackIterator = mRCStack.iterator();
-            while(stackIterator.hasNext()) {
-                RemoteControlStackEntry rcse = stackIterator.next();
-                if (rcse.mRccId == rccId) {
-                    rcse.mRemoteVolumeObs = rvo;
-                    break;
+            //  with this RCC ID, but the matching ID is more likely at the top of the stack, so
+            //  start iterating from the top.
+            try {
+                for (int index = mRCStack.size()-1; index >= 0; index--) {
+                    final RemoteControlStackEntry rcse = mRCStack.elementAt(index);
+                    if (rcse.mRccId == rccId) {
+                        rcse.mRemoteVolumeObs = rvo;
+                        break;
+                    }
                 }
+            } catch (ArrayIndexOutOfBoundsException e) {
+                // not expected to happen, indicates improper concurrent modification
+                Log.e(TAG, "Wrong index accessing media button stack, lock error? ", e);
             }
         }
     }
@@ -5813,18 +5815,20 @@
         IRemoteVolumeObserver rvo = null;
         synchronized (mRCStack) {
             // The stack traversal order doesn't matter because there is only one stack entry
-            //  with this RCC ID, and we can stop iterating over the stack entries once the matching
-            //  ID has been found.
-            // FIXME optimize by traversing stack from top to bottom, the matching ID is more likely
-            //  at the top of the stack
-            Iterator<RemoteControlStackEntry> stackIterator = mRCStack.iterator();
-            while(stackIterator.hasNext()) {
-                RemoteControlStackEntry rcse = stackIterator.next();
-                //FIXME OPTIMIZE store this info in mMainRemote so we don't have to iterate?
-                if (rcse.mRccId == rccId) {
-                    rvo = rcse.mRemoteVolumeObs;
-                    break;
+            //  with this RCC ID, but the matching ID is more likely at the top of the stack, so
+            //  start iterating from the top.
+            try {
+                for (int index = mRCStack.size()-1; index >= 0; index--) {
+                    final RemoteControlStackEntry rcse = mRCStack.elementAt(index);
+                    //FIXME OPTIMIZE store this info in mMainRemote so we don't have to iterate?
+                    if (rcse.mRccId == rccId) {
+                        rvo = rcse.mRemoteVolumeObs;
+                        break;
+                    }
                 }
+            } catch (ArrayIndexOutOfBoundsException e) {
+                // not expected to happen, indicates improper concurrent modification
+                Log.e(TAG, "Wrong index accessing media button stack, lock error? ", e);
             }
         }
         if (rvo != null) {
@@ -5866,18 +5870,20 @@
         IRemoteVolumeObserver rvo = null;
         synchronized (mRCStack) {
             // The stack traversal order doesn't matter because there is only one stack entry
-            //  with this RCC ID, and we can stop iterating over the stack entries once the matching
-            //  ID has been found.
-            // FIXME optimize by traversing stack from top to bottom, the matching ID is more likely
-            //  at the top of the stack
-            Iterator<RemoteControlStackEntry> stackIterator = mRCStack.iterator();
-            while(stackIterator.hasNext()) {
-                RemoteControlStackEntry rcse = stackIterator.next();
-                if (rcse.mRccId == rccId) {
+            //  with this RCC ID, but the matching ID is more likely at the top of the stack, so
+            //  start iterating from the top.
+            try {
+                for (int index = mRCStack.size()-1; index >= 0; index--) {
+                    final RemoteControlStackEntry rcse = mRCStack.elementAt(index);
                     //FIXME OPTIMIZE store this info in mMainRemote so we don't have to iterate?
-                    rvo = rcse.mRemoteVolumeObs;
-                    break;
+                    if (rcse.mRccId == rccId) {
+                        rvo = rcse.mRemoteVolumeObs;
+                        break;
+                    }
                 }
+            } catch (ArrayIndexOutOfBoundsException e) {
+                // not expected to happen, indicates improper concurrent modification
+                Log.e(TAG, "Wrong index accessing media button stack, lock error? ", e);
             }
         }
         if (rvo != null) {
@@ -5991,6 +5997,7 @@
                     }
                 }
             }
+            mVolumePanel.setLayoutDirection(config.getLayoutDirection());
         } catch (Exception e) {
             Log.e(TAG, "Error retrieving device orientation: " + e);
         }
diff --git a/media/java/android/media/MediaScanner.java b/media/java/android/media/MediaScanner.java
index fbbcb0a..7768a61 100644
--- a/media/java/android/media/MediaScanner.java
+++ b/media/java/android/media/MediaScanner.java
@@ -958,7 +958,9 @@
                 // If the rowId of the inserted file is needed, it gets inserted immediately,
                 // bypassing the bulk inserter.
                 if (inserter == null || needToSetSettings) {
-                    inserter.flushAll();
+                    if (inserter != null) {
+                        inserter.flushAll();
+                    }
                     result = mMediaProvider.insert(tableUri, values);
                 } else if (entry.mFormat == MtpConstants.FORMAT_ASSOCIATION) {
                     inserter.insertwithPriority(tableUri, values);
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaRecorderStressTestRunner.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaRecorderStressTestRunner.java
index 95e7b5e..5c74552 100644
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaRecorderStressTestRunner.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaRecorderStressTestRunner.java
@@ -33,18 +33,16 @@
     // the test must be supported by the corresponding camera.
     public static int mCameraId = 0;
     public static int mProfileQuality = CamcorderProfile.QUALITY_HIGH;
-    public static CamcorderProfile profile =
-                        CamcorderProfile.get(mCameraId, mProfileQuality);
-
-    public static int mIterations = 100;
+    public static CamcorderProfile profile = CamcorderProfile.get(mCameraId, mProfileQuality);
+    public static int mIterations = 15;
     public static int mVideoEncoder = profile.videoCodec;
-    public static int mAudioEncdoer = profile.audioCodec;
+    public static int mAudioEncoder = profile.audioCodec;
     public static int mFrameRate = profile.videoFrameRate;
     public static int mVideoWidth = profile.videoFrameWidth;
     public static int mVideoHeight = profile.videoFrameHeight;
     public static int mBitRate = profile.videoBitRate;
     public static boolean mRemoveVideo = true;
-    public static int mDuration = 10 * 1000; // 10 seconds
+    public static int mDuration = 60 * 1000; // 60 seconds
     public static int mTimeLapseDuration = 180 * 1000; // 3 minutes
     public static double mCaptureRate = 0.5; // 2 sec timelapse interval
 
@@ -64,41 +62,41 @@
     public void onCreate(Bundle icicle) {
         super.onCreate(icicle);
         String iterations = (String) icicle.get("iterations");
-        String video_encoder = (String) icicle.get("video_encoder");
-        String audio_encoder = (String) icicle.get("audio_encoder");
-        String frame_rate = (String) icicle.get("frame_rate");
-        String video_width = (String) icicle.get("video_width");
-        String video_height = (String) icicle.get("video_height");
-        String bit_rate = (String) icicle.get("bit_rate");
-        String record_duration = (String) icicle.get("record_duration");
-        String remove_videos = (String) icicle.get("remove_videos");
+        String videoEncoder = (String) icicle.get("video_encoder");
+        String audioEncoder = (String) icicle.get("audio_encoder");
+        String frameRate = (String) icicle.get("frame_rate");
+        String videoWidth = (String) icicle.get("video_width");
+        String videoHeight = (String) icicle.get("video_height");
+        String bitRate = (String) icicle.get("bit_rate");
+        String recordDuration = (String) icicle.get("record_duration");
+        String removeVideos = (String) icicle.get("remove_videos");
 
         if (iterations != null ) {
             mIterations = Integer.parseInt(iterations);
         }
-        if ( video_encoder != null) {
-            mVideoEncoder = Integer.parseInt(video_encoder);
+        if (videoEncoder != null) {
+            mVideoEncoder = Integer.parseInt(videoEncoder);
         }
-        if ( audio_encoder != null) {
-            mAudioEncdoer = Integer.parseInt(audio_encoder);
+        if (audioEncoder != null) {
+            mAudioEncoder = Integer.parseInt(audioEncoder);
         }
-        if (frame_rate != null) {
-            mFrameRate = Integer.parseInt(frame_rate);
+        if (frameRate != null) {
+            mFrameRate = Integer.parseInt(frameRate);
         }
-        if (video_width != null) {
-            mVideoWidth = Integer.parseInt(video_width);
+        if (videoWidth != null) {
+            mVideoWidth = Integer.parseInt(videoWidth);
         }
-        if (video_height != null) {
-            mVideoHeight = Integer.parseInt(video_height);
+        if (videoHeight != null) {
+            mVideoHeight = Integer.parseInt(videoHeight);
         }
-        if (bit_rate != null) {
-            mBitRate = Integer.parseInt(bit_rate);
+        if (bitRate != null) {
+            mBitRate = Integer.parseInt(bitRate);
         }
-        if (record_duration != null) {
-            mDuration = Integer.parseInt(record_duration);
+        if (recordDuration != null) {
+            mDuration = Integer.parseInt(recordDuration);
         }
-        if (remove_videos != null) {
-            if (remove_videos.compareTo("true") == 0) {
+        if (removeVideos != null) {
+            if (removeVideos.compareTo("true") == 0) {
                 mRemoveVideo = true;
             } else {
                 mRemoveVideo = false;
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/stress/CameraStressTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/stress/CameraStressTest.java
index ab9e36c3..ed1d8fc 100644
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/stress/CameraStressTest.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/stress/CameraStressTest.java
@@ -28,6 +28,7 @@
 import java.io.Writer;
 import java.util.concurrent.Semaphore;
 import java.util.concurrent.TimeUnit;
+import java.util.List;
 
 import android.hardware.Camera;
 import android.hardware.Camera.PictureCallback;
@@ -44,7 +45,7 @@
 import junit.framework.Assert;
 
 /**
- * Junit / Instrumentation test case for the camera zoom api
+ * Junit / Instrumentation test case for the camera zoom and scene mode APIs
  *
  * adb shell am instrument
  *  -e class com.android.mediaframeworktest.stress.CameraStressTest
@@ -54,18 +55,22 @@
     private String TAG = "CameraStressTest";
     private Camera mCamera;
 
+    private static final int CAMERA_ID = 0;
     private static final int NUMBER_OF_ZOOM_LOOPS = 100;
+    private static final int NUMBER_OF_SCENE_MODE_LOOPS = 10;
     private static final long WAIT_GENERIC = 3 * 1000; // 3 seconds
     private static final long WAIT_TIMEOUT = 10 * 1000; // 10 seconds
     private static final long WAIT_ZOOM_ANIMATION = 5 * 1000; // 5 seconds
-    private static final String CAMERA_STRESS_OUTPUT =
-            "/sdcard/cameraStressOutput.txt";
-    private static final int CAMERA_ID = 0;
+    private static final String CAMERA_STRESS_IMAGES_DIRECTORY = "cameraStressImages";
+    private static final String CAMERA_STRESS_IMAGES_PREFIX = "camera-stress-test";
+    private static final String CAMERA_STRESS_OUTPUT = "cameraStressOutput.txt";
     private final CameraErrorCallback mCameraErrorCallback = new CameraErrorCallback();
 
     private Thread mLooperThread;
     private Handler mHandler;
 
+    private Writer mOutput;
+
     public CameraStressTest() {
         super("com.android.mediaframeworktest", MediaFrameworkTest.class);
     }
@@ -89,6 +94,20 @@
         }
         getActivity();
         super.setUp();
+
+        File sdcard = Environment.getExternalStorageDirectory();
+
+        // Create the test images directory if it doesn't exist
+        File stressImagesDirectory = new File(String.format("%s/%s", sdcard,
+                CAMERA_STRESS_IMAGES_DIRECTORY));
+        if (!stressImagesDirectory.exists()) {
+            stressImagesDirectory.mkdir();
+        }
+
+        // Start writing output file
+        File stressOutFile = new File(String.format("%s/%s",sdcard, CAMERA_STRESS_OUTPUT));
+        mOutput = new BufferedWriter(new FileWriter(stressOutFile, true));
+        mOutput.write(this.getName() + ":\n");
     }
 
     @Override
@@ -105,6 +124,9 @@
             mLooperThread = null;
         }
 
+        mOutput.write("\n\n");
+        mOutput.close();
+
         super.tearDown();
     }
 
@@ -127,9 +149,7 @@
 
     private final class CameraErrorCallback implements android.hardware.Camera.ErrorCallback {
         public void onError(int error, android.hardware.Camera camera) {
-            if (error == android.hardware.Camera.CAMERA_ERROR_SERVER_DIED) {
-                assertTrue("Camera test mediaserver died", false);
-            }
+            fail(String.format("Camera error, code: %d", error));
         }
     }
 
@@ -154,49 +174,76 @@
 
             try {
                 Log.v(TAG, "JPEG picture taken");
-                fos = new FileOutputStream(String.format("%s/zoom-test-%d.jpg",
-                        Environment.getExternalStorageDirectory(), System.currentTimeMillis()));
+                fos = new FileOutputStream(String.format("%s/%s/%s-%d.jpg",
+                        Environment.getExternalStorageDirectory(), CAMERA_STRESS_IMAGES_DIRECTORY,
+                        CAMERA_STRESS_IMAGES_PREFIX, System.currentTimeMillis()));
                 fos.write(data);
-            }
-            catch (FileNotFoundException e) {
-                Log.v(TAG, "File not found: " + e.toString());
-            }
-            catch (IOException e) {
-                Log.v(TAG, "Error accessing file: " + e.toString());
-            }
-            finally {
+            } catch (FileNotFoundException e) {
+                Log.e(TAG, "File not found: " + e.toString());
+            } catch (IOException e) {
+                Log.e(TAG, "Error accessing file: " + e.toString());
+            } finally {
                 try {
                     if (fos != null) {
                         fos.close();
                     }
-                }
-                catch (IOException e) {
-                    Log.v(TAG, "Error closing file: " + e.toString());
+                } catch (IOException e) {
+                    Log.e(TAG, "Error closing file: " + e.toString());
                 }
             }
         }
     };
 
     // Helper method for cleaning up pics taken during testStressCameraZoom
-    private void cleanupZoomImages() {
+    private void cleanupStressTestImages() {
         try {
-            File sdcard = Environment.getExternalStorageDirectory();
+            File stressImagesDirectory = new File(String.format("%s/%s",
+                    Environment.getExternalStorageDirectory(), CAMERA_STRESS_IMAGES_DIRECTORY));
             File[] zoomImages = null;
 
             FilenameFilter filter = new FilenameFilter() {
                 public boolean accept(File dir, String name) {
-                    return name.startsWith("zoom-test-");
+                    return name.startsWith(CAMERA_STRESS_IMAGES_PREFIX);
                 }
             };
 
-            zoomImages = sdcard.listFiles(filter);
+            zoomImages = stressImagesDirectory.listFiles(filter);
 
             for (File f : zoomImages) {
                 f.delete();
             }
+        } catch (SecurityException e) {
+            Log.e(TAG, "Security manager access violation: " + e.toString());
         }
-        catch (SecurityException e) {
-            Log.v(TAG, "Security manager access violation: " + e.toString());
+    }
+
+    // Helper method for starting up the camera preview
+    private void startCameraPreview(SurfaceHolder surfaceHolder) {
+        try {
+            mCamera.setErrorCallback(mCameraErrorCallback);
+            mCamera.setPreviewDisplay(surfaceHolder);
+            mCamera.startPreview();
+            Thread.sleep(WAIT_GENERIC);
+        } catch (IOException e) {
+            Log.e(TAG, "Error setting preview display: " + e.toString());
+        } catch (InterruptedException e) {
+            Log.e(TAG, "Error waiting for preview to come up: " + e.toString());
+        } catch (Exception e) {
+            Log.e(TAG, "Error starting up camera preview: " + e.toString());
+        }
+    }
+
+    // Helper method for taking a photo
+    private void capturePhoto() {
+        try {
+            mCamera.takePicture(shutterCallback, rawCallback, jpegCallback);
+            Thread.sleep(WAIT_GENERIC);
+            mCamera.stopPreview();
+            mCamera.release();
+        } catch (InterruptedException e) {
+            Log.e(TAG, "Error waiting for photo to be taken: " + e.toString());
+        } catch (Exception e) {
+            Log.e(TAG, "Error capturing photo: " + e.toString());
         }
     }
 
@@ -205,14 +252,11 @@
     public void testStressCameraZoom() throws Exception {
         SurfaceHolder mSurfaceHolder;
         mSurfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder();
-        File stressOutFile = new File(CAMERA_STRESS_OUTPUT);
-        Writer output = new BufferedWriter(new FileWriter(stressOutFile, true));
-        output.write("Camera zoom stress:\n");
-        output.write("Total number of loops: " +  NUMBER_OF_ZOOM_LOOPS + "\n");
+        mOutput.write("Total number of loops: " + NUMBER_OF_ZOOM_LOOPS + "\n");
 
         try {
             Log.v(TAG, "Start preview");
-            output.write("No of loop: ");
+            mOutput.write("No of loop: ");
 
             mCamera = Camera.open(CAMERA_ID);
             Camera.Parameters params = mCamera.getParameters();
@@ -220,9 +264,8 @@
 
             if (!params.isSmoothZoomSupported() && !params.isZoomSupported()) {
                 Log.v(TAG, "Device camera does not support zoom");
-                assertTrue("Camera zoom stress test", false);
-            }
-            else {
+                fail("Camera zoom stress test failed");
+            } else {
                 Log.v(TAG, "Device camera does support zoom");
 
                 int nextZoomLevel = 0;
@@ -235,11 +278,7 @@
                         }
                     });
 
-                    mCamera.setErrorCallback(mCameraErrorCallback);
-                    mCamera.setPreviewDisplay(mSurfaceHolder);
-                    mCamera.startPreview();
-                    Thread.sleep(WAIT_GENERIC);
-
+                    startCameraPreview(mSurfaceHolder);
                     params = mCamera.getParameters();
                     int currentZoomLevel = params.getZoom();
 
@@ -250,8 +289,7 @@
 
                     if (params.isSmoothZoomSupported()) {
                         mCamera.startSmoothZoom(nextZoomLevel);
-                    }
-                    else {
+                    } else {
                         params.setZoom(nextZoomLevel);
                         mCamera.setParameters(params);
                     }
@@ -259,23 +297,66 @@
 
                     // sleep allows for zoom animation to finish
                     Thread.sleep(WAIT_ZOOM_ANIMATION);
+                    capturePhoto();
 
-                    // take picture
-                    mCamera.takePicture(shutterCallback, rawCallback, jpegCallback);
-                    Thread.sleep(WAIT_GENERIC);
-                    mCamera.stopPreview();
-                    mCamera.release();
-                    output.write(" ," + i);
+                    if (i == 0) {
+                        mOutput.write(Integer.toString(i));
+                    } else {
+                        mOutput.write(", " + i);
+                    }
                 }
             }
+            cleanupStressTestImages();
+        } catch (Exception e) {
+            Log.e(TAG, e.toString());
+            fail("Camera zoom stress test Exception");
+        }
+    }
 
-            cleanupZoomImages();
+    // Test case for stressing the camera scene mode feature
+    @LargeTest
+    public void testStressCameraSceneModes() throws Exception {
+        SurfaceHolder mSurfaceHolder;
+        mSurfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder();
+
+        try {
+            mCamera = Camera.open(CAMERA_ID);
+            Camera.Parameters params = mCamera.getParameters();
+            mCamera.release();
+            List<String> supportedSceneModes = params.getSupportedSceneModes();
+            assertNotNull("No scene modes supported", supportedSceneModes);
+
+            mOutput.write("Total number of loops: " +
+                    (NUMBER_OF_SCENE_MODE_LOOPS * supportedSceneModes.size()) + "\n");
+            Log.v(TAG, "Start preview");
+            mOutput.write("No of loop: ");
+
+            for (int i = 0; i < supportedSceneModes.size(); i++) {
+                for (int j = 0; j < NUMBER_OF_SCENE_MODE_LOOPS; j++) {
+                    runOnLooper(new Runnable() {
+                        @Override
+                        public void run() {
+                            mCamera = Camera.open(CAMERA_ID);
+                        }
+                    });
+
+                    startCameraPreview(mSurfaceHolder);
+                    Log.v(TAG, "Setting mode to " + supportedSceneModes.get(i));
+                    params.setSceneMode(supportedSceneModes.get(i));
+                    mCamera.setParameters(params);
+                    capturePhoto();
+
+                    if ((i == 0) && (j == 0)) {
+                        mOutput.write(Integer.toString(j + i * NUMBER_OF_SCENE_MODE_LOOPS));
+                    } else {
+                        mOutput.write(", " + (j + i * NUMBER_OF_SCENE_MODE_LOOPS));
+                    }
+                }
+            }
+            cleanupStressTestImages();
+        } catch (Exception e) {
+            Log.e(TAG, e.toString());
+            fail("Camera scene mode test Exception");
         }
-        catch (Exception e) {
-            assertTrue("Camera zoom stress test Exception", false);
-            Log.v(TAG, e.toString());
-        }
-        output.write("\n\n");
-        output.close();
     }
 }
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/stress/MediaRecorderStressTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/stress/MediaRecorderStressTest.java
index 6995c60..6eb9891 100644
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/stress/MediaRecorderStressTest.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/stress/MediaRecorderStressTest.java
@@ -31,6 +31,7 @@
 import android.media.CamcorderProfile;
 import android.media.MediaPlayer;
 import android.media.MediaRecorder;
+import android.os.Environment;
 import android.os.Handler;
 import android.os.Looper;
 import android.test.ActivityInstrumentationTestCase2;
@@ -48,26 +49,26 @@
     private MediaRecorder mRecorder;
     private Camera mCamera;
 
+    private static final int CAMERA_ID = 0;
     private static final int NUMBER_OF_CAMERA_STRESS_LOOPS = 100;
     private static final int NUMBER_OF_RECORDER_STRESS_LOOPS = 100;
     private static final int NUMBER_OF_RECORDERANDPLAY_STRESS_LOOPS = 50;
     private static final int NUMBER_OF_SWTICHING_LOOPS_BW_CAMERA_AND_RECORDER = 200;
     private static final int NUMBER_OF_TIME_LAPSE_LOOPS = 25;
     private static final int TIME_LAPSE_PLAYBACK_WAIT_TIME = 5* 1000; // 5 seconds
+    private static final int USE_TEST_RUNNER_PROFILE = -1;
+    private static final long WAIT_TIMEOUT = 10 * 1000; // 10 seconds
     private static final long WAIT_TIME_CAMERA_TEST = 3 * 1000; // 3 seconds
     private static final long WAIT_TIME_RECORDER_TEST = 6 * 1000; // 6 seconds
-    private static final String OUTPUT_FILE = "/sdcard/temp";
     private static final String OUTPUT_FILE_EXT = ".3gp";
-    private static final String MEDIA_STRESS_OUTPUT =
-        "/sdcard/mediaStressOutput.txt";
-    private static final int CAMERA_ID = 0;
+    private static final String MEDIA_STRESS_OUTPUT = "mediaStressOutput.txt";
 
     private final CameraErrorCallback mCameraErrorCallback = new CameraErrorCallback();
     private final RecorderErrorCallback mRecorderErrorCallback = new RecorderErrorCallback();
 
-    private final static int WAIT_TIMEOUT = 10 * 1000; // 10 seconds
-    private Thread mLooperThread;
     private Handler mHandler;
+    private Thread mLooperThread;
+    private Writer mOutput;
 
     public MediaRecorderStressTest() {
         super("com.android.mediaframeworktest", MediaFrameworkTest.class);
@@ -95,6 +96,11 @@
         Thread.sleep(2000);
         getActivity();
         super.setUp();
+
+        File stressOutFile = new File(String.format("%s/%s",
+                Environment.getExternalStorageDirectory(), MEDIA_STRESS_OUTPUT));
+        mOutput = new BufferedWriter(new FileWriter(stressOutFile, true));
+        mOutput.write(this.getName() + "\n");
     }
 
     @Override
@@ -110,7 +116,8 @@
             }
             mLooperThread = null;
         }
-
+        mOutput.write("\n\n");
+        mOutput.close();
         super.tearDown();
     }
 
@@ -133,16 +140,13 @@
 
     private final class CameraErrorCallback implements android.hardware.Camera.ErrorCallback {
         public void onError(int error, android.hardware.Camera camera) {
-            if (error == android.hardware.Camera.CAMERA_ERROR_SERVER_DIED) {
-                assertTrue("Camera test mediaserver died", false);
-            }
+            fail(String.format("Camera error, code: %d", error));
         }
     }
 
     private final class RecorderErrorCallback implements MediaRecorder.OnErrorListener {
         public void onError(MediaRecorder mr, int what, int extra) {
-            // fail the test case no matter what error come up
-            assertTrue("mediaRecorder error", false);
+            fail(String.format("Media recorder error, code: %d\textra: %d", what, extra));
         }
     }
 
@@ -151,14 +155,11 @@
     public void testStressCamera() throws Exception {
         SurfaceHolder mSurfaceHolder;
         mSurfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder();
-        File stressOutFile = new File(MEDIA_STRESS_OUTPUT);
-        Writer output = new BufferedWriter(new FileWriter(stressOutFile, true));
-        output.write("Camera start preview stress:\n");
-        output.write("Total number of loops:" +
-                NUMBER_OF_CAMERA_STRESS_LOOPS + "\n");
+        Log.v(TAG, "Camera start preview stress test");
+        mOutput.write("Total number of loops:" + NUMBER_OF_CAMERA_STRESS_LOOPS + "\n");
         try {
             Log.v(TAG, "Start preview");
-            output.write("No of loop: ");
+            mOutput.write("No of loop: ");
 
             for (int i = 0; i< NUMBER_OF_CAMERA_STRESS_LOOPS; i++) {
                 runOnLooper(new Runnable() {
@@ -173,29 +174,27 @@
                 Thread.sleep(WAIT_TIME_CAMERA_TEST);
                 mCamera.stopPreview();
                 mCamera.release();
-                output.write(" ," + i);
+                if (i == 0) {
+                    mOutput.write(i + 1);
+                } else {
+                    mOutput.write(String.format(", %d", (i + 1)));
+                }
             }
         } catch (Exception e) {
-            assertTrue("CameraStressTest", false);
-            Log.v(TAG, e.toString());
+            Log.e(TAG, e.toString());
+            fail("Camera startup preview stress test");
         }
-        output.write("\n\n");
-        output.close();
     }
 
     //Test case for stressing the camera preview.
     @LargeTest
     public void testStressRecorder() throws Exception {
-        String filename;
         SurfaceHolder mSurfaceHolder;
         mSurfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder();
-        File stressOutFile = new File(MEDIA_STRESS_OUTPUT);
-        Writer output = new BufferedWriter(new FileWriter(stressOutFile, true));
-        output.write("H263 video record- reset after prepare Stress test\n");
-        output.write("Total number of loops:" +
-                NUMBER_OF_RECORDER_STRESS_LOOPS + "\n");
+        Log.v(TAG, "H263 video record: reset after prepare Stress test");
+        mOutput.write("Total number of loops:" + NUMBER_OF_RECORDER_STRESS_LOOPS + "\n");
         try {
-            output.write("No of loop: ");
+            mOutput.write("No of loop: ");
             Log.v(TAG, "Start preview");
             for (int i = 0; i < NUMBER_OF_RECORDER_STRESS_LOOPS; i++) {
                 runOnLooper(new Runnable() {
@@ -205,12 +204,15 @@
                     }
                 });
                 Log.v(TAG, "counter = " + i);
-                filename = OUTPUT_FILE + i + OUTPUT_FILE_EXT;
-                Log.v(TAG, filename);
+                String fileName = String.format("%s/temp%d%s",
+                        Environment.getExternalStorageDirectory(),
+                        i, OUTPUT_FILE_EXT);
+
+                Log.v(TAG, fileName);
                 mRecorder.setOnErrorListener(mRecorderErrorCallback);
                 mRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
                 mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
-                mRecorder.setOutputFile(filename);
+                mRecorder.setOutputFile(fileName);
                 mRecorder.setVideoFrameRate(MediaRecorderStressTestRunner.mFrameRate);
                 mRecorder.setVideoSize(176,144);
                 Log.v(TAG, "setEncoder");
@@ -224,30 +226,29 @@
                 Thread.sleep(WAIT_TIME_RECORDER_TEST);
                 mRecorder.reset();
                 mRecorder.release();
-                output.write(", " + i);
+                if (i == 0) {
+                    mOutput.write(i + 1);
+                } else {
+                    mOutput.write(String.format(", %d", (i + 1)));
+                }
             }
         } catch (Exception e) {
-            assertTrue("Recorder Stress test", false);
-            Log.v(TAG, e.toString());
+            Log.e(TAG, e.toString());
+            fail("H263 video recording stress test");
         }
-        output.write("\n\n");
-        output.close();
     }
 
     //Stress test case for switching camera and video recorder preview.
     @LargeTest
     public void testStressCameraSwitchRecorder() throws Exception {
-        String filename;
         SurfaceHolder mSurfaceHolder;
         mSurfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder();
-        File stressOutFile = new File(MEDIA_STRESS_OUTPUT);
-        Writer output = new BufferedWriter(new FileWriter(stressOutFile, true));
-        output.write("Camera and video recorder preview switching\n");
-        output.write("Total number of loops:"
-                + NUMBER_OF_SWTICHING_LOOPS_BW_CAMERA_AND_RECORDER + "\n");
+        Log.v(TAG, "Camera and video recorder preview switching");
+        mOutput.write("Total number of loops: " +
+                NUMBER_OF_SWTICHING_LOOPS_BW_CAMERA_AND_RECORDER + "\n");
         try {
             Log.v(TAG, "Start preview");
-            output.write("No of loop: ");
+            mOutput.write("No of loop: ");
             for (int i = 0; i < NUMBER_OF_SWTICHING_LOOPS_BW_CAMERA_AND_RECORDER; i++) {
                 runOnLooper(new Runnable() {
                     @Override
@@ -263,8 +264,10 @@
                 mCamera.release();
                 mCamera = null;
                 Log.v(TAG, "release camera");
-                filename = OUTPUT_FILE + i + OUTPUT_FILE_EXT;
-                Log.v(TAG, filename);
+                String fileName = String.format("%s/temp%d%s",
+                        Environment.getExternalStorageDirectory(),
+                        i, OUTPUT_FILE_EXT);
+                Log.v(TAG, fileName);
                 runOnLooper(new Runnable() {
                     @Override
                     public void run() {
@@ -274,7 +277,7 @@
                 mRecorder.setOnErrorListener(mRecorderErrorCallback);
                 mRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
                 mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
-                mRecorder.setOutputFile(filename);
+                mRecorder.setOutputFile(fileName);
                 mRecorder.setVideoFrameRate(MediaRecorderStressTestRunner.mFrameRate);
                 mRecorder.setVideoSize(176,144);
                 Log.v(TAG, "Media recorder setEncoder");
@@ -287,117 +290,167 @@
                 Thread.sleep(WAIT_TIME_CAMERA_TEST);
                 mRecorder.release();
                 Log.v(TAG, "release video recorder");
-                output.write(", " + i);
+                if (i == 0) {
+                    mOutput.write(i + 1);
+                } else {
+                    mOutput.write(String.format(", %d", (i + 1)));
+                }
             }
         } catch (Exception e) {
-            assertTrue("Camer and recorder switch mode", false);
-                Log.v(TAG, e.toString());
+            Log.e(TAG, e.toString());
+            fail("Camera and recorder switch mode");
         }
-        output.write("\n\n");
-        output.close();
     }
 
-    public void validateRecordedVideo(String recorded_file) {
+    public void validateRecordedVideo(String recordedFile) {
         try {
             MediaPlayer mp = new MediaPlayer();
-            mp.setDataSource(recorded_file);
+            mp.setDataSource(recordedFile);
             mp.prepare();
             int duration = mp.getDuration();
             if (duration <= 0){
-                assertTrue("stressRecordAndPlayback", false);
+                fail("stressRecordAndPlayback");
             }
             mp.release();
         } catch (Exception e) {
-            assertTrue("stressRecordAndPlayback", false);
+            fail("stressRecordAndPlayback");
         }
     }
 
-    public void removeRecordedVideo(String filename){
-        File video = new File(filename);
-        Log.v(TAG, "remove recorded video " + filename);
+    public void removeRecordedVideo(String fileName){
+        File video = new File(fileName);
+        Log.v(TAG, "remove recorded video " + fileName);
         video.delete();
     }
 
-    //Stress test case for record a video and play right away.
-    @LargeTest
-    public void testStressRecordVideoAndPlayback() throws Exception {
-        int iterations = MediaRecorderStressTestRunner.mIterations;
-        int video_encoder = MediaRecorderStressTestRunner.mVideoEncoder;
-        int audio_encoder = MediaRecorderStressTestRunner.mAudioEncdoer;
-        int frame_rate = MediaRecorderStressTestRunner.mFrameRate;
-        int video_width = MediaRecorderStressTestRunner.mVideoWidth;
-        int video_height = MediaRecorderStressTestRunner.mVideoHeight;
-        int bit_rate = MediaRecorderStressTestRunner.mBitRate;
-        boolean remove_video = MediaRecorderStressTestRunner.mRemoveVideo;
-        int record_duration = MediaRecorderStressTestRunner.mDuration;
+    // Helper method for record & playback testing with different camcorder profiles
+    private void recordVideoAndPlayback(int profile) throws Exception {
+        int iterations;
+        int recordDuration;
+        boolean removeVideo;
 
-        String filename;
-        SurfaceHolder mSurfaceHolder;
-        mSurfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder();
-        File stressOutFile = new File(MEDIA_STRESS_OUTPUT);
-        Writer output = new BufferedWriter(
-                new FileWriter(stressOutFile, true));
-        output.write("Video record and play back stress test:\n");
-        output.write("Total number of loops:"
-                + NUMBER_OF_RECORDERANDPLAY_STRESS_LOOPS + "\n");
+        int videoEncoder;
+        int audioEncoder;
+        int frameRate;
+        int videoWidth;
+        int videoHeight;
+        int bitRate;
+
+        if (profile != USE_TEST_RUNNER_PROFILE) {
+            assertTrue(String.format("Camera doesn't support profile %d", profile),
+                    CamcorderProfile.hasProfile(CAMERA_ID, profile));
+            CamcorderProfile camcorderProfile = CamcorderProfile.get(CAMERA_ID, profile);
+            videoEncoder = camcorderProfile.videoCodec;
+            audioEncoder = camcorderProfile.audioCodec;
+            frameRate = camcorderProfile.videoFrameRate;
+            videoWidth = camcorderProfile.videoFrameWidth;
+            videoHeight = camcorderProfile.videoFrameHeight;
+            bitRate = camcorderProfile.videoBitRate;
+        } else {
+            videoEncoder = MediaRecorderStressTestRunner.mVideoEncoder;
+            audioEncoder = MediaRecorderStressTestRunner.mAudioEncoder;
+            frameRate = MediaRecorderStressTestRunner.mFrameRate;
+            videoWidth = MediaRecorderStressTestRunner.mVideoWidth;
+            videoHeight = MediaRecorderStressTestRunner.mVideoHeight;
+            bitRate = MediaRecorderStressTestRunner.mBitRate;
+        }
+        iterations = MediaRecorderStressTestRunner.mIterations;
+        recordDuration = MediaRecorderStressTestRunner.mDuration;
+        removeVideo = MediaRecorderStressTestRunner.mRemoveVideo;
+
+        SurfaceHolder surfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder();
+        mOutput.write("Total number of loops: " + iterations + "\n");
+
         try {
-            output.write("No of loop: ");
-            for (int i = 0; i < iterations; i++){
-                filename = OUTPUT_FILE + i + OUTPUT_FILE_EXT;
-                Log.v(TAG, filename);
+            mOutput.write("No of loop: ");
+            for (int i = 0; i < iterations; i++) {
+                String fileName = String.format("%s/temp%d%s",
+                        Environment.getExternalStorageDirectory(), i, OUTPUT_FILE_EXT);
+                Log.v(TAG, fileName);
+
                 runOnLooper(new Runnable() {
                     @Override
                     public void run() {
                         mRecorder = new MediaRecorder();
                     }
                 });
+
                 Log.v(TAG, "iterations : " + iterations);
-                Log.v(TAG, "video_encoder : " + video_encoder);
-                Log.v(TAG, "audio_encoder : " + audio_encoder);
-                Log.v(TAG, "frame_rate : " + frame_rate);
-                Log.v(TAG, "video_width : " + video_width);
-                Log.v(TAG, "video_height : " + video_height);
-                Log.v(TAG, "bit rate : " + bit_rate);
-                Log.v(TAG, "record_duration : " + record_duration);
+                Log.v(TAG, "video encoder : " + videoEncoder);
+                Log.v(TAG, "audio encoder : " + audioEncoder);
+                Log.v(TAG, "frame rate : " + frameRate);
+                Log.v(TAG, "video width : " + videoWidth);
+                Log.v(TAG, "video height : " + videoHeight);
+                Log.v(TAG, "bit rate : " + bitRate);
+                Log.v(TAG, "record duration : " + recordDuration);
 
                 mRecorder.setOnErrorListener(mRecorderErrorCallback);
                 mRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
                 mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
                 mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
-                mRecorder.setOutputFile(filename);
-                mRecorder.setVideoFrameRate(frame_rate);
-                mRecorder.setVideoSize(video_width, video_height);
-                mRecorder.setVideoEncoder(video_encoder);
-                mRecorder.setAudioEncoder(audio_encoder);
-                mRecorder.setVideoEncodingBitRate(bit_rate);
+                mRecorder.setOutputFile(fileName);
+                mRecorder.setVideoFrameRate(frameRate);
+                mRecorder.setVideoSize(videoWidth, videoHeight);
+                mRecorder.setVideoEncoder(videoEncoder);
+                mRecorder.setAudioEncoder(audioEncoder);
+                mRecorder.setVideoEncodingBitRate(bitRate);
+
                 Log.v(TAG, "mediaRecorder setPreview");
-                mRecorder.setPreviewDisplay(mSurfaceHolder.getSurface());
+                mRecorder.setPreviewDisplay(surfaceHolder.getSurface());
                 mRecorder.prepare();
                 mRecorder.start();
-                Thread.sleep(record_duration);
+                Thread.sleep(recordDuration);
                 Log.v(TAG, "Before stop");
                 mRecorder.stop();
                 mRecorder.release();
+
                 //start the playback
                 MediaPlayer mp = new MediaPlayer();
-                mp.setDataSource(filename);
+                mp.setDataSource(fileName);
                 mp.setDisplay(MediaFrameworkTest.mSurfaceView.getHolder());
                 mp.prepare();
                 mp.start();
-                Thread.sleep(record_duration);
+                Thread.sleep(recordDuration);
                 mp.release();
-                validateRecordedVideo(filename);
-                if (remove_video) {
-                    removeRecordedVideo(filename);
+                validateRecordedVideo(fileName);
+                if (removeVideo) {
+                    removeRecordedVideo(fileName);
                 }
-                output.write(", " + i);
+                if (i == 0) {
+                    mOutput.write(i + 1);
+                } else {
+                    mOutput.write(String.format(", %d", (i + 1)));
+                }
             }
         } catch (Exception e) {
-            Log.v(TAG, e.toString());
-            assertTrue("record and playback", false);
+            Log.e(TAG, e.toString());
+            fail("Record and playback");
         }
-        output.write("\n\n");
-        output.close();
+    }
+
+    // Record and playback stress test @ 1080P quality
+    @LargeTest
+    public void testStressRecordVideoAndPlayback1080P() throws Exception {
+        recordVideoAndPlayback(CamcorderProfile.QUALITY_1080P);
+    }
+
+    // Record and playback stress test @ 720P quality
+    @LargeTest
+    public void testStressRecordVideoAndPlayback720P() throws Exception {
+        recordVideoAndPlayback(CamcorderProfile.QUALITY_720P);
+    }
+
+    // Record and playback stress test @ 480P quality
+    @LargeTest
+    public void testStressRecordVideoAndPlayback480P() throws Exception {
+        recordVideoAndPlayback(CamcorderProfile.QUALITY_480P);
+    }
+
+    // This test method uses the codec info from the test runner. Use this
+    // for more granular control of video encoding.
+    @LargeTest
+    public void defaultStressRecordVideoAndPlayback() throws Exception {
+        recordVideoAndPlayback(USE_TEST_RUNNER_PROFILE);
     }
 
     // Test case for stressing time lapse
@@ -405,21 +458,19 @@
     public void testStressTimeLapse() throws Exception {
         SurfaceHolder mSurfaceHolder;
         mSurfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder();
-        int record_duration = MediaRecorderStressTestRunner.mTimeLapseDuration;
-        boolean remove_video = MediaRecorderStressTestRunner.mRemoveVideo;
+        int recordDuration = MediaRecorderStressTestRunner.mTimeLapseDuration;
+        boolean removeVideo = MediaRecorderStressTestRunner.mRemoveVideo;
         double captureRate = MediaRecorderStressTestRunner.mCaptureRate;
-        String filename;
-        File stressOutFile = new File(MEDIA_STRESS_OUTPUT);
-        Writer output = new BufferedWriter(new FileWriter(stressOutFile, true));
-        output.write("Start camera time lapse stress:\n");
-        output.write("Total number of loops: " + NUMBER_OF_TIME_LAPSE_LOOPS + "\n");
+        Log.v(TAG, "Start camera time lapse stress:");
+        mOutput.write("Total number of loops: " + NUMBER_OF_TIME_LAPSE_LOOPS + "\n");
 
         try {
-            for (int j = 0, n = Camera.getNumberOfCameras(); j < n; j++) {
-                output.write("No of loop: camera " + j);
-                for (int i = 0; i < NUMBER_OF_TIME_LAPSE_LOOPS; i++) {
-                    filename = OUTPUT_FILE + j + "_" + i + OUTPUT_FILE_EXT;
-                    Log.v(TAG, filename);
+            for (int i = 0, n = Camera.getNumberOfCameras(); i < n; i++) {
+                mOutput.write("No of loop: camera " + i);
+                for (int j = 0; j < NUMBER_OF_TIME_LAPSE_LOOPS; j++) {
+                    String fileName = String.format("%s/temp%d_%d%s",
+                            Environment.getExternalStorageDirectory(), i, j, OUTPUT_FILE_EXT);
+                    Log.v(TAG, fileName);
                     runOnLooper(new Runnable() {
                         @Override
                         public void run() {
@@ -438,12 +489,12 @@
                         CamcorderProfile.get(j, CamcorderProfile.QUALITY_TIME_LAPSE_HIGH);
                     mRecorder.setProfile(profile);
 
-                    // Set the timelapse setting; 0.1 = 10 sec timelapse, 0.5 = 2 sec timelapse, etc.
+                    // Set the timelapse setting; 0.1 = 10 sec timelapse, 0.5 = 2 sec timelapse, etc
                     // http://developer.android.com/guide/topics/media/camera.html#time-lapse-video
                     mRecorder.setCaptureRate(captureRate);
 
                     // Set output file
-                    mRecorder.setOutputFile(filename);
+                    mRecorder.setOutputFile(fileName);
 
                     // Set the preview display
                     Log.v(TAG, "mediaRecorder setPreviewDisplay");
@@ -451,40 +502,40 @@
 
                     mRecorder.prepare();
                     mRecorder.start();
-                    Thread.sleep(record_duration);
+                    Thread.sleep(recordDuration);
                     Log.v(TAG, "Before stop");
                     mRecorder.stop();
                     mRecorder.release();
 
                     // Start the playback
                     MediaPlayer mp = new MediaPlayer();
-                    mp.setDataSource(filename);
+                    mp.setDataSource(fileName);
                     mp.setDisplay(mSurfaceHolder);
                     mp.prepare();
                     mp.start();
                     Thread.sleep(TIME_LAPSE_PLAYBACK_WAIT_TIME);
                     mp.release();
-                    validateRecordedVideo(filename);
-                    if (remove_video) {
-                        removeRecordedVideo(filename);
+                    validateRecordedVideo(fileName);
+                    if (removeVideo) {
+                        removeRecordedVideo(fileName);
                     }
-                    output.write(", " + i);
+
+                    if (j == 0) {
+                        mOutput.write(j + 1);
+                    } else {
+                        mOutput.write(String.format(", %d", (j + 1)));
+                    }
                 }
             }
+        } catch (IllegalStateException e) {
+            Log.e(TAG, e.toString());
+            fail("Camera time lapse stress test IllegalStateException");
+        } catch (IOException e) {
+            Log.e(TAG, e.toString());
+            fail("Camera time lapse stress test IOException");
+        } catch (Exception e) {
+            Log.e(TAG, e.toString());
+            fail("Camera time lapse stress test Exception");
         }
-        catch (IllegalStateException e) {
-            assertTrue("Camera time lapse stress test IllegalStateException", false);
-            Log.v(TAG, e.toString());
-        }
-        catch (IOException e) {
-            assertTrue("Camera time lapse stress test IOException", false);
-            Log.v(TAG, e.toString());
-        }
-        catch (Exception e) {
-            assertTrue("Camera time lapse stress test Exception", false);
-            Log.v(TAG, e.toString());
-        }
-        output.write("\n\n");
-        output.close();
     }
 }
diff --git a/packages/SettingsProvider/res/values/defaults.xml b/packages/SettingsProvider/res/values/defaults.xml
index 82627c0..bfb0931 100644
--- a/packages/SettingsProvider/res/values/defaults.xml
+++ b/packages/SettingsProvider/res/values/defaults.xml
@@ -77,6 +77,7 @@
 
     <bool name="def_lockscreen_disabled">false</bool>
     <bool name="def_device_provisioned">false</bool>
+    <integer name="def_dock_audio_media_enabled">1</integer>
 
     <!-- Notifications use ringer volume -->
     <bool name="def_notifications_use_ring_volume">true</bool>
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
index fd0b79ff..cccce9d 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
@@ -2210,6 +2210,9 @@
             loadStringSetting(stmt, Settings.Global.WIRELESS_CHARGING_STARTED_SOUND,
                     R.string.def_wireless_charging_started_sound);
 
+            loadIntegerSetting(stmt, Settings.Global.DOCK_AUDIO_MEDIA_ENABLED,
+                    R.integer.def_dock_audio_media_enabled);
+
             loadSetting(stmt, Settings.Global.SET_INSTALL_LOCATION, 0);
             loadSetting(stmt, Settings.Global.DEFAULT_INSTALL_LOCATION,
                     PackageHelper.APP_INSTALL_AUTO);
diff --git a/packages/SystemUI/Android.mk b/packages/SystemUI/Android.mk
index 6026258..262000e 100644
--- a/packages/SystemUI/Android.mk
+++ b/packages/SystemUI/Android.mk
@@ -4,7 +4,8 @@
 LOCAL_MODULE_TAGS := optional
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src) \
-    ../../../ex/carousel/java/com/android/ex/carousel/carousel.rs
+    ../../../ex/carousel/java/com/android/ex/carousel/carousel.rs \
+    src/com/android/systemui/EventLogTags.logtags
 
 LOCAL_JAVA_LIBRARIES := services telephony-common
 
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_0.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_0.png
new file mode 100644
index 0000000..3cc2ab4
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_0.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_1.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_1.png
new file mode 100644
index 0000000..258e49b
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_1.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_1x.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_1x.png
new file mode 100644
index 0000000..075250a
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_1x.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_2.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_2.png
new file mode 100644
index 0000000..b485967
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_2.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_3.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_3.png
new file mode 100644
index 0000000..a9e0a06
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_3.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_3g.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_3g.png
new file mode 100644
index 0000000..b03296c
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_3g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_4.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_4.png
new file mode 100644
index 0000000..2974c2f
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_4.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_4g.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_4g.png
new file mode 100644
index 0000000..58b84fc
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_4g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_e.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_e.png
new file mode 100644
index 0000000..6a4da0d
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_e.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_full_0.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_full_0.png
new file mode 100644
index 0000000..4e2cb12
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_full_0.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_full_1.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_full_1.png
new file mode 100644
index 0000000..abadd36
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_full_1.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_full_1x.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_full_1x.png
new file mode 100644
index 0000000..a644516
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_full_1x.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_full_2.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_full_2.png
new file mode 100644
index 0000000..dd52748
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_full_2.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_full_3.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_full_3.png
new file mode 100644
index 0000000..ecbed41
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_full_3.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_full_3g.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_full_3g.png
new file mode 100644
index 0000000..6471056
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_full_3g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_full_4.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_full_4.png
new file mode 100644
index 0000000..964574d
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_full_4.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_full_4g.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_full_4g.png
new file mode 100644
index 0000000..e34a1ab
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_full_4g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_full_e.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_full_e.png
new file mode 100644
index 0000000..2454d81
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_full_e.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_full_g.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_full_g.png
new file mode 100644
index 0000000..d3e9a16
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_full_g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_full_h.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_full_h.png
new file mode 100644
index 0000000..43bccb3
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_full_h.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_full_r.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_full_r.png
new file mode 100644
index 0000000..071e569
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_full_r.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_g.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_g.png
new file mode 100644
index 0000000..b8b298b
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_h.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_h.png
new file mode 100644
index 0000000..fb633cc
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_h.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_in.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_in.png
new file mode 100644
index 0000000..fb08a0c
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_in.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_inout.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_inout.png
new file mode 100644
index 0000000..013881f
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_inout.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_no_network.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_no_network.png
new file mode 100644
index 0000000..f0e3410
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_no_network.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_no_signal.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_no_signal.png
new file mode 100644
index 0000000..7c22391
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_no_signal.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_out.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_out.png
new file mode 100644
index 0000000..a6ed1f9
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_out.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_r.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_r.png
new file mode 100644
index 0000000..d4ecfb9
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/ic_qs_signal_r.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_data_connected_1x.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_data_connected_1x.png
new file mode 100644
index 0000000..bbf897f
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_data_connected_1x.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_data_connected_3g.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_data_connected_3g.png
new file mode 100644
index 0000000..292f5b7
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_data_connected_3g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_data_connected_4g.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_data_connected_4g.png
new file mode 100644
index 0000000..851892c
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_data_connected_4g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_data_connected_e.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_data_connected_e.png
new file mode 100644
index 0000000..8ad379e
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_data_connected_e.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_data_connected_g.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_data_connected_g.png
new file mode 100644
index 0000000..ca1800c
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_data_connected_g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_data_connected_h.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_data_connected_h.png
new file mode 100644
index 0000000..1e71680
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_data_connected_h.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_data_connected_roam.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_data_connected_roam.png
new file mode 100644
index 0000000..b1cb4b8
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_data_connected_roam.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_data_fully_connected_1x.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_data_fully_connected_1x.png
new file mode 100644
index 0000000..983ba67
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_data_fully_connected_1x.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_data_fully_connected_3g.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_data_fully_connected_3g.png
new file mode 100644
index 0000000..fa5ffe9
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_data_fully_connected_3g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_data_fully_connected_4g.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_data_fully_connected_4g.png
new file mode 100644
index 0000000..859adb9
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_data_fully_connected_4g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_data_fully_connected_e.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_data_fully_connected_e.png
new file mode 100644
index 0000000..0d78728
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_data_fully_connected_e.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_data_fully_connected_g.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_data_fully_connected_g.png
new file mode 100644
index 0000000..5290dc4
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_data_fully_connected_g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_data_fully_connected_h.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_data_fully_connected_h.png
new file mode 100644
index 0000000..f034fbfd
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_data_fully_connected_h.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_ringer_silent.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_ringer_silent.png
new file mode 100644
index 0000000..6872ec8
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_ringer_silent.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_ringer_vibrate.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_ringer_vibrate.png
new file mode 100644
index 0000000..98520d3
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_ringer_vibrate.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_signal_0.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_signal_0.png
new file mode 100644
index 0000000..733563d
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_signal_0.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_signal_0_fully.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_signal_0_fully.png
new file mode 100644
index 0000000..3ac0231
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_signal_0_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_signal_1.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_signal_1.png
new file mode 100644
index 0000000..50a3078
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_signal_1.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_signal_1_fully.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_signal_1_fully.png
new file mode 100644
index 0000000..9e353da
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_signal_1_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_signal_2.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_signal_2.png
new file mode 100644
index 0000000..5ff0ac6
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_signal_2.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_signal_2_fully.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_signal_2_fully.png
new file mode 100644
index 0000000..91ca89a
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_signal_2_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_signal_3.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_signal_3.png
new file mode 100644
index 0000000..784c5da
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_signal_3.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_signal_3_fully.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_signal_3_fully.png
new file mode 100644
index 0000000..484d4b8
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_signal_3_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_signal_4.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_signal_4.png
new file mode 100644
index 0000000..db06343
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_signal_4.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_signal_4_fully.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_signal_4_fully.png
new file mode 100644
index 0000000..62130a0
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_signal_4_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_signal_in.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_signal_in.png
new file mode 100644
index 0000000..f2bd618
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_signal_in.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_signal_inout.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_signal_inout.png
new file mode 100644
index 0000000..468dec9
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_signal_inout.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_signal_null.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_signal_null.png
new file mode 100644
index 0000000..7bbe2cc
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_signal_null.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_signal_out.png b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_signal_out.png
new file mode 100644
index 0000000..b2f7f59
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-hdpi/stat_sys_signal_out.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_0.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_0.png
new file mode 100644
index 0000000..c8020e0
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_0.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_1.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_1.png
new file mode 100644
index 0000000..a968e96
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_1.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_1x.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_1x.png
new file mode 100644
index 0000000..712cce4
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_1x.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_2.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_2.png
new file mode 100644
index 0000000..5ac3715
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_2.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_3.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_3.png
new file mode 100644
index 0000000..8b4c97c
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_3.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_3g.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_3g.png
new file mode 100644
index 0000000..835219c
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_3g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_4.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_4.png
new file mode 100644
index 0000000..7fea77c
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_4.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_4g.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_4g.png
new file mode 100644
index 0000000..ec861fa
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_4g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_e.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_e.png
new file mode 100644
index 0000000..3bef9e7
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_e.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_full_0.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_full_0.png
new file mode 100644
index 0000000..31637c2
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_full_0.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_full_1.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_full_1.png
new file mode 100644
index 0000000..4bedf72
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_full_1.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_full_1x.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_full_1x.png
new file mode 100644
index 0000000..0cb5f26
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_full_1x.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_full_2.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_full_2.png
new file mode 100644
index 0000000..c779281
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_full_2.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_full_3.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_full_3.png
new file mode 100644
index 0000000..7e0f98d
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_full_3.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_full_3g.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_full_3g.png
new file mode 100644
index 0000000..c258489
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_full_3g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_full_4.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_full_4.png
new file mode 100644
index 0000000..d479043
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_full_4.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_full_4g.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_full_4g.png
new file mode 100644
index 0000000..e1ce328
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_full_4g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_full_e.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_full_e.png
new file mode 100644
index 0000000..b1d5d5c
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_full_e.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_full_g.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_full_g.png
new file mode 100644
index 0000000..b907713
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_full_g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_full_h.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_full_h.png
new file mode 100644
index 0000000..6396b64
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_full_h.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_full_r.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_full_r.png
new file mode 100644
index 0000000..fd3b644
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_full_r.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_g.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_g.png
new file mode 100644
index 0000000..07f514c
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_h.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_h.png
new file mode 100644
index 0000000..9ccd5aa
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_h.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_in.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_in.png
new file mode 100644
index 0000000..efee374
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_in.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_inout.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_inout.png
new file mode 100644
index 0000000..e69f3f7
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_inout.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_no_network.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_no_network.png
new file mode 100644
index 0000000..f465084
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_no_network.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_no_signal.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_no_signal.png
new file mode 100644
index 0000000..dc52a7b
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_no_signal.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_out.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_out.png
new file mode 100644
index 0000000..69f15e3
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_out.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_r.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_r.png
new file mode 100644
index 0000000..bf1f50e
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/ic_qs_signal_r.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_data_connected_1x.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_data_connected_1x.png
new file mode 100644
index 0000000..f6d53bb
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_data_connected_1x.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_data_connected_3g.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_data_connected_3g.png
new file mode 100644
index 0000000..2fec581
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_data_connected_3g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_data_connected_4g.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_data_connected_4g.png
new file mode 100644
index 0000000..df46db2
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_data_connected_4g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_data_connected_e.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_data_connected_e.png
new file mode 100644
index 0000000..d556d57
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_data_connected_e.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_data_connected_g.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_data_connected_g.png
new file mode 100644
index 0000000..546cff9
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_data_connected_g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_data_connected_h.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_data_connected_h.png
new file mode 100644
index 0000000..0ed7558
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_data_connected_h.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_data_connected_roam.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_data_connected_roam.png
new file mode 100644
index 0000000..0f0cf49
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_data_connected_roam.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_data_fully_connected_1x.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_data_fully_connected_1x.png
new file mode 100644
index 0000000..2ac1a96
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_data_fully_connected_1x.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_data_fully_connected_3g.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_data_fully_connected_3g.png
new file mode 100644
index 0000000..2625fab
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_data_fully_connected_3g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_data_fully_connected_4g.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_data_fully_connected_4g.png
new file mode 100644
index 0000000..17a77b1
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_data_fully_connected_4g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_data_fully_connected_e.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_data_fully_connected_e.png
new file mode 100644
index 0000000..e482a26
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_data_fully_connected_e.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_data_fully_connected_g.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_data_fully_connected_g.png
new file mode 100644
index 0000000..05628d0
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_data_fully_connected_g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_data_fully_connected_h.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_data_fully_connected_h.png
new file mode 100644
index 0000000..7dc5d96
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_data_fully_connected_h.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_ringer_silent.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_ringer_silent.png
new file mode 100644
index 0000000..66b4741
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_ringer_silent.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_ringer_vibrate.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_ringer_vibrate.png
new file mode 100644
index 0000000..f8abf25
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_ringer_vibrate.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_signal_0.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_signal_0.png
new file mode 100644
index 0000000..9be8d23
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_signal_0.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_signal_0_fully.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_signal_0_fully.png
new file mode 100644
index 0000000..0002165
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_signal_0_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_signal_1.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_signal_1.png
new file mode 100644
index 0000000..d142737
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_signal_1.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_signal_1_fully.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_signal_1_fully.png
new file mode 100644
index 0000000..dc31490
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_signal_1_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_signal_2.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_signal_2.png
new file mode 100644
index 0000000..4e5b7d3
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_signal_2.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_signal_2_fully.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_signal_2_fully.png
new file mode 100644
index 0000000..6acb475
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_signal_2_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_signal_3.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_signal_3.png
new file mode 100644
index 0000000..509d1752
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_signal_3.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_signal_3_fully.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_signal_3_fully.png
new file mode 100644
index 0000000..5791615
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_signal_3_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_signal_4.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_signal_4.png
new file mode 100644
index 0000000..01b27ec
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_signal_4.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_signal_4_fully.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_signal_4_fully.png
new file mode 100644
index 0000000..c970e0e
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_signal_4_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_signal_in.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_signal_in.png
new file mode 100644
index 0000000..e0b0f9b
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_signal_in.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_signal_inout.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_signal_inout.png
new file mode 100644
index 0000000..2fb3c2e
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_signal_inout.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_signal_null.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_signal_null.png
new file mode 100644
index 0000000..8691360
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_signal_null.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_signal_out.png b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_signal_out.png
new file mode 100644
index 0000000..0fe8012
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-mdpi/stat_sys_signal_out.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-sw720dp-hdpi/ic_sysbar_signal_0.png b/packages/SystemUI/res/drawable-ldrtl-sw720dp-hdpi/ic_sysbar_signal_0.png
new file mode 100644
index 0000000..db07305
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-sw720dp-hdpi/ic_sysbar_signal_0.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-sw720dp-hdpi/ic_sysbar_signal_0_fully.png b/packages/SystemUI/res/drawable-ldrtl-sw720dp-hdpi/ic_sysbar_signal_0_fully.png
new file mode 100644
index 0000000..4518ad5
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-sw720dp-hdpi/ic_sysbar_signal_0_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-sw720dp-hdpi/ic_sysbar_signal_1.png b/packages/SystemUI/res/drawable-ldrtl-sw720dp-hdpi/ic_sysbar_signal_1.png
new file mode 100644
index 0000000..3b6f74ad
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-sw720dp-hdpi/ic_sysbar_signal_1.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-sw720dp-hdpi/ic_sysbar_signal_1_fully.png b/packages/SystemUI/res/drawable-ldrtl-sw720dp-hdpi/ic_sysbar_signal_1_fully.png
new file mode 100644
index 0000000..396d51d
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-sw720dp-hdpi/ic_sysbar_signal_1_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-sw720dp-hdpi/ic_sysbar_signal_2.png b/packages/SystemUI/res/drawable-ldrtl-sw720dp-hdpi/ic_sysbar_signal_2.png
new file mode 100644
index 0000000..bb90a95
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-sw720dp-hdpi/ic_sysbar_signal_2.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-sw720dp-hdpi/ic_sysbar_signal_2_fully.png b/packages/SystemUI/res/drawable-ldrtl-sw720dp-hdpi/ic_sysbar_signal_2_fully.png
new file mode 100644
index 0000000..34dc19f
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-sw720dp-hdpi/ic_sysbar_signal_2_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-sw720dp-hdpi/ic_sysbar_signal_3.png b/packages/SystemUI/res/drawable-ldrtl-sw720dp-hdpi/ic_sysbar_signal_3.png
new file mode 100644
index 0000000..64c2de2
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-sw720dp-hdpi/ic_sysbar_signal_3.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-sw720dp-hdpi/ic_sysbar_signal_3_fully.png b/packages/SystemUI/res/drawable-ldrtl-sw720dp-hdpi/ic_sysbar_signal_3_fully.png
new file mode 100644
index 0000000..9d93d2b
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-sw720dp-hdpi/ic_sysbar_signal_3_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-sw720dp-hdpi/ic_sysbar_signal_4.png b/packages/SystemUI/res/drawable-ldrtl-sw720dp-hdpi/ic_sysbar_signal_4.png
new file mode 100644
index 0000000..28ae311
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-sw720dp-hdpi/ic_sysbar_signal_4.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-sw720dp-hdpi/ic_sysbar_signal_4_fully.png b/packages/SystemUI/res/drawable-ldrtl-sw720dp-hdpi/ic_sysbar_signal_4_fully.png
new file mode 100644
index 0000000..cd4f706
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-sw720dp-hdpi/ic_sysbar_signal_4_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-sw720dp-hdpi/ic_sysbar_signal_in.png b/packages/SystemUI/res/drawable-ldrtl-sw720dp-hdpi/ic_sysbar_signal_in.png
new file mode 100644
index 0000000..cbce322
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-sw720dp-hdpi/ic_sysbar_signal_in.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-sw720dp-hdpi/ic_sysbar_signal_inout.png b/packages/SystemUI/res/drawable-ldrtl-sw720dp-hdpi/ic_sysbar_signal_inout.png
new file mode 100644
index 0000000..6788da8
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-sw720dp-hdpi/ic_sysbar_signal_inout.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-sw720dp-hdpi/ic_sysbar_signal_null.png b/packages/SystemUI/res/drawable-ldrtl-sw720dp-hdpi/ic_sysbar_signal_null.png
new file mode 100644
index 0000000..0f00fb0
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-sw720dp-hdpi/ic_sysbar_signal_null.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-sw720dp-hdpi/ic_sysbar_signal_out.png b/packages/SystemUI/res/drawable-ldrtl-sw720dp-hdpi/ic_sysbar_signal_out.png
new file mode 100644
index 0000000..db05c5f
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-sw720dp-hdpi/ic_sysbar_signal_out.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-sw720dp-mdpi/ic_sysbar_signal_0.png b/packages/SystemUI/res/drawable-ldrtl-sw720dp-mdpi/ic_sysbar_signal_0.png
new file mode 100644
index 0000000..9b99940
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-sw720dp-mdpi/ic_sysbar_signal_0.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-sw720dp-mdpi/ic_sysbar_signal_0_fully.png b/packages/SystemUI/res/drawable-ldrtl-sw720dp-mdpi/ic_sysbar_signal_0_fully.png
new file mode 100644
index 0000000..2cd8c90
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-sw720dp-mdpi/ic_sysbar_signal_0_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-sw720dp-mdpi/ic_sysbar_signal_1.png b/packages/SystemUI/res/drawable-ldrtl-sw720dp-mdpi/ic_sysbar_signal_1.png
new file mode 100644
index 0000000..f5363c3
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-sw720dp-mdpi/ic_sysbar_signal_1.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-sw720dp-mdpi/ic_sysbar_signal_1_fully.png b/packages/SystemUI/res/drawable-ldrtl-sw720dp-mdpi/ic_sysbar_signal_1_fully.png
new file mode 100644
index 0000000..ded5029
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-sw720dp-mdpi/ic_sysbar_signal_1_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-sw720dp-mdpi/ic_sysbar_signal_2.png b/packages/SystemUI/res/drawable-ldrtl-sw720dp-mdpi/ic_sysbar_signal_2.png
new file mode 100644
index 0000000..01f4eb0
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-sw720dp-mdpi/ic_sysbar_signal_2.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-sw720dp-mdpi/ic_sysbar_signal_2_fully.png b/packages/SystemUI/res/drawable-ldrtl-sw720dp-mdpi/ic_sysbar_signal_2_fully.png
new file mode 100644
index 0000000..9963e97
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-sw720dp-mdpi/ic_sysbar_signal_2_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-sw720dp-mdpi/ic_sysbar_signal_3.png b/packages/SystemUI/res/drawable-ldrtl-sw720dp-mdpi/ic_sysbar_signal_3.png
new file mode 100644
index 0000000..3123cc9
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-sw720dp-mdpi/ic_sysbar_signal_3.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-sw720dp-mdpi/ic_sysbar_signal_3_fully.png b/packages/SystemUI/res/drawable-ldrtl-sw720dp-mdpi/ic_sysbar_signal_3_fully.png
new file mode 100644
index 0000000..34363fa
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-sw720dp-mdpi/ic_sysbar_signal_3_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-sw720dp-mdpi/ic_sysbar_signal_4.png b/packages/SystemUI/res/drawable-ldrtl-sw720dp-mdpi/ic_sysbar_signal_4.png
new file mode 100644
index 0000000..186844c
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-sw720dp-mdpi/ic_sysbar_signal_4.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-sw720dp-mdpi/ic_sysbar_signal_4_fully.png b/packages/SystemUI/res/drawable-ldrtl-sw720dp-mdpi/ic_sysbar_signal_4_fully.png
new file mode 100644
index 0000000..680f806
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-sw720dp-mdpi/ic_sysbar_signal_4_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-sw720dp-mdpi/ic_sysbar_signal_in.png b/packages/SystemUI/res/drawable-ldrtl-sw720dp-mdpi/ic_sysbar_signal_in.png
new file mode 100644
index 0000000..4d5bb0b
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-sw720dp-mdpi/ic_sysbar_signal_in.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-sw720dp-mdpi/ic_sysbar_signal_inout.png b/packages/SystemUI/res/drawable-ldrtl-sw720dp-mdpi/ic_sysbar_signal_inout.png
new file mode 100644
index 0000000..253d15c
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-sw720dp-mdpi/ic_sysbar_signal_inout.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-sw720dp-mdpi/ic_sysbar_signal_null.png b/packages/SystemUI/res/drawable-ldrtl-sw720dp-mdpi/ic_sysbar_signal_null.png
new file mode 100644
index 0000000..5d688aa
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-sw720dp-mdpi/ic_sysbar_signal_null.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-sw720dp-mdpi/ic_sysbar_signal_out.png b/packages/SystemUI/res/drawable-ldrtl-sw720dp-mdpi/ic_sysbar_signal_out.png
new file mode 100644
index 0000000..8198fdc
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-sw720dp-mdpi/ic_sysbar_signal_out.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-sw720dp-xhdpi/ic_sysbar_signal_0.png b/packages/SystemUI/res/drawable-ldrtl-sw720dp-xhdpi/ic_sysbar_signal_0.png
new file mode 100644
index 0000000..a8691dc
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-sw720dp-xhdpi/ic_sysbar_signal_0.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-sw720dp-xhdpi/ic_sysbar_signal_0_fully.png b/packages/SystemUI/res/drawable-ldrtl-sw720dp-xhdpi/ic_sysbar_signal_0_fully.png
new file mode 100644
index 0000000..77ade2f
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-sw720dp-xhdpi/ic_sysbar_signal_0_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-sw720dp-xhdpi/ic_sysbar_signal_1.png b/packages/SystemUI/res/drawable-ldrtl-sw720dp-xhdpi/ic_sysbar_signal_1.png
new file mode 100644
index 0000000..0974b2c
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-sw720dp-xhdpi/ic_sysbar_signal_1.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-sw720dp-xhdpi/ic_sysbar_signal_1_fully.png b/packages/SystemUI/res/drawable-ldrtl-sw720dp-xhdpi/ic_sysbar_signal_1_fully.png
new file mode 100644
index 0000000..4be5612
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-sw720dp-xhdpi/ic_sysbar_signal_1_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-sw720dp-xhdpi/ic_sysbar_signal_2.png b/packages/SystemUI/res/drawable-ldrtl-sw720dp-xhdpi/ic_sysbar_signal_2.png
new file mode 100644
index 0000000..79f8b88
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-sw720dp-xhdpi/ic_sysbar_signal_2.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-sw720dp-xhdpi/ic_sysbar_signal_2_fully.png b/packages/SystemUI/res/drawable-ldrtl-sw720dp-xhdpi/ic_sysbar_signal_2_fully.png
new file mode 100644
index 0000000..6167246
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-sw720dp-xhdpi/ic_sysbar_signal_2_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-sw720dp-xhdpi/ic_sysbar_signal_3.png b/packages/SystemUI/res/drawable-ldrtl-sw720dp-xhdpi/ic_sysbar_signal_3.png
new file mode 100644
index 0000000..d2ecd47
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-sw720dp-xhdpi/ic_sysbar_signal_3.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-sw720dp-xhdpi/ic_sysbar_signal_3_fully.png b/packages/SystemUI/res/drawable-ldrtl-sw720dp-xhdpi/ic_sysbar_signal_3_fully.png
new file mode 100644
index 0000000..92871c3
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-sw720dp-xhdpi/ic_sysbar_signal_3_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-sw720dp-xhdpi/ic_sysbar_signal_4.png b/packages/SystemUI/res/drawable-ldrtl-sw720dp-xhdpi/ic_sysbar_signal_4.png
new file mode 100644
index 0000000..4b86ca4
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-sw720dp-xhdpi/ic_sysbar_signal_4.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-sw720dp-xhdpi/ic_sysbar_signal_4_fully.png b/packages/SystemUI/res/drawable-ldrtl-sw720dp-xhdpi/ic_sysbar_signal_4_fully.png
new file mode 100644
index 0000000..200d1cb
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-sw720dp-xhdpi/ic_sysbar_signal_4_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-sw720dp-xhdpi/ic_sysbar_signal_in.png b/packages/SystemUI/res/drawable-ldrtl-sw720dp-xhdpi/ic_sysbar_signal_in.png
new file mode 100644
index 0000000..f4c5281
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-sw720dp-xhdpi/ic_sysbar_signal_in.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-sw720dp-xhdpi/ic_sysbar_signal_inout.png b/packages/SystemUI/res/drawable-ldrtl-sw720dp-xhdpi/ic_sysbar_signal_inout.png
new file mode 100644
index 0000000..42e2170
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-sw720dp-xhdpi/ic_sysbar_signal_inout.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-sw720dp-xhdpi/ic_sysbar_signal_null.png b/packages/SystemUI/res/drawable-ldrtl-sw720dp-xhdpi/ic_sysbar_signal_null.png
new file mode 100644
index 0000000..eaff2c0
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-sw720dp-xhdpi/ic_sysbar_signal_null.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-sw720dp-xhdpi/ic_sysbar_signal_out.png b/packages/SystemUI/res/drawable-ldrtl-sw720dp-xhdpi/ic_sysbar_signal_out.png
new file mode 100644
index 0000000..9feb041
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-sw720dp-xhdpi/ic_sysbar_signal_out.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_0.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_0.png
new file mode 100644
index 0000000..3f87163
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_0.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_1.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_1.png
new file mode 100644
index 0000000..5fae5fe
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_1.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_1x.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_1x.png
new file mode 100644
index 0000000..24c8fde
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_1x.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_2.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_2.png
new file mode 100644
index 0000000..2e68d0f
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_2.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_3.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_3.png
new file mode 100644
index 0000000..01af7f9
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_3.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_3g.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_3g.png
new file mode 100644
index 0000000..f5e4b7e
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_3g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_4.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_4.png
new file mode 100644
index 0000000..2368f71
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_4.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_4g.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_4g.png
new file mode 100644
index 0000000..eeeed04
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_4g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_e.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_e.png
new file mode 100644
index 0000000..6188ec3
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_e.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_full_0.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_full_0.png
new file mode 100644
index 0000000..cd41a810
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_full_0.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_full_1.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_full_1.png
new file mode 100644
index 0000000..637c8bb
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_full_1.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_full_1x.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_full_1x.png
new file mode 100644
index 0000000..c8348d4
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_full_1x.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_full_2.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_full_2.png
new file mode 100644
index 0000000..b499d01
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_full_2.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_full_3.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_full_3.png
new file mode 100644
index 0000000..589f41b
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_full_3.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_full_3g.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_full_3g.png
new file mode 100644
index 0000000..c756e15
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_full_3g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_full_4.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_full_4.png
new file mode 100644
index 0000000..0208cdb
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_full_4.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_full_4g.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_full_4g.png
new file mode 100644
index 0000000..9cd1154
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_full_4g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_full_e.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_full_e.png
new file mode 100644
index 0000000..01c8876
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_full_e.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_full_g.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_full_g.png
new file mode 100644
index 0000000..5516e0f
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_full_g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_full_h.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_full_h.png
new file mode 100644
index 0000000..8f411c3
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_full_h.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_full_r.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_full_r.png
new file mode 100644
index 0000000..ef65b74
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_full_r.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_g.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_g.png
new file mode 100644
index 0000000..6e51ecb
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_h.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_h.png
new file mode 100644
index 0000000..7c8155c
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_h.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_in.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_in.png
new file mode 100644
index 0000000..fd5f0e52
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_in.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_inout.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_inout.png
new file mode 100644
index 0000000..1f04910
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_inout.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_no_network.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_no_network.png
new file mode 100644
index 0000000..74b5b92
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_no_network.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_no_signal.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_no_signal.png
new file mode 100644
index 0000000..bcdd82d
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_no_signal.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_out.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_out.png
new file mode 100644
index 0000000..d95b997
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_out.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_r.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_r.png
new file mode 100644
index 0000000..1e6aef5
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/ic_qs_signal_r.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_data_connected_1x.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_data_connected_1x.png
new file mode 100644
index 0000000..d3b57c3
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_data_connected_1x.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_data_connected_3g.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_data_connected_3g.png
new file mode 100644
index 0000000..cc2256f
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_data_connected_3g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_data_connected_4g.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_data_connected_4g.png
new file mode 100644
index 0000000..e1f1ab9
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_data_connected_4g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_data_connected_e.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_data_connected_e.png
new file mode 100644
index 0000000..5a04dde
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_data_connected_e.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_data_connected_g.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_data_connected_g.png
new file mode 100644
index 0000000..65c4fe1
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_data_connected_g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_data_connected_h.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_data_connected_h.png
new file mode 100644
index 0000000..066405f
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_data_connected_h.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_data_connected_roam.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_data_connected_roam.png
new file mode 100644
index 0000000..97d5d5b7
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_data_connected_roam.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_data_fully_connected_1x.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_data_fully_connected_1x.png
new file mode 100644
index 0000000..a3d2b35
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_data_fully_connected_1x.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_data_fully_connected_3g.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_data_fully_connected_3g.png
new file mode 100644
index 0000000..8e13caa
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_data_fully_connected_3g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_data_fully_connected_4g.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_data_fully_connected_4g.png
new file mode 100644
index 0000000..23fcf42
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_data_fully_connected_4g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_data_fully_connected_e.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_data_fully_connected_e.png
new file mode 100644
index 0000000..4370c22
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_data_fully_connected_e.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_data_fully_connected_g.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_data_fully_connected_g.png
new file mode 100644
index 0000000..3504a75
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_data_fully_connected_g.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_data_fully_connected_h.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_data_fully_connected_h.png
new file mode 100644
index 0000000..21fc58c
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_data_fully_connected_h.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_ringer_silent.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_ringer_silent.png
new file mode 100644
index 0000000..629b5f8
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_ringer_silent.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_ringer_vibrate.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_ringer_vibrate.png
new file mode 100644
index 0000000..8e3e8b4
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_ringer_vibrate.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_signal_0.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_signal_0.png
new file mode 100644
index 0000000..62d1d34
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_signal_0.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_signal_0_fully.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_signal_0_fully.png
new file mode 100644
index 0000000..b263831
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_signal_0_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_signal_1.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_signal_1.png
new file mode 100644
index 0000000..6f9620e
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_signal_1.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_signal_1_fully.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_signal_1_fully.png
new file mode 100644
index 0000000..7adae9f
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_signal_1_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_signal_2.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_signal_2.png
new file mode 100644
index 0000000..906b418
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_signal_2.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_signal_2_fully.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_signal_2_fully.png
new file mode 100644
index 0000000..ebdf136
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_signal_2_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_signal_3.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_signal_3.png
new file mode 100644
index 0000000..1a2ab1c
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_signal_3.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_signal_3_fully.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_signal_3_fully.png
new file mode 100644
index 0000000..c0170a6
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_signal_3_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_signal_4.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_signal_4.png
new file mode 100644
index 0000000..2cc587b
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_signal_4.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_signal_4_fully.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_signal_4_fully.png
new file mode 100644
index 0000000..11a26c6
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_signal_4_fully.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_signal_in.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_signal_in.png
new file mode 100644
index 0000000..3afb5b2
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_signal_in.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_signal_inout.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_signal_inout.png
new file mode 100644
index 0000000..fcf7f6e
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_signal_inout.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_signal_null.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_signal_null.png
new file mode 100644
index 0000000..815de33
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_signal_null.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_signal_out.png b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_signal_out.png
new file mode 100644
index 0000000..f153216
--- /dev/null
+++ b/packages/SystemUI/res/drawable-ldrtl-xhdpi/stat_sys_signal_out.png
Binary files differ
diff --git a/packages/SystemUI/src/com/android/systemui/EventLogTags.logtags b/packages/SystemUI/src/com/android/systemui/EventLogTags.logtags
new file mode 100644
index 0000000..aa32e9c
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/EventLogTags.logtags
@@ -0,0 +1,33 @@
+# See system/core/logcat/event.logtags for a description of the format of this file.
+
+option java_package com.android.systemui;
+
+# ---------------------------
+# PhoneStatusBar.java
+# ---------------------------
+36000 sysui_statusbar_touch (type|1),(x|1),(y|1),(enabled|1)
+
+# ---------------------------
+# PhoneStatusBarView.java
+# ---------------------------
+36010 sysui_panelbar_touch (type|1),(x|1),(y|1),(enabled|1)
+
+# ---------------------------
+# NotificationPanelView.java
+# ---------------------------
+36020 sysui_notificationpanel_touch (type|1),(x|1),(y|1)
+
+# ---------------------------
+# SettingsPanelView.java
+# ---------------------------
+36030 sysui_quickpanel_touch (type|1),(x|1),(y|1)
+
+# ---------------------------
+# PanelHolder.java
+# ---------------------------
+36040 sysui_panelholder_touch (type|1),(x|1),(y|1)
+
+# ---------------------------
+# SearchPanelView.java
+# ---------------------------
+36050 sysui_searchpanel_touch (type|1),(x|1),(y|1)
diff --git a/packages/SystemUI/src/com/android/systemui/SearchPanelView.java b/packages/SystemUI/src/com/android/systemui/SearchPanelView.java
index daac9ed..c0a6f56 100644
--- a/packages/SystemUI/src/com/android/systemui/SearchPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/SearchPanelView.java
@@ -31,6 +31,7 @@
 import android.os.Vibrator;
 import android.provider.Settings;
 import android.util.AttributeSet;
+import android.util.EventLog;
 import android.util.Slog;
 import android.view.IWindowManager;
 import android.view.MotionEvent;
@@ -42,6 +43,8 @@
 
 import com.android.internal.widget.multiwaveview.GlowPadView;
 import com.android.internal.widget.multiwaveview.GlowPadView.OnTriggerListener;
+
+import com.android.systemui.EventLogTags;
 import com.android.systemui.R;
 import com.android.systemui.recent.StatusBarTouchProxy;
 import com.android.systemui.statusbar.BaseStatusBar;
@@ -55,6 +58,7 @@
     private static final int SEARCH_PANEL_HOLD_DURATION = 0;
     static final String TAG = "SearchPanelView";
     static final boolean DEBUG = TabletStatusBar.DEBUG || PhoneStatusBar.DEBUG || false;
+    public static final boolean DEBUG_GESTURES = true;
     private static final String ASSIST_ICON_METADATA_NAME =
             "com.android.systemui.action_assist_icon";
     private final Context mContext;
@@ -304,6 +308,17 @@
         }
     }
 
+    @Override
+    public boolean onTouchEvent(MotionEvent event) {
+        if (DEBUG_GESTURES) {
+            if (event.getActionMasked() != MotionEvent.ACTION_MOVE) {
+                EventLog.writeEvent(EventLogTags.SYSUI_SEARCHPANEL_TOUCH,
+                        event.getActionMasked(), (int) event.getX(), (int) event.getY());
+            }
+        }
+        return super.onTouchEvent(event);
+    }
+
     private LayoutTransition createLayoutTransitioner() {
         LayoutTransition transitioner = new LayoutTransition();
         transitioner.setDuration(200);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java b/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java
index 6424a71..baaefab 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java
@@ -148,10 +148,14 @@
         if (mWifiGroup == null) return;
 
         if (mWifiVisible) {
-            mWifiGroup.setVisibility(View.VISIBLE);
+            mWifi.setImageDrawable(null);
+            mWifiActivity.setImageDrawable(null);
+
             mWifi.setImageResource(mWifiStrengthId);
             mWifiActivity.setImageResource(mWifiActivityId);
+
             mWifiGroup.setContentDescription(mWifiDescription);
+            mWifiGroup.setVisibility(View.VISIBLE);
         } else {
             mWifiGroup.setVisibility(View.GONE);
         }
@@ -162,11 +166,16 @@
                     mWifiStrengthId, mWifiActivityId));
 
         if (mMobileVisible && !mIsAirplaneMode) {
-            mMobileGroup.setVisibility(View.VISIBLE);
+            mMobile.setImageDrawable(null);
+            mMobileActivity.setImageDrawable(null);
+            mMobileType.setImageDrawable(null);
+
             mMobile.setImageResource(mMobileStrengthId);
             mMobileActivity.setImageResource(mMobileActivityId);
             mMobileType.setImageResource(mMobileTypeId);
+
             mMobileGroup.setContentDescription(mMobileTypeDescription + " " + mMobileDescription);
+            mMobileGroup.setVisibility(View.VISIBLE);
         } else {
             mMobileGroup.setVisibility(View.GONE);
         }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java
index dbc55c8..39d56a4 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java
@@ -118,12 +118,7 @@
         mIcon = icon.clone();
         setContentDescription(icon.contentDescription);
         if (!iconEquals) {
-            Drawable drawable = getIcon(icon);
-            if (drawable == null) {
-                Slog.w(TAG, "No icon for slot " + mSlot);
-                return false;
-            }
-            setImageDrawable(drawable);
+            if (!updateDrawable(false /* no clear */)) return false;
         }
         if (!levelEquals) {
             setImageLevel(icon.iconLevel);
@@ -149,6 +144,23 @@
         return true;
     }
 
+    public void updateDrawable() {
+        updateDrawable(true /* with clear */);
+    }
+
+    private boolean updateDrawable(boolean withClear) {
+        Drawable drawable = getIcon(mIcon);
+        if (drawable == null) {
+            Slog.w(TAG, "No icon for slot " + mSlot);
+            return false;
+        }
+        if (withClear) {
+            setImageDrawable(null);
+        }
+        setImageDrawable(drawable);
+        return true;
+    }
+
     private Drawable getIcon(StatusBarIcon icon) {
         return getIcon(getContext(), icon);
     }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
index 2bad353..ff36485 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
@@ -21,14 +21,17 @@
 import android.graphics.Canvas;
 import android.graphics.drawable.Drawable;
 import android.util.AttributeSet;
+import android.util.EventLog;
 import android.util.Slog;
 import android.view.MotionEvent;
 import android.view.View;
 
+import com.android.systemui.EventLogTags;
 import com.android.systemui.R;
 import com.android.systemui.statusbar.GestureRecorder;
 
 public class NotificationPanelView extends PanelView {
+    public static final boolean DEBUG_GESTURES = true;
 
     Drawable mHandleBar;
     int mHandleBarHeight;
@@ -91,6 +94,12 @@
 
     @Override
     public boolean onTouchEvent(MotionEvent event) {
+        if (DEBUG_GESTURES) {
+            if (event.getActionMasked() != MotionEvent.ACTION_MOVE) {
+                EventLog.writeEvent(EventLogTags.SYSUI_NOTIFICATIONPANEL_TOUCH,
+                       event.getActionMasked(), (int) event.getX(), (int) event.getY());
+            }
+        }
         if (PhoneStatusBar.SETTINGS_DRAG_SHORTCUT && mStatusBar.mHasFlipSettings) {
             switch (event.getActionMasked()) {
                 case MotionEvent.ACTION_DOWN:
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelHolder.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelHolder.java
index 8a54347..c229a09 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelHolder.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelHolder.java
@@ -18,10 +18,14 @@
 
 import android.content.Context;
 import android.util.AttributeSet;
+import android.util.EventLog;
 import android.view.MotionEvent;
 import android.widget.FrameLayout;
 
+import com.android.systemui.EventLogTags;
+
 public class PanelHolder extends FrameLayout {
+    public static final boolean DEBUG_GESTURES = true;
 
     private int mSelectedPanelIndex = -1;
     private PanelBar mBar;
@@ -67,6 +71,12 @@
 
     @Override
     public boolean onTouchEvent(MotionEvent event) {
+        if (DEBUG_GESTURES) {
+            if (event.getActionMasked() != MotionEvent.ACTION_MOVE) {
+                EventLog.writeEvent(EventLogTags.SYSUI_PANELHOLDER_TOUCH,
+                        event.getActionMasked(), (int) event.getX(), (int) event.getY());
+            }
+        }
         switch (event.getAction()) {
             case MotionEvent.ACTION_DOWN:
                 PanelBar.LOG("PanelHolder got touch in open air, closing panels");
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index fea1a05..3227a34 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -52,6 +52,7 @@
 import android.service.dreams.DreamService;
 import android.service.dreams.IDreamManager;
 import android.util.DisplayMetrics;
+import android.util.EventLog;
 import android.util.Log;
 import android.util.Slog;
 import android.view.Display;
@@ -76,6 +77,7 @@
 
 import com.android.internal.statusbar.StatusBarIcon;
 import com.android.internal.statusbar.StatusBarNotification;
+import com.android.systemui.EventLogTags;
 import com.android.systemui.R;
 import com.android.systemui.statusbar.BaseStatusBar;
 import com.android.systemui.statusbar.CommandQueue;
@@ -103,7 +105,7 @@
     public static final boolean DEBUG = BaseStatusBar.DEBUG;
     public static final boolean SPEW = DEBUG;
     public static final boolean DUMPTRUCK = true; // extra dumpsys info
-    public static final boolean DEBUG_GESTURES = false;
+    public static final boolean DEBUG_GESTURES = true;
 
     public static final boolean DEBUG_CLINGS = false;
 
@@ -835,6 +837,16 @@
         mWindowManager.addView(mIntruderAlertView, lp);
     }
 
+    public void refreshAllStatusBarIcons() {
+        final int count = mStatusIcons.getChildCount();
+        for (int n = 0; n < count; n++) {
+            View child = mStatusIcons.getChildAt(n);
+            if (child instanceof StatusBarIconView) {
+                ((StatusBarIconView) child).updateDrawable();
+            }
+        }
+    }
+
     public void addIcon(String slot, int index, int viewIndex, StatusBarIcon icon) {
         if (SPEW) Slog.d(TAG, "addIcon slot=" + slot + " index=" + index + " viewIndex=" + viewIndex
                 + " icon=" + icon);
@@ -982,6 +994,8 @@
             mNotificationButton.setImageDrawable(null);
             mNotificationButton.setImageResource(R.drawable.ic_notifications);
         }
+
+        refreshAllStatusBarIcons();
     }
 
     private void updateShowSearchHoldoff() {
@@ -1775,6 +1789,14 @@
     }
 
     public boolean interceptTouchEvent(MotionEvent event) {
+        if (DEBUG_GESTURES) {
+            if (event.getActionMasked() != MotionEvent.ACTION_MOVE) {
+                EventLog.writeEvent(EventLogTags.SYSUI_STATUSBAR_TOUCH,
+                        event.getActionMasked(), (int) event.getX(), (int) event.getY(), mDisabled);
+            }
+
+        }
+
         if (SPEW) {
             Slog.d(TAG, "Touch: rawY=" + event.getRawY() + " event=" + event + " mDisabled="
                 + mDisabled + " mTracking=" + mTracking);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
index 571544b..de9f750 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
@@ -22,15 +22,19 @@
 import android.content.res.Resources;
 import android.content.res.Resources.NotFoundException;
 import android.util.AttributeSet;
+import android.util.EventLog;
 import android.util.Slog;
 import android.view.MotionEvent;
 import android.view.View;
 import android.view.accessibility.AccessibilityEvent;
+
+import com.android.systemui.EventLogTags;
 import com.android.systemui.R;
 
 public class PhoneStatusBarView extends PanelBar {
     private static final String TAG = "PhoneStatusBarView";
     private static final boolean DEBUG = PhoneStatusBar.DEBUG;
+    private static final boolean DEBUG_GESTURES = true;
 
     PhoneStatusBar mBar;
     int mScrimColor;
@@ -175,7 +179,17 @@
 
     @Override
     public boolean onTouchEvent(MotionEvent event) {
-        return mBar.interceptTouchEvent(event) || super.onTouchEvent(event);
+        boolean barConsumedEvent = mBar.interceptTouchEvent(event);
+
+        if (DEBUG_GESTURES) {
+            if (event.getActionMasked() != MotionEvent.ACTION_MOVE) {
+                EventLog.writeEvent(EventLogTags.SYSUI_PANELBAR_TOUCH,
+                        event.getActionMasked(), (int) event.getX(), (int) event.getY(),
+                        barConsumedEvent ? 1 : 0);
+            }
+        }
+
+        return barConsumedEvent || super.onTouchEvent(event);
     }
 
     @Override
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java
index a6500a2..4ff3862 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java
@@ -471,6 +471,8 @@
                     ImageView iv = (ImageView) view.findViewById(R.id.rssi_image);
                     ImageView iov = (ImageView) view.findViewById(R.id.rssi_overlay_image);
                     TextView tv = (TextView) view.findViewById(R.id.rssi_textview);
+                    // Force refresh
+                    iv.setImageDrawable(null);
                     iv.setImageResource(rssiState.signalIconId);
 
                     if (rssiState.dataTypeIconId > 0) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/SettingsPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/SettingsPanelView.java
index bbb8455..2314d93 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/SettingsPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/SettingsPanelView.java
@@ -23,10 +23,13 @@
 import android.graphics.Canvas;
 import android.graphics.drawable.Drawable;
 import android.util.AttributeSet;
+import android.util.EventLog;
 import android.view.LayoutInflater;
+import android.view.MotionEvent;
 import android.view.View;
 import android.view.ViewGroup;
 
+import com.android.systemui.EventLogTags;
 import com.android.systemui.R;
 import com.android.systemui.statusbar.BaseStatusBar;
 import com.android.systemui.statusbar.GestureRecorder;
@@ -36,6 +39,7 @@
 import com.android.systemui.statusbar.policy.NetworkController;
 
 public class SettingsPanelView extends PanelView {
+    public static final boolean DEBUG_GESTURES = true;
 
     private QuickSettings mQS;
     private QuickSettingsContainerView mQSContainer;
@@ -136,4 +140,15 @@
         mHandleBar.draw(canvas);
         canvas.translate(0, -off);
     }
+
+    @Override
+    public boolean onTouchEvent(MotionEvent event) {
+        if (DEBUG_GESTURES) {
+            if (event.getActionMasked() != MotionEvent.ACTION_MOVE) {
+                EventLog.writeEvent(EventLogTags.SYSUI_QUICKPANEL_TOUCH,
+                       event.getActionMasked(), (int) event.getX(), (int) event.getY());
+            }
+        }
+        return super.onTouchEvent(event);
+    }
 }
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
index 5bf7e21..71e80831d 100644
--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -412,6 +412,8 @@
     boolean mForceStatusBar;
     boolean mForceStatusBarFromKeyguard;
     boolean mHideLockScreen;
+    boolean mForcingShowNavBar;
+    int mForcingShowNavBarLayer;
 
     // States of keyguard dismiss.
     private static final int DISMISS_KEYGUARD_NONE = 0; // Keyguard not being dismissed.
@@ -1711,31 +1713,40 @@
     static final boolean PRINT_ANIM = false;
     
     /** {@inheritDoc} */
+    @Override
     public int selectAnimationLw(WindowState win, int transit) {
         if (PRINT_ANIM) Log.i(TAG, "selectAnimation in " + win
               + ": transit=" + transit);
         if (win == mStatusBar) {
-            if (transit == TRANSIT_EXIT || transit == TRANSIT_HIDE) {
+            if (transit == TRANSIT_EXIT
+                    || transit == TRANSIT_HIDE) {
                 return R.anim.dock_top_exit;
-            } else if (transit == TRANSIT_ENTER || transit == TRANSIT_SHOW) {
+            } else if (transit == TRANSIT_ENTER
+                    || transit == TRANSIT_SHOW) {
                 return R.anim.dock_top_enter;
             }
         } else if (win == mNavigationBar) {
             // This can be on either the bottom or the right.
             if (mNavigationBarOnBottom) {
-                if (transit == TRANSIT_EXIT || transit == TRANSIT_HIDE) {
+                if (transit == TRANSIT_EXIT
+                        || transit == TRANSIT_HIDE) {
                     return R.anim.dock_bottom_exit;
-                } else if (transit == TRANSIT_ENTER || transit == TRANSIT_SHOW) {
+                } else if (transit == TRANSIT_ENTER
+                        || transit == TRANSIT_SHOW) {
                     return R.anim.dock_bottom_enter;
                 }
             } else {
-                if (transit == TRANSIT_EXIT || transit == TRANSIT_HIDE) {
+                if (transit == TRANSIT_EXIT
+                        || transit == TRANSIT_HIDE) {
                     return R.anim.dock_right_exit;
-                } else if (transit == TRANSIT_ENTER || transit == TRANSIT_SHOW) {
+                } else if (transit == TRANSIT_ENTER
+                        || transit == TRANSIT_SHOW) {
                     return R.anim.dock_right_enter;
                 }
             }
-        } if (transit == TRANSIT_PREVIEW_DONE) {
+        }
+
+        if (transit == TRANSIT_PREVIEW_DONE) {
             if (win.hasAppShownWindows()) {
                 if (PRINT_ANIM) Log.i(TAG, "**** STARTING EXIT");
                 return com.android.internal.R.anim.app_starting_exit;
@@ -2943,6 +2954,8 @@
         mTopFullscreenOpaqueWindowState = null;
         mForceStatusBar = false;
         mForceStatusBarFromKeyguard = false;
+        mForcingShowNavBar = false;
+        mForcingShowNavBarLayer = -1;
         
         mHideLockScreen = false;
         mAllowLockscreenWhenOn = false;
@@ -2957,6 +2970,13 @@
                                 WindowManager.LayoutParams attrs) {
         if (DEBUG_LAYOUT) Slog.i(TAG, "Win " + win + ": isVisibleOrBehindKeyguardLw="
                 + win.isVisibleOrBehindKeyguardLw());
+        if (mTopFullscreenOpaqueWindowState == null && (win.getAttrs().privateFlags
+                &WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_SHOW_NAV_BAR) != 0) {
+            if (mForcingShowNavBarLayer < 0) {
+                mForcingShowNavBar = true;
+                mForcingShowNavBarLayer = win.getSurfaceLayer();
+            }
+        }
         if (mTopFullscreenOpaqueWindowState == null &&
                 win.isVisibleOrBehindKeyguardLw() && !win.isGoneForLayoutLw()) {
             if ((attrs.flags & FLAG_FORCE_NOT_FULLSCREEN) != 0) {
@@ -4485,9 +4505,13 @@
             // will quickly lose focus once it correctly gets hidden.
             return 0;
         }
-        final int visibility = mFocusedWindow.getSystemUiVisibility()
+        int tmpVisibility = mFocusedWindow.getSystemUiVisibility()
                 & ~mResettingSystemUiFlags
                 & ~mForceClearedSystemUiFlags;
+        if (mForcingShowNavBar && mFocusedWindow.getSurfaceLayer() < mForcingShowNavBarLayer) {
+            tmpVisibility &= ~View.SYSTEM_UI_CLEARABLE_FLAGS;
+        }
+        final int visibility = tmpVisibility;
         int diff = visibility ^ mLastSystemUiFlags;
         final boolean needsMenu = mFocusedWindow.getNeedsMenuLw(mTopFullscreenOpaqueWindowState);
         if (diff == 0 && mLastFocusNeedsMenu == needsMenu
@@ -4568,71 +4592,6 @@
         return true;
     }
 
-    /**
-     * Returns the human readable name of a window transition.
-     *
-     * @param transition The window transition.
-     * @return The transition symbolic name.
-     */
-    public static String windowTransitionToString(int transition) {
-        switch (transition) {
-            case WindowManagerPolicy.TRANSIT_UNSET: {
-                return "TRANSIT_UNSET";
-            }
-            case WindowManagerPolicy.TRANSIT_NONE: {
-                return "TRANSIT_NONE";
-            }
-            case WindowManagerPolicy.TRANSIT_ENTER: {
-                return "TRANSIT_ENTER";
-            }
-            case WindowManagerPolicy.TRANSIT_EXIT: {
-                return "TRANSIT_EXIT";
-            }
-            case WindowManagerPolicy.TRANSIT_SHOW: {
-                return "TRANSIT_SHOW";
-            }
-            case WindowManagerPolicy.TRANSIT_EXIT_MASK: {
-                return "TRANSIT_EXIT_MASK";
-            }
-            case WindowManagerPolicy.TRANSIT_PREVIEW_DONE: {
-                return "TRANSIT_PREVIEW_DONE";
-            }
-            case WindowManagerPolicy.TRANSIT_ACTIVITY_OPEN: {
-                return "TRANSIT_ACTIVITY_OPEN";
-            }
-            case WindowManagerPolicy.TRANSIT_ACTIVITY_CLOSE: {
-                return "TRANSIT_ACTIVITY_CLOSE";
-            }
-            case WindowManagerPolicy.TRANSIT_TASK_OPEN: {
-                return "TRANSIT_TASK_OPEN";
-            }
-            case WindowManagerPolicy.TRANSIT_TASK_CLOSE: {
-                return "TRANSIT_TASK_CLOSE";
-            }
-            case WindowManagerPolicy.TRANSIT_TASK_TO_FRONT: {
-                return "TRANSIT_TASK_TO_FRONT";
-            }
-            case WindowManagerPolicy.TRANSIT_TASK_TO_BACK: {
-                return "TRANSIT_TASK_TO_BACK";
-            }
-            case WindowManagerPolicy.TRANSIT_WALLPAPER_CLOSE: {
-                return "TRANSIT_WALLPAPER_CLOSE";
-            }
-            case WindowManagerPolicy.TRANSIT_WALLPAPER_OPEN: {
-                return "TRANSIT_WALLPAPER_OPEN";
-            }
-            case WindowManagerPolicy.TRANSIT_WALLPAPER_INTRA_OPEN: {
-                return "TRANSIT_WALLPAPER_INTRA_OPEN";
-            }
-            case WindowManagerPolicy.TRANSIT_WALLPAPER_INTRA_CLOSE: {
-                return "TRANSIT_WALLPAPER_INTRA_CLOSE";
-            }
-            default: {
-                return "<UNKNOWN>";
-            }
-        }
-    }
-
     @Override
     public void dump(String prefix, PrintWriter pw, String[] args) {
         pw.print(prefix); pw.print("mSafeMode="); pw.print(mSafeMode);
@@ -4748,6 +4707,11 @@
             pw.print(prefix); pw.print("mTopFullscreenOpaqueWindowState=");
                     pw.println(mTopFullscreenOpaqueWindowState);
         }
+        if (mForcingShowNavBar) {
+            pw.print(prefix); pw.print("mForcingShowNavBar=");
+                    pw.println(mForcingShowNavBar); pw.print( "mForcingShowNavBarLayer=");
+                    pw.println(mForcingShowNavBarLayer);
+        }
         pw.print(prefix); pw.print("mTopIsFullscreen="); pw.print(mTopIsFullscreen);
                 pw.print(" mHideLockScreen="); pw.println(mHideLockScreen);
         pw.print(prefix); pw.print("mForceStatusBar="); pw.print(mForceStatusBar);
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardFaceUnlockView.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardFaceUnlockView.java
index de3354a..4df434c 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardFaceUnlockView.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardFaceUnlockView.java
@@ -197,7 +197,7 @@
         }
 
         @Override
-        public void onUserSwitched(int userId) {
+        public void onUserSwitching(int userId) {
             if (DEBUG) Log.d(TAG, "onUserSwitched(" + userId + ")");
             if (mBiometricUnlock != null) {
                 mBiometricUnlock.stop();
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java
index b05d111..217e5d7 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java
@@ -101,9 +101,12 @@
     private boolean mSafeModeEnabled;
 
     private boolean mUserSetupCompleted;
+
     // User for whom this host view was created
     private int mUserId;
 
+    private KeyguardMultiUserSelectorView mKeyguardMultiUserSelectorView;
+
     /*package*/ interface TransportCallback {
         void onListenerDetached();
         void onListenerAttached();
@@ -209,6 +212,12 @@
                 mCleanupAppWidgetsOnBootCompleted = false;
             }
         }
+        @Override
+        public void onUserSwitchComplete(int userId) {
+            if (mKeyguardMultiUserSelectorView != null) {
+                mKeyguardMultiUserSelectorView.finalizeActiveUserView(true);
+            }
+        }
     };
 
     private SlidingChallengeLayout mSlidingChallengeLayout;
@@ -399,6 +408,12 @@
         }
     };
 
+    public void initializeSwitchingUserState(boolean switching) {
+        if (!switching && mKeyguardMultiUserSelectorView != null) {
+            mKeyguardMultiUserSelectorView.finalizeActiveUserView(false);
+        }
+    }
+
     public void userActivity() {
         if (mViewMediatorCallback != null) {
             mViewMediatorCallback.userActivity();
@@ -1452,10 +1467,9 @@
 
         if (users.size() > 1) {
             if (multiUserView instanceof KeyguardMultiUserSelectorView) {
-                KeyguardMultiUserSelectorView multiUser =
-                        (KeyguardMultiUserSelectorView) multiUserView;
-                multiUser.setVisibility(View.VISIBLE);
-                multiUser.addUsers(users);
+                mKeyguardMultiUserSelectorView = (KeyguardMultiUserSelectorView) multiUserView;
+                mKeyguardMultiUserSelectorView.setVisibility(View.VISIBLE);
+                mKeyguardMultiUserSelectorView.addUsers(users);
                 UserSwitcherCallback callback = new UserSwitcherCallback() {
                     @Override
                     public void hideSecurityView(int duration) {
@@ -1481,7 +1495,7 @@
                         }
                     }
                 };
-                multiUser.setCallback(callback);
+                mKeyguardMultiUserSelectorView.setCallback(callback);
             } else {
                 Throwable t = new Throwable();
                 t.fillInStackTrace();
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardMultiUserAvatar.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardMultiUserAvatar.java
index 7bf2bf9..9d1f041 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardMultiUserAvatar.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardMultiUserAvatar.java
@@ -69,6 +69,7 @@
     private boolean mInit = true;
     private KeyguardMultiUserSelectorView mUserSelector;
     private KeyguardCircleFramedDrawable mFramed;
+    private boolean mPressLock;
 
     public static KeyguardMultiUserAvatar fromXml(int resId, Context context,
             KeyguardMultiUserSelectorView userSelector, UserInfo info) {
@@ -212,13 +213,22 @@
 
     @Override
     public void setPressed(boolean pressed) {
-        if (!pressed || isClickable()) {
+        if (mPressLock && !pressed) {
+            return;
+        }
+
+        if (mPressLock || !pressed || isClickable()) {
             super.setPressed(pressed);
             mFramed.setPressed(pressed);
             mUserImage.invalidate();
         }
     }
 
+    public void lockPressed(boolean pressed) {
+        mPressLock = pressed;
+        setPressed(pressed);
+    }
+
     public UserInfo getUserInfo() {
         return mUserInfo;
     }
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardMultiUserSelectorView.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardMultiUserSelectorView.java
index 728e87c..f9ea5bb 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardMultiUserSelectorView.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardMultiUserSelectorView.java
@@ -81,11 +81,28 @@
             KeyguardMultiUserAvatar uv = createAndAddUser(user);
             if (user.id == activeUser.id) {
                 mActiveUserAvatar = uv;
-                mActiveUserAvatar.setActive(true, false, null);
-            } else {
-                uv.setActive(false, false, null);
             }
+            uv.setActive(false, false, null);
         }
+        mActiveUserAvatar.lockPressed(true);
+    }
+
+    public void finalizeActiveUserView(boolean animate) {
+        if (animate) {
+            getHandler().postDelayed(new Runnable() {
+                    @Override
+                        public void run() {
+                        finalizeActiveUserNow(true);
+                    }
+                }, 500);
+        } else {
+            finalizeActiveUserNow(animate);
+        }
+    }
+
+    void finalizeActiveUserNow(boolean animate) {
+        mActiveUserAvatar.lockPressed(false);
+        mActiveUserAvatar.setActive(true, animate, null);
     }
 
     Comparator<UserInfo> mOrderAddedComparator = new Comparator<UserInfo>() {
@@ -132,25 +149,21 @@
                 // Reset the previously active user to appear inactive
                 mCallback.hideSecurityView(FADE_OUT_ANIMATION_DURATION);
                 setAllClickable(false);
+                avatar.lockPressed(true);
                 mActiveUserAvatar.setActive(false, true, new Runnable() {
                     @Override
                     public void run() {
                         mActiveUserAvatar = avatar;
-                        mActiveUserAvatar.setActive(true, true, new Runnable() {
-                            @Override
-                            public void run() {
-                                if (this.getClass().getName().contains("internal")) {
-                                    try {
-                                        ActivityManagerNative.getDefault()
-                                                .switchUser(avatar.getUserInfo().id);
-                                    } catch (RemoteException re) {
-                                        Log.e(TAG, "Couldn't switch user " + re);
-                                    }
-                                } else {
-                                    setAllClickable(true);
-                                }
+                        if (this.getClass().getName().contains("internal")) {
+                            try {
+                                ActivityManagerNative.getDefault()
+                                        .switchUser(avatar.getUserInfo().id);
+                            } catch (RemoteException re) {
+                                Log.e(TAG, "Couldn't switch user " + re);
                             }
-                        });
+                        } else {
+                            setAllClickable(true);
+                        }
                     }
                 });
             }
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardUpdateMonitor.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardUpdateMonitor.java
index ad6f55c..c9bffbe 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardUpdateMonitor.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardUpdateMonitor.java
@@ -79,10 +79,11 @@
     private static final int MSG_CLOCK_VISIBILITY_CHANGED = 307;
     private static final int MSG_DEVICE_PROVISIONED = 308;
     private static final int MSG_DPM_STATE_CHANGED = 309;
-    private static final int MSG_USER_SWITCHED = 310;
+    private static final int MSG_USER_SWITCHING = 310;
     private static final int MSG_USER_REMOVED = 311;
     private static final int MSG_KEYGUARD_VISIBILITY_CHANGED = 312;
     protected static final int MSG_BOOT_COMPLETED = 313;
+    private static final int MSG_USER_SWITCH_COMPLETE = 314;
 
 
     private static KeyguardUpdateMonitor sInstance;
@@ -147,8 +148,11 @@
                 case MSG_DPM_STATE_CHANGED:
                     handleDevicePolicyManagerStateChanged();
                     break;
-                case MSG_USER_SWITCHED:
-                    handleUserSwitched(msg.arg1, (IRemoteCallback)msg.obj);
+                case MSG_USER_SWITCHING:
+                    handleUserSwitching(msg.arg1, (IRemoteCallback)msg.obj);
+                    break;
+                case MSG_USER_SWITCH_COMPLETE:
+                    handleUserSwitchComplete(msg.arg1);
                     break;
                 case MSG_USER_REMOVED:
                     handleUserRemoved(msg.arg1);
@@ -359,11 +363,13 @@
                     new IUserSwitchObserver.Stub() {
                         @Override
                         public void onUserSwitching(int newUserId, IRemoteCallback reply) {
-                            mHandler.sendMessage(mHandler.obtainMessage(MSG_USER_SWITCHED,
+                            mHandler.sendMessage(mHandler.obtainMessage(MSG_USER_SWITCHING,
                                     newUserId, 0, reply));
                         }
                         @Override
                         public void onUserSwitchComplete(int newUserId) throws RemoteException {
+                            mHandler.sendMessage(mHandler.obtainMessage(MSG_USER_SWITCH_COMPLETE,
+                                    newUserId));
                         }
                     });
         } catch (RemoteException e) {
@@ -418,13 +424,13 @@
     }
 
     /**
-     * Handle {@link #MSG_USER_SWITCHED}
+     * Handle {@link #MSG_USER_SWITCHING}
      */
-    protected void handleUserSwitched(int userId, IRemoteCallback reply) {
+    protected void handleUserSwitching(int userId, IRemoteCallback reply) {
         for (int i = 0; i < mCallbacks.size(); i++) {
             KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
             if (cb != null) {
-                cb.onUserSwitched(userId);
+                cb.onUserSwitching(userId);
             }
         }
         setAlternateUnlockEnabled(false);
@@ -435,6 +441,18 @@
     }
 
     /**
+     * Handle {@link #MSG_USER_SWITCH_COMPLETE}
+     */
+    protected void handleUserSwitchComplete(int userId) {
+        for (int i = 0; i < mCallbacks.size(); i++) {
+            KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
+            if (cb != null) {
+                cb.onUserSwitchComplete(userId);
+            }
+        }
+    }
+
+    /**
      * Handle {@link #MSG_BOOT_COMPLETED}
      */
     protected void handleBootCompleted() {
@@ -456,7 +474,7 @@
     }
 
     /**
-     * Handle {@link #MSG_USER_SWITCHED}
+     * Handle {@link #MSG_USER_REMOVED}
      */
     protected void handleUserRemoved(int userId) {
         for (int i = 0; i < mCallbacks.size(); i++) {
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardUpdateMonitorCallback.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardUpdateMonitorCallback.java
index 1ba1388..2126f06 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardUpdateMonitorCallback.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardUpdateMonitorCallback.java
@@ -85,9 +85,14 @@
     void onDevicePolicyManagerStateChanged() { }
 
     /**
-     * Called when the user changes.
+     * Called when the user change begins.
      */
-    void onUserSwitched(int userId) { }
+    void onUserSwitching(int userId) { }
+
+    /**
+     * Called when the user change is complete.
+     */
+    void onUserSwitchComplete(int userId) { }
 
     /**
      * Called when the SIM state changes.
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java
index ff136b1..8562f0c 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java
@@ -53,6 +53,7 @@
     private final static boolean DEBUG = KeyguardViewMediator.DEBUG;
     private static String TAG = "KeyguardViewManager";
     public static boolean USE_UPPER_CASE = true;
+    public final static String IS_SWITCHING_USER = "is_switching_user";
 
     // Timeout used for keypresses
     static final int DIGIT_PRESS_WAKE_MILLIS = 5000;
@@ -237,6 +238,8 @@
         mKeyguardView = (KeyguardHostView) view.findViewById(R.id.keyguard_host_view);
         mKeyguardView.setLockPatternUtils(mLockPatternUtils);
         mKeyguardView.setViewMediatorCallback(mViewMediatorCallback);
+        mKeyguardView.initializeSwitchingUserState(options != null &&
+                options.getBoolean(IS_SWITCHING_USER));
 
         // HACK
         // The keyguard view will have set up window flags in onFinishInflate before we set
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java
index 7d757ff..fef0613 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java
@@ -153,6 +153,7 @@
     private StatusBarManager mStatusBarManager;
     private boolean mShowLockIcon;
     private boolean mShowingLockIcon;
+    private boolean mSwitchingUser;
 
     private boolean mSystemReady;
 
@@ -310,11 +311,12 @@
     KeyguardUpdateMonitorCallback mUpdateCallback = new KeyguardUpdateMonitorCallback() {
 
         @Override
-        public void onUserSwitched(int userId) {
+        public void onUserSwitching(int userId) {
             // Note that the mLockPatternUtils user has already been updated from setCurrentUser.
             // We need to force a reset of the views, since lockNow (called by
             // ActivityManagerService) will not reconstruct the keyguard if it is already showing.
             synchronized (KeyguardViewMediator.this) {
+                mSwitchingUser = true;
                 resetStateLocked(null);
                 adjustStatusBarLocked();
                 // Disable face unlock when the user switches.
@@ -323,6 +325,11 @@
         }
 
         @Override
+        public void onUserSwitchComplete(int userId) {
+            mSwitchingUser = false;
+        }
+
+        @Override
         public void onUserRemoved(int userId) {
             mLockPatternUtils.removeUser(userId);
         }
@@ -1361,6 +1368,10 @@
      * @see #RESET
      */
     private void handleReset(Bundle options) {
+        if (options == null) {
+            options = new Bundle();
+        }
+        options.putBoolean(KeyguardViewManager.IS_SWITCHING_USER, mSwitchingUser);
         synchronized (KeyguardViewMediator.this) {
             if (DEBUG) Log.d(TAG, "handleReset");
             mKeyguardViewManager.reset(options);
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetPager.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetPager.java
index b4fe0c7..ad5e257 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetPager.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetPager.java
@@ -27,6 +27,7 @@
 import android.content.Context;
 import android.os.Handler;
 import android.os.HandlerThread;
+import android.text.format.DateFormat;
 import android.util.AttributeSet;
 import android.util.Slog;
 import android.view.Gravity;
@@ -38,10 +39,12 @@
 import android.view.accessibility.AccessibilityManager;
 import android.view.animation.DecelerateInterpolator;
 import android.widget.FrameLayout;
+import android.widget.TextClock;
 
 import com.android.internal.widget.LockPatternUtils;
 
 import java.util.ArrayList;
+import java.util.TimeZone;
 
 public class KeyguardWidgetPager extends PagedView implements PagedView.PageSwitchListener,
         OnLongClickListener, ChallengeLayout.OnBouncerStateChangedListener {
@@ -51,6 +54,9 @@
     protected static float OVERSCROLL_MAX_ROTATION = 30;
     private static final boolean PERFORM_OVERSCROLL_ROTATION = true;
 
+    private static final int FLAG_HAS_LOCAL_HOUR = 0x1;
+    private static final int FLAG_HAS_LOCAL_MINUTE = 0x2;
+
     protected KeyguardViewStateManager mViewStateManager;
     private LockPatternUtils mLockPatternUtils;
 
@@ -131,16 +137,21 @@
 
     @Override
     public void onPageSwitched(View newPage, int newPageIndex) {
-        boolean showingStatusWidget = false;
+        boolean showingClock = false;
         if (newPage instanceof ViewGroup) {
             ViewGroup vg = (ViewGroup) newPage;
             if (vg.getChildAt(0) instanceof KeyguardStatusView) {
-                showingStatusWidget = true;
+                showingClock = true;
             }
         }
 
+        if (newPage != null &&
+                findClockInHierarchy(newPage) == (FLAG_HAS_LOCAL_HOUR | FLAG_HAS_LOCAL_MINUTE)) {
+            showingClock = true;
+        }
+
         // Disable the status bar clock if we're showing the default status widget
-        if (showingStatusWidget) {
+        if (showingClock) {
             setSystemUiVisibility(getSystemUiVisibility() | View.STATUS_BAR_DISABLE_CLOCK);
         } else {
             setSystemUiVisibility(getSystemUiVisibility() & ~View.STATUS_BAR_DISABLE_CLOCK);
@@ -857,4 +868,53 @@
     protected boolean shouldSetTopAlignedPivotForWidget(int childIndex) {
         return !isCameraPage(childIndex) && super.shouldSetTopAlignedPivotForWidget(childIndex);
     }
+
+    /**
+     * Search given {@link View} hierarchy for {@link TextClock} instances that
+     * show various time components. Returns combination of
+     * {@link #FLAG_HAS_LOCAL_HOUR} and {@link #FLAG_HAS_LOCAL_MINUTE}.
+     */
+    private static int findClockInHierarchy(View view) {
+        if (view instanceof TextClock) {
+            return getClockFlags((TextClock) view);
+        } else if (view instanceof ViewGroup) {
+            int flags = 0;
+            final ViewGroup group = (ViewGroup) view;
+            final int size = group.getChildCount();
+            for (int i = 0; i < size; i++) {
+                flags |= findClockInHierarchy(group.getChildAt(i));
+            }
+            return flags;
+        } else {
+            return 0;
+        }
+    }
+
+    /**
+     * Return combination of {@link #FLAG_HAS_LOCAL_HOUR} and
+     * {@link #FLAG_HAS_LOCAL_MINUTE} describing the time represented described
+     * by the given {@link TextClock}.
+     */
+    private static int getClockFlags(TextClock clock) {
+        int flags = 0;
+
+        final String timeZone = clock.getTimeZone();
+        if (timeZone != null && !TimeZone.getDefault().equals(TimeZone.getTimeZone(timeZone))) {
+            // Ignore clocks showing another timezone
+            return 0;
+        }
+
+        final CharSequence format = clock.getFormat();
+        final char hour = clock.is24HourModeEnabled() ? DateFormat.HOUR_OF_DAY
+                : DateFormat.HOUR;
+
+        if (DateFormat.hasDesignator(format, hour)) {
+            flags |= FLAG_HAS_LOCAL_HOUR;
+        }
+        if (DateFormat.hasDesignator(format, DateFormat.MINUTE)) {
+            flags |= FLAG_HAS_LOCAL_MINUTE;
+        }
+
+        return flags;
+    }
 }
diff --git a/services/java/com/android/server/AlarmManagerService.java b/services/java/com/android/server/AlarmManagerService.java
index cbd00f3..fa758a8 100644
--- a/services/java/com/android/server/AlarmManagerService.java
+++ b/services/java/com/android/server/AlarmManagerService.java
@@ -956,16 +956,12 @@
         }
         
         public void scheduleTimeTickEvent() {
-            Calendar calendar = Calendar.getInstance();
             final long currentTime = System.currentTimeMillis();
-            calendar.setTimeInMillis(currentTime);
-            calendar.add(Calendar.MINUTE, 1);
-            calendar.set(Calendar.SECOND, 0);
-            calendar.set(Calendar.MILLISECOND, 0);
+            final long nextTime = 60000 * ((currentTime / 60000) + 1);
 
             // Schedule this event for the amount of time that it would take to get to
             // the top of the next minute.
-            final long tickEventDelay = calendar.getTimeInMillis() - currentTime;
+            final long tickEventDelay = nextTime - currentTime;
 
             set(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime() + tickEventDelay,
                     mTimeTickSender);
diff --git a/services/java/com/android/server/AppOpsService.java b/services/java/com/android/server/AppOpsService.java
new file mode 100644
index 0000000..5ad4be8
--- /dev/null
+++ b/services/java/com/android/server/AppOpsService.java
@@ -0,0 +1,260 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.server;
+
+import java.io.File;
+import java.io.FileDescriptor;
+import java.io.PrintWriter;
+import java.util.HashMap;
+
+import android.app.AppOpsManager;
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.content.pm.PackageManager.NameNotFoundException;
+import android.os.Binder;
+import android.os.Environment;
+import android.os.Process;
+import android.os.ServiceManager;
+import android.os.UserHandle;
+import android.util.AtomicFile;
+import android.util.Slog;
+import android.util.SparseArray;
+import android.util.TimeUtils;
+
+import com.android.internal.app.IAppOpsService;
+
+public class AppOpsService extends IAppOpsService.Stub {
+    static final String TAG = "AppOps";
+
+    Context mContext;
+    final AtomicFile mFile;
+
+    final SparseArray<HashMap<String, Ops>> mUidOps
+            = new SparseArray<HashMap<String, Ops>>();
+
+    final static class Ops extends SparseArray<Op> {
+        public final String packageName;
+
+        public Ops(String _packageName) {
+            packageName = _packageName;
+        }
+    }
+
+    final static class Op {
+        public final int op;
+        public int duration;
+        public long time;
+
+        public Op(int _op) {
+            op = _op;
+        }
+    }
+
+    public AppOpsService() {
+        mFile = new AtomicFile(new File(Environment.getSecureDataDirectory(), "appops.xml"));
+    }
+    
+    public void publish(Context context) {
+        mContext = context;
+        ServiceManager.addService(Context.APP_OPS_SERVICE, asBinder());
+    }
+
+    public void shutdown() {
+        Slog.w(TAG, "Writing app ops before shutdown...");
+    }
+
+    @Override
+    public int noteOperation(int code, int uid, String packageName) {
+        uid = handleIncomingUid(uid);
+        synchronized (this) {
+            Op op = getOpLocked(code, uid, packageName);
+            if (op == null) {
+                return AppOpsManager.MODE_IGNORED;
+            }
+            if (op.duration == -1) {
+                Slog.w(TAG, "Noting op not finished: uid " + uid + " pkg " + packageName
+                        + " code " + code + " time=" + op.time + " duration=" + op.duration);
+            }
+            op.time = System.currentTimeMillis();
+            op.duration = 0;
+        }
+        return AppOpsManager.MODE_ALLOWED;
+    }
+
+    @Override
+    public int startOperation(int code, int uid, String packageName) {
+        uid = handleIncomingUid(uid);
+        synchronized (this) {
+            Op op = getOpLocked(code, uid, packageName);
+            if (op == null) {
+                return AppOpsManager.MODE_IGNORED;
+            }
+            if (op.duration == -1) {
+                Slog.w(TAG, "Starting op not finished: uid " + uid + " pkg " + packageName
+                        + " code " + code + " time=" + op.time + " duration=" + op.duration);
+            }
+            op.time = System.currentTimeMillis();
+            op.duration = -1;
+        }
+        return AppOpsManager.MODE_ALLOWED;
+    }
+
+    @Override
+    public void finishOperation(int code, int uid, String packageName) {
+        uid = handleIncomingUid(uid);
+        synchronized (this) {
+            Op op = getOpLocked(code, uid, packageName);
+            if (op == null) {
+                return;
+            }
+            if (op.duration != -1) {
+                Slog.w(TAG, "Ignoring finishing op not started: uid " + uid + " pkg " + packageName
+                        + " code " + code + " time=" + op.time + " duration=" + op.duration);
+                return;
+            }
+            op.duration = (int)(System.currentTimeMillis() - op.time);
+        }
+    }
+
+    @Override
+    public int noteTimedOperation(int code, int uid, String packageName, int duration) {
+        uid = handleIncomingUid(uid);
+        synchronized (this) {
+            Op op = getOpLocked(code, uid, packageName);
+            if (op == null) {
+                return AppOpsManager.MODE_IGNORED;
+            }
+            if (op.duration == -1) {
+                Slog.w(TAG, "Noting op not finished: uid " + uid + " pkg " + packageName
+                        + " code " + code + " time=" + op.time + " duration=" + op.duration);
+            }
+            op.time = System.currentTimeMillis();
+            op.duration = duration;
+        }
+        return AppOpsManager.MODE_ALLOWED;
+    }
+
+    @Override
+    public void earlyFinishOperation(int code, int uid, String packageName) {
+        uid = handleIncomingUid(uid);
+        synchronized (this) {
+            Op op = getOpLocked(code, uid, packageName);
+            if (op == null) {
+                return;
+            }
+            if (op.duration != -1) {
+                Slog.w(TAG, "Noting timed op not finished: uid " + uid + " pkg " + packageName
+                        + " code " + code + " time=" + op.time + " duration=" + op.duration);
+            }
+            int newDuration = (int)(System.currentTimeMillis() - op.time);
+            if (newDuration < op.duration) {
+                op.duration = newDuration;
+            }
+        }
+    }
+
+    private int handleIncomingUid(int uid) {
+        if (uid == Binder.getCallingUid()) {
+            return uid;
+        }
+        if (Binder.getCallingPid() == Process.myPid()) {
+            return uid;
+        }
+        mContext.enforcePermission(android.Manifest.permission.UPDATE_APP_OPS_STATS,
+                Binder.getCallingPid(), Binder.getCallingUid(), null);
+        return uid;
+    }
+
+    private Op getOpLocked(int code, int uid, String packageName) {
+        HashMap<String, Ops> pkgOps = mUidOps.get(uid);
+        if (pkgOps == null) {
+            pkgOps = new HashMap<String, Ops>();
+            mUidOps.put(uid, pkgOps);
+        }
+        Ops ops = pkgOps.get(packageName);
+        if (ops == null) {
+            // This is the first time we have seen this package name under this uid,
+            // so let's make sure it is valid.
+            // XXX for now we always allow null through until we can fix everything
+            // to provide the name.
+            if (packageName != null) {
+                final long ident = Binder.clearCallingIdentity();
+                try {
+                    int pkgUid = -1;
+                    try {
+                        pkgUid = mContext.getPackageManager().getPackageUid(packageName,
+                                UserHandle.getUserId(uid));
+                    } catch (NameNotFoundException e) {
+                    }
+                    if (pkgUid != uid) {
+                        // Oops!  The package name is not valid for the uid they are calling
+                        // under.  Abort.
+                        Slog.w(TAG, "Bad call: specified package " + packageName
+                                + " under uid " + uid + " but it is really " + pkgUid);
+                        return null;
+                    }
+                } finally {
+                    Binder.restoreCallingIdentity(ident);
+                }
+            }
+            ops = new Ops(packageName);
+            pkgOps.put(packageName, ops);
+        }
+        Op op = ops.get(code);
+        if (op == null) {
+            op = new Op(code);
+            ops.put(code, op);
+        }
+        return op;
+    }
+
+    @Override
+    protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
+        if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
+                != PackageManager.PERMISSION_GRANTED) {
+            pw.println("Permission Denial: can't dump ApOps service from from pid="
+                    + Binder.getCallingPid()
+                    + ", uid=" + Binder.getCallingUid());
+            return;
+        }
+
+        synchronized (this) {
+            pw.println("Current AppOps Service state:");
+            for (int i=0; i<mUidOps.size(); i++) {
+                pw.print("  Uid "); UserHandle.formatUid(pw, mUidOps.keyAt(i)); pw.println(":");
+                HashMap<String, Ops> pkgOps = mUidOps.valueAt(i);
+                for (Ops ops : pkgOps.values()) {
+                    pw.print("    Package "); pw.print(ops.packageName); pw.println(":");
+                    for (int j=0; j<ops.size(); j++) {
+                        Op op = ops.valueAt(j);
+                        pw.print("      "); pw.print(AppOpsManager.opToString(op.op));
+                        pw.print(": time=");
+                        TimeUtils.formatDuration(System.currentTimeMillis()-op.time, pw);
+                        pw.print(" ago");
+                        if (op.duration == -1) {
+                            pw.println(" (running)");
+                        } else {
+                            pw.print("; duration=");
+                                    TimeUtils.formatDuration(op.duration, pw);
+                                    pw.println();
+                        }
+                    }
+                }
+            }
+        }
+    }
+}
diff --git a/services/java/com/android/server/InputMethodManagerService.java b/services/java/com/android/server/InputMethodManagerService.java
index 81ae101..91ac1de 100644
--- a/services/java/com/android/server/InputMethodManagerService.java
+++ b/services/java/com/android/server/InputMethodManagerService.java
@@ -782,9 +782,6 @@
         if (!isSystemIme(imi)) {
             return false;
         }
-        if (imi.isAuxiliaryIme()) {
-            return false;
-        }
         if (imi.getIsDefaultResourceId() != 0) {
             try {
                 Resources res = context.createPackageContext(
@@ -808,9 +805,6 @@
         if (!isSystemIme(imi)) {
             return false;
         }
-        if (imi.isAuxiliaryIme()) {
-            return false;
-        }
         return containsSubtypeOf(imi, ENGLISH_LOCALE.getLanguage());
     }
 
@@ -2864,9 +2858,6 @@
         List<Pair<String, ArrayList<String>>> enabledInputMethodsList = mSettings
                 .getEnabledInputMethodsAndSubtypeListLocked();
 
-        if (DEBUG) {
-            Slog.d(TAG, (enabled ? "Enable " : "Disable ") + id);
-        }
         if (enabled) {
             for (Pair<String, ArrayList<String>> pair: enabledInputMethodsList) {
                 if (pair.first.equals(id)) {
diff --git a/services/java/com/android/server/LocationManagerService.java b/services/java/com/android/server/LocationManagerService.java
index 83b94e2..9e40dc5 100644
--- a/services/java/com/android/server/LocationManagerService.java
+++ b/services/java/com/android/server/LocationManagerService.java
@@ -16,6 +16,7 @@
 
 package com.android.server;
 
+import android.app.AppOpsManager;
 import android.app.PendingIntent;
 import android.content.BroadcastReceiver;
 import android.content.ContentResolver;
@@ -53,6 +54,7 @@
 import android.os.PowerManager;
 import android.os.Process;
 import android.os.RemoteException;
+import android.os.ServiceManager;
 import android.os.SystemClock;
 import android.os.UserHandle;
 import android.os.WorkSource;
@@ -60,6 +62,7 @@
 import android.util.Log;
 import android.util.Slog;
 
+import com.android.internal.app.IAppOpsService;
 import com.android.internal.content.PackageMonitor;
 import com.android.internal.location.ProviderProperties;
 import com.android.internal.location.ProviderRequest;
@@ -124,6 +127,7 @@
     private static final LocationRequest DEFAULT_LOCATION_REQUEST = new LocationRequest();
 
     private final Context mContext;
+    private final AppOpsManager mAppOps;
 
     // used internally for synchronization
     private final Object mLock = new Object();
@@ -187,6 +191,7 @@
     public LocationManagerService(Context context) {
         super();
         mContext = context;
+        mAppOps = (AppOpsManager)context.getSystemService(Context.APP_OPS_SERVICE);
 
         if (D) Log.d(TAG, "Constructed");
 
@@ -524,6 +529,10 @@
         }
 
         public boolean callLocationChangedLocked(Location location) {
+            if (mAppOps.noteOpNoThrow(AppOpsManager.OP_LOCATION, mUid, mPackageName)
+                    != AppOpsManager.MODE_ALLOWED) {
+                return true;
+            }
             if (mListener != null) {
                 try {
                     synchronized (this) {
@@ -1162,7 +1171,7 @@
     private Receiver checkListenerOrIntent(ILocationListener listener, PendingIntent intent,
             int pid, int uid, String packageName) {
         if (intent == null && listener == null) {
-            throw new IllegalArgumentException("need eiter listener or intent");
+            throw new IllegalArgumentException("need either listener or intent");
         } else if (intent != null && listener != null) {
             throw new IllegalArgumentException("cannot register both listener and intent");
         } else if (intent != null) {
@@ -1185,11 +1194,14 @@
 
         final int pid = Binder.getCallingPid();
         final int uid = Binder.getCallingUid();
-        Receiver recevier = checkListenerOrIntent(listener, intent, pid, uid, packageName);
-
         // providers may use public location API's, need to clear identity
         long identity = Binder.clearCallingIdentity();
         try {
+            // We don't check for MODE_IGNORED here; we will do that when we go to deliver
+            // a location.
+            mAppOps.noteOp(AppOpsManager.OP_LOCATION, uid, packageName);
+            Receiver recevier = checkListenerOrIntent(listener, intent, pid, uid, packageName);
+
             synchronized (mLock) {
                 requestLocationUpdatesLocked(sanitizedRequest, recevier, pid, uid, packageName);
             }
@@ -1296,8 +1308,14 @@
                 request.getProvider());
         // no need to sanitize this request, as only the provider name is used
 
-        long identity = Binder.clearCallingIdentity();
+        final int uid = Binder.getCallingUid();
+        final long identity = Binder.clearCallingIdentity();
         try {
+            if (mAppOps.noteOp(AppOpsManager.OP_LOCATION, uid, packageName)
+                    != AppOpsManager.MODE_ALLOWED) {
+                return null;
+            }
+            
             if (mBlacklist.isBlacklisted(packageName)) {
                 if (D) Log.d(TAG, "not returning last loc for blacklisted app: " +
                         packageName);
@@ -1381,13 +1399,24 @@
 
 
     @Override
-    public boolean addGpsStatusListener(IGpsStatusListener listener) {
+    public boolean addGpsStatusListener(IGpsStatusListener listener, String packageName) {
         if (mGpsStatusProvider == null) {
             return false;
         }
         checkResolutionLevelIsSufficientForProviderUse(getCallerAllowedResolutionLevel(),
                 LocationManager.GPS_PROVIDER);
 
+        final int uid = Binder.getCallingUid();
+        final long ident = Binder.clearCallingIdentity();
+        try {
+            if (mAppOps.noteOp(AppOpsManager.OP_LOCATION, uid, packageName)
+                    != AppOpsManager.MODE_ALLOWED) {
+                return false;
+            }
+        } finally {
+            Binder.restoreCallingIdentity(ident);
+        }
+
         try {
             mGpsStatusProvider.addGpsStatusListener(listener);
         } catch (RemoteException e) {
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
index a7b502a..c33eb2b 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -261,7 +261,6 @@
             ServiceManager.addService(Context.USER_SERVICE,
                     UserManagerService.getInstance());
 
-
             mContentResolver = context.getContentResolver();
 
             // The AccountManager must come before the ContentService
diff --git a/services/java/com/android/server/VibratorService.java b/services/java/com/android/server/VibratorService.java
index df91dec..69379f1 100644
--- a/services/java/com/android/server/VibratorService.java
+++ b/services/java/com/android/server/VibratorService.java
@@ -16,6 +16,7 @@
 
 package com.android.server;
 
+import android.app.AppOpsManager;
 import android.content.BroadcastReceiver;
 import android.content.Context;
 import android.content.Intent;
@@ -30,6 +31,7 @@
 import android.os.RemoteException;
 import android.os.IBinder;
 import android.os.Binder;
+import android.os.ServiceManager;
 import android.os.SystemClock;
 import android.os.UserHandle;
 import android.os.Vibrator;
@@ -39,6 +41,9 @@
 import android.util.Slog;
 import android.view.InputDevice;
 
+import com.android.internal.app.IAppOpsService;
+import com.android.internal.app.IBatteryStats;
+
 import java.util.ArrayList;
 import java.util.LinkedList;
 import java.util.ListIterator;
@@ -54,6 +59,8 @@
 
     private final Context mContext;
     private final PowerManager.WakeLock mWakeLock;
+    private final IAppOpsService mAppOpsService;
+    private final IBatteryStats mBatteryStatsService;
     private InputManager mIm;
 
     volatile VibrateThread mThread;
@@ -64,6 +71,8 @@
     private boolean mVibrateInputDevicesSetting; // guarded by mInputDeviceVibrators
     private boolean mInputDeviceListenerRegistered; // guarded by mInputDeviceVibrators
 
+    private int mCurVibUid = -1;
+
     native static boolean vibratorExists();
     native static void vibratorOn(long milliseconds);
     native static void vibratorOff();
@@ -75,23 +84,25 @@
         private final long[]  mPattern;
         private final int     mRepeat;
         private final int     mUid;
+        private final String  mPackageName;
 
-        Vibration(IBinder token, long millis, int uid) {
-            this(token, millis, null, 0, uid);
+        Vibration(IBinder token, long millis, int uid, String packageName) {
+            this(token, millis, null, 0, uid, packageName);
         }
 
-        Vibration(IBinder token, long[] pattern, int repeat, int uid) {
-            this(token, 0, pattern, repeat, uid);
+        Vibration(IBinder token, long[] pattern, int repeat, int uid, String packageName) {
+            this(token, 0, pattern, repeat, uid, packageName);
         }
 
         private Vibration(IBinder token, long millis, long[] pattern,
-                int repeat, int uid) {
+                int repeat, int uid, String packageName) {
             mToken = token;
             mTimeout = millis;
             mStartTime = SystemClock.uptimeMillis();
             mPattern = pattern;
             mRepeat = repeat;
             mUid = uid;
+            mPackageName = packageName;
         }
 
         public void binderDied() {
@@ -131,6 +142,9 @@
         mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "*vibrator*");
         mWakeLock.setReferenceCounted(true);
 
+        mAppOpsService = IAppOpsService.Stub.asInterface(ServiceManager.getService(Context.APP_OPS_SERVICE));
+        mBatteryStatsService = IBatteryStats.Stub.asInterface(ServiceManager.getService("batteryinfo"));
+
         mVibrations = new LinkedList<Vibration>();
 
         IntentFilter filter = new IntentFilter();
@@ -164,7 +178,7 @@
         return doVibratorExists();
     }
 
-    public void vibrate(long milliseconds, IBinder token) {
+    public void vibrate(String packageName, long milliseconds, IBinder token) {
         if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.VIBRATE)
                 != PackageManager.PERMISSION_GRANTED) {
             throw new SecurityException("Requires VIBRATE permission");
@@ -180,12 +194,18 @@
             return;
         }
 
-        Vibration vib = new Vibration(token, milliseconds, uid);
-        synchronized (mVibrations) {
-            removeVibrationLocked(token);
-            doCancelVibrateLocked();
-            mCurrentVibration = vib;
-            startVibrationLocked(vib);
+        Vibration vib = new Vibration(token, milliseconds, uid, packageName);
+
+        final long ident = Binder.clearCallingIdentity();
+        try {
+            synchronized (mVibrations) {
+                removeVibrationLocked(token);
+                doCancelVibrateLocked();
+                mCurrentVibration = vib;
+                startVibrationLocked(vib);
+            }
+        } finally {
+            Binder.restoreCallingIdentity(ident);
         }
     }
 
@@ -199,7 +219,7 @@
         return true;
     }
 
-    public void vibratePattern(long[] pattern, int repeat, IBinder token) {
+    public void vibratePattern(String packageName, long[] pattern, int repeat, IBinder token) {
         if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.VIBRATE)
                 != PackageManager.PERMISSION_GRANTED) {
             throw new SecurityException("Requires VIBRATE permission");
@@ -224,7 +244,7 @@
                 return;
             }
 
-            Vibration vib = new Vibration(token, pattern, repeat, uid);
+            Vibration vib = new Vibration(token, pattern, repeat, uid, packageName);
             try {
                 token.linkToDeath(vib, 0);
             } catch (RemoteException e) {
@@ -291,11 +311,13 @@
         }
         doVibratorOff();
         mH.removeCallbacks(mVibrationRunnable);
+        reportFinishVibrationLocked();
     }
 
     // Lock held on mVibrations
     private void startNextVibrationLocked() {
         if (mVibrations.size() <= 0) {
+            reportFinishVibrationLocked();
             mCurrentVibration = null;
             return;
         }
@@ -305,8 +327,19 @@
 
     // Lock held on mVibrations
     private void startVibrationLocked(final Vibration vib) {
+        try {
+            int mode = mAppOpsService.startOperation(AppOpsManager.OP_VIBRATE, vib.mUid, vib.mPackageName);
+            if (mode != AppOpsManager.MODE_ALLOWED) {
+                if (mode == AppOpsManager.MODE_ERRORED) {
+                    Slog.w(TAG, "Would be an error: vibrate from uid " + vib.mUid);
+                }
+                mH.post(mVibrationRunnable);
+                return;
+            }
+        } catch (RemoteException e) {
+        }
         if (vib.mTimeout != 0) {
-            doVibratorOn(vib.mTimeout);
+            doVibratorOn(vib.mTimeout, vib.mUid);
             mH.postDelayed(mVibrationRunnable, vib.mTimeout);
         } else {
             // mThread better be null here. doCancelVibrate should always be
@@ -316,6 +349,17 @@
         }
     }
 
+    private void reportFinishVibrationLocked() {
+        if (mCurrentVibration != null) {
+            try {
+                mAppOpsService.finishOperation(AppOpsManager.OP_VIBRATE, mCurrentVibration.mUid,
+                        mCurrentVibration.mPackageName);
+            } catch (RemoteException e) {
+            }
+            mCurrentVibration = null;
+        }
+    }
+
     // Lock held on mVibrations
     private Vibration removeVibrationLocked(IBinder token) {
         ListIterator<Vibration> iter = mVibrations.listIterator(0);
@@ -413,8 +457,13 @@
         return vibratorExists();
     }
 
-    private void doVibratorOn(long millis) {
+    private void doVibratorOn(long millis, int uid) {
         synchronized (mInputDeviceVibrators) {
+            try {
+                mBatteryStatsService.noteVibratorOn(uid, millis);
+                mCurVibUid = uid;
+            } catch (RemoteException e) {
+            }
             final int vibratorCount = mInputDeviceVibrators.size();
             if (vibratorCount != 0) {
                 for (int i = 0; i < vibratorCount; i++) {
@@ -428,6 +477,13 @@
 
     private void doVibratorOff() {
         synchronized (mInputDeviceVibrators) {
+            if (mCurVibUid >= 0) {
+                try {
+                    mBatteryStatsService.noteVibratorOff(mCurVibUid);
+                } catch (RemoteException e) {
+                }
+                mCurVibUid = -1;
+            }
             final int vibratorCount = mInputDeviceVibrators.size();
             if (vibratorCount != 0) {
                 for (int i = 0; i < vibratorCount; i++) {
@@ -470,10 +526,11 @@
         public void run() {
             Process.setThreadPriority(Process.THREAD_PRIORITY_URGENT_DISPLAY);
             synchronized (this) {
+                final long[] pattern = mVibration.mPattern;
+                final int len = pattern.length;
+                final int repeat = mVibration.mRepeat;
+                final int uid = mVibration.mUid;
                 int index = 0;
-                long[] pattern = mVibration.mPattern;
-                int len = pattern.length;
-                int repeat = mVibration.mRepeat;
                 long duration = 0;
 
                 while (!mDone) {
@@ -493,7 +550,7 @@
                         // duration is saved for delay() at top of loop
                         duration = pattern[index++];
                         if (duration > 0) {
-                            VibratorService.this.doVibratorOn(duration);
+                            VibratorService.this.doVibratorOn(duration, uid);
                         }
                     } else {
                         if (repeat < 0) {
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index 1cd370a..8297988e 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -21,6 +21,7 @@
 import com.android.internal.R;
 import com.android.internal.os.BatteryStatsImpl;
 import com.android.internal.os.ProcessStats;
+import com.android.server.AppOpsService;
 import com.android.server.AttributeCache;
 import com.android.server.IntentResolver;
 import com.android.server.ProcessMap;
@@ -28,6 +29,7 @@
 import com.android.server.Watchdog;
 import com.android.server.am.ActivityStack.ActivityState;
 import com.android.server.pm.UserManagerService;
+import com.android.server.wm.AppTransition;
 import com.android.server.wm.WindowManagerService;
 
 import dalvik.system.Zygote;
@@ -130,7 +132,6 @@
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.WindowManager;
-import android.view.WindowManagerPolicy;
 
 import java.io.BufferedInputStream;
 import java.io.BufferedOutputStream;
@@ -619,9 +620,14 @@
     final BatteryStatsService mBatteryStatsService;
     
     /**
-     * information about component usage
+     * Information about component usage
      */
     final UsageStatsService mUsageStatsService;
+    
+    /**
+     * Information about and control over application operations
+     */
+    final AppOpsService mAppOpsService;
 
     /**
      * Current configuration information.  HistoryRecord objects are given
@@ -1450,7 +1456,8 @@
         
         m.mBatteryStatsService.publish(context);
         m.mUsageStatsService.publish(context);
-        
+        m.mAppOpsService.publish(context);
+
         synchronized (thr) {
             thr.mReady = true;
             thr.notifyAll();
@@ -1613,9 +1620,10 @@
         mOnBattery = DEBUG_POWER ? true
                 : mBatteryStatsService.getActiveStatistics().getIsOnBattery();
         mBatteryStatsService.getActiveStatistics().setCallback(this);
-        
+
         mUsageStatsService = new UsageStatsService(new File(
                 systemDir, "usagestats").toString());
+        mAppOpsService = new AppOpsService();
         mHeadless = "1".equals(SystemProperties.get("ro.config.headless", "0"));
 
         // User 0 is the first and only user that runs at boot.
@@ -1970,9 +1978,9 @@
     
     boolean isNextTransitionForward() {
         int transit = mWindowManager.getPendingAppTransition();
-        return transit == WindowManagerPolicy.TRANSIT_ACTIVITY_OPEN
-                || transit == WindowManagerPolicy.TRANSIT_TASK_OPEN
-                || transit == WindowManagerPolicy.TRANSIT_TASK_TO_FRONT;
+        return transit == AppTransition.TRANSIT_ACTIVITY_OPEN
+                || transit == AppTransition.TRANSIT_TASK_OPEN
+                || transit == AppTransition.TRANSIT_TASK_TO_FRONT;
     }
     
     final ProcessRecord startProcessLocked(String processName,
@@ -3906,7 +3914,7 @@
         }
 
         boolean didSomething = killPackageProcessesLocked(name, appId, userId,
-                -100, callerWillRestart, false, doit, evenPersistent,
+                -100, callerWillRestart, true, doit, evenPersistent,
                 name == null ? ("force stop user " + userId) : ("force stop " + name));
         
         TaskRecord lastTask = null;
@@ -7174,7 +7182,8 @@
                 }
             }
         }
-        
+
+        mAppOpsService.shutdown();
         mUsageStatsService.shutdown();
         mBatteryStatsService.shutdown();
         
diff --git a/services/java/com/android/server/am/ActivityStack.java b/services/java/com/android/server/am/ActivityStack.java
index 0e01e4c..c1b10cf 100644
--- a/services/java/com/android/server/am/ActivityStack.java
+++ b/services/java/com/android/server/am/ActivityStack.java
@@ -22,6 +22,7 @@
 import com.android.internal.app.HeavyWeightSwitcherActivity;
 import com.android.internal.os.BatteryStatsImpl;
 import com.android.server.am.ActivityManagerService.PendingActivityLaunch;
+import com.android.server.wm.AppTransition;
 
 import android.app.Activity;
 import android.app.ActivityManager;
@@ -61,7 +62,6 @@
 import android.util.Log;
 import android.util.Slog;
 import android.view.Display;
-import android.view.WindowManagerPolicy;
 
 import java.io.IOException;
 import java.lang.ref.WeakReference;
@@ -423,8 +423,8 @@
                 }
             }
         }
-    };
-    
+    }
+
     ActivityStack(ActivityManagerService service, Context context, boolean mainStack, Looper looper) {
         mHandler = new ActivityStackHandler(looper);
         mService = service;
@@ -1612,11 +1612,11 @@
                         "Prepare close transition: prev=" + prev);
                 if (mNoAnimActivities.contains(prev)) {
                     mService.mWindowManager.prepareAppTransition(
-                            WindowManagerPolicy.TRANSIT_NONE, false);
+                            AppTransition.TRANSIT_NONE, false);
                 } else {
                     mService.mWindowManager.prepareAppTransition(prev.task == next.task
-                            ? WindowManagerPolicy.TRANSIT_ACTIVITY_CLOSE
-                            : WindowManagerPolicy.TRANSIT_TASK_CLOSE, false);
+                            ? AppTransition.TRANSIT_ACTIVITY_CLOSE
+                            : AppTransition.TRANSIT_TASK_CLOSE, false);
                 }
                 mService.mWindowManager.setAppWillBeHidden(prev.appToken);
                 mService.mWindowManager.setAppVisibility(prev.appToken, false);
@@ -1626,11 +1626,11 @@
                 if (mNoAnimActivities.contains(next)) {
                     noAnim = true;
                     mService.mWindowManager.prepareAppTransition(
-                            WindowManagerPolicy.TRANSIT_NONE, false);
+                            AppTransition.TRANSIT_NONE, false);
                 } else {
                     mService.mWindowManager.prepareAppTransition(prev.task == next.task
-                            ? WindowManagerPolicy.TRANSIT_ACTIVITY_OPEN
-                            : WindowManagerPolicy.TRANSIT_TASK_OPEN, false);
+                            ? AppTransition.TRANSIT_ACTIVITY_OPEN
+                            : AppTransition.TRANSIT_TASK_OPEN, false);
                 }
             }
             if (false) {
@@ -1643,10 +1643,10 @@
             if (mNoAnimActivities.contains(next)) {
                 noAnim = true;
                 mService.mWindowManager.prepareAppTransition(
-                        WindowManagerPolicy.TRANSIT_NONE, false);
+                        AppTransition.TRANSIT_NONE, false);
             } else {
                 mService.mWindowManager.prepareAppTransition(
-                        WindowManagerPolicy.TRANSIT_ACTIVITY_OPEN, false);
+                        AppTransition.TRANSIT_ACTIVITY_OPEN, false);
             }
         }
         if (!noAnim) {
@@ -1890,12 +1890,12 @@
                     "Prepare open transition: starting " + r);
             if ((r.intent.getFlags()&Intent.FLAG_ACTIVITY_NO_ANIMATION) != 0) {
                 mService.mWindowManager.prepareAppTransition(
-                        WindowManagerPolicy.TRANSIT_NONE, keepCurTransition);
+                        AppTransition.TRANSIT_NONE, keepCurTransition);
                 mNoAnimActivities.add(r);
             } else {
                 mService.mWindowManager.prepareAppTransition(newTask
-                        ? WindowManagerPolicy.TRANSIT_TASK_OPEN
-                        : WindowManagerPolicy.TRANSIT_ACTIVITY_OPEN, keepCurTransition);
+                        ? AppTransition.TRANSIT_TASK_OPEN
+                        : AppTransition.TRANSIT_ACTIVITY_OPEN, keepCurTransition);
                 mNoAnimActivities.remove(r);
             }
             r.updateOptionsLocked(options);
@@ -3812,8 +3812,8 @@
             if (DEBUG_TRANSITION) Slog.v(TAG,
                     "Prepare close transition: finishing " + r);
             mService.mWindowManager.prepareAppTransition(endTask
-                    ? WindowManagerPolicy.TRANSIT_TASK_CLOSE
-                    : WindowManagerPolicy.TRANSIT_ACTIVITY_CLOSE, false);
+                    ? AppTransition.TRANSIT_TASK_CLOSE
+                    : AppTransition.TRANSIT_ACTIVITY_CLOSE, false);
     
             // Tell window manager to prepare for this one to be removed.
             mService.mWindowManager.setAppVisibility(r.appToken, false);
@@ -4300,7 +4300,7 @@
                     (reason.intent.getFlags()&Intent.FLAG_ACTIVITY_NO_ANIMATION) != 0) {
                 ActivityOptions.abort(options);
             } else {
-                updateTransitLocked(WindowManagerPolicy.TRANSIT_TASK_TO_FRONT, options);
+                updateTransitLocked(AppTransition.TRANSIT_TASK_TO_FRONT, options);
             }
             return;
         }
@@ -4338,14 +4338,14 @@
         if (reason != null &&
                 (reason.intent.getFlags()&Intent.FLAG_ACTIVITY_NO_ANIMATION) != 0) {
             mService.mWindowManager.prepareAppTransition(
-                    WindowManagerPolicy.TRANSIT_NONE, false);
+                    AppTransition.TRANSIT_NONE, false);
             ActivityRecord r = topRunningActivityLocked(null);
             if (r != null) {
                 mNoAnimActivities.add(r);
             }
             ActivityOptions.abort(options);
         } else {
-            updateTransitLocked(WindowManagerPolicy.TRANSIT_TASK_TO_FRONT, options);
+            updateTransitLocked(AppTransition.TRANSIT_TASK_TO_FRONT, options);
         }
         
         mService.mWindowManager.moveAppTokensToTop(moved);
@@ -4431,14 +4431,14 @@
         if (reason != null &&
                 (reason.intent.getFlags()&Intent.FLAG_ACTIVITY_NO_ANIMATION) != 0) {
             mService.mWindowManager.prepareAppTransition(
-                    WindowManagerPolicy.TRANSIT_NONE, false);
+                    AppTransition.TRANSIT_NONE, false);
             ActivityRecord r = topRunningActivityLocked(null);
             if (r != null) {
                 mNoAnimActivities.add(r);
             }
         } else {
             mService.mWindowManager.prepareAppTransition(
-                    WindowManagerPolicy.TRANSIT_TASK_TO_BACK, false);
+                    AppTransition.TRANSIT_TASK_TO_BACK, false);
         }
         mService.mWindowManager.moveAppTokensToBottom(moved);
         if (VALIDATE_TOKENS) {
diff --git a/services/java/com/android/server/am/BatteryStatsService.java b/services/java/com/android/server/am/BatteryStatsService.java
index ab20208..d19c7f6 100644
--- a/services/java/com/android/server/am/BatteryStatsService.java
+++ b/services/java/com/android/server/am/BatteryStatsService.java
@@ -144,6 +144,20 @@
         }
     }
     
+    public void noteVibratorOn(int uid, long durationMillis) {
+        enforceCallingPermission();
+        synchronized (mStats) {
+            mStats.noteVibratorOnLocked(uid, durationMillis);
+        }
+    }
+
+    public void noteVibratorOff(int uid) {
+        enforceCallingPermission();
+        synchronized (mStats) {
+            mStats.noteVibratorOffLocked(uid);
+        }
+    }
+
     public void noteStartGps(int uid) {
         enforceCallingPermission();
         synchronized (mStats) {
diff --git a/services/java/com/android/server/location/GpsLocationProvider.java b/services/java/com/android/server/location/GpsLocationProvider.java
index 7f059f5..f1739d5 100644
--- a/services/java/com/android/server/location/GpsLocationProvider.java
+++ b/services/java/com/android/server/location/GpsLocationProvider.java
@@ -17,6 +17,7 @@
 package com.android.server.location;
 
 import android.app.AlarmManager;
+import android.app.AppOpsManager;
 import android.app.PendingIntent;
 import android.content.BroadcastReceiver;
 import android.content.Context;
@@ -56,6 +57,8 @@
 import android.telephony.gsm.GsmCellLocation;
 import android.util.Log;
 import android.util.NtpTrustedTime;
+
+import com.android.internal.app.IAppOpsService;
 import com.android.internal.app.IBatteryStats;
 import com.android.internal.location.GpsNetInitiatedHandler;
 import com.android.internal.location.ProviderProperties;
@@ -305,6 +308,7 @@
     private final PendingIntent mWakeupIntent;
     private final PendingIntent mTimeoutIntent;
 
+    private final IAppOpsService mAppOpsService;
     private final IBatteryStats mBatteryStats;
 
     // only modified on handler thread
@@ -434,6 +438,10 @@
 
         mConnMgr = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
 
+        // App ops service to keep track of who is accessing the GPS
+        mAppOpsService = IAppOpsService.Stub.asInterface(ServiceManager.getService(
+                Context.APP_OPS_SERVICE));
+
         // Battery statistics service to be notified when GPS turns on or off
         mBatteryStats = IBatteryStats.Stub.asInterface(ServiceManager.getService("batteryinfo"));
 
@@ -863,6 +871,7 @@
             }
             if (newUid) {
                 try {
+                    mAppOpsService.startOperation(AppOpsManager.OP_GPS, uid1, null);
                     mBatteryStats.noteStartGps(uid1);
                 } catch (RemoteException e) {
                     Log.w(TAG, "RemoteException", e);
@@ -882,6 +891,7 @@
             if (oldUid) {
                 try {
                     mBatteryStats.noteStopGps(uid1);
+                    mAppOpsService.finishOperation(AppOpsManager.OP_GPS, uid1, null);
                 } catch (RemoteException e) {
                     Log.w(TAG, "RemoteException", e);
                 }
diff --git a/services/java/com/android/server/pm/Installer.java b/services/java/com/android/server/pm/Installer.java
index e96820f..02a2c1b 100644
--- a/services/java/com/android/server/pm/Installer.java
+++ b/services/java/com/android/server/pm/Installer.java
@@ -188,12 +188,7 @@
         }
     }
 
-    /**
-     * @param restrictHomeDir if {@code true}, installd will create the application's
-     *     home directory with {@code 0700} permissions.  If false, {@code 0751} will
-     *     be used instead.
-     */
-    public int install(String name, int uid, int gid, boolean restrictHomeDir) {
+    public int install(String name, int uid, int gid) {
         StringBuilder builder = new StringBuilder("install");
         builder.append(' ');
         builder.append(name);
@@ -201,8 +196,6 @@
         builder.append(uid);
         builder.append(' ');
         builder.append(gid);
-        builder.append(' ');
-        builder.append(restrictHomeDir);
         return execute(builder.toString());
     }
 
@@ -270,12 +263,7 @@
         return execute(builder.toString());
     }
 
-    /**
-     * @param restrictHomeDir if {@code true}, installd will create the application's
-     *     home directory with {@code 0700} permissions.  If false, {@code 0751} will
-     *     be used instead.
-     */
-    public int createUserData(String name, int uid, int userId, boolean restrictHomeDir) {
+    public int createUserData(String name, int uid, int userId) {
         StringBuilder builder = new StringBuilder("mkuserdata");
         builder.append(' ');
         builder.append(name);
@@ -283,8 +271,6 @@
         builder.append(uid);
         builder.append(' ');
         builder.append(userId);
-        builder.append(' ');
-        builder.append(restrictHomeDir);
         return execute(builder.toString());
     }
 
diff --git a/services/java/com/android/server/pm/PackageManagerService.java b/services/java/com/android/server/pm/PackageManagerService.java
index aa2b461..2238f17 100644
--- a/services/java/com/android/server/pm/PackageManagerService.java
+++ b/services/java/com/android/server/pm/PackageManagerService.java
@@ -24,6 +24,7 @@
 import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
 import static com.android.internal.util.ArrayUtils.appendInt;
 import static com.android.internal.util.ArrayUtils.removeInt;
+import static libcore.io.OsConstants.S_ISLNK;
 import static libcore.io.OsConstants.S_IRWXU;
 import static libcore.io.OsConstants.S_IRGRP;
 import static libcore.io.OsConstants.S_IXGRP;
@@ -110,6 +111,7 @@
 import android.os.SystemProperties;
 import android.os.UserHandle;
 import android.os.Environment.UserEnvironment;
+import android.provider.Settings.Secure;
 import android.security.SystemKeyStore;
 import android.util.DisplayMetrics;
 import android.util.EventLog;
@@ -146,11 +148,13 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.Set;
 
 import libcore.io.ErrnoException;
 import libcore.io.IoUtils;
 import libcore.io.Libcore;
+import libcore.io.OsConstants;
 import libcore.io.StructStat;
 
 /**
@@ -3578,17 +3582,16 @@
         }
     }
 
-    private int createDataDirsLI(String packageName, int uid, int targetSdkVersion) {
+    private int createDataDirsLI(String packageName, int uid) {
         int[] users = sUserManager.getUserIds();
-        boolean restrictHomeDir = (targetSdkVersion >= Build.VERSION_CODES.K);
-        int res = mInstaller.install(packageName, uid, uid, restrictHomeDir);
+        int res = mInstaller.install(packageName, uid, uid);
         if (res < 0) {
             return res;
         }
         for (int user : users) {
             if (user != 0) {
                 res = mInstaller.createUserData(packageName,
-                        UserHandle.getUid(user, uid), user, restrictHomeDir);
+                        UserHandle.getUid(user, uid), user);
                 if (res < 0) {
                     return res;
                 }
@@ -3982,8 +3985,7 @@
                             recovered = true;
 
                             // And now re-install the app.
-                            ret = createDataDirsLI(pkgName, pkg.applicationInfo.uid,
-                                    pkg.applicationInfo.targetSdkVersion);
+                            ret = createDataDirsLI(pkgName, pkg.applicationInfo.uid);
                             if (ret == -1) {
                                 // Ack should not happen!
                                 msg = prefix + pkg.packageName
@@ -4028,9 +4030,8 @@
                     if ((parseFlags & PackageParser.PARSE_CHATTY) != 0)
                         Log.v(TAG, "Want this data dir: " + dataPath);
                 }
-                // invoke installer to do the actual installation
-                int ret = createDataDirsLI(pkgName, pkg.applicationInfo.uid,
-                        pkg.applicationInfo.targetSdkVersion);
+                //invoke installer to do the actual installation
+                int ret = createDataDirsLI(pkgName, pkg.applicationInfo.uid);
                 if (ret < 0) {
                     // Error from installer
                     mLastScanError = PackageManager.INSTALL_FAILED_INSUFFICIENT_STORAGE;
diff --git a/services/java/com/android/server/pm/Settings.java b/services/java/com/android/server/pm/Settings.java
index f791a6e..06f11bc 100644
--- a/services/java/com/android/server/pm/Settings.java
+++ b/services/java/com/android/server/pm/Settings.java
@@ -25,6 +25,7 @@
 import com.android.internal.util.FastXmlSerializer;
 import com.android.internal.util.JournaledFile;
 import com.android.internal.util.XmlUtils;
+import com.android.server.IntentResolver;
 import com.android.server.pm.PackageManagerService.DumpState;
 
 import org.xmlpull.v1.XmlPullParser;
@@ -45,7 +46,6 @@
 import android.content.pm.PackageUserState;
 import android.content.pm.VerifierDeviceIdentity;
 import android.os.Binder;
-import android.os.Build;
 import android.os.Environment;
 import android.os.FileUtils;
 import android.os.Process;
@@ -2335,11 +2335,9 @@
         for (PackageSetting ps : mPackages.values()) {
             // Only system apps are initially installed.
             ps.setInstalled((ps.pkgFlags&ApplicationInfo.FLAG_SYSTEM) != 0, userHandle);
-            boolean restrictHomeDir = (ps.pkg.applicationInfo.targetSdkVersion >= Build.VERSION_CODES.K);
             // Need to create a data directory for all apps under this user.
             installer.createUserData(ps.name,
-                    UserHandle.getUid(userHandle, ps.appId), userHandle,
-                    restrictHomeDir);
+                    UserHandle.getUid(userHandle, ps.appId), userHandle);
         }
         readDefaultPreferredAppsLPw(userHandle);
         writePackageRestrictionsLPr(userHandle);
diff --git a/services/java/com/android/server/power/DisplayPowerController.java b/services/java/com/android/server/power/DisplayPowerController.java
index 724e126..b5010f2 100644
--- a/services/java/com/android/server/power/DisplayPowerController.java
+++ b/services/java/com/android/server/power/DisplayPowerController.java
@@ -344,7 +344,7 @@
      * Creates the display power controller.
      */
     public DisplayPowerController(Looper looper, Context context, Notifier notifier,
-            LightsService lights, TwilightService twilight,
+            LightsService lights, TwilightService twilight, SensorManager sensorManager,
             DisplayManagerService displayManager,
             DisplayBlanker displayBlanker,
             Callbacks callbacks, Handler callbackHandler) {
@@ -356,7 +356,7 @@
 
         mLights = lights;
         mTwilight = twilight;
-        mSensorManager = new SystemSensorManager(mHandler.getLooper());
+        mSensorManager = sensorManager;
         mDisplayManager = displayManager;
 
         final Resources resources = context.getResources();
diff --git a/services/java/com/android/server/power/PowerManagerService.java b/services/java/com/android/server/power/PowerManagerService.java
index ec82290..2652739 100644
--- a/services/java/com/android/server/power/PowerManagerService.java
+++ b/services/java/com/android/server/power/PowerManagerService.java
@@ -35,6 +35,8 @@
 import android.content.pm.PackageManager;
 import android.content.res.Resources;
 import android.database.ContentObserver;
+import android.hardware.SensorManager;
+import android.hardware.SystemSensorManager;
 import android.net.Uri;
 import android.os.BatteryManager;
 import android.os.Binder;
@@ -153,11 +155,6 @@
     // Otherwise the user won't get much screen on time before dimming occurs.
     private static final float MAXIMUM_SCREEN_DIM_RATIO = 0.2f;
 
-    // Upper bound on the battery charge percentage in order to consider turning
-    // the screen on when the device starts charging wirelessly.
-    // See point of use for more details.
-    private static final int WIRELESS_CHARGER_TURN_ON_BATTERY_LEVEL_LIMIT = 95;
-
     // The name of the boot animation service in init.rc.
     private static final String BOOT_ANIMATION_SERVICE = "bootanim";
 
@@ -179,6 +176,7 @@
     private WindowManagerPolicy mPolicy;
     private Notifier mNotifier;
     private DisplayPowerController mDisplayPowerController;
+    private WirelessChargerDetector mWirelessChargerDetector;
     private SettingsObserver mSettingsObserver;
     private DreamManagerService mDreamManager;
     private LightsService.Light mAttentionLight;
@@ -434,6 +432,8 @@
             mScreenBrightnessSettingMaximum = pm.getMaximumScreenBrightnessSetting();
             mScreenBrightnessSettingDefault = pm.getDefaultScreenBrightnessSetting();
 
+            SensorManager sensorManager = new SystemSensorManager(mHandler.getLooper());
+
             // The notifier runs on the system server's main looper so as not to interfere
             // with the animations and other critical functions of the power manager.
             mNotifier = new Notifier(Looper.getMainLooper(), mContext, mBatteryStats,
@@ -441,11 +441,14 @@
                     mScreenOnBlocker, mPolicy);
 
             // The display power controller runs on the power manager service's
-            // own handler thread.
+            // own handler thread to ensure timely operation.
             mDisplayPowerController = new DisplayPowerController(mHandler.getLooper(),
-                    mContext, mNotifier, mLightsService, twilight, mDisplayManagerService,
-                    mDisplayBlanker, mDisplayPowerControllerCallbacks, mHandler);
+                    mContext, mNotifier, mLightsService, twilight, sensorManager,
+                    mDisplayManagerService, mDisplayBlanker,
+                    mDisplayPowerControllerCallbacks, mHandler);
 
+            mWirelessChargerDetector = new WirelessChargerDetector(sensorManager,
+                    createSuspendBlockerLocked("PowerManagerService.WirelessChargerDetector"));
             mSettingsObserver = new SettingsObserver(mHandler);
             mAttentionLight = mLightsService.getLight(LightsService.LIGHT_ID_ATTENTION);
 
@@ -1164,65 +1167,51 @@
             if (wasPowered != mIsPowered || oldPlugType != mPlugType) {
                 mDirty |= DIRTY_IS_POWERED;
 
+                // Update wireless dock detection state.
+                final boolean dockedOnWirelessCharger = mWirelessChargerDetector.update(
+                        mIsPowered, mPlugType, mBatteryLevel);
+
                 // Treat plugging and unplugging the devices as a user activity.
                 // Users find it disconcerting when they plug or unplug the device
                 // and it shuts off right away.
                 // Some devices also wake the device when plugged or unplugged because
                 // they don't have a charging LED.
                 final long now = SystemClock.uptimeMillis();
-                if (shouldWakeUpWhenPluggedOrUnpluggedLocked(wasPowered, oldPlugType)) {
+                if (shouldWakeUpWhenPluggedOrUnpluggedLocked(wasPowered, oldPlugType,
+                        dockedOnWirelessCharger)) {
                     wakeUpNoUpdateLocked(now);
                 }
                 userActivityNoUpdateLocked(
                         now, PowerManager.USER_ACTIVITY_EVENT_OTHER, 0, Process.SYSTEM_UID);
 
                 // Tell the notifier whether wireless charging has started so that
-                // it can provide feedback to the user.  Refer to
-                // shouldWakeUpWhenPluggedOrUnpluggedLocked for justification of the
-                // heuristics used here.
-                if (!wasPowered && mIsPowered
-                        && mPlugType == BatteryManager.BATTERY_PLUGGED_WIRELESS
-                        && mBatteryLevel < WIRELESS_CHARGER_TURN_ON_BATTERY_LEVEL_LIMIT) {
+                // it can provide feedback to the user.
+                if (dockedOnWirelessCharger) {
                     mNotifier.onWirelessChargingStarted();
                 }
             }
         }
     }
 
-    private boolean shouldWakeUpWhenPluggedOrUnpluggedLocked(boolean wasPowered, int oldPlugType) {
+    private boolean shouldWakeUpWhenPluggedOrUnpluggedLocked(
+            boolean wasPowered, int oldPlugType, boolean dockedOnWirelessCharger) {
         // Don't wake when powered unless configured to do so.
         if (!mWakeUpWhenPluggedOrUnpluggedConfig) {
             return false;
         }
 
-        // FIXME: Need more accurate detection of wireless chargers.
-        //
-        // We are unable to accurately detect whether the device is resting on the
-        // charger unless it is actually receiving power.  This causes us some grief
-        // because the device might not appear to be plugged into the wireless charger
-        // unless it actually charging.
-        //
-        // To avoid spuriously waking the screen, we apply a special policy to
-        // wireless chargers.
-        //
-        // 1. Don't wake the device when unplugged from wireless charger because
-        //    it might be that the device is still resting on the wireless charger
-        //    but is not receiving power anymore because the battery is full.
-        //
-        // 2. Don't wake the device when plugged into a wireless charger if the
-        //    battery already appears to be mostly full.  This situation may indicate
-        //    that the device was resting on the charger the whole time and simply
-        //    wasn't receiving power because the battery was full.  We can't tell
-        //    whether the device was just placed on the charger or whether it has
-        //    been there for half of the night slowly discharging until it hit
-        //    the point where it needed to start charging again.
+        // Don't wake when undocked from wireless charger.
+        // See WirelessChargerDetector for justification.
         if (wasPowered && !mIsPowered
                 && oldPlugType == BatteryManager.BATTERY_PLUGGED_WIRELESS) {
             return false;
         }
+
+        // Don't wake when docked on wireless charger unless we are certain of it.
+        // See WirelessChargerDetector for justification.
         if (!wasPowered && mIsPowered
                 && mPlugType == BatteryManager.BATTERY_PLUGGED_WIRELESS
-                && mBatteryLevel >= WIRELESS_CHARGER_TURN_ON_BATTERY_LEVEL_LIMIT) {
+                && !dockedOnWirelessCharger) {
             return false;
         }
 
@@ -2209,6 +2198,7 @@
         pw.println("POWER MANAGER (dumpsys power)\n");
 
         final DisplayPowerController dpc;
+        final WirelessChargerDetector wcd;
         synchronized (mLock) {
             pw.println("Power Manager State:");
             pw.println("  mDirty=0x" + Integer.toHexString(mDirty));
@@ -2291,11 +2281,16 @@
             pw.println("Display Blanker: " + mDisplayBlanker);
 
             dpc = mDisplayPowerController;
+            wcd = mWirelessChargerDetector;
         }
 
         if (dpc != null) {
             dpc.dump(pw);
         }
+
+        if (wcd != null) {
+            wcd.dump(pw);
+        }
     }
 
     private SuspendBlocker createSuspendBlockerLocked(String name) {
diff --git a/services/java/com/android/server/power/WirelessChargerDetector.java b/services/java/com/android/server/power/WirelessChargerDetector.java
new file mode 100644
index 0000000..ac6dc3e
--- /dev/null
+++ b/services/java/com/android/server/power/WirelessChargerDetector.java
@@ -0,0 +1,320 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.server.power;
+
+import android.hardware.Sensor;
+import android.hardware.SensorEvent;
+import android.hardware.SensorEventListener;
+import android.hardware.SensorManager;
+import android.os.BatteryManager;
+import android.util.Slog;
+
+import java.io.PrintWriter;
+
+/**
+ * Implements heuristics to detect docking or undocking from a wireless charger.
+ * <p>
+ * Some devices have wireless charging circuits that are unable to detect when the
+ * device is resting on a wireless charger except when the device is actually
+ * receiving power from the charger.  The device may stop receiving power
+ * if the battery is already nearly full or if it is too hot.  As a result, we cannot
+ * always rely on the battery service wireless plug signal to accurately indicate
+ * whether the device has been docked or undocked from a wireless charger.
+ * </p><p>
+ * This is a problem because the power manager typically wakes up the screen and
+ * plays a tone when the device is docked in a wireless charger.  It is important
+ * for the system to suppress spurious docking and undocking signals because they
+ * can be intrusive for the user (especially if they cause a tone to be played
+ * late at night for no apparent reason).
+ * </p><p>
+ * To avoid spurious signals, we apply some special policies to wireless chargers.
+ * </p><p>
+ * 1. Don't wake the device when undocked from the wireless charger because
+ * it might be that the device is still resting on the wireless charger
+ * but is not receiving power anymore because the battery is full.
+ * Ideally we would wake the device if we could be certain that the user had
+ * picked it up from the wireless charger but due to hardware limitations we
+ * must be more conservative.
+ * </p><p>
+ * 2. Don't wake the device when docked on a wireless charger if the
+ * battery already appears to be mostly full.  This situation may indicate
+ * that the device was resting on the charger the whole time and simply
+ * wasn't receiving power because the battery was already full.  We can't tell
+ * whether the device was just placed on the charger or whether it has
+ * been there for half of the night slowly discharging until it reached
+ * the point where it needed to start charging again.  So we suppress docking
+ * signals that occur when the battery level is above a given threshold.
+ * </p><p>
+ * 3. Don't wake the device when docked on a wireless charger if it does
+ * not appear to have moved since it was last undocked because it may
+ * be that the prior undocking signal was spurious.  We use the gravity
+ * sensor to detect this case.
+ * </p>
+ */
+final class WirelessChargerDetector {
+    private static final String TAG = "WirelessChargerDetector";
+    private static final boolean DEBUG = false;
+
+    // Number of nanoseconds per millisecond.
+    private static final long NANOS_PER_MS = 1000000;
+
+    // The minimum amount of time to spend watching the sensor before making
+    // a determination of whether movement occurred.
+    private static final long SETTLE_TIME_NANOS = 500 * NANOS_PER_MS;
+
+    // The minimum number of samples that must be collected.
+    private static final int MIN_SAMPLES = 3;
+
+    // Upper bound on the battery charge percentage in order to consider turning
+    // the screen on when the device starts charging wirelessly.
+    private static final int WIRELESS_CHARGER_TURN_ON_BATTERY_LEVEL_LIMIT = 95;
+
+    // To detect movement, we compute the angle between the gravity vector
+    // at rest and the current gravity vector.  This field specifies the
+    // cosine of the maximum angle variance that we tolerate while at rest.
+    private static final double MOVEMENT_ANGLE_COS_THRESHOLD = Math.cos(5 * Math.PI / 180);
+
+    // Sanity thresholds for the gravity vector.
+    private static final double MIN_GRAVITY = SensorManager.GRAVITY_EARTH - 1.0f;
+    private static final double MAX_GRAVITY = SensorManager.GRAVITY_EARTH + 1.0f;
+
+    private final Object mLock = new Object();
+
+    private final SensorManager mSensorManager;
+    private final SuspendBlocker mSuspendBlocker;
+
+    // The gravity sensor, or null if none.
+    private Sensor mGravitySensor;
+
+    // Previously observed wireless power state.
+    private boolean mPoweredWirelessly;
+
+    // True if the device is thought to be at rest on a wireless charger.
+    private boolean mAtRest;
+
+    // The gravity vector most recently observed while at rest.
+    private float mRestX, mRestY, mRestZ;
+
+    /* These properties are only meaningful while detection is in progress. */
+
+    // True if detection is in progress.
+    // The suspend blocker is held while this is the case.
+    private boolean mDetectionInProgress;
+
+    // True if the rest position should be updated if at rest.
+    // Otherwise, the current rest position is simply checked and cleared if movement
+    // is detected but no new rest position is stored.
+    private boolean mMustUpdateRestPosition;
+
+    // The total number of samples collected.
+    private int mTotalSamples;
+
+    // The number of samples collected that showed evidence of not being at rest.
+    private int mMovingSamples;
+
+    // The time and value of the first sample that was collected.
+    private long mFirstSampleTime;
+    private float mFirstSampleX, mFirstSampleY, mFirstSampleZ;
+
+    public WirelessChargerDetector(SensorManager sensorManager,
+            SuspendBlocker suspendBlocker) {
+        mSensorManager = sensorManager;
+        mSuspendBlocker = suspendBlocker;
+
+        mGravitySensor = sensorManager.getDefaultSensor(Sensor.TYPE_GRAVITY);
+    }
+
+    public void dump(PrintWriter pw) {
+        synchronized (mLock) {
+            pw.println();
+            pw.println("Wireless Charger Detector State:");
+            pw.println("  mGravitySensor=" + mGravitySensor);
+            pw.println("  mPoweredWirelessly=" + mPoweredWirelessly);
+            pw.println("  mAtRest=" + mAtRest);
+            pw.println("  mRestX=" + mRestX + ", mRestY=" + mRestY + ", mRestZ=" + mRestZ);
+            pw.println("  mDetectionInProgress=" + mDetectionInProgress);
+            pw.println("  mMustUpdateRestPosition=" + mMustUpdateRestPosition);
+            pw.println("  mTotalSamples=" + mTotalSamples);
+            pw.println("  mMovingSamples=" + mMovingSamples);
+            pw.println("  mFirstSampleTime=" + mFirstSampleTime);
+            pw.println("  mFirstSampleX=" + mFirstSampleX
+                    + ", mFirstSampleY=" + mFirstSampleY + ", mFirstSampleZ=" + mFirstSampleZ);
+        }
+    }
+
+    /**
+     * Updates the charging state and returns true if docking was detected.
+     *
+     * @param isPowered True if the device is powered.
+     * @param plugType The current plug type.
+     * @param batteryLevel The current battery level.
+     * @return True if the device is determined to have just been docked on a wireless
+     * charger, after suppressing spurious docking or undocking signals.
+     */
+    public boolean update(boolean isPowered, int plugType, int batteryLevel) {
+        synchronized (mLock) {
+            final boolean wasPoweredWirelessly = mPoweredWirelessly;
+
+            if (isPowered && plugType == BatteryManager.BATTERY_PLUGGED_WIRELESS) {
+                // The device is receiving power from the wireless charger.
+                // Update the rest position asynchronously.
+                mPoweredWirelessly = true;
+                mMustUpdateRestPosition = true;
+                startDetectionLocked();
+            } else {
+                // The device may or may not be on the wireless charger depending on whether
+                // the unplug signal that we received was spurious.
+                mPoweredWirelessly = false;
+                if (mAtRest) {
+                    if (plugType != 0 && plugType != BatteryManager.BATTERY_PLUGGED_WIRELESS) {
+                        // The device was plugged into a new non-wireless power source.
+                        // It's safe to assume that it is no longer on the wireless charger.
+                        mMustUpdateRestPosition = false;
+                        clearAtRestLocked();
+                    } else {
+                        // The device may still be on the wireless charger but we don't know.
+                        // Check whether the device has remained at rest on the charger
+                        // so that we will know to ignore the next wireless plug event
+                        // if needed.
+                        startDetectionLocked();
+                    }
+                }
+            }
+
+            // Report that the device has been docked only if the device just started
+            // receiving power wirelessly, has a high enough battery level that we
+            // can be assured that charging was not delayed due to the battery previously
+            // having been full, and the device is not known to already be at rest
+            // on the wireless charger from earlier.
+            return mPoweredWirelessly && !wasPoweredWirelessly
+                    && batteryLevel < WIRELESS_CHARGER_TURN_ON_BATTERY_LEVEL_LIMIT
+                    && !mAtRest;
+        }
+    }
+
+    private void startDetectionLocked() {
+        if (!mDetectionInProgress && mGravitySensor != null) {
+            if (mSensorManager.registerListener(mListener, mGravitySensor,
+                    SensorManager.SENSOR_DELAY_UI)) {
+                mSuspendBlocker.acquire();
+                mDetectionInProgress = true;
+                mTotalSamples = 0;
+                mMovingSamples = 0;
+            }
+        }
+    }
+
+    private void processSample(long timeNanos, float x, float y, float z) {
+        synchronized (mLock) {
+            if (!mDetectionInProgress) {
+                return;
+            }
+
+            mTotalSamples += 1;
+            if (mTotalSamples == 1) {
+                // Save information about the first sample collected.
+                mFirstSampleTime = timeNanos;
+                mFirstSampleX = x;
+                mFirstSampleY = y;
+                mFirstSampleZ = z;
+            } else {
+                // Determine whether movement has occurred relative to the first sample.
+                if (hasMoved(mFirstSampleX, mFirstSampleY, mFirstSampleZ, x, y, z)) {
+                    mMovingSamples += 1;
+                }
+            }
+
+            // Clear the at rest flag if movement has occurred relative to the rest sample.
+            if (mAtRest && hasMoved(mRestX, mRestY, mRestZ, x, y, z)) {
+                if (DEBUG) {
+                    Slog.d(TAG, "No longer at rest: "
+                            + "mRestX=" + mRestX + ", mRestY=" + mRestY + ", mRestZ=" + mRestZ
+                            + ", x=" + x + ", y=" + y + ", z=" + z);
+                }
+                clearAtRestLocked();
+            }
+
+            // Save the result when done.
+            if (timeNanos - mFirstSampleTime >= SETTLE_TIME_NANOS
+                    && mTotalSamples >= MIN_SAMPLES) {
+                mSensorManager.unregisterListener(mListener);
+                if (mMustUpdateRestPosition) {
+                    if (mMovingSamples == 0) {
+                        mAtRest = true;
+                        mRestX = x;
+                        mRestY = y;
+                        mRestZ = z;
+                    } else {
+                        clearAtRestLocked();
+                    }
+                    mMustUpdateRestPosition = false;
+                }
+                mDetectionInProgress = false;
+                mSuspendBlocker.release();
+
+                if (DEBUG) {
+                    Slog.d(TAG, "New state: mAtRest=" + mAtRest
+                            + ", mRestX=" + mRestX + ", mRestY=" + mRestY + ", mRestZ=" + mRestZ
+                            + ", mTotalSamples=" + mTotalSamples
+                            + ", mMovingSamples=" + mMovingSamples);
+                }
+            }
+        }
+    }
+
+    private void clearAtRestLocked() {
+        mAtRest = false;
+        mRestX = 0;
+        mRestY = 0;
+        mRestZ = 0;
+    }
+
+    private static boolean hasMoved(float x1, float y1, float z1,
+            float x2, float y2, float z2) {
+        final double dotProduct = (x1 * x2) + (y1 * y2) + (z1 * z2);
+        final double mag1 = Math.sqrt((x1 * x1) + (y1 * y1) + (z1 * z1));
+        final double mag2 = Math.sqrt((x2 * x2) + (y2 * y2) + (z2 * z2));
+        if (mag1 < MIN_GRAVITY || mag1 > MAX_GRAVITY
+                || mag2 < MIN_GRAVITY || mag2 > MAX_GRAVITY) {
+            if (DEBUG) {
+                Slog.d(TAG, "Weird gravity vector: mag1=" + mag1 + ", mag2=" + mag2);
+            }
+            return true;
+        }
+        final boolean moved = (dotProduct < mag1 * mag2 * MOVEMENT_ANGLE_COS_THRESHOLD);
+        if (DEBUG) {
+            Slog.d(TAG, "Check: moved=" + moved
+                    + ", x1=" + x1 + ", y1=" + y1 + ", z1=" + z1
+                    + ", x2=" + x2 + ", y2=" + y2 + ", z2=" + z2
+                    + ", angle=" + (Math.acos(dotProduct / mag1 / mag2) * 180 / Math.PI)
+                    + ", dotProduct=" + dotProduct
+                    + ", mag1=" + mag1 + ", mag2=" + mag2);
+        }
+        return moved;
+    }
+
+    private final SensorEventListener mListener = new SensorEventListener() {
+        @Override
+        public void onSensorChanged(SensorEvent event) {
+            processSample(event.timestamp, event.values[0], event.values[1], event.values[2]);
+        }
+
+        @Override
+        public void onAccuracyChanged(Sensor sensor, int accuracy) {
+        }
+    };
+}
diff --git a/services/java/com/android/server/wm/AppTransition.java b/services/java/com/android/server/wm/AppTransition.java
index 7736c93..30019e7 100644
--- a/services/java/com/android/server/wm/AppTransition.java
+++ b/services/java/com/android/server/wm/AppTransition.java
@@ -16,7 +16,6 @@
 
 package com.android.server.wm;
 
-import android.app.ActivityOptions;
 import android.content.Context;
 import android.graphics.Bitmap;
 import android.graphics.Point;
@@ -25,7 +24,6 @@
 import android.os.IRemoteCallback;
 import android.util.Slog;
 import android.view.WindowManager;
-import android.view.WindowManagerPolicy;
 import android.view.animation.AlphaAnimation;
 import android.view.animation.Animation;
 import android.view.animation.AnimationSet;
@@ -39,8 +37,26 @@
 
 import java.io.PrintWriter;
 
-import static android.view.WindowManagerPolicy.TRANSIT_NONE;
-import static android.view.WindowManagerPolicy.TRANSIT_UNSET;
+import static com.android.internal.R.styleable.WindowAnimation_activityOpenEnterAnimation;
+import static com.android.internal.R.styleable.WindowAnimation_activityOpenExitAnimation;
+import static com.android.internal.R.styleable.WindowAnimation_activityCloseEnterAnimation;
+import static com.android.internal.R.styleable.WindowAnimation_activityCloseExitAnimation;
+import static com.android.internal.R.styleable.WindowAnimation_taskOpenEnterAnimation;
+import static com.android.internal.R.styleable.WindowAnimation_taskOpenExitAnimation;
+import static com.android.internal.R.styleable.WindowAnimation_taskCloseEnterAnimation;
+import static com.android.internal.R.styleable.WindowAnimation_taskCloseExitAnimation;
+import static com.android.internal.R.styleable.WindowAnimation_taskToFrontEnterAnimation;
+import static com.android.internal.R.styleable.WindowAnimation_taskToFrontExitAnimation;
+import static com.android.internal.R.styleable.WindowAnimation_taskToBackEnterAnimation;
+import static com.android.internal.R.styleable.WindowAnimation_taskToBackExitAnimation;
+import static com.android.internal.R.styleable.WindowAnimation_wallpaperOpenEnterAnimation;
+import static com.android.internal.R.styleable.WindowAnimation_wallpaperOpenExitAnimation;
+import static com.android.internal.R.styleable.WindowAnimation_wallpaperCloseEnterAnimation;
+import static com.android.internal.R.styleable.WindowAnimation_wallpaperCloseExitAnimation;
+import static com.android.internal.R.styleable.WindowAnimation_wallpaperIntraOpenEnterAnimation;
+import static com.android.internal.R.styleable.WindowAnimation_wallpaperIntraOpenExitAnimation;
+import static com.android.internal.R.styleable.WindowAnimation_wallpaperIntraCloseEnterAnimation;
+import static com.android.internal.R.styleable.WindowAnimation_wallpaperIntraCloseExitAnimation;
 
 // State management of app transitions.  When we are preparing for a
 // transition, mNextAppTransition will be the kind of transition to
@@ -53,32 +69,81 @@
             WindowManagerService.DEBUG_APP_TRANSITIONS;
     private static final boolean DEBUG_ANIM = WindowManagerService.DEBUG_ANIM;
 
+    /** Bit mask that is set for all enter transition. */
+    public static final int TRANSIT_ENTER_MASK = 0x1000;
+
+    /** Bit mask that is set for all exit transitions. */
+    public static final int TRANSIT_EXIT_MASK = 0x2000;
+
+    /** Not set up for a transition. */
+    public static final int TRANSIT_UNSET = -1;
+    /** No animation for transition. */
+    public static final int TRANSIT_NONE = 0;
+    /** A window in a new activity is being opened on top of an existing one in the same task. */
+    public static final int TRANSIT_ACTIVITY_OPEN = 6 | TRANSIT_ENTER_MASK;
+    /** The window in the top-most activity is being closed to reveal the
+     * previous activity in the same task. */
+    public static final int TRANSIT_ACTIVITY_CLOSE = 7 | TRANSIT_EXIT_MASK;
+    /** A window in a new task is being opened on top of an existing one
+     * in another activity's task. */
+    public static final int TRANSIT_TASK_OPEN = 8 | TRANSIT_ENTER_MASK;
+    /** A window in the top-most activity is being closed to reveal the
+     * previous activity in a different task. */
+    public static final int TRANSIT_TASK_CLOSE = 9 | TRANSIT_EXIT_MASK;
+    /** A window in an existing task is being displayed on top of an existing one
+     * in another activity's task. */
+    public static final int TRANSIT_TASK_TO_FRONT = 10 | TRANSIT_ENTER_MASK;
+    /** A window in an existing task is being put below all other tasks. */
+    public static final int TRANSIT_TASK_TO_BACK = 11 | TRANSIT_EXIT_MASK;
+    /** A window in a new activity that doesn't have a wallpaper is being opened on top of one that
+     * does, effectively closing the wallpaper. */
+    public static final int TRANSIT_WALLPAPER_CLOSE = 12 | TRANSIT_EXIT_MASK;
+    /** A window in a new activity that does have a wallpaper is being opened on one that didn't,
+     * effectively opening the wallpaper. */
+    public static final int TRANSIT_WALLPAPER_OPEN = 13 | TRANSIT_ENTER_MASK;
+    /** A window in a new activity is being opened on top of an existing one, and both are on top
+     * of the wallpaper. */
+    public static final int TRANSIT_WALLPAPER_INTRA_OPEN = 14 | TRANSIT_ENTER_MASK;
+    /** The window in the top-most activity is being closed to reveal the previous activity, and
+     * both are on top of the wallpaper. */
+    public static final int TRANSIT_WALLPAPER_INTRA_CLOSE = 15 | TRANSIT_EXIT_MASK;
+
     /** Fraction of animation at which the recents thumbnail becomes completely transparent */
-    static final float RECENTS_THUMBNAIL_FADEOUT_FRACTION = 0.25f;
+    private static final float RECENTS_THUMBNAIL_FADEOUT_FRACTION = 0.25f;
 
-    static final long DEFAULT_APP_TRANSITION_DURATION = 250;
+    private static final long DEFAULT_APP_TRANSITION_DURATION = 250;
 
-    final Context mContext;
-    final Handler mH;
+    private final Context mContext;
+    private final Handler mH;
 
-    int mNextAppTransition = TRANSIT_UNSET;
-    int mNextAppTransitionType = ActivityOptions.ANIM_NONE;
-    String mNextAppTransitionPackage;
-    Bitmap mNextAppTransitionThumbnail;
+    private int mNextAppTransition = TRANSIT_UNSET;
+
+    private static final int NEXT_TRANSIT_TYPE_NONE = 0;
+    private static final int NEXT_TRANSIT_TYPE_CUSTOM = 1;
+    private static final int NEXT_TRANSIT_TYPE_SCALE_UP = 2;
+    private static final int NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP = 3;
+    private static final int NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN = 4;
+    private int mNextAppTransitionType = NEXT_TRANSIT_TYPE_NONE;
+
+    private String mNextAppTransitionPackage;
+    private Bitmap mNextAppTransitionThumbnail;
     // Used for thumbnail transitions. True if we're scaling up, false if scaling down
-    boolean mNextAppTransitionScaleUp;
-    IRemoteCallback mNextAppTransitionCallback;
-    int mNextAppTransitionEnter;
-    int mNextAppTransitionExit;
-    int mNextAppTransitionStartX;
-    int mNextAppTransitionStartY;
-    int mNextAppTransitionStartWidth;
-    int mNextAppTransitionStartHeight;
-    boolean mAppTransitionReady = false;
-    boolean mAppTransitionRunning = false;
-    boolean mAppTransitionTimeout = false;
+    private boolean mNextAppTransitionScaleUp;
+    private IRemoteCallback mNextAppTransitionCallback;
+    private int mNextAppTransitionEnter;
+    private int mNextAppTransitionExit;
+    private int mNextAppTransitionStartX;
+    private int mNextAppTransitionStartY;
+    private int mNextAppTransitionStartWidth;
+    private int mNextAppTransitionStartHeight;
 
-    final int mConfigShortAnimTime;
+    private final static int APP_STATE_IDLE = 0;
+    private final static int APP_STATE_READY = 1;
+    private final static int APP_STATE_RUNNING = 2;
+    private final static int APP_STATE_TIMEOUT = 3;
+    private int mAppTransitionState = APP_STATE_IDLE;
+
+    private final int mConfigShortAnimTime;
     private final Interpolator mDecelerateInterpolator;
     private final Interpolator mThumbnailFadeoutInterpolator;
 
@@ -122,27 +187,28 @@
     }
 
     boolean isReady() {
-        return mAppTransitionReady;
+        return mAppTransitionState == APP_STATE_READY
+                || mAppTransitionState == APP_STATE_TIMEOUT;
     }
 
     void setReady() {
-        mAppTransitionReady = true;
+        mAppTransitionState = APP_STATE_READY;
     }
 
     boolean isRunning() {
-        return mAppTransitionRunning;
+        return mAppTransitionState == APP_STATE_RUNNING;
     }
 
-    void setRunning(boolean running) {
-        mAppTransitionRunning = running;
+    void setIdle() {
+        mAppTransitionState = APP_STATE_IDLE;
     }
 
     boolean isTimeout() {
-        return mAppTransitionTimeout;
+        return mAppTransitionState == APP_STATE_TIMEOUT;
     }
 
-    void setTimeout(boolean timeout) {
-        mAppTransitionTimeout = timeout;
+    void setTimeout() {
+        mAppTransitionState = APP_STATE_TIMEOUT;
     }
 
     Bitmap getNextAppTransitionThumbnail() {
@@ -154,28 +220,29 @@
         outPoint.y = mNextAppTransitionStartY;
     }
 
-    int getType() {
-        return mNextAppTransitionType;
-    }
-
     void prepare() {
-        mAppTransitionReady = false;
-        mAppTransitionTimeout = false;
+        if (!isRunning()) {
+            mAppTransitionState = APP_STATE_IDLE;
+        }
     }
 
     void goodToGo() {
-        mNextAppTransition = WindowManagerPolicy.TRANSIT_UNSET;
-        mAppTransitionReady = false;
-        mAppTransitionRunning = true;
-        mAppTransitionTimeout = false;
+        mNextAppTransition = TRANSIT_UNSET;
+        mAppTransitionState = APP_STATE_RUNNING;
     }
 
     void clear() {
-        mNextAppTransitionType = ActivityOptions.ANIM_NONE;
+        mNextAppTransitionType = NEXT_TRANSIT_TYPE_NONE;
         mNextAppTransitionPackage = null;
         mNextAppTransitionThumbnail = null;
     }
 
+    void freeze() {
+        setAppTransition(AppTransition.TRANSIT_UNSET);
+        clear();
+        setReady();
+    }
+
     private AttributeCache.Entry getCachedAnimations(WindowManager.LayoutParams lp) {
         if (DEBUG_ANIM) Slog.v(TAG, "Loading animations: layout params pkg="
                 + (lp != null ? lp.packageName : null)
@@ -282,8 +349,8 @@
             set.addAnimation(alpha);
             set.setDetachWallpaper(true);
             a = set;
-        } else  if (transit == WindowManagerPolicy.TRANSIT_WALLPAPER_INTRA_OPEN ||
-                    transit == WindowManagerPolicy.TRANSIT_WALLPAPER_INTRA_CLOSE) {
+        } else  if (transit == TRANSIT_WALLPAPER_INTRA_OPEN ||
+                    transit == TRANSIT_WALLPAPER_INTRA_CLOSE) {
             // If we are on top of the wallpaper, we need an animation that
             // correctly handles the wallpaper staying static behind all of
             // the animated elements.  To do this, will just have the existing
@@ -300,8 +367,8 @@
         // task transition duration.
         final long duration;
         switch (transit) {
-            case WindowManagerPolicy.TRANSIT_ACTIVITY_OPEN:
-            case WindowManagerPolicy.TRANSIT_ACTIVITY_CLOSE:
+            case TRANSIT_ACTIVITY_OPEN:
+            case TRANSIT_ACTIVITY_CLOSE:
                 duration = mConfigShortAnimTime;
                 break;
             default:
@@ -363,7 +430,7 @@
         } else {
             // Exiting app
             if (mNextAppTransitionScaleUp) {
-                if (transit == WindowManagerPolicy.TRANSIT_WALLPAPER_INTRA_OPEN) {
+                if (transit == TRANSIT_WALLPAPER_INTRA_OPEN) {
                     // Fade out while bringing up selected activity. This keeps the
                     // current activity from showing through a launching wallpaper
                     // activity.
@@ -394,8 +461,8 @@
         // task transition duration.
         final long duration;
         switch (transit) {
-            case WindowManagerPolicy.TRANSIT_ACTIVITY_OPEN:
-            case WindowManagerPolicy.TRANSIT_ACTIVITY_CLOSE:
+            case TRANSIT_ACTIVITY_OPEN:
+            case TRANSIT_ACTIVITY_CLOSE:
                 duration = mConfigShortAnimTime;
                 break;
             default:
@@ -413,7 +480,7 @@
     Animation loadAnimation(WindowManager.LayoutParams lp, int transit, boolean enter,
                             int appWidth, int appHeight) {
         Animation a;
-        if (mNextAppTransitionType == ActivityOptions.ANIM_CUSTOM) {
+        if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_CUSTOM) {
             a = loadAnimation(mNextAppTransitionPackage, enter ?
                     mNextAppTransitionEnter : mNextAppTransitionExit);
             if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG,
@@ -421,17 +488,17 @@
                     + " anim=" + a + " nextAppTransition=ANIM_CUSTOM"
                     + " transit=" + transit + " isEntrance=" + enter
                     + " Callers=" + Debug.getCallers(3));
-        } else if (mNextAppTransitionType == ActivityOptions.ANIM_SCALE_UP) {
+        } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_SCALE_UP) {
             a = createScaleUpAnimationLocked(transit, enter, appWidth, appHeight);
             if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG,
                     "applyAnimation:"
                     + " anim=" + a + " nextAppTransition=ANIM_SCALE_UP"
                     + " transit=" + transit + " isEntrance=" + enter
                     + " Callers=" + Debug.getCallers(3));
-        } else if (mNextAppTransitionType == ActivityOptions.ANIM_THUMBNAIL_SCALE_UP ||
-                mNextAppTransitionType == ActivityOptions.ANIM_THUMBNAIL_SCALE_DOWN) {
+        } else if (mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP ||
+                mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN) {
             mNextAppTransitionScaleUp =
-                    (mNextAppTransitionType == ActivityOptions.ANIM_THUMBNAIL_SCALE_UP);
+                    (mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP);
             a = createThumbnailAnimationLocked(transit, enter, false, appWidth, appHeight);
             if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) {
                 String animName = mNextAppTransitionScaleUp ?
@@ -444,55 +511,55 @@
         } else {
             int animAttr = 0;
             switch (transit) {
-                case WindowManagerPolicy.TRANSIT_ACTIVITY_OPEN:
+                case TRANSIT_ACTIVITY_OPEN:
                     animAttr = enter
-                            ? com.android.internal.R.styleable.WindowAnimation_activityOpenEnterAnimation
-                            : com.android.internal.R.styleable.WindowAnimation_activityOpenExitAnimation;
+                            ? WindowAnimation_activityOpenEnterAnimation
+                            : WindowAnimation_activityOpenExitAnimation;
                     break;
-                case WindowManagerPolicy.TRANSIT_ACTIVITY_CLOSE:
+                case TRANSIT_ACTIVITY_CLOSE:
                     animAttr = enter
-                            ? com.android.internal.R.styleable.WindowAnimation_activityCloseEnterAnimation
-                            : com.android.internal.R.styleable.WindowAnimation_activityCloseExitAnimation;
+                            ? WindowAnimation_activityCloseEnterAnimation
+                            : WindowAnimation_activityCloseExitAnimation;
                     break;
-                case WindowManagerPolicy.TRANSIT_TASK_OPEN:
+                case TRANSIT_TASK_OPEN:
                     animAttr = enter
-                            ? com.android.internal.R.styleable.WindowAnimation_taskOpenEnterAnimation
-                            : com.android.internal.R.styleable.WindowAnimation_taskOpenExitAnimation;
+                            ? WindowAnimation_taskOpenEnterAnimation
+                            : WindowAnimation_taskOpenExitAnimation;
                     break;
-                case WindowManagerPolicy.TRANSIT_TASK_CLOSE:
+                case TRANSIT_TASK_CLOSE:
                     animAttr = enter
-                            ? com.android.internal.R.styleable.WindowAnimation_taskCloseEnterAnimation
-                            : com.android.internal.R.styleable.WindowAnimation_taskCloseExitAnimation;
+                            ? WindowAnimation_taskCloseEnterAnimation
+                            : WindowAnimation_taskCloseExitAnimation;
                     break;
-                case WindowManagerPolicy.TRANSIT_TASK_TO_FRONT:
+                case TRANSIT_TASK_TO_FRONT:
                     animAttr = enter
-                            ? com.android.internal.R.styleable.WindowAnimation_taskToFrontEnterAnimation
-                            : com.android.internal.R.styleable.WindowAnimation_taskToFrontExitAnimation;
+                            ? WindowAnimation_taskToFrontEnterAnimation
+                            : WindowAnimation_taskToFrontExitAnimation;
                     break;
-                case WindowManagerPolicy.TRANSIT_TASK_TO_BACK:
+                case TRANSIT_TASK_TO_BACK:
                     animAttr = enter
-                            ? com.android.internal.R.styleable.WindowAnimation_taskToBackEnterAnimation
-                            : com.android.internal.R.styleable.WindowAnimation_taskToBackExitAnimation;
+                            ? WindowAnimation_taskToBackEnterAnimation
+                            : WindowAnimation_taskToBackExitAnimation;
                     break;
-                case WindowManagerPolicy.TRANSIT_WALLPAPER_OPEN:
+                case TRANSIT_WALLPAPER_OPEN:
                     animAttr = enter
-                            ? com.android.internal.R.styleable.WindowAnimation_wallpaperOpenEnterAnimation
-                            : com.android.internal.R.styleable.WindowAnimation_wallpaperOpenExitAnimation;
+                            ? WindowAnimation_wallpaperOpenEnterAnimation
+                            : WindowAnimation_wallpaperOpenExitAnimation;
                     break;
-                case WindowManagerPolicy.TRANSIT_WALLPAPER_CLOSE:
+                case TRANSIT_WALLPAPER_CLOSE:
                     animAttr = enter
-                            ? com.android.internal.R.styleable.WindowAnimation_wallpaperCloseEnterAnimation
-                            : com.android.internal.R.styleable.WindowAnimation_wallpaperCloseExitAnimation;
+                            ? WindowAnimation_wallpaperCloseEnterAnimation
+                            : WindowAnimation_wallpaperCloseExitAnimation;
                     break;
-                case WindowManagerPolicy.TRANSIT_WALLPAPER_INTRA_OPEN:
+                case TRANSIT_WALLPAPER_INTRA_OPEN:
                     animAttr = enter
-                            ? com.android.internal.R.styleable.WindowAnimation_wallpaperIntraOpenEnterAnimation
-                            : com.android.internal.R.styleable.WindowAnimation_wallpaperIntraOpenExitAnimation;
+                            ? WindowAnimation_wallpaperIntraOpenEnterAnimation
+                            : WindowAnimation_wallpaperIntraOpenExitAnimation;
                     break;
-                case WindowManagerPolicy.TRANSIT_WALLPAPER_INTRA_CLOSE:
+                case TRANSIT_WALLPAPER_INTRA_CLOSE:
                     animAttr = enter
-                            ? com.android.internal.R.styleable.WindowAnimation_wallpaperIntraCloseEnterAnimation
-                            : com.android.internal.R.styleable.WindowAnimation_wallpaperIntraCloseExitAnimation;
+                            ? WindowAnimation_wallpaperIntraCloseEnterAnimation
+                            : WindowAnimation_wallpaperIntraCloseExitAnimation;
                     break;
             }
             a = animAttr != 0 ? loadAnimation(lp, animAttr) : null;
@@ -516,7 +583,7 @@
     void overridePendingAppTransition(String packageName, int enterAnim, int exitAnim,
                                              IRemoteCallback startedCallback) {
         if (isTransitionSet()) {
-            mNextAppTransitionType = ActivityOptions.ANIM_CUSTOM;
+            mNextAppTransitionType = NEXT_TRANSIT_TYPE_CUSTOM;
             mNextAppTransitionPackage = packageName;
             mNextAppTransitionThumbnail = null;
             mNextAppTransitionEnter = enterAnim;
@@ -531,7 +598,7 @@
     void overridePendingAppTransitionScaleUp(int startX, int startY, int startWidth,
                                                     int startHeight) {
         if (isTransitionSet()) {
-            mNextAppTransitionType = ActivityOptions.ANIM_SCALE_UP;
+            mNextAppTransitionType = NEXT_TRANSIT_TYPE_SCALE_UP;
             mNextAppTransitionPackage = null;
             mNextAppTransitionThumbnail = null;
             mNextAppTransitionStartX = startX;
@@ -546,8 +613,8 @@
     void overridePendingAppTransitionThumb(Bitmap srcThumb, int startX, int startY,
                                            IRemoteCallback startedCallback, boolean scaleUp) {
         if (isTransitionSet()) {
-            mNextAppTransitionType = scaleUp ? ActivityOptions.ANIM_THUMBNAIL_SCALE_UP
-                    : ActivityOptions.ANIM_THUMBNAIL_SCALE_DOWN;
+            mNextAppTransitionType = scaleUp ? NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP
+                    : NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN;
             mNextAppTransitionPackage = null;
             mNextAppTransitionThumbnail = srcThumb;
             mNextAppTransitionScaleUp = scaleUp;
@@ -565,17 +632,100 @@
         return "mNextAppTransition=0x" + Integer.toHexString(mNextAppTransition);
     }
 
+    /**
+     * Returns the human readable name of a window transition.
+     *
+     * @param transition The window transition.
+     * @return The transition symbolic name.
+     */
+    public static String appTransitionToString(int transition) {
+        switch (transition) {
+            case TRANSIT_UNSET: {
+                return "TRANSIT_UNSET";
+            }
+            case TRANSIT_NONE: {
+                return "TRANSIT_NONE";
+            }
+            case TRANSIT_EXIT_MASK: {
+                return "TRANSIT_EXIT_MASK";
+            }
+            case TRANSIT_ACTIVITY_OPEN: {
+                return "TRANSIT_ACTIVITY_OPEN";
+            }
+            case TRANSIT_ACTIVITY_CLOSE: {
+                return "TRANSIT_ACTIVITY_CLOSE";
+            }
+            case TRANSIT_TASK_OPEN: {
+                return "TRANSIT_TASK_OPEN";
+            }
+            case TRANSIT_TASK_CLOSE: {
+                return "TRANSIT_TASK_CLOSE";
+            }
+            case TRANSIT_TASK_TO_FRONT: {
+                return "TRANSIT_TASK_TO_FRONT";
+            }
+            case TRANSIT_TASK_TO_BACK: {
+                return "TRANSIT_TASK_TO_BACK";
+            }
+            case TRANSIT_WALLPAPER_CLOSE: {
+                return "TRANSIT_WALLPAPER_CLOSE";
+            }
+            case TRANSIT_WALLPAPER_OPEN: {
+                return "TRANSIT_WALLPAPER_OPEN";
+            }
+            case TRANSIT_WALLPAPER_INTRA_OPEN: {
+                return "TRANSIT_WALLPAPER_INTRA_OPEN";
+            }
+            case TRANSIT_WALLPAPER_INTRA_CLOSE: {
+                return "TRANSIT_WALLPAPER_INTRA_CLOSE";
+            }
+            default: {
+                return "<UNKNOWN>";
+            }
+        }
+    }
+
+    private String appStateToString() {
+        switch (mAppTransitionState) {
+            case APP_STATE_IDLE:
+                return "APP_STATE_IDLE";
+            case APP_STATE_READY:
+                return "APP_STATE_READY";
+            case APP_STATE_RUNNING:
+                return "APP_STATE_RUNNING";
+            case APP_STATE_TIMEOUT:
+                return "APP_STATE_TIMEOUT";
+            default:
+                return "unknown state=" + mAppTransitionState;
+        }
+    }
+
+    private String transitTypeToString() {
+        switch (mNextAppTransitionType) {
+            case NEXT_TRANSIT_TYPE_NONE:
+                return "NEXT_TRANSIT_TYPE_NONE";
+            case NEXT_TRANSIT_TYPE_CUSTOM:
+                return "NEXT_TRANSIT_TYPE_CUSTOM";
+            case NEXT_TRANSIT_TYPE_SCALE_UP:
+                return "NEXT_TRANSIT_TYPE_SCALE_UP";
+            case NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP:
+                return "NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP";
+            case NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN:
+                return "NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN";
+            default:
+                return "unknown type=" + mNextAppTransitionType;
+        }
+    }
+
     @Override
     public void dump(PrintWriter pw) {
         pw.print(" " + this);
-        pw.print(" mAppTransitionReady="); pw.println(mAppTransitionReady);
-        pw.print("  mAppTransitionRunning="); pw.print(mAppTransitionRunning);
-        pw.print(" mAppTransitionTimeout="); pw.println(mAppTransitionTimeout);
-        if (mNextAppTransitionType != ActivityOptions.ANIM_NONE) {
-            pw.print("  mNextAppTransitionType="); pw.println(mNextAppTransitionType);
+        pw.print(" mAppTransitionState="); pw.println(appStateToString());
+        if (mNextAppTransitionType != NEXT_TRANSIT_TYPE_NONE) {
+            pw.print("  mNextAppTransitionType="); pw.println(transitTypeToString());
         }
         switch (mNextAppTransitionType) {
-            case ActivityOptions.ANIM_CUSTOM:
+            case NEXT_TRANSIT_TYPE_CUSTOM:
                 pw.print("  mNextAppTransitionPackage=");
                         pw.println(mNextAppTransitionPackage);
                 pw.print("  mNextAppTransitionEnter=0x");
@@ -583,7 +733,7 @@
                         pw.print(" mNextAppTransitionExit=0x");
                         pw.println(Integer.toHexString(mNextAppTransitionExit));
                 break;
-            case ActivityOptions.ANIM_SCALE_UP:
+            case NEXT_TRANSIT_TYPE_SCALE_UP:
                 pw.print("  mNextAppTransitionStartX="); pw.print(mNextAppTransitionStartX);
                         pw.print(" mNextAppTransitionStartY=");
                         pw.println(mNextAppTransitionStartY);
@@ -592,8 +742,8 @@
                         pw.print(" mNextAppTransitionStartHeight=");
                         pw.println(mNextAppTransitionStartHeight);
                 break;
-            case ActivityOptions.ANIM_THUMBNAIL_SCALE_UP:
-            case ActivityOptions.ANIM_THUMBNAIL_SCALE_DOWN:
+            case NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP:
+            case NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN:
                 pw.print("  mNextAppTransitionThumbnail=");
                         pw.print(mNextAppTransitionThumbnail);
                         pw.print(" mNextAppTransitionStartX=");
diff --git a/services/java/com/android/server/wm/AppWindowToken.java b/services/java/com/android/server/wm/AppWindowToken.java
index adad09d..0ada604 100644
--- a/services/java/com/android/server/wm/AppWindowToken.java
+++ b/services/java/com/android/server/wm/AppWindowToken.java
@@ -225,7 +225,6 @@
 
     boolean isVisible() {
         final int N = allAppWindows.size();
-        // TODO: Consider using allDrawn instead of a single window.
         for (int i=0; i<N; i++) {
             WindowState win = allAppWindows.get(i);
             if (!win.mAppFreezing
diff --git a/services/java/com/android/server/wm/DimAnimator.java b/services/java/com/android/server/wm/DimAnimator.java
deleted file mode 100644
index 5874202..0000000
--- a/services/java/com/android/server/wm/DimAnimator.java
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.server.wm;
-
-import android.content.res.Resources;
-import android.graphics.PixelFormat;
-import android.util.Slog;
-import android.util.TypedValue;
-import android.view.Surface;
-import android.view.SurfaceSession;
-
-import java.io.PrintWriter;
-
-/**
- * DimAnimator class that controls the dim animation. This holds the surface and
- * all state used for dim animation.
- */
-class DimAnimator {
-    static final String TAG = "DimAnimator";
-
-    Surface mDimSurface;
-    boolean mDimShown = false;
-    float mDimCurrentAlpha;
-    float mDimTargetAlpha;
-    float mDimDeltaPerMs;
-    long mLastDimAnimTime;
-
-    int mLastDimWidth, mLastDimHeight;
-
-    DimAnimator (SurfaceSession session, final int layerStack) {
-        try {
-            if (WindowManagerService.DEBUG_SURFACE_TRACE) {
-                mDimSurface = new WindowStateAnimator.SurfaceTrace(session,
-                    "DimAnimator",
-                    16, 16, PixelFormat.OPAQUE,
-                    Surface.FX_SURFACE_DIM | Surface.HIDDEN);
-            } else {
-                mDimSurface = new Surface(session, "DimAnimator",
-                    16, 16, PixelFormat.OPAQUE,
-                    Surface.FX_SURFACE_DIM | Surface.HIDDEN);
-            }
-            if (WindowManagerService.SHOW_TRANSACTIONS ||
-                    WindowManagerService.SHOW_SURFACE_ALLOC) Slog.i(WindowManagerService.TAG,
-                            "  DIM " + mDimSurface + ": CREATE");
-            mDimSurface.setLayerStack(layerStack);
-            mDimSurface.setAlpha(0.0f);
-            mDimSurface.show();
-        } catch (Exception e) {
-            Slog.e(WindowManagerService.TAG, "Exception creating Dim surface", e);
-        }
-    }
-
-    /**
-     * Set's the dim surface's layer and update dim parameters that will be used in
-     * {@link #updateSurface} after all windows are examined.
-     */
-    void updateParameters(final Resources res, final Parameters params, final long currentTime) {
-        if (mDimSurface == null) {
-            Slog.e(TAG, "updateParameters: no Surface");
-            return;
-        }
-
-        // Multiply by 1.5 so that rotating a frozen surface that includes this does not expose a
-        // corner.
-        final int dw = (int) (params.mDimWidth * 1.5);
-        final int dh = (int) (params.mDimHeight * 1.5);
-        final WindowStateAnimator winAnimator = params.mDimWinAnimator;
-        final float target = params.mDimTarget;
-        if (!mDimShown) {
-            if (WindowManagerService.SHOW_TRANSACTIONS) Slog.i(WindowManagerService.TAG,
-                "  DIM " + mDimSurface + ": SHOW pos=(0,0) (" + dw + "x" + dh + ")");
-            mDimShown = true;
-            try {
-                mLastDimWidth = dw;
-                mLastDimHeight = dh;
-                // back off position so mDimXXX/4 is before and mDimXXX/4 is after
-                mDimSurface.setPosition(-1 * dw / 6, -1 * dh /6);
-                mDimSurface.setSize(dw, dh);
-                mDimSurface.show();
-            } catch (RuntimeException e) {
-                Slog.w(WindowManagerService.TAG, "Failure showing dim surface", e);
-            }
-        } else if (mLastDimWidth != dw || mLastDimHeight != dh) {
-            mLastDimWidth = dw;
-            mLastDimHeight = dh;
-            mDimSurface.setSize(dw, dh);
-            // back off position so mDimXXX/4 is before and mDimXXX/4 is after
-            mDimSurface.setPosition(-1 * dw / 6, -1 * dh /6);
-        }
-
-        mDimSurface.setLayer(winAnimator.mAnimLayer - WindowManagerService.LAYER_OFFSET_DIM);
-
-        if (WindowManagerService.SHOW_TRANSACTIONS) Slog.i(WindowManagerService.TAG, "  DIM "
-                + mDimSurface + ": layer=" + (winAnimator.mAnimLayer-1) + " target=" + target);
-        if (mDimTargetAlpha != target) {
-            // If the desired dim level has changed, then
-            // start an animation to it.
-            mLastDimAnimTime = currentTime;
-            long duration = (winAnimator.mAnimating && winAnimator.mAnimation != null)
-                    ? winAnimator.mAnimation.computeDurationHint()
-                    : WindowManagerService.DEFAULT_DIM_DURATION;
-            if (target > mDimTargetAlpha) {
-                TypedValue tv = new TypedValue();
-                res.getValue(com.android.internal.R.fraction.config_dimBehindFadeDuration,
-                        tv, true);
-                if (tv.type == TypedValue.TYPE_FRACTION) {
-                    duration = (long)tv.getFraction(duration, duration);
-                } else if (tv.type >= TypedValue.TYPE_FIRST_INT
-                        && tv.type <= TypedValue.TYPE_LAST_INT) {
-                    duration = tv.data;
-                }
-            }
-            if (duration < 1) {
-                // Don't divide by zero
-                duration = 1;
-            }
-            mDimTargetAlpha = target;
-            mDimDeltaPerMs = (mDimTargetAlpha-mDimCurrentAlpha) / duration;
-        }
-    }
-
-    /**
-     * Updating the surface's alpha. Returns true if the animation continues, or returns
-     * false when the animation is finished and the dim surface is hidden.
-     */
-    boolean updateSurface(boolean dimming, long currentTime, boolean displayFrozen) {
-        if (mDimSurface == null) {
-            Slog.e(TAG, "updateSurface: no Surface");
-            return false;
-        }
-
-        if (!dimming) {
-            if (mDimTargetAlpha != 0) {
-                mLastDimAnimTime = currentTime;
-                mDimTargetAlpha = 0;
-                mDimDeltaPerMs = (-mDimCurrentAlpha) / WindowManagerService.DEFAULT_DIM_DURATION;
-            }
-        }
-
-        boolean animating = mLastDimAnimTime != 0;
-        if (animating) {
-            mDimCurrentAlpha += mDimDeltaPerMs
-                    * (currentTime-mLastDimAnimTime);
-            if (displayFrozen) {
-                // If the display is frozen, there is no reason to animate.
-                animating = false;
-            } else if (mDimDeltaPerMs > 0) {
-                if (mDimCurrentAlpha > mDimTargetAlpha) {
-                    animating = false;
-                }
-            } else if (mDimDeltaPerMs < 0) {
-                if (mDimCurrentAlpha < mDimTargetAlpha) {
-                    animating = false;
-                }
-            } else {
-                animating = false;
-            }
-
-            // Do we need to continue animating?
-            if (animating) {
-                if (WindowManagerService.SHOW_TRANSACTIONS) Slog.i(WindowManagerService.TAG, "  DIM "
-                        + mDimSurface + ": alpha=" + mDimCurrentAlpha);
-                mLastDimAnimTime = currentTime;
-                mDimSurface.setAlpha(mDimCurrentAlpha);
-            } else {
-                mDimCurrentAlpha = mDimTargetAlpha;
-                mLastDimAnimTime = 0;
-                if (WindowManagerService.SHOW_TRANSACTIONS) Slog.i(WindowManagerService.TAG, "  DIM "
-                        + mDimSurface + ": final alpha=" + mDimCurrentAlpha);
-                mDimSurface.setAlpha(mDimCurrentAlpha);
-                if (!dimming) {
-                    if (WindowManagerService.SHOW_TRANSACTIONS) Slog.i(WindowManagerService.TAG, "  DIM " + mDimSurface
-                            + ": HIDE");
-                    try {
-                        mDimSurface.hide();
-                    } catch (RuntimeException e) {
-                        Slog.w(WindowManagerService.TAG, "Illegal argument exception hiding dim surface");
-                    }
-                    mDimShown = false;
-                }
-            }
-        }
-        return animating;
-    }
-
-    public void kill() {
-        if (mDimSurface != null) {
-            mDimSurface.destroy();
-            mDimSurface = null;
-        }
-    }
-
-    public void printTo(String prefix, PrintWriter pw) {
-        pw.print(prefix);
-        pw.print("mDimSurface="); pw.print(mDimSurface);
-                pw.print(" "); pw.print(mLastDimWidth); pw.print(" x ");
-                pw.println(mLastDimHeight);
-        pw.print(prefix);
-        pw.print("mDimShown="); pw.print(mDimShown);
-        pw.print(" current="); pw.print(mDimCurrentAlpha);
-        pw.print(" target="); pw.print(mDimTargetAlpha);
-        pw.print(" delta="); pw.print(mDimDeltaPerMs);
-        pw.print(" lastAnimTime="); pw.println(mLastDimAnimTime);
-    }
-
-    static class Parameters {
-        final WindowStateAnimator mDimWinAnimator;
-        final int mDimWidth;
-        final int mDimHeight;
-        final float mDimTarget;
-        Parameters(final WindowStateAnimator dimWinAnimator, final int dimWidth,
-                final int dimHeight, final float dimTarget) {
-            mDimWinAnimator = dimWinAnimator;
-            mDimWidth = dimWidth;
-            mDimHeight = dimHeight;
-            mDimTarget = dimTarget;
-        }
-
-        Parameters(Parameters o) {
-            mDimWinAnimator = o.mDimWinAnimator;
-            mDimWidth = o.mDimWidth;
-            mDimHeight = o.mDimHeight;
-            mDimTarget = o.mDimTarget;
-        }
-
-        public void printTo(String prefix, PrintWriter pw) {
-            pw.print(prefix);
-            pw.print("mDimWinAnimator="); pw.print(mDimWinAnimator.mWin.mAttrs.getTitle());
-                    pw.print(" "); pw.print(mDimWidth); pw.print(" x ");
-                    pw.print(mDimHeight);
-            pw.print(" mDimTarget="); pw.println(mDimTarget);
-        }
-    }
-}
diff --git a/services/java/com/android/server/wm/DimLayer.java b/services/java/com/android/server/wm/DimLayer.java
new file mode 100644
index 0000000..4c7add9
--- /dev/null
+++ b/services/java/com/android/server/wm/DimLayer.java
@@ -0,0 +1,257 @@
+// Copyright 2012 Google Inc. All Rights Reserved.
+
+package com.android.server.wm;
+
+import android.graphics.PixelFormat;
+import android.os.SystemClock;
+import android.util.Slog;
+import android.view.DisplayInfo;
+import android.view.Surface;
+
+import java.io.PrintWriter;
+
+public class DimLayer {
+    private static final String TAG = "DimLayer";
+    private static final boolean DEBUG = false;
+
+    /** Reference to the owner of this object. */
+    final DisplayContent mDisplayContent;
+
+    /** Actual surface that dims */
+    Surface mDimSurface;
+
+    /** Last value passed to mDimSurface.setAlpha() */
+    float mAlpha = 0;
+
+    /** Last value passed to mDimSurface.setLayer() */
+    int mLayer = -1;
+
+    /** Last values passed to mDimSurface.setSize() */
+    int mLastDimWidth, mLastDimHeight;
+
+    /** True after mDimSurface.show() has been called, false after mDimSurface.hide(). */
+    private boolean mShowing = false;
+
+    /** Value of mAlpha when beginning transition to mTargetAlpha */
+    float mStartAlpha = 0;
+
+    /** Final value of mAlpha following transition */
+    float mTargetAlpha = 0;
+
+    /** Time in units of SystemClock.uptimeMillis() at which the current transition started */
+    long mStartTime;
+
+    /** Time in milliseconds to take to transition from mStartAlpha to mTargetAlpha */
+    long mDuration;
+
+    DimLayer(WindowManagerService service, int displayId) {
+        if (DEBUG) Slog.v(TAG, "Ctor: displayId=" + displayId);
+        mDisplayContent = service.getDisplayContentLocked(displayId);
+        Surface.openTransaction();
+        try {
+            if (WindowManagerService.DEBUG_SURFACE_TRACE) {
+                mDimSurface = new WindowStateAnimator.SurfaceTrace(service.mFxSession,
+                    "DimSurface",
+                    16, 16, PixelFormat.OPAQUE,
+                    Surface.FX_SURFACE_DIM | Surface.HIDDEN);
+            } else {
+                mDimSurface = new Surface(service.mFxSession, TAG,
+                    16, 16, PixelFormat.OPAQUE,
+                    Surface.FX_SURFACE_DIM | Surface.HIDDEN);
+            }
+            if (WindowManagerService.SHOW_TRANSACTIONS ||
+                    WindowManagerService.SHOW_SURFACE_ALLOC) Slog.i(TAG,
+                            "  DIM " + mDimSurface + ": CREATE");
+            mDimSurface.setLayerStack(displayId);
+        } catch (Exception e) {
+            Slog.e(WindowManagerService.TAG, "Exception creating Dim surface", e);
+        } finally {
+            Surface.closeTransaction();
+        }
+    }
+
+    /** Return true if dim layer is showing */
+    boolean isDimming() {
+        return mTargetAlpha != 0;
+    }
+
+    /** Return true if in a transition period */
+    boolean isAnimating() {
+        return mTargetAlpha != mAlpha;
+    }
+
+    float getTargetAlpha() {
+        return mTargetAlpha;
+    }
+
+    private void setAlpha(float alpha) {
+        if (mAlpha != alpha) {
+            if (DEBUG) Slog.v(TAG, "setAlpha alpha=" + alpha);
+            try {
+                mDimSurface.setAlpha(alpha);
+                if (alpha == 0 && mShowing) {
+                    if (DEBUG) Slog.v(TAG, "setAlpha hiding");
+                    mDimSurface.hide();
+                    mShowing = false;
+                } else if (alpha > 0 && !mShowing) {
+                    if (DEBUG) Slog.v(TAG, "setAlpha showing");
+                    mDimSurface.show();
+                    mShowing = true;
+                }
+            } catch (RuntimeException e) {
+                Slog.w(TAG, "Failure setting alpha immediately", e);
+            }
+            mAlpha = alpha;
+        }
+    }
+
+    /**
+     * @param duration The time to test.
+     * @return True if the duration would lead to an earlier end to the current animation.
+     */
+    private boolean durationEndsEarlier(long duration) {
+        return SystemClock.uptimeMillis() + duration < mStartTime + mDuration;
+    }
+
+    /** Jump to the end of the animation.
+     * NOTE: Must be called with Surface transaction open. */
+    void show() {
+        if (isAnimating()) {
+            if (DEBUG) Slog.v(TAG, "show: immediate");
+            show(mLayer, mTargetAlpha, 0);
+        }
+    }
+
+    /**
+     * Begin an animation to a new dim value.
+     * NOTE: Must be called with Surface transaction open.
+     *
+     * @param layer The layer to set the surface to.
+     * @param alpha The dim value to end at.
+     * @param duration How long to take to get there in milliseconds.
+     */
+    void show(int layer, float alpha, long duration) {
+        if (DEBUG) Slog.v(TAG, "show: layer=" + layer + " alpha=" + alpha
+                + " duration=" + duration);
+        if (mDimSurface == null) {
+            Slog.e(TAG, "show: no Surface");
+            // Make sure isAnimating() returns false.
+            mTargetAlpha = mAlpha = 0;
+            return;
+        }
+
+        // Set surface size to screen size.
+        final DisplayInfo info = mDisplayContent.getDisplayInfo();
+        // Multiply by 1.5 so that rotating a frozen surface that includes this does not expose a
+        // corner.
+        final int dw = (int) (info.logicalWidth * 1.5);
+        final int dh = (int) (info.logicalHeight * 1.5);
+        // back off position so 1/4 of Surface is before and 1/4 is after.
+        final float xPos = -1 * dw / 6;
+        final float yPos = -1 * dh / 6;
+
+        if (mLastDimWidth != dw || mLastDimHeight != dh || mLayer != layer) {
+            try {
+                mDimSurface.setPosition(xPos, yPos);
+                mDimSurface.setSize(dw, dh);
+                mDimSurface.setLayer(layer);
+            } catch (RuntimeException e) {
+                Slog.w(TAG, "Failure setting size or layer", e);
+            }
+            mLastDimWidth = dw;
+            mLastDimHeight = dh;
+            mLayer = layer;
+        }
+
+        long curTime = SystemClock.uptimeMillis();
+        final boolean animating = isAnimating();
+        if ((animating && (mTargetAlpha != alpha || durationEndsEarlier(duration)))
+                || (!animating && mAlpha != alpha)) {
+            if (duration <= 0) {
+                // No animation required, just set values.
+                setAlpha(alpha);
+            } else {
+                // Start or continue animation with new parameters.
+                mStartAlpha = mAlpha;
+                mStartTime = curTime;
+                mDuration = duration;
+            }
+        }
+        if (DEBUG) Slog.v(TAG, "show: mStartAlpha=" + mStartAlpha + " mStartTime=" + mStartTime);
+        mTargetAlpha = alpha;
+    }
+
+    /** Immediate hide.
+     * NOTE: Must be called with Surface transaction open. */
+    void hide() {
+        if (mShowing) {
+            if (DEBUG) Slog.v(TAG, "hide: immediate");
+            hide(0);
+        }
+    }
+
+    /**
+     * Gradually fade to transparent.
+     * NOTE: Must be called with Surface transaction open.
+     *
+     * @param duration Time to fade in milliseconds.
+     */
+    void hide(long duration) {
+        if (mShowing && (mTargetAlpha != 0 || durationEndsEarlier(duration))) {
+            if (DEBUG) Slog.v(TAG, "hide: duration=" + duration);
+            show(mLayer, 0, duration);
+        }
+    }
+
+    /**
+     * Advance the dimming per the last #show(int, float, long) call.
+     * NOTE: Must be called with Surface transaction open.
+     *
+     * @return True if animation is still required after this step.
+     */
+    boolean stepAnimation() {
+        if (mDimSurface == null) {
+            Slog.e(TAG, "stepAnimation: null Surface");
+            // Ensure that isAnimating() returns false;
+            mTargetAlpha = mAlpha = 0;
+            return false;
+        }
+
+        if (isAnimating()) {
+            final long curTime = SystemClock.uptimeMillis();
+            final float alphaDelta = mTargetAlpha - mStartAlpha;
+            float alpha = mStartAlpha + alphaDelta * (curTime - mStartTime) / mDuration;
+            if (alphaDelta > 0 && alpha > mTargetAlpha ||
+                    alphaDelta < 0 && alpha < mTargetAlpha) {
+                // Don't exceed limits.
+                alpha = mTargetAlpha;
+            }
+            if (DEBUG) Slog.v(TAG, "stepAnimation: curTime=" + curTime + " alpha=" + alpha);
+            setAlpha(alpha);
+        }
+
+        return isAnimating();
+    }
+
+    /** Cleanup */
+    void destroySurface() {
+        if (DEBUG) Slog.v(TAG, "destroySurface.");
+        if (mDimSurface != null) {
+            mDimSurface.destroy();
+            mDimSurface = null;
+        }
+    }
+
+    public void printTo(String prefix, PrintWriter pw) {
+        pw.print(prefix); pw.print("mDimSurface="); pw.println(mDimSurface);
+        pw.print(prefix); pw.print(" mLayer="); pw.print(mLayer);
+                pw.print(" mAlpha="); pw.println(mAlpha);
+        pw.print(prefix); pw.print("mLastDimWidth="); pw.print(mLastDimWidth);
+                pw.print(" mLastDimWidth="); pw.println(mLastDimWidth);
+        pw.print(prefix); pw.print("Last animation: mStartTime="); pw.print(mStartTime);
+                pw.print(" mDuration="); pw.print(mDuration);
+                pw.print(" curTime="); pw.println(SystemClock.uptimeMillis());
+        pw.print(" mStartAlpha="); pw.println(mStartAlpha);
+                pw.print(" mTargetAlpha="); pw.print(mTargetAlpha);
+    }
+}
diff --git a/services/java/com/android/server/wm/DimSurface.java b/services/java/com/android/server/wm/DimSurface.java
deleted file mode 100644
index 511d388..0000000
--- a/services/java/com/android/server/wm/DimSurface.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.server.wm;
-
-import android.graphics.PixelFormat;
-import android.util.Slog;
-import android.view.DisplayInfo;
-import android.view.Surface;
-import android.view.SurfaceSession;
-
-import java.io.PrintWriter;
-
-class DimSurface {
-    static final String TAG = "DimSurface";
-
-    Surface mDimSurface;
-    boolean mDimShown = false;
-    int mDimColor = 0;
-    int mLayer = -1;
-    int mLastDimWidth, mLastDimHeight;
-    final DisplayContent mDisplayContent;
-
-    DimSurface(SurfaceSession session, DisplayContent displayContent) {
-        mDisplayContent = displayContent;
-        final int layerStack = displayContent.getDisplayId();
-        try {
-            if (WindowManagerService.DEBUG_SURFACE_TRACE) {
-                mDimSurface = new WindowStateAnimator.SurfaceTrace(session,
-                    "DimSurface",
-                    16, 16, PixelFormat.OPAQUE,
-                    Surface.FX_SURFACE_DIM | Surface.HIDDEN);
-            } else {
-                mDimSurface = new Surface(session, "DimSurface",
-                    16, 16, PixelFormat.OPAQUE,
-                    Surface.FX_SURFACE_DIM | Surface.HIDDEN);
-            }
-            if (WindowManagerService.SHOW_TRANSACTIONS ||
-                    WindowManagerService.SHOW_SURFACE_ALLOC) Slog.i(WindowManagerService.TAG,
-                            "  DIM " + mDimSurface + ": CREATE");
-            mDimSurface.setLayerStack(layerStack);
-            mDimSurface.setAlpha(0.0f);
-            mDimSurface.show();
-        } catch (Exception e) {
-            Slog.e(WindowManagerService.TAG, "Exception creating Dim surface", e);
-        }
-    }
-
-    /**
-     * Show the dim surface.
-     */
-    void show(int layer, int color) {
-        final DisplayInfo info = mDisplayContent.getDisplayInfo();
-        final int dw = info.logicalWidth;
-        final int dh = info.logicalHeight;
-        if (mDimSurface == null) {
-            Slog.e(TAG, "show: no Surface");
-            return;
-        }
-
-        if (!mDimShown) {
-            if (WindowManagerService.SHOW_TRANSACTIONS) Slog.i(WindowManagerService.TAG, "  DIM " + mDimSurface + ": SHOW pos=(0,0) (" +
-                    dw + "x" + dh + " layer=" + layer + ")");
-            mDimShown = true;
-            try {
-                mLastDimWidth = dw;
-                mLastDimHeight = dh;
-                mDimSurface.setPosition(0, 0);
-                mDimSurface.setSize(dw, dh);
-                mDimSurface.setLayer(layer);
-                mDimSurface.show();
-            } catch (RuntimeException e) {
-                Slog.w(WindowManagerService.TAG, "Failure showing dim surface", e);
-            }
-        } else if (mLastDimWidth != dw || mLastDimHeight != dh || mDimColor != color
-                || mLayer != layer) {
-            if (WindowManagerService.SHOW_TRANSACTIONS) Slog.i(WindowManagerService.TAG, "  DIM " + mDimSurface + ": pos=(0,0) (" +
-                    dw + "x" + dh + " layer=" + layer + ")");
-            mLastDimWidth = dw;
-            mLastDimHeight = dh;
-            mLayer = layer;
-            mDimColor = color;
-            mDimSurface.setSize(dw, dh);
-            mDimSurface.setLayer(layer);
-            mDimSurface.setAlpha(((color>>24)&0xff)/255.0f);
-        }
-    }
-
-    void hide() {
-        if (mDimSurface == null) {
-            Slog.e(TAG, "hide: no Surface");
-            return;
-        }
-
-        if (mDimShown) {
-            mDimShown = false;
-            try {
-                if (WindowManagerService.SHOW_TRANSACTIONS) Slog.i(WindowManagerService.TAG, "  HIDE " + mDimSurface);
-                mDimSurface.hide();
-            } catch (RuntimeException e) {
-                Slog.w(WindowManagerService.TAG, "Illegal argument exception hiding dim surface");
-            }
-        }
-    }
-
-    void kill() {
-        if (mDimSurface != null) {
-            mDimSurface.destroy();
-            mDimSurface = null;
-        }
-    }
-
-    public void printTo(String prefix, PrintWriter pw) {
-        pw.print(prefix); pw.print("mDimSurface="); pw.println(mDimSurface);
-        pw.print(prefix); pw.print("mDimShown="); pw.print(mDimShown);
-                pw.print(" mLayer="); pw.print(mLayer);
-                pw.print(" mDimColor=0x"); pw.println(Integer.toHexString(mDimColor));
-        pw.print(prefix); pw.print("mLastDimWidth="); pw.print(mLastDimWidth);
-                pw.print(" mLastDimWidth="); pw.println(mLastDimWidth);
-    }
-}
diff --git a/services/java/com/android/server/wm/DisplayMagnifier.java b/services/java/com/android/server/wm/DisplayMagnifier.java
index cd5ae4b..d3c01f0 100644
--- a/services/java/com/android/server/wm/DisplayMagnifier.java
+++ b/services/java/com/android/server/wm/DisplayMagnifier.java
@@ -50,7 +50,6 @@
 
 import com.android.internal.R;
 import com.android.internal.os.SomeArgs;
-import com.android.internal.policy.impl.PhoneWindowManager;
 
 /**
  * This class is a part of the window manager and encapsulates the
@@ -137,25 +136,34 @@
         mHandler.sendEmptyMessage(MyHandler.MESSAGE_NOTIFY_ROTATION_CHANGED);
     }
 
-    public void onWindowTransitionLocked(WindowState windowState, int transition) {
+    public void onAppWindowTransitionLocked(WindowState windowState, int transition) {
         if (DEBUG_WINDOW_TRANSITIONS) {
             Slog.i(LOG_TAG, "Window transition: "
-                    + PhoneWindowManager.windowTransitionToString(transition)
+                    + AppTransition.appTransitionToString(transition)
                     + " displayId: " + windowState.getDisplayId());
         }
         final boolean magnifying = mMagnifedViewport.isMagnifyingLocked();
         if (magnifying) {
             switch (transition) {
-                case WindowManagerPolicy.TRANSIT_ACTIVITY_OPEN:
-                case WindowManagerPolicy.TRANSIT_TASK_OPEN:
-                case WindowManagerPolicy.TRANSIT_TASK_TO_FRONT:
-                case WindowManagerPolicy.TRANSIT_WALLPAPER_OPEN:
-                case WindowManagerPolicy.TRANSIT_WALLPAPER_CLOSE:
-                case WindowManagerPolicy.TRANSIT_WALLPAPER_INTRA_OPEN: {
+                case AppTransition.TRANSIT_ACTIVITY_OPEN:
+                case AppTransition.TRANSIT_TASK_OPEN:
+                case AppTransition.TRANSIT_TASK_TO_FRONT:
+                case AppTransition.TRANSIT_WALLPAPER_OPEN:
+                case AppTransition.TRANSIT_WALLPAPER_CLOSE:
+                case AppTransition.TRANSIT_WALLPAPER_INTRA_OPEN: {
                     mHandler.sendEmptyMessage(MyHandler.MESSAGE_NOTIFY_USER_CONTEXT_CHANGED);
                 }
             }
         }
+    }
+
+    public void onWindowTransitionLocked(WindowState windowState, int transition) {
+        if (DEBUG_WINDOW_TRANSITIONS) {
+            Slog.i(LOG_TAG, "Window transition: "
+                    + AppTransition.appTransitionToString(transition)
+                    + " displayId: " + windowState.getDisplayId());
+        }
+        final boolean magnifying = mMagnifedViewport.isMagnifyingLocked();
         final int type = windowState.mAttrs.type;
         switch (transition) {
             case WindowManagerPolicy.TRANSIT_ENTER:
@@ -459,7 +467,6 @@
             private static final int MIN_ALPHA = 0;
             private static final int MAX_ALPHA = 255;
 
-            private final Point mTempPoint = new Point();
             private final Region mBounds = new Region();
             private final Rect mDirtyRect = new Rect();
             private final Paint mPaint = new Paint();
diff --git a/services/java/com/android/server/wm/WindowAnimator.java b/services/java/com/android/server/wm/WindowAnimator.java
index a9f3c0f..d5144fb 100644
--- a/services/java/com/android/server/wm/WindowAnimator.java
+++ b/services/java/com/android/server/wm/WindowAnimator.java
@@ -19,6 +19,7 @@
 import android.util.SparseArray;
 import android.util.SparseIntArray;
 import android.util.TimeUtils;
+import android.util.TypedValue;
 import android.view.Display;
 import android.view.Surface;
 import android.view.WindowManagerPolicy;
@@ -37,6 +38,10 @@
 public class WindowAnimator {
     private static final String TAG = "WindowAnimator";
 
+    /** Amount of time in milliseconds to animate the dim surface from one value to another,
+     * when no window animation is driving it. */
+    static final int DEFAULT_DIM_DURATION = 200;
+
     final WindowManagerService mService;
     final Context mContext;
     final WindowManagerPolicy mPolicy;
@@ -115,7 +120,7 @@
         final DisplayContentsAnimator displayAnimator = mDisplayContentsAnimators.get(displayId);
         if (displayAnimator != null) {
             if (displayAnimator.mWindowAnimationBackgroundSurface != null) {
-                displayAnimator.mWindowAnimationBackgroundSurface.kill();
+                displayAnimator.mWindowAnimationBackgroundSurface.destroySurface();
                 displayAnimator.mWindowAnimationBackgroundSurface = null;
             }
             if (displayAnimator.mScreenRotationAnimation != null) {
@@ -123,7 +128,7 @@
                 displayAnimator.mScreenRotationAnimation = null;
             }
             if (displayAnimator.mDimAnimator != null) {
-                displayAnimator.mDimAnimator.kill();
+                displayAnimator.mDimAnimator.destroySurface();
                 displayAnimator.mDimAnimator = null;
             }
         }
@@ -359,8 +364,6 @@
         WindowStateAnimator windowAnimationBackground = null;
         int windowAnimationBackgroundColor = 0;
         WindowState detachedWallpaper = null;
-        final DimSurface windowAnimationBackgroundSurface =
-                displayAnimator.mWindowAnimationBackgroundSurface;
 
         for (int i = windows.size() - 1; i >= 0; i--) {
             final WindowState win = windows.get(i);
@@ -440,15 +443,11 @@
                 }
             }
 
-            if (windowAnimationBackgroundSurface != null) {
-                windowAnimationBackgroundSurface.show(
-                        animLayer - WindowManagerService.LAYER_OFFSET_DIM,
-                        windowAnimationBackgroundColor);
-            }
+            displayAnimator.mWindowAnimationBackgroundSurface.show(
+                    animLayer - WindowManagerService.LAYER_OFFSET_DIM,
+                    ((windowAnimationBackgroundColor >> 24) & 0xff) / 255f, 0);
         } else {
-            if (windowAnimationBackgroundSurface != null) {
-                windowAnimationBackgroundSurface.hide();
-            }
+            displayAnimator.mWindowAnimationBackgroundSurface.hide();
         }
     }
 
@@ -499,8 +498,19 @@
         updateWallpaperLocked(displayId);
     }
 
-    // TODO(cmautner): Change the following comment when no longer locked on mWindowMap */
-    /** Locked on mService.mWindowMap and this. */
+    private long getDimBehindFadeDuration(long duration) {
+        TypedValue tv = new TypedValue();
+        mContext.getResources().getValue(
+            com.android.internal.R.fraction.config_dimBehindFadeDuration, tv, true);
+        if (tv.type == TypedValue.TYPE_FRACTION) {
+            duration = (long)tv.getFraction(duration, duration);
+        } else if (tv.type >= TypedValue.TYPE_FIRST_INT && tv.type <= TypedValue.TYPE_LAST_INT) {
+            duration = tv.data;
+        }
+        return duration;
+    }
+
+    /** Locked on mService.mWindowMap. */
     private void animateLocked() {
         if (!mInitialized) {
             return;
@@ -561,15 +571,38 @@
                     screenRotationAnimation.updateSurfacesInTransaction();
                 }
 
-                final DimAnimator.Parameters dimParams = displayAnimator.mDimParams;
-                final DimAnimator dimAnimator = displayAnimator.mDimAnimator;
-                if (dimAnimator != null && dimParams != null) {
-                    dimAnimator.updateParameters(mContext.getResources(), dimParams, mCurrentTime);
+                final DimLayer dimAnimator = displayAnimator.mDimAnimator;
+                final WindowStateAnimator winAnimator = displayAnimator.mDimWinAnimator;
+                final float dimAmount;
+                if (winAnimator == null) {
+                    dimAmount = 0;
+                } else {
+                    dimAmount = winAnimator.mWin.mAttrs.dimAmount;
                 }
-                if (dimAnimator != null && dimAnimator.mDimShown) {
-                    mAnimating |= dimAnimator.updateSurface(isDimmingLocked(displayId),
-                            mCurrentTime, !mService.okToDisplay());
+                final float targetAlpha = dimAnimator.getTargetAlpha();
+                if (targetAlpha != dimAmount) {
+                    if (winAnimator == null) {
+                        dimAnimator.hide(DEFAULT_DIM_DURATION);
+                    } else {
+                        long duration = (winAnimator.mAnimating && winAnimator.mAnimation != null)
+                                ? winAnimator.mAnimation.computeDurationHint()
+                                : DEFAULT_DIM_DURATION;
+                        if (targetAlpha > dimAmount) {
+                            duration = getDimBehindFadeDuration(duration);
+                        }
+                        dimAnimator.show(winAnimator.mAnimLayer -
+                                WindowManagerService.LAYER_OFFSET_DIM, dimAmount, duration);
+                    }
                 }
+                if (dimAnimator.isAnimating()) {
+                    if (!mService.okToDisplay()) {
+                        // Jump to the end of the animation.
+                        dimAnimator.show();
+                    } else {
+                        mAnimating |= dimAnimator.stepAnimation();
+                    }
+                }
+
                 //TODO (multidisplay): Magnification is supported only for the default display.
                 if (mService.mDisplayMagnifier != null && displayId == Display.DEFAULT_DISPLAY) {
                     mService.mDisplayMagnifier.drawMagnifiedRegionBorderIfNeededLocked();
@@ -628,13 +661,18 @@
     }
 
     boolean isDimmingLocked(int displayId) {
-        return getDisplayContentsAnimatorLocked(displayId).mDimParams != null;
+        return getDisplayContentsAnimatorLocked(displayId).mDimAnimator.isDimming();
     }
 
     boolean isDimmingLocked(final WindowStateAnimator winAnimator) {
-        DimAnimator.Parameters dimParams =
-                getDisplayContentsAnimatorLocked(winAnimator.mWin.getDisplayId()).mDimParams;
-        return dimParams != null && dimParams.mDimWinAnimator == winAnimator;
+        final int displayId = winAnimator.mWin.getDisplayId();
+        DisplayContentsAnimator displayAnimator =
+                getDisplayContentsAnimatorLocked(displayId);
+        if (displayAnimator != null) {
+            return displayAnimator.mDimWinAnimator == winAnimator
+                    && displayAnimator.mDimAnimator.isDimming();
+        }
+        return false;
     }
 
     static String bulkUpdateParamsToString(int bulkUpdateParams) {
@@ -675,24 +713,16 @@
                         pw.print(": "); pw.println(wanim);
             }
             if (displayAnimator.mWindowAnimationBackgroundSurface != null) {
-                if (dumpAll || displayAnimator.mWindowAnimationBackgroundSurface.mDimShown) {
+                if (dumpAll || displayAnimator.mWindowAnimationBackgroundSurface.isDimming()) {
                     pw.print(subPrefix); pw.println("mWindowAnimationBackgroundSurface:");
                     displayAnimator.mWindowAnimationBackgroundSurface.printTo(subSubPrefix, pw);
                 }
             }
-            if (displayAnimator.mDimAnimator != null) {
-                if (dumpAll || displayAnimator.mDimAnimator.mDimShown) {
-                    pw.print(subPrefix); pw.println("mDimAnimator:");
-                    displayAnimator.mDimAnimator.printTo(subSubPrefix, pw);
-                }
-            } else if (dumpAll) {
-                pw.print(subPrefix); pw.println("no DimAnimator ");
-            }
-            if (displayAnimator.mDimParams != null) {
-                pw.print(subPrefix); pw.println("mDimParams:");
-                displayAnimator.mDimParams.printTo(subSubPrefix, pw);
-            } else if (dumpAll) {
-                pw.print(subPrefix); pw.println("no DimParams ");
+            if (dumpAll || displayAnimator.mDimAnimator.isDimming()) {
+                pw.print(subPrefix); pw.println("mDimAnimator:");
+                displayAnimator.mDimAnimator.printTo(subSubPrefix, pw);
+                pw.print(subPrefix); pw.print("mDimWinAnimator=");
+                        pw.println(displayAnimator.mDimWinAnimator);
             }
             if (displayAnimator.mScreenRotationAnimation != null) {
                 pw.print(subPrefix); pw.println("mScreenRotationAnimation:");
@@ -751,23 +781,18 @@
         }
     }
 
-    void setDimParamsLocked(int displayId, DimAnimator.Parameters dimParams) {
+    void setDimWinAnimatorLocked(int displayId, WindowStateAnimator newWinAnimator) {
         DisplayContentsAnimator displayAnimator = mDisplayContentsAnimators.get(displayId);
-        if (dimParams == null) {
-            displayAnimator.mDimParams = null;
+        if (newWinAnimator == null) {
+            displayAnimator.mDimWinAnimator = null;
         } else {
-            final WindowStateAnimator newWinAnimator = dimParams.mDimWinAnimator;
-
             // Only set dim params on the highest dimmed layer.
-            final WindowStateAnimator existingDimWinAnimator =
-                    displayAnimator.mDimParams == null ?
-                            null : displayAnimator.mDimParams.mDimWinAnimator;
-            // Don't turn on for an unshown surface, or for any layer but the highest
-            // dimmed layer.
+            final WindowStateAnimator existingDimWinAnimator = displayAnimator.mDimWinAnimator;
+            // Don't turn on for an unshown surface, or for any layer but the highest dimmed layer.
             if (newWinAnimator.mSurfaceShown && (existingDimWinAnimator == null
                     || !existingDimWinAnimator.mSurfaceShown
                     || existingDimWinAnimator.mAnimLayer < newWinAnimator.mAnimLayer)) {
-                displayAnimator.mDimParams = new DimAnimator.Parameters(dimParams);
+                displayAnimator.mDimWinAnimator = newWinAnimator;
             }
         }
     }
@@ -790,15 +815,14 @@
     }
 
     private class DisplayContentsAnimator {
-        DimAnimator mDimAnimator = null;
-        DimAnimator.Parameters mDimParams = null;
-        DimSurface mWindowAnimationBackgroundSurface = null;
+        DimLayer mDimAnimator = null;
+        WindowStateAnimator mDimWinAnimator = null;
+        DimLayer mWindowAnimationBackgroundSurface = null;
         ScreenRotationAnimation mScreenRotationAnimation = null;
 
         public DisplayContentsAnimator(int displayId) {
-            mDimAnimator = new DimAnimator(mService.mFxSession, displayId);
-            mWindowAnimationBackgroundSurface = new DimSurface(mService.mFxSession,
-                    mService.getDisplayContentLocked(displayId));
+            mDimAnimator = new DimLayer(mService, displayId);
+            mWindowAnimationBackgroundSurface = new DimLayer(mService, displayId);
         }
     }
 }
diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java
index c67a465..a488b84 100644
--- a/services/java/com/android/server/wm/WindowManagerService.java
+++ b/services/java/com/android/server/wm/WindowManagerService.java
@@ -250,11 +250,6 @@
      */
     static final int MAX_ANIMATION_DURATION = 10*1000;
 
-    /** Amount of time (in milliseconds) to animate the dim surface from one
-     * value to another, when no window animation is driving it.
-     */
-    static final int DEFAULT_DIM_DURATION = 200;
-
     /** Amount of time (in milliseconds) to animate the fade-in-out transition for
      * compatible windows.
      */
@@ -324,6 +319,7 @@
     /**
      * Mapping from an IWindow IBinder to the server's Window object.
      * This is also used as the lock for all of our state.
+     * NOTE: Never call into methods that lock ActivityManagerService while holding this object.
      */
     final HashMap<IBinder, WindowState> mWindowMap = new HashMap<IBinder, WindowState>();
 
@@ -1113,7 +1109,6 @@
         }
     }
 
-    /** TODO(cmautner): Is this the same as {@link WindowState#canReceiveKeys()} */
     static boolean canBeImeTarget(WindowState w) {
         final int fl = w.mAttrs.flags
                 & (FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM);
@@ -1969,12 +1964,7 @@
                     winAnimator.computeShownFrameLocked();
                     // No need to lay out the windows - we can just set the wallpaper position
                     // directly.
-                    // TODO(cmautner): Don't move this from here, just lock the WindowAnimator.
-                    if (winAnimator.mSurfaceX != wallpaper.mShownFrame.left
-                            || winAnimator.mSurfaceY != wallpaper.mShownFrame.top) {
-                        winAnimator.setWallpaperOffset((int) wallpaper.mShownFrame.left,
-                                (int) wallpaper.mShownFrame.top);
-                    }
+                    winAnimator.setWallpaperOffset(wallpaper.mShownFrame);
                     // We only want to be synchronous with one wallpaper.
                     sync = false;
                 }
@@ -2478,19 +2468,13 @@
         }
     }
 
-    // TODO(cmautner): Move to WindowStateAnimator.
-    void setTransparentRegionHint(final WindowStateAnimator winAnimator, final Region region) {
-        mH.sendMessage(mH.obtainMessage(H.SET_TRANSPARENT_REGION,
-                new Pair<WindowStateAnimator, Region>(winAnimator, region)));
-    }
-
     void setTransparentRegionWindow(Session session, IWindow client, Region region) {
         long origId = Binder.clearCallingIdentity();
         try {
             synchronized (mWindowMap) {
                 WindowState w = windowForClientLocked(session, client, false);
                 if ((w != null) && w.mHasSurface) {
-                    setTransparentRegionHint(w.mWinAnimator, region);
+                    w.mWinAnimator.setTransparentRegionHintLocked(region);
                 }
             }
         } finally {
@@ -2652,7 +2636,6 @@
         long origId = Binder.clearCallingIdentity();
 
         synchronized(mWindowMap) {
-            // TODO(cmautner): synchronize on mAnimator or win.mWinAnimator.
             WindowState win = windowForClientLocked(session, client, false);
             if (win == null) {
                 return 0;
@@ -2871,18 +2854,15 @@
 
             // updateFocusedWindowLocked() already assigned layers so we only need to
             // reassign them at this point if the IM window state gets shuffled
-            boolean assignLayers = false;
-
-            if (imMayMove) {
-                if (moveInputMethodWindowsIfNeededLocked(false) || toBeDisplayed) {
-                    // Little hack here -- we -should- be able to rely on the
-                    // function to return true if the IME has moved and needs
-                    // its layer recomputed.  However, if the IME was hidden
-                    // and isn't actually moved in the list, its layer may be
-                    // out of data so we make sure to recompute it.
-                    assignLayers = true;
-                }
+            if (imMayMove && (moveInputMethodWindowsIfNeededLocked(false) || toBeDisplayed)) {
+                // Little hack here -- we -should- be able to rely on the
+                // function to return true if the IME has moved and needs
+                // its layer recomputed.  However, if the IME was hidden
+                // and isn't actually moved in the list, its layer may be
+                // out of data so we make sure to recompute it.
+                assignLayersLocked(win.getWindowList());
             }
+
             if (wallpaperMayMove) {
                 getDefaultDisplayContentLocked().pendingLayoutChanges |=
                         WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
@@ -2973,18 +2953,21 @@
 
     public void finishDrawingWindow(Session session, IWindow client) {
         final long origId = Binder.clearCallingIdentity();
-        synchronized (mWindowMap) {
-            WindowState win = windowForClientLocked(session, client, false);
-            if (win != null && win.mWinAnimator.finishDrawingLocked()) {
-                if ((win.mAttrs.flags & FLAG_SHOW_WALLPAPER) != 0) {
-                    getDefaultDisplayContentLocked().pendingLayoutChanges |=
-                            WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
+        try {
+            synchronized (mWindowMap) {
+                WindowState win = windowForClientLocked(session, client, false);
+                if (win != null && win.mWinAnimator.finishDrawingLocked()) {
+                    if ((win.mAttrs.flags & FLAG_SHOW_WALLPAPER) != 0) {
+                        getDefaultDisplayContentLocked().pendingLayoutChanges |=
+                                WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
+                    }
+                    win.mDisplayContent.layoutNeeded = true;
+                    requestTraversalLocked();
                 }
-                win.mDisplayContent.layoutNeeded = true;
-                performLayoutAndPlaceSurfacesLocked();
             }
+        } finally {
+            Binder.restoreCallingIdentity(origId);
         }
-        Binder.restoreCallingIdentity(origId);
     }
 
     @Override
@@ -3622,14 +3605,14 @@
                 if (!mAppTransition.isTransitionSet() || mAppTransition.isTransitionNone()) {
                     mAppTransition.setAppTransition(transit);
                 } else if (!alwaysKeepCurrent) {
-                    if (transit == WindowManagerPolicy.TRANSIT_TASK_OPEN
+                    if (transit == AppTransition.TRANSIT_TASK_OPEN
                             && mAppTransition.isTransitionEqual(
-                                    WindowManagerPolicy.TRANSIT_TASK_CLOSE)) {
+                                    AppTransition.TRANSIT_TASK_CLOSE)) {
                         // Opening a new task always supersedes a close for the anim.
                         mAppTransition.setAppTransition(transit);
-                    } else if (transit == WindowManagerPolicy.TRANSIT_ACTIVITY_OPEN
+                    } else if (transit == AppTransition.TRANSIT_ACTIVITY_OPEN
                             && mAppTransition.isTransitionEqual(
-                                WindowManagerPolicy.TRANSIT_ACTIVITY_CLOSE)) {
+                                AppTransition.TRANSIT_ACTIVITY_CLOSE)) {
                         // Opening a new activity always supersedes a close for the anim.
                         mAppTransition.setAppTransition(transit);
                     }
@@ -3948,7 +3931,7 @@
 
             boolean runningAppAnimation = false;
 
-            if (transit != WindowManagerPolicy.TRANSIT_UNSET) {
+            if (transit != AppTransition.TRANSIT_UNSET) {
                 if (wtoken.mAppAnimator.animation == AppWindowAnimator.sDummyAnimation) {
                     wtoken.mAppAnimator.animation = null;
                 }
@@ -3959,7 +3942,7 @@
                 //TODO (multidisplay): Magnification is supported only for the default display.
                 if (window != null && mDisplayMagnifier != null
                         && window.getDisplayId() == Display.DEFAULT_DISPLAY) {
-                    mDisplayMagnifier.onWindowTransitionLocked(window, transit);
+                    mDisplayMagnifier.onAppWindowTransitionLocked(window, transit);
                 }
                 changed = true;
             }
@@ -4127,7 +4110,7 @@
             }
 
             final long origId = Binder.clearCallingIdentity();
-            setTokenVisibilityLocked(wtoken, null, visible, WindowManagerPolicy.TRANSIT_UNSET,
+            setTokenVisibilityLocked(wtoken, null, visible, AppTransition.TRANSIT_UNSET,
                     true);
             wtoken.updateReportedVisibilityLocked();
             Binder.restoreCallingIdentity(origId);
@@ -4259,7 +4242,7 @@
             if (basewtoken != null && (wtoken=basewtoken.appWindowToken) != null) {
                 if (DEBUG_APP_TRANSITIONS) Slog.v(TAG, "Removing app token: " + wtoken);
                 delayed = setTokenVisibilityLocked(wtoken, null, false,
-                        WindowManagerPolicy.TRANSIT_UNSET, true);
+                        AppTransition.TRANSIT_UNSET, true);
                 wtoken.inPendingTransaction = false;
                 mOpeningApps.remove(wtoken);
                 wtoken.waitingToShow = false;
@@ -4812,6 +4795,7 @@
         mH.sendEmptyMessage(H.PERSIST_ANIMATION_SCALE);
     }
 
+    @Override
     public void setAnimationScales(float[] scales) {
         if (!checkCallingPermission(android.Manifest.permission.SET_ANIMATION_SCALE,
                 "setAnimationScale()")) {
@@ -4839,6 +4823,7 @@
         ValueAnimator.setDurationScale(scale);
     }
 
+    @Override
     public float getAnimationScale(int which) {
         switch (which) {
             case 0: return mWindowAnimationScale;
@@ -4848,6 +4833,7 @@
         return 0;
     }
 
+    @Override
     public float[] getAnimationScales() {
         return new float[] { mWindowAnimationScale, mTransitionAnimationScale,
                 mAnimatorDurationScale };
@@ -6621,12 +6607,6 @@
 
         public static final int CLIENT_FREEZE_TIMEOUT = 30;
 
-        public static final int ANIMATOR_WHAT_OFFSET = 100000;
-        public static final int SET_TRANSPARENT_REGION = ANIMATOR_WHAT_OFFSET + 1;
-
-        public H() {
-        }
-
         @Override
         public void handleMessage(Message msg) {
             if (DEBUG_WINDOW_TRACE) {
@@ -6878,10 +6858,8 @@
                 case APP_TRANSITION_TIMEOUT: {
                     synchronized (mWindowMap) {
                         if (mAppTransition.isTransitionSet()) {
-                            if (DEBUG_APP_TRANSITIONS) Slog.v(TAG,
-                                    "*** APP TRANSITION TIMEOUT");
-                            mAppTransition.setReady();
-                            mAppTransition.setTimeout(true);
+                            if (DEBUG_APP_TRANSITIONS) Slog.v(TAG, "*** APP TRANSITION TIMEOUT");
+                            mAppTransition.setTimeout();
                             mAnimatingAppTokens.clear();
                             mAnimatingAppTokens.addAll(mAppTokens);
                             performLayoutAndPlaceSurfacesLocked();
@@ -7030,15 +7008,6 @@
                     break;
                 }
 
-                // Animation messages. Move to Window{State}Animator
-                case SET_TRANSPARENT_REGION: {
-                    Pair<WindowStateAnimator, Region> pair =
-                                (Pair<WindowStateAnimator, Region>) msg.obj;
-                    final WindowStateAnimator winAnimator = pair.first;
-                    winAnimator.setTransparentRegionHint(pair.second);
-                    break;
-                }
-
                 case DO_ANIMATION_CALLBACK: {
                     try {
                         ((IRemoteCallback)msg.obj).sendResult(null);
@@ -7146,13 +7115,13 @@
     }
 
     public void getInitialDisplaySize(int displayId, Point size) {
-        // TODO(cmautner): Access to DisplayContent should be locked on mWindowMap. Doing that
-        //  could lead to deadlock since this is called from ActivityManager.
-        final DisplayContent displayContent = getDisplayContentLocked(displayId);
-        if (displayContent != null) {
-            synchronized(displayContent.mDisplaySizeLock) {
-                size.x = displayContent.mInitialDisplayWidth;
-                size.y = displayContent.mInitialDisplayHeight;
+        synchronized (mWindowMap) {
+            final DisplayContent displayContent = getDisplayContentLocked(displayId);
+            if (displayContent != null) {
+                synchronized(displayContent.mDisplaySizeLock) {
+                    size.x = displayContent.mInitialDisplayWidth;
+                    size.y = displayContent.mInitialDisplayHeight;
+                }
             }
         }
     }
@@ -7813,7 +7782,7 @@
             if (DEBUG_APP_TRANSITIONS) Slog.v(TAG, "**** GOOD TO GO");
             int transit = mAppTransition.getAppTransition();
             if (mSkipAppTransitionAnimation) {
-                transit = WindowManagerPolicy.TRANSIT_UNSET;
+                transit = AppTransition.TRANSIT_UNSET;
             }
             mAppTransition.goodToGo();
             mStartingIconInTransition = false;
@@ -7901,28 +7870,28 @@
             if (closingAppHasWallpaper && openingAppHasWallpaper) {
                 if (DEBUG_APP_TRANSITIONS) Slog.v(TAG, "Wallpaper animation!");
                 switch (transit) {
-                    case WindowManagerPolicy.TRANSIT_ACTIVITY_OPEN:
-                    case WindowManagerPolicy.TRANSIT_TASK_OPEN:
-                    case WindowManagerPolicy.TRANSIT_TASK_TO_FRONT:
-                        transit = WindowManagerPolicy.TRANSIT_WALLPAPER_INTRA_OPEN;
+                    case AppTransition.TRANSIT_ACTIVITY_OPEN:
+                    case AppTransition.TRANSIT_TASK_OPEN:
+                    case AppTransition.TRANSIT_TASK_TO_FRONT:
+                        transit = AppTransition.TRANSIT_WALLPAPER_INTRA_OPEN;
                         break;
-                    case WindowManagerPolicy.TRANSIT_ACTIVITY_CLOSE:
-                    case WindowManagerPolicy.TRANSIT_TASK_CLOSE:
-                    case WindowManagerPolicy.TRANSIT_TASK_TO_BACK:
-                        transit = WindowManagerPolicy.TRANSIT_WALLPAPER_INTRA_CLOSE;
+                    case AppTransition.TRANSIT_ACTIVITY_CLOSE:
+                    case AppTransition.TRANSIT_TASK_CLOSE:
+                    case AppTransition.TRANSIT_TASK_TO_BACK:
+                        transit = AppTransition.TRANSIT_WALLPAPER_INTRA_CLOSE;
                         break;
                 }
                 if (DEBUG_APP_TRANSITIONS) Slog.v(TAG, "New transit: " + transit);
             } else if ((oldWallpaper != null) && !mOpeningApps.contains(oldWallpaper.mAppToken)) {
                 // We are transitioning from an activity with
                 // a wallpaper to one without.
-                transit = WindowManagerPolicy.TRANSIT_WALLPAPER_CLOSE;
+                transit = AppTransition.TRANSIT_WALLPAPER_CLOSE;
                 if (DEBUG_APP_TRANSITIONS) Slog.v(TAG,
                         "New transit away from wallpaper: " + transit);
             } else if (mWallpaperTarget != null && mWallpaperTarget.isVisibleLw()) {
                 // We are transitioning from an activity without
                 // a wallpaper to now showing the wallpaper
-                transit = WindowManagerPolicy.TRANSIT_WALLPAPER_OPEN;
+                transit = AppTransition.TRANSIT_WALLPAPER_OPEN;
                 if (DEBUG_APP_TRANSITIONS) Slog.v(TAG,
                         "New transit into wallpaper: " + transit);
             }
@@ -8065,7 +8034,7 @@
     private int handleAnimatingStoppedAndTransitionLocked() {
         int changes = 0;
 
-        mAppTransition.setRunning(false);
+        mAppTransition.setIdle();
         // Restore window app tokens to the ActivityManager views
         for (int i = mAnimatingAppTokens.size() - 1; i >= 0; i--) {
             mAnimatingAppTokens.get(i).sendingToBottom = false;
@@ -8219,18 +8188,8 @@
             mInnerFields.mDimming = true;
             final WindowStateAnimator winAnimator = w.mWinAnimator;
             if (!mAnimator.isDimmingLocked(winAnimator)) {
-                final int width, height;
-                if (attrs.type == TYPE_BOOT_PROGRESS) {
-                    final DisplayInfo displayInfo = w.mDisplayContent.getDisplayInfo();
-                    width = displayInfo.logicalWidth;
-                    height = displayInfo.logicalHeight;
-                } else {
-                    width = innerDw;
-                    height = innerDh;
-                }
                 if (localLOGV) Slog.v(TAG, "Win " + w + " start dimming.");
-                startDimmingLocked(
-                        winAnimator, w.mExiting ? 0 : w.mAttrs.dimAmount, width, height);
+                startDimmingLocked(winAnimator, w.mExiting ? 0 : w.mAttrs.dimAmount);
             }
         }
     }
@@ -8926,14 +8885,12 @@
         }
     }
 
-    void startDimmingLocked(final WindowStateAnimator winAnimator, final float target,
-                      final int width, final int height) {
-        mAnimator.setDimParamsLocked(winAnimator.mWin.getDisplayId(),
-                new DimAnimator.Parameters(winAnimator, width, height, target));
+    void startDimmingLocked(final WindowStateAnimator winAnimator, final float target) {
+        mAnimator.setDimWinAnimatorLocked(winAnimator.mWin.getDisplayId(), winAnimator);
     }
 
     void stopDimmingLocked(int displayId) {
-        mAnimator.setDimParamsLocked(displayId, null);
+        mAnimator.setDimWinAnimatorLocked(displayId, null);
     }
 
     private boolean needsLayout() {
@@ -8950,8 +8907,6 @@
         boolean doRequest = false;
 
         final int bulkUpdateParams = mAnimator.mBulkUpdateParams;
-        // TODO(cmautner): As the number of bits grows, use masks of bit groups to
-        //  eliminate unnecessary tests.
         if ((bulkUpdateParams & LayoutFields.SET_UPDATE_ROTATION) != 0) {
             mInnerFields.mUpdateRotation = true;
             doRequest = true;
@@ -9250,9 +9205,7 @@
         mPolicy.setLastInputMethodWindowLw(null, null);
 
         if (mAppTransition.isTransitionSet()) {
-            mAppTransition.setAppTransition(WindowManagerPolicy.TRANSIT_UNSET);
-            mAppTransition.clear();
-            mAppTransition.setReady();
+            mAppTransition.freeze();
         }
 
         if (PROFILE_ORIENTATION) {
diff --git a/services/java/com/android/server/wm/WindowState.java b/services/java/com/android/server/wm/WindowState.java
index 5fd42c2..cb11be3 100644
--- a/services/java/com/android/server/wm/WindowState.java
+++ b/services/java/com/android/server/wm/WindowState.java
@@ -945,11 +945,11 @@
         }
     }
 
-    /** Returns true if this window desires key events.
-     * TODO(cmautner): Is this the same as {@link WindowManagerService#canBeImeTarget}
+    /**
+     * @return true if this window desires key events.
      */
     public final boolean canReceiveKeys() {
-        return     isVisibleOrAdding()
+        return isVisibleOrAdding()
                 && (mViewVisibility == View.VISIBLE)
                 && ((mAttrs.flags & WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE) == 0);
     }
diff --git a/services/java/com/android/server/wm/WindowStateAnimator.java b/services/java/com/android/server/wm/WindowStateAnimator.java
index 5b7cb99..a4c6a9e 100644
--- a/services/java/com/android/server/wm/WindowStateAnimator.java
+++ b/services/java/com/android/server/wm/WindowStateAnimator.java
@@ -12,6 +12,7 @@
 import android.graphics.Point;
 import android.graphics.PointF;
 import android.graphics.Rect;
+import android.graphics.RectF;
 import android.graphics.Region;
 import android.os.Debug;
 import android.util.Slog;
@@ -1183,9 +1184,7 @@
                 mAnimator.setPendingLayoutChanges(displayId,
                         WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER);
                 if ((w.mAttrs.flags & LayoutParams.FLAG_DIM_BEHIND) != 0) {
-                    final DisplayInfo displayInfo = mWin.mDisplayContent.getDisplayInfo();
-                    mService.startDimmingLocked(this, w.mExiting ? 0 : w.mAttrs.dimAmount,
-                            displayInfo.appWidth, displayInfo.appHeight);
+                    mService.startDimmingLocked(this, w.mExiting ? 0 : w.mAttrs.dimAmount);
                 }
             } catch (RuntimeException e) {
                 // If something goes wrong with the surface (such
@@ -1318,7 +1317,7 @@
         }
     }
 
-    void setTransparentRegionHint(final Region region) {
+    void setTransparentRegionHintLocked(final Region region) {
         if (mSurface == null) {
             Slog.w(TAG, "setTransparentRegionHint: null mSurface after mHasSurface true");
             return;
@@ -1337,31 +1336,35 @@
         }
     }
 
-    void setWallpaperOffset(int left, int top) {
-        mSurfaceX = left;
-        mSurfaceY = top;
-        if (mAnimating) {
-            // If this window (or its app token) is animating, then the position
-            // of the surface will be re-computed on the next animation frame.
-            // We can't poke it directly here because it depends on whatever
-            // transformation is being applied by the animation.
-            return;
-        }
-        if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG,
-                ">>> OPEN TRANSACTION setWallpaperOffset");
-        Surface.openTransaction();
-        try {
-            if (WindowManagerService.SHOW_TRANSACTIONS) WindowManagerService.logSurface(mWin,
-                    "POS " + left + ", " + top, null);
-            mSurface.setPosition(mWin.mFrame.left + left, mWin.mFrame.top + top);
-            updateSurfaceWindowCrop(false);
-        } catch (RuntimeException e) {
-            Slog.w(TAG, "Error positioning surface of " + mWin
-                    + " pos=(" + left + "," + top + ")", e);
-        } finally {
-            Surface.closeTransaction();
+    void setWallpaperOffset(RectF shownFrame) {
+        final int left = (int) shownFrame.left;
+        final int top = (int) shownFrame.top;
+        if (mSurfaceX != left || mSurfaceY != top) {
+            mSurfaceX = left;
+            mSurfaceY = top;
+            if (mAnimating) {
+                // If this window (or its app token) is animating, then the position
+                // of the surface will be re-computed on the next animation frame.
+                // We can't poke it directly here because it depends on whatever
+                // transformation is being applied by the animation.
+                return;
+            }
             if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG,
-                    "<<< CLOSE TRANSACTION setWallpaperOffset");
+                    ">>> OPEN TRANSACTION setWallpaperOffset");
+            Surface.openTransaction();
+            try {
+                if (WindowManagerService.SHOW_TRANSACTIONS) WindowManagerService.logSurface(mWin,
+                        "POS " + left + ", " + top, null);
+                mSurface.setPosition(mWin.mFrame.left + left, mWin.mFrame.top + top);
+                updateSurfaceWindowCrop(false);
+            } catch (RuntimeException e) {
+                Slog.w(TAG, "Error positioning surface of " + mWin
+                        + " pos=(" + left + "," + top + ")", e);
+            } finally {
+                Surface.closeTransaction();
+                if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG,
+                        "<<< CLOSE TRANSACTION setWallpaperOffset");
+            }
         }
     }
 
@@ -1511,10 +1514,9 @@
         }
     }
 
-    // TODO(cmautner): Move back to WindowState?
     /**
      * Choose the correct animation and set it to the passed WindowState.
-     * @param transit If WindowManagerPolicy.TRANSIT_PREVIEW_DONE and the app window has been drawn
+     * @param transit If AppTransition.TRANSIT_PREVIEW_DONE and the app window has been drawn
      *      then the animation will be app_starting_exit. Any other value loads the animation from
      *      the switch statement below.
      * @param isEntrance The animation type the last time this was called. Used to keep from
diff --git a/test-runner/src/android/test/mock/MockPackageManager.java b/test-runner/src/android/test/mock/MockPackageManager.java
index 2eba4e1..5ee52de 100644
--- a/test-runner/src/android/test/mock/MockPackageManager.java
+++ b/test-runner/src/android/test/mock/MockPackageManager.java
@@ -81,6 +81,13 @@
         throw new UnsupportedOperationException();
     }
 
+    /** @hide */
+    @Override
+    public int getPackageUid(String packageName, int userHandle)
+            throws NameNotFoundException {
+        throw new UnsupportedOperationException();
+    }
+
     @Override
     public PermissionInfo getPermissionInfo(String name, int flags)
     throws NameNotFoundException {
diff --git a/tests/HwAccelerationTest/AndroidManifest.xml b/tests/HwAccelerationTest/AndroidManifest.xml
index 1974e0f..7d2ba19 100644
--- a/tests/HwAccelerationTest/AndroidManifest.xml
+++ b/tests/HwAccelerationTest/AndroidManifest.xml
@@ -33,6 +33,24 @@
         <meta-data android:name="android.graphics.renderThread" android:value="true" />
 
         <activity
+                android:name="ScaledTextActivity"
+                android:label="_ScaledText">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+
+        <activity
+                android:name="ScaledPathsActivity"
+                android:label="_ScaledPaths">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+
+        <activity
                 android:name="Alpha8BitmapActivity"
                 android:label="_Alpha8Bitmap">
             <intent-filter>
diff --git a/tests/HwAccelerationTest/res/drawable/patch.9.png b/tests/HwAccelerationTest/res/drawable/patch.9.png
deleted file mode 100644
index e3b3639..0000000
--- a/tests/HwAccelerationTest/res/drawable/patch.9.png
+++ /dev/null
Binary files differ
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/ScaledPathsActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/ScaledPathsActivity.java
new file mode 100644
index 0000000..deb4b6b
--- /dev/null
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/ScaledPathsActivity.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.test.hwui;
+
+import android.app.Activity;
+import android.content.Context;
+import android.graphics.Canvas;
+import android.graphics.Paint;
+import android.graphics.Path;
+import android.graphics.RectF;
+import android.os.Bundle;
+import android.view.View;
+
+@SuppressWarnings({"UnusedDeclaration"})
+public class ScaledPathsActivity extends Activity {
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        final PathsView view = new PathsView(this);
+        setContentView(view);
+    }
+
+    public static class PathsView extends View {
+        private final Paint mPathPaint;
+        private final Path mPath;
+        private final RectF mPathBounds = new RectF();
+
+        public PathsView(Context c) {
+            super(c);
+
+            mPathPaint = new Paint();
+            mPathPaint.setAntiAlias(true);
+            mPathPaint.setColor(0xff0000ff);
+            mPathPaint.setStrokeWidth(5.0f);
+            mPathPaint.setStyle(Paint.Style.FILL);
+
+            mPath = new Path();
+            mPath.moveTo(0.0f, 0.0f);
+            mPath.cubicTo(0.0f, 0.0f, 100.0f, 150.0f, 100.0f, 200.0f);
+            mPath.cubicTo(100.0f, 200.0f, 50.0f, 300.0f, -80.0f, 200.0f);
+            mPath.cubicTo(-80.0f, 200.0f, 100.0f, 200.0f, 200.0f, 0.0f);
+
+            mPath.computeBounds(mPathBounds, true);
+        }
+
+        @Override
+        protected void onDraw(Canvas canvas) {
+            super.onDraw(canvas);
+            canvas.drawARGB(255, 255, 255, 255);
+
+            mPathPaint.setColor(0xff0000ff);
+            mPathPaint.setStyle(Paint.Style.FILL);
+
+            canvas.save();
+            drawPath(canvas, 1.0f, 1.0f);
+            drawPath(canvas, 2.0f, 2.0f);
+            drawPath(canvas, 4.0f, 4.0f);
+            canvas.restore();
+
+            mPathPaint.setColor(0xffff0000);
+            mPathPaint.setStyle(Paint.Style.STROKE);
+
+            canvas.save();
+            drawPath(canvas, 1.0f, 1.0f);
+            drawPath(canvas, 2.0f, 2.0f);
+            drawPath(canvas, 4.0f, 4.0f);
+            canvas.restore();
+        }
+
+        private void drawPath(Canvas canvas, float scaleX, float scaleY) {
+            canvas.save();
+            canvas.scale(scaleX, scaleY);
+            canvas.drawPath(mPath, mPathPaint);
+            canvas.restore();
+            canvas.translate(mPathBounds.width() * scaleX, 0.0f);
+        }
+    }
+}
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/ScaledTextActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/ScaledTextActivity.java
new file mode 100644
index 0000000..e1bf3ea
--- /dev/null
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/ScaledTextActivity.java
@@ -0,0 +1,122 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.test.hwui;
+
+import android.animation.ObjectAnimator;
+import android.app.Activity;
+import android.content.Context;
+import android.graphics.Canvas;
+import android.graphics.Paint;
+import android.graphics.Path;
+import android.os.Bundle;
+import android.view.View;
+
+@SuppressWarnings({"UnusedDeclaration"})
+public class ScaledTextActivity extends Activity {
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        final ScaledTextView view = new ScaledTextView(this);
+        setContentView(view);
+
+        ObjectAnimator animation = ObjectAnimator.ofFloat(view, "textScale", 1.0f, 10.0f);
+        animation.setDuration(3000);
+        animation.setRepeatCount(ObjectAnimator.INFINITE);
+        animation.setRepeatMode(ObjectAnimator.REVERSE);
+        animation.start();
+
+    }
+
+    public static class ScaledTextView extends View {
+        private static final String TEXT = "Hello libhwui! ";
+
+        private final Paint mPaint;
+        private final Paint mShadowPaint;
+        private final Path mPath;
+
+        private float mScale = 1.0f;
+
+        public ScaledTextView(Context c) {
+            super(c);
+
+            mPath = makePath();
+
+            mPaint = new Paint();
+            mPaint.setAntiAlias(true);
+            mPaint.setTextSize(20.0f);
+
+            mShadowPaint = new Paint();
+            mShadowPaint.setAntiAlias(true);
+            mShadowPaint.setShadowLayer(3.0f, 0.0f, 3.0f, 0xff000000);
+            mShadowPaint.setTextSize(20.0f);
+        }
+
+        public float getTextScale() {
+            return mScale;
+        }
+
+        public void setTextScale(float scale) {
+            mScale = scale;
+            invalidate();
+        }
+
+        private static Path makePath() {
+            Path path = new Path();
+            buildPath(path);
+            return path;
+        }
+
+        private static void buildPath(Path path) {
+            path.moveTo(0.0f, 0.0f);
+            path.cubicTo(0.0f, 0.0f, 100.0f, 150.0f, 100.0f, 200.0f);
+            path.cubicTo(100.0f, 200.0f, 50.0f, 300.0f, -80.0f, 200.0f);
+            path.cubicTo(-80.0f, 200.0f, 100.0f, 200.0f, 200.0f, 0.0f);
+        }
+
+        @Override
+        protected void onDraw(Canvas canvas) {
+            super.onDraw(canvas);
+            canvas.drawARGB(255, 255, 255, 255);
+
+            canvas.drawText(TEXT, 30.0f, 30.0f, mPaint);
+
+            canvas.translate(0.0f, 50.0f);
+
+            canvas.save();
+            canvas.scale(mScale, mScale);
+            canvas.drawText(TEXT, 30.0f, 30.0f, mPaint);
+            canvas.restore();
+
+            canvas.translate(0.0f, 250.0f);
+            canvas.save();
+            canvas.scale(3.0f, 3.0f);
+            canvas.drawText(TEXT, 30.0f, 30.0f, mShadowPaint);
+            canvas.translate(100.0f, 0.0f);
+//            canvas.drawTextOnPath(TEXT + TEXT + TEXT, mPath, 0.0f, 0.0f, mPaint);
+            canvas.restore();
+
+            float width = mPaint.measureText(TEXT);
+
+            canvas.translate(500.0f, 0.0f);
+            canvas.rotate(45.0f, width * 3.0f / 2.0f, 0.0f);
+            canvas.scale(3.0f, 3.0f);
+            canvas.drawText(TEXT, 30.0f, 30.0f, mPaint);
+        }
+    }
+}
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/TextOnPathActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/TextOnPathActivity.java
index 9849e3c..ceccfaa 100644
--- a/tests/HwAccelerationTest/src/com/android/test/hwui/TextOnPathActivity.java
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/TextOnPathActivity.java
@@ -41,26 +41,26 @@
         setContentView(view);
     }
 
-    private Path makePath() {
+    private static Path makePath() {
         Path path = new Path();
         buildPath(path);
         return path;
     }
 
-    private void buildPath(Path path) {
+    private static void buildPath(Path path) {
         path.moveTo(0.0f, 0.0f);
         path.cubicTo(0.0f, 0.0f, 100.0f, 150.0f, 100.0f, 200.0f);
         path.cubicTo(100.0f, 200.0f, 50.0f, 300.0f, -80.0f, 200.0f);
         path.cubicTo(-80.0f, 200.0f, 100.0f, 200.0f, 200.0f, 0.0f);
     }
 
-    private Path makeStraightPath() {
+    private static Path makeStraightPath() {
         Path path = new Path();
         buildStraightPath(path);
         return path;
     }
 
-    private void buildStraightPath(Path path) {
+    private static void buildStraightPath(Path path) {
         path.moveTo(0.0f, 0.0f);
         path.lineTo(400.0f, 0.0f);
     }
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ColorCube.java b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ColorCube.java
index 1d2cdbd..f313c46 100644
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ColorCube.java
+++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ColorCube.java
@@ -25,6 +25,7 @@
 import android.renderscript.Script;
 import android.renderscript.ScriptC;
 import android.renderscript.ScriptGroup;
+import android.renderscript.ScriptIntrinsic3DLUT;
 import android.renderscript.ScriptIntrinsicColorMatrix;
 import android.renderscript.Type;
 import android.util.Log;
@@ -32,8 +33,11 @@
 public class ColorCube extends TestBase {
     private Allocation mCube;
     private ScriptC_colorcube mScript;
+    private ScriptIntrinsic3DLUT mIntrinsic;
+    private boolean mUseIntrinsic;
 
-    public ColorCube() {
+    public ColorCube(boolean useIntrinsic) {
+        mUseIntrinsic = useIntrinsic;
     }
 
     private void initCube() {
@@ -66,16 +70,19 @@
 
     public void createTest(android.content.res.Resources res) {
         mScript = new ScriptC_colorcube(mRS, res, R.raw.colorcube);
+        mIntrinsic = ScriptIntrinsic3DLUT.create(mRS, Element.U8_4(mRS));
 
         initCube();
         mScript.invoke_setCube(mCube);
-
-
-        //mScript.invoke_setMatrix(m);
+        mIntrinsic.setLUT(mCube);
     }
 
     public void runTest() {
-        mScript.forEach_root(mInPixelsAllocation, mOutPixelsAllocation);
+        if (mUseIntrinsic) {
+            mIntrinsic.forEach(mInPixelsAllocation, mOutPixelsAllocation);
+        } else {
+            mScript.forEach_root(mInPixelsAllocation, mOutPixelsAllocation);
+        }
     }
 
 }
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java
index 18f438a..a8c1399 100644
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java
+++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java
@@ -292,7 +292,10 @@
             mTest = new WhiteBalance();
             break;
         case 36:
-            mTest = new ColorCube();
+            mTest = new ColorCube(false);
+            break;
+        case 37:
+            mTest = new ColorCube(true);
             break;
         }
 
@@ -305,7 +308,7 @@
     }
 
     void setupTests() {
-        mTestNames = new String[37];
+        mTestNames = new String[38];
         mTestNames[0] = "Levels Vec3 Relaxed";
         mTestNames[1] = "Levels Vec4 Relaxed";
         mTestNames[2] = "Levels Vec3 Full";
@@ -343,6 +346,7 @@
         mTestNames[34] = "Exposure";
         mTestNames[35] = "White Balance";
         mTestNames[36] = "Color Cube";
+        mTestNames[37] = "Color Cube (3D LUT intrinsic)";
 
         mTestSpinner.setAdapter(new ArrayAdapter<String>(
             this, R.layout.spinner_layout, mTestNames));
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/colorcube.rs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/colorcube.rs
index 5250474..fda0d1e 100644
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/colorcube.rs
+++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/colorcube.rs
@@ -62,10 +62,10 @@
     uint4 yz01 = ((v001 * weight1.x) + (v101 * weight2.x)) >> (int4)8;
     uint4 yz11 = ((v011 * weight1.x) + (v111 * weight2.x)) >> (int4)8;
 
-    uint4 z0 = (yz00 * weight1.y) + (yz10 * weight2.y) >> (int4)16;
-    uint4 z1 = (yz01 * weight1.y) + (yz11 * weight2.y) >> (int4)16;
+    uint4 z0 = ((yz00 * weight1.y) + (yz10 * weight2.y)) >> (int4)16;
+    uint4 z1 = ((yz01 * weight1.y) + (yz11 * weight2.y)) >> (int4)16;
 
-    uint4 v = (z0 * weight1.z) + (z1 * weight2.z) >> (int4)16;
+    uint4 v = ((z0 * weight1.z) + (z1 * weight2.z)) >> (int4)16;
     uint4 v2 = (v + 0x7f) >> (int4)8;
 
     *out = convert_uchar4(v2);
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/ImageProcessingActivity2.java b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/ImageProcessingActivity2.java
index 227518f..19bea43 100644
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/ImageProcessingActivity2.java
+++ b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/ImageProcessingActivity2.java
@@ -229,7 +229,7 @@
             break;
         }
 
-        mTest.createBaseTest(this, mBitmapIn, mBitmapIn2);
+        mTest.createBaseTest(this, mBitmapIn, mBitmapIn2, mBitmapOut);
         setupBars();
 
         mTest.runTest();
diff --git a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/TestBase.java b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/TestBase.java
index 9df2eff..dbbc594 100644
--- a/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/TestBase.java
+++ b/tests/RenderScriptTests/ImageProcessing2/src/com/android/rs/image/TestBase.java
@@ -88,18 +88,14 @@
         return false;
     }
 
-    public final void createBaseTest(ImageProcessingActivity2 ipact, Bitmap b, Bitmap b2) {
+    public final void createBaseTest(ImageProcessingActivity2 ipact, Bitmap b, Bitmap b2, Bitmap outb) {
         act = ipact;
         mRS = RenderScript.create(act);
-        mInPixelsAllocation = Allocation.createFromBitmap(mRS, b,
-                                                          Allocation.MipmapControl.MIPMAP_NONE,
-                                                          Allocation.USAGE_SCRIPT);
-        mInPixelsAllocation2 = Allocation.createFromBitmap(mRS, b2,
-                                                          Allocation.MipmapControl.MIPMAP_NONE,
-                                                          Allocation.USAGE_SCRIPT);
-        mOutPixelsAllocation = Allocation.createFromBitmap(mRS, b,
-                                                           Allocation.MipmapControl.MIPMAP_NONE,
-                                                           Allocation.USAGE_SCRIPT);
+
+        mInPixelsAllocation = Allocation.createFromBitmap(mRS, b);
+        mInPixelsAllocation2 = Allocation.createFromBitmap(mRS, b2);
+        mOutPixelsAllocation = Allocation.createFromBitmap(mRS, outb);
+
         createTest(act.getResources());
     }
 
diff --git a/tests/permission/src/com/android/framework/permission/tests/VibratorServicePermissionTest.java b/tests/permission/src/com/android/framework/permission/tests/VibratorServicePermissionTest.java
index 274ac00..2416828 100644
--- a/tests/permission/src/com/android/framework/permission/tests/VibratorServicePermissionTest.java
+++ b/tests/permission/src/com/android/framework/permission/tests/VibratorServicePermissionTest.java
@@ -46,7 +46,7 @@
      */
     public void testVibrate() throws RemoteException {
         try {
-            mVibratorService.vibrate(2000, new Binder());
+            mVibratorService.vibrate(null, 2000, new Binder());
             fail("vibrate did not throw SecurityException as expected");
         } catch (SecurityException e) {
             // expected
@@ -62,7 +62,7 @@
      */
     public void testVibratePattern() throws RemoteException {
         try {
-            mVibratorService.vibratePattern(new long[] {0}, 0, new Binder());
+            mVibratorService.vibratePattern(null, new long[] {0}, 0, new Binder());
             fail("vibratePattern did not throw SecurityException as expected");
         } catch (SecurityException e) {
             // expected
diff --git a/wifi/java/android/net/wifi/p2p/nsd/WifiP2pServiceResponse.java b/wifi/java/android/net/wifi/p2p/nsd/WifiP2pServiceResponse.java
index ac31663..194c982 100644
--- a/wifi/java/android/net/wifi/p2p/nsd/WifiP2pServiceResponse.java
+++ b/wifi/java/android/net/wifi/p2p/nsd/WifiP2pServiceResponse.java
@@ -222,10 +222,10 @@
                  */
                 // The length equals to 3 plus the number of octets in the vendor
                 // specific content field. And this is little endian.
-                int length = ((dis.readByte() & 0xff) +
-                        ((dis.readByte() & 0xff) << 8)) - 3;
+                int length = (dis.readUnsignedByte() +
+                        (dis.readUnsignedByte() << 8)) - 3;
                 int type = dis.readUnsignedByte();
-                byte transId = dis.readByte();
+                int transId = dis.readUnsignedByte();
                 int status = dis.readUnsignedByte();
                 if (length < 0) {
                     return null;