Split app info into several screens

The root screen now only has the uninstall/force stop/disable buttons
and the rest has moved to sub screens listed in a preference list.
The root screen as UI approximate to the new mocks, but the separated
screens (storage, launch by default, etc.) have yet to receive their
visual overhaul.

Bug: 19511439
Change-Id: I4e01fbaefc69e0652edea2429d9e9b028c78e825
diff --git a/res/layout/app_notification_header.xml b/res/layout/app_header.xml
similarity index 100%
rename from res/layout/app_notification_header.xml
rename to res/layout/app_header.xml
diff --git a/res/layout/app_preferred_settings.xml b/res/layout/app_preferred_settings.xml
new file mode 100644
index 0000000..7c6a45f
--- /dev/null
+++ b/res/layout/app_preferred_settings.xml
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright 2015, 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.
+*/
+-->
+<ScrollView
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:clipToPadding="false"
+    android:scrollbarStyle="@integer/preference_scrollbar_style">
+
+    <LinearLayout
+        android:id="@+id/all_details"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:paddingStart="?android:attr/listPreferredItemPaddingStart"
+        android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
+        android:paddingBottom="5dip"
+        android:orientation="vertical">
+
+        <!-- Prefered activities section -->
+        <TextView android:id="@+id/auto_launch_title"
+            style="?android:attr/listSeparatorTextViewStyle"
+            android:layout_marginTop="8dip"
+            android:text="@string/auto_launch_label" />
+
+        <RelativeLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_gravity="center_vertical"
+            android:paddingStart="?android:attr/listPreferredItemPaddingStart"
+            android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">
+            <TextView android:id="@+id/auto_launch"
+                android:textAppearance="?android:attr/textAppearanceSmall"
+                android:layout_alignParentStart="true"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:paddingTop="6dip" />
+
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_below="@id/auto_launch"
+                android:paddingTop="4dip"
+                android:orientation="horizontal">
+                <View
+                    android:layout_width="120dip"
+                    android:layout_height="0dip"
+                    android:layout_weight="0.4" />
+                <View
+                    android:layout_width="0dip"
+                    android:layout_height="0dip"
+                    android:visibility="invisible"
+                    android:layout_weight="0.2" />
+                <Button
+                    android:id="@+id/clear_activities_button"
+                    android:layout_width="120dip"
+                    android:layout_height="wrap_content"
+                    android:layout_weight="0.4"
+                    android:text="@string/clear_activities" />
+            </LinearLayout>
+        </RelativeLayout>
+
+    </LinearLayout>
+</ScrollView>
diff --git a/res/layout/installed_app_details.xml b/res/layout/installed_app_details.xml
index 5b923fc..ccbe105 100644
--- a/res/layout/installed_app_details.xml
+++ b/res/layout/installed_app_details.xml
@@ -16,448 +16,43 @@
 ** limitations under the License.
 */
 -->
-<ScrollView
+<LinearLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/all_details"
     android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:clipToPadding="false"
-    android:scrollbarStyle="@integer/preference_scrollbar_style">
+    android:layout_height="wrap_content"
+    android:paddingStart="?android:attr/listPreferredItemPaddingStart"
+    android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
+    android:orientation="vertical">
 
+    <!-- App snippet with buttons -->
     <LinearLayout
-        android:id="@+id/all_details"
         android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:paddingStart="?android:attr/listPreferredItemPaddingStart"
-        android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
-        android:paddingBottom="5dip"
+        android:layout_height="wrap_content"
+        android:layout_gravity="center_vertical"
+        android:paddingTop="5dip"
+        android:paddingBottom="10dip"
         android:orientation="vertical">
 
-        <!-- App snippet with buttons -->
-        <LinearLayout
+        <!-- Application snippet label, version and icon -->
+        <include
+            layout="@layout/manage_applications_item"
+            android:id="@+id/app_snippet" />
+
+        <Space
             android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_gravity="center_vertical"
-            android:orientation="vertical">
+            android:layout_height="5dp" />
 
-            <!-- Application snippet label, version and icon -->
-            <include
-                layout="@layout/manage_applications_item"
-                android:id="@+id/app_snippet" />
+        <!-- Force stop and uninstall buttons -->
+        <include
+            layout="@layout/two_buttons_panel"
+            android:id="@+id/control_buttons_panel"/>
 
-            <!-- Force stop and uninstall buttons -->
-            <include
-                layout="@layout/two_buttons_panel"
-                android:id="@+id/control_buttons_panel"/>
+        <!-- Force stop and uninstall buttons -->
+        <include
+            layout="@layout/two_buttons_panel"
+            android:id="@+id/more_control_buttons_panel"/>
 
-            <!-- Force stop and uninstall buttons -->
-            <include
-                layout="@layout/two_buttons_panel"
-                android:id="@+id/more_control_buttons_panel"/>
-
-            <!-- Ban notifications for this package -->
-            <CheckBox android:id="@+id/notification_switch"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_gravity="start"
-                android:layout_marginTop="4dip"
-                android:text="@string/app_notifications_switch_label" />
-
-        </LinearLayout>
-
-        <TextView
-            style="?android:attr/listSeparatorTextViewStyle"
-            android:layout_marginTop="8dip"
-            android:text="@string/storage_label" />
-
-        <LinearLayout
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:orientation="vertical"
-            android:paddingStart="?android:attr/listPreferredItemPaddingStart"
-            android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">
-            <LinearLayout
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:orientation="horizontal"
-                android:baselineAligned="true"
-                android:paddingTop="-1dip">
-                <TextView
-                    android:id="@+id/total_size_prefix"
-                    android:text="@string/total_size_label"
-                    android:textAppearance="?android:attr/textAppearanceMedium"
-                    android:layout_height="wrap_content"
-                    android:layout_width="wrap_content"
-                    android:maxLines="1"
-                    android:paddingTop="6dip" />
-                <ImageView
-                    android:id="@+id/info_size_dots"
-                    android:src="@drawable/dotted_line_480px"
-                    android:layout_width="0dip"
-                    android:layout_weight="1"
-                    android:layout_height="1px"
-                    android:layout_gravity="bottom"
-                    android:layout_marginStart="1dip"
-                    android:layout_marginEnd="1dip"
-                    android:layout_marginBottom="4dip"
-                    android:scaleType="center"
-                    android:contentDescription="@null" />
-                <TextView
-                    android:id="@+id/total_size_text"
-                    android:paddingTop="6dip"
-                    android:textAppearance="?android:attr/textAppearanceMedium"
-                    android:layout_height="wrap_content"
-                    android:layout_width="wrap_content"
-                    android:maxLines="1" />
-            </LinearLayout>
-
-            <LinearLayout
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:orientation="horizontal"
-                android:baselineAligned="true"
-                android:paddingTop="-1dip">
-                <TextView
-                    android:id="@+id/application_size_prefix"
-                    android:text="@string/application_size_label"
-                    android:textAppearance="?android:attr/textAppearanceMedium"
-                    android:layout_height="wrap_content"
-                    android:layout_width="wrap_content"
-                    android:maxLines="1"
-                    android:paddingTop="6dip" />
-                <ImageView
-                    android:id="@+id/info_size_dots"
-                    android:src="@drawable/dotted_line_480px"
-                    android:layout_width="0dip"
-                    android:layout_weight="1"
-                    android:layout_height="1px"
-                    android:layout_gravity="bottom"
-                    android:layout_marginStart="1dip"
-                    android:layout_marginEnd="1dip"
-                    android:layout_marginBottom="4dip"
-                    android:scaleType="center"
-                    android:contentDescription="@null" />
-                <TextView
-                    android:id="@+id/application_size_text"
-                    android:textAppearance="?android:attr/textAppearanceMedium"
-                    android:paddingTop="6dip"
-                    android:layout_height="wrap_content"
-                    android:layout_width="wrap_content"
-                    android:maxLines="1" />
-            </LinearLayout>
-
-            <LinearLayout
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:orientation="horizontal"
-                android:baselineAligned="true"
-                android:paddingTop="-1dip">
-                <TextView
-                    android:id="@+id/external_code_size_prefix"
-                    android:text="@string/external_code_size_label"
-                    android:textAppearance="?android:attr/textAppearanceMedium"
-                    android:layout_height="wrap_content"
-                    android:layout_width="wrap_content"
-                    android:maxLines="1"
-                    android:paddingTop="6dip" />
-                <ImageView
-                    android:id="@+id/info_size_dots"
-                    android:src="@drawable/dotted_line_480px"
-                    android:layout_width="0dip"
-                    android:layout_weight="1"
-                    android:layout_height="1px"
-                    android:layout_gravity="bottom"
-                    android:layout_marginStart="1dip"
-                    android:layout_marginEnd="1dip"
-                    android:layout_marginBottom="4dip"
-                    android:scaleType="center"
-                    android:contentDescription="@null" />
-                <TextView
-                    android:id="@+id/external_code_size_text"
-                    android:textAppearance="?android:attr/textAppearanceMedium"
-                    android:paddingTop="6dip"
-                    android:layout_height="wrap_content"
-                    android:layout_width="wrap_content"
-                    android:maxLines="1" />
-            </LinearLayout>
-
-            <LinearLayout
-                android:id="@+id/info_size"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:orientation="horizontal"
-                android:baselineAligned="true"
-                android:paddingTop="-1dip">
-                <TextView
-                    android:id="@+id/data_size_prefix"
-                    android:text="@string/data_size_label"
-                    android:textAppearance="?android:attr/textAppearanceMedium"
-                    android:layout_height="wrap_content"
-                    android:layout_width="wrap_content"
-                    android:maxLines="1"
-                    android:paddingTop="6dip" />
-                <ImageView
-                    android:id="@+id/info_size_dots"
-                    android:src="@drawable/dotted_line_480px"
-                    android:layout_width="0dip"
-                    android:layout_weight="1"
-                    android:layout_height="1px"
-                    android:layout_gravity="bottom"
-                    android:layout_marginStart="1dip"
-                    android:layout_marginEnd="1dip"
-                    android:layout_marginBottom="4dip"
-                    android:scaleType="center"
-                    android:contentDescription="@null" />
-                <TextView
-                    android:id="@+id/data_size_text"
-                    android:textAppearance="?android:attr/textAppearanceMedium"
-                    android:paddingTop="6dip"
-                    android:layout_height="wrap_content"
-                    android:layout_width="wrap_content"
-                    android:maxLines="1" />
-            </LinearLayout>
-
-            <LinearLayout
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:orientation="horizontal"
-                android:baselineAligned="true"
-                android:paddingTop="-1dip">
-                <TextView
-                    android:id="@+id/external_data_size_prefix"
-                    android:text="@string/external_data_size_label"
-                    android:textAppearance="?android:attr/textAppearanceMedium"
-                    android:layout_height="wrap_content"
-                    android:layout_width="wrap_content"
-                    android:maxLines="1"
-                    android:paddingTop="6dip" />
-                <ImageView
-                    android:id="@+id/info_size_dots"
-                    android:src="@drawable/dotted_line_480px"
-                    android:layout_width="0dip"
-                    android:layout_weight="1"
-                    android:layout_height="1px"
-                    android:layout_gravity="bottom"
-                    android:layout_marginStart="1dip"
-                    android:layout_marginEnd="1dip"
-                    android:layout_marginBottom="4dip"
-                    android:scaleType="center"
-                    android:contentDescription="@null" />
-                <TextView
-                    android:id="@+id/external_data_size_text"
-                    android:textAppearance="?android:attr/textAppearanceMedium"
-                    android:paddingTop="6dip"
-                    android:layout_height="wrap_content"
-                    android:layout_width="wrap_content"
-                    android:maxLines="1" />
-            </LinearLayout>
-
-            <!-- Clear data and install location buttons  -->
-            <include
-                layout="@layout/two_buttons_panel"
-                android:id="@+id/data_buttons_panel"/>
-
-        </LinearLayout>
-
-        <!-- Clear cache section -->
-        <RelativeLayout
-            android:id="@+id/cache_panel"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content" >
-            <TextView
-                android:id="@+id/cache_header"
-                style="?android:attr/listSeparatorTextViewStyle"
-                android:layout_marginTop="8dip"
-                android:text="@string/cache_header_label" />
-            <LinearLayout
-                android:id="@+id/cache_size"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:orientation="horizontal"
-                android:baselineAligned="true"
-                android:layout_below="@id/cache_header"
-                android:paddingStart="?android:attr/listPreferredItemPaddingStart"
-                android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
-                android:paddingTop="-1dip">
-                <TextView
-                    android:text="@string/cache_size_label"
-                    android:layout_height="wrap_content"
-                    android:layout_width="wrap_content"
-                    android:maxLines="1"
-                    android:textAppearance="?android:attr/textAppearanceMedium"
-                    android:paddingTop="6dip"
-                    android:gravity="center_vertical" />
-                <ImageView
-                    android:src="@drawable/dotted_line_480px"
-                    android:layout_width="0dip"
-                    android:layout_weight="1"
-                    android:layout_height="1px"
-                    android:layout_gravity="bottom"
-                    android:layout_marginStart="1dip"
-                    android:layout_marginEnd="1dip"
-                    android:layout_marginBottom="4dip"
-                    android:scaleType="center"
-                    android:contentDescription="@null" />
-                <TextView
-                    android:id="@+id/cache_size_text"
-                    android:textAppearance="?android:attr/textAppearanceMedium"
-                    android:paddingTop="6dip"
-                    android:layout_height="wrap_content"
-                    android:layout_width="wrap_content"
-                    android:maxLines="1" />
-            </LinearLayout>
-
-            <LinearLayout
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:layout_below="@id/cache_size"
-                android:paddingStart="?android:attr/listPreferredItemPaddingStart"
-                android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
-                android:paddingTop="4dip"
-                android:orientation="horizontal">
-                <View
-                    android:layout_width="120dip"
-                    android:layout_height="0dip"
-                    android:layout_weight="0.4" />
-                <View
-                    android:layout_width="0dip"
-                    android:layout_height="0dip"
-                    android:visibility="invisible"
-                    android:layout_weight="0.2" />
-                <Button
-                    android:id="@+id/clear_cache_button"
-                    android:layout_width="120dip"
-                    android:layout_height="wrap_content"
-                    android:layout_weight="0.4"
-                    android:text="@string/clear_cache_btn_text" />
-            </LinearLayout>
-
-        </RelativeLayout>
-
-        <!-- Prefered activities section -->
-        <TextView android:id="@+id/auto_launch_title"
-            style="?android:attr/listSeparatorTextViewStyle"
-            android:layout_marginTop="8dip"
-            android:text="@string/auto_launch_label" />
-
-        <RelativeLayout 
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_gravity="center_vertical"
-            android:paddingStart="?android:attr/listPreferredItemPaddingStart"
-            android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">
-            <TextView android:id="@+id/auto_launch"
-                android:textAppearance="?android:attr/textAppearanceSmall"
-                android:layout_alignParentStart="true"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:paddingTop="6dip" />
-
-            <LinearLayout
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:layout_below="@id/auto_launch"
-                android:paddingTop="4dip"
-                android:orientation="horizontal">
-                <View
-                    android:layout_width="120dip"
-                    android:layout_height="0dip"
-                    android:layout_weight="0.4" />
-                <View
-                    android:layout_width="0dip"
-                    android:layout_height="0dip"
-                    android:visibility="invisible"
-                    android:layout_weight="0.2" />
-                <Button
-                    android:id="@+id/clear_activities_button"
-                    android:layout_width="120dip"
-                    android:layout_height="wrap_content"
-                    android:layout_weight="0.4"
-                    android:text="@string/clear_activities" />
-            </LinearLayout>
-        </RelativeLayout>
-
-        <!-- Screen compatibility section -->
-        <LinearLayout android:id="@+id/screen_compatibility_section"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:orientation="vertical">
-            <TextView
-                style="?android:attr/listSeparatorTextViewStyle"
-                android:layout_marginTop="8dip"
-                android:text="@string/screen_compatibility_label" />
-
-            <TextView android:textAppearance="?android:attr/textAppearanceSmall"
-                android:layout_alignParentStart="true"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:paddingTop="6dip"
-                android:paddingStart="?android:attr/listPreferredItemPaddingStart"
-                android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
-                android:text="@string/screen_compatibility_text"/>
-            <CheckBox android:id="@+id/ask_compatibility_cb"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_marginStart="12dip"
-                android:layout_gravity="start"
-                android:text="@string/ask_compatibility" />
-            <CheckBox android:id="@+id/enable_compatibility_cb"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_marginStart="12dip"
-                android:layout_gravity="start"
-                android:text="@string/enable_compatibility" />
-        </LinearLayout>
-
-        <!-- Permissions section -->
-        <LinearLayout
-            android:id="@+id/permissions_section"
-            android:layout_width="match_parent"
-            android:layout_height="match_parent"
-            android:orientation="vertical">
-            <TextView
-                style="?android:attr/listSeparatorTextViewStyle"
-                android:layout_marginTop="8dip"
-                android:text="@string/permissions_label" />
-            <TextView android:id="@+id/security_settings_billing_desc"
-                android:text="@string/security_settings_billing_desc"
-                android:textColor="#ffffb060"
-                android:textAppearance="?android:attr/textAppearanceSmall"
-                android:paddingTop="6dip"
-                android:paddingBottom="6dip"
-                android:paddingStart="?android:attr/listPreferredItemPaddingStart"
-                android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content" />
-            <LinearLayout
-                android:id="@+id/security_settings_billing_list"
-                android:layout_width="match_parent"
-                android:layout_height="match_parent"
-                android:orientation="vertical">
-                <TextView
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:text="@string/security_settings_premium_sms_desc" />
-                <Spinner
-                    android:id="@+id/security_settings_premium_sms_list"
-                    android:layout_width="fill_parent"
-                    android:layout_height="wrap_content"
-                    android:spinnerMode="dropdown" />
-            </LinearLayout>
-            <TextView android:id="@+id/security_settings_desc"
-                android:text="@string/security_settings_desc"
-                android:textAppearance="?android:attr/textAppearanceSmall"
-                android:paddingTop="6dip"
-                android:paddingBottom="6dip"
-                android:paddingStart="?android:attr/listPreferredItemPaddingStart"
-                android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content" />
-            <LinearLayout
-                android:id="@+id/security_settings_list"
-                android:layout_width="match_parent"
-                android:layout_height="match_parent"
-                android:orientation="vertical"/>
-        </LinearLayout>
     </LinearLayout>
