Merge "Increase the Message pool size" into jb-dev
diff --git a/api/current.txt b/api/current.txt
index bf79d81..300a690 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -144,6 +144,7 @@
     field public static final java.lang.String AFFECTS_BATTERY = "android.permission-group.AFFECTS_BATTERY";
     field public static final java.lang.String APP_INFO = "android.permission-group.APP_INFO";
     field public static final java.lang.String AUDIO_SETTINGS = "android.permission-group.AUDIO_SETTINGS";
+    field public static final java.lang.String BLUETOOTH_NETWORK = "android.permission-group.BLUETOOTH_NETWORK";
     field public static final java.lang.String BOOKMARKS = "android.permission-group.BOOKMARKS";
     field public static final java.lang.String CALENDAR = "android.permission-group.CALENDAR";
     field public static final java.lang.String CAMERA = "android.permission-group.CAMERA";
@@ -169,6 +170,7 @@
     field public static final java.lang.String USER_DICTIONARY = "android.permission-group.USER_DICTIONARY";
     field public static final java.lang.String VOICEMAIL = "android.permission-group.VOICEMAIL";
     field public static final java.lang.String WALLPAPER = "android.permission-group.WALLPAPER";
+    field public static final java.lang.String WRITE_USER_DICTIONARY = "android.permission-group.WRITE_USER_DICTIONARY";
   }
 
   public final class R {
@@ -25092,7 +25094,7 @@
     method public static java.lang.String eventTypeToString(int);
     method public long getEventTime();
     method public int getEventType();
-    method public int getGranularity();
+    method public int getMovementGranularity();
     method public java.lang.CharSequence getPackageName();
     method public android.view.accessibility.AccessibilityRecord getRecord(int);
     method public int getRecordCount();
@@ -25102,7 +25104,7 @@
     method public static android.view.accessibility.AccessibilityEvent obtain();
     method public void setEventTime(long);
     method public void setEventType(int);
-    method public void setGranularity(int);
+    method public void setMovementGranularity(int);
     method public void setPackageName(java.lang.CharSequence);
     method public void writeToParcel(android.os.Parcel, int);
     field public static final android.os.Parcelable.Creator CREATOR;
@@ -25124,7 +25126,7 @@
     field public static final int TYPE_VIEW_SELECTED = 4; // 0x4
     field public static final int TYPE_VIEW_TEXT_CHANGED = 16; // 0x10
     field public static final int TYPE_VIEW_TEXT_SELECTION_CHANGED = 8192; // 0x2000
-    field public static final int TYPE_VIEW_TEXT_TRAVERSED_AT_GRANULARITY = 131072; // 0x20000
+    field public static final int TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY = 131072; // 0x20000
     field public static final int TYPE_WINDOW_CONTENT_CHANGED = 2048; // 0x800
     field public static final int TYPE_WINDOW_STATE_CHANGED = 32; // 0x20
   }
@@ -25165,7 +25167,7 @@
     method public int getChildCount();
     method public java.lang.CharSequence getClassName();
     method public java.lang.CharSequence getContentDescription();
-    method public int getGranularities();
+    method public int getMovementGranularities();
     method public java.lang.CharSequence getPackageName();
     method public android.view.accessibility.AccessibilityNodeInfo getParent();
     method public java.lang.CharSequence getText();
@@ -25199,8 +25201,8 @@
     method public void setEnabled(boolean);
     method public void setFocusable(boolean);
     method public void setFocused(boolean);
-    method public void setGranularities(int);
     method public void setLongClickable(boolean);
+    method public void setMovementGranularities(int);
     method public void setPackageName(java.lang.CharSequence);
     method public void setParent(android.view.View);
     method public void setParent(android.view.View, int);
@@ -25212,27 +25214,27 @@
     method public void setText(java.lang.CharSequence);
     method public void writeToParcel(android.os.Parcel, int);
     field public static final int ACTION_ACCESSIBILITY_FOCUS = 64; // 0x40
-    field public static final java.lang.String ACTION_ARGUMENT_GRANULARITY_INT = "ACTION_ARGUMENT_GRANULARITY_INT";
     field public static final java.lang.String ACTION_ARGUMENT_HTML_ELEMENT_STRING = "ACTION_ARGUMENT_HTML_ELEMENT_STRING";
+    field public static final java.lang.String ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT = "ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT";
     field public static final int ACTION_CLEAR_ACCESSIBILITY_FOCUS = 128; // 0x80
     field public static final int ACTION_CLEAR_FOCUS = 2; // 0x2
     field public static final int ACTION_CLEAR_SELECTION = 8; // 0x8
     field public static final int ACTION_CLICK = 16; // 0x10
     field public static final int ACTION_FOCUS = 1; // 0x1
     field public static final int ACTION_LONG_CLICK = 32; // 0x20
-    field public static final int ACTION_NEXT_AT_GRANULARITY = 256; // 0x100
+    field public static final int ACTION_NEXT_AT_MOVEMENT_GRANULARITY = 256; // 0x100
     field public static final int ACTION_NEXT_HTML_ELEMENT = 1024; // 0x400
-    field public static final int ACTION_PREVIOUS_AT_GRANULARITY = 512; // 0x200
+    field public static final int ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY = 512; // 0x200
     field public static final int ACTION_PREVIOUS_HTML_ELEMENT = 2048; // 0x800
     field public static final int ACTION_SELECT = 4; // 0x4
     field public static final android.os.Parcelable.Creator CREATOR;
     field public static final int FOCUS_ACCESSIBILITY = 2; // 0x2
     field public static final int FOCUS_INPUT = 1; // 0x1
