Merge "Bug 6605167: Turning off FUL during error counts as attempt" into jb-dev
diff --git a/cmds/installd/commands.c b/cmds/installd/commands.c
index 203d180..0bc7371 100644
--- a/cmds/installd/commands.c
+++ b/cmds/installd/commands.c
@@ -106,6 +106,43 @@
     return 0;
 }
 
+int fix_uid(const char *pkgname, uid_t uid, gid_t gid)
+{
+    char pkgdir[PKG_PATH_MAX];
+    struct stat s;
+    int rc = 0;
+
+    if ((uid < AID_SYSTEM) || (gid < AID_SYSTEM)) {
+        ALOGE("invalid uid/gid: %d %d\n", uid, gid);
+        return -1;
+    }
+
+    if (create_pkg_path(pkgdir, pkgname, PKG_DIR_POSTFIX, 0)) {
+        ALOGE("cannot create package path\n");
+        return -1;
+    }
+
+    if (stat(pkgdir, &s) < 0) return -1;
+
+    if (s.st_uid != 0 || s.st_gid != 0) {
+        ALOGE("fixing uid of non-root pkg: %s %d %d\n", pkgdir, s.st_uid, s.st_gid);
+        return -1;
+    }
+
+    if (chmod(pkgdir, 0751) < 0) {
+        ALOGE("cannot chmod dir '%s': %s\n", pkgdir, strerror(errno));
+        unlink(pkgdir);
+        return -errno;
+    }
+    if (chown(pkgdir, uid, gid) < 0) {
+        ALOGE("cannot chown dir '%s': %s\n", pkgdir, strerror(errno));
+        unlink(pkgdir);
+        return -errno;
+    }
+
+    return 0;
+}
+
 int delete_user_data(const char *pkgname, uid_t persona)
 {
     char pkgdir[PKG_PATH_MAX];
@@ -950,7 +987,7 @@
 out:
     if (chmod(dataDir, s.st_mode) < 0) {
         ALOGE("failed to chmod '%s': %s\n", dataDir, strerror(errno));
-        return -errno;
+        rc = -errno;
     }
 
     if (chown(dataDir, s.st_uid, s.st_gid) < 0) {
@@ -1027,7 +1064,7 @@
 out:
     if (chmod(dataDir, s.st_mode) < 0) {
         ALOGE("failed to chmod '%s': %s\n", dataDir, strerror(errno));
-        return -1;
+        rc = -1;
     }
 
     if (chown(dataDir, s.st_uid, s.st_gid) < 0) {
diff --git a/cmds/installd/installd.c b/cmds/installd/installd.c
index c2c749a..fa4b8a6 100644
--- a/cmds/installd/installd.c
+++ b/cmds/installd/installd.c
@@ -57,6 +57,11 @@
     return renamepkg(arg[0], arg[1]); /* oldpkgname, newpkgname */
 }
 
+static int do_fixuid(char **arg, char reply[REPLY_MAX])
+{
+    return fix_uid(arg[0], atoi(arg[1]), atoi(arg[2])); /* pkgname, uid, gid */
+}
+
 static int do_free_cache(char **arg, char reply[REPLY_MAX]) /* TODO int:free_size */
 {
     return free_cache((int64_t)atoll(arg[0])); /* free_size */
@@ -141,6 +146,7 @@
     { "rmdex",                1, do_rm_dex },
     { "remove",               2, do_remove },
     { "rename",               2, do_rename },
+    { "fixuid",               3, do_fixuid },
     { "freecache",            1, do_free_cache },
     { "rmcache",              1, do_rm_cache },
     { "protect",              2, do_protect },
diff --git a/cmds/installd/installd.h b/cmds/installd/installd.h
index 78342bb..1b843fd 100644
--- a/cmds/installd/installd.h
+++ b/cmds/installd/installd.h
@@ -143,6 +143,7 @@
 int install(const char *pkgname, uid_t uid, gid_t gid);
 int uninstall(const char *pkgname, uid_t persona);
 int renamepkg(const char *oldpkgname, const char *newpkgname);
+int fix_uid(const char *pkgname, uid_t uid, gid_t gid);
 int delete_user_data(const char *pkgname, uid_t persona);
 int make_user_data(const char *pkgname, uid_t uid, uid_t persona);
 int delete_persona(uid_t persona);
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index 457238a..caade70 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -1614,6 +1614,7 @@
     {
         private CharSequence mBigContentTitle;
         private CharSequence mSummaryText = null;
+        private boolean mSummaryTextSet = false;
 
         protected Builder mBuilder;
 
@@ -1630,6 +1631,7 @@
          */
         protected void internalSetSummaryText(CharSequence cs) {
             mSummaryText = cs;
+            mSummaryTextSet = true;
         }
 
         public void setBuilder(Builder builder) {
@@ -1660,9 +1662,13 @@
                 contentView.setViewVisibility(R.id.line1, View.VISIBLE);
             }
 
-            // The last line defaults to the content text or subtext, but can be replaced by mSummaryText
-            if (mSummaryText != null && !mSummaryText.equals("")) {
-                contentView.setTextViewText(R.id.text, mSummaryText);
+            // The last line defaults to the subtext, but can be replaced by mSummaryText
+            final CharSequence overflowText =
+                    mSummaryTextSet ? mSummaryText
+                                    : mBuilder.mSubText;
+            if (overflowText != null) {
+                contentView.setTextViewText(R.id.text, overflowText);
+                contentView.setViewVisibility(R.id.overflow_divider, View.VISIBLE);
                 contentView.setViewVisibility(R.id.line3, View.VISIBLE);
             }
 
@@ -1803,9 +1809,16 @@
         }
 
         private RemoteViews makeBigContentView() {
-            // Remove the content text so line3 disappears entirely
+            // Remove the content text so line3 only shows if you have a summary
+            final boolean hadThreeLines = (mBuilder.mContentText != null && mBuilder.mSubText != null);
             mBuilder.mContentText = null;
             RemoteViews contentView = getStandardView(R.layout.notification_template_big_text);
+            
+            if (hadThreeLines) {
+                // vertical centering
+                contentView.setViewPadding(R.id.line1, 0, 0, 0, 0);
+            }
+
             contentView.setTextViewText(R.id.big_text, mBigText);
             contentView.setViewVisibility(R.id.big_text, View.VISIBLE);
             contentView.setViewVisibility(R.id.text2, View.GONE);
@@ -1875,7 +1888,10 @@
         }
 
         private RemoteViews makeBigContentView() {
+            // Remove the content text so line3 disappears unless you have a summary
+            mBuilder.mContentText = null;
             RemoteViews contentView = getStandardView(R.layout.notification_template_inbox);
+
             contentView.setViewVisibility(R.id.text2, View.GONE);
 
             int[] rowIds = {R.id.inbox_text0, R.id.inbox_text1, R.id.inbox_text2, R.id.inbox_text3,
diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java
index bcdd012..6de69b0 100644
--- a/core/java/android/content/pm/PackageManager.java
+++ b/core/java/android/content/pm/PackageManager.java
@@ -520,6 +520,14 @@
     public static final int INSTALL_FAILED_PACKAGE_CHANGED = -23;
 
     /**
+     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
+     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
+     * the new package is assigned a different UID than it previously held.
+     * @hide
+     */
+    public static final int INSTALL_FAILED_UID_CHANGED = -24;
+
+    /**
      * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
      * if the parser was given a path that is not a file, or does not end with the expected
diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java
index 679a8ac..b9811c82 100644
--- a/core/java/android/content/pm/PackageParser.java
+++ b/core/java/android/content/pm/PackageParser.java
@@ -129,7 +129,7 @@
         new PackageParser.SplitPermissionInfo[] {
             new PackageParser.SplitPermissionInfo(android.Manifest.permission.WRITE_EXTERNAL_STORAGE,
                     new String[] { android.Manifest.permission.READ_EXTERNAL_STORAGE },
-                    android.os.Build.VERSION_CODES.CUR_DEVELOPMENT+1),
+                    android.os.Build.VERSION_CODES.JELLY_BEAN),
             new PackageParser.SplitPermissionInfo(android.Manifest.permission.READ_CONTACTS,
                     new String[] { android.Manifest.permission.READ_CALL_LOG },
                     android.os.Build.VERSION_CODES.JELLY_BEAN),
diff --git a/core/res/res/drawable-hdpi/progress_bg_holo_dark.9.png b/core/res/res/drawable-hdpi/progress_bg_holo_dark.9.png
index 877fd2b..a4c5b8b 100644
--- a/core/res/res/drawable-hdpi/progress_bg_holo_dark.9.png
+++ b/core/res/res/drawable-hdpi/progress_bg_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/progress_bg_holo_dark.9.png b/core/res/res/drawable-mdpi/progress_bg_holo_dark.9.png
index 155e546..b1f5cf3 100644
--- a/core/res/res/drawable-mdpi/progress_bg_holo_dark.9.png
+++ b/core/res/res/drawable-mdpi/progress_bg_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/progress_bg_holo_dark.9.png b/core/res/res/drawable-xhdpi/progress_bg_holo_dark.9.png
index c8b87d7..3499528 100644
--- a/core/res/res/drawable-xhdpi/progress_bg_holo_dark.9.png
+++ b/core/res/res/drawable-xhdpi/progress_bg_holo_dark.9.png
Binary files differ
diff --git a/core/res/res/layout/notification_template_big_picture.xml b/core/res/res/layout/notification_template_big_picture.xml
index ecb3616..172dfe5 100644
--- a/core/res/res/layout/notification_template_big_picture.xml
+++ b/core/res/res/layout/notification_template_big_picture.xml
@@ -46,7 +46,7 @@
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:layout_marginTop="208dp"
-        android:layout_marginLeft="64dp"
+        android:paddingLeft="64dp"
         android:layout_gravity="bottom"
         android:background="#CC111111"
         >
diff --git a/core/res/res/layout/notification_template_big_text.xml b/core/res/res/layout/notification_template_big_text.xml
index b86177e..d377882 100644
--- a/core/res/res/layout/notification_template_big_text.xml
+++ b/core/res/res/layout/notification_template_big_text.xml
@@ -110,6 +110,7 @@
                 android:layout_height="0dp"
                 android:layout_marginBottom="8dp"
                 android:layout_marginRight="8dp"
+                android:layout_marginTop="2dp"
                 android:singleLine="false"
                 android:visibility="gone"
                 android:maxLines="8"
diff --git a/core/res/res/layout/notification_template_inbox.xml b/core/res/res/layout/notification_template_inbox.xml
index e9a3686..8ee6263 100644
--- a/core/res/res/layout/notification_template_inbox.xml
+++ b/core/res/res/layout/notification_template_inbox.xml
@@ -191,9 +191,8 @@
         <ImageView
             android:layout_width="match_parent"
             android:layout_height="1px"
-            android:id="@+id/overflow_divider"
-            android:layout_marginTop="8dp"
-            android:visibility="visible"
+            android:id="@+id/action_divider"
+            android:visibility="gone"
             android:background="?android:attr/dividerHorizontal" />
         <include
             layout="@layout/notification_action_list"
@@ -204,9 +203,10 @@
         <ImageView
             android:layout_width="match_parent"
             android:layout_height="1px"
-            android:id="@+id/action_divider"
-            android:visibility="gone"
-            android:background="?android:attr/dividerHorizontal" /><!-- note: divider below actions -->
+            android:id="@+id/overflow_divider"
+            android:layout_marginTop="8dp"
+            android:visibility="visible"
+            android:background="?android:attr/dividerHorizontal" />
         <LinearLayout
             android:id="@+id/line3"
             android:layout_width="match_parent"
diff --git a/data/fonts/DroidSansDevanagari-Regular.ttf b/data/fonts/DroidSansDevanagari-Regular.ttf
index 45e15e6a..a25e0e3 100644
--- a/data/fonts/DroidSansDevanagari-Regular.ttf
+++ b/data/fonts/DroidSansDevanagari-Regular.ttf
Binary files differ
diff --git a/packages/SystemUI/res/drawable-sw600dp-tvdpi/notification_panel_bg.9.png b/packages/SystemUI/res/drawable-sw600dp-tvdpi/notification_panel_bg.9.png
new file mode 100644
index 0000000..727ee49
--- /dev/null
+++ b/packages/SystemUI/res/drawable-sw600dp-tvdpi/notification_panel_bg.9.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-sw720dp-hdpi/notify_panel_notify_bg.9.png b/packages/SystemUI/res/drawable-sw720dp-hdpi/notify_panel_notify_bg.9.png
deleted file mode 100644
index 6cb7664..0000000
--- a/packages/SystemUI/res/drawable-sw720dp-hdpi/notify_panel_notify_bg.9.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-sw720dp-mdpi/notify_panel_notify_bg.9.png b/packages/SystemUI/res/drawable-sw720dp-mdpi/notify_panel_notify_bg.9.png
deleted file mode 100644
index e4c9dc1..0000000
--- a/packages/SystemUI/res/drawable-sw720dp-mdpi/notify_panel_notify_bg.9.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-sw720dp-tvdpi/notification_panel_bg.9.png b/packages/SystemUI/res/drawable-sw720dp-tvdpi/notification_panel_bg.9.png
new file mode 100644
index 0000000..571a7a5
--- /dev/null
+++ b/packages/SystemUI/res/drawable-sw720dp-tvdpi/notification_panel_bg.9.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-sw720dp-xhdpi/notify_panel_notify_bg.9.png b/packages/SystemUI/res/drawable-sw720dp-xhdpi/notify_panel_notify_bg.9.png
deleted file mode 100644
index 1f02714..0000000
--- a/packages/SystemUI/res/drawable-sw720dp-xhdpi/notify_panel_notify_bg.9.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-tvdpi/notification_panel_bg.9.png b/packages/SystemUI/res/drawable-tvdpi/notification_panel_bg.9.png
new file mode 100644
index 0000000..c3a105c
--- /dev/null
+++ b/packages/SystemUI/res/drawable-tvdpi/notification_panel_bg.9.png
Binary files differ
diff --git a/packages/SystemUI/res/layout/system_bar_notification_area.xml b/packages/SystemUI/res/layout/system_bar_notification_area.xml
index 739f3aa..a59dad2 100644
--- a/packages/SystemUI/res/layout/system_bar_notification_area.xml
+++ b/packages/SystemUI/res/layout/system_bar_notification_area.xml
@@ -78,22 +78,16 @@
         android:layout_height="match_parent"
         android:gravity="center"
         >
-        <com.android.systemui.statusbar.tablet.HoloClock
+        <com.android.systemui.statusbar.policy.Clock
             android:id="@+id/clock"
+            android:textAppearance="@style/TextAppearance.StatusBar.Clock"
             android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_marginBottom="3dip"
-            android:layout_marginLeft="8dip"
-            android:layout_marginRight="4dip"
-            >
-            <TextView android:id="@+id/time_solid"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:textAppearance="@style/TextAppearance.StatusBar.Clock"
-                android:singleLine="true"
-                android:textSize="40sp"
-                />
-        </com.android.systemui.statusbar.tablet.HoloClock>
+            android:layout_height="match_parent"
+            android:singleLine="true"
+            android:paddingLeft="6dip"
+            android:layout_marginRight="8dip"
+            android:gravity="center_vertical|left"
+            />
 
         <TextView
             android:id="@+id/network_text"
diff --git a/packages/SystemUI/res/layout/system_bar_notification_panel.xml b/packages/SystemUI/res/layout/system_bar_notification_panel.xml
index 5579505..48a188b 100644
--- a/packages/SystemUI/res/layout/system_bar_notification_panel.xml
+++ b/packages/SystemUI/res/layout/system_bar_notification_panel.xml
@@ -18,69 +18,57 @@
 <com.android.systemui.statusbar.tablet.NotificationPanel
     xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:systemui="http://schemas.android.com/apk/res/com.android.systemui"
-    android:id="@+id/panel_root"
+    android:id="@+id/content_parent"
     android:layout_height="match_parent"
     android:layout_width="match_parent"
     android:gravity="right"
     >
 
-    <ImageView android:id="@+id/clear_all_button"
-        android:layout_width="wrap_content"
-        android:layout_height="@*android:dimen/system_bar_height"
+    <!-- lift the panel up off the status bar while leaving a touchable are -->
+    <Space
+        android:id="@+id/system_bar_notification_panel_bottom_space"
+        android:layout_height="56dp"
+        android:layout_width="478dp"
         android:layout_alignParentRight="true"
         android:layout_alignParentBottom="true"
-        android:layout_marginRight="20dp"
-        android:paddingLeft="15dp"
-        android:paddingRight="15dp"
-        android:src="@drawable/ic_notify_clear"
-        android:visibility="invisible"
-        android:contentDescription="@string/accessibility_clear_all"
         />
 
-    <RelativeLayout
-        android:id="@+id/content_parent"
+    <LinearLayout
+        android:id="@+id/content_frame"
+        android:background="@drawable/notification_panel_bg"
         android:layout_height="wrap_content"
-        android:layout_width="match_parent"
-        android:layout_alignParentBottom="true"
+        android:layout_width="478dp"
+        android:orientation="vertical"
         android:layout_alignParentRight="true"
-        android:layout_marginBottom="8dp"
+        android:layout_above="@id/system_bar_notification_panel_bottom_space"
+        android:paddingBottom="8dp"
         >
 
         <include layout="@layout/system_bar_notification_panel_title"
-            android:layout_width="478dp"
-            android:layout_height="224dp"
-            android:layout_alignParentTop="true"
+            android:layout_width="match_parent"
+            android:layout_height="130dp"
+            android:layout_above="@id/content_frame"
             android:layout_alignParentRight="true"
+            android:layout_weight="0"
             />
 
-        <LinearLayout
-            android:id="@+id/content_frame"
-            android:background="@drawable/notify_panel_notify_bg"
-            android:layout_height="wrap_content"
-            android:layout_width="478dp"
-            android:orientation="vertical"
-            android:layout_alignParentRight="true"
-            android:layout_alignParentTop="true"
-            android:layout_marginTop="178dp"
-            >
-            <ScrollView
-                android:id="@+id/notification_scroller"
-                android:layout_height="wrap_content"
-                android:layout_width="match_parent"
-                android:layout_weight="1"
-                >
-                <com.android.systemui.statusbar.policy.NotificationRowLayout
-                    android:id="@+id/content"
-                    android:layout_width="match_parent"
-                    android:layout_height="wrap_content"
-                    android:gravity="center_horizontal|bottom"
-                    android:clickable="true"
-                    android:focusable="true"
-                    android:descendantFocusability="afterDescendants"
-                    systemui:rowHeight="@dimen/notification_row_min_height"
-                    />
-            </ScrollView>
-        </LinearLayout>
-    </RelativeLayout>
+        <ScrollView
 
+            android:id="@+id/notification_scroller"
+            android:layout_height="wrap_content"
+            android:layout_width="match_parent"
+            android:layout_weight="1"
+            >
+            <com.android.systemui.statusbar.policy.NotificationRowLayout
+                android:id="@+id/content"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:gravity="center_horizontal|bottom"
+                android:clickable="true"
+                android:focusable="true"
+                android:descendantFocusability="afterDescendants"
+                systemui:rowHeight="@dimen/notification_row_min_height"
+                />
+        </ScrollView>
+    </LinearLayout>
 </com.android.systemui.statusbar.tablet.NotificationPanel>
diff --git a/packages/SystemUI/res/layout/system_bar_notification_panel_title.xml b/packages/SystemUI/res/layout/system_bar_notification_panel_title.xml
index b985aaf..afe3b49 100644
--- a/packages/SystemUI/res/layout/system_bar_notification_panel_title.xml
+++ b/packages/SystemUI/res/layout/system_bar_notification_panel_title.xml
@@ -18,11 +18,14 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:systemui="http://schemas.android.com/apk/res/com.android.systemui"
     android:id="@+id/title_area"
+    android:background="@color/notification_panel_solid_background"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:clickable="true"
     android:orientation="vertical"
-    android:background="@drawable/notify_panel_clock_bg"
+    android:paddingLeft="26dp"
+    android:paddingTop="14dp"
+    android:paddingRight="26dp"
     >
 
     <TableLayout
@@ -31,7 +34,6 @@
         android:layout_height="wrap_content"
         android:layout_alignParentLeft="true"
         android:layout_alignParentBottom="true"
-        android:layout_marginLeft="16dp"
         android:layout_marginTop="16dp"
         android:layout_marginBottom="16dp"
         android:shrinkColumns="2,4"
@@ -167,7 +169,6 @@
                     android:id="@+id/settings_button"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
-                    android:paddingRight="16dp"
                     android:src="@drawable/ic_sysbar_quicksettings"
                     android:contentDescription="@string/accessibility_settings_button"
                     />
@@ -176,7 +177,6 @@
                     android:id="@+id/notification_button"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
-                    android:paddingRight="16dp"
                     android:src="@drawable/ic_notification_open"
                     android:visibility="invisible"
                     android:contentDescription="@string/accessibility_notifications_button"
@@ -186,40 +186,46 @@
         </TableRow>
     </TableLayout>
 
-    <com.android.systemui.statusbar.tablet.HoloClock
-        android:id="@+id/clock"
+    <LinearLayout
+        xmlns:android="http://schemas.android.com/apk/res/android"
+        xmlns:systemui="http://schemas.android.com/apk/res/com.android.systemui"
+        android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:layout_width="wrap_content"
-        android:layout_alignParentRight="true"
-        android:layout_marginRight="16dip"
-        android:layout_marginTop="16dip"
+        android:paddingTop="@dimen/notification_panel_header_padding_top"
+        android:orientation="horizontal"
+        android:gravity="center_vertical"
+        android:baselineAligned="false"
         >
-        <TextView android:id="@+id/time_bg"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:gravity="right"
-            android:singleLine="true"
-            android:textSize="92sp"
-            android:textColor="#ffffff" />
-        <TextView android:id="@+id/time_fg"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:gravity="right"
-            android:singleLine="true"
-            android:textSize="92sp"
-            android:textColor="#ffffff" />
-    </com.android.systemui.statusbar.tablet.HoloClock>
 
-    <com.android.systemui.statusbar.policy.DateView
-        android:id="@+id/date"
-        style="@style/StatusBarNotificationText"
-        android:layout_height="wrap_content"
-        android:layout_width="wrap_content"
-        android:layout_alignBottom="@id/clock"
-        android:layout_alignParentLeft="true"
-        android:gravity="left"
-        android:layout_marginLeft="16dp"
-        android:textColor="#ffffff"
-        />
+        <com.android.systemui.statusbar.policy.Clock
+            android:id="@+id/clock"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:singleLine="true"
+            android:textAppearance="@style/TextAppearance.StatusBar.Expanded.Clock"
+            />
+    
+        <com.android.systemui.statusbar.policy.DateView
+            android:id="@+id/date"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginLeft="8dp"
+            android:layout_marginRight="8dp"
+            android:textAppearance="@style/TextAppearance.StatusBar.Expanded.Date"
+            />
 
+        <Space
+            android:layout_width="0dp"
+            android:layout_height="48dp"
+            android:layout_weight="1"
+            />
+
+        <ImageView android:id="@+id/clear_all_button"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:scaleType="center"
+            android:src="@drawable/ic_notify_clear"
+            android:contentDescription="@string/accessibility_clear_all"
+            />
+    </LinearLayout>
 </com.android.systemui.statusbar.tablet.NotificationPanelTitle>
diff --git a/packages/SystemUI/res/values-sw720dp/styles.xml b/packages/SystemUI/res/values-sw720dp/styles.xml
index f3d4a0f..684258a 100644
--- a/packages/SystemUI/res/values-sw720dp/styles.xml
+++ b/packages/SystemUI/res/values-sw720dp/styles.xml
@@ -51,4 +51,24 @@
         <item name="android:background">@android:drawable/divider_horizontal_dark</item>
     </style>
 
+    <style name="TextAppearance.StatusBar.Clock" parent="@*android:style/TextAppearance.StatusBar.Icon">
+        <item name="android:textSize">30dp</item>
+        <item name="android:textStyle">normal</item>
+        <item name="android:textColor">@android:color/holo_blue_light</item>
+    </style>
+
+    <style name="TextAppearance.StatusBar.Expanded.Clock">
+        <item name="android:textSize">48dp</item>
+        <item name="android:fontFamily">sans-serif-light</item>
+        <item name="android:textStyle">normal</item>
+        <item name="android:textColor">#ffffff</item>
+    </style>
+
+    <style name="TextAppearance.StatusBar.Expanded.Date">
+        <item name="android:textSize">14dp</item>
+        <item name="android:textStyle">normal</item>
+        <item name="android:textColor">#666666</item>
+        <item name="android:textAllCaps">true</item>
+    </style>
+
 </resources>
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/HoloClock.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/HoloClock.java
deleted file mode 100644
index f98caa2..0000000
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/HoloClock.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.systemui.statusbar.tablet;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.content.res.AssetManager;
-import android.content.res.Resources;
-import android.content.res.TypedArray;
-import android.graphics.Canvas;
-import android.graphics.Typeface;
-import android.graphics.drawable.Drawable;
-import android.text.Spannable;
-import android.text.SpannableStringBuilder;
-import android.text.format.DateFormat;
-import android.text.style.CharacterStyle;
-import android.text.style.ForegroundColorSpan;
-import android.text.style.RelativeSizeSpan;
-import android.text.style.RelativeSizeSpan;
-import android.text.style.StyleSpan;
-import android.util.AttributeSet;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.FrameLayout;
-import android.widget.TextView;
-
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.TimeZone;
-
-import com.android.systemui.R;
-
-public class HoloClock extends FrameLayout {
-    private boolean mAttached;
-    private Calendar mCalendar;
-    private String mClockFormatString;
-    private SimpleDateFormat mClockFormat;
-
-    private static final String FONT_DIR = "/system/fonts/";
-    private static final String CLOCK_FONT = FONT_DIR + "AndroidClock_Solid.ttf";
-    private static final String CLOCK_FG_FONT = FONT_DIR + "AndroidClock.ttf";
-    private static final String CLOCK_BG_FONT = FONT_DIR + "AndroidClock_Highlight.ttf";
-
-    private static Typeface sBackgroundType, sForegroundType, sSolidType;
-    private TextView mSolidText, mBgText, mFgText;
-
-    public HoloClock(Context context) {
-        this(context, null);
-    }
-
-    public HoloClock(Context context, AttributeSet attrs) {
-        this(context, attrs, 0);
-    }
-
-    public HoloClock(Context context, AttributeSet attrs, int defStyle) {
-        super(context, attrs, defStyle);
-    }
-
-    @Override
-    protected void onFinishInflate() {
-        super.onFinishInflate();
-
-        if (sSolidType == null) {
-            sSolidType = Typeface.createFromFile(CLOCK_FONT);
-            sBackgroundType = Typeface.createFromFile(CLOCK_BG_FONT);
-            sForegroundType = Typeface.createFromFile(CLOCK_FG_FONT);
-        }
-        mBgText = (TextView) findViewById(R.id.time_bg);
-        if (mBgText != null) {
-            mBgText.setTypeface(sBackgroundType);
-            mBgText.setVisibility(View.INVISIBLE);
-        }
-
-        mFgText = (TextView) findViewById(R.id.time_fg);
-        if (mFgText != null) {
-            mFgText.setTypeface(sForegroundType);
-        }
-        mSolidText = (TextView) findViewById(R.id.time_solid);
-        if (mSolidText != null) {
-            mSolidText.setTypeface(sSolidType);
-        }
-    }
-
-    @Override
-    protected void onAttachedToWindow() {
-        super.onAttachedToWindow();
-
-        if (!mAttached) {
-            mAttached = true;
-            IntentFilter filter = new IntentFilter();
-
-            filter.addAction(Intent.ACTION_TIME_TICK);
-            filter.addAction(Intent.ACTION_TIME_CHANGED);
-            filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
-            filter.addAction(Intent.ACTION_CONFIGURATION_CHANGED);
-
-            getContext().registerReceiver(mIntentReceiver, filter, null, getHandler());
-        }
-
-        // NOTE: It's safe to do these after registering the receiver since the receiver always runs
-        // in the main thread, therefore the receiver can't run before this method returns.
-
-        // The time zone may have changed while the receiver wasn't registered, so update the Time
-        mCalendar = Calendar.getInstance(TimeZone.getDefault());
-
-        // Make sure we update to the current time
-        updateClock();
-    }
-
-    @Override
-    protected void onDetachedFromWindow() {
-        super.onDetachedFromWindow();
-        if (mAttached) {
-            getContext().unregisterReceiver(mIntentReceiver);
-            mAttached = false;
-        }
-    }
-
-    private final BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
-        @Override
-        public void onReceive(Context context, Intent intent) {
-            String action = intent.getAction();
-            if (action.equals(Intent.ACTION_TIMEZONE_CHANGED)) {
-                String tz = intent.getStringExtra("time-zone");
-                mCalendar = Calendar.getInstance(TimeZone.getTimeZone(tz));
-                if (mClockFormat != null) {
-                    mClockFormat.setTimeZone(mCalendar.getTimeZone());
-                }
-            }
-            updateClock();
-        }
-    };
-
-    final void updateClock() {
-        mCalendar.setTimeInMillis(System.currentTimeMillis());
-        CharSequence txt = getTimeText();
-        if (mBgText != null) mBgText.setText(txt);
-        if (mFgText != null) mFgText.setText(txt);
-        if (mSolidText != null) mSolidText.setText(txt);
-    }
-
-    private final CharSequence getTimeText() {
-        Context context = getContext();
-        int res = DateFormat.is24HourFormat(context)
-            ? com.android.internal.R.string.twenty_four_hour_time_format
-            : com.android.internal.R.string.twelve_hour_time_format;
-
-        SimpleDateFormat sdf;
-        String format = context.getString(res);
-        if (!format.equals(mClockFormatString)) {
-            // we don't want AM/PM showing up in our statusbar, even in 12h mode
-            format = format.replaceAll("a", "").trim();
-            mClockFormat = sdf = new SimpleDateFormat(format);
-            mClockFormatString = format;
-        } else {
-            sdf = mClockFormat;
-        }
-        String result = sdf.format(mCalendar.getTime());
-        return result;
-    }
-}
-
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/NotificationPanel.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/NotificationPanel.java
index b82e1d0..71657f5 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/NotificationPanel.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/NotificationPanel.java
@@ -34,10 +34,15 @@
 import android.view.animation.Interpolator;
 import android.widget.RelativeLayout;
 
+import com.android.systemui.ExpandHelper;
 import com.android.systemui.R;
+import com.android.systemui.statusbar.policy.NotificationRowLayout;
 
 public class NotificationPanel extends RelativeLayout implements StatusBarPanel,
         View.OnClickListener {
+    private ExpandHelper mExpandHelper;
+    private NotificationRowLayout latestItems;
+
     static final String TAG = "Tablet/NotificationPanel";
     static final boolean DEBUG = false;
 
@@ -103,6 +108,16 @@
         setContentFrameVisible(mNotificationCount > 0, false);
     }
 
+    @Override
+    protected void onAttachedToWindow () {
+        super.onAttachedToWindow();
+        latestItems = (NotificationRowLayout) findViewById(R.id.content);
+        int minHeight = getResources().getDimensionPixelSize(R.dimen.notification_row_min_height);
+        int maxHeight = getResources().getDimensionPixelSize(R.dimen.notification_row_max_height);
+        mExpandHelper = new ExpandHelper(mContext, latestItems, minHeight, maxHeight);
+        mExpandHelper.setEventSource(this);
+    }
+
     private View.OnClickListener mClearButtonListener = new View.OnClickListener() {
         public void onClick(View v) {
             mBar.clearAll();
@@ -321,14 +336,11 @@
     }
 
     public boolean isInContentArea(int x, int y) {
-        mContentArea.left = mTitleArea.getLeft() + mTitleArea.getPaddingLeft();
-        mContentArea.top = mTitleArea.getTop() + mTitleArea.getPaddingTop() 
+        mContentArea.left = mContentFrame.getLeft() + mContentFrame.getPaddingLeft();
+        mContentArea.top = mContentFrame.getTop() + mContentFrame.getPaddingTop()
             + (int)mContentParent.getTranslationY(); // account for any adjustment
-        mContentArea.right = mTitleArea.getRight() - mTitleArea.getPaddingRight();
-
-        View theBottom = (mContentFrame.getVisibility() == View.VISIBLE)
-            ? mContentFrame : mTitleArea;
-        mContentArea.bottom = theBottom.getBottom() - theBottom.getPaddingBottom();
+        mContentArea.right = mContentFrame.getRight() - mContentFrame.getPaddingRight();
+        mContentArea.bottom = mContentFrame.getBottom() - mContentFrame.getPaddingBottom();
 
         offsetDescendantRectToMyCoords(mContentParent, mContentArea);
         return mContentArea.contains(x, y);
@@ -440,5 +452,25 @@
         public void onAnimationStart(Animator animation) {
         }
     }
+
+    @Override
+    public boolean onInterceptTouchEvent(MotionEvent ev) {
+        MotionEvent cancellation = MotionEvent.obtain(ev);
+        cancellation.setAction(MotionEvent.ACTION_CANCEL);
+
+        boolean intercept = mExpandHelper.onInterceptTouchEvent(ev) ||
+                super.onInterceptTouchEvent(ev);
+        if (intercept) {
+            latestItems.onInterceptTouchEvent(cancellation);
+        }
+        return intercept;
+    }
+
+    @Override
+    public boolean onTouchEvent(MotionEvent ev) {
+        boolean handled = mExpandHelper.onTouchEvent(ev) ||
+                super.onTouchEvent(ev);
+        return handled;
+    }
 }
 
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/NotificationPanelTitle.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/NotificationPanelTitle.java
index 689bc36..00cf3c5 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/NotificationPanelTitle.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/NotificationPanelTitle.java
@@ -16,6 +16,8 @@
 
 package com.android.systemui.statusbar.tablet;
 
+import java.util.ArrayList;
+
 import android.content.Context;
 import android.util.AttributeSet;
 import android.view.MotionEvent;
@@ -24,11 +26,17 @@
 import android.view.accessibility.AccessibilityEvent;
 import android.widget.RelativeLayout;
 
+import com.android.systemui.R;
+
+
 public class NotificationPanelTitle extends RelativeLayout implements View.OnClickListener {
     private NotificationPanel mPanel;
+    private ArrayList<View> buttons;
+    private View mNotificationsButton;
 
     public NotificationPanelTitle(Context context, AttributeSet attrs) {
         super(context, attrs);
+        buttons = new ArrayList<View>();
         setOnClickListener(this);
     }
 
@@ -37,6 +45,23 @@
     }
 
     @Override
+    public void onFinishInflate() {
+        super.onFinishInflate();
+        buttons.add(findViewById(R.id.settings_button));
+        buttons.add(findViewById(R.id.notification_button));
+    }
+
+    @Override
+    public void setPressed(boolean pressed) {
+        super.setPressed(pressed);
+        for (View button : buttons) {
+            if (button != null) {
+                button.setPressed(pressed);
+            }
+        }
+    }
+
+    @Override
     public boolean onTouchEvent(MotionEvent e) {
         switch (e.getAction()) {
             case MotionEvent.ACTION_DOWN:
diff --git a/services/java/com/android/server/PowerManagerService.java b/services/java/com/android/server/PowerManagerService.java
index 0280425..6695cb9 100644
--- a/services/java/com/android/server/PowerManagerService.java
+++ b/services/java/com/android/server/PowerManagerService.java
@@ -1221,6 +1221,8 @@
                     + " mLightSensorAdjustSetting=" + mLightSensorAdjustSetting);
             pw.println("  mLightSensorValue=" + mLightSensorValue
                     + " mLightSensorPendingValue=" + mLightSensorPendingValue);
+            pw.println("  mHighestLightSensorValue=" + mHighestLightSensorValue
+                    + " mWaitingForFirstLightSensor=" + mWaitingForFirstLightSensor);
             pw.println("  mLightSensorPendingDecrease=" + mLightSensorPendingDecrease
                     + " mLightSensorPendingIncrease=" + mLightSensorPendingIncrease);
             pw.println("  mLightSensorScreenBrightness=" + mLightSensorScreenBrightness
@@ -2281,8 +2283,13 @@
         }
 
         public void dump(PrintWriter pw, String string) {
-            pw.println(prefix + "animating: " + "start:" + startValue + ", end:" + endValue
+            pw.println(string);
+            pw.println("  animating: " + "start:" + startValue + ", end:" + endValue
                     + ", duration:" + duration + ", current:" + currentValue);
+            pw.println("  startSensorValue:" + startSensorValue
+                    + " endSensorValue:" + endSensorValue);
+            pw.println("  startSensorValue:" + startSensorValue
+                    + " endSensorValue:" + endSensorValue);
         }
 
         public void animateTo(int target, int mask, int animationDuration) {
@@ -2291,6 +2298,16 @@
 
         public void animateTo(int target, int sensorTarget, int mask, int animationDuration) {
             synchronized(this) {
+                if ((mask & SCREEN_BRIGHT_BIT) == 0) {
+                    // We only animate keyboard and button when passed in with SCREEN_BRIGHT_BIT.
+                    if ((mask & BUTTON_BRIGHT_BIT) != 0) {
+                        mButtonLight.setBrightness(target);
+                    }
+                    if ((mask & KEYBOARD_BRIGHT_BIT) != 0) {
+                        mKeyboardLight.setBrightness(target);
+                    }
+                    return;
+                }
                 if (isAnimating() && (mask ^ currentMask) != 0) {
                     // current animation is unrelated to new animation, jump to final values
                     cancelAnimation();
@@ -2653,13 +2670,6 @@
             return;
         }
 
-        final int stepsToTargetLevel;
-        if (mHighestLightSensorValue <= value) {
-            stepsToTargetLevel = AUTOBRIGHTNESS_ANIM_STEPS;
-        } else {
-            stepsToTargetLevel = AUTODIMNESS_ANIM_STEPS;
-        }
-
         if (mLightSensorValue != value) {
             mLightSensorValue = value;
             if ((mPowerState & BATTERY_LOW_BIT) == 0) {
@@ -2686,7 +2696,18 @@
 
                 if (mAutoBrightessEnabled && mScreenBrightnessOverride < 0) {
                     if (!mSkippedScreenOn && !mInitialAnimation) {
-                        int steps = immediate ? IMMEDIATE_ANIM_STEPS : stepsToTargetLevel;
+                        final int steps;
+                        if (immediate) {
+                            steps = IMMEDIATE_ANIM_STEPS;
+                        } else {
+                            synchronized (mScreenBrightnessAnimator) {
+                                if (mScreenBrightnessAnimator.currentValue <= lcdValue) {
+                                    steps = AUTOBRIGHTNESS_ANIM_STEPS;
+                                } else {
+                                    steps = AUTODIMNESS_ANIM_STEPS;
+                                }
+                            }
+                        }
                         mScreenBrightnessAnimator.animateTo(lcdValue, value,
                                 SCREEN_BRIGHT_BIT, steps * NOMINAL_FRAME_TIME_MS);
                     }
diff --git a/services/java/com/android/server/pm/Installer.java b/services/java/com/android/server/pm/Installer.java
index 9b1973e..48004bb 100644
--- a/services/java/com/android/server/pm/Installer.java
+++ b/services/java/com/android/server/pm/Installer.java
@@ -243,6 +243,17 @@
         return execute(builder.toString());
     }
 
+    public int fixUid(String name, int uid, int gid) {
+        StringBuilder builder = new StringBuilder("fixuid");
+        builder.append(' ');
+        builder.append(name);
+        builder.append(' ');
+        builder.append(uid);
+        builder.append(' ');
+        builder.append(gid);
+        return execute(builder.toString());
+    }
+
     public int deleteCacheFiles(String name) {
         StringBuilder builder = new StringBuilder("rmcache");
         builder.append(' ');
diff --git a/services/java/com/android/server/pm/PackageManagerService.java b/services/java/com/android/server/pm/PackageManagerService.java
index 9327182..49d2ebd 100644
--- a/services/java/com/android/server/pm/PackageManagerService.java
+++ b/services/java/com/android/server/pm/PackageManagerService.java
@@ -191,6 +191,7 @@
     static final int SCAN_NO_PATHS = 1<<5;
     static final int SCAN_UPDATE_TIME = 1<<6;
     static final int SCAN_DEFER_DEX = 1<<7;
+    static final int SCAN_BOOTING = 1<<8;
 
     static final int REMOVE_CHATTY = 1<<16;
 
@@ -924,7 +925,7 @@
 
             // Set flag to monitor and not change apk file paths when
             // scanning install directories.
-            int scanMode = SCAN_MONITOR | SCAN_NO_PATHS | SCAN_DEFER_DEX;
+            int scanMode = SCAN_MONITOR | SCAN_NO_PATHS | SCAN_DEFER_DEX | SCAN_BOOTING;
             if (mNoDexOpt) {
                 Slog.w(TAG, "Running ENG build: no pre-dexopt!");
                 scanMode |= SCAN_NO_DEX;
@@ -3750,17 +3751,34 @@
         } else {
             // This is a normal package, need to make its data directory.
             dataPath = getDataPathForPackage(pkg.packageName, 0);
-            
+
             boolean uidError = false;
-            
+
             if (dataPath.exists()) {
+                // XXX should really do this check for each user.
                 mOutPermissions[1] = 0;
                 FileUtils.getPermissions(dataPath.getPath(), mOutPermissions);
 
                 // If we have mismatched owners for the data path, we have a problem.
                 if (mOutPermissions[1] != pkg.applicationInfo.uid) {
                     boolean recovered = false;
-                    if ((parseFlags&PackageParser.PARSE_IS_SYSTEM) != 0) {
+                    if (mOutPermissions[1] == 0) {
+                        // The directory somehow became owned by root.  Wow.
+                        // This is probably because the system was stopped while
+                        // installd was in the middle of messing with its libs
+                        // directory.  Ask installd to fix that.
+                        int ret = mInstaller.fixUid(pkgName, pkg.applicationInfo.uid,
+                                pkg.applicationInfo.uid);
+                        if (ret >= 0) {
+                            recovered = true;
+                            String msg = "Package " + pkg.packageName
+                                    + " unexpectedly changed to uid 0; recovered to " +
+                                    + pkg.applicationInfo.uid;
+                            reportSettingsProblem(Log.WARN, msg);
+                        }
+                    }
+                    if (!recovered && ((parseFlags&PackageParser.PARSE_IS_SYSTEM) != 0
+                            || (scanMode&SCAN_BOOTING) != 0)) {
                         // If this is a system app, we can at least delete its
                         // current data so the application will still work.
                         int ret = mInstaller.remove(pkgName, 0);
@@ -3769,7 +3787,9 @@
                             // Remove the data directories for all users
                             sUserManager.removePackageForAllUsers(pkgName);
                             // Old data gone!
-                            String msg = "System package " + pkg.packageName
+                            String prefix = (parseFlags&PackageParser.PARSE_IS_SYSTEM) != 0
+                                    ? "System package " : "Third party package ";
+                            String msg = prefix + pkg.packageName
                                     + " has changed from uid: "
                                     + mOutPermissions[1] + " to "
                                     + pkg.applicationInfo.uid + "; old data erased";
@@ -3781,7 +3801,7 @@
                                     pkg.applicationInfo.uid);
                             if (ret == -1) {
                                 // Ack should not happen!
-                                msg = "System package " + pkg.packageName
+                                msg = prefix + pkg.packageName
                                         + " could not have data directory re-created after delete.";
                                 reportSettingsProblem(Log.WARN, msg);
                                 mLastScanError = PackageManager.INSTALL_FAILED_INSUFFICIENT_STORAGE;
@@ -3794,6 +3814,11 @@
                         if (!recovered) {
                             mHasSystemUidErrors = true;
                         }
+                    } else if (!recovered) {
+                        // If we allow this install to proceed, we will be broken.
+                        // Abort, abort!
+                        mLastScanError = PackageManager.INSTALL_FAILED_UID_CHANGED;
+                        return null;
                     }
                     if (!recovered) {
                         pkg.applicationInfo.dataDir = "/mismatched_uid/settings_"
@@ -6140,7 +6165,22 @@
 
     private InstallArgs createInstallArgs(int flags, String fullCodePath, String fullResourcePath,
             String nativeLibraryPath) {
-        if (installOnSd(flags) || installForwardLocked(flags)) {
+        final boolean isInAsec;
+        if (installOnSd(flags)) {
+            /* Apps on SD card are always in ASEC containers. */
+            isInAsec = true;
+        } else if (installForwardLocked(flags)
+                && !fullCodePath.startsWith(mDrmAppPrivateInstallDir.getAbsolutePath())) {
+            /*
+             * Forward-locked apps are only in ASEC containers if they're the
+             * new style
+             */
+            isInAsec = true;
+        } else {
+            isInAsec = false;
+        }
+
+        if (isInAsec) {
             return new AsecInstallArgs(fullCodePath, fullResourcePath, nativeLibraryPath,
                     installOnSd(flags), installForwardLocked(flags));
         } else {
diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java
index 9e08584..ba4df96b 100755
--- a/services/java/com/android/server/wm/WindowManagerService.java
+++ b/services/java/com/android/server/wm/WindowManagerService.java
@@ -8416,7 +8416,8 @@
             // performance reasons).
             mInnerFields.mObscured = true;
         } else if (canBeSeen && (attrFlags & FLAG_DIM_BEHIND) != 0
-                && !(w.mAppToken != null && w.mAppToken.hiddenRequested)) {
+                && !(w.mAppToken != null && w.mAppToken.hiddenRequested)
+                && !w.mExiting) {
             if (localLOGV) Slog.v(TAG, "Win " + w + " obscured=" + mInnerFields.mObscured);
             if (!mInnerFields.mDimming) {
                 //Slog.i(TAG, "DIM BEHIND: " + w);
diff --git a/services/java/com/android/server/wm/WindowStateAnimator.java b/services/java/com/android/server/wm/WindowStateAnimator.java
index 485f4a7..5908958 100644
--- a/services/java/com/android/server/wm/WindowStateAnimator.java
+++ b/services/java/com/android/server/wm/WindowStateAnimator.java
@@ -1067,6 +1067,11 @@
 
         if (w.mAttachedHidden || !w.isReadyForDisplay()) {
             hide();
+            // TODO: Consider moving the following into hide() and out of finishExit() as well.
+            if (mService.mWallpaperTarget == mWin && mService.mLowerWallpaperTarget == null) {
+                mAnimator.hideWallpapersLocked();
+                mAnimator.mPendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
+            }
             // If we are waiting for this window to handle an
             // orientation change, well, it is hidden, so
             // doesn't really matter.  Note that this does
diff --git a/wifi/java/android/net/wifi/p2p/WifiP2pService.java b/wifi/java/android/net/wifi/p2p/WifiP2pService.java
index a3a697c..9e004d0 100644
--- a/wifi/java/android/net/wifi/p2p/WifiP2pService.java
+++ b/wifi/java/android/net/wifi/p2p/WifiP2pService.java
@@ -703,6 +703,7 @@
                 case WifiP2pManager.CLEAR_LOCAL_SERVICES:
                     if (DBG) logd(getName() + " clear service");
                     clearLocalServices(message.replyTo);
+                    replyToMessage(message, WifiP2pManager.CLEAR_LOCAL_SERVICES_SUCCEEDED);
                     break;
                 case WifiP2pManager.ADD_SERVICE_REQUEST:
                     if (DBG) logd(getName() + " add service request");