-</ScrollView>
+</LinearLayout>
 
diff --git a/res/layout/permission_settings.xml b/res/layout/permission_settings.xml
new file mode 100644
index 0000000..8233c81
--- /dev/null
+++ b/res/layout/permission_settings.xml
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright 2015, 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.
+*/
+-->
+<ScrollView
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:clipToPadding="false"
+    android:scrollbarStyle="@integer/preference_scrollbar_style">
+
+    <LinearLayout
+        android:id="@+id/all_details"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:paddingStart="?android:attr/listPreferredItemPaddingStart"
+        android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
+        android:paddingBottom="5dip"
+        android:orientation="vertical">
+
+        <!-- Permissions section -->
+        <LinearLayout
+            android:id="@+id/permissions_section"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:orientation="vertical">
+            <TextView
+                style="?android:attr/listSeparatorTextViewStyle"
+                android:layout_marginTop="8dip"
+                android:text="@string/permissions_label" />
+            <TextView android:id="@+id/security_settings_billing_desc"
+                android:text="@string/security_settings_billing_desc"
+                android:textColor="#ffffb060"
+                android:textAppearance="?android:attr/textAppearanceSmall"
+                android:paddingTop="6dip"
+                android:paddingBottom="6dip"
+                android:paddingStart="?android:attr/listPreferredItemPaddingStart"
+                android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content" />
+            <LinearLayout
+                android:id="@+id/security_settings_billing_list"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:orientation="vertical">
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="@string/security_settings_premium_sms_desc" />
+                <Spinner
+                    android:id="@+id/security_settings_premium_sms_list"
+                    android:layout_width="fill_parent"
+                    android:layout_height="wrap_content"
+                    android:spinnerMode="dropdown" />
+            </LinearLayout>
+            <TextView android:id="@+id/security_settings_desc"
+                android:text="@string/security_settings_desc"
+                android:textAppearance="?android:attr/textAppearanceSmall"
+                android:paddingTop="6dip"
+                android:paddingBottom="6dip"
+                android:paddingStart="?android:attr/listPreferredItemPaddingStart"
+                android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content" />
+            <LinearLayout
+                android:id="@+id/security_settings_list"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:orientation="vertical"/>
+        </LinearLayout>
+
+
+    </LinearLayout>
+</ScrollView>
diff --git a/res/layout/storage_settings.xml b/res/layout/storage_settings.xml
new file mode 100644
index 0000000..b8dddfd
--- /dev/null
+++ b/res/layout/storage_settings.xml
@@ -0,0 +1,307 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright 2015, 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.
+*/
+-->
+<ScrollView
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:clipToPadding="false"
+    android:scrollbarStyle="@integer/preference_scrollbar_style">
+
+    <LinearLayout
+        android:id="@+id/all_details"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:paddingStart="?android:attr/listPreferredItemPaddingStart"
+        android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
+        android:paddingBottom="5dip"
+        android:orientation="vertical">
+
+
+        <TextView
+            style="?android:attr/listSeparatorTextViewStyle"
+            android:layout_marginTop="8dip"
+            android:text="@string/storage_label" />
+
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:orientation="vertical"
+            android:paddingStart="?android:attr/listPreferredItemPaddingStart"
+            android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:orientation="horizontal"
+                android:baselineAligned="true"
+                android:paddingTop="-1dip">
+                <TextView
+                    android:id="@+id/total_size_prefix"
+                    android:text="@string/total_size_label"
+                    android:textAppearance="?android:attr/textAppearanceMedium"
+                    android:layout_height="wrap_content"
+                    android:layout_width="wrap_content"
+                    android:maxLines="1"
+                    android:paddingTop="6dip" />
+                <ImageView
+                    android:id="@+id/info_size_dots"
+                    android:src="@drawable/dotted_line_480px"
+                    android:layout_width="0dip"
+                    android:layout_weight="1"
+                    android:layout_height="1px"
+                    android:layout_gravity="bottom"
+                    android:layout_marginStart="1dip"
+                    android:layout_marginEnd="1dip"
+                    android:layout_marginBottom="4dip"
+                    android:scaleType="center"
+                    android:contentDescription="@null" />
+                <TextView
+                    android:id="@+id/total_size_text"
+                    android:paddingTop="6dip"
+                    android:textAppearance="?android:attr/textAppearanceMedium"
+                    android:layout_height="wrap_content"
+                    android:layout_width="wrap_content"
+                    android:maxLines="1" />
+            </LinearLayout>
+
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:orientation="horizontal"
+                android:baselineAligned="true"
+                android:paddingTop="-1dip">
+                <TextView
+                    android:id="@+id/application_size_prefix"
+                    android:text="@string/application_size_label"
+                    android:textAppearance="?android:attr/textAppearanceMedium"
+                    android:layout_height="wrap_content"
+                    android:layout_width="wrap_content"
+                    android:maxLines="1"
+                    android:paddingTop="6dip" />
+                <ImageView
+                    android:id="@+id/info_size_dots"
+                    android:src="@drawable/dotted_line_480px"
+                    android:layout_width="0dip"
+                    android:layout_weight="1"
+                    android:layout_height="1px"
+                    android:layout_gravity="bottom"
+                    android:layout_marginStart="1dip"
+                    android:layout_marginEnd="1dip"
+                    android:layout_marginBottom="4dip"
+                    android:scaleType="center"
+                    android:contentDescription="@null" />
+                <TextView
+                    android:id="@+id/application_size_text"
+                    android:textAppearance="?android:attr/textAppearanceMedium"
+                    android:paddingTop="6dip"
+                    android:layout_height="wrap_content"
+                    android:layout_width="wrap_content"
+                    android:maxLines="1" />
+            </LinearLayout>
+
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:orientation="horizontal"
+                android:baselineAligned="true"
+                android:paddingTop="-1dip">
+                <TextView
+                    android:id="@+id/external_code_size_prefix"
+                    android:text="@string/external_code_size_label"
+                    android:textAppearance="?android:attr/textAppearanceMedium"
+                    android:layout_height="wrap_content"
+                    android:layout_width="wrap_content"
+                    android:maxLines="1"
+                    android:paddingTop="6dip" />
+                <ImageView
+                    android:id="@+id/info_size_dots"
+                    android:src="@drawable/dotted_line_480px"
+                    android:layout_width="0dip"
+                    android:layout_weight="1"
+                    android:layout_height="1px"
+                    android:layout_gravity="bottom"
+                    android:layout_marginStart="1dip"
+                    android:layout_marginEnd="1dip"
+                    android:layout_marginBottom="4dip"
+                    android:scaleType="center"
+                    android:contentDescription="@null" />
+                <TextView
+                    android:id="@+id/external_code_size_text"
+                    android:textAppearance="?android:attr/textAppearanceMedium"
+                    android:paddingTop="6dip"
+                    android:layout_height="wrap_content"
+                    android:layout_width="wrap_content"
+                    android:maxLines="1" />
+            </LinearLayout>
+
+            <LinearLayout
+                android:id="@+id/info_size"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:orientation="horizontal"
+                android:baselineAligned="true"
+                android:paddingTop="-1dip">
+                <TextView
+                    android:id="@+id/data_size_prefix"
+                    android:text="@string/data_size_label"
+                    android:textAppearance="?android:attr/textAppearanceMedium"
+                    android:layout_height="wrap_content"
+                    android:layout_width="wrap_content"
+                    android:maxLines="1"
+                    android:paddingTop="6dip" />
+                <ImageView
+                    android:id="@+id/info_size_dots"
+                    android:src="@drawable/dotted_line_480px"
+                    android:layout_width="0dip"
+                    android:layout_weight="1"
+                    android:layout_height="1px"
+                    android:layout_gravity="bottom"
+                    android:layout_marginStart="1dip"
+                    android:layout_marginEnd="1dip"
+                    android:layout_marginBottom="4dip"
+                    android:scaleType="center"
+                    android:contentDescription="@null" />
+                <TextView
+                    android:id="@+id/data_size_text"
+                    android:textAppearance="?android:attr/textAppearanceMedium"
+                    android:paddingTop="6dip"
+                    android:layout_height="wrap_content"
+                    android:layout_width="wrap_content"
+                    android:maxLines="1" />
+            </LinearLayout>
+
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:orientation="horizontal"
+                android:baselineAligned="true"
+                android:paddingTop="-1dip">
+                <TextView
+                    android:id="@+id/external_data_size_prefix"
+                    android:text="@string/external_data_size_label"
+                    android:textAppearance="?android:attr/textAppearanceMedium"
+                    android:layout_height="wrap_content"
+                    android:layout_width="wrap_content"
+                    android:maxLines="1"
+                    android:paddingTop="6dip" />
+                <ImageView
+                    android:id="@+id/info_size_dots"
+                    android:src="@drawable/dotted_line_480px"
+                    android:layout_width="0dip"
+                    android:layout_weight="1"
+                    android:layout_height="1px"
+                    android:layout_gravity="bottom"
+                    android:layout_marginStart="1dip"
+                    android:layout_marginEnd="1dip"
+                    android:layout_marginBottom="4dip"
+                    android:scaleType="center"
+                    android:contentDescription="@null" />
+                <TextView
+                    android:id="@+id/external_data_size_text"
+                    android:textAppearance="?android:attr/textAppearanceMedium"
+                    android:paddingTop="6dip"
+                    android:layout_height="wrap_content"
+                    android:layout_width="wrap_content"
+                    android:maxLines="1" />
+            </LinearLayout>
+
+            <!-- Clear data and install location buttons  -->
+            <include
+                layout="@layout/two_buttons_panel"
+                android:id="@+id/data_buttons_panel"/>
+
+        </LinearLayout>
+
+
+        <!-- Clear cache section -->
+        <RelativeLayout
+            android:id="@+id/cache_panel"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content" >
+            <TextView
+                android:id="@+id/cache_header"
+                style="?android:attr/listSeparatorTextViewStyle"
+                android:layout_marginTop="8dip"
+                android:text="@string/cache_header_label" />
+            <LinearLayout
+                android:id="@+id/cache_size"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:orientation="horizontal"
+                android:baselineAligned="true"
+                android:layout_below="@id/cache_header"
+                android:paddingStart="?android:attr/listPreferredItemPaddingStart"
+                android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
+                android:paddingTop="-1dip">
+                <TextView
+                    android:text="@string/cache_size_label"
+                    android:layout_height="wrap_content"
+                    android:layout_width="wrap_content"
+                    android:maxLines="1"
+                    android:textAppearance="?android:attr/textAppearanceMedium"
+                    android:paddingTop="6dip"
+                    android:gravity="center_vertical" />
+                <ImageView
+                    android:src="@drawable/dotted_line_480px"
+                    android:layout_width="0dip"
+                    android:layout_weight="1"
+                    android:layout_height="1px"
+                    android:layout_gravity="bottom"
+                    android:layout_marginStart="1dip"
+                    android:layout_marginEnd="1dip"
+                    android:layout_marginBottom="4dip"
+                    android:scaleType="center"
+                    android:contentDescription="@null" />
+                <TextView
+                    android:id="@+id/cache_size_text"
+                    android:textAppearance="?android:attr/textAppearanceMedium"
+                    android:paddingTop="6dip"
+                    android:layout_height="wrap_content"
+                    android:layout_width="wrap_content"
+                    android:maxLines="1" />
+            </LinearLayout>
+
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_below="@id/cache_size"
+                android:paddingStart="?android:attr/listPreferredItemPaddingStart"
+                android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
+                android:paddingTop="4dip"
+                android:orientation="horizontal">
+                <View
+                    android:layout_width="120dip"
+                    android:layout_height="0dip"
+                    android:layout_weight="0.4" />
+                <View
+                    android:layout_width="0dip"
+                    android:layout_height="0dip"
+                    android:visibility="invisible"
+                    android:layout_weight="0.2" />
+                <Button
+                    android:id="@+id/clear_cache_button"
+                    android:layout_width="120dip"
+                    android:layout_height="wrap_content"
+                    android:layout_weight="0.4"
+                    android:text="@string/clear_cache_btn_text" />
+            </LinearLayout>
+
+        </RelativeLayout>
+    </LinearLayout>
+</ScrollView>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index ee02364..d57ee72 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -5922,4 +5922,37 @@
    <string name="imei_information_summary">IMEI relative information</string>
    <string name="slot_number">(Slot<xliff:g id="slot_num">%1$d</xliff:g>)</string>
 
+   <!-- New strings needed for App Info 2 -->
+   <!-- Preference label for app default launch settings -->
+   <string name="launch_by_default">Launch by default</string>
+
+   <!-- Summary for app storage preference -->
+   <string name="storage_summary_format"><xliff:g id="size" example="30.00MB">%1$s</xliff:g> used in <xliff:g id="storage_type" example="internal memory">%2$s</xliff:g></string>
+   <!-- Internal storage label -->
+   <string name="storage_type_internal">internal memory</string>
+   <!-- External storage label -->
+   <string name="storage_type_external">external memory</string>
+
+   <!-- App notification summary with notifications enabled -->
+   <string name="notifications_enabled">On</string>
+   <!-- App notification summary with notifications disabled -->
+   <string name="notifications_disabled">Block</string>
+   <!-- App notification summary with notifications sensitive -->
+   <string name="notifications_sensitive">Sensitive</string>
+   <!-- App notification summary with notifications priority -->
+   <string name="notifications_priority">Priority</string>
+   <!-- App notification summary with notifications priority and sensitive -->
+   <string name="notifications_priority_sensitive">Priority &amp; Sensitive</string>
+
+   <!-- Permissions preference summary -->
+   <plurals name="permissions_summary">
+       <item quantity="one"><xliff:g id="count" example="1">%d</xliff:g> permission granted</item>
+       <item quantity="other"><xliff:g id="count" example="10">%d</xliff:g> permissions granted</item>
+   </plurals>
+
+   <!-- Launch defaults preference summary with some set -->
+   <string name="launch_defaults_some">Some defaults set</string>
+   <!-- Launch defaults preference summary with none set -->
+   <string name="launch_defaults_none">No defaults set</string>
+
 </resources>