-    field public static final int GRANULARITY_CHARACTER = 1; // 0x1
-    field public static final int GRANULARITY_LINE = 4; // 0x4
-    field public static final int GRANULARITY_PAGE = 16; // 0x10
-    field public static final int GRANULARITY_PARAGRAPH = 8; // 0x8
-    field public static final int GRANULARITY_WORD = 2; // 0x2
+    field public static final int MOVEMENT_GRANULARITY_CHARACTER = 1; // 0x1
+    field public static final int MOVEMENT_GRANULARITY_LINE = 4; // 0x4
+    field public static final int MOVEMENT_GRANULARITY_PAGE = 16; // 0x10
+    field public static final int MOVEMENT_GRANULARITY_PARAGRAPH = 8; // 0x8
+    field public static final int MOVEMENT_GRANULARITY_WORD = 2; // 0x2
   }
 
   public abstract class AccessibilityNodeProvider {
diff --git a/core/java/android/app/Dialog.java b/core/java/android/app/Dialog.java
index 4a5b8eb..2cc3b02 100644
--- a/core/java/android/app/Dialog.java
+++ b/core/java/android/app/Dialog.java
@@ -27,6 +27,7 @@
 import android.net.Uri;
 import android.os.Bundle;
 import android.os.Handler;
+import android.os.Looper;
 import android.os.Message;
 import android.util.Log;
 import android.util.TypedValue;
@@ -297,7 +298,11 @@
      * that in {@link #onStop}.
      */
     public void dismiss() {
-        mHandler.post(mDismissAction);
+        if (Looper.myLooper() == mHandler.getLooper()) {
+            dismissDialog();
+        } else {
+            mHandler.post(mDismissAction);
+        }
     }
 
     void dismissDialog() {
diff --git a/core/java/android/content/SyncManager.java b/core/java/android/content/SyncManager.java
index 34c40a0..badcb03 100644
--- a/core/java/android/content/SyncManager.java
+++ b/core/java/android/content/SyncManager.java
@@ -17,7 +17,6 @@
 package android.content;
 
 import com.android.internal.R;
-import com.android.internal.util.ArrayUtils;
 import com.google.android.collect.Lists;
 import com.google.android.collect.Maps;
 
@@ -32,7 +31,6 @@
 import android.app.Notification;
 import android.app.NotificationManager;
 import android.app.PendingIntent;
-import android.app.DownloadManager.Request;
 import android.content.SyncStorageEngine.OnSyncRequestListener;
 import android.content.pm.ApplicationInfo;
 import android.content.pm.PackageManager;
@@ -1998,6 +1996,7 @@
                 ActiveSyncContext conflict = null;
                 ActiveSyncContext longRunning = null;
                 ActiveSyncContext toReschedule = null;
+                ActiveSyncContext oldestNonExpeditedRegular = null;
 
                 for (ActiveSyncContext activeSyncContext : mActiveSyncContexts) {
                     final SyncOperation activeOp = activeSyncContext.mSyncOperation;
@@ -2005,6 +2004,13 @@
                         numInit++;
                     } else {
                         numRegular++;
+                        if (!activeOp.isExpedited()) {
+                            if (oldestNonExpeditedRegular == null
+                                || (oldestNonExpeditedRegular.mStartTime
+                                    > activeSyncContext.mStartTime)) {
+                                oldestNonExpeditedRegular = activeSyncContext;
+                            }
+                        }
                     }
                     if (activeOp.account.type.equals(candidate.account.type)
                             && activeOp.authority.equals(candidate.authority)
@@ -2027,8 +2033,13 @@
                     Log.v(TAG, "  numActiveInit=" + numInit + ", numActiveRegular=" + numRegular);
                     Log.v(TAG, "  longRunning: " + longRunning);
                     Log.v(TAG, "  conflict: " + conflict);
+                    Log.v(TAG, "  oldestNonExpeditedRegular: " + oldestNonExpeditedRegular);
                 }
 
+                final boolean roomAvailable = candidateIsInitialization
+                        ? numInit < MAX_SIMULTANEOUS_INITIALIZATION_SYNCS
+                        : numRegular < MAX_SIMULTANEOUS_REGULAR_SYNCS;
+
                 if (conflict != null) {
                     if (candidateIsInitialization && !conflict.mSyncOperation.isInitialization()
                             && numInit < MAX_SIMULTANEOUS_INITIALIZATION_SYNCS) {
@@ -2048,23 +2059,32 @@
                     } else {
                         continue;
                     }
-                } else {
-                    final boolean roomAvailable = candidateIsInitialization
-                            ? numInit < MAX_SIMULTANEOUS_INITIALIZATION_SYNCS
-                            : numRegular < MAX_SIMULTANEOUS_REGULAR_SYNCS;
-                    if (roomAvailable) {
-                        // dispatch candidate
-                    } else if (longRunning != null
-                            && (candidateIsInitialization
-                                == longRunning.mSyncOperation.isInitialization())) {
-                        toReschedule = longRunning;
-                        if (Log.isLoggable(TAG, Log.VERBOSE)) {
-                            Log.v(TAG, "canceling and rescheduling sync since it ran roo long, "
-                                    + longRunning);
-                        }
-                    } else {
-                        continue;
+                } else if (roomAvailable) {
+                    // dispatch candidate
+                } else if (candidate.isExpedited() && oldestNonExpeditedRegular != null
+                           && !candidateIsInitialization) {
+                    // We found an active, non-expedited regular sync. We also know that the
+                    // candidate doesn't conflict with this active sync since conflict
+                    // is null. Reschedule the active sync and start the candidate.
+                    toReschedule = oldestNonExpeditedRegular;
+                    if (Log.isLoggable(TAG, Log.VERBOSE)) {
+                        Log.v(TAG, "canceling and rescheduling sync since an expedited is ready to run, "
+                                + oldestNonExpeditedRegular);
                     }
+                } else if (longRunning != null
+                        && (candidateIsInitialization
+                            == longRunning.mSyncOperation.isInitialization())) {
+                    // We found an active, long-running sync. Reschedule the active
+                    // sync and start the candidate.
+                    toReschedule = longRunning;
+                    if (Log.isLoggable(TAG, Log.VERBOSE)) {
+                        Log.v(TAG, "canceling and rescheduling sync since it ran roo long, "
+                              + longRunning);
+                    }
+                } else {
+                    // we were unable to find or make space to run this candidate, go on to
+                    // the next one
+                    continue;
                 }
 
                 if (toReschedule != null) {
@@ -2516,7 +2536,7 @@
 
             return mSyncStorageEngine.insertStartSyncEvent(
                     syncOperation.account, syncOperation.userId, syncOperation.authority,
-                    now, source);
+                    now, source, syncOperation.isInitialization());
         }
 
         public void stopSyncEvent(long rowId, SyncOperation syncOperation, String resultMessage,
diff --git a/core/java/android/content/SyncOperation.java b/core/java/android/content/SyncOperation.java
index 4e86ef8..9fcc22d 100644
--- a/core/java/android/content/SyncOperation.java
+++ b/core/java/android/content/SyncOperation.java
@@ -116,6 +116,10 @@
         return extras.getBoolean(ContentResolver.SYNC_EXTRAS_INITIALIZE, false);
     }
 
+    public boolean isExpedited() {
+        return extras.getBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, false);
+    }
+
     public boolean ignoreBackoff() {
         return extras.getBoolean(ContentResolver.SYNC_EXTRAS_IGNORE_BACKOFF, false);
     }
diff --git a/core/java/android/content/SyncStorageEngine.java b/core/java/android/content/SyncStorageEngine.java
index d821918..6c7e940 100644
--- a/core/java/android/content/SyncStorageEngine.java
+++ b/core/java/android/content/SyncStorageEngine.java
@@ -221,6 +221,7 @@
         long upstreamActivity;
         long downstreamActivity;
         String mesg;
+        boolean initialization;
     }
 
     public static class DayStats {
@@ -1012,7 +1013,7 @@
      * Note that sync has started for the given account and authority.
      */
     public long insertStartSyncEvent(Account accountName, int userId, String authorityName,
-            long now, int source) {
+                                     long now, int source, boolean initialization) {
         long id;
         synchronized (mAuthorities) {
             if (Log.isLoggable(TAG, Log.VERBOSE)) {
@@ -1025,6 +1026,7 @@
                 return -1;
             }
             SyncHistoryItem item = new SyncHistoryItem();
+            item.initialization = initialization;
             item.authorityId = authority.ident;
             item.historyId = mNextHistoryId++;
             if (mNextHistoryId < 0) mNextHistoryId = 0;
diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java
index 98b40eb..ad52e13 100644
--- a/core/java/android/content/pm/PackageParser.java
+++ b/core/java/android/content/pm/PackageParser.java
@@ -1458,7 +1458,7 @@
                 com.android.internal.R.styleable.AndroidManifestPermissionGroup_permissionGroupFlags, 0);
         perm.info.priority = sa.getInt(
                 com.android.internal.R.styleable.AndroidManifestPermissionGroup_priority, 0);
-        if (perm.info.priority > 0 && (flags&PARSE_IS_SYSTEM) != 0) {
+        if (perm.info.priority > 0 && (flags&PARSE_IS_SYSTEM) == 0) {
             perm.info.priority = 0;
         }
 
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 0837cf4..5299d58 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -4715,10 +4715,10 @@
         }
 
         if (getContentDescription() != null) {
-            info.addAction(AccessibilityNodeInfo.ACTION_NEXT_AT_GRANULARITY);
-            info.addAction(AccessibilityNodeInfo.ACTION_PREVIOUS_AT_GRANULARITY);
-            info.setGranularities(AccessibilityNodeInfo.GRANULARITY_CHARACTER
-                    | AccessibilityNodeInfo.GRANULARITY_WORD);
+            info.addAction(AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY);
+            info.addAction(AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY);
+            info.setMovementGranularities(AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER
+                    | AccessibilityNodeInfo.MOVEMENT_GRANULARITY_WORD);
         }
     }
 
@@ -6453,12 +6453,12 @@
         switch (action) {
             case AccessibilityNodeInfo.ACTION_CLICK: {
                 if (isClickable()) {
-                    performClick();
+                    return performClick();
                 }
             } break;
             case AccessibilityNodeInfo.ACTION_LONG_CLICK: {
                 if (isLongClickable()) {
-                    performLongClick();
+                    return performLongClick();
                 }
             } break;
             case AccessibilityNodeInfo.ACTION_FOCUS: {
@@ -15236,6 +15236,18 @@
         }
     }
 
+    /** @hide */
+    public void setDisabledSystemUiVisibility(int flags) {
+        if (mAttachInfo != null) {
+            if (mAttachInfo.mDisabledSystemUiVisibility != flags) {
+                mAttachInfo.mDisabledSystemUiVisibility = flags;
+                if (mParent != null) {
+                    mParent.recomputeViewAttributes(this);
+                }
+            }
+        }
+    }
+
     /**
      * Creates an image that the system displays during the drag and drop
      * operation. This is called a &quot;drag shadow&quot;. The default implementation
@@ -16913,6 +16925,11 @@
         int mSystemUiVisibility;
 
         /**
+         * Hack to force certain system UI visibility flags to be cleared.
+         */
+        int mDisabledSystemUiVisibility;
+
+        /**
          * True if a view in this hierarchy has an OnSystemUiVisibilityChangeListener
          * attached.
          */
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 79c8320..ec6bd81 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -1026,6 +1026,7 @@
             attachInfo.mSystemUiVisibility = 0;
             attachInfo.mHasSystemUiListeners = false;
             mView.dispatchCollectViewAttributes(attachInfo, 0);
+            attachInfo.mSystemUiVisibility &= ~attachInfo.mDisabledSystemUiVisibility;
             if (attachInfo.mKeepScreenOn != oldScreenOn
                     || attachInfo.mSystemUiVisibility != oldVis
                     || attachInfo.mHasSystemUiListeners != oldHasSystemUiListeners) {
diff --git a/core/java/android/view/accessibility/AccessibilityEvent.java b/core/java/android/view/accessibility/AccessibilityEvent.java
index 6d1166e..f70ffa9 100644
--- a/core/java/android/view/accessibility/AccessibilityEvent.java
+++ b/core/java/android/view/accessibility/AccessibilityEvent.java
@@ -226,9 +226,9 @@
  *   <li>{@link #getContentDescription()} - The content description of the source.</li>
  * </ul>
  * </p>
- * <b>View text traversed at granularity</b> - represents the event of traversing the
+ * <b>View text traversed at movement granularity</b> - represents the event of traversing the
  * text of a view at a given granularity. For example, moving to the next word.</br>
- * <em>Type:</em> {@link #TYPE_VIEW_TEXT_TRAVERSED_AT_GRANULARITY} </br>
+ * <em>Type:</em> {@link #TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY} </br>
  * <em>Properties:</em></br>
  * <ul>
  *   <li>{@link #getEventType()} - The type of the event.</li>
@@ -236,11 +236,12 @@
  *   <li>{@link #getClassName()} - The class name of the source.</li>
  *   <li>{@link #getPackageName()} - The package name of the source.</li>
  *   <li>{@link #getEventTime()}  - The event time.</li>
- *   <li>{@link #getText()} - The text of the current text at the granularity.</li>
+ *   <li>{@link #getText()} - The text of the current text at the movement granularity.</li>
  *   <li>{@link #isPassword()} - Whether the source is password.</li>
  *   <li>{@link #isEnabled()} - Whether the source is enabled.</li>
  *   <li>{@link #getContentDescription()} - The content description of the source.</li>
- *   <li>{@link #getGranularity()} - Sets the granularity at which a view's text was traversed.</li>
+ *   <li>{@link #getMovementGranularity()} - Sets the granularity at which a view's text
+ *       was traversed.</li>
  * </ul>
  * </p>
  * <p>
@@ -597,9 +598,9 @@
     public static final int TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED = 0x00010000;
 
     /**
-     * Represents the event of traversing the text of a view at a given granularity.
+     * Represents the event of traversing the text of a view at a given movement granularity.
      */
-    public static final int TYPE_VIEW_TEXT_TRAVERSED_AT_GRANULARITY = 0x00020000;
+    public static final int TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY = 0x00020000;
 
     /**
      * Mask for {@link AccessibilityEvent} all types.
@@ -619,7 +620,7 @@
      * @see #TYPE_VIEW_SCROLLED
      * @see #TYPE_VIEW_TEXT_SELECTION_CHANGED
      * @see #TYPE_ANNOUNCEMENT
-     * @see #TYPE_VIEW_TEXT_TRAVERSED_AT_GRANULARITY
+     * @see #TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY
      */
     public static final int TYPES_ALL_MASK = 0xFFFFFFFF;
 
@@ -633,7 +634,7 @@
     private int mEventType;
     private CharSequence mPackageName;
     private long mEventTime;
-    int mGranularity;
+    int mMovementGranularity;
 
     private final ArrayList<AccessibilityRecord> mRecords = new ArrayList<AccessibilityRecord>();
 
@@ -651,7 +652,7 @@
     void init(AccessibilityEvent event) {
         super.init(event);
         mEventType = event.mEventType;
-        mGranularity = event.mGranularity;
+        mMovementGranularity = event.mMovementGranularity;
         mEventTime = event.mEventTime;
         mPackageName = event.mPackageName;
     }
@@ -769,24 +770,24 @@
     }
 
     /**
-     * Sets the text granularity that was traversed.
+     * Sets the movement granularity that was traversed.
      *
      * @param granularity The granularity.
      *
      * @throws IllegalStateException If called from an AccessibilityService.
      */
-    public void setGranularity(int granularity) {
+    public void setMovementGranularity(int granularity) {
         enforceNotSealed();
-        mGranularity = granularity;
+        mMovementGranularity = granularity;
     }
 
     /**
-     * Gets the text granularity that was traversed.
+     * Gets the movement granularity that was traversed.
      *
      * @return The granularity.
      */
-    public int getGranularity() {
-        return mGranularity;
+    public int getMovementGranularity() {
+        return mMovementGranularity;
     }
 
     /**
@@ -877,7 +878,7 @@
     protected void clear() {
         super.clear();
         mEventType = 0;
-        mGranularity = 0;
+        mMovementGranularity = 0;
         mPackageName = null;
         mEventTime = 0;
         while (!mRecords.isEmpty()) {
@@ -894,7 +895,7 @@
     public void initFromParcel(Parcel parcel) {
         mSealed = (parcel.readInt() == 1);
         mEventType = parcel.readInt();
-        mGranularity = parcel.readInt();
+        mMovementGranularity = parcel.readInt();
         mPackageName = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(parcel);
         mEventTime = parcel.readLong();
         mConnectionId = parcel.readInt();
@@ -945,7 +946,7 @@
     public void writeToParcel(Parcel parcel, int flags) {
         parcel.writeInt(isSealed() ? 1 : 0);
         parcel.writeInt(mEventType);
-        parcel.writeInt(mGranularity);
+        parcel.writeInt(mMovementGranularity);
         TextUtils.writeToParcel(mPackageName, parcel, 0);
         parcel.writeLong(mEventTime);
         parcel.writeInt(mConnectionId);
@@ -1002,7 +1003,7 @@
         builder.append("EventType: ").append(eventTypeToString(mEventType));
         builder.append("; EventTime: ").append(mEventTime);
         builder.append("; PackageName: ").append(mPackageName);
-        builder.append("; Granularity: ").append(mGranularity);
+        builder.append("; MovementGranularity: ").append(mMovementGranularity);
         builder.append(super.toString());
         if (DEBUG) {
             builder.append("\n");
@@ -1083,8 +1084,8 @@
                 return "TYPE_VIEW_ACCESSIBILITY_FOCUSED";
             case TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED:
                 return "TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED";
-            case TYPE_VIEW_TEXT_TRAVERSED_AT_GRANULARITY:
-                return "TYPE_CURRENT_AT_GRANULARITY_CHANGED";
+            case TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY:
+                return "TYPE_CURRENT_AT_GRANULARITY_MOVEMENT_CHANGED";
             default:
                 return null;
         }
diff --git a/core/java/android/view/accessibility/AccessibilityNodeInfo.java b/core/java/android/view/accessibility/AccessibilityNodeInfo.java
index 5266c83..c0696a9 100644
--- a/core/java/android/view/accessibility/AccessibilityNodeInfo.java
+++ b/core/java/android/view/accessibility/AccessibilityNodeInfo.java
@@ -123,53 +123,56 @@
 
     /**
      * Action that requests to go to the next entity in this node's text
-     * at a given granularity. For example, move to the next character, word, etc.
+     * at a given movement granularity. For example, move to the next character,
+     * word, etc.
      * <p>
-     * <strong>Arguments:</strong> {@link #ACTION_ARGUMENT_GRANULARITY_INT}<br>
+     * <strong>Arguments:</strong> {@link #ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT}<br>
      * <strong>Example:</strong>
      * <code><pre><p>
      *   Bundle arguments = new Bundle();
-     *   arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_GRANULARITY_INT,
-     *           AccessibilityNodeInfo.GRANULARITY_CHARACTER);
-     *   info.performAction(AccessibilityNodeInfo.ACTION_NEXT_AT_GRANULARITY, arguments);
+     *   arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT,
+     *           AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER);
+     *   info.performAction(AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY, arguments);
      * </code></pre></p>
      * </p>
      *
-     * @see #setGranularities(int)
-     * @see #getGranularities()
+     * @see #setMovementGranularities(int)
+     * @see #getMovementGranularities()
      *
-     * @see #GRANULARITY_CHARACTER
-     * @see #GRANULARITY_WORD
-     * @see #GRANULARITY_LINE
-     * @see #GRANULARITY_PARAGRAPH
-     * @see #GRANULARITY_PAGE
+     * @see #MOVEMENT_GRANULARITY_CHARACTER
+     * @see #MOVEMENT_GRANULARITY_WORD
+     * @see #MOVEMENT_GRANULARITY_LINE
+     * @see #MOVEMENT_GRANULARITY_PARAGRAPH
+     * @see #MOVEMENT_GRANULARITY_PAGE
      */
-    public static final int ACTION_NEXT_AT_GRANULARITY = 0x00000100;
+    public static final int ACTION_NEXT_AT_MOVEMENT_GRANULARITY = 0x00000100;
 
     /**
      * Action that requests to go to the previous entity in this node's text
-     * at a given granularity. For example, move to the next character, word, etc.
+     * at a given movement granularity. For example, move to the next character,
+     * word, etc.
      * <p>
-     * <strong>Arguments:</strong> {@link #ACTION_ARGUMENT_GRANULARITY_INT}<br>
+     * <strong>Arguments:</strong> {@link #ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT}<br>
      * <strong>Example:</strong>
      * <code><pre><p>
      *   Bundle arguments = new Bundle();
-     *   arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_GRANULARITY_INT,
-     *           AccessibilityNodeInfo.GRANULARITY_CHARACTER);
-     *   info.performAction(AccessibilityNodeInfo.ACTION_PREVIOUS_AT_GRANULARITY, arguments);
+     *   arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT,
+     *           AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER);
+     *   info.performAction(AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY,
+     *           arguments);
      * </code></pre></p>
      * </p>
      *
-     * @see #setGranularities(int)
-     * @see #getGranularities()
+     * @see #setMovementGranularities(int)
+     * @see #getMovementGranularities()
      *
-     * @see #GRANULARITY_CHARACTER
-     * @see #GRANULARITY_WORD
-     * @see #GRANULARITY_LINE
-     * @see #GRANULARITY_PARAGRAPH
-     * @see #GRANULARITY_PAGE
+     * @see #MOVEMENT_GRANULARITY_CHARACTER
+     * @see #MOVEMENT_GRANULARITY_WORD
+     * @see #MOVEMENT_GRANULARITY_LINE
+     * @see #MOVEMENT_GRANULARITY_PARAGRAPH
+     * @see #MOVEMENT_GRANULARITY_PAGE
      */
-    public static final int ACTION_PREVIOUS_AT_GRANULARITY = 0x00000200;
+    public static final int ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY = 0x00000200;
 
     /**
      * Action to move to the next HTML element of a given type. For example, move
@@ -202,14 +205,15 @@
     public static final int ACTION_PREVIOUS_HTML_ELEMENT = 0x00000800;
 
     /**
-     * Argument for which text granularity to be used when traversing the node text.
+     * Argument for which movement granularity to be used when traversing the node text.
      * <p>
      * <strong>Type:</strong> int<br>
-     * <strong>Actions:</strong> {@link #ACTION_NEXT_AT_GRANULARITY},
-     * {@link #ACTION_PREVIOUS_AT_GRANULARITY}
+     * <strong>Actions:</strong> {@link #ACTION_NEXT_AT_MOVEMENT_GRANULARITY},
+     * {@link #ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY}
      * </p>
      */
-    public static final String ACTION_ARGUMENT_GRANULARITY_INT = "ACTION_ARGUMENT_GRANULARITY_INT";
+    public static final String ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT =
+        "ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT";
 
     /**
      * Argument for which HTML element to get moving to the next/previous HTML element.
@@ -232,32 +236,32 @@
      */
     public static final int FOCUS_ACCESSIBILITY = 2;
 
-    // Granularities
+    // Movement granularities
 
     /**
-     * Granularity bit for traversing the text of a node by character.
+     * Movement granularity bit for traversing the text of a node by character.
      */
-    public static final int GRANULARITY_CHARACTER = 0x00000001;
+    public static final int MOVEMENT_GRANULARITY_CHARACTER = 0x00000001;
 
     /**
-     * Granularity bit for traversing the text of a node by word.
+     * Movement granularity bit for traversing the text of a node by word.
      */
-    public static final int GRANULARITY_WORD = 0x00000002;
+    public static final int MOVEMENT_GRANULARITY_WORD = 0x00000002;
 
     /**
-     * Granularity bit for traversing the text of a node by line.
+     * Movement granularity bit for traversing the text of a node by line.
      */
-    public static final int GRANULARITY_LINE = 0x00000004;
+    public static final int MOVEMENT_GRANULARITY_LINE = 0x00000004;
 
     /**
-     * Granularity bit for traversing the text of a node by paragraph.
+     * Movement granularity bit for traversing the text of a node by paragraph.
      */
-    public static final int GRANULARITY_PARAGRAPH = 0x00000008;
+    public static final int MOVEMENT_GRANULARITY_PARAGRAPH = 0x00000008;
 
     /**
-     * Granularity bit for traversing the text of a node by page.
+     * Movement granularity bit for traversing the text of a node by page.
      */
-    public static final int GRANULARITY_PAGE = 0x00000010;
+    public static final int MOVEMENT_GRANULARITY_PAGE = 0x00000010;
 
     // Boolean attributes.
 
@@ -362,7 +366,7 @@
     private final SparseLongArray mChildNodeIds = new SparseLongArray();
     private int mActions;
 
-    private int mGranularities;
+    private int mMovementGranularities;
 
     private int mConnectionId = UNDEFINED;
 
@@ -586,7 +590,7 @@
     }
 
     /**
-     * Sets the text granularities for traversing the text of this node.
+     * Sets the movement granularities for traversing the text of this node.
      * <p>
      *   <strong>Note:</strong> Cannot be called from an
      *   {@link android.accessibilityservice.AccessibilityService}.
@@ -597,18 +601,18 @@
      *
      * @throws IllegalStateException If called from an AccessibilityService.
      */
-    public void setGranularities(int granularities) {
+    public void setMovementGranularities(int granularities) {
         enforceNotSealed();
-        mGranularities = granularities;
+        mMovementGranularities = granularities;
     }
 
     /**
-     * Gets the granularities for traversing the text of this node.
+     * Gets the movement granularities for traversing the text of this node.
      *
      * @return The bit mask with granularities.
      */
-    public int getGranularities() {
-        return mGranularities;
+    public int getMovementGranularities() {
+        return mMovementGranularities;
     }
 
     /**
@@ -1412,7 +1416,7 @@
 
         parcel.writeInt(mActions);
 
-        parcel.writeInt(mGranularities);
+        parcel.writeInt(mMovementGranularities);
 
         parcel.writeInt(mBooleanProperties);
 
@@ -1446,7 +1450,7 @@
         mContentDescription = other.mContentDescription;
         mActions= other.mActions;
         mBooleanProperties = other.mBooleanProperties;
-        mGranularities = other.mGranularities;
+        mMovementGranularities = other.mMovementGranularities;
         final int otherChildIdCount = other.mChildNodeIds.size();
         for (int i = 0; i < otherChildIdCount; i++) {
             mChildNodeIds.put(i, other.mChildNodeIds.valueAt(i));    
@@ -1484,7 +1488,7 @@
 
         mActions = parcel.readInt();
 
-        mGranularities = parcel.readInt();
+        mMovementGranularities = parcel.readInt();
 
         mBooleanProperties = parcel.readInt();
 
@@ -1503,7 +1507,7 @@
         mParentNodeId = ROOT_NODE_ID;
         mWindowId = UNDEFINED;
         mConnectionId = UNDEFINED;
-        mGranularities = 0;
+        mMovementGranularities = 0;
         mChildNodeIds.clear();
         mBoundsInParent.set(0, 0, 0, 0);
         mBoundsInScreen.set(0, 0, 0, 0);
@@ -1539,10 +1543,10 @@
                 return "ACTION_ACCESSIBILITY_FOCUS";
             case ACTION_CLEAR_ACCESSIBILITY_FOCUS:
                 return "ACTION_CLEAR_ACCESSIBILITY_FOCUS";
-            case ACTION_NEXT_AT_GRANULARITY:
-                return "ACTION_NEXT_AT_GRANULARITY";
-            case ACTION_PREVIOUS_AT_GRANULARITY:
-                return "ACTION_PREVIOUS_AT_GRANULARITY";
+            case ACTION_NEXT_AT_MOVEMENT_GRANULARITY:
+                return "ACTION_NEXT_AT_MOVEMENT_GRANULARITY";
+            case ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY:
+                return "ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY";
             case ACTION_NEXT_HTML_ELEMENT:
                 return "ACTION_NEXT_HTML_ELEMENT";
             case ACTION_PREVIOUS_HTML_ELEMENT:
@@ -1553,25 +1557,25 @@
     }
 
     /**
-     * Gets the human readable granularity symbolic name.
+     * Gets the human readable movement granularity symbolic name.
      *
-     * @param granularity The action.
+     * @param granularity The granularity.
      * @return The symbolic name.
      */
-    private static String getGranularitySymbolicName(int granularity) {
+    private static String getMovementGranularitySymbolicName(int granularity) {
         switch (granularity) {
-            case GRANULARITY_CHARACTER:
-                return "GRANULARITY_CHARACTER";
-            case GRANULARITY_WORD:
-                return "GRANULARITY_WORD";
-            case GRANULARITY_LINE:
-                return "GRANULARITY_LINE";
-            case GRANULARITY_PARAGRAPH:
-                return "GRANULARITY_PARAGRAPH";
-            case GRANULARITY_PAGE:
-                return "GRANULARITY_PAGE";
+            case MOVEMENT_GRANULARITY_CHARACTER:
+                return "MOVEMENT_GRANULARITY_CHARACTER";
+            case MOVEMENT_GRANULARITY_WORD:
+                return "MOVEMENT_GRANULARITY_WORD";
+            case MOVEMENT_GRANULARITY_LINE:
+                return "MOVEMENT_GRANULARITY_LINE";
+            case MOVEMENT_GRANULARITY_PARAGRAPH:
+                return "MOVEMENT_GRANULARITY_PARAGRAPH";
+            case MOVEMENT_GRANULARITY_PAGE:
+                return "MOVEMENT_GRANULARITY_PAGE";
             default:
-                throw new IllegalArgumentException("Unknown granularity: " + granularity);
+                throw new IllegalArgumentException("Unknown movement granularity: " + granularity);
         }
     }
 
@@ -1622,12 +1626,12 @@
             builder.append("; virtualDescendantId: " + getVirtualDescendantId(mSourceNodeId));
             builder.append("; mParentNodeId: " + mParentNodeId);
 
-            int granularities = mGranularities;
-            builder.append("; granularities: [");
+            int granularities = mMovementGranularities;
+            builder.append("; MovementGranularities: [");
             while (granularities != 0) {
                 final int granularity = 1 << Integer.numberOfTrailingZeros(granularities);
                 granularities &= ~granularity;
-                builder.append(getGranularitySymbolicName(granularity));
+                builder.append(getMovementGranularitySymbolicName(granularity));
                 if (granularities != 0) {
                     builder.append(", ");
                 }
diff --git a/core/java/android/widget/ActivityChooserModel.java b/core/java/android/widget/ActivityChooserModel.java
index c53b5f6..fba8d3a 100644
--- a/core/java/android/widget/ActivityChooserModel.java
+++ b/core/java/android/widget/ActivityChooserModel.java
@@ -761,6 +761,16 @@
     }
 
     /**
+     * Gets whether the given observer is already registered.
+     *
+     * @param observer The observer.
+     * @return True if already registered.
+     */
+    public boolean isRegisteredObserver(DataSetObserver observer) {
+        return mObservers.contains(observer);
+    }
+
+    /**
      * Represents a record in the history.
      */
     public final static class HistoricalRecord {
diff --git a/core/java/android/widget/ActivityChooserView.java b/core/java/android/widget/ActivityChooserView.java
index be6b4e2..0c0bb1e 100644
--- a/core/java/android/widget/ActivityChooserView.java
+++ b/core/java/android/widget/ActivityChooserView.java
@@ -20,8 +20,10 @@
 
 import android.content.Context;
 import android.content.Intent;
+import android.content.pm.ActivityInfo;
 import android.content.pm.PackageManager;
 import android.content.pm.ResolveInfo;
+import android.content.res.Configuration;
 import android.content.res.Resources;
 import android.content.res.TypedArray;
 import android.database.DataSetObserver;
@@ -174,6 +176,11 @@
     private int mDefaultActionButtonContentDescription;
 
     /**
+     * Whether this view has a default activity affordance.
+     */
+    private boolean mHasDefaultActivity;
+
+    /**
      * Create a new instance.
      *
      * @param context The application environment.
@@ -245,6 +252,8 @@
         Resources resources = context.getResources();
         mListPopupMaxWidth = Math.max(resources.getDisplayMetrics().widthPixels / 2,
               resources.getDimensionPixelSize(com.android.internal.R.dimen.config_prefDialogWidth));
+
+        updateHasDefaultActivity();
     }
 
     /**
@@ -258,6 +267,21 @@
         }
     }
 
+    @Override
+    protected void onConfigurationChanged(Configuration newConfig) {
+        Configuration oldConfig = mContext.getResources().getConfiguration();
+        final int changed = oldConfig.diff(newConfig);
+        if ((changed & ActivityInfo.CONFIG_SCREEN_SIZE) != 0
+                || (changed & ActivityInfo.CONFIG_ORIENTATION) != 0) {
+            updateHasDefaultActivity();
+        }
+    }
+
+    private void updateHasDefaultActivity() {
+        mHasDefaultActivity = mContext.getResources().getBoolean(
+                R.bool.activity_chooser_view_has_default_activity);
+    }
+
     /**
      * Sets the background for the button that expands the activity
      * overflow list.
@@ -383,7 +407,8 @@
     protected void onAttachedToWindow() {
         super.onAttachedToWindow();
         ActivityChooserModel dataModel = mAdapter.getDataModel();
-        if (dataModel != null) {
+        if (dataModel != null
+                && !dataModel.isRegisteredObserver(mModelDataSetOberver)) {
             dataModel.registerObserver(mModelDataSetOberver);
         }
         mIsAttachedToWindow = true;
@@ -393,7 +418,8 @@
     protected void onDetachedFromWindow() {
         super.onDetachedFromWindow();
         ActivityChooserModel dataModel = mAdapter.getDataModel();
-        if (dataModel != null) {
+        if (dataModel != null
+                && dataModel.isRegisteredObserver(mModelDataSetOberver)) {
             dataModel.unregisterObserver(mModelDataSetOberver);
         }
         ViewTreeObserver viewTreeObserver = getViewTreeObserver();
@@ -496,7 +522,7 @@
         // Default activity button.
         final int activityCount = mAdapter.getActivityCount();
         final int historySize = mAdapter.getHistorySize();
-        if (activityCount > 0 && historySize > 0) {
+        if (mHasDefaultActivity && activityCount > 0 && historySize > 0) {
             mDefaultActivityButton.setVisibility(VISIBLE);
             ResolveInfo activity = mAdapter.getDefaultActivity();
             PackageManager packageManager = mContext.getPackageManager();
@@ -512,9 +538,9 @@
         }
         // Activity chooser content.
         if (mDefaultActivityButton.getVisibility() == VISIBLE) {
-            mActivityChooserContent.setBackgroundDrawable(mActivityChooserContentBackground);
+            mActivityChooserContent.setBackground(mActivityChooserContentBackground);
         } else {
-            mActivityChooserContent.setBackgroundDrawable(null);
+            mActivityChooserContent.setBackground(null);
         }
     }
 
@@ -577,7 +603,7 @@
         // OnLongClickListener#onLongClick
         @Override
         public boolean onLongClick(View view) {
-            if (view == mDefaultActivityButton) {
+            if (mHasDefaultActivity && view == mDefaultActivityButton) {
                 if (mAdapter.getCount() > 0) {
                     mIsSelectingDefaultActivity = true;
                     showPopupUnchecked(mInitialActivityCount);
@@ -630,14 +656,16 @@
 
         public void setDataModel(ActivityChooserModel dataModel) {
             ActivityChooserModel oldDataModel = mAdapter.getDataModel();
-            if (oldDataModel != null && isShown()) {
+            if (oldDataModel != null) {
                 oldDataModel.unregisterObserver(mModelDataSetOberver);
             }
             mDataModel = dataModel;
-            if (dataModel != null && isShown()) {
+            if (dataModel != null) {
                 dataModel.registerObserver(mModelDataSetOberver);
+                notifyDataSetChanged();
+            } else {
+                notifyDataSetInvalidated();
             }
-            notifyDataSetChanged();
         }
 
         @Override
diff --git a/core/java/android/widget/AppSecurityPermissions.java b/core/java/android/widget/AppSecurityPermissions.java
index 5d8bdbb..64f6c07 100755
--- a/core/java/android/widget/AppSecurityPermissions.java
+++ b/core/java/android/widget/AppSecurityPermissions.java
@@ -98,6 +98,20 @@
         MyPermissionGroupInfo(PermissionGroupInfo info) {
             super(info);
         }
+
+        public Drawable loadGroupIcon(PackageManager pm) {
+            if (icon != 0) {
+                return loadIcon(pm);
+            } else {
+                ApplicationInfo appInfo;
+                try {
+                    appInfo = pm.getApplicationInfo(packageName, 0);
+                    return appInfo.loadIcon(pm);
+                } catch (NameNotFoundException e) {
+                }
+            }
+            return null;
+        }
     }
 
     static class MyPermissionInfo extends PermissionInfo {
@@ -155,16 +169,7 @@
             PackageManager pm = getContext().getPackageManager();
             Drawable icon = null;
             if (first) {
-                if (grp.icon != 0) {
-                    icon = grp.loadIcon(pm);
-                } else {
-                    ApplicationInfo appInfo;
-                    try {
-                        appInfo = pm.getApplicationInfo(grp.packageName, 0);
-                        icon = appInfo.loadIcon(pm);
-                    } catch (NameNotFoundException e) {
-                    }
-                }
+                icon = grp.loadGroupIcon(pm);
             }
             CharSequence label = perm.mLabel;
             if (perm.mNew && newPermPrefix != null) {
@@ -191,10 +196,28 @@
                 if (mDialog != null) {
                     mDialog.dismiss();
                 }
+                PackageManager pm = getContext().getPackageManager();
                 AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
                 builder.setTitle(mGroup.mLabel);
-                builder.setMessage(mPerm.loadDescription(getContext().getPackageManager()));
+                if (mPerm.descriptionRes != 0) {
+                    builder.setMessage(mPerm.loadDescription(pm));
+                } else {
+                    CharSequence appName;
+                    try {
+                        ApplicationInfo app = pm.getApplicationInfo(mPerm.packageName, 0);
+                        appName = app.loadLabel(pm);
+                    } catch (NameNotFoundException e) {
+                        appName = mPerm.packageName;
+                    }
+                    StringBuilder sbuilder = new StringBuilder(128);
+                    sbuilder.append(getContext().getString(
+                            R.string.perms_description_app, appName));
+                    sbuilder.append("\n\n");
+                    sbuilder.append(mPerm.name);
+                    builder.setMessage(sbuilder.toString());
+                }
                 builder.setCancelable(true);
+                builder.setIcon(mGroup.loadGroupIcon(pm));
                 mDialog = builder.show();
                 mDialog.setCanceledOnTouchOutside(true);
             }
@@ -611,9 +634,26 @@
         }
 
         for (MyPermissionGroupInfo pgrp : mPermGroups.values()) {
-            pgrp.mLabel = pgrp.loadLabel(mPm);
+            if (pgrp.labelRes != 0 || pgrp.nonLocalizedLabel != null) {
+                pgrp.mLabel = pgrp.loadLabel(mPm);
+            } else {
+                ApplicationInfo app;
+                try {
+                    app = mPm.getApplicationInfo(pgrp.packageName, 0);
+                    pgrp.mLabel = app.loadLabel(mPm);
+                } catch (NameNotFoundException e) {
+                    pgrp.mLabel = pgrp.loadLabel(mPm);
+                }
+            }
             mPermGroupsList.add(pgrp);
         }
         Collections.sort(mPermGroupsList, mPermGroupComparator);
+        if (false) {
+            for (MyPermissionGroupInfo grp : mPermGroupsList) {
+                Log.i("foo", "Group " + grp.name + " personal="
+                        + ((grp.flags&PermissionGroupInfo.FLAG_PERSONAL_INFO) != 0)
+                        + " priority=" + grp.priority);
+            }
+        }
     }
 }
diff --git a/core/java/android/widget/ShareActionProvider.java b/core/java/android/widget/ShareActionProvider.java
index 080b87d..367561e 100644
--- a/core/java/android/widget/ShareActionProvider.java
+++ b/core/java/android/widget/ShareActionProvider.java
@@ -44,6 +44,7 @@
  * <code>
  *  // In Activity#onCreateOptionsMenu
  *  public boolean onCreateOptionsMenu(Menu menu) {
+ *      getManuInflater().inflate(R.menu.my_menu, menu);
  *      // Get the menu item.
  *      MenuItem menuItem = menu.findItem(R.id.my_menu_item);
  *      // Get the provider and hold onto it to set/change the share intent.
@@ -239,7 +240,11 @@
      * <p>
      * <strong>Note:</strong> The history file name can be set any time, however
      * only the action views created by {@link #onCreateActionView()} after setting
-     * the file name will be backed by the provided file.
+     * the file name will be backed by the provided file. Hence, if you are using
+     * a share action provider on a menu item and want to change the history file
+     * based on the type of the currently selected item, you need to call
+     * {@link android.app.Activity#invalidateOptionsMenu()} to force the system
+     * to recreate the menu UI.
      * <p>
      *
      * @param shareHistoryFile The share history file name.
diff --git a/core/java/com/android/internal/app/ActionBarImpl.java b/core/java/com/android/internal/app/ActionBarImpl.java
index 93cf9d0..2cbd9cc902 100644
--- a/core/java/com/android/internal/app/ActionBarImpl.java
+++ b/core/java/com/android/internal/app/ActionBarImpl.java
@@ -39,8 +39,8 @@
 import android.content.res.Configuration;
 import android.content.res.Resources;
 import android.graphics.drawable.Drawable;
-import android.os.Build;
 import android.os.Handler;
+import android.util.Log;
 import android.util.TypedValue;
 import android.view.ActionMode;
 import android.view.ContextThemeWrapper;
@@ -110,10 +110,14 @@
 
     private int mCurWindowVisibility = View.VISIBLE;
 
+    private boolean mHiddenByApp;
+    private boolean mHiddenBySystem;
+    private boolean mShowingForMode;
+
+    private boolean mNowShowing = true;
+
     private Animator mCurrentShowAnim;
-    private Animator mCurrentModeAnim;
     private boolean mShowHideAnimationEnabled;
-    boolean mWasHiddenBeforeMode;
 
     final AnimatorListener mHideListener = new AnimatorListenerAdapter() {
         @Override
@@ -129,6 +133,9 @@
             mContainerView.setTransitioning(false);
             mCurrentShowAnim = null;
             completeDeferredDestroyActionMode();
+            if (mOverlayLayout != null) {
+                mOverlayLayout.requestFitSystemWindows();
+            }
         }
     };
 
@@ -430,16 +437,13 @@
     }
 
     public ActionMode startActionMode(ActionMode.Callback callback) {
-        boolean wasHidden = false;
         if (mActionMode != null) {
-            wasHidden = mWasHiddenBeforeMode;
             mActionMode.finish();
         }
 
         mContextView.killMode();
         ActionModeImpl mode = new ActionModeImpl(callback);
         if (mode.dispatchOnCreate()) {
-            mWasHiddenBeforeMode = !isShowing() || wasHidden;
             mode.invalidate();
             mContextView.initForMode(mode);
             animateToMode(true);
@@ -584,21 +588,91 @@
 
     @Override
     public void show() {
-        show(true, false);
+        if (mHiddenByApp) {
+            mHiddenByApp = false;
+            updateVisibility(false);
+        }
     }
 
-    public void show(boolean markHiddenBeforeMode, boolean alwaysAnimate) {
+    private void showForActionMode() {
+        if (!mShowingForMode) {
+            mShowingForMode = true;
+            if (mOverlayLayout != null) {
+                mOverlayLayout.setShowingForActionMode(true);
+            }
+            updateVisibility(false);
+        }
+    }
+
+    public void showForSystem() {
+        if (mHiddenBySystem) {
+            mHiddenBySystem = false;
+            updateVisibility(true);
+        }
+    }
+
+    @Override
+    public void hide() {
+        if (!mHiddenByApp) {
+            mHiddenByApp = true;
+            updateVisibility(false);
+        }
+    }
+
+    private void hideForActionMode() {
+        if (mShowingForMode) {
+            mShowingForMode = false;
+            if (mOverlayLayout != null) {
+                mOverlayLayout.setShowingForActionMode(false);
+            }
+            updateVisibility(false);
+        }
+    }
+
+    public void hideForSystem() {
+        if (!mHiddenBySystem) {
+            mHiddenBySystem = true;
+            updateVisibility(true);
+        }
+    }
+
+    private static boolean checkShowingFlags(boolean hiddenByApp, boolean hiddenBySystem,
+            boolean showingForMode) {
+        if (showingForMode) {
+            return true;
+        } else if (hiddenByApp || hiddenBySystem) {
+            return false;
+        } else {
+            return true;
+        }
+    }
+
+    private void updateVisibility(boolean fromSystem) {
+        // Based on the current state, should we be hidden or shown?
+        final boolean shown = checkShowingFlags(mHiddenByApp, mHiddenBySystem,
+                mShowingForMode);
+
+        if (shown) {
+            if (!mNowShowing) {
+                mNowShowing = true;
+                doShow(fromSystem);
+            }
+        } else {
+            if (mNowShowing) {
+                mNowShowing = false;
+                doHide(fromSystem);
+            }
+        }
+    }
+
+    public void doShow(boolean fromSystem) {
         if (mCurrentShowAnim != null) {
             mCurrentShowAnim.end();
         }
-        if (mTopVisibilityView.getVisibility() == View.VISIBLE) {
-            if (markHiddenBeforeMode) mWasHiddenBeforeMode = false;
-            return;
-        }
         mTopVisibilityView.setVisibility(View.VISIBLE);
 
         if (mCurWindowVisibility == View.VISIBLE && (mShowHideAnimationEnabled
-                || alwaysAnimate)) {
+                || fromSystem)) {
             mTopVisibilityView.setAlpha(0);
             mTopVisibilityView.setTranslationY(-mTopVisibilityView.getHeight());
             AnimatorSet anim = new AnimatorSet();
@@ -619,6 +693,16 @@
                     com.android.internal.R.interpolator.decelerate_quad));
             anim.setDuration(mContext.getResources().getInteger(
                     com.android.internal.R.integer.config_mediumAnimTime));
+            // If this is being shown from the system, add a small delay.
+            // This is because we will also be animating in the status bar,
+            // and these two elements can't be done in lock-step.  So we give
+            // a little time for the status bar to start its animation before
+            // the action bar animates.  (This corresponds to the corresponding
+            // case when hiding, where the status bar has a small delay before
+            // starting.)
+            if (fromSystem) {
+                anim.setStartDelay(100);
+            }
             anim.addListener(mShowListener);
             mCurrentShowAnim = anim;
             anim.start();
@@ -627,23 +711,18 @@
             mContainerView.setTranslationY(0);
             mShowListener.onAnimationEnd(null);
         }
+        if (mOverlayLayout != null) {
+            mOverlayLayout.requestFitSystemWindows();
+        }
     }
 
-    @Override
-    public void hide() {
-        hide(false);
-    }
-
-    public void hide(boolean alwaysAnimate) {
+    public void doHide(boolean fromSystem) {
         if (mCurrentShowAnim != null) {
             mCurrentShowAnim.end();
         }
-        if (mTopVisibilityView.getVisibility() == View.GONE) {
-            return;
-        }
 
         if (mCurWindowVisibility == View.VISIBLE && (mShowHideAnimationEnabled
-                || alwaysAnimate)) {
+                || fromSystem)) {
             mTopVisibilityView.setAlpha(1);
             mContainerView.setTransitioning(true);
             AnimatorSet anim = new AnimatorSet();
@@ -673,15 +752,18 @@
     }
 
     public boolean isShowing() {
-        return mTopVisibilityView.getVisibility() == View.VISIBLE;
+        return mNowShowing;
+    }
+
+    public boolean isSystemShowing() {
+        return !mHiddenBySystem;
     }
 
     void animateToMode(boolean toActionMode) {
         if (toActionMode) {
-            show(false, false);
-        }
-        if (mCurrentModeAnim != null) {
-            mCurrentModeAnim.end();
+            showForActionMode();
+        } else {
+            hideForActionMode();
         }
 
         mActionView.animateToVisibility(toActionMode ? View.GONE : View.VISIBLE);
@@ -740,11 +822,13 @@
                 return;
             }
 
-            // If we were hidden before the mode was shown, defer the onDestroy
-            // callback until the animation is finished and associated relayout
-            // is about to happen. This lets apps better anticipate visibility
-            // and layout behavior.
-            if (mWasHiddenBeforeMode) {
+            // If this change in state is going to cause the action bar
+            // to be hidden, defer the onDestroy callback until the animation
+            // is finished and associated relayout is about to happen. This lets
+            // apps better anticipate visibility and layout behavior.
+            if (!checkShowingFlags(mHiddenByApp, mHiddenBySystem, false)) {
+                // With the current state but the action bar hidden, our
+                // overall showing state is going to be false.
                 mDeferredDestroyActionMode = this;
                 mDeferredModeDestroyCallback = mCallback;
             } else {
@@ -758,10 +842,6 @@
             mActionView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
 
             mActionMode = null;
-
-            if (mWasHiddenBeforeMode) {
-                hide();
-            }
         }
 
         @Override
diff --git a/core/java/com/android/internal/app/ResolverActivity.java b/core/java/com/android/internal/app/ResolverActivity.java
index 51bbdf1..7867efd 100644
--- a/core/java/com/android/internal/app/ResolverActivity.java
+++ b/core/java/com/android/internal/app/ResolverActivity.java
@@ -19,15 +19,17 @@
 import com.android.internal.R;
 import com.android.internal.content.PackageMonitor;
 
+import android.app.ActivityManager;
 import android.content.ComponentName;
 import android.content.Context;
-import android.content.DialogInterface;
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.content.pm.ActivityInfo;
 import android.content.pm.LabeledIntent;
 import android.content.pm.PackageManager;
+import android.content.pm.PackageManager.NameNotFoundException;
 import android.content.pm.ResolveInfo;
+import android.content.res.Resources;
 import android.graphics.drawable.Drawable;
 import android.net.Uri;
 import android.os.Bundle;
@@ -38,8 +40,8 @@
 import android.view.ViewGroup;
 import android.widget.AdapterView;
 import android.widget.BaseAdapter;
-import android.widget.CheckBox;
-import android.widget.CompoundButton;
+import android.widget.Button;
+import android.widget.GridView;
 import android.widget.ImageView;
 import android.widget.ListView;
 import android.widget.TextView;
@@ -56,12 +58,20 @@
  * which there is more than one matching activity, allowing the user to decide
  * which to go to.  It is not normally used directly by application developers.
  */
-public class ResolverActivity extends AlertActivity implements
-        DialogInterface.OnClickListener, CheckBox.OnCheckedChangeListener {
+public class ResolverActivity extends AlertActivity implements AdapterView.OnItemClickListener {
+    private static final String TAG = "ResolverActivity";
+
     private ResolveListAdapter mAdapter;
-    private CheckBox mAlwaysCheck;
-    private TextView mClearDefaultHint;
     private PackageManager mPm;
+    private boolean mAlwaysUseOption;
+    private boolean mShowExtended;
+    private GridView mGrid;
+    private Button mAlwaysButton;
+    private Button mOnceButton;
+    private int mIconDpi;
+    private int mIconSize;
+
+    private static final int MAX_COLUMNS = 4;
 
     private boolean mRegistered;
     private final PackageMonitor mPackageMonitor = new PackageMonitor() {
@@ -91,33 +101,37 @@
     protected void onCreate(Bundle savedInstanceState, Intent intent,
             CharSequence title, Intent[] initialIntents, List<ResolveInfo> rList,
             boolean alwaysUseOption) {
+        setTheme(R.style.Theme_DeviceDefault_Light_Dialog_Alert);
         super.onCreate(savedInstanceState);
         mPm = getPackageManager();
+        mAlwaysUseOption = alwaysUseOption;
         intent.setComponent(null);
 
         AlertController.AlertParams ap = mAlertParams;
 
         ap.mTitle = title;
-        ap.mOnClickListener = this;
 
         mPackageMonitor.register(this, getMainLooper(), false);
         mRegistered = true;
 
-        if (alwaysUseOption) {
-            LayoutInflater inflater = (LayoutInflater) getSystemService(
-                    Context.LAYOUT_INFLATER_SERVICE);
-            ap.mView = inflater.inflate(R.layout.always_use_checkbox, null);
-            mAlwaysCheck = (CheckBox)ap.mView.findViewById(com.android.internal.R.id.alwaysUse);
-            mAlwaysCheck.setText(R.string.alwaysUse);
-            mAlwaysCheck.setOnCheckedChangeListener(this);
-            mClearDefaultHint = (TextView)ap.mView.findViewById(
-                                                        com.android.internal.R.id.clearDefaultHint);
-            mClearDefaultHint.setVisibility(View.GONE);
-        }
+        final ActivityManager am = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
+        mIconDpi = am.getLauncherLargeIconDensity();
+        mIconSize = am.getLauncherLargeIconSize();
+
         mAdapter = new ResolveListAdapter(this, intent, initialIntents, rList);
         int count = mAdapter.getCount();
         if (count > 1) {
-            ap.mAdapter = mAdapter;
+            ap.mView = getLayoutInflater().inflate(R.layout.resolver_grid, null);
+            mGrid = (GridView) ap.mView.findViewById(R.id.resolver_grid);
+            mGrid.setAdapter(mAdapter);
+            mGrid.setOnItemClickListener(this);
+            mGrid.setOnItemLongClickListener(new ItemLongClickListener());
+
+            if (alwaysUseOption) {
+                mGrid.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
+            }
+
+            resizeGrid();
         } else if (count == 1) {
             startActivity(mAdapter.intentForPosition(0));
             mPackageMonitor.unregister();
@@ -125,17 +139,57 @@
             finish();
             return;
         } else {
-            ap.mMessage = getResources().getText(com.android.internal.R.string.noApplications);
+            ap.mMessage = getResources().getText(R.string.noApplications);
         }
 
         setupAlert();
 
-        ListView lv = mAlert.getListView();
-        if (lv != null) {
-            lv.setOnItemLongClickListener(new ItemLongClickListener());
+        if (alwaysUseOption) {
+            final ViewGroup buttonLayout = (ViewGroup) findViewById(R.id.button_bar);
+            buttonLayout.setVisibility(View.VISIBLE);
+            mAlwaysButton = (Button) buttonLayout.findViewById(R.id.button_always);
+            mOnceButton = (Button) buttonLayout.findViewById(R.id.button_once);
         }
     }
 
+    void resizeGrid() {
+        final int itemCount = mAdapter.getCount();
+        mGrid.setNumColumns(Math.min(itemCount, MAX_COLUMNS));
+    }
+
+    Drawable getIcon(Resources res, int resId) {
+        Drawable result;
+        try {
+            result = res.getDrawableForDensity(resId, mIconDpi);
+        } catch (Resources.NotFoundException e) {
+            result = null;
+        }
+
+        return result;
+    }
+
+    Drawable loadIconForResolveInfo(ResolveInfo ri) {
+        Drawable dr;
+        try {
+            if (ri.resolvePackageName != null && ri.icon != 0) {
+                dr = getIcon(mPm.getResourcesForApplication(ri.resolvePackageName), ri.icon);
+                if (dr != null) {
+                    return dr;
+                }
+            }
+            final int iconRes = ri.getIconResource();
+            if (iconRes != 0) {
+                dr = getIcon(mPm.getResourcesForApplication(ri.activityInfo.packageName), iconRes);
+                if (dr != null) {
+                    return dr;
+                }
+            }
+        } catch (NameNotFoundException e) {
+            Log.e(TAG, "Couldn't find resources for package", e);
+        }
+        return ri.loadIcon(mPm);
+    }
+
     @Override
     protected void onRestart() {
         super.onRestart();
@@ -155,11 +209,28 @@
         }
     }
 
-    public void onClick(DialogInterface dialog, int which) {
+    @Override
+    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
+        if (mAlwaysUseOption) {
+            final int checkedPos = mGrid.getCheckedItemPosition();
+            final boolean enabled = checkedPos != GridView.INVALID_POSITION;
+            mAlwaysButton.setEnabled(enabled);
+            mOnceButton.setEnabled(enabled);
+        } else {
+            startSelected(position, false);
+        }
+    }
+
+    public void onButtonClick(View v) {
+        final int id = v.getId();
+        startSelected(mGrid.getCheckedItemPosition(), id == R.id.button_always);
+        dismiss();
+    }
+
+    void startSelected(int which, boolean always) {
         ResolveInfo ri = mAdapter.resolveInfoForPosition(which);
         Intent intent = mAdapter.intentForPosition(which);
-        boolean alwaysCheck = (mAlwaysCheck != null && mAlwaysCheck.isChecked());
-        onIntentSelected(ri, intent, alwaysCheck);
+        onIntentSelected(ri, intent, always);
         finish();
     }
 
@@ -249,6 +320,12 @@
         }
     }
 
+    void showAppDetails(ResolveInfo ri) {
+        Intent in = new Intent().setAction("android.settings.APPLICATION_DETAILS_SETTINGS")
+                .setData(Uri.fromParts("package", ri.activityInfo.packageName, null));
+        startActivity(in);
+    }
+
     private final class DisplayResolveInfo {
         ResolveInfo ri;
         CharSequence displayLabel;
@@ -285,12 +362,18 @@
         }
 
         public void handlePackagesChanged() {
+            final int oldItemCount = getCount();
             rebuildList();
             notifyDataSetChanged();
             if (mList.size() <= 0) {
                 // We no longer have any items...  just finish the activity.
                 finish();
             }
+
+            final int newItemCount = getCount();
+            if (newItemCount != oldItemCount) {
+                resizeGrid();
+            }
         }
 
         private void rebuildList() {
@@ -299,7 +382,7 @@
             } else {
                 mCurrentResolveList = mPm.queryIntentActivities(
                         mIntent, PackageManager.MATCH_DEFAULT_ONLY
-                        | (mAlwaysCheck != null ? PackageManager.GET_RESOLVED_FILTER : 0));
+                        | (mAlwaysUseOption ? PackageManager.GET_RESOLVED_FILTER : 0));
             }
             int N;
             if ((mCurrentResolveList != null) && ((N = mCurrentResolveList.size()) > 0)) {
@@ -363,6 +446,7 @@
                 r0 = mCurrentResolveList.get(0);
                 int start = 0;
                 CharSequence r0Label =  r0.loadLabel(mPm);
+                mShowExtended = false;
                 for (int i = 1; i < N; i++) {
                     if (r0Label == null) {
                         r0Label = r0.activityInfo.packageName;
@@ -393,6 +477,7 @@
                 // No duplicate labels. Use label for entry at start
                 mList.add(new DisplayResolveInfo(ro, roLabel, null, null));
             } else {
+                mShowExtended = true;
                 boolean usePkg = false;
                 CharSequence startApp = ro.activityInfo.applicationInfo.loadLabel(mPm);
                 if (startApp == null) {
@@ -473,6 +558,11 @@
             if (convertView == null) {
                 view = mInflater.inflate(
                         com.android.internal.R.layout.resolve_list_item, parent, false);
+
+                // Fix the icon size even if we have different sized resources
+                ImageView icon = (ImageView)view.findViewById(R.id.icon);
+                ViewGroup.LayoutParams lp = (ViewGroup.LayoutParams) icon.getLayoutParams();
+                lp.width = lp.height = mIconSize;
             } else {
                 view = convertView;
             }
@@ -485,37 +575,25 @@
             TextView text2 = (TextView)view.findViewById(com.android.internal.R.id.text2);
             ImageView icon = (ImageView)view.findViewById(R.id.icon);
             text.setText(info.displayLabel);
-            if (info.extendedInfo != null) {
+            if (mShowExtended) {
                 text2.setVisibility(View.VISIBLE);
                 text2.setText(info.extendedInfo);
             } else {
                 text2.setVisibility(View.GONE);
             }
             if (info.displayIcon == null) {
-                info.displayIcon = info.ri.loadIcon(mPm);
+                info.displayIcon = loadIconForResolveInfo(info.ri);
             }
             icon.setImageDrawable(info.displayIcon);
         }
     }
 
-    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
-        if (mClearDefaultHint == null) return;
-
-        if(isChecked) {
-            mClearDefaultHint.setVisibility(View.VISIBLE);
-        } else {
-            mClearDefaultHint.setVisibility(View.GONE);
-        }
-    }
-
     class ItemLongClickListener implements AdapterView.OnItemLongClickListener {
 
         @Override
         public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
             ResolveInfo ri = mAdapter.resolveInfoForPosition(position);
-            Intent in = new Intent().setAction("android.settings.APPLICATION_DETAILS_SETTINGS")
-                    .setData(Uri.fromParts("package", ri.activityInfo.packageName, null));
-            startActivity(in);
+            showAppDetails(ri);
             return true;
         }
 
diff --git a/core/java/com/android/internal/view/menu/ActionMenuItemView.java b/core/java/com/android/internal/view/menu/ActionMenuItemView.java
index d5c2018..449194b 100644
--- a/core/java/com/android/internal/view/menu/ActionMenuItemView.java
+++ b/core/java/com/android/internal/view/menu/ActionMenuItemView.java
@@ -70,8 +70,13 @@
         setOnClickListener(this);
         setOnLongClickListener(this);
 
-        // Save the inflated padding for later, we'll need it.
-        mSavedPaddingLeft = getPaddingLeft();
+        mSavedPaddingLeft = -1;
+    }
+
+    @Override
+    public void setPadding(int l, int t, int r, int b) {
+        mSavedPaddingLeft = l;
+        super.setPadding(l, t, r, b);
     }
 
     public MenuItemImpl getItemData() {
@@ -217,8 +222,9 @@
     @Override
     protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
         final boolean textVisible = hasText();
-        if (textVisible) {
-            setPadding(mSavedPaddingLeft, getPaddingTop(), getPaddingRight(), getPaddingBottom());
+        if (textVisible && mSavedPaddingLeft >= 0) {
+            super.setPadding(mSavedPaddingLeft, getPaddingTop(),
+                    getPaddingRight(), getPaddingBottom());
         }
 
         super.onMeasure(widthMeasureSpec, heightMeasureSpec);
@@ -240,7 +246,7 @@
             // a little coercion. Pad in to center the icon after we've measured.
             final int w = getMeasuredWidth();
             final int dw = mIcon.getIntrinsicWidth();
-            setPadding((w - dw) / 2, getPaddingTop(), getPaddingRight(), getPaddingBottom());
+            super.setPadding((w - dw) / 2, getPaddingTop(), getPaddingRight(), getPaddingBottom());
         }
     }
 }
diff --git a/core/java/com/android/internal/view/menu/ActionMenuView.java b/core/java/com/android/internal/view/menu/ActionMenuView.java
index af67d55..f54575b 100644
--- a/core/java/com/android/internal/view/menu/ActionMenuView.java
+++ b/core/java/com/android/internal/view/menu/ActionMenuView.java
@@ -17,6 +17,7 @@
 
 import android.content.Context;
 import android.content.res.Configuration;
+import android.content.res.TypedArray;
 import android.util.AttributeSet;
 import android.view.Gravity;
 import android.view.View;
@@ -25,6 +26,8 @@
 import android.view.accessibility.AccessibilityEvent;
 import android.widget.LinearLayout;
 
+import com.android.internal.R;
+
 /**
  * @hide
  */
@@ -43,6 +46,7 @@
     private int mMinCellSize;
     private int mGeneratedItemPadding;
     private int mMeasuredExtraWidth;
+    private int mMaxItemHeight;
 
     public ActionMenuView(Context context) {
         this(context, null);
@@ -54,6 +58,11 @@
         final float density = context.getResources().getDisplayMetrics().density;
         mMinCellSize = (int) (MIN_CELL_SIZE * density);
         mGeneratedItemPadding = (int) (GENERATED_ITEM_PADDING * density);
+
+        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ActionBar,
+                R.attr.actionBarStyle, 0);
+        mMaxItemHeight = a.getDimensionPixelSize(R.styleable.ActionBar_height, 0);
+        a.recycle();
     }
 
     public void setPresenter(ActionMenuPresenter presenter) {
@@ -116,6 +125,11 @@
         final int widthPadding = getPaddingLeft() + getPaddingRight();
         final int heightPadding = getPaddingTop() + getPaddingBottom();
 
+        final int itemHeightSpec = heightMode == MeasureSpec.EXACTLY
+                ? MeasureSpec.makeMeasureSpec(heightSize - heightPadding, MeasureSpec.EXACTLY)
+                : MeasureSpec.makeMeasureSpec(
+                    Math.min(mMaxItemHeight, heightSize - heightPadding), MeasureSpec.AT_MOST);
+
         widthSize -= widthPadding;
 
         // Divide the view into cells.
@@ -167,7 +181,7 @@
             final int cellsAvailable = lp.isOverflowButton ? 1 : cellsRemaining;
 
             final int cellsUsed = measureChildForCells(child, cellSize, cellsAvailable,
-                    heightMeasureSpec, heightPadding);
+                    itemHeightSpec, heightPadding);
 
             maxCellsUsed = Math.max(maxCellsUsed, cellsUsed);
             if (lp.expandable) expandableItemCount++;
@@ -298,7 +312,6 @@
 
         // Remeasure any items that have had extra space allocated to them.
         if (needsExpansion) {
-            int heightSpec = MeasureSpec.makeMeasureSpec(heightSize - heightPadding, heightMode);
             for (int i = 0; i < childCount; i++) {
                 final View child = getChildAt(i);
                 final LayoutParams lp = (LayoutParams) child.getLayoutParams();
@@ -306,7 +319,8 @@
                 if (!lp.expanded) continue;
 
                 final int width = lp.cellsUsed * cellSize + lp.extraPixels;
-                child.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), heightSpec);
+                child.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
+                        itemHeightSpec);
             }
         }
 
diff --git a/core/java/com/android/internal/widget/ActionBarOverlayLayout.java b/core/java/com/android/internal/widget/ActionBarOverlayLayout.java
index d1652df..a129496 100644
--- a/core/java/com/android/internal/widget/ActionBarOverlayLayout.java
+++ b/core/java/com/android/internal/widget/ActionBarOverlayLayout.java
@@ -22,6 +22,7 @@
 import android.content.res.TypedArray;
 import android.graphics.Rect;
 import android.util.AttributeSet;
+import android.util.Log;
 import android.view.View;
 import android.widget.FrameLayout;
 
@@ -76,6 +77,26 @@
         }
     }
 
+    public void setShowingForActionMode(boolean showing) {
+        if (showing) {
+            // Here's a fun hack: if the status bar is currently being hidden,
+            // and the application has asked for stable content insets, then
+            // we will end up with the action mode action bar being shown
+            // without the status bar, but moved below where the status bar
+            // would be.  Not nice.  Trying to have this be positioned
+            // correctly is not easy (basically we need yet *another* content
+            // inset from the window manager to know where to put it), so
+            // instead we will just temporarily force the status bar to be shown.
+            if ((getWindowSystemUiVisibility() & (SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
+                    | SYSTEM_UI_FLAG_LAYOUT_STABLE))
+                    == (SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | SYSTEM_UI_FLAG_LAYOUT_STABLE)) {
+                setDisabledSystemUiVisibility(SYSTEM_UI_FLAG_FULLSCREEN);
+            }
+        } else {
+            setDisabledSystemUiVisibility(0);
+        }
+    }
+
     @Override
     public void onWindowSystemUiVisibilityChanged(int visible) {
         super.onWindowSystemUiVisibilityChanged(visible);
@@ -83,11 +104,13 @@
         final int diff = mLastSystemUiVisibility ^ visible;
         mLastSystemUiVisibility = visible;
         final boolean barVisible = (visible&SYSTEM_UI_FLAG_FULLSCREEN) == 0;
-        final boolean wasVisible = mActionBar != null ? mActionBar.isShowing() : true;
-        if (barVisible != wasVisible || (diff&SYSTEM_UI_FLAG_LAYOUT_STABLE) != 0) {
+        final boolean wasVisible = mActionBar != null ? mActionBar.isSystemShowing() : true;
+        if (mActionBar != null) {
+            if (barVisible) mActionBar.showForSystem();
+            else mActionBar.hideForSystem();
+        }
+        if ((diff&SYSTEM_UI_FLAG_LAYOUT_STABLE) != 0) {
             if (mActionBar != null) {
-                if (barVisible) mActionBar.show(true, true);
-                else mActionBar.hide(true);
                 requestFitSystemWindows();
             }
         }
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index bd1f574..e16e49a 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -155,9 +155,10 @@
          receiving or reading an MMS. -->
     <permission-group android:name="android.permission-group.MESSAGES"
         android:label="@string/permgrouplab_messages"
+        android:icon="@drawable/perm_group_messages"
         android:description="@string/permgroupdesc_messages"
         android:permissionGroupFlags="personalInfo"
-        android:priority="2"/>
+        android:priority="360"/>
 
   <!-- Allows an application to send SMS messages. -->
     <permission android:name="android.permission.SEND_SMS"
@@ -250,9 +251,10 @@
 
     <permission-group android:name="android.permission-group.SOCIAL_INFO"
         android:label="@string/permgrouplab_socialInfo"
+        android:icon="@drawable/perm_group_social_info"
         android:description="@string/permgroupdesc_socialInfo"
         android:permissionGroupFlags="personalInfo"
-        android:priority="6" />
+        android:priority="320" />
 
     <!-- Allows an application to read the user's contacts data. -->
     <permission android:name="android.permission.READ_CONTACTS"
@@ -310,9 +312,10 @@
          distinct permissions). -->
     <permission-group android:name="android.permission-group.PERSONAL_INFO"
         android:label="@string/permgrouplab_personalInfo"
+        android:icon="@drawable/perm_group_personal_info"
         android:description="@string/permgroupdesc_personalInfo"
         android:permissionGroupFlags="personalInfo"
-        android:priority="7" />
+        android:priority="310" />
 
     <!-- Allows an application to read the user's personal profile data. -->
     <permission android:name="android.permission.READ_PROFILE"
@@ -338,9 +341,10 @@
          calendar to create / view events.-->
     <permission-group android:name="android.permission-group.CALENDAR"
         android:label="@string/permgrouplab_calendar"
+        android:icon="@drawable/perm_group_calendar"
         android:description="@string/permgroupdesc_calendar"
         android:permissionGroupFlags="personalInfo"
-        android:priority="9" />
+        android:priority="290" />
 
     <!-- Allows an application to read the user's calendar data. -->
     <permission android:name="android.permission.READ_CALENDAR"
@@ -366,9 +370,10 @@
          calendar to create / view events.-->
     <permission-group android:name="android.permission-group.USER_DICTIONARY"
         android:label="@string/permgrouplab_dictionary"
+        android:icon="@drawable/perm_group_user_dictionary"
         android:description="@string/permgroupdesc_dictionary"
         android:permissionGroupFlags="personalInfo"
-        android:priority="20" />
+        android:priority="170" />
 
     <!-- Allows an application to read the user dictionary. This should
          really only be required by an IME, or a dictionary editor like
@@ -379,9 +384,18 @@
         android:label="@string/permlab_readDictionary"
         android:description="@string/permdesc_readDictionary" />
 
+    <!-- Used for permissions that provide access to the user
+         calendar to create / view events.-->
+    <permission-group android:name="android.permission-group.WRITE_USER_DICTIONARY"
+        android:label="@string/permgrouplab_writeDictionary"
+        android:icon="@drawable/perm_group_user_dictionary_write"
+        android:description="@string/permgroupdesc_writeDictionary"
+        android:permissionGroupFlags="personalInfo"
+        android:priority="160" />
+
     <!-- Allows an application to write to the user dictionary. -->
     <permission android:name="android.permission.WRITE_USER_DICTIONARY"
-        android:permissionGroup="android.permission-group.USER_DICTIONARY"
+        android:permissionGroup="android.permission-group.WRITE_USER_DICTIONARY"
         android:protectionLevel="normal"
         android:label="@string/permlab_writeDictionary"
         android:description="@string/permdesc_writeDictionary" />
@@ -395,9 +409,10 @@
          bookmarks and browser history.-->
     <permission-group android:name="android.permission-group.BOOKMARKS"
         android:label="@string/permgrouplab_bookmarks"
+        android:icon="@drawable/perm_group_bookmarks"
         android:description="@string/permgroupdesc_bookmarks"
         android:permissionGroupFlags="personalInfo"
-        android:priority="8" />
+        android:priority="300" />
 
     <!-- Allows an application to read (but not write) the user's
         browsing history and bookmarks. -->
@@ -423,9 +438,10 @@
     <!-- Used for permissions that provide access to the user voicemail box. -->
     <permission-group android:name="android.permission-group.DEVICE_ALARMS"
         android:label="@string/permgrouplab_deviceAlarms"
+        android:icon="@drawable/perm_group_device_alarms"
         android:description="@string/permgroupdesc_deviceAlarms"
         android:permissionGroupFlags="personalInfo"
-        android:priority="16"/>
+        android:priority="210" />
 
     <!-- Allows an application to broadcast an Intent to set an alarm for the
          user. -->
@@ -443,9 +459,10 @@
     <!-- Used for permissions that provide access to the user voicemail box. -->
     <permission-group android:name="android.permission-group.VOICEMAIL"
         android:label="@string/permgrouplab_voicemail"
+        android:icon="@drawable/perm_group_voicemail"
         android:description="@string/permgroupdesc_voicemail"
         android:permissionGroupFlags="personalInfo"
-        android:priority="10" />
+        android:priority="280" />
 
    <!-- Allows an application to add voicemails into the system. -->
     <permission android:name="com.android.voicemail.permission.ADD_VOICEMAIL"
@@ -463,9 +480,10 @@
          location. -->
     <permission-group android:name="android.permission-group.LOCATION"
         android:label="@string/permgrouplab_location"
+        android:icon="@drawable/perm_group_location"
         android:description="@string/permgroupdesc_location"
         android:permissionGroupFlags="personalInfo"
-        android:priority="5" />
+        android:priority="330" />
 
     <!-- Allows an application to access fine (e.g., GPS) location -->
     <permission android:name="android.permission.ACCESS_FINE_LOCATION"
@@ -512,8 +530,9 @@
          or other related network operations. -->
     <permission-group android:name="android.permission-group.NETWORK"
         android:label="@string/permgrouplab_network"
+        android:icon="@drawable/perm_group_network"
         android:description="@string/permgroupdesc_network"
-        android:priority="11" />
+        android:priority="270" />
 
     <!-- Allows applications to open network sockets. -->
     <permission android:name="android.permission.INTERNET"
@@ -562,28 +581,36 @@
     <!-- ======================================= -->
     <eat-comment />
 
-    <!-- Used for permissions that provide access to network services that
-         are for peripherals and other nearby devices.  These networks
-         generally do not provide IP based networking or internet access.-->
-    <permission-group android:name="android.permission-group.SHORTRANGE_NETWORK"
-        android:label="@string/permgrouplab_shortRangeNetwork"
-        android:description="@string/permgroupdesc_shortRangeNetwork"
-        android:priority="12" />
+    <!-- Used for permissions that provide access to other devices through Bluetooth.-->
+    <permission-group android:name="android.permission-group.BLUETOOTH_NETWORK"
+        android:label="@string/permgrouplab_bluetoothNetwork"
+        android:icon="@drawable/perm_group_bluetooth"
+        android:description="@string/permgroupdesc_bluetoothNetwork"
+        android:priority="260" />
 
     <!-- Allows applications to connect to paired bluetooth devices -->
     <permission android:name="android.permission.BLUETOOTH"
-        android:permissionGroup="android.permission-group.SHORTRANGE_NETWORK"
+        android:permissionGroup="android.permission-group.BLUETOOTH_NETWORK"
         android:protectionLevel="dangerous"
         android:description="@string/permdesc_bluetooth"
         android:label="@string/permlab_bluetooth" />
         
     <!-- Allows applications to discover and pair bluetooth devices -->
     <permission android:name="android.permission.BLUETOOTH_ADMIN"
-        android:permissionGroup="android.permission-group.SHORTRANGE_NETWORK"
+        android:permissionGroup="android.permission-group.BLUETOOTH_NETWORK"
         android:protectionLevel="dangerous"
         android:description="@string/permdesc_bluetoothAdmin"
         android:label="@string/permlab_bluetoothAdmin" />
    
+    <!-- Used for permissions that provide access to network services that
+         are for peripherals and other nearby devices.  These networks
+         generally do not provide IP based networking or internet access.-->
+    <permission-group android:name="android.permission-group.SHORTRANGE_NETWORK"
+        android:label="@string/permgrouplab_shortrangeNetwork"
+        android:icon="@drawable/perm_group_shortrange_network"
+        android:description="@string/permgroupdesc_shortrangeNetwork"
+        android:priority="250" />
+
     <!-- Allows applications to perform I/O operations over NFC -->
     <permission android:name="android.permission.NFC"
         android:permissionGroup="android.permission-group.SHORTRANGE_NETWORK"
@@ -607,9 +634,10 @@
          by the Account Manager. -->
     <permission-group android:name="android.permission-group.ACCOUNTS"
         android:label="@string/permgrouplab_accounts"
+        android:icon="@drawable/perm_group_accounts"
         android:description="@string/permgroupdesc_accounts"
         android:permissionGroupFlags="personalInfo"
-        android:priority="17" />
+        android:priority="200" />
 
     <!-- Allows access to the list of accounts in the Accounts Service -->
     <permission android:name="android.permission.GET_ACCOUNTS"
@@ -659,8 +687,9 @@
 
     <permission-group android:name="android.permission-group.AFFECTS_BATTERY"
         android:label="@string/permgrouplab_affectsBattery"
+        android:icon="@drawable/perm_group_affects_battery"
         android:description="@string/permgroupdesc_affectsBattery"
-        android:priority="19" />
+        android:priority="180" />
 
     <!-- Allows applications to enter Wi-Fi Multicast mode -->
     <permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE"
@@ -699,8 +728,9 @@
          the device. -->
     <permission-group android:name="android.permission-group.AUDIO_SETTINGS"
         android:label="@string/permgrouplab_audioSettings"
+        android:icon="@drawable/perm_group_audio_settings"
         android:description="@string/permgroupdesc_audioSettings"
-        android:priority="25" />
+        android:priority="130" />
 
     <!-- Allows an application to modify global audio settings -->
     <permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"
@@ -719,7 +749,7 @@
     <permission-group android:name="android.permission-group.HARDWARE_CONTROLS"
         android:label="@string/permgrouplab_hardwareControls"
         android:description="@string/permgroupdesc_hardwareControls"
-        android:priority="26"/>
+        android:priority="260"/>
 
     <!-- Allows an application to manage preferences and permissions for USB devices
          @hide -->
@@ -766,9 +796,10 @@
          but are in a separate (more visible) permission group. -->
     <permission-group android:name="android.permission-group.MICROPHONE"
         android:label="@string/permgrouplab_microphone"
+        android:icon="@drawable/perm_group_microphone"
         android:description="@string/permgroupdesc_microphone"
         android:permissionGroupFlags="personalInfo"
-        android:priority="4" />
+        android:priority="340" />
 
     <!-- Allows an application to record audio -->
     <permission android:name="android.permission.RECORD_AUDIO"
@@ -786,9 +817,10 @@
          camera or capturing images/video from the device. -->
     <permission-group android:name="android.permission-group.CAMERA"
         android:label="@string/permgrouplab_camera"
+        android:icon="@drawable/perm_group_camera"
         android:description="@string/permgroupdesc_camera"
         android:permissionGroupFlags="personalInfo"
-        android:priority="3" />
+        android:priority="350" />
 
     <!-- Required to be able to access the camera device.
          <p>This will automatically enforce the <a
@@ -813,9 +845,10 @@
          and modifying the phone state. -->
     <permission-group android:name="android.permission-group.PHONE_CALLS"
         android:label="@string/permgrouplab_phoneCalls"
+        android:icon="@drawable/perm_group_phone_calls"
         android:description="@string/permgroupdesc_phoneCalls"
         android:permissionGroupFlags="personalInfo"
-        android:priority="1" />
+        android:priority="370" />
 
     <!-- Allows an application to monitor, modify, or abort outgoing
          calls. -->
@@ -870,9 +903,10 @@
     <!-- Group of permissions that are related to SD card access. -->
     <permission-group android:name="android.permission-group.STORAGE"
         android:label="@string/permgrouplab_storage"
+        android:icon="@drawable/perm_group_storage"
         android:description="@string/permgroupdesc_storage"
         android:permissionGroupFlags="personalInfo"
-        android:priority="13" />
+        android:priority="240" />
 
     <!-- Allows an application to read from external storage -->
     <permission android:name="android.permission.READ_EXTERNAL_STORAGE"
@@ -904,8 +938,10 @@
     <!-- Group of permissions that are related to the screenlock. -->
     <permission-group android:name="android.permission-group.SCREENLOCK"
         android:label="@string/permgrouplab_storage"
+        android:icon="@drawable/perm_group_screenlock"
         android:permissionGroupFlags="personalInfo"
-        android:description="@string/permgroupdesc_storage" />
+        android:description="@string/permgroupdesc_storage"
+        android:priority="230" />
 
     <!-- Allows applications to disable the keyguard -->
     <permission android:name="android.permission.DISABLE_KEYGUARD"
@@ -924,7 +960,9 @@
          running apps, or killing background processes. -->
     <permission-group android:name="android.permission-group.APP_INFO"
         android:label="@string/permgrouplab_appInfo"
-        android:description="@string/permgroupdesc_appInfo" />
+        android:icon="@drawable/perm_group_app_info"
+        android:description="@string/permgroupdesc_appInfo"
+        android:priority="220" />
 
     <!-- Allows an application to get information about the currently
          or recently running tasks. -->
@@ -990,8 +1028,9 @@
          another application displays UI to the user. -->
     <permission-group android:name="android.permission-group.DISPLAY"
         android:label="@string/permgrouplab_display"
+        android:icon="@drawable/perm_group_display"
         android:description="@string/permgroupdesc_display"
-        android:priority="18"/>
+        android:priority="190"/>
 
     <!-- Allows an application to open windows using the type
          {@link android.view.WindowManager.LayoutParams#TYPE_SYSTEM_ALERT},
@@ -1013,8 +1052,9 @@
          another application displays UI to the user. -->
     <permission-group android:name="android.permission-group.WALLPAPER"
         android:label="@string/permgrouplab_wallpaper"
+        android:icon="@drawable/perm_group_wallpaper"
         android:description="@string/permgroupdesc_wallpaper"
-        android:priority="22" />
+        android:priority="150" />
 
     <!-- Allows applications to set the wallpaper -->
     <permission android:name="android.permission.SET_WALLPAPER"
@@ -1038,8 +1078,9 @@
     <!-- Group of permissions that are related to system clock. -->
     <permission-group android:name="android.permission-group.SYSTEM_CLOCK"
         android:label="@string/permgrouplab_systemClock"
+        android:icon="@drawable/perm_group_system_clock"
         android:description="@string/permgroupdesc_systemClock"
-        android:priority="23" />
+        android:priority="140" />
 
     <!-- Allows applications to set the system time -->
     <permission android:name="android.permission.SET_TIME"
@@ -1061,7 +1102,9 @@
     <!-- Used for permissions that change the status bar -->
     <permission-group android:name="android.permission-group.STATUS_BAR"
         android:label="@string/permgrouplab_statusBar"
-        android:description="@string/permgroupdesc_statusBar" />
+        android:icon="@drawable/perm_group_status_bar"
+        android:description="@string/permgroupdesc_statusBar"
+        android:priority="110" />
 
     <!-- Allows an application to expand or collapse the status bar. -->
     <permission android:name="android.permission.EXPAND_STATUS_BAR"
@@ -1078,8 +1121,9 @@
          related information. -->
     <permission-group android:name="android.permission-group.SYNC_SETTINGS"
         android:label="@string/permgrouplab_syncSettings"
+        android:icon="@drawable/perm_group_sync_settings"
         android:description="@string/permgroupdesc_syncSettings"
-        android:priority="29" />
+        android:priority="120" />
 
     <!-- Allows applications to read the sync settings -->
     <permission android:name="android.permission.READ_SYNC_SETTINGS"
@@ -1116,8 +1160,9 @@
          such as writing the global system settings. -->
     <permission-group android:name="android.permission-group.SYSTEM_TOOLS"
         android:label="@string/permgrouplab_systemTools"
+        android:icon="@drawable/perm_group_system_tools"
         android:description="@string/permgroupdesc_systemTools"
-        android:priority="30" />
+        android:priority="100" />
 
     <!-- @hide Change the screen compatibility mode of applications -->
     <permission android:name="android.permission.SET_SCREEN_COMPATIBILITY"
@@ -1345,7 +1390,7 @@
     <permission-group android:name="android.permission-group.DEVELOPMENT_TOOLS"
         android:label="@string/permgrouplab_developmentTools"
         android:description="@string/permgroupdesc_developmentTools"
-        android:priority="31" />
+        android:priority="310" />
 
     <!-- Allows an application to read or write the secure system settings. -->
     <permission android:name="android.permission.WRITE_SECURE_SETTINGS"
diff --git a/core/res/res/drawable-hdpi/perm_group_accounts.png b/core/res/res/drawable-hdpi/perm_group_accounts.png
new file mode 100644
index 0000000..db59ab0
--- /dev/null
+++ b/core/res/res/drawable-hdpi/perm_group_accounts.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/perm_group_affects_battery.png b/core/res/res/drawable-hdpi/perm_group_affects_battery.png
new file mode 100644
index 0000000..8ca8154
--- /dev/null
+++ b/core/res/res/drawable-hdpi/perm_group_affects_battery.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/perm_group_app_info.png b/core/res/res/drawable-hdpi/perm_group_app_info.png
new file mode 100644
index 0000000..b03e2f3
--- /dev/null
+++ b/core/res/res/drawable-hdpi/perm_group_app_info.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/perm_group_audio_settings.png b/core/res/res/drawable-hdpi/perm_group_audio_settings.png
new file mode 100644
index 0000000..4e652a8
--- /dev/null
+++ b/core/res/res/drawable-hdpi/perm_group_audio_settings.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/perm_group_bluetooth.png b/core/res/res/drawable-hdpi/perm_group_bluetooth.png
new file mode 100644
index 0000000..0f28454
--- /dev/null
+++ b/core/res/res/drawable-hdpi/perm_group_bluetooth.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/perm_group_bookmarks.png b/core/res/res/drawable-hdpi/perm_group_bookmarks.png
new file mode 100644
index 0000000..06f63445
--- /dev/null
+++ b/core/res/res/drawable-hdpi/perm_group_bookmarks.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/perm_group_calendar.png b/core/res/res/drawable-hdpi/perm_group_calendar.png
new file mode 100644
index 0000000..c0a4dfd
--- /dev/null
+++ b/core/res/res/drawable-hdpi/perm_group_calendar.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/perm_group_camera.png b/core/res/res/drawable-hdpi/perm_group_camera.png
new file mode 100644
index 0000000..cbc07b0
--- /dev/null
+++ b/core/res/res/drawable-hdpi/perm_group_camera.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/perm_group_device_alarms.png b/core/res/res/drawable-hdpi/perm_group_device_alarms.png
new file mode 100644
index 0000000..d44b9de
--- /dev/null
+++ b/core/res/res/drawable-hdpi/perm_group_device_alarms.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/perm_group_display.png b/core/res/res/drawable-hdpi/perm_group_display.png
new file mode 100644
index 0000000..e8afece
--- /dev/null
+++ b/core/res/res/drawable-hdpi/perm_group_display.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/perm_group_location.png b/core/res/res/drawable-hdpi/perm_group_location.png
new file mode 100644
index 0000000..dc2f8ef
--- /dev/null
+++ b/core/res/res/drawable-hdpi/perm_group_location.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/perm_group_messages.png b/core/res/res/drawable-hdpi/perm_group_messages.png
new file mode 100644
index 0000000..680c178
--- /dev/null
+++ b/core/res/res/drawable-hdpi/perm_group_messages.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/perm_group_microphone.png b/core/res/res/drawable-hdpi/perm_group_microphone.png
new file mode 100644
index 0000000..a73a945
--- /dev/null
+++ b/core/res/res/drawable-hdpi/perm_group_microphone.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/perm_group_network.png b/core/res/res/drawable-hdpi/perm_group_network.png
new file mode 100644
index 0000000..c750e2aa
--- /dev/null
+++ b/core/res/res/drawable-hdpi/perm_group_network.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/perm_group_personal_info.png b/core/res/res/drawable-hdpi/perm_group_personal_info.png
new file mode 100644
index 0000000..130e7ad
--- /dev/null
+++ b/core/res/res/drawable-hdpi/perm_group_personal_info.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/perm_group_phone_calls.png b/core/res/res/drawable-hdpi/perm_group_phone_calls.png
new file mode 100644
index 0000000..577855b
--- /dev/null
+++ b/core/res/res/drawable-hdpi/perm_group_phone_calls.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/perm_group_screenlock.png b/core/res/res/drawable-hdpi/perm_group_screenlock.png
new file mode 100644
index 0000000..9c5143d
--- /dev/null
+++ b/core/res/res/drawable-hdpi/perm_group_screenlock.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/perm_group_shortrange_network.png b/core/res/res/drawable-hdpi/perm_group_shortrange_network.png
new file mode 100644
index 0000000..554a4e4
--- /dev/null
+++ b/core/res/res/drawable-hdpi/perm_group_shortrange_network.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/perm_group_social_info.png b/core/res/res/drawable-hdpi/perm_group_social_info.png
new file mode 100644
index 0000000..134990b
--- /dev/null
+++ b/core/res/res/drawable-hdpi/perm_group_social_info.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/perm_group_status_bar.png b/core/res/res/drawable-hdpi/perm_group_status_bar.png
new file mode 100644
index 0000000..bda963b
--- /dev/null
+++ b/core/res/res/drawable-hdpi/perm_group_status_bar.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/perm_group_storage.png b/core/res/res/drawable-hdpi/perm_group_storage.png
new file mode 100644
index 0000000..e6b3965
--- /dev/null
+++ b/core/res/res/drawable-hdpi/perm_group_storage.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/perm_group_sync_settings.png b/core/res/res/drawable-hdpi/perm_group_sync_settings.png
new file mode 100644
index 0000000..be70866
--- /dev/null
+++ b/core/res/res/drawable-hdpi/perm_group_sync_settings.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/perm_group_system_clock.png b/core/res/res/drawable-hdpi/perm_group_system_clock.png
new file mode 100644
index 0000000..75794c3
--- /dev/null
+++ b/core/res/res/drawable-hdpi/perm_group_system_clock.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/perm_group_system_tools.png b/core/res/res/drawable-hdpi/perm_group_system_tools.png
new file mode 100644
index 0000000..3fd4385
--- /dev/null
+++ b/core/res/res/drawable-hdpi/perm_group_system_tools.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/perm_group_user_dictionary.png b/core/res/res/drawable-hdpi/perm_group_user_dictionary.png
new file mode 100644
index 0000000..98a0894
--- /dev/null
+++ b/core/res/res/drawable-hdpi/perm_group_user_dictionary.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/perm_group_user_dictionary_write.png b/core/res/res/drawable-hdpi/perm_group_user_dictionary_write.png
new file mode 100644
index 0000000..784ea0f
--- /dev/null
+++ b/core/res/res/drawable-hdpi/perm_group_user_dictionary_write.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/perm_group_voicemail.png b/core/res/res/drawable-hdpi/perm_group_voicemail.png
new file mode 100644
index 0000000..b08b153
--- /dev/null
+++ b/core/res/res/drawable-hdpi/perm_group_voicemail.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/perm_group_wallpaper.png b/core/res/res/drawable-hdpi/perm_group_wallpaper.png
new file mode 100644
index 0000000..cf073a4
--- /dev/null
+++ b/core/res/res/drawable-hdpi/perm_group_wallpaper.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/perm_group_accounts.png b/core/res/res/drawable-mdpi/perm_group_accounts.png
new file mode 100644
index 0000000..3dd4043
--- /dev/null
+++ b/core/res/res/drawable-mdpi/perm_group_accounts.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/perm_group_affects_battery.png b/core/res/res/drawable-mdpi/perm_group_affects_battery.png
new file mode 100644
index 0000000..7291916
--- /dev/null
+++ b/core/res/res/drawable-mdpi/perm_group_affects_battery.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/perm_group_app_info.png b/core/res/res/drawable-mdpi/perm_group_app_info.png
new file mode 100644
index 0000000..8ba65bd
--- /dev/null
+++ b/core/res/res/drawable-mdpi/perm_group_app_info.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/perm_group_audio_settings.png b/core/res/res/drawable-mdpi/perm_group_audio_settings.png
new file mode 100644
index 0000000..f2f461b
--- /dev/null
+++ b/core/res/res/drawable-mdpi/perm_group_audio_settings.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/perm_group_bluetooth.png b/core/res/res/drawable-mdpi/perm_group_bluetooth.png
new file mode 100644
index 0000000..6db6fde
--- /dev/null
+++ b/core/res/res/drawable-mdpi/perm_group_bluetooth.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/perm_group_bookmarks.png b/core/res/res/drawable-mdpi/perm_group_bookmarks.png
new file mode 100644
index 0000000..f908e14
--- /dev/null
+++ b/core/res/res/drawable-mdpi/perm_group_bookmarks.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/perm_group_calendar.png b/core/res/res/drawable-mdpi/perm_group_calendar.png
new file mode 100644
index 0000000..5905973
--- /dev/null
+++ b/core/res/res/drawable-mdpi/perm_group_calendar.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/perm_group_camera.png b/core/res/res/drawable-mdpi/perm_group_camera.png
new file mode 100644
index 0000000..be1c9e6
--- /dev/null
+++ b/core/res/res/drawable-mdpi/perm_group_camera.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/perm_group_device_alarms.png b/core/res/res/drawable-mdpi/perm_group_device_alarms.png
new file mode 100644
index 0000000..48d6d6a
--- /dev/null
+++ b/core/res/res/drawable-mdpi/perm_group_device_alarms.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/perm_group_display.png b/core/res/res/drawable-mdpi/perm_group_display.png
new file mode 100644
index 0000000..e10609c
--- /dev/null
+++ b/core/res/res/drawable-mdpi/perm_group_display.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/perm_group_location.png b/core/res/res/drawable-mdpi/perm_group_location.png
new file mode 100644
index 0000000..e79ec25
--- /dev/null
+++ b/core/res/res/drawable-mdpi/perm_group_location.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/perm_group_messages.png b/core/res/res/drawable-mdpi/perm_group_messages.png
new file mode 100644
index 0000000..dfb3ba7
--- /dev/null
+++ b/core/res/res/drawable-mdpi/perm_group_messages.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/perm_group_microphone.png b/core/res/res/drawable-mdpi/perm_group_microphone.png
new file mode 100644
index 0000000..9bab315
--- /dev/null
+++ b/core/res/res/drawable-mdpi/perm_group_microphone.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/perm_group_network.png b/core/res/res/drawable-mdpi/perm_group_network.png
new file mode 100644
index 0000000..f2798a7
--- /dev/null
+++ b/core/res/res/drawable-mdpi/perm_group_network.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/perm_group_personal_info.png b/core/res/res/drawable-mdpi/perm_group_personal_info.png
new file mode 100644
index 0000000..6233a82
--- /dev/null
+++ b/core/res/res/drawable-mdpi/perm_group_personal_info.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/perm_group_phone_calls.png b/core/res/res/drawable-mdpi/perm_group_phone_calls.png
new file mode 100644
index 0000000..ff3ffd5
--- /dev/null
+++ b/core/res/res/drawable-mdpi/perm_group_phone_calls.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/perm_group_screenlock.png b/core/res/res/drawable-mdpi/perm_group_screenlock.png
new file mode 100644
index 0000000..abfe6e4
--- /dev/null
+++ b/core/res/res/drawable-mdpi/perm_group_screenlock.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/perm_group_shortrange_network.png b/core/res/res/drawable-mdpi/perm_group_shortrange_network.png
new file mode 100644
index 0000000..5d73375
--- /dev/null
+++ b/core/res/res/drawable-mdpi/perm_group_shortrange_network.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/perm_group_social_info.png b/core/res/res/drawable-mdpi/perm_group_social_info.png
new file mode 100644
index 0000000..c862f9e
--- /dev/null
+++ b/core/res/res/drawable-mdpi/perm_group_social_info.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/perm_group_status_bar.png b/core/res/res/drawable-mdpi/perm_group_status_bar.png
new file mode 100644
index 0000000..4158fa6
--- /dev/null
+++ b/core/res/res/drawable-mdpi/perm_group_status_bar.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/perm_group_storage.png b/core/res/res/drawable-mdpi/perm_group_storage.png
new file mode 100644
index 0000000..3dcfb22
--- /dev/null
+++ b/core/res/res/drawable-mdpi/perm_group_storage.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/perm_group_sync_settings.png b/core/res/res/drawable-mdpi/perm_group_sync_settings.png
new file mode 100644
index 0000000..5a0e5ff
--- /dev/null
+++ b/core/res/res/drawable-mdpi/perm_group_sync_settings.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/perm_group_system_clock.png b/core/res/res/drawable-mdpi/perm_group_system_clock.png
new file mode 100644
index 0000000..e4d5743
--- /dev/null
+++ b/core/res/res/drawable-mdpi/perm_group_system_clock.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/perm_group_system_tools.png b/core/res/res/drawable-mdpi/perm_group_system_tools.png
new file mode 100644
index 0000000..fc7337d
--- /dev/null
+++ b/core/res/res/drawable-mdpi/perm_group_system_tools.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/perm_group_user_dictionary.png b/core/res/res/drawable-mdpi/perm_group_user_dictionary.png
new file mode 100644
index 0000000..92864ba
--- /dev/null
+++ b/core/res/res/drawable-mdpi/perm_group_user_dictionary.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/perm_group_user_dictionary_write.png b/core/res/res/drawable-mdpi/perm_group_user_dictionary_write.png
new file mode 100644
index 0000000..9f48713
--- /dev/null
+++ b/core/res/res/drawable-mdpi/perm_group_user_dictionary_write.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/perm_group_voicemail.png b/core/res/res/drawable-mdpi/perm_group_voicemail.png
new file mode 100644
index 0000000..a34d689
--- /dev/null
+++ b/core/res/res/drawable-mdpi/perm_group_voicemail.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/perm_group_wallpaper.png b/core/res/res/drawable-mdpi/perm_group_wallpaper.png
new file mode 100644
index 0000000..b990e7f
--- /dev/null
+++ b/core/res/res/drawable-mdpi/perm_group_wallpaper.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/perm_group_accounts.png b/core/res/res/drawable-xhdpi/perm_group_accounts.png
new file mode 100644
index 0000000..74cd33b
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/perm_group_accounts.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/perm_group_affects_battery.png b/core/res/res/drawable-xhdpi/perm_group_affects_battery.png
new file mode 100644
index 0000000..d4a9bb5d
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/perm_group_affects_battery.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/perm_group_app_info.png b/core/res/res/drawable-xhdpi/perm_group_app_info.png
new file mode 100644
index 0000000..46089e5
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/perm_group_app_info.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/perm_group_audio_settings.png b/core/res/res/drawable-xhdpi/perm_group_audio_settings.png
new file mode 100644
index 0000000..2f7cbc3
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/perm_group_audio_settings.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/perm_group_bluetooth.png b/core/res/res/drawable-xhdpi/perm_group_bluetooth.png
new file mode 100644
index 0000000..6bbde52
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/perm_group_bluetooth.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/perm_group_bookmarks.png b/core/res/res/drawable-xhdpi/perm_group_bookmarks.png
new file mode 100644
index 0000000..1277d03
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/perm_group_bookmarks.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/perm_group_calendar.png b/core/res/res/drawable-xhdpi/perm_group_calendar.png
new file mode 100644
index 0000000..3c7f2d3
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/perm_group_calendar.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/perm_group_camera.png b/core/res/res/drawable-xhdpi/perm_group_camera.png
new file mode 100644
index 0000000..a454554
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/perm_group_camera.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/perm_group_device_alarms.png b/core/res/res/drawable-xhdpi/perm_group_device_alarms.png
new file mode 100644
index 0000000..1bb151c
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/perm_group_device_alarms.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/perm_group_display.png b/core/res/res/drawable-xhdpi/perm_group_display.png
new file mode 100644
index 0000000..9e36cf8
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/perm_group_display.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/perm_group_location.png b/core/res/res/drawable-xhdpi/perm_group_location.png
new file mode 100644
index 0000000..4c49521
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/perm_group_location.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/perm_group_messages.png b/core/res/res/drawable-xhdpi/perm_group_messages.png
new file mode 100644
index 0000000..f046d46
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/perm_group_messages.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/perm_group_microphone.png b/core/res/res/drawable-xhdpi/perm_group_microphone.png
new file mode 100644
index 0000000..bdb66e2
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/perm_group_microphone.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/perm_group_network.png b/core/res/res/drawable-xhdpi/perm_group_network.png
new file mode 100644
index 0000000..fe1adad
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/perm_group_network.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/perm_group_personal_info.png b/core/res/res/drawable-xhdpi/perm_group_personal_info.png
new file mode 100644
index 0000000..1ae418f
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/perm_group_personal_info.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/perm_group_phone_calls.png b/core/res/res/drawable-xhdpi/perm_group_phone_calls.png
new file mode 100644
index 0000000..288e15c
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/perm_group_phone_calls.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/perm_group_screenlock.png b/core/res/res/drawable-xhdpi/perm_group_screenlock.png
new file mode 100644
index 0000000..bf3ec34
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/perm_group_screenlock.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/perm_group_shortrange_network.png b/core/res/res/drawable-xhdpi/perm_group_shortrange_network.png
new file mode 100644
index 0000000..5e1e240
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/perm_group_shortrange_network.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/perm_group_social_info.png b/core/res/res/drawable-xhdpi/perm_group_social_info.png
new file mode 100644
index 0000000..2111a83
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/perm_group_social_info.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/perm_group_status_bar.png b/core/res/res/drawable-xhdpi/perm_group_status_bar.png
new file mode 100644
index 0000000..ce65380
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/perm_group_status_bar.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/perm_group_storage.png b/core/res/res/drawable-xhdpi/perm_group_storage.png
new file mode 100644
index 0000000..4cd5c9b
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/perm_group_storage.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/perm_group_sync_settings.png b/core/res/res/drawable-xhdpi/perm_group_sync_settings.png
new file mode 100644
index 0000000..24eb579
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/perm_group_sync_settings.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/perm_group_system_clock.png b/core/res/res/drawable-xhdpi/perm_group_system_clock.png
new file mode 100644
index 0000000..36d1294
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/perm_group_system_clock.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/perm_group_system_tools.png b/core/res/res/drawable-xhdpi/perm_group_system_tools.png
new file mode 100644
index 0000000..7b6cdd8
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/perm_group_system_tools.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/perm_group_user_dictionary.png b/core/res/res/drawable-xhdpi/perm_group_user_dictionary.png
new file mode 100644
index 0000000..c0106bb
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/perm_group_user_dictionary.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/perm_group_user_dictionary_write.png b/core/res/res/drawable-xhdpi/perm_group_user_dictionary_write.png
new file mode 100644
index 0000000..36bb395
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/perm_group_user_dictionary_write.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/perm_group_voicemail.png b/core/res/res/drawable-xhdpi/perm_group_voicemail.png
new file mode 100644
index 0000000..eb17a63
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/perm_group_voicemail.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/perm_group_wallpaper.png b/core/res/res/drawable-xhdpi/perm_group_wallpaper.png
new file mode 100644
index 0000000..be4663c
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/perm_group_wallpaper.png
Binary files differ
diff --git a/core/res/res/layout/app_permission_item.xml b/core/res/res/layout/app_permission_item.xml
index 9b8c5ae..c448bd1 100644
--- a/core/res/res/layout/app_permission_item.xml
+++ b/core/res/res/layout/app_permission_item.xml
@@ -42,6 +42,7 @@
     <TextView
         android:id="@+id/perm_name"
         android:textAppearance="?android:attr/textAppearanceSmall"
+        android:textSize="16sp"
         android:layout_marginLeft="8dp"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
diff --git a/core/res/res/layout/resolve_list_item.xml b/core/res/res/layout/resolve_list_item.xml
index c0404be..e3d3ddf 100644
--- a/core/res/res/layout/resolve_list_item.xml
+++ b/core/res/res/layout/resolve_list_item.xml
@@ -18,39 +18,40 @@
 */
 -->
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:gravity="center_vertical"
-    android:orientation="horizontal"
-    android:minHeight="?android:attr/listPreferredItemHeight"
-    android:layout_height="wrap_content"
-    android:layout_width="match_parent"
-    android:paddingLeft="16dip"
-    android:paddingRight="16dip">
+              android:gravity="center"
+              android:orientation="vertical"
+              android:layout_height="wrap_content"
+              android:layout_width="match_parent"
+              android:background="?android:attr/activatedBackgroundIndicator"
+              android:padding="16dp">
 
-    <!-- Activity icon when presenting dialog -->
+    <!-- Extended activity info to distinguish between duplicate activity names -->
+    <TextView android:id="@android:id/text2"
+              android:textAppearance="?android:attr/textAppearance"
+              android:layout_width="wrap_content"
+              android:layout_height="wrap_content"
+              android:gravity="center"
+              android:minLines="2"
+              android:maxLines="2"
+              android:paddingLeft="8dip"
+              android:paddingRight="8dip" />
+
+    <!-- Activity icon when presenting dialog
+         Size will be filled in by ResolverActivity -->
     <ImageView android:id="@+id/icon"
-        android:layout_width="@android:dimen/app_icon_size"
-        android:layout_height="@android:dimen/app_icon_size"
-        android:scaleType="fitCenter" />
+               android:layout_width="0dp"
+               android:layout_height="0dp"
+               android:scaleType="fitCenter" />
 
-    <LinearLayout
-        android:orientation="vertical"
-        android:gravity="center_vertical"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content" >
-        <!-- Activity name -->
-        <TextView android:id="@android:id/text1"
-            android:textAppearance="?android:attr/textAppearanceListItemSmall"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:maxLines="2"
-            android:paddingLeft="16dip" />
-        <!-- Extended activity info to distinguish between duplicate activity names -->
-        <TextView android:id="@android:id/text2"
-            android:textAppearance="?android:attr/textAppearanceSmall"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:maxLines="2"
-            android:paddingLeft="16dip" />
-    </LinearLayout>
+    <!-- Activity name -->
+    <TextView android:id="@android:id/text1"
+              android:textAppearance="?android:attr/textAppearanceSmall"
+              android:layout_width="wrap_content"
+              android:layout_height="wrap_content"
+              android:gravity="center"
+              android:minLines="2"
+              android:maxLines="2"
+              android:paddingLeft="8dip"
+              android:paddingRight="8dip" />
 </LinearLayout>
 
diff --git a/core/res/res/layout/resolver_grid.xml b/core/res/res/layout/resolver_grid.xml
new file mode 100644
index 0000000..f10a59f0
--- /dev/null
+++ b/core/res/res/layout/resolver_grid.xml
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+* Copyright 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.
+*/
+-->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+              android:layout_width="match_parent"
+              android:layout_height="match_parent"
+              android:orientation="vertical"
+              android:divider="?android:attr/dividerHorizontal"
+              android:showDividers="middle"
+              android:dividerPadding="0dip">
+    <GridView
+        android:layout_gravity="center"
+        android:layout_height="wrap_content"
+        android:layout_width="wrap_content"
+        android:id="@+id/resolver_grid"
+        android:numColumns="4"
+        android:columnWidth="128dp"
+        android:padding="16dp"
+        android:clipToPadding="false" />
+    <LinearLayout
+        android:id="@+id/button_bar"
+        android:visibility="gone"
+        style="?android:attr/buttonBarStyle"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:orientation="horizontal"
+        android:layoutDirection="locale"
+        android:measureWithLargestChild="true">
+        <Button android:id="@+id/button_always"
+                android:layout_width="wrap_content"
+                android:layout_gravity="right"
+                android:layout_weight="1"
+                android:maxLines="2"
+                android:minHeight="@dimen/alert_dialog_button_bar_height"
+                style="?android:attr/buttonBarButtonStyle"
+                android:textSize="14sp"
+                android:layout_height="wrap_content"
+                android:enabled="false"
+                android:text="@string/activity_resolver_use_always"
+                android:onClick="onButtonClick" />
+        <Button android:id="@+id/button_once"
+                android:layout_width="wrap_content"
+                android:layout_gravity="left"
+                android:layout_weight="1"
+                android:maxLines="2"
+                style="?android:attr/buttonBarButtonStyle"
+                android:textSize="14sp"
+                android:minHeight="@dimen/alert_dialog_button_bar_height"
+                android:layout_height="wrap_content"
+                android:enabled="false"
+                android:text="@string/activity_resolver_use_once"
+                android:onClick="onButtonClick" />
+    </LinearLayout>
+</LinearLayout>
\ No newline at end of file
diff --git a/core/res/res/values-large/dimens.xml b/core/res/res/values-large/dimens.xml
index 864675a..8cd614d 100644
--- a/core/res/res/values-large/dimens.xml
+++ b/core/res/res/values-large/dimens.xml
@@ -24,10 +24,6 @@
     <!-- keyboardHeight = key_height*4 + key_bottom_gap*3 -->
     <dimen name="password_keyboard_height">48.0mm</dimen>
 
-    <!-- The width that is used when creating thumbnails of applications. -->
-    <dimen name="thumbnail_width">230dp</dimen>
-    <!-- The height that is used when creating thumbnails of applications. -->
-    <dimen name="thumbnail_height">135dp</dimen>
     <!-- Minimum width of the search view text entry area. -->
     <dimen name="search_view_text_min_width">192dip</dimen>
 
diff --git a/core/res/res/values-sw720dp/dimens.xml b/core/res/res/values-sw720dp/dimens.xml
index bbbfaae..7b1bc4c5 100644
--- a/core/res/res/values-sw720dp/dimens.xml
+++ b/core/res/res/values-sw720dp/dimens.xml
@@ -34,6 +34,10 @@
          (the screen is in landscape). This may be either a fraction or a dimension.-->
     <item type="dimen" name="dialog_fixed_height_minor">90%</item>
 
+    <!-- The width that is used when creating thumbnails of applications. -->
+    <dimen name="thumbnail_width">230dp</dimen>
+    <!-- The height that is used when creating thumbnails of applications. -->
+    <dimen name="thumbnail_height">135dp</dimen>
 </resources>
 
 
diff --git a/core/res/res/values-w500dp/bools.xml b/core/res/res/values-w500dp/bools.xml
new file mode 100644
index 0000000..f53fd39
--- /dev/null
+++ b/core/res/res/values-w500dp/bools.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<resources>
+    <bool name="activity_chooser_view_has_default_activity">true</bool>
+</resources>
\ No newline at end of file
diff --git a/core/res/res/values-xlarge/dimens.xml b/core/res/res/values-xlarge/dimens.xml
index c15770d..29cea26 100644
--- a/core/res/res/values-xlarge/dimens.xml
+++ b/core/res/res/values-xlarge/dimens.xml
@@ -25,10 +25,6 @@
     <!-- keyboardHeight = key_height*4 + key_bottom_gap*3 -->
     <dimen name="password_keyboard_height">48.0mm</dimen>
 
-    <!-- The width that is used when creating thumbnails of applications. -->
-    <dimen name="thumbnail_width">230dp</dimen>
-    <!-- The height that is used when creating thumbnails of applications. -->
-    <dimen name="thumbnail_height">135dp</dimen>
     <!-- Minimum width of the search view text entry area. -->
     <dimen name="search_view_text_min_width">192dip</dimen>
 
diff --git a/core/res/res/values/bools.xml b/core/res/res/values/bools.xml
index f9762b1..6910ebe 100644
--- a/core/res/res/values/bools.xml
+++ b/core/res/res/values/bools.xml
@@ -22,4 +22,5 @@
     <bool name="show_ongoing_ime_switcher">true</bool>
     <bool name="action_bar_expanded_action_views_exclusive">true</bool>
     <bool name="target_honeycomb_needs_options_menu">true</bool>
+    <bool name="activity_chooser_view_has_default_activity">false</bool>
 </resources>
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index f06e30f..5e89dd1 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -462,7 +462,6 @@
   <java-symbol type="string" name="db_default_sync_mode" />
   <java-symbol type="string" name="db_wal_sync_mode" />
   <java-symbol type="string" name="decline" />
-  <java-symbol type="string" name="default_permission_group" />
   <java-symbol type="string" name="default_text_encoding" />
   <java-symbol type="string" name="description_target_unlock_tablet" />
   <java-symbol type="string" name="double_tap_toast" />
@@ -652,10 +651,8 @@
   <java-symbol type="string" name="orgTypeOther" />
   <java-symbol type="string" name="orgTypeWork" />
   <java-symbol type="string" name="passwordIncorrect" />
-  <java-symbol type="string" name="permissions_format" />
+  <java-symbol type="string" name="perms_description_app" />
   <java-symbol type="string" name="perms_new_perm_prefix" />
-  <java-symbol type="string" name="perms_hide" />
-  <java-symbol type="string" name="perms_show_all" />
   <java-symbol type="string" name="petabyteShort" />
   <java-symbol type="string" name="phoneTypeAssistant" />
   <java-symbol type="string" name="phoneTypeCallback" />
@@ -1376,6 +1373,7 @@
   <java-symbol type="bool" name="config_wifi_dual_band_support" />
   <java-symbol type="bool" name="config_wimaxEnabled" />
   <java-symbol type="bool" name="show_ongoing_ime_switcher" />
+  <java-symbol type="bool" name="activity_chooser_view_has_default_activity" />
   <java-symbol type="color" name="config_defaultNotificationColor" />
   <java-symbol type="drawable" name="ic_notification_ime_default" />
   <java-symbol type="drawable" name="stat_notify_car_mode" />
@@ -1510,6 +1508,11 @@
   <java-symbol type="bool" name="config_enableDreams" />
   <java-symbol type="string" name="config_defaultDreamComponent" />
 
+  <java-symbol type="layout" name="resolver_grid" />
+  <java-symbol type="id" name="resolver_grid" />
+  <java-symbol type="id" name="button_once" />
+  <java-symbol type="id" name="button_always" />
+
   <!-- From SystemUI -->
   <java-symbol type="anim" name="push_down_in" />
   <java-symbol type="anim" name="push_down_out" />
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 3250507..e7ad4c2 100755
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -408,16 +408,21 @@
     <string name="permgroupdesc_network">Access various network features.</string>
 
     <!-- Title of a category of application permissions, listed so the user can choose whether they want to allow the application to do this. -->
-    <string name="permgrouplab_shortRangeNetwork">Bluetooth and NFC</string>
+    <string name="permgrouplab_bluetoothNetwork">Bluetooth</string>
     <!-- Description of a category of application permissions, listed so the user can choose whether they want to allow the application to do this. -->
-    <string name="permgroupdesc_shortRangeNetwork">Access Bluetooth or NFC networks and devices.</string>
+    <string name="permgroupdesc_bluetoothNetwork">Access devices and networks through Bluetooth.</string>
 
-  <!-- Title of a category of application permissions, listed so the user can choose whether they want to allow the application to do this. -->
+    <!-- Title of a category of application permissions, listed so the user can choose whether they want to allow the application to do this. -->
+    <string name="permgrouplab_shortrangeNetwork">Short-range Networks</string>
+    <!-- Description of a category of application permissions, listed so the user can choose whether they want to allow the application to do this. -->
+    <string name="permgroupdesc_shortrangeNetwork">Access devices through short-range networks such as NFC.</string>
+
+    <!-- Title of a category of application permissions, listed so the user can choose whether they want to allow the application to do this. -->
     <string name="permgrouplab_audioSettings">Audio Settings</string>
     <!-- Description of a category of application permissions, listed so the user can choose whether they want to allow the application to do this. -->
     <string name="permgroupdesc_audioSettings">Change audio settings.</string>
 
-  <!-- Title of a category of application permissions, listed so the user can choose whether they want to allow the application to do this. -->
+    <!-- Title of a category of application permissions, listed so the user can choose whether they want to allow the application to do this. -->
     <string name="permgrouplab_affectsBattery">Affects Battery</string>
     <!-- Description of a category of application permissions, listed so the user can choose whether they want to allow the application to do this. -->
     <string name="permgroupdesc_affectsBattery">Use features that can quickly drain battery.</string>
@@ -428,9 +433,14 @@
     <string name="permgroupdesc_calendar">Direct access to calendar and events.</string>
 
     <!-- Title of a category of application permissions, listed so the user can choose whether they want to allow the application to do this. -->
-    <string name="permgrouplab_dictionary">User Dictionary</string>
+    <string name="permgrouplab_dictionary">Read User Dictionary</string>
     <!-- Description of a category of application permissions, listed so the user can choose whether they want to allow the application to do this. -->
-    <string name="permgroupdesc_dictionary">Direct access to the user dictionary.</string>
+    <string name="permgroupdesc_dictionary">Read words in user dictionary.</string>
+
+    <!-- Title of a category of application permissions, listed so the user can choose whether they want to allow the application to do this. -->
+    <string name="permgrouplab_writeDictionary">Write User Dictionary</string>
+    <!-- Description of a category of application permissions, listed so the user can choose whether they want to allow the application to do this. -->
+    <string name="permgroupdesc_writeDictionary">Add words to the user dictionary.</string>
 
     <!-- Title of a category of application permissions, listed so the user can choose whether they want to allow the application to do this. -->
     <string name="permgrouplab_bookmarks">Bookmarks and History</string>
@@ -1597,7 +1607,7 @@
     <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. [CHAR LIMIT=30] -->
     <string name="permlab_sdcardWrite" product="nosdcard">modify or delete the contents of your USB storage</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_sdcardWrite" product="default">modify or delete the contens of your SD card</string>
+    <string name="permlab_sdcardWrite" product="default">modify or delete the contents of your SD card</string>
     <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. [CHAR LIMIT=30] -->
     <string name="permdesc_sdcardWrite" product="nosdcard">Allows the app to write to the USB storage.</string>
     <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
@@ -2976,18 +2986,12 @@
     <string name="date_time_done">Done</string>
 
     <!-- Security Permissions strings-->
-    <!-- The default permission group for any permissions that have not explicitly set a group. -->
-    <string name="default_permission_group">Default</string>
-    <!-- Do not translate. -->
-    <string name="permissions_format"><xliff:g id="perm_line1">%1$s</xliff:g>, <xliff:g id="perm_line2">%2$s</xliff:g></string>
     <!-- Text that is placed at the front of a permission name that is being added to an app [CHAR LIMIT=NONE] -->
     <string name="perms_new_perm_prefix"><font size="12" fgcolor="#ff900000">NEW: </font></string>
+    <!-- Text that is placed at the front of a permission name that is being added to an app [CHAR LIMIT=NONE] -->
+    <string name="perms_description_app">Provided by <xliff:g id="app_name">%1$s</xliff:g>.</string>
     <!-- Shown for an application when it doesn't require any permission grants. -->
     <string name="no_permissions">No permissions required</string>
-    <!-- When installing an application, the less-dangerous permissions are hidden.  If the user showed those, this is the text to hide them again.  -->
-    <string name="perms_hide"><b>Hide</b></string>
-    <!-- When installing an application, the less-dangerous permissions are hidden.  This is the text to show those. -->
-    <string name="perms_show_all"><b>Show all</b></string>
 
     <!-- USB storage dialog strings -->
     <!-- This is the title for the activity's window. -->
@@ -3556,4 +3560,12 @@
     <!-- STK setup Call -->
     <string name="SetupCallDefault">Accept call?</string>
 
+    <!-- Title for a button to choose the currently selected activity
+         as the default in the activity resolver. [CHAR LIMIT=25] -->
+    <string name="activity_resolver_use_always">Use Always</string>
+
+    <!-- Title for a button to choose the currently selected activity
+         from the activity resolver to use just this once. [CHAR LIMIT=25] -->
+    <string name="activity_resolver_use_once">Just Once</string>
+
 </resources>
diff --git a/core/tests/coretests/src/android/content/SyncStorageEngineTest.java b/core/tests/coretests/src/android/content/SyncStorageEngineTest.java
index 96f313a..2add623 100644
--- a/core/tests/coretests/src/android/content/SyncStorageEngineTest.java
+++ b/core/tests/coretests/src/android/content/SyncStorageEngineTest.java
@@ -20,7 +20,6 @@
 
 import android.accounts.Account;
 import android.os.Bundle;
-import android.os.Debug;
 import android.test.AndroidTestCase;
 import android.test.RenamingDelegatingContext;
 import android.test.mock.MockContentResolver;
@@ -57,7 +56,8 @@
 
         long time0 = 1000;
         long historyId = engine.insertStartSyncEvent(
-                account, 0, authority, time0, SyncStorageEngine.SOURCE_LOCAL);
+                account, 0, authority, time0, SyncStorageEngine.SOURCE_LOCAL,
+                false /* initialization */);
         long time1 = time0 + SyncStorageEngine.MILLIS_IN_4WEEKS * 2;
         engine.stopSyncEvent(historyId, time1 - time0, "yay", 0, 0);
     }
diff --git a/services/java/com/android/server/accessibility/AccessibilityManagerService.java b/services/java/com/android/server/accessibility/AccessibilityManagerService.java
index 8d454ce..fbe4a83 100644
--- a/services/java/com/android/server/accessibility/AccessibilityManagerService.java
+++ b/services/java/com/android/server/accessibility/AccessibilityManagerService.java
@@ -1701,17 +1701,17 @@
             | AccessibilityNodeInfo.ACTION_CLEAR_SELECTION
             | AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS
             | AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS
-            | AccessibilityNodeInfo.ACTION_NEXT_AT_GRANULARITY
-            | AccessibilityNodeInfo.ACTION_PREVIOUS_AT_GRANULARITY
+            | AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY
+            | AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY
             | AccessibilityNodeInfo.ACTION_NEXT_HTML_ELEMENT
             | AccessibilityNodeInfo.ACTION_PREVIOUS_HTML_ELEMENT;
 
         private static final int VALID_GRANULARITIES =
-            AccessibilityNodeInfo.GRANULARITY_CHARACTER
-            | AccessibilityNodeInfo.GRANULARITY_WORD
-            | AccessibilityNodeInfo.GRANULARITY_LINE
-            | AccessibilityNodeInfo.GRANULARITY_PARAGRAPH
-            | AccessibilityNodeInfo.GRANULARITY_PAGE;
+            AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER
+            | AccessibilityNodeInfo.MOVEMENT_GRANULARITY_WORD
+            | AccessibilityNodeInfo.MOVEMENT_GRANULARITY_LINE
+            | AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PARAGRAPH
+            | AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PAGE;
 
         private static final int RETRIEVAL_ALLOWING_EVENT_TYPES =
             AccessibilityEvent.TYPE_VIEW_CLICKED
diff --git a/services/java/com/android/server/wm/BlackFrame.java b/services/java/com/android/server/wm/BlackFrame.java
index c915932..27af313 100644
--- a/services/java/com/android/server/wm/BlackFrame.java
+++ b/services/java/com/android/server/wm/BlackFrame.java
@@ -42,8 +42,17 @@
             this.layer = layer;
             int w = r-l;
             int h = b-t;
-            surface = new Surface(session, 0, "BlackSurface",
-                    -1, w, h, PixelFormat.OPAQUE, Surface.FX_SURFACE_DIM);
+            if (WindowManagerService.DEBUG_SURFACE_TRACE) {
+                surface = new WindowStateAnimator.SurfaceTrace(session, 0, "BlackSurface("
+                        + l + ", " + t + ")",
+                        -1, w, h, PixelFormat.OPAQUE, Surface.FX_SURFACE_DIM);
+            } else {
+                surface = new Surface(session, 0, "BlackSurface",
+                        -1, w, h, PixelFormat.OPAQUE, Surface.FX_SURFACE_DIM);
+            }
+            surface.setAlpha(1);
+            surface.setLayer(layer);
+            surface.show();
             if (WindowManagerService.SHOW_TRANSACTIONS ||
                     WindowManagerService.SHOW_SURFACE_ALLOC) Slog.i(WindowManagerService.TAG,
                             "  BLACK " + surface + ": CREATE layer=" + layer);
@@ -58,8 +67,6 @@
             surface.setMatrix(
                     mTmpFloats[Matrix.MSCALE_X], mTmpFloats[Matrix.MSKEW_Y],
                     mTmpFloats[Matrix.MSKEW_X], mTmpFloats[Matrix.MSCALE_Y]);
-            surface.setAlpha(1.0f);
-            surface.setLayer(layer);
             if (false) {
                 Slog.i(WindowManagerService.TAG, "Black Surface @ (" + left + "," + top + "): ("
                         + mTmpFloats[Matrix.MTRANS_X] + ","
@@ -159,14 +166,6 @@
         }
     }
 
-    public void setAlpha(float alpha) {
-        for (int i=0; i<mBlackSurfaces.length; i++) {
-            if (mBlackSurfaces[i] != null) {
-                mBlackSurfaces[i].surface.setAlpha(alpha);
-            }
-        }
-    }
-
     public void clearMatrix() {
         for (int i=0; i<mBlackSurfaces.length; i++) {
             if (mBlackSurfaces[i] != null) {
diff --git a/services/java/com/android/server/wm/ScreenRotationAnimation.java b/services/java/com/android/server/wm/ScreenRotationAnimation.java
index 13013a8..938db9e 100644
--- a/services/java/com/android/server/wm/ScreenRotationAnimation.java
+++ b/services/java/com/android/server/wm/ScreenRotationAnimation.java
@@ -862,7 +862,6 @@
             } else {
                 mExitFrameFinalMatrix.setConcat(mExitTransformation.getMatrix(), mFrameInitialMatrix);
                 mExitingBlackFrame.setMatrix(mExitFrameFinalMatrix);
-                mExitingBlackFrame.setAlpha(mExitTransformation.getAlpha());
             }
         }