diff --git a/res/xml/installed_app_details.xml b/res/xml/installed_app_details.xml
new file mode 100644
index 0000000..05bea5c
--- /dev/null
+++ b/res/xml/installed_app_details.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 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.
+-->
+
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+                  android:title="@string/application_info_label">
+    <com.android.settings.applications.HeaderPreference
+        android:key="header_view"
+        android:layout="@layout/installed_app_details" />
+
+    <Preference
+        android:key="notification_settings"
+        android:title="@string/notification_section_header"
+        android:selectable="true" />
+
+    <Preference
+        android:key="storage_settings"
+        android:title="@string/storage_settings"
+        android:selectable="true" />
+
+    <Preference
+        android:key="permission_settings"
+        android:title="@string/permissions_label"
+        android:selectable="true" />
+
+    <Preference
+        android:key="data_settings"
+        android:title="@string/data_size_label"
+        android:selectable="true" />
+
+    <Preference
+        android:key="preferred_settings"
+        android:title="@string/launch_by_default"
+        android:selectable="true" />
+</PreferenceScreen>
diff --git a/src/com/android/settings/AppHeader.java b/src/com/android/settings/AppHeader.java
new file mode 100644
index 0000000..5cd126a
--- /dev/null
+++ b/src/com/android/settings/AppHeader.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2015 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.settings;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.graphics.drawable.Drawable;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.ViewGroup;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+public class AppHeader {
+
+    public static void createAppHeader(final Activity activity, Drawable icon, CharSequence label,
+            final Intent settingsIntent) {
+        final View content = activity.findViewById(R.id.main_content);
+        final ViewGroup contentParent = (ViewGroup) content.getParent();
+        final View bar = activity.getLayoutInflater().inflate(R.layout.app_header,
+                contentParent, false);
+
+        final ImageView appIcon = (ImageView) bar.findViewById(R.id.app_icon);
+        appIcon.setImageDrawable(icon);
+
+        final TextView appName = (TextView) bar.findViewById(R.id.app_name);
+        appName.setText(label);
+
+        final View appSettings = bar.findViewById(R.id.app_settings);
+        if (settingsIntent == null) {
+            appSettings.setVisibility(View.GONE);
+        } else {
+            appSettings.setClickable(true);
+            appSettings.setOnClickListener(new OnClickListener() {
+                @Override
+                public void onClick(View v) {
+                    activity.startActivity(settingsIntent);
+                }
+            });
+        }
+        contentParent.addView(bar, 0);
+    }
+
+}
diff --git a/src/com/android/settings/applications/AppInfoBase.java b/src/com/android/settings/applications/AppInfoBase.java
new file mode 100644
index 0000000..2203a21
--- /dev/null
+++ b/src/com/android/settings/applications/AppInfoBase.java
@@ -0,0 +1,188 @@
+/*
+ * Copyright (C) 2015 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.settings.applications;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.app.DialogFragment;
+import android.app.admin.DevicePolicyManager;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
+import android.content.pm.PackageManager.NameNotFoundException;
+import android.hardware.usb.IUsbManager;
+import android.os.Bundle;
+import android.os.IBinder;
+import android.os.ServiceManager;
+import android.os.UserManager;
+import android.preference.PreferenceFragment;
+import android.util.Log;
+
+import com.android.settings.SettingsActivity;
+import com.android.settings.applications.ApplicationsState.AppEntry;
+
+import java.util.ArrayList;
+
+public abstract class AppInfoBase extends PreferenceFragment
+        implements ApplicationsState.Callbacks {
+
+    public static final String ARG_PACKAGE_NAME = "package";
+
+    protected static final String TAG = AppInfoBase.class.getSimpleName();
+    protected static final boolean localLOGV = false;
+
+    protected boolean mAppControlRestricted = false;
+
+    protected ApplicationsState mState;
+    private ApplicationsState.Session mSession;
+    protected ApplicationsState.AppEntry mAppEntry;
+    protected PackageInfo mPackageInfo;
+    protected String mPackageName;
+
+    protected IUsbManager mUsbManager;
+    protected DevicePolicyManager mDpm;
+    protected UserManager mUserManager;
+    protected PackageManager mPm;
+
+    // Dialog identifiers used in showDialog
+    protected static final int DLG_BASE = 0;
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        mState = ApplicationsState.getInstance(getActivity().getApplication());
+        mSession = mState.newSession(this);
+        Context context = getActivity();
+        mDpm = (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE);
+        mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
+        mPm = context.getPackageManager();
+        IBinder b = ServiceManager.getService(Context.USB_SERVICE);
+        mUsbManager = IUsbManager.Stub.asInterface(b);
+
+        // Need to make sure we have loaded applications at this point.
+        mSession.resume();
+
+        retrieveAppEntry();
+    }
+
+    @Override
+    public void onResume() {
+        super.onResume();
+        mAppControlRestricted = mUserManager.hasUserRestriction(UserManager.DISALLOW_APPS_CONTROL);
+        mSession.resume();
+
+        if (!refreshUi()) {
+            setIntentAndFinish(true, true);
+        }
+    }
+
+    @Override
+    public void onPause() {
+        super.onPause();
+        mSession.pause();
+    }
+
+    @Override
+    public void onDestroyView() {
+        super.onDestroyView();
+        mSession.release();
+    }
+
+    protected String retrieveAppEntry() {
+        final Bundle args = getArguments();
+        mPackageName = (args != null) ? args.getString(ARG_PACKAGE_NAME) : null;
+        if (mPackageName == null) {
+            Intent intent = (args == null) ?
+                    getActivity().getIntent() : (Intent) args.getParcelable("intent");
+            if (intent != null) {
+                mPackageName = intent.getData().getSchemeSpecificPart();
+            }
+        }
+        mAppEntry = mState.getEntry(mPackageName);
+        if (mAppEntry != null) {
+            // Get application info again to refresh changed properties of application
+            try {
+                mPackageInfo = mPm.getPackageInfo(mAppEntry.info.packageName,
+                        PackageManager.GET_DISABLED_COMPONENTS |
+                        PackageManager.GET_UNINSTALLED_PACKAGES |
+                        PackageManager.GET_SIGNATURES);
+            } catch (NameNotFoundException e) {
+                Log.e(TAG, "Exception when retrieving package:" + mAppEntry.info.packageName, e);
+            }
+        } else {
+            Log.w(TAG, "Missing AppEntry; maybe reinstalling?");
+            mPackageInfo = null;
+        }
+
+        return mPackageName;
+    }
+
+    protected void setIntentAndFinish(boolean finish, boolean appChanged) {
+        if (localLOGV) Log.i(TAG, "appChanged="+appChanged);
+        Intent intent = new Intent();
+        intent.putExtra(ManageApplications.APP_CHG, appChanged);
+        SettingsActivity sa = (SettingsActivity)getActivity();
+        sa.finishPreferencePanel(this, Activity.RESULT_OK, intent);
+    }
+
+    protected void showDialogInner(int id, int moveErrorCode) {
+        DialogFragment newFragment = new MyAlertDialogFragment(id, moveErrorCode);
+        newFragment.setTargetFragment(this, 0);
+        newFragment.show(getFragmentManager(), "dialog " + id);
+    }
+
+    protected abstract boolean refreshUi();
+    protected abstract AlertDialog createDialog(int id, int errorCode);
+
+    @Override
+    public void onRunningStateChanged(boolean running) { }
+    @Override
+    public void onRebuildComplete(ArrayList<AppEntry> apps) { }
+    @Override
+    public void onPackageIconChanged() { }
+    @Override
+    public void onPackageSizeChanged(String packageName) { }
+    @Override
+    public void onAllSizesComputed() { }
+
+    @Override
+    public void onPackageListChanged() {
+        refreshUi();
+    }
+
+    public class MyAlertDialogFragment extends DialogFragment {
+        public MyAlertDialogFragment(int id, int errorCode) {
+            Bundle args = new Bundle();
+            args.putInt("id", id);
+            args.putInt("moveError", errorCode);
+            setArguments(args);
+        }
+
+        @Override
+        public Dialog onCreateDialog(Bundle savedInstanceState) {
+            int id = getArguments().getInt("id");
+            int errorCode = getArguments().getInt("moveError");
+            Dialog dialog = createDialog(id, errorCode);
+            if (dialog == null) {
+                throw new IllegalArgumentException("unknown id " + id);
+            }
+            return dialog;
+        }
+    }
+}
diff --git a/src/com/android/settings/applications/AppInfoWithHeader.java b/src/com/android/settings/applications/AppInfoWithHeader.java
new file mode 100644
index 0000000..f7546f2
--- /dev/null
+++ b/src/com/android/settings/applications/AppInfoWithHeader.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2015 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.settings.applications;
+
+import android.os.Bundle;
+import android.util.Log;
+
+import com.android.settings.AppHeader;
+
+public abstract class AppInfoWithHeader extends AppInfoBase {
+
+    private boolean mCreated;
+
+    @Override
+    public void onActivityCreated(Bundle savedInstanceState) {
+        super.onActivityCreated(savedInstanceState);
+        if (mCreated) {
+            Log.w(TAG, "onActivityCreated: ignoring duplicate call");
+            return;
+        }
+        mCreated = true;
+        if (mPackageInfo == null) return;
+        AppHeader.createAppHeader(getActivity(), mPackageInfo.applicationInfo.loadIcon(mPm),
+                mPackageInfo.applicationInfo.loadLabel(mPm), null);
+    }
+}
diff --git a/src/com/android/settings/applications/AppLaunchSettings.java b/src/com/android/settings/applications/AppLaunchSettings.java
new file mode 100644
index 0000000..6379102
--- /dev/null
+++ b/src/com/android/settings/applications/AppLaunchSettings.java
@@ -0,0 +1,190 @@
+/*
+ * Copyright (C) 2015 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.settings.applications;
+
+import android.app.AlertDialog;
+import android.appwidget.AppWidgetManager;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.IntentFilter;
+import android.content.pm.PackageManager;
+import android.hardware.usb.IUsbManager;
+import android.os.Bundle;
+import android.os.RemoteException;
+import android.os.UserHandle;
+import android.text.SpannableString;
+import android.text.TextUtils;
+import android.text.style.BulletSpan;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.TextView;
+
+import com.android.settings.R;
+import com.android.settings.Utils;
+import com.android.settings.applications.ApplicationsState.AppEntry;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+public class AppLaunchSettings extends AppInfoWithHeader implements OnClickListener {
+
+    private Button mActivitiesButton;
+    private AppWidgetManager mAppWidgetManager;
+
+    private View mRootView;
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        mAppWidgetManager = AppWidgetManager.getInstance(getActivity());
+    }
+
+    @Override
+    public View onCreateView(LayoutInflater inflater, ViewGroup container,
+            Bundle savedInstanceState) {
+        final View view = inflater.inflate(R.layout.app_preferred_settings, container, false);
+
+        final ViewGroup allDetails = (ViewGroup) view.findViewById(R.id.all_details);
+        Utils.forceCustomPadding(allDetails, true /* additive padding */);
+
+        mActivitiesButton = (Button) view.findViewById(R.id.clear_activities_button);
+        mRootView = view;
+
+        return view;
+    }
+
+    @Override
+    protected boolean refreshUi() {
+        retrieveAppEntry();
+        boolean hasBindAppWidgetPermission =
+                mAppWidgetManager.hasBindAppWidgetPermission(mAppEntry.info.packageName);
+
+        TextView autoLaunchTitleView = (TextView) mRootView.findViewById(R.id.auto_launch_title);
+        TextView autoLaunchView = (TextView) mRootView.findViewById(R.id.auto_launch);
+        boolean autoLaunchEnabled = hasPreferredActivities(mPm, mPackageName)
+                || hasUsbDefaults(mUsbManager, mPackageName);
+        if (!autoLaunchEnabled && !hasBindAppWidgetPermission) {
+            resetLaunchDefaultsUi(autoLaunchTitleView, autoLaunchView);
+        } else {
+            boolean useBullets = hasBindAppWidgetPermission && autoLaunchEnabled;
+
+            if (hasBindAppWidgetPermission) {
+                autoLaunchTitleView.setText(R.string.auto_launch_label_generic);
+            } else {
+                autoLaunchTitleView.setText(R.string.auto_launch_label);
+            }
+
+            CharSequence text = null;
+            int bulletIndent = getResources()
+                    .getDimensionPixelSize(R.dimen.installed_app_details_bullet_offset);
+            if (autoLaunchEnabled) {
+                CharSequence autoLaunchEnableText = getText(R.string.auto_launch_enable_text);
+                SpannableString s = new SpannableString(autoLaunchEnableText);
+                if (useBullets) {
+                    s.setSpan(new BulletSpan(bulletIndent), 0, autoLaunchEnableText.length(), 0);
+                }
+                text = (text == null) ?
+                        TextUtils.concat(s, "\n") : TextUtils.concat(text, "\n", s, "\n");
+            }
+            if (hasBindAppWidgetPermission) {
+                CharSequence alwaysAllowBindAppWidgetsText =
+                        getText(R.string.always_allow_bind_appwidgets_text);
+                SpannableString s = new SpannableString(alwaysAllowBindAppWidgetsText);
+                if (useBullets) {
+                    s.setSpan(new BulletSpan(bulletIndent),
+                            0, alwaysAllowBindAppWidgetsText.length(), 0);
+                }
+                text = (text == null) ?
+                        TextUtils.concat(s, "\n") : TextUtils.concat(text, "\n", s, "\n");
+            }
+            autoLaunchView.setText(text);
+            mActivitiesButton.setEnabled(true);
+            mActivitiesButton.setOnClickListener(this);
+        }
+        return true;
+    }
+
+    private void resetLaunchDefaultsUi(TextView title, TextView autoLaunchView) {
+        title.setText(R.string.auto_launch_label);
+        autoLaunchView.setText(R.string.auto_launch_disable_text);
+        // Disable clear activities button
+        mActivitiesButton.setEnabled(false);
+    }
+
+    @Override
+    protected AlertDialog createDialog(int id, int errorCode) {
+        // No dialogs for preferred launch settings.
+        return null;
+    }
+
+    @Override
+    public void onClick(View v) {
+        if (v == mActivitiesButton) {
+            if (mUsbManager != null) {
+                mPm.clearPackagePreferredActivities(mPackageName);
+                try {
+                    mUsbManager.clearDefaults(mPackageName, UserHandle.myUserId());
+                } catch (RemoteException e) {
+                    Log.e(TAG, "mUsbManager.clearDefaults", e);
+                }
+                mAppWidgetManager.setBindAppWidgetPermission(mPackageName, false);
+                TextView autoLaunchTitleView =
+                        (TextView) mRootView.findViewById(R.id.auto_launch_title);
+                TextView autoLaunchView = (TextView) mRootView.findViewById(R.id.auto_launch);
+                resetLaunchDefaultsUi(autoLaunchTitleView, autoLaunchView);
+            }
+        }
+    }
+
+    private static boolean hasUsbDefaults(IUsbManager usbManager, String packageName) {
+        try {
+            if (usbManager != null) {
+                return usbManager.hasDefaults(packageName, UserHandle.myUserId());
+            }
+        } catch (RemoteException e) {
+            Log.e(TAG, "mUsbManager.hasDefaults", e);
+        }
+        return false;
+    }
+
+    private static boolean hasPreferredActivities(PackageManager pm, String packageName) {
+        // Get list of preferred activities
+        List<ComponentName> prefActList = Collections.emptyList();
+        // Intent list cannot be null. so pass empty list
+        List<IntentFilter> intentList = Collections.emptyList();
+        pm.getPreferredActivities(intentList, prefActList, packageName);
+        if (localLOGV) {
+            Log.i(TAG, "Have " + prefActList.size() + " number of activities in preferred list");
+        }
+        return prefActList.size() > 0;
+    }
+
+    public static CharSequence getSummary(AppEntry appEntry, IUsbManager usbManager,
+            PackageManager pm, Context context) {
+        String packageName = appEntry.info.packageName;
+        boolean hasPreferred = hasPreferredActivities(pm, packageName)
+                || hasUsbDefaults(usbManager, packageName);
+        return context.getString(hasPreferred
+                ? R.string.launch_defaults_some
+                : R.string.launch_defaults_none);
+    }
+
+}
diff --git a/src/com/android/settings/applications/AppPermissionSettings.java b/src/com/android/settings/applications/AppPermissionSettings.java
new file mode 100644
index 0000000..a5b4895
--- /dev/null
+++ b/src/com/android/settings/applications/AppPermissionSettings.java
@@ -0,0 +1,221 @@
+/*
+ * Copyright (C) 2015 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.settings.applications;
+
+import android.app.AlertDialog;
+import android.content.Context;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
+import android.content.res.Resources;
+import android.os.Bundle;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.AppSecurityPermissions;
+import android.widget.ArrayAdapter;
+import android.widget.LinearLayout;
+import android.widget.Spinner;
+import android.widget.TextView;
+
+import com.android.internal.telephony.ISms;
+import com.android.internal.telephony.SmsUsageMonitor;
+import com.android.settings.R;
+import com.android.settings.Utils;
+import com.android.settings.applications.ApplicationsState.AppEntry;
+
+import java.util.ArrayList;
+
+public class AppPermissionSettings extends AppInfoWithHeader {
+
+    private ISms mSmsManager;
+    private View mRootView;
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        mSmsManager = ISms.Stub.asInterface(ServiceManager.getService("isms"));
+    }
+
+    @Override
+    public View onCreateView(LayoutInflater inflater, ViewGroup container,
+            Bundle savedInstanceState) {
+        final View view = inflater.inflate(R.layout.permission_settings, container, false);
+
+        final ViewGroup allDetails = (ViewGroup) view.findViewById(R.id.all_details);
+        Utils.forceCustomPadding(allDetails, true /* additive padding */);
+
+        mRootView = view;
+        return view;
+    }
+
+    @Override
+    protected boolean refreshUi() {
+        retrieveAppEntry();
+        // Security permissions section
+        LinearLayout permsView = (LinearLayout) mRootView.findViewById(R.id.permissions_section);
+        AppSecurityPermissions asp = new AppSecurityPermissions(getActivity(), mPackageName);
+        int premiumSmsPermission = getPremiumSmsPermission(mPackageName);
+        // Premium SMS permission implies the app also has SEND_SMS permission, so the original
+        // application permissions list doesn't have to be shown/hidden separately. The premium
+        // SMS subsection should only be visible if the app has tried to send to a premium SMS.
+        if (asp.getPermissionCount() > 0
+                || premiumSmsPermission != SmsUsageMonitor.PREMIUM_SMS_PERMISSION_UNKNOWN) {
+            permsView.setVisibility(View.VISIBLE);
+        } else {
+            permsView.setVisibility(View.GONE);
+        }
+        // Premium SMS permission subsection
+        TextView securityBillingDesc = (TextView) permsView.findViewById(
+                R.id.security_settings_billing_desc);
+        LinearLayout securityBillingList = (LinearLayout) permsView.findViewById(
+                R.id.security_settings_billing_list);
+        if (premiumSmsPermission != SmsUsageMonitor.PREMIUM_SMS_PERMISSION_UNKNOWN) {
+            // Show the premium SMS permission selector
+            securityBillingDesc.setVisibility(View.VISIBLE);
+            securityBillingList.setVisibility(View.VISIBLE);
+            Spinner spinner = (Spinner) permsView.findViewById(
+                    R.id.security_settings_premium_sms_list);
+            ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActivity(),
+                    R.array.security_settings_premium_sms_values,
+                    android.R.layout.simple_spinner_item);
+            adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+            spinner.setAdapter(adapter);
+            // List items are in the same order as SmsUsageMonitor constants, offset by 1.
+            spinner.setSelection(premiumSmsPermission - 1);
+            spinner.setOnItemSelectedListener(new PremiumSmsSelectionListener(
+                    mPackageName, mSmsManager));
+        } else {
+            // Hide the premium SMS permission selector
+            securityBillingDesc.setVisibility(View.GONE);
+            securityBillingList.setVisibility(View.GONE);
+        }
+        // App permissions subsection
+        if (asp.getPermissionCount() > 0) {
+            // Make the security sections header visible
+            LinearLayout securityList = (LinearLayout) permsView.findViewById(
+                    R.id.security_settings_list);
+            securityList.removeAllViews();
+            securityList.addView(asp.getPermissionsViewWithRevokeButtons());
+            // If this app is running under a shared user ID with other apps,
+            // update the description to explain this.
+            String[] packages = mPm.getPackagesForUid(mPackageInfo.applicationInfo.uid);
+            if (packages != null && packages.length > 1) {
+                ArrayList<CharSequence> pnames = new ArrayList<CharSequence>();
+                for (int i=0; i<packages.length; i++) {
+                    String pkg = packages[i];
+                    if (mPackageInfo.packageName.equals(pkg)) {
+                        continue;
+                    }
+                    try {
+                        ApplicationInfo ainfo = mPm.getApplicationInfo(pkg, 0);
+                        pnames.add(ainfo.loadLabel(mPm));
+                    } catch (PackageManager.NameNotFoundException e) {
+                    }
+                }
+                final int N = pnames.size();
+                if (N > 0) {
+                    final Resources res = getActivity().getResources();
+                    String appListStr;
+                    if (N == 1) {
+                        appListStr = pnames.get(0).toString();
+                    } else if (N == 2) {
+                        appListStr = res.getString(R.string.join_two_items, pnames.get(0),
+                                pnames.get(1));
+                    } else {
+                        appListStr = pnames.get(N-2).toString();
+                        for (int i=N-3; i>=0; i--) {
+                            appListStr = res.getString(i == 0 ? R.string.join_many_items_first
+                                    : R.string.join_many_items_middle, pnames.get(i), appListStr);
+                        }
+                        appListStr = res.getString(R.string.join_many_items_last,
+                                appListStr, pnames.get(N-1));
+                    }
+                    TextView descr = (TextView) mRootView.findViewById(
+                            R.id.security_settings_desc);
+                    descr.setText(res.getString(R.string.security_settings_desc_multi,
+                            mPackageInfo.applicationInfo.loadLabel(mPm), appListStr));
+                }
+            }
+        }
+        return true;
+    }
+
+    private int getPremiumSmsPermission(String packageName) {
+        try {
+            if (mSmsManager != null) {
+                return mSmsManager.getPremiumSmsPermission(packageName);
+            }
+        } catch (RemoteException ex) {
+            // ignored
+        }
+        return SmsUsageMonitor.PREMIUM_SMS_PERMISSION_UNKNOWN;
+    }
+
+    @Override
+    protected AlertDialog createDialog(int id, int errorCode) {
+        // No dialogs for Permissions screen.
+        return null;
+    }
+
+    public static CharSequence getSummary(AppEntry appEntry, Context context) {
+        AppSecurityPermissions asp = new AppSecurityPermissions(context,
+                appEntry.info.packageName);
+        int count = asp.getPermissionCount();
+        return context.getResources().getQuantityString(R.plurals.permissions_summary,
+                count, count);
+    }
+
+    private static class PremiumSmsSelectionListener implements AdapterView.OnItemSelectedListener {
+        private final String mPackageName;
+        private final ISms mSmsManager;
+
+        PremiumSmsSelectionListener(String packageName, ISms smsManager) {
+            mPackageName = packageName;
+            mSmsManager = smsManager;
+        }
+
+        @Override
+        public void onItemSelected(AdapterView<?> parent, View view, int position,
+                long id) {
+            if (position >= 0 && position < 3) {
+                if (localLOGV) Log.d(TAG, "Selected premium SMS policy " + position);
+                setPremiumSmsPermission(mPackageName, (position + 1));
+            } else {
+                Log.e(TAG, "Error: unknown premium SMS policy " + position);
+            }
+        }
+
+        @Override
+        public void onNothingSelected(AdapterView<?> parent) {
+            // Ignored
+        }
+
+        private void setPremiumSmsPermission(String packageName, int permission) {
+            try {
+                if (mSmsManager != null) {
+                    mSmsManager.setPremiumSmsPermission(packageName, permission);
+                }
+            } catch (RemoteException ex) {
+                // ignored
+            }
+        }
+    }
+
+}
\ No newline at end of file
diff --git a/src/com/android/settings/applications/AppStorageSettings.java b/src/com/android/settings/applications/AppStorageSettings.java
new file mode 100644
index 0000000..5ae5e8f
--- /dev/null
+++ b/src/com/android/settings/applications/AppStorageSettings.java
@@ -0,0 +1,501 @@
+/*
+ * Copyright (C) 2015 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.settings.applications;
+
+import android.app.ActivityManager;
+import android.app.AlertDialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.IPackageDataObserver;
+import android.content.pm.IPackageMoveObserver;
+import android.content.pm.PackageManager;
+import android.os.Bundle;
+import android.os.Environment;
+import android.os.Handler;
+import android.os.Message;
+import android.os.RemoteException;
+import android.text.format.Formatter;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.TextView;
+
+import com.android.settings.R;
+import com.android.settings.Utils;
+import com.android.settings.applications.ApplicationsState.AppEntry;
+import com.android.settings.applications.ApplicationsState.Callbacks;
+
+public class AppStorageSettings extends AppInfoWithHeader implements OnClickListener, Callbacks {
+    private static final String TAG = "AppStorageSettings";
+
+    //internal constants used in Handler
+    private static final int OP_SUCCESSFUL = 1;
+    private static final int OP_FAILED = 2;
+    private static final int MSG_CLEAR_USER_DATA = 1;
+    private static final int MSG_CLEAR_CACHE = 3;
+    private static final int MSG_PACKAGE_MOVE = 4;
+
+    // invalid size value used initially and also when size retrieval through PackageManager
+    // fails for whatever reason
+    private static final int SIZE_INVALID = -1;
+
+    // Result code identifiers
+    public static final int REQUEST_MANAGE_SPACE = 2;
+
+    private static final int DLG_CLEAR_DATA = DLG_BASE + 1;
+    private static final int DLG_CANNOT_CLEAR_DATA = DLG_BASE + 2;
+    private static final int DLG_MOVE_FAILED = DLG_BASE + 3;
+
+    private CanBeOnSdCardChecker mCanBeOnSdCardChecker;
+    private TextView mTotalSize;
+    private TextView mAppSize;
+    private TextView mDataSize;
+    private TextView mExternalCodeSize;
+    private TextView mExternalDataSize;
+
+    // Views related to cache info
+    private TextView mCacheSize;
+    private Button mClearDataButton;
+    private Button mClearCacheButton;
+    private Button mMoveAppButton;
+    private boolean mMoveInProgress = false;
+
+    private boolean mCanClearData = true;
+    private boolean mHaveSizes = false;
+
+    private long mLastCodeSize = -1;
+    private long mLastDataSize = -1;
+    private long mLastExternalCodeSize = -1;
+    private long mLastExternalDataSize = -1;
+    private long mLastCacheSize = -1;
+    private long mLastTotalSize = -1;
+
+    private ClearCacheObserver mClearCacheObserver;
+    private ClearUserDataObserver mClearDataObserver;
+    private PackageMoveObserver mPackageMoveObserver;
+
+    // Resource strings
+    private CharSequence mInvalidSizeStr;
+    private CharSequence mComputingStr;
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        mCanBeOnSdCardChecker = new CanBeOnSdCardChecker();
+    }
+
+    @Override
+    public View onCreateView(LayoutInflater inflater, ViewGroup container,
+            Bundle savedInstanceState) {
+        final View view = inflater.inflate(R.layout.storage_settings, container, false);
+
+        final ViewGroup allDetails = (ViewGroup)view.findViewById(R.id.all_details);
+        Utils.forceCustomPadding(allDetails, true /* additive padding */);
+        mComputingStr = getActivity().getText(R.string.computing_size);
+        mInvalidSizeStr = getActivity().getText(R.string.invalid_size_value);
+
+        // Set default values on sizes
+        mTotalSize = (TextView)view.findViewById(R.id.total_size_text);
+        mAppSize = (TextView)view.findViewById(R.id.application_size_text);
+        mDataSize = (TextView)view.findViewById(R.id.data_size_text);
+        mExternalCodeSize = (TextView)view.findViewById(R.id.external_code_size_text);
+        mExternalDataSize = (TextView)view.findViewById(R.id.external_data_size_text);
+
+        if (Environment.isExternalStorageEmulated()) {
+            ((View)mExternalCodeSize.getParent()).setVisibility(View.GONE);
+            ((View)mExternalDataSize.getParent()).setVisibility(View.GONE);
+        }
+
+        // Initialize clear data and move install location buttons
+        View data_buttons_panel = view.findViewById(R.id.data_buttons_panel);
+        mMoveAppButton = (Button) data_buttons_panel.findViewById(R.id.left_button);
+
+        // Cache section
+        mCacheSize = (TextView)view.findViewById(R.id.cache_size_text);
+        mClearCacheButton = (Button)view.findViewById(R.id.clear_cache_button);
+        mClearDataButton = (Button) data_buttons_panel.findViewById(R.id.right_button);
+
+        return view;
+    }
+
+    @Override
+    public void onClick(View v) {
+        if (v == mClearCacheButton) {
+            // Lazy initialization of observer
+            if (mClearCacheObserver == null) {
+                mClearCacheObserver = new ClearCacheObserver();
+            }
+            mPm.deleteApplicationCacheFiles(mPackageName, mClearCacheObserver);
+        } else if(v == mClearDataButton) {
+            if (mAppEntry.info.manageSpaceActivityName != null) {
+                if (!Utils.isMonkeyRunning()) {
+                    Intent intent = new Intent(Intent.ACTION_DEFAULT);
+                    intent.setClassName(mAppEntry.info.packageName,
+                            mAppEntry.info.manageSpaceActivityName);
+                    startActivityForResult(intent, REQUEST_MANAGE_SPACE);
+                }
+            } else {
+                showDialogInner(DLG_CLEAR_DATA, 0);
+            }
+        } else if (v == mMoveAppButton) {
+            if (mPackageMoveObserver == null) {
+                mPackageMoveObserver = new PackageMoveObserver();
+            }
+            int moveFlags = (mAppEntry.info.flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0 ?
+                    PackageManager.MOVE_INTERNAL : PackageManager.MOVE_EXTERNAL_MEDIA;
+            mMoveInProgress = true;
+            refreshButtons();
+            mPm.movePackage(mAppEntry.info.packageName, mPackageMoveObserver, moveFlags);
+        }
+    }
+
+    private String getSizeStr(long size) {
+        if (size == SIZE_INVALID) {
+            return mInvalidSizeStr.toString();
+        }
+        return Formatter.formatFileSize(getActivity(), size);
+    }
+
+    private void refreshSizeInfo() {
+        if (mAppEntry.size == ApplicationsState.SIZE_INVALID
+                || mAppEntry.size == ApplicationsState.SIZE_UNKNOWN) {
+            mLastCodeSize = mLastDataSize = mLastCacheSize = mLastTotalSize = -1;
+            if (!mHaveSizes) {
+                mAppSize.setText(mComputingStr);
+                mDataSize.setText(mComputingStr);
+                mCacheSize.setText(mComputingStr);
+                mTotalSize.setText(mComputingStr);
+            }
+            mClearDataButton.setEnabled(false);
+            mClearCacheButton.setEnabled(false);
+
+        } else {
+            mHaveSizes = true;
+            long codeSize = mAppEntry.codeSize;
+            long dataSize = mAppEntry.dataSize;
+            if (Environment.isExternalStorageEmulated()) {
+                codeSize += mAppEntry.externalCodeSize;
+                dataSize +=  mAppEntry.externalDataSize;
+            } else {
+                if (mLastExternalCodeSize != mAppEntry.externalCodeSize) {
+                    mLastExternalCodeSize = mAppEntry.externalCodeSize;
+                    mExternalCodeSize.setText(getSizeStr(mAppEntry.externalCodeSize));
+                }
+                if (mLastExternalDataSize !=  mAppEntry.externalDataSize) {
+                    mLastExternalDataSize =  mAppEntry.externalDataSize;
+                    mExternalDataSize.setText(getSizeStr( mAppEntry.externalDataSize));
+                }
+            }
+            if (mLastCodeSize != codeSize) {
+                mLastCodeSize = codeSize;
+                mAppSize.setText(getSizeStr(codeSize));
+            }
+            if (mLastDataSize != dataSize) {
+                mLastDataSize = dataSize;
+                mDataSize.setText(getSizeStr(dataSize));
+            }
+            long cacheSize = mAppEntry.cacheSize + mAppEntry.externalCacheSize;
+            if (mLastCacheSize != cacheSize) {
+                mLastCacheSize = cacheSize;
+                mCacheSize.setText(getSizeStr(cacheSize));
+            }
+            if (mLastTotalSize != mAppEntry.size) {
+                mLastTotalSize = mAppEntry.size;
+                mTotalSize.setText(getSizeStr(mAppEntry.size));
+            }
+
+            if ((mAppEntry.dataSize+ mAppEntry.externalDataSize) <= 0 || !mCanClearData) {
+                mClearDataButton.setEnabled(false);
+            } else {
+                mClearDataButton.setEnabled(true);
+                mClearDataButton.setOnClickListener(this);
+            }
+            if (cacheSize <= 0) {
+                mClearCacheButton.setEnabled(false);
+            } else {
+                mClearCacheButton.setEnabled(true);
+                mClearCacheButton.setOnClickListener(this);
+            }
+        }
+        if (mAppControlRestricted) {
+            mClearCacheButton.setEnabled(false);
+            mClearDataButton.setEnabled(false);
+        }
+    }
+
+    @Override
+    protected boolean refreshUi() {
+        retrieveAppEntry();
+        refreshButtons();
+        refreshSizeInfo();
+        return true;
+    }
+
+    private void refreshButtons() {
+        if (!mMoveInProgress) {
+            initMoveButton();
+            initDataButtons();
+        } else {
+            mMoveAppButton.setText(R.string.moving);
+            mMoveAppButton.setEnabled(false);
+        }
+    }
+
+    private void initDataButtons() {
+        // If the app doesn't have its own space management UI
+        // And it's a system app that doesn't allow clearing user data or is an active admin
+        // Then disable the Clear Data button.
+        if (mAppEntry.info.manageSpaceActivityName == null
+                && ((mAppEntry.info.flags&(ApplicationInfo.FLAG_SYSTEM
+                        | ApplicationInfo.FLAG_ALLOW_CLEAR_USER_DATA))
+                        == ApplicationInfo.FLAG_SYSTEM
+                        || mDpm.packageHasActiveAdmins(mPackageName))) {
+            mClearDataButton.setText(R.string.clear_user_data_text);
+            mClearDataButton.setEnabled(false);
+            mCanClearData = false;
+        } else {
+            if (mAppEntry.info.manageSpaceActivityName != null) {
+                mClearDataButton.setText(R.string.manage_space_text);
+            } else {
+                mClearDataButton.setText(R.string.clear_user_data_text);
+            }
+            mClearDataButton.setOnClickListener(this);
+        }
+
+        if (mAppControlRestricted) {
+            mClearDataButton.setEnabled(false);
+        }
+    }
+
+    private void initMoveButton() {
+        if (Environment.isExternalStorageEmulated()) {
+            mMoveAppButton.setVisibility(View.INVISIBLE);
+            return;
+        }
+        boolean dataOnly = (mPackageInfo == null) && (mAppEntry != null);
+        boolean moveDisable = true;
+        if (dataOnly) {
+            mMoveAppButton.setText(R.string.move_app);
+        } else if ((mAppEntry.info.flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0) {
+            mMoveAppButton.setText(R.string.move_app_to_internal);
+            // Always let apps move to internal storage from sdcard.
+            moveDisable = false;
+        } else {
+            mMoveAppButton.setText(R.string.move_app_to_sdcard);
+            mCanBeOnSdCardChecker.init();
+            moveDisable = !mCanBeOnSdCardChecker.check(mAppEntry.info);
+        }
+        if (moveDisable || mAppControlRestricted) {
+            mMoveAppButton.setEnabled(false);
+        } else {
+            mMoveAppButton.setOnClickListener(this);
+            mMoveAppButton.setEnabled(true);
+        }
+    }
+
+    /*
+     * Private method to initiate clearing user data when the user clicks the clear data
+     * button for a system package
+     */
+    private void initiateClearUserData() {
+        mClearDataButton.setEnabled(false);
+        // Invoke uninstall or clear user data based on sysPackage
+        String packageName = mAppEntry.info.packageName;
+        Log.i(TAG, "Clearing user data for package : " + packageName);
+        if (mClearDataObserver == null) {
+            mClearDataObserver = new ClearUserDataObserver();
+        }
+        ActivityManager am = (ActivityManager)
+                getActivity().getSystemService(Context.ACTIVITY_SERVICE);
+        boolean res = am.clearApplicationUserData(packageName, mClearDataObserver);
+        if (!res) {
+            // Clearing data failed for some obscure reason. Just log error for now
+            Log.i(TAG, "Couldnt clear application user data for package:"+packageName);
+            showDialogInner(DLG_CANNOT_CLEAR_DATA, 0);
+        } else {
+            mClearDataButton.setText(R.string.recompute_size);
+        }
+    }
+
+    private void processMoveMsg(Message msg) {
+        int result = msg.arg1;
+        String packageName = mAppEntry.info.packageName;
+        // Refresh the button attributes.
+        mMoveInProgress = false;
+        if (result == PackageManager.MOVE_SUCCEEDED) {
+            Log.i(TAG, "Moved resources for " + packageName);
+            // Refresh size information again.
+            mState.requestSize(mAppEntry.info.packageName);
+        } else {
+            showDialogInner(DLG_MOVE_FAILED, result);
+        }
+        refreshUi();
+    }
+
+    /*
+     * Private method to handle clear message notification from observer when
+     * the async operation from PackageManager is complete
+     */
+    private void processClearMsg(Message msg) {
+        int result = msg.arg1;
+        String packageName = mAppEntry.info.packageName;
+        mClearDataButton.setText(R.string.clear_user_data_text);
+        if(result == OP_SUCCESSFUL) {
+            Log.i(TAG, "Cleared user data for package : "+packageName);
+            mState.requestSize(mAppEntry.info.packageName);
+        } else {
+            mClearDataButton.setEnabled(true);
+        }
+    }
+
+    private CharSequence getMoveErrMsg(int errCode) {
+        switch (errCode) {
+            case PackageManager.MOVE_FAILED_INSUFFICIENT_STORAGE:
+                return getActivity().getString(R.string.insufficient_storage);
+            case PackageManager.MOVE_FAILED_DOESNT_EXIST:
+                return getActivity().getString(R.string.does_not_exist);
+            case PackageManager.MOVE_FAILED_FORWARD_LOCKED:
+                return getActivity().getString(R.string.app_forward_locked);
+            case PackageManager.MOVE_FAILED_INVALID_LOCATION:
+                return getActivity().getString(R.string.invalid_location);
+            case PackageManager.MOVE_FAILED_SYSTEM_PACKAGE:
+                return getActivity().getString(R.string.system_package);
+            case PackageManager.MOVE_FAILED_INTERNAL_ERROR:
+                return "";
+        }
+        return "";
+    }
+
+    @Override
+    protected AlertDialog createDialog(int id, int errorCode) {
+        switch (id) {
+            case DLG_CLEAR_DATA:
+                return new AlertDialog.Builder(getActivity())
+                        .setTitle(getActivity().getText(R.string.clear_data_dlg_title))
+                        .setMessage(getActivity().getText(R.string.clear_data_dlg_text))
+                        .setPositiveButton(R.string.dlg_ok, new DialogInterface.OnClickListener() {
+                            public void onClick(DialogInterface dialog, int which) {
+                                // Clear user data here
+                                initiateClearUserData();
+                            }
+                        })
+                        .setNegativeButton(R.string.dlg_cancel, null)
+                        .create();
+            case DLG_CANNOT_CLEAR_DATA:
+                return new AlertDialog.Builder(getActivity())
+                        .setTitle(getActivity().getText(R.string.clear_failed_dlg_title))
+                        .setMessage(getActivity().getText(R.string.clear_failed_dlg_text))
+                        .setNeutralButton(R.string.dlg_ok, new DialogInterface.OnClickListener() {
+                            public void onClick(DialogInterface dialog, int which) {
+                                mClearDataButton.setEnabled(false);
+                                //force to recompute changed value
+                                setIntentAndFinish(false, false);
+                            }
+                        })
+                        .create();
+            case DLG_MOVE_FAILED:
+                CharSequence msg = getActivity().getString(R.string.move_app_failed_dlg_text,
+                        getMoveErrMsg(errorCode));
+                return new AlertDialog.Builder(getActivity())
+                        .setTitle(getActivity().getText(R.string.move_app_failed_dlg_title))
+                        .setMessage(msg)
+                        .setNeutralButton(R.string.dlg_ok, null)
+                        .create();
+        }
+        return null;
+    }
+
+    @Override
+    public void onPackageSizeChanged(String packageName) {
+        if (packageName.equals(mAppEntry.info.packageName)) {
+            refreshSizeInfo();
+        }
+    }
+
+    private final Handler mHandler = new Handler() {
+        public void handleMessage(Message msg) {
+            if (getView() == null) {
+                return;
+            }
+            switch (msg.what) {
+                case MSG_CLEAR_USER_DATA:
+                    processClearMsg(msg);
+                    break;
+                case MSG_CLEAR_CACHE:
+                    // Refresh size info
+                    mState.requestSize(mPackageName);
+                    break;
+                case MSG_PACKAGE_MOVE:
+                    processMoveMsg(msg);
+                    break;
+            }
+        }
+    };
+
+    public static CharSequence getSummary(AppEntry appEntry, Context context) {
+        if (appEntry.size == ApplicationsState.SIZE_INVALID
+                || appEntry.size == ApplicationsState.SIZE_UNKNOWN) {
+            return context.getText(R.string.computing_size);
+        } else {
+            CharSequence storageType = context.getString(
+                    (appEntry.info.flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0
+                    ? R.string.storage_type_external
+                    : R.string.storage_type_internal);
+            return context.getString(R.string.storage_summary_format,
+                    getSize(appEntry, context), storageType);
+        }
+    }
+
+    private static CharSequence getSize(AppEntry appEntry, Context context) {
+        long size = appEntry.size;
+        if (size == SIZE_INVALID) {
+            return context.getText(R.string.invalid_size_value);
+        }
+        return Formatter.formatFileSize(context, size);
+    }
+
+    class ClearCacheObserver extends IPackageDataObserver.Stub {
+        public void onRemoveCompleted(final String packageName, final boolean succeeded) {
+            final Message msg = mHandler.obtainMessage(MSG_CLEAR_CACHE);
+            msg.arg1 = succeeded ? OP_SUCCESSFUL : OP_FAILED;
+            mHandler.sendMessage(msg);
+        }
+    }
+
+    class ClearUserDataObserver extends IPackageDataObserver.Stub {
+       public void onRemoveCompleted(final String packageName, final boolean succeeded) {
+           final Message msg = mHandler.obtainMessage(MSG_CLEAR_USER_DATA);
+           msg.arg1 = succeeded?OP_SUCCESSFUL:OP_FAILED;
+           mHandler.sendMessage(msg);
+        }
+    }
+
+    class PackageMoveObserver extends IPackageMoveObserver.Stub {
+        public void packageMoved(String packageName, int returnCode) throws RemoteException {
+            final Message msg = mHandler.obtainMessage(MSG_PACKAGE_MOVE);
+            msg.arg1 = returnCode;
+            mHandler.sendMessage(msg);
+        }
+    }
+
+}
diff --git a/src/com/android/settings/applications/HeaderPreference.java b/src/com/android/settings/applications/HeaderPreference.java
new file mode 100644
index 0000000..57fe9f3
--- /dev/null
+++ b/src/com/android/settings/applications/HeaderPreference.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2015 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.settings.applications;
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.preference.Preference;
+import android.util.AttributeSet;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import com.android.settings.R;
+import com.android.settings.Utils;
+
+public class HeaderPreference extends Preference {
+
+    private View mRootView;
+
+    public HeaderPreference(Context context, AttributeSet attrs) {
+        super(context, attrs);
+        final TypedArray a = context.obtainStyledAttributes(
+                attrs, com.android.internal.R.styleable.Preference, 0, 0);
+        int layoutResource = a.getResourceId(com.android.internal.R.styleable.Preference_layout,
+                0);
+        if (layoutResource == 0) {
+            throw new IllegalArgumentException("HeaderPreference requires a layout to be defined");
+        }
+        // Need to create view now so that findViewById can be called immediately.
+        final View view = LayoutInflater.from(getContext())
+                .inflate(layoutResource, null, false);
+
+        final ViewGroup allDetails = (ViewGroup) view.findViewById(R.id.all_details);
+        Utils.forceCustomPadding(allDetails, true /* additive padding */);
+        mRootView = view;
+    }
+
+    @Override
+    protected View onCreateView(ViewGroup parent) {
+        return mRootView;
+    }
+
+    public View findViewById(int id) {
+        return mRootView.findViewById(id);
+    }
+
+}
diff --git a/src/com/android/settings/applications/InstalledAppDetails.java b/src/com/android/settings/applications/InstalledAppDetails.java
index 3aa948d..d77d63f 100755
--- a/src/com/android/settings/applications/InstalledAppDetails.java
+++ b/src/com/android/settings/applications/InstalledAppDetails.java
@@ -16,74 +16,46 @@
 
 package com.android.settings.applications;
 
-import com.android.internal.telephony.ISms;
-import com.android.internal.telephony.SmsUsageMonitor;
-import com.android.settings.R;
-import com.android.settings.SettingsActivity;
-import com.android.settings.Utils;
-import com.android.settings.applications.ApplicationsState.AppEntry;
-
 import android.app.Activity;
 import android.app.ActivityManager;
 import android.app.AlertDialog;
-import android.app.Dialog;
-import android.app.DialogFragment;
-import android.app.Fragment;
-import android.app.INotificationManager;
-import android.app.admin.DevicePolicyManager;
-import android.appwidget.AppWidgetManager;
 import android.content.BroadcastReceiver;
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.DialogInterface;
 import android.content.Intent;
-import android.content.IntentFilter;
 import android.content.pm.ApplicationInfo;
-import android.content.pm.IPackageDataObserver;
-import android.content.pm.IPackageMoveObserver;
 import android.content.pm.PackageInfo;
 import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
 import android.content.pm.PackageManager.NameNotFoundException;
-import android.content.res.Resources;
-import android.hardware.usb.IUsbManager;
+import android.content.pm.ResolveInfo;
 import android.net.Uri;
 import android.os.AsyncTask;
 import android.os.Bundle;
-import android.os.Environment;
-import android.os.Handler;
-import android.os.IBinder;
-import android.os.Message;
-import android.os.RemoteException;
-import android.os.ServiceManager;
 import android.os.UserHandle;
-import android.os.UserManager;
-import android.text.SpannableString;
-import android.text.TextUtils;
-import android.text.format.Formatter;
-import android.text.style.BulletSpan;
-import android.util.Log;
+import android.preference.Preference;
+import android.preference.Preference.OnPreferenceClickListener;
+import android.provider.Settings;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.Button;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.android.settings.R;
+import com.android.settings.SettingsActivity;
+import com.android.settings.Utils;
+import com.android.settings.applications.ApplicationsState.AppEntry;
+import com.android.settings.notification.NotificationAppList;
+import com.android.settings.notification.NotificationAppList.AppRow;
+import com.android.settings.notification.NotificationAppList.Backend;
 
 import java.lang.ref.WeakReference;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
-import android.view.LayoutInflater;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.AdapterView;
-import android.widget.AppSecurityPermissions;
-import android.widget.ArrayAdapter;
-import android.widget.Button;
-import android.widget.CheckBox;
-import android.widget.CompoundButton;
-import android.widget.ImageView;
-import android.widget.LinearLayout;
-import android.widget.Spinner;
-import android.widget.TextView;
 
 /**
  * Activity to display application information from Settings. This activity presents
@@ -94,227 +66,48 @@
  * For non-system applications, there is no option to clear data. Instead there is an option to
  * uninstall the application.
  */
-public class InstalledAppDetails extends Fragment
-        implements View.OnClickListener, CompoundButton.OnCheckedChangeListener,
-        ApplicationsState.Callbacks {
-    private static final String TAG="InstalledAppDetails";
-    private static final boolean localLOGV = false;
-    
-    public static final String ARG_PACKAGE_NAME = "package";
-
-    private PackageManager mPm;
-    private UserManager mUserManager;
-    private IUsbManager mUsbManager;
-    private AppWidgetManager mAppWidgetManager;
-    private DevicePolicyManager mDpm;
-    private ISms mSmsManager;
-    private ApplicationsState mState;
-    private ApplicationsState.Session mSession;
-    private ApplicationsState.AppEntry mAppEntry;
-    private boolean mInitialized;
-    private boolean mShowUninstalled;
-    private PackageInfo mPackageInfo;
-    private CanBeOnSdCardChecker mCanBeOnSdCardChecker;
-    private View mRootView;
-    private Button mUninstallButton;
-    private View mMoreControlButtons;
-    private Button mSpecialDisableButton;
-    private boolean mMoveInProgress = false;
-    private boolean mUpdatedSysApp = false;
-    private Button mActivitiesButton;
-    private View mScreenCompatSection;
-    private CheckBox mAskCompatibilityCB;
-    private CheckBox mEnableCompatibilityCB;
-    private boolean mCanClearData = true;
-    private boolean mAppControlRestricted = false;
-    private TextView mAppVersion;
-    private TextView mTotalSize;
-    private TextView mAppSize;
-    private TextView mDataSize;
-    private TextView mExternalCodeSize;
-    private TextView mExternalDataSize;
-    private ClearUserDataObserver mClearDataObserver;
-    // Views related to cache info
-    private TextView mCacheSize;
-    private Button mClearCacheButton;
-    private ClearCacheObserver mClearCacheObserver;
-    private Button mForceStopButton;
-    private Button mClearDataButton;
-    private Button mMoveAppButton;
-    private CompoundButton mNotificationSwitch;
-
-    private PackageMoveObserver mPackageMoveObserver;
-
-    private final HashSet<String> mHomePackages = new HashSet<String>();
-
-    private boolean mDisableAfterUninstall;
-
-    private boolean mHaveSizes = false;
-    private long mLastCodeSize = -1;
-    private long mLastDataSize = -1;
-    private long mLastExternalCodeSize = -1;
-    private long mLastExternalDataSize = -1;
-    private long mLastCacheSize = -1;
-    private long mLastTotalSize = -1;
-    
-    //internal constants used in Handler
-    private static final int OP_SUCCESSFUL = 1;
-    private static final int OP_FAILED = 2;
-    private static final int CLEAR_USER_DATA = 1;
-    private static final int CLEAR_CACHE = 3;
-    private static final int PACKAGE_MOVE = 4;
-    
-    // invalid size value used initially and also when size retrieval through PackageManager
-    // fails for whatever reason
-    private static final int SIZE_INVALID = -1;
-    
-    // Resource strings
-    private CharSequence mInvalidSizeStr;
-    private CharSequence mComputingStr;
-    
-    // Dialog identifiers used in showDialog
-    private static final int DLG_BASE = 0;
-    private static final int DLG_CLEAR_DATA = DLG_BASE + 1;
-    private static final int DLG_FACTORY_RESET = DLG_BASE + 2;
-    private static final int DLG_APP_NOT_FOUND = DLG_BASE + 3;
-    private static final int DLG_CANNOT_CLEAR_DATA = DLG_BASE + 4;
-    private static final int DLG_FORCE_STOP = DLG_BASE + 5;
-    private static final int DLG_MOVE_FAILED = DLG_BASE + 6;
-    private static final int DLG_DISABLE = DLG_BASE + 7;
-    private static final int DLG_DISABLE_NOTIFICATIONS = DLG_BASE + 8;
-    private static final int DLG_SPECIAL_DISABLE = DLG_BASE + 9;
+public class InstalledAppDetails extends AppInfoBase
+        implements View.OnClickListener, OnPreferenceClickListener {
 
     // Menu identifiers
     public static final int UNINSTALL_ALL_USERS_MENU = 1;
 
     // Result code identifiers
-    public static final int REQUEST_UNINSTALL = 1;
-    public static final int REQUEST_MANAGE_SPACE = 2;
+    public static final int REQUEST_UNINSTALL = 0;
+    private static final int SUB_INFO_FRAGMENT = 1;
 
-    private Handler mHandler = new Handler() {
-        public void handleMessage(Message msg) {
-            // If the fragment is gone, don't process any more messages.
-            if (getView() == null) {
-                return;
-            }
-            switch (msg.what) {
-                case CLEAR_USER_DATA:
-                    processClearMsg(msg);
-                    break;
-                case CLEAR_CACHE:
-                    // Refresh size info
-                    mState.requestSize(mAppEntry.info.packageName);
-                    break;
-                case PACKAGE_MOVE:
-                    processMoveMsg(msg);
-                    break;
-                default:
-                    break;
-            }
-        }
-    };
-    
-    class ClearUserDataObserver extends IPackageDataObserver.Stub {
-       public void onRemoveCompleted(final String packageName, final boolean succeeded) {
-           final Message msg = mHandler.obtainMessage(CLEAR_USER_DATA);
-           msg.arg1 = succeeded?OP_SUCCESSFUL:OP_FAILED;
-           mHandler.sendMessage(msg);
-        }
-    }
-    
-    class ClearCacheObserver extends IPackageDataObserver.Stub {
-        public void onRemoveCompleted(final String packageName, final boolean succeeded) {
-            final Message msg = mHandler.obtainMessage(CLEAR_CACHE);
-            msg.arg1 = succeeded ? OP_SUCCESSFUL:OP_FAILED;
-            mHandler.sendMessage(msg);
-         }
-     }
+    private static final int DLG_FORCE_STOP = DLG_BASE + 1;
+    private static final int DLG_DISABLE = DLG_BASE + 2;
+    private static final int DLG_SPECIAL_DISABLE = DLG_BASE + 3;
+    private static final int DLG_FACTORY_RESET = DLG_BASE + 4;
 
-    class PackageMoveObserver extends IPackageMoveObserver.Stub {
-        public void packageMoved(String packageName, int returnCode) throws RemoteException {
-            final Message msg = mHandler.obtainMessage(PACKAGE_MOVE);
-            msg.arg1 = returnCode;
-            mHandler.sendMessage(msg);
-        }
-    }
-    
-    private String getSizeStr(long size) {
-        if (size == SIZE_INVALID) {
-            return mInvalidSizeStr.toString();
-        }
-        return Formatter.formatFileSize(getActivity(), size);
-    }
-    
-    private void initDataButtons() {
-        // If the app doesn't have its own space management UI
-        // And it's a system app that doesn't allow clearing user data or is an active admin
-        // Then disable the Clear Data button.
-        if (mAppEntry.info.manageSpaceActivityName == null
-                && ((mAppEntry.info.flags&(ApplicationInfo.FLAG_SYSTEM
-                        | ApplicationInfo.FLAG_ALLOW_CLEAR_USER_DATA))
-                        == ApplicationInfo.FLAG_SYSTEM
-                        || mDpm.packageHasActiveAdmins(mPackageInfo.packageName))) {
-            mClearDataButton.setText(R.string.clear_user_data_text);
-            mClearDataButton.setEnabled(false);
-            mCanClearData = false;
-        } else {
-            if (mAppEntry.info.manageSpaceActivityName != null) {
-                mClearDataButton.setText(R.string.manage_space_text);
-            } else {
-                mClearDataButton.setText(R.string.clear_user_data_text);
-            }
-            mClearDataButton.setOnClickListener(this);
-        }
+    private static final String KEY_HEADER = "header_view";
+    private static final String KEY_NOTIFICATION = "notification_settings";
+    private static final String KEY_STORAGE = "storage_settings";
+    private static final String KEY_PERMISSION = "permission_settings";
+    private static final String KEY_DATA = "data_settings";
+    private static final String KEY_LAUNCH = "preferred_settings";
 
-        if (mAppControlRestricted) {
-            mClearDataButton.setEnabled(false);
-        }
-    }
+    private final HashSet<String> mHomePackages = new HashSet<String>();
 
-    private CharSequence getMoveErrMsg(int errCode) {
-        switch (errCode) {
-            case PackageManager.MOVE_FAILED_INSUFFICIENT_STORAGE:
-                return getActivity().getString(R.string.insufficient_storage);
-            case PackageManager.MOVE_FAILED_DOESNT_EXIST:
-                return getActivity().getString(R.string.does_not_exist);
-            case PackageManager.MOVE_FAILED_FORWARD_LOCKED:
-                return getActivity().getString(R.string.app_forward_locked);
-            case PackageManager.MOVE_FAILED_INVALID_LOCATION:
-                return getActivity().getString(R.string.invalid_location);
-            case PackageManager.MOVE_FAILED_SYSTEM_PACKAGE:
-                return getActivity().getString(R.string.system_package);
-            case PackageManager.MOVE_FAILED_INTERNAL_ERROR:
-                return "";
-        }
-        return "";
-    }
+    private boolean mInitialized;
+    private boolean mShowUninstalled;
+    private HeaderPreference mHeader;
+    private Button mUninstallButton;
+    private View mMoreControlButtons;
+    private Button mSpecialDisableButton;
+    private boolean mUpdatedSysApp = false;
+    private TextView mAppVersion;
+    private Button mForceStopButton;
+    private Preference mNotificationPreference;
+    private Preference mStoragePreference;
+    private Preference mPermissionsPreference;
+    private Preference mLaunchPreference;
+    private Preference mDataPreference;
 
-    private void initMoveButton() {
-        if (Environment.isExternalStorageEmulated()) {
-            mMoveAppButton.setVisibility(View.INVISIBLE);
-            return;
-        }
-        boolean dataOnly = false;
-        dataOnly = (mPackageInfo == null) && (mAppEntry != null);
-        boolean moveDisable = true;
-        if (dataOnly) {
-            mMoveAppButton.setText(R.string.move_app);
-        } else if ((mAppEntry.info.flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0) {
-            mMoveAppButton.setText(R.string.move_app_to_internal);
-            // Always let apps move to internal storage from sdcard.
-            moveDisable = false;
-        } else {
-            mMoveAppButton.setText(R.string.move_app_to_sdcard);
-            mCanBeOnSdCardChecker.init();
-            moveDisable = !mCanBeOnSdCardChecker.check(mAppEntry.info);
-        }
-        if (moveDisable || mAppControlRestricted) {
-            mMoveAppButton.setEnabled(false);
-        } else {
-            mMoveAppButton.setOnClickListener(this);
-            mMoveAppButton.setEnabled(true);
-        }
-    }
+    private boolean mDisableAfterUninstall;
+    // Used for updating notification preference.
+    private final Backend mBackend = new Backend();
 
     private boolean handleDisableable(Button button) {
         boolean disableable = false;
@@ -407,108 +200,48 @@
         }
     }
 
-    private void initNotificationButton() {
-        INotificationManager nm = INotificationManager.Stub.asInterface(
-                ServiceManager.getService(Context.NOTIFICATION_SERVICE));
-        boolean enabled = true; // default on
-        try {
-            enabled = nm.areNotificationsEnabledForPackage(mAppEntry.info.packageName,
-                    mAppEntry.info.uid);
-        } catch (android.os.RemoteException ex) {
-            // this does not bode well
-        }
-        mNotificationSwitch.setChecked(enabled);
-        if (Utils.isSystemPackage(mPm, mPackageInfo)) {
-            mNotificationSwitch.setEnabled(false);
-        } else if ((mPackageInfo.applicationInfo.flags & ApplicationInfo.FLAG_INSTALLED) == 0) {
-            // App is not installed on the current user
-            mNotificationSwitch.setEnabled(false);
-        } else {
-            mNotificationSwitch.setEnabled(true);
-            mNotificationSwitch.setOnCheckedChangeListener(this);
-        }
-    }
-
     /** Called when the activity is first created. */
     @Override
     public void onCreate(Bundle icicle) {
         super.onCreate(icicle);
 
-        mState = ApplicationsState.getInstance(getActivity().getApplication());
-        mSession = mState.newSession(this);
-        mPm = getActivity().getPackageManager();
-        mUserManager = (UserManager)getActivity().getSystemService(Context.USER_SERVICE);
-        IBinder b = ServiceManager.getService(Context.USB_SERVICE);
-        mUsbManager = IUsbManager.Stub.asInterface(b);
-        mAppWidgetManager = AppWidgetManager.getInstance(getActivity());
-        mDpm = (DevicePolicyManager)getActivity().getSystemService(Context.DEVICE_POLICY_SERVICE);
-        mSmsManager = ISms.Stub.asInterface(ServiceManager.getService("isms"));
-
-        mCanBeOnSdCardChecker = new CanBeOnSdCardChecker();
-
-        // Need to make sure we have loaded applications at this point.
-        mSession.resume();
-
-        retrieveAppEntry();
-
         setHasOptionsMenu(true);
+        addPreferencesFromResource(R.xml.installed_app_details);
     }
 
-    @Override
-    public View onCreateView(
-            LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
-        final View view = inflater.inflate(R.layout.installed_app_details, container, false);
+    public void onActivityCreated(Bundle savedInstanceState) {
+        super.onActivityCreated(savedInstanceState);
+        handleHeader();
 
-        final ViewGroup allDetails = (ViewGroup) view.findViewById(R.id.all_details);
-        Utils.forceCustomPadding(allDetails, true /* additive padding */);
+        mNotificationPreference = findPreference(KEY_NOTIFICATION);
+        mNotificationPreference.setOnPreferenceClickListener(this);
+        mStoragePreference = findPreference(KEY_STORAGE);
+        mStoragePreference.setOnPreferenceClickListener(this);
+        mPermissionsPreference = findPreference(KEY_PERMISSION);
+        mPermissionsPreference.setOnPreferenceClickListener(this);
+        mLaunchPreference = findPreference(KEY_LAUNCH);
+        mLaunchPreference.setOnPreferenceClickListener(this);
+        mDataPreference = findPreference(KEY_DATA);
+        mDataPreference.setOnPreferenceClickListener(this);
+        // Data isn't ready, lets just pull it for now.
+        getPreferenceScreen().removePreference(mDataPreference);
+    }
 
-        mRootView = view;
-        mComputingStr = getActivity().getText(R.string.computing_size);
-        
-        // Set default values on sizes
-        mTotalSize = (TextView) view.findViewById(R.id.total_size_text);
-        mAppSize = (TextView) view.findViewById(R.id.application_size_text);
-        mDataSize = (TextView) view.findViewById(R.id.data_size_text);
-        mExternalCodeSize = (TextView) view.findViewById(R.id.external_code_size_text);
-        mExternalDataSize = (TextView) view.findViewById(R.id.external_data_size_text);
-
-        if (Environment.isExternalStorageEmulated()) {
-            ((View)mExternalCodeSize.getParent()).setVisibility(View.GONE);
-            ((View)mExternalDataSize.getParent()).setVisibility(View.GONE);
-        }
+    private void handleHeader() {
+        mHeader = (HeaderPreference) findPreference(KEY_HEADER);
 
         // Get Control button panel
-        View btnPanel = view.findViewById(R.id.control_buttons_panel);
-        mForceStopButton = (Button) btnPanel.findViewById(R.id.left_button);
+        View btnPanel = mHeader.findViewById(R.id.control_buttons_panel);
+        mForceStopButton = (Button) btnPanel.findViewById(R.id.right_button);
         mForceStopButton.setText(R.string.force_stop);
-        mUninstallButton = (Button) btnPanel.findViewById(R.id.right_button);
+        mUninstallButton = (Button) btnPanel.findViewById(R.id.left_button);
         mForceStopButton.setEnabled(false);
-        
+
         // Get More Control button panel
-        mMoreControlButtons = view.findViewById(R.id.more_control_buttons_panel);
-        mMoreControlButtons.findViewById(R.id.left_button).setVisibility(View.INVISIBLE);
-        mSpecialDisableButton = (Button) mMoreControlButtons.findViewById(R.id.right_button);
+        mMoreControlButtons = mHeader.findViewById(R.id.more_control_buttons_panel);
+        mMoreControlButtons.findViewById(R.id.right_button).setVisibility(View.INVISIBLE);
+        mSpecialDisableButton = (Button) mMoreControlButtons.findViewById(R.id.left_button);
         mMoreControlButtons.setVisibility(View.GONE);
-        
-        // Initialize clear data and move install location buttons
-        View data_buttons_panel = view.findViewById(R.id.data_buttons_panel);
-        mClearDataButton = (Button) data_buttons_panel.findViewById(R.id.right_button);
-        mMoveAppButton = (Button) data_buttons_panel.findViewById(R.id.left_button);
-        
-        // Cache section
-        mCacheSize = (TextView) view.findViewById(R.id.cache_size_text);
-        mClearCacheButton = (Button) view.findViewById(R.id.clear_cache_button);
-
-        mActivitiesButton = (Button) view.findViewById(R.id.clear_activities_button);
-        
-        // Screen compatibility control
-        mScreenCompatSection = view.findViewById(R.id.screen_compatibility_section);
-        mAskCompatibilityCB = (CheckBox) view.findViewById(R.id.ask_compatibility_cb);
-        mEnableCompatibilityCB = (CheckBox) view.findViewById(R.id.enable_compatibility_cb);
-        
-        mNotificationSwitch = (CompoundButton) view.findViewById(R.id.notification_switch);
-
-        return view;
     }
 
     @Override
@@ -572,8 +305,9 @@
 
     // Utility method to set application label and icon.
     private void setAppLabelAndIcon(PackageInfo pkgInfo) {
-        final View appSnippet = mRootView.findViewById(R.id.app_snippet);
-        appSnippet.setPaddingRelative(0, appSnippet.getPaddingTop(), 0, appSnippet.getPaddingBottom());
+        final View appSnippet = mHeader.findViewById(R.id.app_snippet);
+        appSnippet.setPaddingRelative(0, appSnippet.getPaddingTop(), 0,
+                appSnippet.getPaddingBottom());
 
         ImageView icon = (ImageView) appSnippet.findViewById(R.id.app_icon);
         mState.ensureIcon(mAppEntry);
@@ -593,86 +327,6 @@
         }
     }
 
-    @Override
-    public void onResume() {
-        super.onResume();
-        
-        mAppControlRestricted = mUserManager.hasUserRestriction(UserManager.DISALLOW_APPS_CONTROL);
-        mSession.resume();
-        if (!refreshUi()) {
-            setIntentAndFinish(true, true);
-        }
-    }
-
-    @Override
-    public void onPause() {
-        super.onPause();
-        mSession.pause();
-    }
-
-    @Override
-    public void onDestroyView() {
-        super.onDestroyView();
-        mSession.release();
-    }
-
-    @Override
-    public void onAllSizesComputed() {
-    }
-
-    @Override
-    public void onPackageIconChanged() {
-    }
-
-    @Override
-    public void onPackageListChanged() {
-        refreshUi();
-    }
-
-    @Override
-    public void onRebuildComplete(ArrayList<AppEntry> apps) {
-    }
-
-    @Override
-    public void onPackageSizeChanged(String packageName) {
-        if (packageName.equals(mAppEntry.info.packageName)) {
-            refreshSizeInfo();
-        }
-    }
-
-    @Override
-    public void onRunningStateChanged(boolean running) {
-    }
-
-    private String retrieveAppEntry() {
-        final Bundle args = getArguments();
-        String packageName = (args != null) ? args.getString(ARG_PACKAGE_NAME) : null;
-        if (packageName == null) {
-            Intent intent = (args == null) ?
-                    getActivity().getIntent() : (Intent) args.getParcelable("intent");
-            if (intent != null) {
-                packageName = intent.getData().getSchemeSpecificPart();
-            }
-        }
-        mAppEntry = mState.getEntry(packageName);
-        if (mAppEntry != null) {
-            // Get application info again to refresh changed properties of application
-            try {
-                mPackageInfo = mPm.getPackageInfo(mAppEntry.info.packageName,
-                        PackageManager.GET_DISABLED_COMPONENTS |
-                        PackageManager.GET_UNINSTALLED_PACKAGES |
-                        PackageManager.GET_SIGNATURES);
-            } catch (NameNotFoundException e) {
-                Log.e(TAG, "Exception when retrieving package:" + mAppEntry.info.packageName, e);
-            }
-        } else {
-            Log.w(TAG, "Missing AppEntry; maybe reinstalling?");
-            mPackageInfo = null;
-        }
-
-        return packageName;
-    }
-
     private boolean signaturesMatch(String pkg1, String pkg2) {
         if (pkg1 != null && pkg2 != null) {
             try {
@@ -688,12 +342,9 @@
         return false;
     }
 
-    private boolean refreshUi() {
-        if (mMoveInProgress) {
-            return true;
-        }
-        final String packageName = retrieveAppEntry();
-
+    @Override
+    protected boolean refreshUi() {
+        retrieveAppEntry();
         if (mAppEntry == null) {
             return false; // onCreate must have failed, make sure to exit
         }
@@ -721,175 +372,18 @@
             }
         }
 
-        // Get list of preferred activities
-        List<ComponentName> prefActList = new ArrayList<ComponentName>();
-        
-        // Intent list cannot be null. so pass empty list
-        List<IntentFilter> intentList = new ArrayList<IntentFilter>();
-        mPm.getPreferredActivities(intentList, prefActList, packageName);
-        if (localLOGV)
-            Log.i(TAG, "Have " + prefActList.size() + " number of activities in preferred list");
-        boolean hasUsbDefaults = false;
-        try {
-            if (mUsbManager != null) {
-                hasUsbDefaults = mUsbManager.hasDefaults(packageName, UserHandle.myUserId());
-            }
-        } catch (RemoteException e) {
-            Log.e(TAG, "mUsbManager.hasDefaults", e);
-        }
-        boolean hasBindAppWidgetPermission =
-                mAppWidgetManager.hasBindAppWidgetPermission(mAppEntry.info.packageName);
-
-        TextView autoLaunchTitleView = (TextView) mRootView.findViewById(R.id.auto_launch_title);
-        TextView autoLaunchView = (TextView) mRootView.findViewById(R.id.auto_launch);
-        boolean autoLaunchEnabled = prefActList.size() > 0 || hasUsbDefaults;
-        if (!autoLaunchEnabled && !hasBindAppWidgetPermission) {
-            resetLaunchDefaultsUi(autoLaunchTitleView, autoLaunchView);
-        } else {
-            boolean useBullets = hasBindAppWidgetPermission && autoLaunchEnabled;
-
-            if (hasBindAppWidgetPermission) {
-                autoLaunchTitleView.setText(R.string.auto_launch_label_generic);
-            } else {
-                autoLaunchTitleView.setText(R.string.auto_launch_label);
-            }
-
-            CharSequence text = null;
-            int bulletIndent = getResources()
-                    .getDimensionPixelSize(R.dimen.installed_app_details_bullet_offset);
-            if (autoLaunchEnabled) {
-                CharSequence autoLaunchEnableText = getText(R.string.auto_launch_enable_text);
-                SpannableString s = new SpannableString(autoLaunchEnableText);
-                if (useBullets) {
-                    s.setSpan(new BulletSpan(bulletIndent), 0, autoLaunchEnableText.length(), 0);
-                }
-                text = (text == null) ?
-                        TextUtils.concat(s, "\n") : TextUtils.concat(text, "\n", s, "\n");
-            }
-            if (hasBindAppWidgetPermission) {
-                CharSequence alwaysAllowBindAppWidgetsText =
-                        getText(R.string.always_allow_bind_appwidgets_text);
-                SpannableString s = new SpannableString(alwaysAllowBindAppWidgetsText);
-                if (useBullets) {
-                    s.setSpan(new BulletSpan(bulletIndent),
-                            0, alwaysAllowBindAppWidgetsText.length(), 0);
-                }
-                text = (text == null) ?
-                        TextUtils.concat(s, "\n") : TextUtils.concat(text, "\n", s, "\n");
-            }
-            autoLaunchView.setText(text);
-            mActivitiesButton.setEnabled(true);
-            mActivitiesButton.setOnClickListener(this);
-        }
-
-        // Screen compatibility section.
-        ActivityManager am = (ActivityManager)
-                getActivity().getSystemService(Context.ACTIVITY_SERVICE);
-        int compatMode = am.getPackageScreenCompatMode(packageName);
-        // For now these are always off; this is the old UI model which we
-        // are no longer using.
-        if (false && (compatMode == ActivityManager.COMPAT_MODE_DISABLED
-                || compatMode == ActivityManager.COMPAT_MODE_ENABLED)) {
-            mScreenCompatSection.setVisibility(View.VISIBLE);
-            mAskCompatibilityCB.setChecked(am.getPackageAskScreenCompat(packageName));
-            mAskCompatibilityCB.setOnCheckedChangeListener(this);
-            mEnableCompatibilityCB.setChecked(compatMode == ActivityManager.COMPAT_MODE_ENABLED);
-            mEnableCompatibilityCB.setOnCheckedChangeListener(this);
-        } else {
-            mScreenCompatSection.setVisibility(View.GONE);
-        }
-
-        // Security permissions section
-        LinearLayout permsView = (LinearLayout) mRootView.findViewById(R.id.permissions_section);
-        AppSecurityPermissions asp = new AppSecurityPermissions(getActivity(), packageName);
-        int premiumSmsPermission = getPremiumSmsPermission(packageName);
-        // Premium SMS permission implies the app also has SEND_SMS permission, so the original
-        // application permissions list doesn't have to be shown/hidden separately. The premium
-        // SMS subsection should only be visible if the app has tried to send to a premium SMS.
-        if (asp.getPermissionCount() > 0
-                || premiumSmsPermission != SmsUsageMonitor.PREMIUM_SMS_PERMISSION_UNKNOWN) {
-            permsView.setVisibility(View.VISIBLE);
-        } else {
-            permsView.setVisibility(View.GONE);
-        }
-        // Premium SMS permission subsection
-        TextView securityBillingDesc = (TextView) permsView.findViewById(
-                R.id.security_settings_billing_desc);
-        LinearLayout securityBillingList = (LinearLayout) permsView.findViewById(
-                R.id.security_settings_billing_list);
-        if (premiumSmsPermission != SmsUsageMonitor.PREMIUM_SMS_PERMISSION_UNKNOWN) {
-            // Show the premium SMS permission selector
-            securityBillingDesc.setVisibility(View.VISIBLE);
-            securityBillingList.setVisibility(View.VISIBLE);
-            Spinner spinner = (Spinner) permsView.findViewById(
-                    R.id.security_settings_premium_sms_list);
-            ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActivity(),
-                    R.array.security_settings_premium_sms_values,
-                    android.R.layout.simple_spinner_item);
-            adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
-            spinner.setAdapter(adapter);
-            // List items are in the same order as SmsUsageMonitor constants, offset by 1.
-            spinner.setSelection(premiumSmsPermission - 1);
-            spinner.setOnItemSelectedListener(new PremiumSmsSelectionListener(
-                    packageName, mSmsManager));
-        } else {
-            // Hide the premium SMS permission selector
-            securityBillingDesc.setVisibility(View.GONE);
-            securityBillingList.setVisibility(View.GONE);
-        }
-        // App permissions subsection
-        if (asp.getPermissionCount() > 0) {
-            // Make the security sections header visible
-            LinearLayout securityList = (LinearLayout) permsView.findViewById(
-                    R.id.security_settings_list);
-            securityList.removeAllViews();
-            securityList.addView(asp.getPermissionsViewWithRevokeButtons());
-            // If this app is running under a shared user ID with other apps,
-            // update the description to explain this.
-            String[] packages = mPm.getPackagesForUid(mPackageInfo.applicationInfo.uid);
-            if (packages != null && packages.length > 1) {
-                ArrayList<CharSequence> pnames = new ArrayList<CharSequence>();
-                for (int i=0; i<packages.length; i++) {
-                    String pkg = packages[i];
-                    if (mPackageInfo.packageName.equals(pkg)) {
-                        continue;
-                    }
-                    try {
-                        ApplicationInfo ainfo = mPm.getApplicationInfo(pkg, 0);
-                        pnames.add(ainfo.loadLabel(mPm));
-                    } catch (PackageManager.NameNotFoundException e) {
-                    }
-                }
-                final int N = pnames.size();
-                if (N > 0) {
-                    final Resources res = getActivity().getResources();
-                    String appListStr;
-                    if (N == 1) {
-                        appListStr = pnames.get(0).toString();
-                    } else if (N == 2) {
-                        appListStr = res.getString(R.string.join_two_items, pnames.get(0),
-                                pnames.get(1));
-                    } else {
-                        appListStr = pnames.get(N-2).toString();
-                        for (int i=N-3; i>=0; i--) {
-                            appListStr = res.getString(i == 0 ? R.string.join_many_items_first
-                                    : R.string.join_many_items_middle, pnames.get(i), appListStr);
-                        }
-                        appListStr = res.getString(R.string.join_many_items_last,
-                                appListStr, pnames.get(N-1));
-                    }
-                    TextView descr = (TextView) mRootView.findViewById(
-                            R.id.security_settings_desc);
-                    descr.setText(res.getString(R.string.security_settings_desc_multi,
-                            mPackageInfo.applicationInfo.loadLabel(mPm), appListStr));
-                }
-            }
-        }
-        
         checkForceStop();
         setAppLabelAndIcon(mPackageInfo);
-        refreshButtons();
-        refreshSizeInfo();
+        initUninstallButtons();
+
+        // Update the preference summaries.
+        Activity context = getActivity();
+        mStoragePreference.setSummary(AppStorageSettings.getSummary(mAppEntry, context));
+        mPermissionsPreference.setSummary(AppPermissionSettings.getSummary(mAppEntry, context));
+        mLaunchPreference.setSummary(AppLaunchSettings.getSummary(mAppEntry, mUsbManager,
+                mPm, context));
+        mNotificationPreference.setSummary(getNotificationSummary(mAppEntry, context,
+                mBackend));
 
         if (!mInitialized) {
             // First time init: are we displaying an uninstalled app?
@@ -899,7 +393,7 @@
             // All other times: if the app no longer exists then we want
             // to go away.
             try {
-                ApplicationInfo ainfo = getActivity().getPackageManager().getApplicationInfo(
+                ApplicationInfo ainfo = context.getPackageManager().getApplicationInfo(
                         mAppEntry.info.packageName, PackageManager.GET_UNINSTALLED_PACKAGES
                         | PackageManager.GET_DISABLED_COMPONENTS);
                 if (!mShowUninstalled) {
@@ -916,344 +410,63 @@
         return true;
     }
 
-    private static class PremiumSmsSelectionListener implements AdapterView.OnItemSelectedListener {
-        private final String mPackageName;
-        private final ISms mSmsManager;
-
-        PremiumSmsSelectionListener(String packageName, ISms smsManager) {
-            mPackageName = packageName;
-            mSmsManager = smsManager;
+    @Override
+    protected AlertDialog createDialog(int id, int errorCode) {
+        switch (id) {
+            case DLG_DISABLE:
+                return new AlertDialog.Builder(getActivity())
+                        .setTitle(getActivity().getText(R.string.app_disable_dlg_title))
+                        .setMessage(getActivity().getText(R.string.app_disable_dlg_text))
+                        .setPositiveButton(R.string.dlg_ok, new DialogInterface.OnClickListener() {
+                            public void onClick(DialogInterface dialog, int which) {
+                                // Disable the app
+                                new DisableChanger(InstalledAppDetails.this, mAppEntry.info,
+                                        PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER)
+                                .execute((Object)null);
+                            }
+                        })
+                        .setNegativeButton(R.string.dlg_cancel, null)
+                        .create();
+            case DLG_SPECIAL_DISABLE:
+                return new AlertDialog.Builder(getActivity())
+                        .setTitle(getActivity().getText(R.string.app_special_disable_dlg_title))
+                        .setMessage(getActivity().getText(R.string.app_special_disable_dlg_text))
+                        .setPositiveButton(R.string.dlg_ok, new DialogInterface.OnClickListener() {
+                            public void onClick(DialogInterface dialog, int which) {
+                                // Clear user data here
+                                uninstallPkg(mAppEntry.info.packageName,
+                                        false, true);
+                            }
+                        })
+                        .setNegativeButton(R.string.dlg_cancel, null)
+                        .create();
+            case DLG_FORCE_STOP:
+                return new AlertDialog.Builder(getActivity())
+                        .setTitle(getActivity().getText(R.string.force_stop_dlg_title))
+                        .setMessage(getActivity().getText(R.string.force_stop_dlg_text))
+                        .setPositiveButton(R.string.dlg_ok, new DialogInterface.OnClickListener() {
+                            public void onClick(DialogInterface dialog, int which) {
+                                // Force stop
+                                forceStopPackage(mAppEntry.info.packageName);
+                            }
+                        })
+                        .setNegativeButton(R.string.dlg_cancel, null)
+                        .create();
+            case DLG_FACTORY_RESET:
+                return new AlertDialog.Builder(getActivity())
+                        .setTitle(getActivity().getText(R.string.app_factory_reset_dlg_title))
+                        .setMessage(getActivity().getText(R.string.app_factory_reset_dlg_text))
+                        .setPositiveButton(R.string.dlg_ok, new DialogInterface.OnClickListener() {
+                            public void onClick(DialogInterface dialog, int which) {
+                                // Clear user data here
+                                uninstallPkg(mAppEntry.info.packageName,
+                                        false, false);
+                            }
+                        })
+                        .setNegativeButton(R.string.dlg_cancel, null)
+                        .create();
         }
-
-        @Override
-        public void onItemSelected(AdapterView<?> parent, View view, int position,
-                long id) {
-            if (position >= 0 && position < 3) {
-                Log.d(TAG, "Selected premium SMS policy " + position);
-                setPremiumSmsPermission(mPackageName, (position + 1));
-            } else {
-                Log.e(TAG, "Error: unknown premium SMS policy " + position);
-            }
-        }
-
-        @Override
-        public void onNothingSelected(AdapterView<?> parent) {
-            // Ignored
-        }
-
-        private void setPremiumSmsPermission(String packageName, int permission) {
-            try {
-                if (mSmsManager != null) {
-                    mSmsManager.setPremiumSmsPermission(packageName, permission);
-                }
-            } catch (RemoteException ex) {
-                // ignored
-            }
-        }
-    }
-    
-    private void resetLaunchDefaultsUi(TextView title, TextView autoLaunchView) {
-        title.setText(R.string.auto_launch_label);
-        autoLaunchView.setText(R.string.auto_launch_disable_text);
-        // Disable clear activities button
-        mActivitiesButton.setEnabled(false);
-    }
-
-    private void setIntentAndFinish(boolean finish, boolean appChanged) {
-        if(localLOGV) Log.i(TAG, "appChanged="+appChanged);
-        Intent intent = new Intent();
-        intent.putExtra(ManageApplications.APP_CHG, appChanged);
-        SettingsActivity sa = (SettingsActivity)getActivity();
-        sa.finishPreferencePanel(this, Activity.RESULT_OK, intent);
-    }
-    
-    private void refreshSizeInfo() {
-        if (mAppEntry.size == ApplicationsState.SIZE_INVALID
-                || mAppEntry.size == ApplicationsState.SIZE_UNKNOWN) {
-            mLastCodeSize = mLastDataSize = mLastCacheSize = mLastTotalSize = -1;
-            if (!mHaveSizes) {
-                mAppSize.setText(mComputingStr);
-                mDataSize.setText(mComputingStr);
-                mCacheSize.setText(mComputingStr);
-                mTotalSize.setText(mComputingStr);
-            }
-            mClearDataButton.setEnabled(false);
-            mClearCacheButton.setEnabled(false);
-            
-        } else {
-            mHaveSizes = true;
-            long codeSize = mAppEntry.codeSize;
-            long dataSize = mAppEntry.dataSize;
-            if (Environment.isExternalStorageEmulated()) {
-                codeSize += mAppEntry.externalCodeSize;
-                dataSize +=  mAppEntry.externalDataSize;
-            } else {
-                if (mLastExternalCodeSize != mAppEntry.externalCodeSize) {
-                    mLastExternalCodeSize = mAppEntry.externalCodeSize;
-                    mExternalCodeSize.setText(getSizeStr(mAppEntry.externalCodeSize));
-                }
-                if (mLastExternalDataSize !=  mAppEntry.externalDataSize) {
-                    mLastExternalDataSize =  mAppEntry.externalDataSize;
-                    mExternalDataSize.setText(getSizeStr( mAppEntry.externalDataSize));
-                }
-            }
-            if (mLastCodeSize != codeSize) {
-                mLastCodeSize = codeSize;
-                mAppSize.setText(getSizeStr(codeSize));
-            }
-            if (mLastDataSize != dataSize) {
-                mLastDataSize = dataSize;
-                mDataSize.setText(getSizeStr(dataSize));
-            }
-            long cacheSize = mAppEntry.cacheSize + mAppEntry.externalCacheSize;
-            if (mLastCacheSize != cacheSize) {
-                mLastCacheSize = cacheSize;
-                mCacheSize.setText(getSizeStr(cacheSize));
-            }
-            if (mLastTotalSize != mAppEntry.size) {
-                mLastTotalSize = mAppEntry.size;
-                mTotalSize.setText(getSizeStr(mAppEntry.size));
-            }
-            
-            if ((mAppEntry.dataSize+ mAppEntry.externalDataSize) <= 0 || !mCanClearData) {
-                mClearDataButton.setEnabled(false);
-            } else {
-                mClearDataButton.setEnabled(true);
-                mClearDataButton.setOnClickListener(this);
-            }
-            if (cacheSize <= 0) {
-                mClearCacheButton.setEnabled(false);
-            } else {
-                mClearCacheButton.setEnabled(true);
-                mClearCacheButton.setOnClickListener(this);
-            }
-        }
-        if (mAppControlRestricted) {
-            mClearCacheButton.setEnabled(false);
-            mClearDataButton.setEnabled(false);
-        }
-    }
-    
-    /*
-     * Private method to handle clear message notification from observer when
-     * the async operation from PackageManager is complete
-     */
-    private void processClearMsg(Message msg) {
-        int result = msg.arg1;
-        String packageName = mAppEntry.info.packageName;
-        mClearDataButton.setText(R.string.clear_user_data_text);
-        if(result == OP_SUCCESSFUL) {
-            Log.i(TAG, "Cleared user data for package : "+packageName);
-            mState.requestSize(mAppEntry.info.packageName);
-        } else {
-            mClearDataButton.setEnabled(true);
-        }
-        checkForceStop();
-    }
-
-    private void refreshButtons() {
-        if (!mMoveInProgress) {
-            initUninstallButtons();
-            initDataButtons();
-            initMoveButton();
-            initNotificationButton();
-        } else {
-            mMoveAppButton.setText(R.string.moving);
-            mMoveAppButton.setEnabled(false);
-            mUninstallButton.setEnabled(false);
-            mSpecialDisableButton.setEnabled(false);
-        }
-    }
-
-    private void processMoveMsg(Message msg) {
-        int result = msg.arg1;
-        String packageName = mAppEntry.info.packageName;
-        // Refresh the button attributes.
-        mMoveInProgress = false;
-        if (result == PackageManager.MOVE_SUCCEEDED) {
-            Log.i(TAG, "Moved resources for " + packageName);
-            // Refresh size information again.
-            mState.requestSize(mAppEntry.info.packageName);
-        } else {
-            showDialogInner(DLG_MOVE_FAILED, result);
-        }
-        refreshUi();
-    }
-
-    /*
-     * Private method to initiate clearing user data when the user clicks the clear data 
-     * button for a system package
-     */
-    private  void initiateClearUserData() {
-        mClearDataButton.setEnabled(false);
-        // Invoke uninstall or clear user data based on sysPackage
-        String packageName = mAppEntry.info.packageName;
-        Log.i(TAG, "Clearing user data for package : " + packageName);
-        if (mClearDataObserver == null) {
-            mClearDataObserver = new ClearUserDataObserver();
-        }
-        ActivityManager am = (ActivityManager)
-                getActivity().getSystemService(Context.ACTIVITY_SERVICE);
-        boolean res = am.clearApplicationUserData(packageName, mClearDataObserver);
-        if (!res) {
-            // Clearing data failed for some obscure reason. Just log error for now
-            Log.i(TAG, "Couldnt clear application user data for package:"+packageName);
-            showDialogInner(DLG_CANNOT_CLEAR_DATA, 0);
-        } else {
-            mClearDataButton.setText(R.string.recompute_size);
-        }
-    }
-    
-    private void showDialogInner(int id, int moveErrorCode) {
-        DialogFragment newFragment = MyAlertDialogFragment.newInstance(id, moveErrorCode);
-        newFragment.setTargetFragment(this, 0);
-        newFragment.show(getFragmentManager(), "dialog " + id);
-    }
-    
-    public static class MyAlertDialogFragment extends DialogFragment {
-
-        public static MyAlertDialogFragment newInstance(int id, int moveErrorCode) {
-            MyAlertDialogFragment frag = new MyAlertDialogFragment();
-            Bundle args = new Bundle();
-            args.putInt("id", id);
-            args.putInt("moveError", moveErrorCode);
-            frag.setArguments(args);
-            return frag;
-        }
-
-        InstalledAppDetails getOwner() {
-            return (InstalledAppDetails)getTargetFragment();
-        }
-
-        @Override
-        public Dialog onCreateDialog(Bundle savedInstanceState) {
-            int id = getArguments().getInt("id");
-            int moveErrorCode = getArguments().getInt("moveError");
-            switch (id) {
-                case DLG_CLEAR_DATA:
-                    return new AlertDialog.Builder(getActivity())
-                    .setTitle(getActivity().getText(R.string.clear_data_dlg_title))
-                    .setMessage(getActivity().getText(R.string.clear_data_dlg_text))
-                    .setPositiveButton(R.string.dlg_ok,
-                            new DialogInterface.OnClickListener() {
-                        public void onClick(DialogInterface dialog, int which) {
-                            // Clear user data here
-                            getOwner().initiateClearUserData();
-                        }
-                    })
-                    .setNegativeButton(R.string.dlg_cancel, null)
-                    .create();
-                case DLG_FACTORY_RESET:
-                    return new AlertDialog.Builder(getActivity())
-                    .setTitle(getActivity().getText(R.string.app_factory_reset_dlg_title))
-                    .setMessage(getActivity().getText(R.string.app_factory_reset_dlg_text))
-                    .setPositiveButton(R.string.dlg_ok,
-                            new DialogInterface.OnClickListener() {
-                        public void onClick(DialogInterface dialog, int which) {
-                            // Clear user data here
-                            getOwner().uninstallPkg(getOwner().mAppEntry.info.packageName,
-                                    false, false);
-                        }
-                    })
-                    .setNegativeButton(R.string.dlg_cancel, null)
-                    .create();
-                case DLG_APP_NOT_FOUND:
-                    return new AlertDialog.Builder(getActivity())
-                    .setTitle(getActivity().getText(R.string.app_not_found_dlg_title))
-                    .setMessage(getActivity().getText(R.string.app_not_found_dlg_title))
-                    .setNeutralButton(getActivity().getText(R.string.dlg_ok),
-                            new DialogInterface.OnClickListener() {
-                        public void onClick(DialogInterface dialog, int which) {
-                            //force to recompute changed value
-                            getOwner().setIntentAndFinish(true, true);
-                        }
-                    })
-                    .create();
-                case DLG_CANNOT_CLEAR_DATA:
-                    return new AlertDialog.Builder(getActivity())
-                    .setTitle(getActivity().getText(R.string.clear_failed_dlg_title))
-                    .setMessage(getActivity().getText(R.string.clear_failed_dlg_text))
-                    .setNeutralButton(R.string.dlg_ok,
-                            new DialogInterface.OnClickListener() {
-                        public void onClick(DialogInterface dialog, int which) {
-                            getOwner().mClearDataButton.setEnabled(false);
-                            //force to recompute changed value
-                            getOwner().setIntentAndFinish(false, false);
-                        }
-                    })
-                    .create();
-                case DLG_FORCE_STOP:
-                    return new AlertDialog.Builder(getActivity())
-                    .setTitle(getActivity().getText(R.string.force_stop_dlg_title))
-                    .setMessage(getActivity().getText(R.string.force_stop_dlg_text))
-                    .setPositiveButton(R.string.dlg_ok,
-                        new DialogInterface.OnClickListener() {
-                        public void onClick(DialogInterface dialog, int which) {
-                            // Force stop
-                            getOwner().forceStopPackage(getOwner().mAppEntry.info.packageName);
-                        }
-                    })
-                    .setNegativeButton(R.string.dlg_cancel, null)
-                    .create();
-                case DLG_MOVE_FAILED:
-                    CharSequence msg = getActivity().getString(R.string.move_app_failed_dlg_text,
-                            getOwner().getMoveErrMsg(moveErrorCode));
-                    return new AlertDialog.Builder(getActivity())
-                    .setTitle(getActivity().getText(R.string.move_app_failed_dlg_title))
-                    .setMessage(msg)
-                    .setNeutralButton(R.string.dlg_ok, null)
-                    .create();
-                case DLG_DISABLE:
-                    return new AlertDialog.Builder(getActivity())
-                    .setTitle(getActivity().getText(R.string.app_disable_dlg_title))
-                    .setMessage(getActivity().getText(R.string.app_disable_dlg_text))
-                    .setPositiveButton(R.string.dlg_ok,
-                        new DialogInterface.OnClickListener() {
-                        public void onClick(DialogInterface dialog, int which) {
-                            // Disable the app
-                            new DisableChanger(getOwner(), getOwner().mAppEntry.info,
-                                    PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER)
-                            .execute((Object)null);
-                        }
-                    })
-                    .setNegativeButton(R.string.dlg_cancel, null)
-                    .create();
-                case DLG_DISABLE_NOTIFICATIONS:
-                    return new AlertDialog.Builder(getActivity())
-                    .setTitle(getActivity().getText(R.string.app_disable_notifications_dlg_title))
-                    .setMessage(getActivity().getText(R.string.app_disable_notifications_dlg_text))
-                    .setPositiveButton(R.string.dlg_ok,
-                        new DialogInterface.OnClickListener() {
-                        public void onClick(DialogInterface dialog, int which) {
-                            // Disable the package's notifications
-                            getOwner().setNotificationsEnabled(false);
-                        }
-                    })
-                    .setNegativeButton(R.string.dlg_cancel,
-                        new DialogInterface.OnClickListener() {
-                        public void onClick(DialogInterface dialog, int which) {
-                            // Re-enable the checkbox
-                            getOwner().mNotificationSwitch.setChecked(true);
-                        }
-                    })
-                    .create();
-                case DLG_SPECIAL_DISABLE:
-                    return new AlertDialog.Builder(getActivity())
-                    .setTitle(getActivity().getText(R.string.app_special_disable_dlg_title))
-                    .setMessage(getActivity().getText(R.string.app_special_disable_dlg_text))
-                    .setPositiveButton(R.string.dlg_ok,
-                            new DialogInterface.OnClickListener() {
-                        public void onClick(DialogInterface dialog, int which) {
-                            // Clear user data here
-                            getOwner().uninstallPkg(getOwner().mAppEntry.info.packageName,
-                                    false, true);
-                        }
-                    })
-                    .setNegativeButton(R.string.dlg_cancel, null)
-                    .create();
-            }
-            throw new IllegalArgumentException("unknown id " + id);
-        }
+        return null;
     }
 
     private void uninstallPkg(String packageName, boolean allUsers, boolean andDisable) {
@@ -1277,13 +490,6 @@
         checkForceStop();
     }
 
-    private final BroadcastReceiver mCheckKillProcessesReceiver = new BroadcastReceiver() {
-        @Override
-        public void onReceive(Context context, Intent intent) {
-            updateForceStopButton(getResultCode() != Activity.RESULT_CANCELED);
-        }
-    };
-
     private void updateForceStopButton(boolean enabled) {
         if (mAppControlRestricted) {
             mForceStopButton.setEnabled(false);
@@ -1292,7 +498,7 @@
             mForceStopButton.setOnClickListener(InstalledAppDetails.this);
         }
     }
-    
+
     private void checkForceStop() {
         if (mDpm.packageHasActiveAdmins(mPackageInfo.packageName)) {
             // User can't force stop device admin.
@@ -1312,47 +518,21 @@
         }
     }
 
-    static class DisableChanger extends AsyncTask<Object, Object, Object> {
-        final PackageManager mPm;
-        final WeakReference<InstalledAppDetails> mActivity;
-        final ApplicationInfo mInfo;
-        final int mState;
+    private void startAppInfoFragment(Class<? extends AppInfoBase> fragment, CharSequence title) {
+        // start new fragment to display extended information
+        Bundle args = new Bundle();
+        args.putString(InstalledAppDetails.ARG_PACKAGE_NAME, mAppEntry.info.packageName);
 
-        DisableChanger(InstalledAppDetails activity, ApplicationInfo info, int state) {
-            mPm = activity.mPm;
-            mActivity = new WeakReference<InstalledAppDetails>(activity);
-            mInfo = info;
-            mState = state;
-        }
-
-        @Override
-        protected Object doInBackground(Object... params) {
-            mPm.setApplicationEnabledSetting(mInfo.packageName, mState, 0);
-            return null;
-        }
+        SettingsActivity sa = (SettingsActivity) getActivity();
+        sa.startPreferencePanel(fragment.getName(), args, -1, title, this, SUB_INFO_FRAGMENT);
     }
 
-    private void setNotificationsEnabled(boolean enabled) {
-        String packageName = mAppEntry.info.packageName;
-        INotificationManager nm = INotificationManager.Stub.asInterface(
-                ServiceManager.getService(Context.NOTIFICATION_SERVICE));
-        try {
-            final boolean enable = mNotificationSwitch.isChecked();
-            nm.setNotificationsEnabledForPackage(packageName, mAppEntry.info.uid, enabled);
-        } catch (android.os.RemoteException ex) {
-            mNotificationSwitch.setChecked(!enabled); // revert
-        }
-    }
-
-    private int getPremiumSmsPermission(String packageName) {
-        try {
-            if (mSmsManager != null) {
-                return mSmsManager.getPremiumSmsPermission(packageName);
-            }
-        } catch (RemoteException ex) {
-            // ignored
-        }
-        return SmsUsageMonitor.PREMIUM_SMS_PERMISSION_UNKNOWN;
+    private void startNotifications() {
+        // start new fragment to display extended information
+        getActivity().startActivity(new Intent(Settings.ACTION_APP_NOTIFICATION_SETTINGS)
+                .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
+                .putExtra(Settings.EXTRA_APP_PACKAGE, mAppEntry.info.packageName)
+                .putExtra(Settings.EXTRA_APP_UID, mAppEntry.info.uid));
     }
 
     /*
@@ -1381,69 +561,77 @@
             }
         } else if(v == mSpecialDisableButton) {
             showDialogInner(DLG_SPECIAL_DISABLE, 0);
-        } else if(v == mActivitiesButton) {
-            if (mUsbManager != null) {
-                mPm.clearPackagePreferredActivities(packageName);
-                try {
-                    mUsbManager.clearDefaults(packageName, UserHandle.myUserId());
-                } catch (RemoteException e) {
-                    Log.e(TAG, "mUsbManager.clearDefaults", e);
-                }
-                mAppWidgetManager.setBindAppWidgetPermission(packageName, false);
-                TextView autoLaunchTitleView =
-                        (TextView) mRootView.findViewById(R.id.auto_launch_title);
-                TextView autoLaunchView = (TextView) mRootView.findViewById(R.id.auto_launch);
-                resetLaunchDefaultsUi(autoLaunchTitleView, autoLaunchView);
-            }
-        } else if(v == mClearDataButton) {
-            if (mAppEntry.info.manageSpaceActivityName != null) {
-                if (!Utils.isMonkeyRunning()) {
-                    Intent intent = new Intent(Intent.ACTION_DEFAULT);
-                    intent.setClassName(mAppEntry.info.packageName,
-                            mAppEntry.info.manageSpaceActivityName);
-                    startActivityForResult(intent, REQUEST_MANAGE_SPACE);
-                }
-            } else {
-                showDialogInner(DLG_CLEAR_DATA, 0);
-            }
-        } else if (v == mClearCacheButton) {
-            // Lazy initialization of observer
-            if (mClearCacheObserver == null) {
-                mClearCacheObserver = new ClearCacheObserver();
-            }
-            mPm.deleteApplicationCacheFiles(packageName, mClearCacheObserver);
         } else if (v == mForceStopButton) {
             showDialogInner(DLG_FORCE_STOP, 0);
             //forceStopPackage(mAppInfo.packageName);
-        } else if (v == mMoveAppButton) {
-            if (mPackageMoveObserver == null) {
-                mPackageMoveObserver = new PackageMoveObserver();
-            }
-            int moveFlags = (mAppEntry.info.flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0 ?
-                    PackageManager.MOVE_INTERNAL : PackageManager.MOVE_EXTERNAL_MEDIA;
-            mMoveInProgress = true;
-            refreshButtons();
-            mPm.movePackage(mAppEntry.info.packageName, mPackageMoveObserver, moveFlags);
         }
     }
 
     @Override
-    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
-        String packageName = mAppEntry.info.packageName;
-        ActivityManager am = (ActivityManager)
-                getActivity().getSystemService(Context.ACTIVITY_SERVICE);
-        if (buttonView == mAskCompatibilityCB) {
-            am.setPackageAskScreenCompat(packageName, isChecked);
-        } else if (buttonView == mEnableCompatibilityCB) {
-            am.setPackageScreenCompatMode(packageName, isChecked ?
-                    ActivityManager.COMPAT_MODE_ENABLED : ActivityManager.COMPAT_MODE_DISABLED);
-        } else if (buttonView == mNotificationSwitch) {
-            if (!isChecked) {
-                showDialogInner(DLG_DISABLE_NOTIFICATIONS, 0);
-            } else {
-                setNotificationsEnabled(true);
+    public boolean onPreferenceClick(Preference preference) {
+        if (preference == mStoragePreference) {
+            startAppInfoFragment(AppStorageSettings.class, mStoragePreference.getTitle());
+        } else if (preference == mNotificationPreference) {
+            startNotifications();
+        } else if (preference == mPermissionsPreference) {
+            startAppInfoFragment(AppPermissionSettings.class, mPermissionsPreference.getTitle());
+        } else if (preference == mLaunchPreference) {
+            startAppInfoFragment(AppLaunchSettings.class, mLaunchPreference.getTitle());
+        } else if (preference == mDataPreference) {
+            // Not yet.
+        } else {
+            return false;
+        }
+        return true;
+    }
+
+    public static CharSequence getNotificationSummary(AppEntry appEntry, Context context) {
+        return getNotificationSummary(appEntry, context, new Backend());
+    }
+
+    public static CharSequence getNotificationSummary(AppEntry appEntry, Context context,
+            Backend backend) {
+        AppRow appRow = NotificationAppList.loadAppRow(context.getPackageManager(), appEntry.info,
+                backend);
+        if (appRow.banned) {
+            return context.getString(R.string.notifications_disabled);
+        } else if (appRow.priority) {
+            if (appRow.sensitive) {
+                return context.getString(R.string.notifications_priority_sensitive);
             }
+            return context.getString(R.string.notifications_priority);
+        } else if (appRow.sensitive) {
+            return context.getString(R.string.notifications_sensitive);
+        }
+        return context.getString(R.string.notifications_enabled);
+    }
+
+    static class DisableChanger extends AsyncTask<Object, Object, Object> {
+        final PackageManager mPm;
+        final WeakReference<InstalledAppDetails> mActivity;
+        final ApplicationInfo mInfo;
+        final int mState;
+
+        DisableChanger(InstalledAppDetails activity, ApplicationInfo info, int state) {
+            mPm = activity.mPm;
+            mActivity = new WeakReference<InstalledAppDetails>(activity);
+            mInfo = info;
+            mState = state;
+        }
+
+        @Override
+        protected Object doInBackground(Object... params) {
+            mPm.setApplicationEnabledSetting(mInfo.packageName, mState, 0);
+            return null;
         }
     }
+
+    private final BroadcastReceiver mCheckKillProcessesReceiver = new BroadcastReceiver() {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            updateForceStopButton(getResultCode() != Activity.RESULT_CANCELED);
+        }
+    };
 }
 
+
diff --git a/src/com/android/settings/notification/AppNotificationSettings.java b/src/com/android/settings/notification/AppNotificationSettings.java
index 0eeefa9..67a8074 100644
--- a/src/com/android/settings/notification/AppNotificationSettings.java
+++ b/src/com/android/settings/notification/AppNotificationSettings.java
@@ -37,6 +37,7 @@
 import android.widget.Toast;
 
 import com.android.internal.widget.LockPatternUtils;
+import com.android.settings.AppHeader;
 import com.android.settings.R;
 import com.android.settings.SettingsPreferenceFragment;
 import com.android.settings.Utils;
@@ -74,30 +75,8 @@
         }
         mCreated = true;
         if (mAppRow == null) return;
-        final View content = getActivity().findViewById(R.id.main_content);
-        final ViewGroup contentParent = (ViewGroup) content.getParent();
-        final View bar = getActivity().getLayoutInflater().inflate(R.layout.app_notification_header,
-                contentParent, false);
-
-        final ImageView appIcon = (ImageView) bar.findViewById(R.id.app_icon);
-        appIcon.setImageDrawable(mAppRow.icon);
-
-        final TextView appName = (TextView) bar.findViewById(R.id.app_name);
-        appName.setText(mAppRow.label);
-
-        final View appSettings = bar.findViewById(R.id.app_settings);
-        if (mAppRow.settingsIntent == null) {
-            appSettings.setVisibility(View.GONE);
-        } else {
-            appSettings.setClickable(true);
-            appSettings.setOnClickListener(new OnClickListener() {
-                @Override
-                public void onClick(View v) {
-                    mContext.startActivity(mAppRow.settingsIntent);
-                }
-            });
-        }
-        contentParent.addView(bar, 0);
+        AppHeader.createAppHeader(getActivity(), mAppRow.icon, mAppRow.label,
+                mAppRow.settingsIntent);
     }
 
     @Override