Merge "Hide "Phone number" from About page if not call enabled."
diff --git a/Android.mk b/Android.mk
index b9121ec..df85bbc 100644
--- a/Android.mk
+++ b/Android.mk
@@ -37,8 +37,8 @@
     ims-common
 
 LOCAL_STATIC_JAVA_LIBRARIES := \
-    apptoolkit-arch-core-runtime \
-    apptoolkit-lifecycle-extensions \
+    android-arch-lifecycle-runtime \
+    android-arch-lifecycle-extensions \
     jsr305 \
     settings-logtags \
 
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 2e51108..c526d6f 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -146,7 +146,7 @@
                 android:parentActivityName="Settings">
         </activity>
 
-        <activity android:name="CreateShortcut"
+        <activity android:name=".shortcut.CreateShortcut"
                   android:label="@string/settings_shortcut">
             <intent-filter>
                 <action android:name="android.intent.action.CREATE_SHORTCUT"/>
@@ -1013,6 +1013,7 @@
                   android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.DEVICE_INFO_SETTINGS" />
+                <action android:name="android.settings.DEVICE_NAME" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
             <intent-filter>
@@ -1279,7 +1280,7 @@
                 android:value="true" />
         </activity>
 
-        <activity android:name="Settings$SecuritySettingsActivity"
+        <activity android:name=".Settings$SecurityDashboardActivity"
                 android:label="@string/security_settings_title"
                 android:icon="@drawable/ic_homepage_security"
                 android:configChanges="orientation|keyboardHidden|screenSize"
@@ -1306,28 +1307,6 @@
                 android:value="true" />
         </activity>
 
-        <!-- TODO(32953042) Merge with Settings$SecuritySettingsActivity -->
-        <activity android:name="Settings$SecuritySettingsActivityV2"
-                  android:label="@string/security_settings_title"
-                  android:icon="@drawable/ic_homepage_security"
-                  android:enabled="false"
-                  android:configChanges="orientation|keyboardHidden|screenSize"
-                  android:taskAffinity=""
-                  android:parentActivityName="Settings">
-            <intent-filter android:priority="-1">
-                <action android:name="android.settings.SECURITY_SETTINGS" />
-                <action android:name="android.credentials.UNLOCK" />
-                <category android:name="android.intent.category.DEFAULT" />
-            </intent-filter>
-            <intent-filter android:priority="4">
-                <action android:name="com.android.settings.action.SETTINGS" />
-            </intent-filter>
-            <meta-data android:name="com.android.settings.category"
-                       android:value="com.android.settings.category.ia.homepage" />
-            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
-                       android:value="com.android.settings.security.SecuritySettingsV2" />
-        </activity>
-
         <activity android:name="MonitoringCertInfoActivity"
                 android:label=""
                 android:theme="@style/Transparent"
@@ -1358,16 +1337,6 @@
                 android:value="true" />
         </activity>
 
-        <!-- Keep compatibility with old shortcuts. -->
-        <activity-alias android:name="SecuritySettings"
-                android:label="@string/security_settings_title"
-                android:configChanges="orientation|keyboardHidden|screenSize"
-                android:exported="true"
-                android:targetActivity="Settings$SecuritySettingsActivity">
-            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
-                android:value="com.android.settings.security.SecuritySettings" />
-        </activity-alias>
-
         <activity android:name="Settings$PrivacySettingsActivity"
                 android:label="@string/privacy_settings_title"
                 android:icon="@drawable/ic_settings_backup"
@@ -1405,7 +1374,7 @@
         <activity android:name="Settings$DeviceAdminSettingsActivity"
                 android:label="@string/device_admin_settings_title"
                 android:taskAffinity="com.android.settings"
-                android:parentActivityName="Settings$SecuritySettingsActivity">
+                android:parentActivityName=".Settings$SecurityDashboardActivity">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -1436,7 +1405,7 @@
         <activity android:name="Settings$UsageAccessSettingsActivity"
                 android:label="@string/usage_access_title"
                 android:taskAffinity="com.android.settings"
-                android:parentActivityName="Settings$SecuritySettingsActivity">
+                android:parentActivityName=".Settings$SecurityDashboardActivity">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.USAGE_ACCESS_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -1574,7 +1543,7 @@
         <activity android:name="Settings$EnterprisePrivacySettingsActivity"
                 android:label="@string/enterprise_privacy_settings"
                 android:taskAffinity="com.android.settings"
-                android:parentActivityName="Settings$SecuritySettingsActivity">
+                android:parentActivityName=".Settings$SecurityDashboardActivity">
             <intent-filter>
                 <action android:name="android.settings.ENTERPRISE_PRIVACY_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -2044,13 +2013,21 @@
             </intent-filter>
         </activity>
 
-        <activity android:name=".deviceinfo.UsbModeChooserActivity"
+        <activity android:name=".connecteddevice.usb.UsbModeChooserActivity"
                   android:excludeFromRecents="true"
                   android:exported="true"
                   android:permission="android.permission.MANAGE_USB"
                   android:theme="@*android:style/Theme.DeviceDefault.Settings.Dialog.NoActionBar">
         </activity>
 
+        <activity android:name=".Settings$UsbDetailsActivity"
+                  android:excludeFromRecents="true"
+                  android:permission="android.permission.MANAGE_USB"
+                  android:exported="true">
+            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
+                android:value="com.android.settings.connecteddevice.usb.UsbDetailsFragment"/>
+        </activity>
+
         <activity android:name=".RemoteBugreportActivity"
                   android:excludeFromRecents="true"
                   android:exported="true"
@@ -2677,19 +2654,6 @@
                 android:value="com.android.settings.notification.SoundSettings" />
         </activity-alias>
 
-        <!-- Show apps for which application-level notification settings are applicable -->
-        <activity android:name="Settings$NotificationAppListActivity"
-                android:label="@string/app_notifications_title"
-                android:icon="@drawable/ic_notifications"
-                android:exported="true"
-                android:taskAffinity="">
-            <intent-filter android:priority="150">
-                <action android:name="com.android.settings.action.SETTINGS" />
-            </intent-filter>
-            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
-                android:value="com.android.settings.applications.NotificationApps" />
-        </activity>
-
         <!-- Show application-level notification settings (app passed in as extras) -->
         <activity android:name="Settings$AppNotificationSettingsActivity"
                 android:exported="true">
@@ -3234,16 +3198,11 @@
         <activity android:name="Settings$AdvancedConnectedDeviceActivity"
                   android:label="@string/connected_device_connections_title"
                   android:taskAffinity="com.android.settings"
-                  android:parentActivityName="Settings$ConnectedDeviceDashboardActivity"
-                  android:enabled="false">
+                  android:parentActivityName="Settings$ConnectedDeviceDashboardActivity">
             <intent-filter android:priority="1">
                 <action android:name="com.android.settings.ADVANCED_CONNECTED_DEVICE_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.DEFAULT" />
-            </intent-filter>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                        android:value="com.android.settings.connecteddevice.AdvancedConnectedDeviceDashboardFragment" />
             <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
diff --git a/res/layout/suggestion_condition_footer.xml b/res/layout/condition_footer.xml
similarity index 100%
rename from res/layout/suggestion_condition_footer.xml
rename to res/layout/condition_footer.xml
diff --git a/res/layout/suggestion_condition_header.xml b/res/layout/condition_header.xml
similarity index 100%
rename from res/layout/suggestion_condition_header.xml
rename to res/layout/condition_header.xml
diff --git a/res/layout/search_icon_view.xml b/res/layout/search_icon_view.xml
index ef99bee..aa0bf02 100644
--- a/res/layout/search_icon_view.xml
+++ b/res/layout/search_icon_view.xml
@@ -18,7 +18,7 @@
 <ImageView
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@android:id/icon"
-    android:layout_width="@dimen/dashboard_tile_image_size"
+    android:layout_width="@dimen/dashboard_tile_foreground_image_size"
     android:layout_height="match_parent"
     android:scaleType="centerInside"
     android:layout_marginStart="@dimen/dashboard_tile_image_margin"
diff --git a/res/layout/search_saved_query_item.xml b/res/layout/search_saved_query_item.xml
deleted file mode 100644
index f8c239a..0000000
--- a/res/layout/search_saved_query_item.xml
+++ /dev/null
@@ -1,44 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-  Copyright (C) 2017 The Android Open Source Project
-
-  Licensed under the Apache License, Version 2.0 (the "License");
-  you may not use this file except in compliance with the License.
-  You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-  Unless required by applicable law or agreed to in writing, software
-  distributed under the License is distributed on an "AS IS" BASIS,
-  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  See the License for the specific language governing permissions and
-  limitations under the License.
-  -->
-
-<LinearLayout
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    android:orientation="horizontal"
-    android:layout_width="match_parent"
-    android:layout_height="wrap_content"
-    android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
-    android:background="?android:attr/selectableItemBackground"
-    android:minHeight="?android:attr/listPreferredItemHeight"
-    android:gravity="center_vertical">
-
-    <ImageView
-        android:id="@android:id/icon"
-        android:layout_width="@dimen/dashboard_tile_image_size"
-        android:layout_height="@dimen/dashboard_tile_image_size"
-        android:scaleType="centerInside"
-        android:layout_marginStart="@dimen/dashboard_tile_image_margin"
-        android:layout_marginEnd="@dimen/dashboard_tile_image_margin"
-        android:src="@drawable/ic_restore" />
-
-    <TextView
-        android:id="@android:id/title"
-        android:layout_height="match_parent"
-        android:layout_width="match_parent"
-        android:gravity="center_vertical"
-        android:textAppearance="?android:attr/textAppearanceListItem" />
-
-</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/suggestion_condition_container.xml b/res/layout/suggestion_condition_container.xml
deleted file mode 100644
index a4c60ad..0000000
--- a/res/layout/suggestion_condition_container.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-     Copyright (C) 2017 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.
--->
-
-<FrameLayout
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
-    style="@style/SuggestionConditionStyle"
-    android:layout_width="match_parent"
-    android:layout_height="wrap_content"
-    android:paddingStart="5dp"
-    android:paddingEnd="5dp"
-    android:paddingBottom="@dimen/dashboard_padding_bottom">
-
-    <android.support.v7.widget.CardView
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        app:cardUseCompatPadding="true"
-        app:cardElevation="2dp">
-
-        <android.support.v7.widget.RecyclerView
-            android:id="@+id/data"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:background="@color/material_grey_300"
-            android:scrollbars="none"/>
-
-    </android.support.v7.widget.CardView>
-
-</FrameLayout>
diff --git a/res/layout/suggestion_container.xml b/res/layout/suggestion_container.xml
index 9110c58..640a91f 100644
--- a/res/layout/suggestion_container.xml
+++ b/res/layout/suggestion_container.xml
@@ -55,7 +55,7 @@
         android:id="@+id/suggestion_list"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:paddingTop="18dp"
+        android:paddingTop="14dp"
         android:paddingBottom="16dp"
         android:scrollbars="none"/>
 
diff --git a/res/layout/suggestion_tile.xml b/res/layout/suggestion_tile.xml
index b947452..79f6dca 100644
--- a/res/layout/suggestion_tile.xml
+++ b/res/layout/suggestion_tile.xml
@@ -14,51 +14,69 @@
      limitations under the License.
 -->
 
-<LinearLayout
+<android.support.v7.widget.CardView
     xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="match_parent"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:id="@+id/suggestion_card"
+    android:layout_width="wrap_content"
     android:layout_height="wrap_content"
-    android:orientation="vertical">
+    app:cardPreventCornerOverlap="false"
+    app:cardUseCompatPadding="true"
+    app:cardElevation="2dp"
+    app:cardCornerRadius="@dimen/suggestion_card_corner_radius">
 
     <LinearLayout
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:background="@android:color/white"
-        android:gravity="center_vertical"
-        android:orientation="horizontal"
-        android:minHeight="@dimen/dashboard_tile_minimum_height">
+        android:minHeight="112dp"
+        android:orientation="vertical">
 
-        <ImageView
-            android:id="@android:id/icon"
-            android:layout_width="@dimen/suggestion_card_icon_size"
-            android:layout_height="@dimen/suggestion_card_icon_size"
-            android:layout_marginStart="14dp"
-            android:layout_marginEnd="24dp" />
-
-        <LinearLayout
-            android:layout_width="wrap_content"
+        <RelativeLayout
+            android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:orientation="vertical">
+            android:orientation="horizontal">
 
-            <TextView
-                android:id="@android:id/title"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:singleLine="true"
-                android:textAppearance="@style/TextAppearance.TileTitle"
-                android:ellipsize="marquee"
-                android:fadingEdge="horizontal" />
+            <ImageView
+                android:id="@android:id/icon"
+                android:layout_width="@dimen/suggestion_card_icon_size"
+                android:layout_height="@dimen/suggestion_card_icon_size"
+                style="@style/SuggestionCardIcon"
+                android:layout_marginTop="16dp"
+                android:layout_marginBottom="8dp" />
 
-            <TextView
-                android:id="@android:id/summary"
-                android:textAppearance="@style/TextAppearance.SuggestionSummary"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content" />
+            <ImageView
+                android:id="@+id/close_button"
+                android:layout_width="18dp"
+                android:layout_height="18dp"
+                android:alpha="0.54"
+                android:layout_alignParentEnd="true"
+                android:layout_marginTop="8dp"
+                android:layout_marginEnd="8dp"
+                android:src="@drawable/ic_suggestion_close_button"/>
 
-        </LinearLayout>
+        </RelativeLayout>
+
+        <TextView
+            android:id="@android:id/title"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            style="@style/SuggestionCardText"
+            android:layout_marginStart="12dp"
+            android:layout_marginEnd="12dp"
+            android:singleLine="true"
+            android:textAppearance="@style/TextAppearance.SuggestionTitleV2"
+            android:ellipsize="end"
+            android:fadingEdge="horizontal" />
+
+        <TextView
+            android:id="@android:id/summary"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            style="@style/SuggestionCardText"
+            android:layout_marginStart="12dp"
+            android:layout_marginEnd="12dp"
+            android:textAppearance="@style/TextAppearance.SuggestionSummary" />
 
     </LinearLayout>
 
-    <include layout="@layout/horizontal_divider" />
-
-</LinearLayout>
\ No newline at end of file
+</android.support.v7.widget.CardView>
diff --git a/res/layout/suggestion_tile_v2.xml b/res/layout/suggestion_tile_v2.xml
deleted file mode 100644
index e04febb..0000000
--- a/res/layout/suggestion_tile_v2.xml
+++ /dev/null
@@ -1,82 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2018 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.
--->
-
-<android.support.v7.widget.CardView
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
-    android:id="@+id/suggestion_card"
-    android:layout_width="328dp"
-    android:layout_height="wrap_content"
-    app:cardPreventCornerOverlap="false"
-    app:cardUseCompatPadding="true"
-    app:cardElevation="2dp"
-    app:cardCornerRadius="@dimen/suggestion_card_corner_radius">
-
-    <LinearLayout
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:minHeight="112dp"
-        android:orientation="vertical">
-
-        <RelativeLayout
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:orientation="horizontal">
-
-            <ImageView
-                android:id="@android:id/icon"
-                android:layout_width="@dimen/suggestion_card_icon_size"
-                android:layout_height="@dimen/suggestion_card_icon_size"
-                style="@style/SuggestionCardIcon"
-                android:layout_marginTop="16dp"
-                android:layout_marginBottom="8dp" />
-
-            <ImageView
-                android:id="@+id/close_button"
-                android:layout_width="18dp"
-                android:layout_height="18dp"
-                android:alpha="0.54"
-                android:layout_alignParentEnd="true"
-                android:layout_marginTop="8dp"
-                android:layout_marginEnd="8dp"
-                android:src="@drawable/ic_suggestion_close_button"/>
-
-        </RelativeLayout>
-
-        <TextView
-            android:id="@android:id/title"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            style="@style/SuggestionCardText"
-            android:layout_marginStart="12dp"
-            android:layout_marginEnd="12dp"
-            android:singleLine="true"
-            android:textAppearance="@style/TextAppearance.SuggestionTitleV2"
-            android:ellipsize="marquee"
-            android:fadingEdge="horizontal" />
-
-        <TextView
-            android:id="@android:id/summary"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            style="@style/SuggestionCardText"
-            android:layout_marginStart="12dp"
-            android:layout_marginEnd="12dp"
-            android:textAppearance="@style/TextAppearance.SuggestionSummary" />
-
-    </LinearLayout>
-
-</android.support.v7.widget.CardView>
diff --git a/res/layout/suggestion_tile_with_button.xml b/res/layout/suggestion_tile_with_button.xml
index 081df5b..a674bcb 100644
--- a/res/layout/suggestion_tile_with_button.xml
+++ b/res/layout/suggestion_tile_with_button.xml
@@ -14,58 +14,78 @@
      limitations under the License.
 -->
 
-<LinearLayout
+<android.support.v7.widget.CardView
     xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="match_parent"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:id="@+id/suggestion_card"
+    android:layout_width="wrap_content"
     android:layout_height="wrap_content"
-    android:background="@android:color/white"
-    android:clipChildren="false"
-    android:clipToPadding="false"
-    android:paddingStart="16dp"
-    android:paddingEnd="12dp"
-    android:paddingBottom="20dp"
-    android:paddingTop="16dp"
-    android:orientation="horizontal"
-    android:minHeight="@dimen/dashboard_tile_minimum_height">
-
-    <ImageView
-        android:id="@android:id/icon"
-        android:layout_width="@dimen/dashboard_tile_image_size"
-        android:layout_height="@dimen/dashboard_tile_image_size" />
+    app:cardPreventCornerOverlap="false"
+    app:cardUseCompatPadding="true"
+    app:cardElevation="2dp"
+    app:cardCornerRadius="@dimen/suggestion_card_corner_radius">
 
     <LinearLayout
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:layout_gravity="start"
-        android:layout_marginStart="18dp"
-        android:layout_marginTop="2dp"
-        android:clipChildren="false"
-        android:clipToPadding="false"
+        android:minHeight="112dp"
         android:orientation="vertical">
 
+        <RelativeLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:orientation="horizontal">
+
+            <ImageView
+                android:id="@android:id/icon"
+                android:layout_width="@dimen/suggestion_card_icon_size"
+                android:layout_height="@dimen/suggestion_card_icon_size"
+                style="@style/SuggestionCardIcon"
+                android:layout_marginTop="16dp"
+                android:layout_marginBottom="8dp" />
+
+            <ImageView
+                android:id="@+id/close_button"
+                android:layout_width="18dp"
+                android:layout_height="18dp"
+                android:alpha="0.54"
+                android:layout_alignParentEnd="true"
+                android:layout_marginTop="8dp"
+                android:layout_marginEnd="8dp"
+                android:src="@drawable/ic_suggestion_close_button"/>
+
+        </RelativeLayout>
+
         <TextView
             android:id="@android:id/title"
-            android:layout_width="wrap_content"
+            android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:layout_marginStart="6dp"
-            android:textAppearance="@style/TextAppearance.TileTitle" />
+            style="@style/SuggestionCardText"
+            android:layout_marginStart="12dp"
+            android:layout_marginEnd="12dp"
+            android:singleLine="true"
+            android:textAppearance="@style/TextAppearance.SuggestionTitleV2"
+            android:ellipsize="end"
+            android:fadingEdge="horizontal" />
 
         <TextView
             android:id="@android:id/summary"
-            android:layout_width="wrap_content"
+            android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:layout_marginTop="12dp"
-            android:layout_marginStart="6dp"
-            android:layout_marginEnd="50dp"
+            style="@style/SuggestionCardText"
+            android:layout_marginStart="12dp"
+            android:layout_marginEnd="12dp"
             android:textAppearance="@style/TextAppearance.SuggestionSummary" />
 
         <Button
             android:id="@android:id/primary"
             style="@style/ActionPrimaryButton"
+            android:layout_gravity="center"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_marginTop="12dp"
             android:text="@string/suggestion_button_text" />
+
     </LinearLayout>
 
-</LinearLayout>
\ No newline at end of file
+</android.support.v7.widget.CardView>
diff --git a/res/layout/suggestion_tile_with_button_v2.xml b/res/layout/suggestion_tile_with_button_v2.xml
deleted file mode 100644
index 5f4ed18..0000000
--- a/res/layout/suggestion_tile_with_button_v2.xml
+++ /dev/null
@@ -1,88 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2018 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.
--->
-
-<android.support.v7.widget.CardView
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
-    android:id="@+id/suggestion_card"
-    android:layout_width="328dp"
-    android:layout_height="wrap_content"
-    app:cardUseCompatPadding="true"
-    app:cardElevation="2dp"
-    app:cardCornerRadius="@dimen/suggestion_card_corner_radius">
-
-    <LinearLayout
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:minHeight="112dp"
-        android:orientation="vertical">
-
-        <RelativeLayout
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:orientation="horizontal">
-
-            <ImageView
-                android:id="@android:id/icon"
-                android:layout_width="@dimen/dashboard_tile_image_size"
-                android:layout_height="@dimen/dashboard_tile_image_size"
-                style="@style/SuggestionCardIcon"
-                android:layout_marginTop="16dp"
-                android:layout_marginBottom="8dp" />
-
-            <ImageView
-                android:id="@+id/close_button"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_alignParentEnd="true"
-                android:layout_marginTop="8dp"
-                android:layout_marginEnd="8dp"
-                android:src="@drawable/ic_suggestion_close_button"/>
-
-        </RelativeLayout>
-
-        <TextView
-            android:id="@android:id/title"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            style="@style/SuggestionCardText"
-            android:layout_marginStart="12dp"
-            android:layout_marginEnd="12dp"
-            android:singleLine="true"
-            android:textAppearance="@style/TextAppearance.TileTitle"
-            android:ellipsize="marquee"
-            android:fadingEdge="horizontal" />
-
-        <TextView
-            android:id="@android:id/summary"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            style="@style/SuggestionCardText"
-            android:layout_marginStart="12dp"
-            android:layout_marginEnd="12dp"
-            android:textAppearance="@style/TextAppearance.SuggestionSummary" />
-
-        <Button
-            android:id="@android:id/primary"
-            style="@style/ActionPrimaryButton"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_marginTop="12dp"
-            android:text="@string/suggestion_button_text" />
-
-    </LinearLayout>
-
-</android.support.v7.widget.CardView>
diff --git a/res/values-sw400dp/dimens.xml b/res/values-sw400dp/dimens.xml
index 4f13e09..8d45dd4 100755
--- a/res/values-sw400dp/dimens.xml
+++ b/res/values-sw400dp/dimens.xml
@@ -23,9 +23,9 @@
     <dimen name="support_escalation_card_padding_end">56dp</dimen>
 
     <!-- Suggestion cards-->
-    <dimen name="suggestion_card_width_one_card">380dp</dimen>
-    <dimen name="suggestion_card_width_two_cards">184dp</dimen>
-    <dimen name="suggestion_card_width_multiple_cards">176dp</dimen>
+    <dimen name="suggestion_card_width_one_card">384dp</dimen>
+    <dimen name="suggestion_card_width_two_cards">188dp</dimen>
+    <dimen name="suggestion_card_width_multiple_cards">180dp</dimen>
     <dimen name="suggestion_card_padding_bottom_one_card">22dp</dimen>
 
 </resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 332deea..12193c4 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -110,7 +110,7 @@
     <dimen name="dashboard_tile_foreground_image_inset">6dp</dimen>
 
     <!-- Dashboard tile image margin start / end -->
-    <dimen name="dashboard_tile_image_margin">24dp</dimen>
+    <dimen name="dashboard_tile_image_margin">18dp</dimen>
 
     <!-- SwitchBar sub settings margin start / end -->
     <dimen name="switchbar_subsettings_margin_start">72dp</dimen>
@@ -119,8 +119,8 @@
     <!-- The following two margins need to match, with the caveat that
          the second should be negative. The second one ensures that the icons and text
          align despite the additional padding caused by the search bar's card background. -->
-    <dimen name="search_bar_margin">8dp</dimen>
-    <dimen name="search_bar_negative_margin">-8dp</dimen>
+    <dimen name="search_bar_margin">16dp</dimen>
+    <dimen name="search_bar_negative_margin">-16dp</dimen>
 
     <dimen name="search_bar_height">48dp</dimen>
     <dimen name="search_bar_corner_radius">2dp</dimen>
@@ -304,9 +304,9 @@
 
     <!-- Suggestion cards size and padding -->
     <dimen name="suggestion_card_icon_size">24dp</dimen>
-    <dimen name="suggestion_card_width_one_card">328dp</dimen>
-    <dimen name="suggestion_card_width_two_cards">158dp</dimen>
-    <dimen name="suggestion_card_width_multiple_cards">152dp</dimen>
+    <dimen name="suggestion_card_width_one_card">332dp</dimen>
+    <dimen name="suggestion_card_width_two_cards">162dp</dimen>
+    <dimen name="suggestion_card_width_multiple_cards">156dp</dimen>
     <dimen name="suggestion_card_outer_margin">16dp</dimen>
     <dimen name="suggestion_card_inner_margin">12dp</dimen>
     <dimen name="suggestion_card_padding_bottom_one_card">16dp</dimen>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index f917d81..9a6ff90 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1133,8 +1133,12 @@
     <!-- Title for suggested actions for settings up a fingerprint lock [CHAR LIMIT=34] -->
     <string name="suggested_fingerprint_lock_settings_title">Unlock with fingerprint</string>
 
-    <!-- Summary for suggested actions for settings up a fingerprint lock -->
-    <string name="suggested_fingerprint_lock_settings_summary">Unlock with your fingerprint</string>
+    <!-- Summary for suggested actions for settings up a fingerprint lock (tablet)  -->
+    <string name="suggested_fingerprint_lock_settings_summary" product="tablet">Unlock with your fingerprint</string>
+    <!-- Summary for suggested actions for settings up a fingerprint lock (device)  -->
+    <string name="suggested_fingerprint_lock_settings_summary" product="device">Unlock with your fingerprint</string>
+    <!-- Summary for suggested actions for settings up a fingerprint lock (phone)  -->
+    <string name="suggested_fingerprint_lock_settings_summary" product="default">Unlock with your fingerprint</string>
 
     <!--  Title for security picker to choose the unlock method: None/Pattern/PIN/Password [CHAR LIMIT=22] -->
     <string name="lock_settings_picker_title">Choose screen lock</string>
@@ -2579,6 +2583,7 @@
 
     <!-- [CHAR LIMIT=30] Title of the preference that opens the Ambient display settings screen. -->
     <string name="ambient_display_screen_title">Ambient display</string>
+
     <!-- [CHAR LIMIT=50] Summary of the preference that opens the Ambient display settings screen, when Ambient display is set to be always on -->
     <string name="ambient_display_screen_summary_always_on">Always on / Increased battery usage</string>
     <!-- [CHAR LIMIT=30] Summary of the preference that opens the Ambient display settings screen, when Ambient display is set to show when new notifications come in. -->
@@ -6647,6 +6652,8 @@
     <string name="app_and_notification_dashboard_summary">Permissions, default apps</string>
     <!-- Title for setting tile leading to account settings [CHAR LIMIT=40]-->
     <string name="account_dashboard_title">Accounts</string>
+    <!-- Summary for account settings tiles when there is no accounts on device [CHAR LIMIT=NONE]-->
+    <string name="account_dashboard_default_summary">No accounts added</string>
     <!-- Title for setting tile leading to setting UI which allows user set default app to
     handle actions such as open web page, making phone calls, default SMS apps [CHAR  LIMIT=40]-->
     <string name="app_default_dashboard_title">Default apps</string>
@@ -6714,6 +6721,8 @@
     <string name="keywords_sim_status">network, mobile network state, service state, signal strength, mobile network type, roaming, iccid</string>
     <string name="keywords_model_and_hardware">serial number, hardware version</string>
     <string name="keywords_android_version">android security patch level, baseband version, kernel version</string>
+    <!-- Search keyword for Ambient display settings screen. -->
+    <string name="keywords_ambient_display_screen">Ambient display, Lock screen display</string>
 
     <!-- NFC Wi-Fi pairing/setup strings-->
 
@@ -6976,6 +6985,9 @@
     <!-- notification header - apps that have recently sent notifications -->
     <string name="recent_notifications">Recently sent</string>
 
+    <!-- Preference title for showing all apps on device [CHAR_LIMIT=50]-->
+    <string name="recent_notifications_see_all_title">See all apps</string>
+
     <!-- Configure Notifications: Advanced section header [CHAR LIMIT=30] -->
     <string name="advanced_section_header">Advanced</string>
 
@@ -7993,15 +8005,15 @@
     <!-- Title of one of the choices in a dialog (with title defined in usb_use) that lets the user
          select what the USB connection for this device should be used for. This choice
          is for powering the other device only. -->
-    <string name="usb_use_power_only">Supply power</string>
+    <string name="usb_use_power_only">Charging connected device</string>
     <!-- Decription of one of the choices in a dialog (with title defined in usb_use) that lets the
          user select what the USB connection for this device should be used for. This choice
          is for powering the other device. -->
-    <string name="usb_use_power_only_desc">Charge the connected device. Works only with devices that support USB charging.</string>
+    <string name="usb_use_power_only_desc">Other settings unavailable when turned on</string>
     <!-- Title of one of the choices in a dialog (with title defined in usb_use) that lets the user
          select what the USB connection for this device should be used for. This choice
          is for transferring files via MTP. -->
-    <string name="usb_use_file_transfers">Transfer files</string>
+    <string name="usb_use_file_transfers">File Transfer</string>
     <!-- Description of one of the choices in a dialog (with title defined in usb_use) that lets the user
          select what the USB connection for this device should be used for. This choice
          is for transferring files via MTP. -->
@@ -8009,23 +8021,31 @@
     <!-- Title of one of the choices in a dialog (with title defined in usb_use) that lets the user
          select what the USB connection for this device should be used for. This choice
          is for transferring photos via PTP. -->
-    <string name="usb_use_photo_transfers">Transfer photos (PTP)</string>
+    <string name="usb_use_photo_transfers">PTP</string>
     <!-- Description of one of the choices in a dialog (with title defined in usb_use) that lets the user
          select what the USB connection for this device should be used for. This choice
          is for transferring photos via PTP. -->
     <string name="usb_use_photo_transfers_desc">Transfer photos or files if MTP is not supported (PTP)</string>
     <!-- Title of one of the choices in a dialog (with title defined in usb_use) that lets the user
          select what the USB connection for this device should be used for. This choice
+         is for USB tethering. -->
+    <string name="usb_use_tethering">USB tethering</string>
+    <!-- Title of one of the choices in a dialog (with title defined in usb_use) that lets the user
+         select what the USB connection for this device should be used for. This choice
          is for entering MIDI mode. -->
-    <string name="usb_use_MIDI">Use device as MIDI</string>
+    <string name="usb_use_MIDI">MIDI</string>
     <!-- Description of one of the choices in a dialog (with title defined in usb_use) that lets the user
          select what the USB connection for this device should be used for. This choice
          is for entering MIDI mode. -->
     <string name="usb_use_MIDI_desc">Use this device as MIDI</string>
     <!-- The title used in a dialog which lets the user select what the USB connection
-         for this device should be used for. Choices are usb_use_charging_only,
-         usb_use_file_transfer, use_use_photo_transfer, and usb_use_MIDI -->
-    <string name="usb_use">Use USB to</string>
+         for this device should be used for. These options are more commonly used.
+         Choices are usb_use_file_transfer.-->
+    <string name="usb_use">Use USB for</string>
+    <!-- The title used in a dialog which lets the user select what the USB connection
+         for this device should be used for. These options are less commonly used.
+         Choices are usb_use_tethering, usb_use_photo_transfers, usb_use_MIDI, and usb_use_power_only.-->
+    <string name="usb_use_also">Also use USB for</string>
 
     <!-- Settings item title for USB preference [CHAR LIMIT=35] -->
     <string name="usb_pref">USB</string>
@@ -8033,13 +8053,27 @@
     <!-- Settings item summary for USB preference when set to charging only [CHAR LIMIT=NONE] -->
     <string name="usb_summary_charging_only">Charging this device</string>
     <!-- Settings item summary for USB preference when set to powering the other device only [CHAR LIMIT=NONE] -->
-    <string name="usb_summary_power_only">Supplying power</string>
+    <string name="usb_summary_power_only">Charging connected device</string>
     <!-- Settings item summary for USB preference when set to transferring files via MTP [CHAR LIMIT=NONE] -->
-    <string name="usb_summary_file_transfers">Transferring files</string>
+    <string name="usb_summary_file_transfers">File transfer</string>
+    <!-- Settings item summary for USB preference when set to USB tethering [CHAR LIMIT=NONE] -->
+    <string name="usb_summary_tether">USB tethering</string>
     <!-- Settings item summary for USB preference when set to transferring photos via PTP [CHAR LIMIT=NONE] -->
-    <string name="usb_summary_photo_transfers">Transferring photos (PTP)</string>
+    <string name="usb_summary_photo_transfers">PTP</string>
     <!-- Settings item summary for USB preference when set to entering MIDI mode [CHAR LIMIT=NONE] -->
-    <string name="usb_summary_MIDI">Using device as MIDI</string>
+    <string name="usb_summary_MIDI">MIDI</string>
+    <!-- Settings item summary for USB preference when set to transferring files via MTP
+          and powering other device [CHAR LIMIT=NONE] -->
+    <string name="usb_summary_file_transfers_power">File transfer and supplying power</string>
+    <!-- Settings item summary for USB preference when set to USB tethering
+         and powering other device [CHAR LIMIT=NONE] -->
+    <string name="usb_summary_tether_power">USB tethering and supplying power</string>
+    <!-- Settings item summary for USB preference when set to transferring photos via PTP
+         and powering other device [CHAR LIMIT=NONE] -->
+    <string name="usb_summary_photo_transfers_power">PTP and supplying power</string>
+    <!-- Settings item summary for USB preference when set to entering MIDI mode
+         and powering other device [CHAR LIMIT=NONE] -->
+    <string name="usb_summary_MIDI_power">MIDI and supplying power</string>
 
     <!-- Settings item title for SMS Mirroring preference [CHAR LIMIT=35] -->
     <string name="sms_mirroring_pref">SMS Mirroring</string>
@@ -8333,8 +8367,10 @@
     <!-- Backup disabled summary [CHAR LIMIT=NONE] -->
     <string name="backup_disabled">Back up disabled</string>
 
-    <!-- Summary of device info page [CHAR LIMIT=NONE] -->
-    <string name="about_summary">Updated to Android <xliff:g id="version" example="6.0">%1$s</xliff:g></string>
+    <!-- Summary of Android version info [CHAR LIMIT=NONE] -->
+    <string name="android_version_summary">Updated to Android <xliff:g id="version" example="6.0">%1$s</xliff:g></string>
+    <!-- Summary of Android version info (when there is a pending upgrade available) [CHAR LIMIT=NONE] -->
+    <string name="android_version_pending_update_summary">Update available</string>
 
     <!-- Title for dialog displayed when user clicks on a setting locked by an admin [CHAR LIMIT=30] -->
     <string name="disabled_by_policy_title">Action not allowed</string>
diff --git a/res/xml/ambient_display_settings.xml b/res/xml/ambient_display_settings.xml
index a8ded0d..8bd9bd6 100644
--- a/res/xml/ambient_display_settings.xml
+++ b/res/xml/ambient_display_settings.xml
@@ -17,7 +17,9 @@
 
 <PreferenceScreen
     xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:settings="http://schemas.android.com/apk/res-auto"
     android:key="ambient_display_preference_screen"
+    settings:keywords="@string/keywords_ambient_display_screen"
     android:title="@string/ambient_display_screen_title">
 
     <PreferenceCategory
diff --git a/res/xml/app_data_usage.xml b/res/xml/app_data_usage.xml
index 3e94135..a4b2159 100644
--- a/res/xml/app_data_usage.xml
+++ b/res/xml/app_data_usage.xml
@@ -16,6 +16,8 @@
 
 <PreferenceScreen
     xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:settings="http://schemas.android.com/apk/res-auto"
+    android:key="app_data_usage_screen"
     android:title="@string/data_usage_app_summary_title">
 
     <com.android.settings.datausage.SpinnerPreference
@@ -50,15 +52,19 @@
             android:key="app_settings"
             android:title="@string/data_usage_app_settings" />
 
-        <SwitchPreference
+        <com.android.settingslib.RestrictedSwitchPreference
             android:key="restrict_background"
             android:title="@string/data_usage_app_restrict_background"
-            android:summary="@string/data_usage_app_restrict_background_summary" />
+            android:summary="@string/data_usage_app_restrict_background_summary"
+            settings:useAdditionalSummary="true"
+            settings:restrictedSwitchSummary="@string/disabled_by_admin" />
 
-        <SwitchPreference
+        <com.android.settingslib.RestrictedSwitchPreference
             android:key="unrestricted_data_saver"
             android:title="@string/unrestricted_app_title"
-            android:summary="@string/unrestricted_app_summary" />
+            android:summary="@string/unrestricted_app_summary"
+            settings:useAdditionalSummary="true"
+            settings:restrictedSwitchSummary="@string/disabled_by_admin" />
 
     </PreferenceCategory>
 
diff --git a/res/xml/app_notification_settings.xml b/res/xml/app_notification_settings.xml
index b21d168..2d5dc57 100644
--- a/res/xml/app_notification_settings.xml
+++ b/res/xml/app_notification_settings.xml
@@ -15,7 +15,8 @@
 -->
 
 <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
-        xmlns:settings="http://schemas.android.com/apk/res-auto">
+        xmlns:settings="http://schemas.android.com/apk/res-auto"
+        settings:initialExpandedChildrenCount="500">
 
     <com.android.settings.applications.LayoutPreference
         android:key="pref_app_header"
@@ -25,24 +26,24 @@
         android:key="block"
         android:layout="@layout/styled_switch_bar" />
 
+    <com.android.settings.notification.NotificationFooterPreference
+        android:key="block_desc" />
+
+    <!-- Channels/Channel groups added here -->
+
     <!-- Show badge -->
     <com.android.settingslib.RestrictedSwitchPreference
         android:key="badge"
         android:title="@string/notification_badge_title"
+        android:order="501"
         settings:useAdditionalSummary="true"
+        settings:allowDividerAbove="true"
         settings:restrictedSwitchSummary="@string/enabled_by_admin" />
 
-    <!-- Channels/Channel groups added here -->
-
     <Preference
         android:key="app_link"
         android:title="@string/app_settings_link"
-        android:order="500"
-        settings:allowDividerAbove="true"/>
-
-    <com.android.settings.notification.NotificationFooterPreference
-        android:key="block_desc"
-        android:order="1000" />
+        android:order="502" />
 
     <com.android.settings.notification.NotificationFooterPreference
         android:key="desc"
diff --git a/res/xml/channel_notification_settings.xml b/res/xml/channel_notification_settings.xml
index 6d20571..9d0398d 100644
--- a/res/xml/channel_notification_settings.xml
+++ b/res/xml/channel_notification_settings.xml
@@ -27,7 +27,7 @@
         android:layout="@layout/styled_switch_bar" />
 
     <!-- Importance -->
-    <Preference
+    <com.android.settings.RestrictedListPreference
         android:key="importance"
         android:title="@string/notification_importance_title" />
 
diff --git a/res/xml/configure_notification_settings.xml b/res/xml/configure_notification_settings.xml
index e080be4..9d72441 100644
--- a/res/xml/configure_notification_settings.xml
+++ b/res/xml/configure_notification_settings.xml
@@ -79,7 +79,7 @@
             <intent
                 android:action="android.intent.action.MAIN"
                 android:targetPackage="com.android.settings"
-                android:targetClass="com.android.settings.Settings$NotificationAppListActivity">
+                android:targetClass="com.android.settings.Settings$ManageApplicationsActivity">
             </intent>
         </Preference>
     </PreferenceCategory>
diff --git a/res/xml/connected_devices_advanced.xml b/res/xml/connected_devices_advanced.xml
index 8ca6b81..0b75abf 100644
--- a/res/xml/connected_devices_advanced.xml
+++ b/res/xml/connected_devices_advanced.xml
@@ -57,16 +57,6 @@
         android:order="-2"/>
 
     <Preference
-        android:key="usb_mode"
-        android:title="@string/usb_pref"
-        android:icon="@drawable/ic_usb"
-        android:order="-1">
-        <intent android:action="android.intent.action.MAIN"
-                android:targetPackage="com.android.settings"
-                android:targetClass="com.android.settings.deviceinfo.UsbModeChooserActivity"/>
-    </Preference>
-
-    <Preference
         android:key="bt_received_files"
         android:icon="@drawable/ic_folder_vd_theme_24"
         android:title="@string/bluetooth_show_received_files" />
diff --git a/res/xml/connected_devices_old.xml b/res/xml/connected_devices_old.xml
index 3eb62ea..cc7b5b4 100644
--- a/res/xml/connected_devices_old.xml
+++ b/res/xml/connected_devices_old.xml
@@ -53,7 +53,7 @@
         android:order="-2">
         <intent android:action="android.intent.action.MAIN"
                 android:targetPackage="com.android.settings"
-                android:targetClass="com.android.settings.deviceinfo.UsbModeChooserActivity"/>
+                android:targetClass="com.android.settings.connecteddevice.usb.UsbModeChooserActivity"/>
     </Preference>
 
     <PreferenceCategory
diff --git a/res/xml/security_settings_v2.xml b/res/xml/security_dashboard_settings.xml
similarity index 100%
rename from res/xml/security_settings_v2.xml
rename to res/xml/security_dashboard_settings.xml
diff --git a/res/xml/security_settings.xml b/res/xml/security_settings.xml
deleted file mode 100644
index 31f2334..0000000
--- a/res/xml/security_settings.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2008 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"
-    xmlns:settings="http://schemas.android.com/apk/res-auto"
-    android:key="security_dashboard_page"
-    android:title="@string/security_settings_title"
-    settings:initialExpandedChildrenCount="9">
-
-</PreferenceScreen>
diff --git a/res/xml/security_settings_chooser.xml b/res/xml/security_settings_chooser.xml
deleted file mode 100644
index 360e620..0000000
--- a/res/xml/security_settings_chooser.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2010 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-          http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
-                  xmlns:settings="http://schemas.android.com/apk/res-auto"
-                  android:key="security_settings_chooser_screen"
-                  android:title="@string/security_settings_title">
-
-    <PreferenceCategory
-        android:key="security_category"
-        android:title="@string/lock_settings_title">
-
-        <com.android.settings.widget.GearPreference
-            android:key="unlock_set_or_change"
-            android:title="@string/unlock_set_unlock_launch_picker_title"
-            android:summary="@string/unlock_set_unlock_mode_none"
-            settings:keywords="@string/keywords_lockscreen"
-            android:persistent="false"/>
-
-        <Preference android:key="lockscreen_preferences"
-            android:title="@string/lockscreen_settings_title"
-            android:fragment="com.android.settings.security.LockscreenDashboardFragment"/>
-
-    </PreferenceCategory>
-
-</PreferenceScreen>
diff --git a/res/xml/security_settings_lockscreen.xml b/res/xml/security_settings_lockscreen.xml
deleted file mode 100644
index 56410fb..0000000
--- a/res/xml/security_settings_lockscreen.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2010 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-          http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
-                  xmlns:settings="http://schemas.android.com/apk/res-auto"
-                  android:key="security_settings_lockscreen_screen"
-                  android:title="@string/security_settings_title">
-
-    <PreferenceCategory
-        android:key="security_category"
-        android:title="@string/lock_settings_title">
-
-        <com.android.settingslib.RestrictedPreference
-            android:key="unlock_set_or_change"
-            android:title="@string/unlock_set_unlock_launch_picker_title"
-            android:summary="@string/unlock_set_unlock_mode_off"
-            settings:keywords="@string/keywords_lockscreen"
-            android:persistent="false"/>
-
-    </PreferenceCategory>
-
-</PreferenceScreen>
diff --git a/res/xml/security_settings_lockscreen_profile.xml b/res/xml/security_settings_lockscreen_profile.xml
deleted file mode 100644
index a0c3f02..0000000
--- a/res/xml/security_settings_lockscreen_profile.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2016 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"
-                  xmlns:settings="http://schemas.android.com/apk/res-auto"
-                  android:key="security_settings_lockscreen_profile_screen"
-                  android:title="@string/security_settings_title">
-
-    <com.android.settingslib.RestrictedPreference
-        android:key="unlock_set_or_change_profile"
-        android:title="@string/unlock_set_unlock_launch_picker_title_profile"
-        android:summary="@string/unlock_set_unlock_mode_off"
-        settings:keywords="@string/keywords_lockscreen"
-        android:persistent="false"/>
-
-</PreferenceScreen>
diff --git a/res/xml/security_settings_misc.xml b/res/xml/security_settings_misc.xml
deleted file mode 100644
index 730686c..0000000
--- a/res/xml/security_settings_misc.xml
+++ /dev/null
@@ -1,88 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2011 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-          http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
-                  android:key="security_settings_misc_screen"
-        android:title="@string/security_settings_title">
-
-    <PreferenceCategory
-        android:key="security_settings_misc_category"
-        android:title="@string/security_passwords_title">
-
-        <Preference
-            android:key="location"
-            android:title="@string/location_settings_title"
-            android:fragment="com.android.settings.location.LocationSettings">
-        </Preference>
-
-        <SwitchPreference
-            android:key="show_password"
-            android:title="@string/show_password"
-            android:summary="@string/show_password_summary"/>
-
-    </PreferenceCategory>
-
-    <PreferenceCategory
-        android:key="security_settings_device_admin_category">
-
-        <Preference android:key="manage_device_admin"
-                android:title="@string/manage_device_admin"
-                android:persistent="false"
-                android:fragment="com.android.settings.DeviceAdminSettings"/>
-
-        <Preference android:key="enterprise_privacy"
-                android:title="@string/enterprise_privacy_settings"
-                android:persistent="false"
-                android:fragment="com.android.settings.enterprise.EnterprisePrivacySettings"/>
-
-    </PreferenceCategory>
-
-    <Preference android:key="sim_lock_settings"
-        android:title="@string/sim_lock_settings_category"
-        android:persistent="false">
-
-        <intent android:action="android.intent.action.MAIN"
-            android:targetPackage="com.android.settings"
-            android:targetClass="com.android.settings.Settings$IccLockSettingsActivity"/>
-
-    </Preference>
-
-    <Preference
-        android:key="encryption_and_credential"
-        android:title="@string/encryption_and_credential_settings_title"
-        android:summary="@string/encryption_and_credential_settings_summary"
-        android:fragment="com.android.settings.security.EncryptionAndCredential"/>
-
-    <Preference android:key="manage_trust_agents"
-        android:title="@string/manage_trust_agents"
-        android:persistent="false"
-        android:fragment="com.android.settings.security.trustagent.TrustAgentSettings"/>
-
-    <Preference
-        android:key="screen_pinning_settings"
-        android:title="@string/screen_pinning_title"
-        android:summary="@string/switch_off_text"
-        android:fragment="com.android.settings.security.ScreenPinningSettings"/>
-
-    <Preference android:key="security_misc_usage_access"
-        android:title="@string/usage_access_title"
-        android:fragment="com.android.settings.applications.manageapplications.ManageApplications">
-        <extra
-            android:name="classname"
-            android:value="com.android.settings.Settings$UsageAccessSettingsActivity" />
-    </Preference>
-
-</PreferenceScreen>
diff --git a/res/xml/security_settings_password.xml b/res/xml/security_settings_password.xml
deleted file mode 100644
index 26077c7..0000000
--- a/res/xml/security_settings_password.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2010 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-          http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
-                  xmlns:settings="http://schemas.android.com/apk/res-auto"
-                  android:key="security_settings_password_screen"
-                  android:title="@string/lock_settings_picker_title">
-
-    <PreferenceCategory
-        android:key="security_category"
-        android:title="@string/lock_settings_title">
-
-        <com.android.settings.widget.GearPreference
-            android:key="unlock_set_or_change"
-            android:title="@string/unlock_set_unlock_launch_picker_title"
-            android:summary="@string/unlock_set_unlock_mode_password"
-            settings:keywords="@string/keywords_lockscreen" />
-
-        <Preference android:key="lockscreen_preferences"
-            android:title="@string/lockscreen_settings_title"
-            android:fragment="com.android.settings.security.LockscreenDashboardFragment"/>
-
-    </PreferenceCategory>
-
-</PreferenceScreen>
diff --git a/res/xml/security_settings_password_profile.xml b/res/xml/security_settings_password_profile.xml
deleted file mode 100644
index 257b234..0000000
--- a/res/xml/security_settings_password_profile.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2016 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"
-                  xmlns:settings="http://schemas.android.com/apk/res-auto"
-                  android:key="security_settings_password_profile_screen"
-                  android:title="@string/security_settings_title">
-
-    <com.android.settingslib.RestrictedPreference
-        android:key="unlock_set_or_change_profile"
-        android:title="@string/unlock_set_unlock_launch_picker_title_profile"
-        android:summary="@string/unlock_set_unlock_mode_password"
-        settings:keywords="@string/keywords_lockscreen"
-        android:persistent="false"/>
-
-</PreferenceScreen>
diff --git a/res/xml/security_settings_pattern.xml b/res/xml/security_settings_pattern.xml
deleted file mode 100644
index 9b7482f..0000000
--- a/res/xml/security_settings_pattern.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2010 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-          http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
-                  xmlns:settings="http://schemas.android.com/apk/res-auto"
-                  android:key="security_settings_pattern_screen"
-                  android:title="@string/lock_settings_picker_title">
-
-    <PreferenceCategory
-        android:key="security_category"
-        android:title="@string/lock_settings_title">
-
-        <com.android.settings.widget.GearPreference
-            android:key="unlock_set_or_change"
-            android:title="@string/unlock_set_unlock_launch_picker_title"
-            android:summary="@string/unlock_set_unlock_mode_pattern"
-            settings:keywords="@string/keywords_lockscreen" />
-
-        <Preference android:key="lockscreen_preferences"
-            android:title="@string/lockscreen_settings_title"
-            android:fragment="com.android.settings.security.LockscreenDashboardFragment"/>
-
-    </PreferenceCategory>
-
-</PreferenceScreen>
diff --git a/res/xml/security_settings_pattern_profile.xml b/res/xml/security_settings_pattern_profile.xml
deleted file mode 100644
index e095486..0000000
--- a/res/xml/security_settings_pattern_profile.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2016 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"
-                  xmlns:settings="http://schemas.android.com/apk/res-auto"
-                  android:key="security_settings_pattern_profile_screen"
-                  android:title="@string/security_settings_title">
-
-    <com.android.settingslib.RestrictedPreference
-        android:key="unlock_set_or_change_profile"
-        android:title="@string/unlock_set_unlock_launch_picker_title_profile"
-        android:summary="@string/unlock_set_unlock_mode_pattern"
-        settings:keywords="@string/keywords_lockscreen"
-        android:persistent="false"/>
-
-    <SwitchPreference
-        android:key="visiblepattern_profile"
-        android:title="@string/lockpattern_settings_enable_visible_pattern_title_profile"/>
-
-</PreferenceScreen>
diff --git a/res/xml/security_settings_pin.xml b/res/xml/security_settings_pin.xml
deleted file mode 100644
index 780ca19..0000000
--- a/res/xml/security_settings_pin.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2010 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-          http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
-                  xmlns:settings="http://schemas.android.com/apk/res-auto"
-                  android:title="@string/lock_settings_picker_title">
-
-    <PreferenceCategory
-        android:key="security_category"
-        android:title="@string/lock_settings_title">
-
-        <com.android.settings.widget.GearPreference
-            android:key="unlock_set_or_change"
-            android:title="@string/unlock_set_unlock_launch_picker_title"
-            android:summary="@string/unlock_set_unlock_mode_pin"
-            settings:keywords="@string/keywords_lockscreen" />
-
-        <Preference android:key="lockscreen_preferences"
-            android:title="@string/lockscreen_settings_title"
-            android:fragment="com.android.settings.security.LockscreenDashboardFragment"/>
-
-    </PreferenceCategory>
-
-</PreferenceScreen>
diff --git a/res/xml/security_settings_pin_profile.xml b/res/xml/security_settings_pin_profile.xml
deleted file mode 100644
index 071b2f5..0000000
--- a/res/xml/security_settings_pin_profile.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2016 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"
-                  xmlns:settings="http://schemas.android.com/apk/res-auto"
-                  android:key="security_settings_pin_profile_screen"
-                  android:title="@string/security_settings_title">
-
-    <com.android.settingslib.RestrictedPreference
-        android:key="unlock_set_or_change_profile"
-        android:title="@string/unlock_set_unlock_launch_picker_title_profile"
-        android:summary="@string/unlock_set_unlock_mode_pin"
-        settings:keywords="@string/keywords_lockscreen"
-        android:persistent="false"/>
-
-</PreferenceScreen>
diff --git a/res/xml/security_settings_profile.xml b/res/xml/security_settings_profile.xml
deleted file mode 100644
index 9870e30..0000000
--- a/res/xml/security_settings_profile.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2016 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"
-                  xmlns:settings="http://schemas.android.com/apk/res-auto"
-                  android:title="@string/lock_settings_picker_title">
-
-    <PreferenceCategory
-        android:key="security_category_profile"
-        android:title="@string/lock_settings_profile_title">
-
-    </PreferenceCategory>
-
-</PreferenceScreen>
diff --git a/res/xml/security_settings_status.xml b/res/xml/security_settings_status.xml
deleted file mode 100644
index 06930f9..0000000
--- a/res/xml/security_settings_status.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2017 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/security_settings_title">
-
-    <PreferenceCategory
-        android:key="security_status"
-        android:title="@string/security_status_title"/>
-
-</PreferenceScreen>
diff --git a/res/xml/security_settings_unification.xml b/res/xml/security_settings_unification.xml
deleted file mode 100644
index b9c59e5..0000000
--- a/res/xml/security_settings_unification.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2016 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"
-                  xmlns:settings="http://schemas.android.com/apk/res-auto"
-                  android:title="@string/security_settings_title">
-
-    <com.android.settingslib.RestrictedSwitchPreference
-        android:key="unification"
-        android:title="@string/lock_settings_profile_unification_title"
-        android:summary="@string/lock_settings_profile_unification_summary"
-        settings:keywords="@string/keywords_unification"/>
-
-</PreferenceScreen>
diff --git a/res/xml/system_dashboard_fragment.xml b/res/xml/system_dashboard_fragment.xml
index 73aab4b..d8459dd 100644
--- a/res/xml/system_dashboard_fragment.xml
+++ b/res/xml/system_dashboard_fragment.xml
@@ -55,7 +55,7 @@
         android:summary="@string/summary_placeholder"
         android:icon="@drawable/ic_system_update"
         android:order="-30"
-        settings:controller="com.android.settings.deviceinfo.SystemUpdatePreferenceController">
+        settings:controller="com.android.settings.system.SystemUpdatePreferenceController">
         <intent android:action="android.settings.SYSTEM_UPDATE_SETTINGS" />
     </Preference>
 
@@ -63,7 +63,7 @@
         android:key="additional_system_update_settings"
         android:title="@string/additional_system_update_settings_list_item_title"
         android:order="-31"
-        settings:controller="com.android.settings.deviceinfo.AdditionalSystemUpdatePreferenceController">
+        settings:controller="com.android.settings.system.AdditionalSystemUpdatePreferenceController">
         <intent android:action="android.intent.action.MAIN"
                 android:targetPackage="@string/additional_system_update"
                 android:targetClass="@string/additional_system_update_menu" />
diff --git a/res/xml/usb_details_fragment.xml b/res/xml/usb_details_fragment.xml
new file mode 100644
index 0000000..30ca993
--- /dev/null
+++ b/res/xml/usb_details_fragment.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  Copyright (C) 2017 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"
+    xmlns:settings="http://schemas.android.com/apk/res-auto"
+    android:title="@string/device_details_title">
+
+    <com.android.settings.applications.LayoutPreference
+        android:key="usb_device_header"
+        android:layout="@layout/settings_entity_header"
+        android:selectable="false"/>
+
+    <PreferenceCategory
+        android:key="usb_main_options"
+        android:title="@string/usb_use"/>
+
+    <PreferenceCategory
+        android:key="usb_secondary_options"
+        android:title="@string/usb_use_also"/>
+
+</PreferenceScreen>
diff --git a/src/com/android/settings/MasterClear.java b/src/com/android/settings/MasterClear.java
index 687e645..47aa8a6 100644
--- a/src/com/android/settings/MasterClear.java
+++ b/src/com/android/settings/MasterClear.java
@@ -123,24 +123,34 @@
         return !((requestCode != KEYGUARD_REQUEST) && (requestCode != CREDENTIAL_CONFIRM_REQUEST));
     }
 
-    @VisibleForTesting
-    boolean isShowFinalConfirmation(int requestCode, int resultCode) {
-        return (resultCode == Activity.RESULT_OK) || (requestCode == CREDENTIAL_CONFIRM_REQUEST);
-    }
-
     @Override
     public void onActivityResult(int requestCode, int resultCode, Intent data) {
         super.onActivityResult(requestCode, resultCode, data);
+        onActivityResultInternal(requestCode, resultCode, data);
+    }
+
+    /*
+     * Internal method that allows easy testing without dealing with super references.
+     */
+    @VisibleForTesting
+    void onActivityResultInternal(int requestCode, int resultCode, Intent data) {
         if (!isValidRequestCode(requestCode)) {
             return;
         }
 
-        // If the user entered a valid keyguard trace, present the final
-        // confirmation prompt; otherwise, go back to the initial state.
-        if (isShowFinalConfirmation(requestCode, resultCode)) {
-            showFinalConfirmation();
-        } else {
+        if (resultCode != Activity.RESULT_OK) {
             establishInitialState();
+            return;
+        }
+
+        Intent intent = null;
+        // If returning from a Keyguard request, try to show an account confirmation request if
+        // applciable.
+        if (CREDENTIAL_CONFIRM_REQUEST != requestCode
+                && (intent = getAccountConfirmationIntent()) != null) {
+            showAccountCredentialConfirmation(intent);
+        } else {
+            showFinalConfirmation();
         }
     }
 
@@ -155,7 +165,12 @@
     }
 
     @VisibleForTesting
-    boolean tryShowAccountConfirmation() {
+    void showAccountCredentialConfirmation(Intent intent) {
+        startActivityForResult(intent, CREDENTIAL_CONFIRM_REQUEST);
+    }
+
+    @VisibleForTesting
+    Intent getAccountConfirmationIntent() {
         final Context context = getActivity();
         final String accountType = context.getString(R.string.account_type);
         final String packageName = context.getString(R.string.account_confirmation_package);
@@ -163,7 +178,8 @@
         if (TextUtils.isEmpty(accountType)
                 || TextUtils.isEmpty(packageName)
                 || TextUtils.isEmpty(className)) {
-            return false;
+            Log.i(TAG, "Resources not set for account confirmation.");
+            return null;
         }
         final AccountManager am = AccountManager.get(context);
         Account[] accounts = am.getAccountsByType(accountType);
@@ -179,12 +195,14 @@
                     && packageName.equals(resolution.activityInfo.packageName)) {
                 // Note that we need to check the packagename to make sure that an Activity resolver
                 // wasn't returned.
-                startActivityForResult(
-                    requestAccountConfirmation, CREDENTIAL_CONFIRM_REQUEST);
-                return true;
+                return requestAccountConfirmation;
+            } else {
+                Log.i(TAG, "Unable to resolve Activity: " + packageName + "/" + className);
             }
+        } else {
+            Log.d(TAG, "No " + accountType + " accounts installed!");
         }
-        return false;
+        return null;
     }
 
     /**
@@ -210,7 +228,14 @@
                 return;
             }
 
-            if (!tryShowAccountConfirmation() && !runKeyguardConfirmation(KEYGUARD_REQUEST)) {
+            if (runKeyguardConfirmation(KEYGUARD_REQUEST)) {
+                return;
+            }
+
+            Intent intent = getAccountConfirmationIntent();
+            if (intent != null) {
+                showAccountCredentialConfirmation(intent);
+            } else {
                 showFinalConfirmation();
             }
         }
@@ -228,7 +253,8 @@
      * time, then simply reuse the inflated views directly whenever we need
      * to change contents.
      */
-    private void establishInitialState() {
+    @VisibleForTesting
+    void establishInitialState() {
         mInitiateButton = (Button) mContentView.findViewById(R.id.initiate_master_clear);
         mInitiateButton.setOnClickListener(mInitiateListener);
         mExternalStorageContainer = mContentView.findViewById(R.id.erase_external_container);
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index 0b6fe89..741bfda 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -67,8 +67,7 @@
     public static class AccessibilityInversionSettingsActivity extends SettingsActivity { /* empty */ }
     public static class AccessibilityContrastSettingsActivity extends SettingsActivity { /* empty */ }
     public static class AccessibilityDaltonizerSettingsActivity extends SettingsActivity { /* empty */ }
-    public static class SecuritySettingsActivity extends SettingsActivity { /* empty */ }
-    public static class SecuritySettingsActivityV2 extends SettingsActivity { /* empty */ }
+    public static class SecurityDashboardActivity extends SettingsActivity { /* empty */ }
     public static class UsageAccessSettingsActivity extends SettingsActivity { /* empty */ }
     public static class LocationSettingsActivity extends SettingsActivity { /* empty */ }
     public static class PrivacySettingsActivity extends SettingsActivity { /* empty */ }
@@ -97,6 +96,7 @@
     public static class ZenAccessSettingsActivity extends SettingsActivity { /* empty */ }
     public static class ConditionProviderSettingsActivity extends SettingsActivity { /* empty */ }
     public static class UsbSettingsActivity extends SettingsActivity { /* empty */ }
+    public static class UsbDetailsActivity extends SettingsActivity { /* empty */ }
     public static class TrustedCredentialsSettingsActivity extends SettingsActivity { /* empty */ }
     public static class PaymentSettingsActivity extends SettingsActivity { /* empty */ }
     public static class PrintSettingsActivity extends SettingsActivity { /* empty */ }
@@ -109,7 +109,6 @@
     public static class ZenModeExternalRuleSettingsActivity extends SettingsActivity { /* empty */ }
     public static class SoundSettingsActivity extends SettingsActivity { /* empty */ }
     public static class ConfigureNotificationSettingsActivity extends SettingsActivity { /* empty */ }
-    public static class NotificationAppListActivity extends SettingsActivity { /* empty */ }
     public static class AppNotificationSettingsActivity extends SettingsActivity { /* empty */ }
     public static class ChannelNotificationSettingsActivity extends SettingsActivity { /* empty */ }
     public static class ChannelGroupNotificationSettingsActivity extends SettingsActivity { /* empty */ }
diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java
index d4584b7..3c18efb 100644
--- a/src/com/android/settings/SettingsActivity.java
+++ b/src/com/android/settings/SettingsActivity.java
@@ -802,20 +802,6 @@
                 !isConnectedDeviceV2Enabled && !UserManager.isDeviceInDemoMode(this) /* enabled */,
                 isAdmin) || somethingChanged;
 
-        final boolean isSecurityV2Enabled = featureFactory.getSecurityFeatureProvider()
-                .isSecuritySettingsV2Enabled(this);
-
-        // Enable new security page if v2 enabled
-        somethingChanged = setTileEnabled(
-                new ComponentName(packageName,Settings.SecuritySettingsActivityV2.class.getName()),
-                isSecurityV2Enabled,
-                isAdmin) || somethingChanged;
-        // Enable old security page if v2 disabled
-        somethingChanged = setTileEnabled(
-                new ComponentName(packageName,Settings.SecuritySettingsActivity.class.getName()),
-                !isSecurityV2Enabled,
-                isAdmin) || somethingChanged;
-
         somethingChanged = setTileEnabled(new ComponentName(packageName,
                         Settings.SimSettingsActivity.class.getName()),
                 Utils.showSimCardTile(this), isAdmin)
diff --git a/src/com/android/settings/SettingsInitialize.java b/src/com/android/settings/SettingsInitialize.java
index 6b15770..9f2bdcc 100644
--- a/src/com/android/settings/SettingsInitialize.java
+++ b/src/com/android/settings/SettingsInitialize.java
@@ -34,6 +34,8 @@
 import static android.content.pm.PackageManager.GET_RESOLVED_FILTER;
 import static android.content.pm.PackageManager.MATCH_DISABLED_COMPONENTS;
 
+import com.android.settings.shortcut.CreateShortcut;
+
 /**
  * Listens to {@link Intent.ACTION_PRE_BOOT_COMPLETED} and {@link Intent.ACTION_USER_INITIALIZED}
  * performs setup steps for a managed profile (disables the launcher icon of the Settings app,
diff --git a/src/com/android/settings/accounts/AccountDashboardFragment.java b/src/com/android/settings/accounts/AccountDashboardFragment.java
index 65a5ff0..0a4c343 100644
--- a/src/com/android/settings/accounts/AccountDashboardFragment.java
+++ b/src/com/android/settings/accounts/AccountDashboardFragment.java
@@ -91,17 +91,20 @@
                 final BidiFormatter bidiFormatter = BidiFormatter.getInstance();
 
                 CharSequence summary = null;
+                if (types == null || types.length == 0) {
+                    summary = mContext.getString(R.string.account_dashboard_default_summary);
+                } else {
+                    // Show up to 3 account types
+                    final int size = Math.min(3, types.length);
 
-                // Show up to 3 account types
-                final int size = Math.min(3, types.length);
-
-                for (int i = 0; i < size; i++) {
-                    final CharSequence label = authHelper.getLabelForType(mContext, types[i]);
-                    if (summary == null) {
-                        summary = bidiFormatter.unicodeWrap(label);
-                    } else {
-                        summary = mContext.getString(R.string.join_many_items_middle, summary,
-                                bidiFormatter.unicodeWrap(label));
+                    for (int i = 0; i < size; i++) {
+                        final CharSequence label = authHelper.getLabelForType(mContext, types[i]);
+                        if (summary == null) {
+                            summary = bidiFormatter.unicodeWrap(label);
+                        } else {
+                            summary = mContext.getString(R.string.join_many_items_middle, summary,
+                                    bidiFormatter.unicodeWrap(label));
+                        }
                     }
                 }
                 mSummaryLoader.setSummary(this, summary);
diff --git a/src/com/android/settings/applications/InstalledAppDetails.java b/src/com/android/settings/applications/InstalledAppDetails.java
deleted file mode 100755
index f78459f..0000000
--- a/src/com/android/settings/applications/InstalledAppDetails.java
+++ /dev/null
@@ -1,1478 +0,0 @@
-/*
- * Copyright (C) 2007 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 static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
-
-import android.Manifest.permission;
-import android.app.Activity;
-import android.app.ActivityManager;
-import android.app.AlertDialog;
-import android.app.LoaderManager;
-import android.app.LoaderManager.LoaderCallbacks;
-import android.content.ActivityNotFoundException;
-import android.content.BroadcastReceiver;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.content.Loader;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager;
-import android.content.pm.PackageManager.NameNotFoundException;
-import android.content.pm.ResolveInfo;
-import android.content.pm.UserInfo;
-import android.content.res.Resources;
-import android.icu.text.ListFormatter;
-import android.net.INetworkStatsService;
-import android.net.INetworkStatsSession;
-import android.net.NetworkTemplate;
-import android.net.TrafficStats;
-import android.net.Uri;
-import android.os.AsyncTask;
-import android.os.BatteryStats;
-import android.os.Bundle;
-import android.os.RemoteException;
-import android.os.ServiceManager;
-import android.os.UserHandle;
-import android.os.UserManager;
-import android.support.annotation.VisibleForTesting;
-import android.support.v7.preference.Preference;
-import android.support.v7.preference.Preference.OnPreferenceClickListener;
-import android.support.v7.preference.PreferenceCategory;
-import android.support.v7.preference.PreferenceScreen;
-import android.text.BidiFormatter;
-import android.text.TextUtils;
-import android.text.format.DateUtils;
-import android.text.format.Formatter;
-import android.util.Log;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.MenuItem;
-import android.view.View;
-import android.webkit.IWebViewUpdateService;
-
-import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.internal.os.BatterySipper;
-import com.android.internal.os.BatteryStatsHelper;
-import com.android.settings.DeviceAdminAdd;
-import com.android.settings.R;
-import com.android.settings.SettingsActivity;
-import com.android.settings.SettingsPreferenceFragment;
-import com.android.settings.Utils;
-import com.android.settings.applications.appinfo.AppInfoDashboardFragment;
-import com.android.settings.applications.appinfo.DrawOverlayDetails;
-import com.android.settings.applications.appinfo.ExternalSourcesDetails;
-import com.android.settings.applications.appinfo.PictureInPictureDetails;
-import com.android.settings.applications.appinfo.PictureInPictureSettings;
-import com.android.settings.applications.appinfo.WriteSettingsDetails;
-import com.android.settings.applications.defaultapps.DefaultBrowserPreferenceController;
-import com.android.settings.applications.defaultapps.DefaultEmergencyPreferenceController;
-import com.android.settings.applications.defaultapps.DefaultHomePreferenceController;
-import com.android.settings.applications.defaultapps.DefaultPhonePreferenceController;
-import com.android.settings.applications.defaultapps.DefaultSmsPreferenceController;
-import com.android.settings.applications.instantapps.InstantAppButtonsController;
-import com.android.settings.datausage.AppDataUsage;
-import com.android.settings.datausage.DataUsageList;
-import com.android.settings.datausage.DataUsageUtils;
-import com.android.settings.fuelgauge.AdvancedPowerUsageDetail;
-import com.android.settings.fuelgauge.BatteryEntry;
-import com.android.settings.fuelgauge.BatteryStatsHelperLoader;
-import com.android.settings.fuelgauge.BatteryUtils;
-import com.android.settings.notification.AppNotificationSettings;
-import com.android.settings.notification.NotificationBackend;
-import com.android.settings.notification.NotificationBackend.AppRow;
-import com.android.settings.widget.ActionButtonPreference;
-import com.android.settings.widget.EntityHeaderController;
-import com.android.settingslib.AppItem;
-import com.android.settingslib.RestrictedLockUtils;
-import com.android.settingslib.applications.AppUtils;
-import com.android.settingslib.applications.ApplicationsState;
-import com.android.settingslib.applications.ApplicationsState.AppEntry;
-import com.android.settingslib.applications.PermissionsSummaryHelper;
-import com.android.settingslib.applications.PermissionsSummaryHelper.PermissionsResultCallback;
-import com.android.settingslib.applications.StorageStatsSource;
-import com.android.settingslib.applications.StorageStatsSource.AppStorageStats;
-import com.android.settingslib.development.DevelopmentSettingsEnabler;
-import com.android.settingslib.net.ChartData;
-import com.android.settingslib.net.ChartDataLoader;
-import com.android.settingslib.wrapper.PackageManagerWrapper;
-
-import java.lang.ref.WeakReference;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-/**
- * Activity to display application information from Settings. This activity presents
- * extended information associated with a package like code, data, total size, permissions
- * used by the application and also the set of default launchable activities.
- * For system applications, an option to clear user data is displayed only if data size is > 0.
- * System applications that do not want clear user data do not have this option.
- * For non-system applications, there is no option to clear data. Instead there is an option to
- * uninstall the application.
- *
- * deprecated in favor of {@link AppInfoDashboardFragment}
- */
-@Deprecated
-public class InstalledAppDetails extends AppInfoBase
-        implements OnPreferenceClickListener, LoaderManager.LoaderCallbacks<AppStorageStats> {
-
-    private static final String LOG_TAG = "InstalledAppDetails";
-
-    // Menu identifiers
-    public static final int UNINSTALL_ALL_USERS_MENU = 1;
-    public static final int UNINSTALL_UPDATES = 2;
-
-    // Result code identifiers
-    public static final int REQUEST_UNINSTALL = 0;
-    private static final int REQUEST_REMOVE_DEVICE_ADMIN = 1;
-
-    private static final int SUB_INFO_FRAGMENT = 1;
-
-    private static final int LOADER_CHART_DATA = 2;
-    private static final int LOADER_STORAGE = 3;
-    @VisibleForTesting
-    static final int LOADER_BATTERY = 4;
-
-    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 String EXTRA_HIDE_INFO_BUTTON = "hideInfoButton";
-    private static final String KEY_HEADER = "header_view";
-    private static final String KEY_INSTANT_APP_BUTTONS = "instant_app_buttons";
-    private static final String KEY_ACTION_BUTTONS = "action_buttons";
-    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";
-    private static final String KEY_BATTERY = "battery";
-    private static final String KEY_MEMORY = "memory";
-    private static final String KEY_VERSION = "app_version";
-    private static final String KEY_INSTANT_APP_SUPPORTED_LINKS =
-            "instant_app_launch_supported_domain_urls";
-
-    private final HashSet<String> mHomePackages = new HashSet<>();
-
-    private boolean mInitialized;
-    private boolean mShowUninstalled;
-    private LayoutPreference mHeader;
-    private boolean mUpdatedSysApp = false;
-    private Preference mNotificationPreference;
-    private Preference mStoragePreference;
-    private Preference mPermissionsPreference;
-    private Preference mLaunchPreference;
-    private Preference mDataPreference;
-    private Preference mMemoryPreference;
-    private Preference mVersionPreference;
-    private AppDomainsPreference mInstantAppDomainsPreference;
-    private boolean mDisableAfterUninstall;
-
-    // Used for updating notification preference.
-    private final NotificationBackend mBackend = new NotificationBackend();
-
-    private ChartData mChartData;
-    private INetworkStatsSession mStatsSession;
-
-    @VisibleForTesting
-    ActionButtonPreference mActionButtons;
-    @VisibleForTesting
-    Preference mBatteryPreference;
-    @VisibleForTesting
-    BatterySipper mSipper;
-    @VisibleForTesting
-    BatteryStatsHelper mBatteryHelper;
-    @VisibleForTesting
-    BatteryUtils mBatteryUtils;
-
-    protected ProcStatsData mStatsManager;
-    protected ProcStatsPackageEntry mStats;
-
-    private InstantAppButtonsController mInstantAppButtonsController;
-
-    private AppStorageStats mLastResult;
-    private String mBatteryPercent;
-
-    @VisibleForTesting
-    final LoaderCallbacks<BatteryStatsHelper> mBatteryCallbacks =
-            new LoaderCallbacks<BatteryStatsHelper>() {
-
-                @Override
-                public Loader<BatteryStatsHelper> onCreateLoader(int id, Bundle args) {
-                    return new BatteryStatsHelperLoader(getContext());
-                }
-
-                @Override
-                public void onLoadFinished(Loader<BatteryStatsHelper> loader,
-                        BatteryStatsHelper batteryHelper) {
-                    mBatteryHelper = batteryHelper;
-                    if (mPackageInfo != null) {
-                        mSipper = findTargetSipper(batteryHelper, mPackageInfo.applicationInfo.uid);
-                        if (getActivity() != null) {
-                            updateBattery();
-                        }
-                    }
-                }
-
-                @Override
-                public void onLoaderReset(Loader<BatteryStatsHelper> loader) {
-                }
-            };
-
-    @VisibleForTesting
-    boolean handleDisableable() {
-        boolean disableable = false;
-        // Try to prevent the user from bricking their phone
-        // by not allowing disabling of apps signed with the
-        // system cert and any launcher app in the system.
-        if (mHomePackages.contains(mAppEntry.info.packageName)
-                || Utils.isSystemPackage(getContext().getResources(), mPm, mPackageInfo)) {
-            // Disable button for core system applications.
-            mActionButtons
-                    .setButton1Text(R.string.disable_text)
-                    .setButton1Positive(false);
-        } else if (mAppEntry.info.enabled && !isDisabledUntilUsed()) {
-            mActionButtons
-                    .setButton1Text(R.string.disable_text)
-                    .setButton1Positive(false);
-            disableable = !mApplicationFeatureProvider.getKeepEnabledPackages()
-                    .contains(mAppEntry.info.packageName);
-        } else {
-            mActionButtons
-                    .setButton1Text(R.string.enable_text)
-                    .setButton1Positive(true);
-            disableable = true;
-        }
-
-        return disableable;
-    }
-
-    private boolean isDisabledUntilUsed() {
-        return mAppEntry.info.enabledSetting
-                == PackageManager.COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED;
-    }
-
-    private void initUninstallButtons() {
-        final boolean isBundled = (mAppEntry.info.flags & ApplicationInfo.FLAG_SYSTEM) != 0;
-        boolean enabled;
-        if (isBundled) {
-            enabled = handleDisableable();
-        } else {
-            enabled = initUninstallButtonForUserApp();
-        }
-        // If this is a device admin, it can't be uninstalled or disabled.
-        // We do this here so the text of the button is still set correctly.
-        if (isBundled && mDpm.packageHasActiveAdmins(mPackageInfo.packageName)) {
-            enabled = false;
-        }
-
-        // We don't allow uninstalling DO/PO on *any* users, because if it's a system app,
-        // "uninstall" is actually "downgrade to the system version + disable", and "downgrade"
-        // will clear data on all users.
-        if (Utils.isProfileOrDeviceOwner(mUserManager, mDpm, mPackageInfo.packageName)) {
-            enabled = false;
-        }
-
-        // Don't allow uninstalling the device provisioning package.
-        if (Utils.isDeviceProvisioningPackage(getResources(), mAppEntry.info.packageName)) {
-            enabled = false;
-        }
-
-        // If the uninstall intent is already queued, disable the uninstall button
-        if (mDpm.isUninstallInQueue(mPackageName)) {
-            enabled = false;
-        }
-
-        // Home apps need special handling.  Bundled ones we don't risk downgrading
-        // because that can interfere with home-key resolution.  Furthermore, we
-        // can't allow uninstallation of the only home app, and we don't want to
-        // allow uninstallation of an explicitly preferred one -- the user can go
-        // to Home settings and pick a different one, after which we'll permit
-        // uninstallation of the now-not-default one.
-        if (enabled && mHomePackages.contains(mPackageInfo.packageName)) {
-            if (isBundled) {
-                enabled = false;
-            } else {
-                ArrayList<ResolveInfo> homeActivities = new ArrayList<ResolveInfo>();
-                ComponentName currentDefaultHome  = mPm.getHomeActivities(homeActivities);
-                if (currentDefaultHome == null) {
-                    // No preferred default, so permit uninstall only when
-                    // there is more than one candidate
-                    enabled = (mHomePackages.size() > 1);
-                } else {
-                    // There is an explicit default home app -- forbid uninstall of
-                    // that one, but permit it for installed-but-inactive ones.
-                    enabled = !mPackageInfo.packageName.equals(currentDefaultHome.getPackageName());
-                }
-            }
-        }
-
-        if (mAppsControlDisallowedBySystem) {
-            enabled = false;
-        }
-
-        try {
-            IWebViewUpdateService webviewUpdateService =
-                IWebViewUpdateService.Stub.asInterface(ServiceManager.getService("webviewupdate"));
-            if (webviewUpdateService.isFallbackPackage(mAppEntry.info.packageName)) {
-                enabled = false;
-            }
-        } catch (RemoteException e) {
-            throw new RuntimeException(e);
-        }
-
-        mActionButtons.setButton1Enabled(enabled);
-        if (enabled) {
-            // Register listener
-            mActionButtons.setButton1OnClickListener(v -> handleUninstallButtonClick());
-        }
-    }
-
-    @VisibleForTesting
-    boolean initUninstallButtonForUserApp() {
-        boolean enabled = true;
-        if ((mPackageInfo.applicationInfo.flags & ApplicationInfo.FLAG_INSTALLED) == 0
-                && mUserManager.getUsers().size() >= 2) {
-            // When we have multiple users, there is a separate menu
-            // to uninstall for all users.
-            enabled = false;
-        } else if (AppUtils.isInstant(mPackageInfo.applicationInfo)) {
-            enabled = false;
-            mActionButtons.setButton1Visible(false);
-        }
-        mActionButtons.setButton1Text(R.string.uninstall_text).setButton1Positive(false);
-        return enabled;
-    }
-
-    /** Called when the activity is first created. */
-    @Override
-    public void onCreate(Bundle icicle) {
-        super.onCreate(icicle);
-        final Activity activity = getActivity();
-
-        if (!ensurePackageInfoAvailable(activity)) {
-            return;
-        }
-
-        setHasOptionsMenu(true);
-        addPreferencesFromResource(R.xml.installed_app_details);
-
-        addDynamicPrefs();
-        if (Utils.isBandwidthControlEnabled()) {
-            INetworkStatsService statsService = INetworkStatsService.Stub.asInterface(
-                    ServiceManager.getService(Context.NETWORK_STATS_SERVICE));
-            try {
-                mStatsSession = statsService.openSession();
-            } catch (RemoteException e) {
-                throw new RuntimeException(e);
-            }
-        } else {
-            removePreference(KEY_DATA);
-        }
-        mBatteryUtils = BatteryUtils.getInstance(getContext());
-    }
-
-    @Override
-    public int getMetricsCategory() {
-        return MetricsEvent.APPLICATIONS_INSTALLED_APP_DETAILS;
-    }
-
-    @Override
-    public void onResume() {
-        super.onResume();
-        if (mFinishing) {
-            return;
-        }
-        AppItem app = new AppItem(mAppEntry.info.uid);
-        app.addUid(mAppEntry.info.uid);
-        if (mStatsSession != null) {
-            LoaderManager loaderManager = getLoaderManager();
-            loaderManager.restartLoader(LOADER_CHART_DATA,
-                    ChartDataLoader.buildArgs(getTemplate(getContext()), app),
-                    mDataCallbacks);
-            loaderManager.restartLoader(LOADER_STORAGE, Bundle.EMPTY, this);
-        }
-        restartBatteryStatsLoader();
-        if (DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(getContext())) {
-            new MemoryUpdater().execute();
-        }
-        updateDynamicPrefs();
-    }
-
-    @VisibleForTesting
-    public void restartBatteryStatsLoader() {
-        getLoaderManager().restartLoader(LOADER_BATTERY, Bundle.EMPTY, mBatteryCallbacks);
-    }
-
-    @Override
-    public void onPause() {
-        getLoaderManager().destroyLoader(LOADER_CHART_DATA);
-        super.onPause();
-    }
-
-    @Override
-    public void onDestroy() {
-        TrafficStats.closeQuietly(mStatsSession);
-        super.onDestroy();
-    }
-
-    public void onActivityCreated(Bundle savedInstanceState) {
-        super.onActivityCreated(savedInstanceState);
-        if (mFinishing) {
-            return;
-        }
-        final Activity activity = getActivity();
-        mHeader = (LayoutPreference) findPreference(KEY_HEADER);
-        mActionButtons = ((ActionButtonPreference) findPreference(KEY_ACTION_BUTTONS))
-                .setButton2Text(R.string.force_stop)
-                .setButton2Positive(false)
-                .setButton2Enabled(false);
-        EntityHeaderController.newInstance(activity, this, mHeader.findViewById(R.id.entity_header))
-                .setRecyclerView(getListView(), getLifecycle())
-                .setPackageName(mPackageName)
-                .setHasAppInfoLink(false)
-                .setButtonActions(EntityHeaderController.ActionType.ACTION_APP_PREFERENCE,
-                        EntityHeaderController.ActionType.ACTION_NONE)
-                .styleActionBar(activity)
-                .bindHeaderButtons();
-
-        mNotificationPreference = findPreference(KEY_NOTIFICATION);
-        mNotificationPreference.setOnPreferenceClickListener(this);
-        mStoragePreference = findPreference(KEY_STORAGE);
-        mStoragePreference.setOnPreferenceClickListener(this);
-        mPermissionsPreference = findPreference(KEY_PERMISSION);
-        mPermissionsPreference.setOnPreferenceClickListener(this);
-        mDataPreference = findPreference(KEY_DATA);
-        if (mDataPreference != null) {
-            mDataPreference.setOnPreferenceClickListener(this);
-        }
-        mBatteryPreference = findPreference(KEY_BATTERY);
-        mBatteryPreference.setEnabled(false);
-        mBatteryPreference.setOnPreferenceClickListener(this);
-        mMemoryPreference = findPreference(KEY_MEMORY);
-        mMemoryPreference.setOnPreferenceClickListener(this);
-        mMemoryPreference.setVisible(
-                DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(getContext()));
-        mVersionPreference = findPreference(KEY_VERSION);
-        mInstantAppDomainsPreference =
-                (AppDomainsPreference) findPreference(KEY_INSTANT_APP_SUPPORTED_LINKS);
-        mLaunchPreference = findPreference(KEY_LAUNCH);
-        if (mAppEntry != null && mAppEntry.info != null) {
-            if ((mAppEntry.info.flags&ApplicationInfo.FLAG_INSTALLED) == 0 ||
-                    !mAppEntry.info.enabled) {
-                mLaunchPreference.setEnabled(false);
-            } else {
-                mLaunchPreference.setOnPreferenceClickListener(this);
-            }
-        } else {
-            mLaunchPreference.setEnabled(false);
-        }
-    }
-
-    @Override
-    public void onPackageSizeChanged(String packageName) {
-        if (!TextUtils.equals(packageName, mPackageName)) {
-            Log.d(LOG_TAG, "Package change irrelevant, skipping");
-          return;
-        }
-        refreshUi();
-    }
-
-    /**
-     * Ensures the {@link PackageInfo} is available to proceed. If it's not available, the fragment
-     * will finish.
-     *
-     * @return true if packageInfo is available.
-     */
-    @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
-    boolean ensurePackageInfoAvailable(Activity activity) {
-        if (mPackageInfo == null) {
-            mFinishing = true;
-            Log.w(LOG_TAG, "Package info not available. Is this package already uninstalled?");
-            activity.finishAndRemoveTask();
-            return false;
-        }
-        return true;
-    }
-
-    @Override
-    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
-        super.onCreateOptionsMenu(menu, inflater);
-        menu.add(0, UNINSTALL_UPDATES, 0, R.string.app_factory_reset)
-                .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
-        menu.add(0, UNINSTALL_ALL_USERS_MENU, 1, R.string.uninstall_all_users_text)
-                .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
-    }
-
-    @Override
-    public void onPrepareOptionsMenu(Menu menu) {
-        if (mFinishing) {
-            return;
-        }
-        menu.findItem(UNINSTALL_ALL_USERS_MENU).setVisible(shouldShowUninstallForAll(mAppEntry));
-        mUpdatedSysApp = (mAppEntry.info.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0;
-        MenuItem uninstallUpdatesItem = menu.findItem(UNINSTALL_UPDATES);
-        uninstallUpdatesItem.setVisible(mUpdatedSysApp && !mAppsControlDisallowedBySystem);
-        if (uninstallUpdatesItem.isVisible()) {
-            RestrictedLockUtils.setMenuItemAsDisabledByAdmin(getActivity(),
-                    uninstallUpdatesItem, mAppsControlDisallowedAdmin);
-        }
-    }
-
-    @Override
-    public boolean onOptionsItemSelected(MenuItem item) {
-        switch (item.getItemId()) {
-            case UNINSTALL_ALL_USERS_MENU:
-                uninstallPkg(mAppEntry.info.packageName, true, false);
-                return true;
-            case UNINSTALL_UPDATES:
-                uninstallPkg(mAppEntry.info.packageName, false, false);
-                return true;
-        }
-        return false;
-    }
-
-    @Override
-    public void onActivityResult(int requestCode, int resultCode, Intent data) {
-        super.onActivityResult(requestCode, resultCode, data);
-        switch (requestCode) {
-            case REQUEST_UNINSTALL:
-                // Refresh option menu
-                getActivity().invalidateOptionsMenu();
-
-                if (mDisableAfterUninstall) {
-                    mDisableAfterUninstall = false;
-                    new DisableChanger(this, mAppEntry.info,
-                            PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER)
-                            .execute((Object)null);
-                }
-                // continue with following operations
-            case REQUEST_REMOVE_DEVICE_ADMIN:
-                if (!refreshUi()) {
-                    setIntentAndFinish(true, true);
-                } else {
-                    startListeningToPackageRemove();
-                }
-                break;
-        }
-    }
-
-    @Override
-    public Loader<AppStorageStats> onCreateLoader(int id, Bundle args) {
-        Context context = getContext();
-        return new FetchPackageStorageAsyncLoader(
-                context, new StorageStatsSource(context), mAppEntry.info, UserHandle.of(mUserId));
-    }
-
-    @Override
-    public void onLoadFinished(Loader<AppStorageStats> loader, AppStorageStats result) {
-        mLastResult = result;
-        refreshUi();
-    }
-
-    @Override
-    public void onLoaderReset(Loader<AppStorageStats> loader) {
-    }
-
-    /**
-     * Utility method to hide and show specific preferences based on whether the app being displayed
-     * is an Instant App or an installed app.
-     */
-    @VisibleForTesting
-    void prepareInstantAppPrefs() {
-        final boolean isInstant = AppUtils.isInstant(mPackageInfo.applicationInfo);
-        if (isInstant) {
-            Set<String> handledDomainSet = Utils.getHandledDomains(mPm, mPackageInfo.packageName);
-            String[] handledDomains = handledDomainSet.toArray(new String[handledDomainSet.size()]);
-            mInstantAppDomainsPreference.setTitles(handledDomains);
-            // Dummy values, unused in the implementation
-            mInstantAppDomainsPreference.setValues(new int[handledDomains.length]);
-            getPreferenceScreen().removePreference(mLaunchPreference);
-        } else {
-            getPreferenceScreen().removePreference(mInstantAppDomainsPreference);
-        }
-    }
-
-    // Utility method to set application label and icon.
-    private void setAppLabelAndIcon(PackageInfo pkgInfo) {
-        final View appSnippet = mHeader.findViewById(R.id.entity_header);
-        mState.ensureIcon(mAppEntry);
-        final Activity activity = getActivity();
-        final boolean isInstantApp = AppUtils.isInstant(mPackageInfo.applicationInfo);
-        final CharSequence summary =
-                isInstantApp ? null : getString(Utils.getInstallationStatus(mAppEntry.info));
-        EntityHeaderController.newInstance(activity, this, appSnippet)
-                .setLabel(mAppEntry)
-                .setIcon(mAppEntry)
-                .setSummary(summary)
-                .setIsInstantApp(isInstantApp)
-                .done(activity, false /* rebindActions */);
-        mVersionPreference.setSummary(getString(R.string.version_text,
-                BidiFormatter.getInstance().unicodeWrap(pkgInfo.versionName)));
-    }
-
-    @VisibleForTesting
-    boolean shouldShowUninstallForAll(ApplicationsState.AppEntry appEntry) {
-        boolean showIt = true;
-        if (mUpdatedSysApp) {
-            showIt = false;
-        } else if (appEntry == null) {
-            showIt = false;
-        } else if ((appEntry.info.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
-            showIt = false;
-        } else if (mPackageInfo == null || mDpm.packageHasActiveAdmins(mPackageInfo.packageName)) {
-            showIt = false;
-        } else if (UserHandle.myUserId() != 0) {
-            showIt = false;
-        } else if (mUserManager.getUsers().size() < 2) {
-            showIt = false;
-        } else if (PackageUtil.countPackageInUsers(mPm, mUserManager, mPackageName) < 2
-                && (appEntry.info.flags & ApplicationInfo.FLAG_INSTALLED) != 0) {
-            showIt = false;
-        } else if (AppUtils.isInstant(appEntry.info)) {
-            showIt = false;
-        }
-        return showIt;
-    }
-
-    @VisibleForTesting
-    BatterySipper findTargetSipper(BatteryStatsHelper batteryHelper, int uid) {
-        List<BatterySipper> usageList = batteryHelper.getUsageList();
-        for (int i = 0, size = usageList.size(); i < size; i++) {
-            BatterySipper sipper = usageList.get(i);
-            if (sipper.getUid() == uid) {
-                return sipper;
-            }
-        }
-
-        return null;
-    }
-
-    private boolean signaturesMatch(String pkg1, String pkg2) {
-        if (pkg1 != null && pkg2 != null) {
-            try {
-                final int match = mPm.checkSignatures(pkg1, pkg2);
-                if (match >= PackageManager.SIGNATURE_MATCH) {
-                    return true;
-                }
-            } catch (Exception e) {
-                // e.g. named alternate package not found during lookup;
-                // this is an expected case sometimes
-            }
-        }
-        return false;
-    }
-
-    @Override
-    protected boolean refreshUi() {
-        retrieveAppEntry();
-        if (mAppEntry == null) {
-            return false; // onCreate must have failed, make sure to exit
-        }
-
-        if (mPackageInfo == null) {
-            return false; // onCreate must have failed, make sure to exit
-        }
-
-        // Get list of "home" apps and trace through any meta-data references
-        List<ResolveInfo> homeActivities = new ArrayList<ResolveInfo>();
-        mPm.getHomeActivities(homeActivities);
-        mHomePackages.clear();
-        for (int i = 0; i< homeActivities.size(); i++) {
-            ResolveInfo ri = homeActivities.get(i);
-            final String activityPkg = ri.activityInfo.packageName;
-            mHomePackages.add(activityPkg);
-
-            // Also make sure to include anything proxying for the home app
-            final Bundle metadata = ri.activityInfo.metaData;
-            if (metadata != null) {
-                final String metaPkg = metadata.getString(ActivityManager.META_HOME_ALTERNATE);
-                if (signaturesMatch(metaPkg, activityPkg)) {
-                    mHomePackages.add(metaPkg);
-                }
-            }
-        }
-
-        checkForceStop();
-        setAppLabelAndIcon(mPackageInfo);
-        initUninstallButtons();
-        prepareInstantAppPrefs();
-
-        // Update the preference summaries.
-        Activity context = getActivity();
-        boolean isExternal = ((mAppEntry.info.flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0);
-        mStoragePreference.setSummary(getStorageSummary(context, mLastResult, isExternal));
-
-        PermissionsSummaryHelper.getPermissionSummary(getContext(),
-                mPackageName, mPermissionCallback);
-        mLaunchPreference.setSummary(AppUtils.getLaunchByDefaultSummary(mAppEntry, mUsbManager,
-                mPm, context));
-        mNotificationPreference.setSummary(getNotificationSummary(mAppEntry, context,
-                mBackend));
-        if (mDataPreference != null) {
-            mDataPreference.setSummary(getDataSummary());
-        }
-
-        if (!mInitialized) {
-            // First time init: are we displaying an uninstalled app?
-            mInitialized = true;
-            mShowUninstalled = (mAppEntry.info.flags&ApplicationInfo.FLAG_INSTALLED) == 0;
-        } else {
-            // All other times: if the app no longer exists then we want
-            // to go away.
-            try {
-                ApplicationInfo ainfo = context.getPackageManager().getApplicationInfo(
-                        mAppEntry.info.packageName,
-                        PackageManager.MATCH_DISABLED_COMPONENTS
-                        | PackageManager.MATCH_ANY_USER);
-                if (!mShowUninstalled) {
-                    // If we did not start out with the app uninstalled, then
-                    // it transitioning to the uninstalled state for the current
-                    // user means we should go away as well.
-                    return (ainfo.flags&ApplicationInfo.FLAG_INSTALLED) != 0;
-                }
-            } catch (NameNotFoundException e) {
-                return false;
-            }
-        }
-
-        return true;
-    }
-
-    @VisibleForTesting
-    void updateBattery() {
-        mBatteryPreference.setEnabled(true);
-        if (isBatteryStatsAvailable()) {
-            final int dischargeAmount = mBatteryHelper.getStats().getDischargeAmount(
-                    BatteryStats.STATS_SINCE_CHARGED);
-
-            final List<BatterySipper> usageList = new ArrayList<>(mBatteryHelper.getUsageList());
-            final double hiddenAmount = mBatteryUtils.removeHiddenBatterySippers(usageList);
-            final int percentOfMax = (int) mBatteryUtils.calculateBatteryPercent(
-                    mSipper.totalPowerMah, mBatteryHelper.getTotalPower(), hiddenAmount,
-                    dischargeAmount);
-            mBatteryPercent = Utils.formatPercentage(percentOfMax);
-            mBatteryPreference.setSummary(getString(R.string.battery_summary, mBatteryPercent));
-        } else {
-            mBatteryPreference.setSummary(getString(R.string.no_battery_summary));
-        }
-    }
-
-    private CharSequence getDataSummary() {
-        if (mChartData != null) {
-            long totalBytes = mChartData.detail.getTotalBytes();
-            if (totalBytes == 0) {
-                return getString(R.string.no_data_usage);
-            }
-            Context context = getActivity();
-            return getString(R.string.data_summary_format,
-                    Formatter.formatFileSize(context, totalBytes),
-                    DateUtils.formatDateTime(context, mChartData.detail.getStart(),
-                            DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_MONTH));
-        }
-        return getString(R.string.computing_size);
-    }
-
-    @VisibleForTesting
-    static CharSequence getStorageSummary(
-            Context context, AppStorageStats stats, boolean isExternal) {
-        if (stats == null) {
-            return context.getText(R.string.computing_size);
-        } else {
-            CharSequence storageType = context.getString(isExternal
-                    ? R.string.storage_type_external
-                    : R.string.storage_type_internal);
-            return context.getString(R.string.storage_summary_format,
-                    getSize(context, stats), storageType.toString().toLowerCase());
-        }
-    }
-
-    @VisibleForTesting
-    boolean isBatteryStatsAvailable() {
-        return mBatteryHelper != null && mSipper != null;
-    }
-
-    private static CharSequence getSize(Context context, AppStorageStats stats) {
-        return Formatter.formatFileSize(context, stats.getTotalBytes());
-    }
-
-
-    @Override
-    protected AlertDialog createDialog(int id, int errorCode) {
-        switch (id) {
-            case DLG_DISABLE:
-                return new AlertDialog.Builder(getActivity())
-                        .setMessage(getActivity().getText(R.string.app_disable_dlg_text))
-                        .setPositiveButton(R.string.app_disable_dlg_positive,
-                                new DialogInterface.OnClickListener() {
-                            public void onClick(DialogInterface dialog, int which) {
-                                // Disable the app
-                                mMetricsFeatureProvider.action(getContext(),
-                                        MetricsEvent.ACTION_SETTINGS_DISABLE_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())
-                        .setMessage(getActivity().getText(R.string.app_disable_dlg_text))
-                        .setPositiveButton(R.string.app_disable_dlg_positive,
-                                new DialogInterface.OnClickListener() {
-                            public void onClick(DialogInterface dialog, int which) {
-                                // Disable the app and ask for uninstall
-                                mMetricsFeatureProvider.action(getContext(),
-                                        MetricsEvent.ACTION_SETTINGS_DISABLE_APP);
-                                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();
-        }
-        if (mInstantAppButtonsController != null) {
-            return mInstantAppButtonsController.createDialog(id);
-        }
-        return null;
-    }
-
-    private void uninstallPkg(String packageName, boolean allUsers, boolean andDisable) {
-        stopListeningToPackageRemove();
-         // Create new intent to launch Uninstaller activity
-        Uri packageURI = Uri.parse("package:"+packageName);
-        Intent uninstallIntent = new Intent(Intent.ACTION_UNINSTALL_PACKAGE, packageURI);
-        uninstallIntent.putExtra(Intent.EXTRA_UNINSTALL_ALL_USERS, allUsers);
-        mMetricsFeatureProvider.action(
-                getContext(), MetricsEvent.ACTION_SETTINGS_UNINSTALL_APP);
-        startActivityForResult(uninstallIntent, REQUEST_UNINSTALL);
-        mDisableAfterUninstall = andDisable;
-    }
-
-    private void forceStopPackage(String pkgName) {
-        mMetricsFeatureProvider.action(getContext(), MetricsEvent.ACTION_APP_FORCE_STOP, pkgName);
-        ActivityManager am = (ActivityManager) getActivity().getSystemService(
-                Context.ACTIVITY_SERVICE);
-        Log.d(LOG_TAG, "Stopping package " + pkgName);
-        am.forceStopPackage(pkgName);
-        int userId = UserHandle.getUserId(mAppEntry.info.uid);
-        mState.invalidatePackage(pkgName, userId);
-        ApplicationsState.AppEntry newEnt = mState.getEntry(pkgName, userId);
-        if (newEnt != null) {
-            mAppEntry = newEnt;
-        }
-        checkForceStop();
-    }
-
-    private void updateForceStopButton(boolean enabled) {
-        mActionButtons
-                .setButton2Enabled(mAppsControlDisallowedBySystem ? false : enabled)
-                .setButton2OnClickListener(mAppsControlDisallowedBySystem
-                        ? null : v -> handleForceStopButtonClick());
-    }
-
-    @VisibleForTesting
-    void checkForceStop() {
-        if (mDpm.packageHasActiveAdmins(mPackageInfo.packageName)) {
-            // User can't force stop device admin.
-            Log.w(LOG_TAG, "User can't force stop device admin");
-            updateForceStopButton(false);
-        } else if (AppUtils.isInstant(mPackageInfo.applicationInfo)) {
-            updateForceStopButton(false);
-            mActionButtons.setButton2Visible(false);
-        } else if ((mAppEntry.info.flags & ApplicationInfo.FLAG_STOPPED) == 0) {
-            // If the app isn't explicitly stopped, then always show the
-            // force stop button.
-            Log.w(LOG_TAG, "App is not explicitly stopped");
-            updateForceStopButton(true);
-        } else {
-            Intent intent = new Intent(Intent.ACTION_QUERY_PACKAGE_RESTART,
-                    Uri.fromParts("package", mAppEntry.info.packageName, null));
-            intent.putExtra(Intent.EXTRA_PACKAGES, new String[] { mAppEntry.info.packageName });
-            intent.putExtra(Intent.EXTRA_UID, mAppEntry.info.uid);
-            intent.putExtra(Intent.EXTRA_USER_HANDLE, UserHandle.getUserId(mAppEntry.info.uid));
-            Log.d(LOG_TAG, "Sending broadcast to query restart status for "
-                    + mAppEntry.info.packageName);
-            getActivity().sendOrderedBroadcastAsUser(intent, UserHandle.CURRENT, null,
-                    mCheckKillProcessesReceiver, null, Activity.RESULT_CANCELED, null, null);
-        }
-    }
-
-    private void startManagePermissionsActivity() {
-        // start new activity to manage app permissions
-        Intent intent = new Intent(Intent.ACTION_MANAGE_APP_PERMISSIONS);
-        intent.putExtra(Intent.EXTRA_PACKAGE_NAME, mAppEntry.info.packageName);
-        intent.putExtra(EXTRA_HIDE_INFO_BUTTON, true);
-        try {
-            getActivity().startActivityForResult(intent, SUB_INFO_FRAGMENT);
-        } catch (ActivityNotFoundException e) {
-            Log.w(LOG_TAG, "No app can handle android.intent.action.MANAGE_APP_PERMISSIONS");
-        }
-    }
-
-    private void startAppInfoFragment(Class<?> fragment, int title) {
-        startAppInfoFragment(fragment, title, this, mAppEntry);
-    }
-
-    public static void startAppInfoFragment(Class<?> fragment, int title,
-            SettingsPreferenceFragment caller, AppEntry appEntry) {
-        // start new fragment to display extended information
-        Bundle args = new Bundle();
-        args.putString(ARG_PACKAGE_NAME, appEntry.info.packageName);
-        args.putInt(ARG_PACKAGE_UID, appEntry.info.uid);
-
-        SettingsActivity sa = (SettingsActivity) caller.getActivity();
-        sa.startPreferencePanel(caller, fragment.getName(), args, title, null, caller,
-                SUB_INFO_FRAGMENT);
-    }
-
-    private void handleUninstallButtonClick() {
-        if (mAppEntry == null) {
-            setIntentAndFinish(true, true);
-            return;
-        }
-        final String packageName = mAppEntry.info.packageName;
-        if (mDpm.packageHasActiveAdmins(mPackageInfo.packageName)) {
-            stopListeningToPackageRemove();
-            Activity activity = getActivity();
-            Intent uninstallDAIntent = new Intent(activity, DeviceAdminAdd.class);
-            uninstallDAIntent.putExtra(DeviceAdminAdd.EXTRA_DEVICE_ADMIN_PACKAGE_NAME,
-                    mPackageName);
-            mMetricsFeatureProvider.action(
-                    activity, MetricsEvent.ACTION_SETTINGS_UNINSTALL_DEVICE_ADMIN);
-            activity.startActivityForResult(uninstallDAIntent, REQUEST_REMOVE_DEVICE_ADMIN);
-            return;
-        }
-        EnforcedAdmin admin = RestrictedLockUtils.checkIfUninstallBlocked(getActivity(),
-                packageName, mUserId);
-        boolean uninstallBlockedBySystem = mAppsControlDisallowedBySystem ||
-                RestrictedLockUtils.hasBaseUserRestriction(getActivity(), packageName, mUserId);
-        if (admin != null && !uninstallBlockedBySystem) {
-            RestrictedLockUtils.sendShowAdminSupportDetailsIntent(getActivity(), admin);
-        } else if ((mAppEntry.info.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
-            if (mAppEntry.info.enabled && !isDisabledUntilUsed()) {
-                // If the system app has an update and this is the only user on the device,
-                // then offer to downgrade the app, otherwise only offer to disable the
-                // app for this user.
-                if (mUpdatedSysApp && isSingleUser()) {
-                    showDialogInner(DLG_SPECIAL_DISABLE, 0);
-                } else {
-                    showDialogInner(DLG_DISABLE, 0);
-                }
-            } else {
-                mMetricsFeatureProvider.action(
-                        getActivity(),
-                        MetricsEvent.ACTION_SETTINGS_ENABLE_APP);
-                new DisableChanger(this, mAppEntry.info,
-                        PackageManager.COMPONENT_ENABLED_STATE_ENABLED)
-                        .execute((Object) null);
-            }
-        } else if ((mAppEntry.info.flags & ApplicationInfo.FLAG_INSTALLED) == 0) {
-            uninstallPkg(packageName, true, false);
-        } else {
-            uninstallPkg(packageName, false, false);
-        }
-    }
-
-    private void handleForceStopButtonClick() {
-        if (mAppEntry == null) {
-            setIntentAndFinish(true, true);
-            return;
-        }
-        if (mAppsControlDisallowedAdmin != null && !mAppsControlDisallowedBySystem) {
-            RestrictedLockUtils.sendShowAdminSupportDetailsIntent(
-                    getActivity(), mAppsControlDisallowedAdmin);
-        } else {
-            showDialogInner(DLG_FORCE_STOP, 0);
-            //forceStopPackage(mAppInfo.packageName);
-        }
-    }
-
-    /** Returns whether there is only one user on this device, not including the system-only user */
-    private boolean isSingleUser() {
-        final int userCount = mUserManager.getUserCount();
-        return userCount == 1
-                || (mUserManager.isSplitSystemUser() && userCount == 2);
-    }
-
-    @Override
-    public boolean onPreferenceClick(Preference preference) {
-        if (preference == mStoragePreference) {
-            startAppInfoFragment(AppStorageSettings.class, R.string.storage_settings);
-        } else if (preference == mNotificationPreference) {
-            startAppInfoFragment(AppNotificationSettings.class, R.string.app_notifications_title);
-        } else if (preference == mPermissionsPreference) {
-            startManagePermissionsActivity();
-        } else if (preference == mLaunchPreference) {
-            startAppInfoFragment(AppLaunchSettings.class, R.string.launch_by_default);
-        } else if (preference == mMemoryPreference) {
-            ProcessStatsBase.launchMemoryDetail((SettingsActivity) getActivity(),
-                    mStatsManager.getMemInfo(), mStats, false);
-        } else if (preference == mDataPreference) {
-            startAppInfoFragment(AppDataUsage.class, R.string.app_data_usage);
-        } else if (preference == mBatteryPreference) {
-            if (isBatteryStatsAvailable()) {
-                BatteryEntry entry = new BatteryEntry(getContext(), null, mUserManager, mSipper);
-                entry.defaultPackageName = mPackageName;
-                AdvancedPowerUsageDetail.startBatteryDetailPage((SettingsActivity) getActivity(),
-                        this, mBatteryHelper, BatteryStats.STATS_SINCE_CHARGED, entry,
-                        mBatteryPercent, null /* mAnomalies */);
-            } else {
-                AdvancedPowerUsageDetail.startBatteryDetailPage((SettingsActivity) getActivity(),
-                        this, mPackageName);
-            }
-        } else {
-            return false;
-        }
-        return true;
-    }
-
-    private void addDynamicPrefs() {
-        if (UserManager.get(getContext()).isManagedProfile()) {
-            return;
-        }
-        final PreferenceScreen screen = getPreferenceScreen();
-        final Context context = getContext();
-        if (DefaultHomePreferenceController.hasHomePreference(mPackageName, context)) {
-            screen.addPreference(new ShortcutPreference(getPrefContext(),
-                    DefaultAppSettings.class, "default_home", R.string.home_app,
-                    R.string.configure_apps));
-        }
-        if (DefaultBrowserPreferenceController.hasBrowserPreference(mPackageName, context)) {
-            screen.addPreference(new ShortcutPreference(getPrefContext(),
-                    DefaultAppSettings.class, "default_browser", R.string.default_browser_title,
-                    R.string.configure_apps));
-        }
-        if (DefaultPhonePreferenceController.hasPhonePreference(mPackageName, context)) {
-            screen.addPreference(new ShortcutPreference(getPrefContext(),
-                    DefaultAppSettings.class, "default_phone_app", R.string.default_phone_title,
-                    R.string.configure_apps));
-        }
-        if (DefaultEmergencyPreferenceController.hasEmergencyPreference(mPackageName, context)) {
-            screen.addPreference(new ShortcutPreference(getPrefContext(),
-                    DefaultAppSettings.class, "default_emergency_app",
-                    R.string.default_emergency_app, R.string.configure_apps));
-        }
-        if (DefaultSmsPreferenceController.hasSmsPreference(mPackageName, context)) {
-            screen.addPreference(new ShortcutPreference(getPrefContext(),
-                    DefaultAppSettings.class, "default_sms_app", R.string.sms_application_title,
-                    R.string.configure_apps));
-        }
-
-        // Get the package info with the activities
-        PackageInfo packageInfoWithActivities = null;
-        try {
-            packageInfoWithActivities = mPm.getPackageInfoAsUser(mPackageName,
-                    PackageManager.GET_ACTIVITIES, UserHandle.myUserId());
-        } catch (NameNotFoundException e) {
-            Log.e(TAG, "Exception while retrieving the package info of " + mPackageName, e);
-        }
-
-        boolean hasDrawOverOtherApps = hasPermission(permission.SYSTEM_ALERT_WINDOW);
-        boolean hasWriteSettings = hasPermission(permission.WRITE_SETTINGS);
-        boolean hasPictureInPictureActivities = (packageInfoWithActivities != null) &&
-                PictureInPictureSettings.checkPackageHasPictureInPictureActivities(
-                        packageInfoWithActivities.packageName,
-                        packageInfoWithActivities.activities);
-        boolean isPotentialAppSource = isPotentialAppSource();
-        if (hasDrawOverOtherApps || hasWriteSettings || hasPictureInPictureActivities ||
-                isPotentialAppSource) {
-            PreferenceCategory category = new PreferenceCategory(getPrefContext());
-            category.setTitle(R.string.advanced_apps);
-            screen.addPreference(category);
-
-            if (hasDrawOverOtherApps) {
-                Preference pref = new Preference(getPrefContext());
-                pref.setTitle(R.string.draw_overlay);
-                pref.setKey("system_alert_window");
-                pref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
-                    @Override
-                    public boolean onPreferenceClick(Preference preference) {
-                        startAppInfoFragment(DrawOverlayDetails.class, R.string.draw_overlay);
-                        return true;
-                    }
-                });
-                category.addPreference(pref);
-            }
-            if (hasWriteSettings) {
-                Preference pref = new Preference(getPrefContext());
-                pref.setTitle(R.string.write_settings);
-                pref.setKey("write_settings_apps");
-                pref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
-                    @Override
-                    public boolean onPreferenceClick(Preference preference) {
-                        startAppInfoFragment(WriteSettingsDetails.class, R.string.write_settings);
-                        return true;
-                    }
-                });
-                category.addPreference(pref);
-            }
-            if (hasPictureInPictureActivities) {
-                Preference pref = new Preference(getPrefContext());
-                pref.setTitle(R.string.picture_in_picture_app_detail_title);
-                pref.setKey("picture_in_picture");
-                pref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
-                    @Override
-                    public boolean onPreferenceClick(Preference preference) {
-                        AppInfoBase.startAppInfoFragment(PictureInPictureDetails.class,
-                                R.string.picture_in_picture_app_detail_title, mPackageName,
-                                mPackageInfo.applicationInfo.uid, InstalledAppDetails.this,
-                                -1, getMetricsCategory());
-                        return true;
-                    }
-                });
-                category.addPreference(pref);
-            }
-            if (isPotentialAppSource) {
-                Preference pref = new Preference(getPrefContext());
-                pref.setTitle(R.string.install_other_apps);
-                pref.setKey("install_other_apps");
-                pref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
-                    @Override
-                    public boolean onPreferenceClick(Preference preference) {
-                        startAppInfoFragment(ExternalSourcesDetails.class,
-                                R.string.install_other_apps);
-                        return true;
-                    }
-                });
-                category.addPreference(pref);
-            }
-        }
-
-        addAppInstallerInfoPref(screen);
-        maybeAddInstantAppButtons();
-    }
-
-    private boolean isPotentialAppSource() {
-        AppStateInstallAppsBridge.InstallAppsState appState =
-                new AppStateInstallAppsBridge(getContext(), null, null)
-                        .createInstallAppsStateFor(mPackageName, mPackageInfo.applicationInfo.uid);
-        return appState.isPotentialAppSource();
-    }
-
-    private void addAppInstallerInfoPref(PreferenceScreen screen) {
-        String installerPackageName =
-                AppStoreUtil.getInstallerPackageName(getContext(), mPackageName);
-
-        final CharSequence installerLabel = Utils.getApplicationLabel(getContext(),
-                installerPackageName);
-        if (installerLabel == null) {
-            return;
-        }
-        final int detailsStringId = AppUtils.isInstant(mPackageInfo.applicationInfo)
-                ? R.string.instant_app_details_summary
-                : R.string.app_install_details_summary;
-        PreferenceCategory category = new PreferenceCategory(getPrefContext());
-        category.setTitle(R.string.app_install_details_group_title);
-        screen.addPreference(category);
-        Preference pref = new Preference(getPrefContext());
-        pref.setTitle(R.string.app_install_details_title);
-        pref.setKey("app_info_store");
-        pref.setSummary(getString(detailsStringId, installerLabel));
-
-        Intent intent =
-                AppStoreUtil.getAppStoreLink(getContext(), installerPackageName, mPackageName);
-        if (intent != null) {
-            pref.setIntent(intent);
-        } else {
-            pref.setEnabled(false);
-        }
-        category.addPreference(pref);
-    }
-
-    @VisibleForTesting
-    void maybeAddInstantAppButtons() {
-        if (AppUtils.isInstant(mPackageInfo.applicationInfo)) {
-            LayoutPreference buttons = (LayoutPreference) findPreference(KEY_INSTANT_APP_BUTTONS);
-            mInstantAppButtonsController = mApplicationFeatureProvider
-                    .newInstantAppButtonsController(this,
-                            buttons.findViewById(R.id.instant_app_button_container),
-                            id -> showDialogInner(id, 0))
-                    .setPackageName(mPackageName)
-                    .show();
-        }
-    }
-
-    private boolean hasPermission(String permission) {
-        if (mPackageInfo == null || mPackageInfo.requestedPermissions == null) {
-            return false;
-        }
-        for (int i = 0; i < mPackageInfo.requestedPermissions.length; i++) {
-            if (mPackageInfo.requestedPermissions[i].equals(permission)) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    private void updateDynamicPrefs() {
-        final Context context = getContext();
-        Preference pref = findPreference("default_home");
-
-        if (pref != null) {
-            pref.setSummary(DefaultHomePreferenceController.isHomeDefault(mPackageName,
-                    new PackageManagerWrapper(context.getPackageManager()))
-                    ? R.string.yes : R.string.no);
-        }
-        pref = findPreference("default_browser");
-        if (pref != null) {
-            pref.setSummary(new DefaultBrowserPreferenceController(context)
-                    .isBrowserDefault(mPackageName, mUserId)
-                    ? R.string.yes : R.string.no);
-        }
-        pref = findPreference("default_phone_app");
-        if (pref != null) {
-            pref.setSummary(
-                    DefaultPhonePreferenceController.isPhoneDefault(mPackageName, context)
-                    ? R.string.yes : R.string.no);
-        }
-        pref = findPreference("default_emergency_app");
-        if (pref != null) {
-            pref.setSummary(DefaultEmergencyPreferenceController.isEmergencyDefault(mPackageName,
-                    getContext()) ? R.string.yes : R.string.no);
-        }
-        pref = findPreference("default_sms_app");
-        if (pref != null) {
-            pref.setSummary(DefaultSmsPreferenceController.isSmsDefault(mPackageName, context)
-                    ? R.string.yes : R.string.no);
-        }
-        pref = findPreference("system_alert_window");
-        if (pref != null) {
-            pref.setSummary(DrawOverlayDetails.getSummary(getContext(), mAppEntry));
-        }
-        pref = findPreference("picture_in_picture");
-        if (pref != null) {
-            pref.setSummary(PictureInPictureDetails.getPreferenceSummary(getContext(),
-                    mPackageInfo.applicationInfo.uid, mPackageName));
-        }
-        pref = findPreference("write_settings_apps");
-        if (pref != null) {
-            pref.setSummary(WriteSettingsDetails.getSummary(getContext(), mAppEntry));
-        }
-        pref = findPreference("install_other_apps");
-        if (pref != null) {
-            pref.setSummary(ExternalSourcesDetails.getPreferenceSummary(getContext(), mAppEntry));
-        }
-    }
-
-    public static NetworkTemplate getTemplate(Context context) {
-        if (DataUsageList.hasReadyMobileRadio(context)) {
-            return NetworkTemplate.buildTemplateMobileWildcard();
-        }
-        if (DataUsageUtils.hasWifiRadio(context)) {
-            return NetworkTemplate.buildTemplateWifiWildcard();
-        }
-        return NetworkTemplate.buildTemplateEthernet();
-    }
-
-    public static CharSequence getNotificationSummary(AppEntry appEntry, Context context,
-            NotificationBackend backend) {
-        AppRow appRow = backend.loadAppRow(context, context.getPackageManager(), appEntry.info);
-        return getNotificationSummary(appRow, context);
-    }
-
-    public static CharSequence getNotificationSummary(AppRow appRow, Context context) {
-        // TODO: implement summary when it is known what it should say
-        return "";
-    }
-
-    @Override
-    protected void onPackageRemoved() {
-        getActivity().finishActivity(SUB_INFO_FRAGMENT);
-        super.onPackageRemoved();
-    }
-
-    private class MemoryUpdater extends AsyncTask<Void, Void, ProcStatsPackageEntry> {
-
-        @Override
-        protected ProcStatsPackageEntry doInBackground(Void... params) {
-            if (getActivity() == null) {
-                return null;
-            }
-            if (mPackageInfo == null) {
-                return null;
-            }
-            if (mStatsManager == null) {
-                mStatsManager = new ProcStatsData(getActivity(), false);
-                mStatsManager.setDuration(ProcessStatsBase.sDurations[0]);
-            }
-            mStatsManager.refreshStats(true);
-            for (ProcStatsPackageEntry pkgEntry : mStatsManager.getEntries()) {
-                for (ProcStatsEntry entry : pkgEntry.mEntries) {
-                    if (entry.mUid == mPackageInfo.applicationInfo.uid) {
-                        pkgEntry.updateMetrics();
-                        return pkgEntry;
-                    }
-                }
-            }
-            return null;
-        }
-
-        @Override
-        protected void onPostExecute(ProcStatsPackageEntry entry) {
-            if (getActivity() == null) {
-                return;
-            }
-            if (entry != null) {
-                mStats = entry;
-                mMemoryPreference.setEnabled(true);
-                double amount = Math.max(entry.mRunWeight, entry.mBgWeight)
-                        * mStatsManager.getMemInfo().weightToRam;
-                mMemoryPreference.setSummary(getString(R.string.memory_use_summary,
-                        Formatter.formatShortFileSize(getContext(), (long) amount)));
-            } else {
-                mMemoryPreference.setEnabled(false);
-                mMemoryPreference.setSummary(getString(R.string.no_memory_use_summary));
-            }
-        }
-
-    }
-
-    /**
-     * Elicit this class for testing. Test cannot be done in robolectric because it
-     * invokes the new API.
-     */
-    @VisibleForTesting
-    public static class PackageUtil {
-        /**
-         * Count how many users in device have installed package {@paramref packageName}
-         */
-        public static int countPackageInUsers(PackageManager packageManager, UserManager
-                userManager, String packageName) {
-            final List<UserInfo> userInfos = userManager.getUsers(true);
-            int count = 0;
-
-            for (final UserInfo userInfo : userInfos) {
-                try {
-                    // Use this API to check whether user has this package
-                    final ApplicationInfo info = packageManager.getApplicationInfoAsUser(
-                            packageName, PackageManager.GET_META_DATA, userInfo.id);
-                    if ((info.flags & ApplicationInfo.FLAG_INSTALLED) != 0) {
-                        count++;
-                    }
-                } catch(NameNotFoundException e) {
-                    Log.e(TAG, "Package: " + packageName + " not found for user: " + userInfo.id);
-                }
-            }
-
-            return count;
-        }
-    }
-
-    private 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 LoaderCallbacks<ChartData> mDataCallbacks = new LoaderCallbacks<ChartData>() {
-
-        @Override
-        public Loader<ChartData> onCreateLoader(int id, Bundle args) {
-            return new ChartDataLoader(getActivity(), mStatsSession, args);
-        }
-
-        @Override
-        public void onLoadFinished(Loader<ChartData> loader, ChartData data) {
-            mChartData = data;
-            mDataPreference.setSummary(getDataSummary());
-        }
-
-        @Override
-        public void onLoaderReset(Loader<ChartData> loader) {
-            // Leave last result.
-        }
-    };
-
-    private final BroadcastReceiver mCheckKillProcessesReceiver = new BroadcastReceiver() {
-        @Override
-        public void onReceive(Context context, Intent intent) {
-            final boolean enabled = getResultCode() != Activity.RESULT_CANCELED;
-            Log.d(LOG_TAG, "Got broadcast response: Restart status for "
-                    + mAppEntry.info.packageName + " " + enabled);
-            updateForceStopButton(enabled);
-        }
-    };
-
-    private final PermissionsResultCallback mPermissionCallback
-            = new PermissionsResultCallback() {
-        @Override
-        public void onPermissionSummaryResult(int standardGrantedPermissionCount,
-                int requestedPermissionCount, int additionalGrantedPermissionCount,
-                List<CharSequence> grantedGroupLabels) {
-            if (getActivity() == null) {
-                return;
-            }
-            final Resources res = getResources();
-            CharSequence summary = null;
-
-            if (requestedPermissionCount == 0) {
-                summary = res.getString(
-                        R.string.runtime_permissions_summary_no_permissions_requested);
-                mPermissionsPreference.setOnPreferenceClickListener(null);
-                mPermissionsPreference.setEnabled(false);
-            } else {
-                final ArrayList<CharSequence> list = new ArrayList<>(grantedGroupLabels);
-                if (additionalGrantedPermissionCount > 0) {
-                    // N additional permissions.
-                    list.add(res.getQuantityString(
-                            R.plurals.runtime_permissions_additional_count,
-                            additionalGrantedPermissionCount, additionalGrantedPermissionCount));
-                }
-                if (list.size() == 0) {
-                    summary = res.getString(
-                            R.string.runtime_permissions_summary_no_permissions_granted);
-                } else {
-                    summary = ListFormatter.getInstance().format(list);
-                }
-                mPermissionsPreference.setOnPreferenceClickListener(InstalledAppDetails.this);
-                mPermissionsPreference.setEnabled(true);
-            }
-            mPermissionsPreference.setSummary(summary);
-        }
-    };
-}
diff --git a/src/com/android/settings/applications/InstalledAppDetailsTop.java b/src/com/android/settings/applications/InstalledAppDetailsTop.java
index 8090de0..2d9756a 100644
--- a/src/com/android/settings/applications/InstalledAppDetailsTop.java
+++ b/src/com/android/settings/applications/InstalledAppDetailsTop.java
@@ -17,30 +17,21 @@
 package com.android.settings.applications;
 
 import android.content.Intent;
-import android.util.FeatureFlagUtils;
 
 import com.android.settings.SettingsActivity;
 import com.android.settings.applications.appinfo.AppInfoDashboardFragment;
-import com.android.settings.core.FeatureFlags;
 
 public class InstalledAppDetailsTop extends SettingsActivity {
 
     @Override
     public Intent getIntent() {
         Intent modIntent = new Intent(super.getIntent());
-        if (FeatureFlagUtils.isEnabled(this, FeatureFlags.APP_INFO_V2)) {
-            modIntent.putExtra(EXTRA_SHOW_FRAGMENT, AppInfoDashboardFragment.class.getName());
-        } else {
-            modIntent.putExtra(EXTRA_SHOW_FRAGMENT, InstalledAppDetails.class.getName());
-        }
+        modIntent.putExtra(EXTRA_SHOW_FRAGMENT, AppInfoDashboardFragment.class.getName());
         return modIntent;
     }
 
     @Override
     protected boolean isValidFragment(String fragmentName) {
-        if (FeatureFlagUtils.isEnabled(this, FeatureFlags.APP_INFO_V2)) {
-            return AppInfoDashboardFragment.class.getName().equals(fragmentName);
-        }
-        return InstalledAppDetails.class.getName().equals(fragmentName);
+        return AppInfoDashboardFragment.class.getName().equals(fragmentName);
     }
 }
diff --git a/src/com/android/settings/applications/NotificationApps.java b/src/com/android/settings/applications/NotificationApps.java
deleted file mode 100644
index f921092..0000000
--- a/src/com/android/settings/applications/NotificationApps.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (C) 2016 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.content.Context;
-import android.content.pm.ApplicationInfo;
-
-import com.android.settings.R;
-import com.android.settings.applications.manageapplications.ManageApplications;
-import com.android.settings.dashboard.SummaryLoader;
-import com.android.settings.notification.NotificationBackend;
-import com.android.settingslib.wrapper.PackageManagerWrapper;
-
-/**
- * Extension of ManageApplications with no changes other than having its own
- * SummaryProvider.
- */
-public class NotificationApps extends ManageApplications {
-
-    public static class SummaryProvider implements SummaryLoader.SummaryProvider {
-
-        private final Context mContext;
-        private final SummaryLoader mLoader;
-        private final NotificationBackend mNotificationBackend;
-        private final PackageManagerWrapper mPackageManager;
-
-        public SummaryProvider(Context context, SummaryLoader loader) {
-            mContext = context;
-            mLoader = loader;
-            mNotificationBackend = new NotificationBackend();
-            mPackageManager = new PackageManagerWrapper(mContext.getPackageManager());
-        }
-
-        @Override
-        public void setListening(boolean listening) {
-            if (listening) {
-                new AppCounter(mContext, mPackageManager) {
-                    @Override
-                    protected void onCountComplete(int num) {
-                        updateSummary(num);
-                    }
-
-                    @Override
-                    protected boolean includeInCount(ApplicationInfo info) {
-                        return mNotificationBackend.getNotificationsBanned(info.packageName,
-                                info.uid);
-                    }
-                }.execute();
-            }
-        }
-
-        private void updateSummary(int count) {
-            if (count == 0) {
-                mLoader.setSummary(this, mContext.getString(R.string.notification_summary_none));
-            } else {
-                mLoader.setSummary(this, mContext.getResources().getQuantityString(
-                        R.plurals.notification_summary, count, count));
-            }
-        }
-    }
-
-    public static final SummaryLoader.SummaryProviderFactory SUMMARY_PROVIDER_FACTORY
-            = new SummaryLoader.SummaryProviderFactory() {
-        @Override
-        public SummaryLoader.SummaryProvider createSummaryProvider(Activity activity,
-                                                                   SummaryLoader summaryLoader) {
-            return new SummaryProvider(activity, summaryLoader);
-        }
-    };
-}
diff --git a/src/com/android/settings/applications/RecentAppsPreferenceController.java b/src/com/android/settings/applications/RecentAppsPreferenceController.java
index 3859081..e15671b 100644
--- a/src/com/android/settings/applications/RecentAppsPreferenceController.java
+++ b/src/com/android/settings/applications/RecentAppsPreferenceController.java
@@ -34,14 +34,12 @@
 import android.text.TextUtils;
 import android.util.ArrayMap;
 import android.util.ArraySet;
-import android.util.FeatureFlagUtils;
 import android.util.IconDrawableFactory;
 import android.util.Log;
 
 import com.android.settings.R;
 import com.android.settings.Utils;
 import com.android.settings.applications.appinfo.AppInfoDashboardFragment;
-import com.android.settings.core.FeatureFlags;
 import com.android.settings.core.PreferenceControllerMixin;
 import com.android.settings.widget.AppPreference;
 import com.android.settingslib.applications.AppUtils;
@@ -245,17 +243,10 @@
                     System.currentTimeMillis() - stat.getLastTimeUsed(), false));
             pref.setOrder(i);
             pref.setOnPreferenceClickListener(preference -> {
-                if (FeatureFlagUtils.isEnabled(mContext, FeatureFlags.APP_INFO_V2)) {
-                    AppInfoBase.startAppInfoFragment(AppInfoDashboardFragment.class,
-                            R.string.application_info_label, pkgName, appEntry.info.uid, mHost,
-                            1001 /*RequestCode*/, SETTINGS_APP_NOTIF_CATEGORY);
-                    return true;
-                } else {
-                    AppInfoBase.startAppInfoFragment(InstalledAppDetails.class,
-                            R.string.application_info_label, pkgName, appEntry.info.uid, mHost,
-                            1001 /*RequestCode*/, SETTINGS_APP_NOTIF_CATEGORY);
-                    return true;
-                }
+                AppInfoBase.startAppInfoFragment(AppInfoDashboardFragment.class,
+                    R.string.application_info_label, pkgName, appEntry.info.uid, mHost,
+                    1001 /*RequestCode*/, SETTINGS_APP_NOTIF_CATEGORY);
+                return true;
             });
             if (!rebindPref) {
                 mCategory.addPreference(pref);
diff --git a/src/com/android/settings/applications/appinfo/AppActionButtonPreferenceController.java b/src/com/android/settings/applications/appinfo/AppActionButtonPreferenceController.java
index 130138c..1a5a285 100644
--- a/src/com/android/settings/applications/appinfo/AppActionButtonPreferenceController.java
+++ b/src/com/android/settings/applications/appinfo/AppActionButtonPreferenceController.java
@@ -16,18 +16,14 @@
 
 package com.android.settings.applications.appinfo;
 
-import android.app.Activity;
 import android.app.ActivityManager;
 import android.app.admin.DevicePolicyManager;
-import android.content.BroadcastReceiver;
 import android.content.ComponentName;
 import android.content.Context;
-import android.content.Intent;
 import android.content.pm.ApplicationInfo;
 import android.content.pm.PackageInfo;
 import android.content.pm.PackageManager;
 import android.content.pm.ResolveInfo;
-import android.net.Uri;
 import android.os.Bundle;
 import android.os.RemoteException;
 import android.os.ServiceManager;
@@ -35,7 +31,6 @@
 import android.os.UserManager;
 import android.support.annotation.VisibleForTesting;
 import android.support.v7.preference.PreferenceScreen;
-import android.util.Log;
 import android.webkit.IWebViewUpdateService;
 
 import com.android.settings.R;
@@ -71,16 +66,6 @@
     private UserManager mUserManager;
     private PackageManager mPm;
 
-    private final BroadcastReceiver mCheckKillProcessesReceiver = new BroadcastReceiver() {
-        @Override
-        public void onReceive(Context context, Intent intent) {
-            final boolean enabled = getResultCode() != Activity.RESULT_CANCELED;
-            Log.d(TAG, "Got broadcast response: Restart status for "
-                    + mParent.getAppEntry().info.packageName + " " + enabled);
-            updateForceStopButton(enabled);
-        }
-    };
-
     public AppActionButtonPreferenceController(Context context, AppInfoDashboardFragment parent,
             String packageName) {
         super(context, KEY_ACTION_BUTTONS);
@@ -101,9 +86,7 @@
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
         mActionButtons = ((ActionButtonPreference) screen.findPreference(KEY_ACTION_BUTTONS))
-                .setButton2Text(R.string.force_stop)
-                .setButton2Positive(false)
-                .setButton2Enabled(false);
+                .setButton2Visible(false);
     }
 
     @Override
@@ -140,7 +123,6 @@
             }
         }
 
-        checkForceStop(appEntry, packageInfo);
         initUninstallButtons(appEntry, packageInfo);
     }
 
@@ -269,41 +251,6 @@
         return disableable;
     }
 
-    private void updateForceStopButton(boolean enabled) {
-        final boolean disallowedBySystem = RestrictedLockUtils.hasBaseUserRestriction(
-                mContext, UserManager.DISALLOW_APPS_CONTROL, mUserId);
-        mActionButtons
-                .setButton2Enabled(disallowedBySystem ? false : enabled)
-                .setButton2OnClickListener(
-                        disallowedBySystem ? null : v -> mParent.handleForceStopButtonClick());
-    }
-
-    void checkForceStop(AppEntry appEntry, PackageInfo packageInfo) {
-        if (mDpm.packageHasActiveAdmins(packageInfo.packageName)) {
-            // User can't force stop device admin.
-            Log.w(TAG, "User can't force stop device admin");
-            updateForceStopButton(false);
-        } else if (AppUtils.isInstant(packageInfo.applicationInfo)) {
-            updateForceStopButton(false);
-            mActionButtons.setButton2Visible(false);
-        } else if ((appEntry.info.flags & ApplicationInfo.FLAG_STOPPED) == 0) {
-            // If the app isn't explicitly stopped, then always show the
-            // force stop button.
-            Log.w(TAG, "App is not explicitly stopped");
-            updateForceStopButton(true);
-        } else {
-            final Intent intent = new Intent(Intent.ACTION_QUERY_PACKAGE_RESTART,
-                    Uri.fromParts("package", appEntry.info.packageName, null));
-            intent.putExtra(Intent.EXTRA_PACKAGES, new String[] { appEntry.info.packageName });
-            intent.putExtra(Intent.EXTRA_UID, appEntry.info.uid);
-            intent.putExtra(Intent.EXTRA_USER_HANDLE, UserHandle.getUserId(appEntry.info.uid));
-            Log.d(TAG, "Sending broadcast to query restart status for "
-                    + appEntry.info.packageName);
-            mContext.sendOrderedBroadcastAsUser(intent, UserHandle.CURRENT, null,
-                    mCheckKillProcessesReceiver, null, Activity.RESULT_CANCELED, null, null);
-        }
-    }
-
     private boolean signaturesMatch(String pkg1, String pkg2) {
         if (pkg1 != null && pkg2 != null) {
             try {
diff --git a/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java b/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java
index 41c1f7c..a99ba65 100755
--- a/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java
+++ b/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java
@@ -19,7 +19,6 @@
 import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
 
 import android.app.Activity;
-import android.app.ActivityManager;
 import android.app.AlertDialog;
 import android.app.Dialog;
 import android.app.DialogFragment;
@@ -45,19 +44,15 @@
 import android.view.Menu;
 import android.view.MenuInflater;
 import android.view.MenuItem;
-import android.view.View;
 
 import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
 import com.android.settings.DeviceAdminAdd;
 import com.android.settings.R;
 import com.android.settings.SettingsActivity;
 import com.android.settings.SettingsPreferenceFragment;
-import com.android.settings.Utils;
-import com.android.settings.applications.LayoutPreference;
 import com.android.settings.applications.manageapplications.ManageApplications;
 import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
 import com.android.settings.dashboard.DashboardFragment;
-import com.android.settings.widget.EntityHeaderController;
 import com.android.settings.widget.PreferenceCategoryController;
 import com.android.settings.wrapper.DevicePolicyManagerWrapper;
 import com.android.settingslib.RestrictedLockUtils;
@@ -89,6 +84,7 @@
     // Menu identifiers
     private static final int UNINSTALL_ALL_USERS_MENU = 1;
     private static final int UNINSTALL_UPDATES = 2;
+    static final int FORCE_STOP_MENU = 3;
 
     // Result code identifiers
     @VisibleForTesting
@@ -103,7 +99,7 @@
 
     // Dialog identifiers used in showDialog
     private static final int DLG_BASE = 0;
-    private static final int DLG_FORCE_STOP = DLG_BASE + 1;
+    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;
 
@@ -141,6 +137,7 @@
 
     private InstantAppButtonsPreferenceController mInstantAppButtonPreferenceController;
     private AppActionButtonPreferenceController mAppActionButtonPreferenceController;
+    private ForceStopOptionsMenuController mForceStopOptionsMenuController;
 
     /**
      * Callback to invoke when app info has been changed.
@@ -172,6 +169,9 @@
             return;
         }
 
+        mForceStopOptionsMenuController =
+            new ForceStopOptionsMenuController(activity, this /* parent */, mDpm,
+                mMetricsFeatureProvider, getLifecycle());
         setHasOptionsMenu(true);
     }
 
@@ -268,6 +268,10 @@
         return mAppEntry;
     }
 
+    void setAppEntry(ApplicationsState.AppEntry appEntry) {
+        mAppEntry = appEntry;
+    }
+
     PackageInfo getPackageInfo() {
         if (mAppEntry == null) {
             retrieveAppEntry();
@@ -275,6 +279,10 @@
         return mPackageInfo;
     }
 
+    ApplicationsState getAppState() {
+        return mState;
+    }
+
     @Override
     public void onPackageSizeChanged(String packageName) {
         if (!TextUtils.equals(packageName, mPackageName)) {
@@ -315,6 +323,7 @@
         if (mFinishing) {
             return;
         }
+        super.onPrepareOptionsMenu(menu);
         menu.findItem(UNINSTALL_ALL_USERS_MENU).setVisible(shouldShowUninstallForAll(mAppEntry));
         mUpdatedSysApp = (mAppEntry.info.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0;
         final MenuItem uninstallUpdatesItem = menu.findItem(UNINSTALL_UPDATES);
@@ -335,7 +344,7 @@
                 uninstallPkg(mAppEntry.info.packageName, false, false);
                 return true;
         }
-        return false;
+        return super.onOptionsItemSelected(item);
     }
 
     @Override
@@ -465,18 +474,10 @@
                         })
                         .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();
+        }
+        final AlertDialog dialog = mForceStopOptionsMenuController.createDialog(id);
+        if (dialog != null) {
+            return dialog;
         }
         return mInstantAppButtonPreferenceController.createDialog(id);
     }
@@ -493,21 +494,6 @@
         mDisableAfterUninstall = andDisable;
     }
 
-    private void forceStopPackage(String pkgName) {
-        mMetricsFeatureProvider.action(getContext(), MetricsEvent.ACTION_APP_FORCE_STOP, pkgName);
-        final ActivityManager am = (ActivityManager) getActivity().getSystemService(
-                Context.ACTIVITY_SERVICE);
-        Log.d(TAG, "Stopping package " + pkgName);
-        am.forceStopPackage(pkgName);
-        final int userId = UserHandle.getUserId(mAppEntry.info.uid);
-        mState.invalidatePackage(pkgName, userId);
-        final AppEntry newEnt = mState.getEntry(pkgName, userId);
-        if (newEnt != null) {
-            mAppEntry = newEnt;
-        }
-        mAppActionButtonPreferenceController.checkForceStop(mAppEntry, mPackageInfo);
-    }
-
     public static void startAppInfoFragment(Class<?> fragment, int title,
             SettingsPreferenceFragment caller, AppEntry appEntry) {
         // start new fragment to display extended information
@@ -568,20 +554,6 @@
         }
     }
 
-    void handleForceStopButtonClick() {
-        if (mAppEntry == null) {
-            setIntentAndFinish(true, true);
-            return;
-        }
-        if (mAppsControlDisallowedAdmin != null && !mAppsControlDisallowedBySystem) {
-            RestrictedLockUtils.sendShowAdminSupportDetailsIntent(
-                    getActivity(), mAppsControlDisallowedAdmin);
-        } else {
-            showDialogInner(DLG_FORCE_STOP, 0);
-            //forceStopPackage(mAppInfo.packageName);
-        }
-    }
-
     /** Returns whether there is only one user on this device, not including the system-only user */
     private boolean isSingleUser() {
         final int userCount = mUserManager.getUserCount();
@@ -679,7 +651,7 @@
         }
     }
 
-    private void setIntentAndFinish(boolean finish, boolean appChanged) {
+    void setIntentAndFinish(boolean finish, boolean appChanged) {
         if (localLOGV) Log.i(TAG, "appChanged="+appChanged);
         final Intent intent = new Intent();
         intent.putExtra(ManageApplications.APP_CHG, appChanged);
diff --git a/src/com/android/settings/applications/appinfo/ForceStopOptionsMenuController.java b/src/com/android/settings/applications/appinfo/ForceStopOptionsMenuController.java
new file mode 100644
index 0000000..cf87147
--- /dev/null
+++ b/src/com/android/settings/applications/appinfo/ForceStopOptionsMenuController.java
@@ -0,0 +1,198 @@
+/*
+ * Copyright (C) 2018 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.appinfo;
+
+import static com.android.settings.applications.appinfo.AppInfoDashboardFragment.FORCE_STOP_MENU;
+import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
+
+import android.app.Activity;
+import android.app.ActivityManager;
+import android.app.AlertDialog;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageInfo;
+import android.net.Uri;
+import android.os.UserHandle;
+import android.os.UserManager;
+import android.support.annotation.VisibleForTesting;
+import android.util.Log;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+
+import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+import com.android.settings.R;
+import com.android.settings.wrapper.DevicePolicyManagerWrapper;
+import com.android.settingslib.RestrictedLockUtils;
+import com.android.settingslib.applications.AppUtils;
+import com.android.settingslib.applications.ApplicationsState;
+import com.android.settingslib.applications.ApplicationsState.AppEntry;
+import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+import com.android.settingslib.core.lifecycle.LifecycleObserver;
+import com.android.settingslib.core.lifecycle.events.OnCreateOptionsMenu;
+import com.android.settingslib.core.lifecycle.events.OnOptionsItemSelected;
+import com.android.settingslib.core.lifecycle.events.OnPrepareOptionsMenu;
+
+public class ForceStopOptionsMenuController implements LifecycleObserver, OnCreateOptionsMenu,
+        OnPrepareOptionsMenu, OnOptionsItemSelected {
+
+    private static final String TAG = "ForceStopMenuController";
+
+    private final Context mContext;
+    private final AppInfoDashboardFragment mParent;
+    private final DevicePolicyManagerWrapper mDpm;
+    private final MetricsFeatureProvider mMetricsFeatureProvider;
+
+    private int mUserId;
+    private MenuItem mForceStopMenu;
+
+    private final BroadcastReceiver mCheckKillProcessesReceiver = new BroadcastReceiver() {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            final boolean enabled = getResultCode() != Activity.RESULT_CANCELED;
+            Log.d(TAG, "Got broadcast response: Restart status for "
+                + mParent.getAppEntry().info.packageName + " " + enabled);
+            enableForceStopMenu(enabled);
+        }
+    };
+
+    public ForceStopOptionsMenuController(Context context, AppInfoDashboardFragment parent,
+            DevicePolicyManagerWrapper devicePolicyManager,
+            MetricsFeatureProvider metricsFeatureProvider, Lifecycle lifecycle) {
+        mContext = context;
+        mParent = parent;
+        mDpm = devicePolicyManager;
+        mMetricsFeatureProvider = metricsFeatureProvider;
+        mUserId = UserHandle.myUserId();
+        if (lifecycle != null) {
+            lifecycle.addObserver(this);
+        }
+    }
+
+    @Override
+    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+        menu.add(0, FORCE_STOP_MENU, 2, R.string.force_stop)
+            .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
+    }
+
+    @Override
+    public boolean onOptionsItemSelected(MenuItem menuItem) {
+        if (menuItem.getItemId() == FORCE_STOP_MENU) {
+            handleForceStopMenuClick();
+            return true;
+        }
+        return false;
+    }
+
+    @Override
+    public void onPrepareOptionsMenu(Menu menu) {
+        mForceStopMenu = menu.findItem(FORCE_STOP_MENU);
+        updateForceStopMenu(mParent.getAppEntry(), mParent.getPackageInfo());
+    }
+
+    @VisibleForTesting
+    void updateForceStopMenu(AppEntry appEntry, PackageInfo packageInfo) {
+        boolean enabled = false;
+        if (mDpm.packageHasActiveAdmins(packageInfo.packageName)) {
+            // User can't force stop device admin.
+            Log.w(TAG, "User can't force stop device admin");
+        } else if (AppUtils.isInstant(packageInfo.applicationInfo)) {
+            // No force stop for instant app
+            if (mForceStopMenu != null) {
+                mForceStopMenu.setVisible(false);
+            }
+        } else if ((appEntry.info.flags & ApplicationInfo.FLAG_STOPPED) == 0) {
+            // If the app isn't explicitly stopped, then always show the
+            // force stop button.
+            Log.w(TAG, "App is not explicitly stopped");
+            enabled = true;
+        } else {
+            final Intent intent = new Intent(Intent.ACTION_QUERY_PACKAGE_RESTART,
+                Uri.fromParts("package", appEntry.info.packageName, null));
+            intent.putExtra(Intent.EXTRA_PACKAGES, new String[] { appEntry.info.packageName });
+            intent.putExtra(Intent.EXTRA_UID, appEntry.info.uid);
+            intent.putExtra(Intent.EXTRA_USER_HANDLE, UserHandle.getUserId(appEntry.info.uid));
+            Log.d(TAG, "Sending broadcast to query restart status for "
+                + appEntry.info.packageName);
+            mContext.sendOrderedBroadcastAsUser(intent, UserHandle.CURRENT, null,
+                mCheckKillProcessesReceiver, null, Activity.RESULT_CANCELED, null, null);
+        }
+        enableForceStopMenu(enabled);
+    }
+
+    private void enableForceStopMenu(boolean enabled) {
+        if (mForceStopMenu != null) {
+            final boolean disallowedBySystem = RestrictedLockUtils.hasBaseUserRestriction(
+                mContext, UserManager.DISALLOW_APPS_CONTROL, mUserId);
+            mForceStopMenu.setEnabled(disallowedBySystem ? false : enabled);
+        }
+    }
+
+    @VisibleForTesting
+    void handleForceStopMenuClick() {
+        if (mParent.getAppEntry() == null) {
+            mParent.setIntentAndFinish(true, true);
+            return;
+        }
+        final EnforcedAdmin admin = RestrictedLockUtils.checkIfRestrictionEnforced(
+            mContext, UserManager.DISALLOW_APPS_CONTROL, mUserId);
+        final boolean disallowedBySystem = RestrictedLockUtils.hasBaseUserRestriction(
+            mContext, UserManager.DISALLOW_APPS_CONTROL, mUserId);
+        if (admin != null && !disallowedBySystem) {
+            RestrictedLockUtils.sendShowAdminSupportDetailsIntent(mContext, admin);
+        } else {
+            mParent.showDialogInner(mParent.DLG_FORCE_STOP, 0);
+        }
+    }
+
+    private void forceStopPackage(String pkgName) {
+        mMetricsFeatureProvider.action(mContext, MetricsEvent.ACTION_APP_FORCE_STOP, pkgName);
+        final ActivityManager am = (ActivityManager) mContext.getSystemService(
+            Context.ACTIVITY_SERVICE);
+        Log.d(TAG, "Stopping package " + pkgName);
+        am.forceStopPackage(pkgName);
+        final int userId = UserHandle.getUserId(mParent.getAppEntry().info.uid);
+        final ApplicationsState appState = mParent.getAppState();
+        appState.invalidatePackage(pkgName, userId);
+        final AppEntry newEnt = appState.getEntry(pkgName, userId);
+        if (newEnt != null) {
+            mParent.setAppEntry(newEnt);
+        }
+    }
+
+    public AlertDialog createDialog(int id) {
+        if (id != mParent.DLG_FORCE_STOP) {
+            return null;
+        }
+        return new AlertDialog.Builder(mContext)
+            .setTitle(mContext.getText(R.string.force_stop_dlg_title))
+            .setMessage(mContext.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(mParent.getAppEntry().info.packageName);
+                }
+            })
+            .setNegativeButton(R.string.dlg_cancel, null)
+            .create();
+    }
+
+}
diff --git a/src/com/android/settings/applications/manageapplications/ManageApplications.java b/src/com/android/settings/applications/manageapplications/ManageApplications.java
index 09896dc..b0949ea 100644
--- a/src/com/android/settings/applications/manageapplications/ManageApplications.java
+++ b/src/com/android/settings/applications/manageapplications/ManageApplications.java
@@ -50,7 +50,6 @@
 import android.support.v7.widget.RecyclerView;
 import android.text.TextUtils;
 import android.util.ArraySet;
-import android.util.FeatureFlagUtils;
 import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.Menu;
@@ -71,7 +70,6 @@
 import com.android.settings.Settings.HighPowerApplicationsActivity;
 import com.android.settings.Settings.ManageExternalSourcesActivity;
 import com.android.settings.Settings.MoviesStorageActivity;
-import com.android.settings.Settings.NotificationAppListActivity;
 import com.android.settings.Settings.OverlaySettingsActivity;
 import com.android.settings.Settings.StorageUseActivity;
 import com.android.settings.Settings.UsageAccessSettingsActivity;
@@ -91,15 +89,13 @@
 import com.android.settings.applications.AppStorageSettings;
 import com.android.settings.applications.DefaultAppSettings;
 import com.android.settings.applications.InstalledAppCounter;
-import com.android.settings.applications.InstalledAppDetails;
-import com.android.settings.applications.NotificationApps;
 import com.android.settings.applications.DirectoryAccessDetails;
 import com.android.settings.applications.UsageAccessDetails;
 import com.android.settings.applications.appinfo.AppInfoDashboardFragment;
+import com.android.settings.applications.appinfo.AppNotificationPreferenceController;
 import com.android.settings.applications.appinfo.DrawOverlayDetails;
 import com.android.settings.applications.appinfo.ExternalSourcesDetails;
 import com.android.settings.applications.appinfo.WriteSettingsDetails;
-import com.android.settings.core.FeatureFlags;
 import com.android.settings.core.InstrumentedPreferenceFragment;
 import com.android.settings.dashboard.SummaryLoader;
 import com.android.settings.fuelgauge.HighPowerDetail;
@@ -151,7 +147,7 @@
     private static final String EXTRA_HAS_ENTRIES = "hasEntries";
     private static final String EXTRA_HAS_BRIDGE = "hasBridge";
 
-    // attributes used as keys when passing values to InstalledAppDetails activity
+    // attributes used as keys when passing values to AppInfoDashboardFragment activity
     public static final String APP_CHG = "chg";
 
     // constant value that can be used to check return code from sub activity.
@@ -240,12 +236,7 @@
         if (className == null) {
             className = intent.getComponent().getClassName();
         }
-        if (className.equals(NotificationAppListActivity.class.getName())
-                || this instanceof NotificationApps) {
-            mListType = LIST_TYPE_NOTIFICATION;
-            mNotifBackend = new NotificationBackend();
-            screenTitle = R.string.app_notifications_title;
-        } else if (className.equals(StorageUseActivity.class.getName())) {
+        if (className.equals(StorageUseActivity.class.getName())) {
             if (args != null && args.containsKey(EXTRA_VOLUME_UUID)) {
                 mVolumeUuid = args.getString(EXTRA_VOLUME_UUID);
                 mStorageType = args.getInt(EXTRA_STORAGE_TYPE, STORAGE_TYPE_DEFAULT);
@@ -553,13 +544,8 @@
             // process ahead of time, to avoid a long load of data when user clicks on a managed
             // app. Maybe when they load the list of apps that contains managed profile apps.
             default:
-                if (FeatureFlagUtils.isEnabled(getContext(), FeatureFlags.APP_INFO_V2)) {
-                    startAppInfoFragment(
-                            AppInfoDashboardFragment.class, R.string.application_info_label);
-                } else {
-                    startAppInfoFragment(
-                            InstalledAppDetails.class, R.string.application_info_label);
-                }
+                startAppInfoFragment(
+                    AppInfoDashboardFragment.class, R.string.application_info_label);
                 break;
         }
     }
@@ -1227,7 +1213,8 @@
             switch (mManageApplications.mListType) {
                 case LIST_TYPE_NOTIFICATION:
                     if (entry.extraInfo != null) {
-                        holder.setSummary(InstalledAppDetails.getNotificationSummary(
+                        holder.setSummary(
+                            AppNotificationPreferenceController.getNotificationSummary(
                                 (AppRow) entry.extraInfo, mContext));
                     } else {
                         holder.setSummary(null);
diff --git a/src/com/android/settings/connecteddevice/AdvancedConnectedDeviceDashboardFragment.java b/src/com/android/settings/connecteddevice/AdvancedConnectedDeviceDashboardFragment.java
index 2a136bc..9ac6ebd 100644
--- a/src/com/android/settings/connecteddevice/AdvancedConnectedDeviceDashboardFragment.java
+++ b/src/com/android/settings/connecteddevice/AdvancedConnectedDeviceDashboardFragment.java
@@ -24,8 +24,9 @@
 import com.android.settings.bluetooth.BluetoothFilesPreferenceController;
 import com.android.settings.bluetooth.BluetoothMasterSwitchPreferenceController;
 import com.android.settings.bluetooth.BluetoothSwitchPreferenceController;
+import com.android.settings.connecteddevice.usb.UsbBackend;
+import com.android.settings.connecteddevice.usb.UsbModePreferenceController;
 import com.android.settings.dashboard.DashboardFragment;
-import com.android.settings.deviceinfo.UsbBackend;
 import com.android.settings.nfc.NfcPreferenceController;
 import com.android.settings.overlay.FeatureFactory;
 import com.android.settings.search.BaseSearchIndexProvider;
diff --git a/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragmentOld.java b/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragmentOld.java
index 7097b36..bde5e81 100644
--- a/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragmentOld.java
+++ b/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragmentOld.java
@@ -26,9 +26,10 @@
 import com.android.settings.SettingsActivity;
 import com.android.settings.bluetooth.BluetoothMasterSwitchPreferenceController;
 import com.android.settings.bluetooth.Utils;
+import com.android.settings.connecteddevice.usb.UsbBackend;
+import com.android.settings.connecteddevice.usb.UsbModePreferenceController;
 import com.android.settings.dashboard.DashboardFragment;
 import com.android.settings.dashboard.SummaryLoader;
-import com.android.settings.deviceinfo.UsbBackend;
 import com.android.settings.nfc.NfcPreferenceController;
 import com.android.settings.overlay.FeatureFactory;
 import com.android.settings.search.BaseSearchIndexProvider;
diff --git a/src/com/android/settings/connecteddevice/ConnectedDeviceGroupController.java b/src/com/android/settings/connecteddevice/ConnectedDeviceGroupController.java
index 3cccc15..3d5d0e5 100644
--- a/src/com/android/settings/connecteddevice/ConnectedDeviceGroupController.java
+++ b/src/com/android/settings/connecteddevice/ConnectedDeviceGroupController.java
@@ -20,6 +20,7 @@
 import android.support.v7.preference.PreferenceGroup;
 import android.support.v7.preference.PreferenceScreen;
 
+import com.android.settings.connecteddevice.usb.ConnectedUsbDeviceUpdater;
 import com.android.settings.core.PreferenceControllerMixin;
 import com.android.settings.bluetooth.BluetoothDeviceUpdater;
 import com.android.settings.bluetooth.ConnectedBluetoothDeviceUpdater;
@@ -48,7 +49,7 @@
     public ConnectedDeviceGroupController(DashboardFragment fragment, Lifecycle lifecycle) {
         super(fragment.getContext());
         init(lifecycle, new ConnectedBluetoothDeviceUpdater(fragment, this),
-                new ConnectedUsbDeviceUpdater(fragment.getContext(), this));
+                new ConnectedUsbDeviceUpdater(fragment, this));
     }
 
     @VisibleForTesting
diff --git a/src/com/android/settings/connecteddevice/UsbConnectionBroadcastReceiver.java b/src/com/android/settings/connecteddevice/UsbConnectionBroadcastReceiver.java
deleted file mode 100644
index 07a7691..0000000
--- a/src/com/android/settings/connecteddevice/UsbConnectionBroadcastReceiver.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (C) 2017 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.connecteddevice;
-
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.hardware.usb.UsbManager;
-
-/**
- * Receiver to receive usb update and use {@link UsbConnectionListener} to invoke callback
- */
-public class UsbConnectionBroadcastReceiver extends BroadcastReceiver {
-    private Context mContext;
-    private UsbConnectionListener mUsbConnectionListener;
-    private boolean mListeningToUsbEvents;
-    private boolean mConnected;
-
-    public UsbConnectionBroadcastReceiver(Context context,
-            UsbConnectionListener usbConnectionListener) {
-        mContext = context;
-        mUsbConnectionListener = usbConnectionListener;
-    }
-
-    @Override
-    public void onReceive(Context context, Intent intent) {
-        mConnected = intent != null
-                && intent.getExtras().getBoolean(UsbManager.USB_CONNECTED);
-        if (mUsbConnectionListener != null) {
-            mUsbConnectionListener.onUsbConnectionChanged(mConnected);
-        }
-    }
-
-    public void register() {
-        if (!mListeningToUsbEvents) {
-            final IntentFilter intentFilter = new IntentFilter(UsbManager.ACTION_USB_STATE);
-            final Intent intent = mContext.registerReceiver(this, intentFilter);
-            mConnected = intent != null
-                    && intent.getExtras().getBoolean(UsbManager.USB_CONNECTED);
-            mListeningToUsbEvents = true;
-        }
-    }
-
-    public void unregister() {
-        if (mListeningToUsbEvents) {
-            mContext.unregisterReceiver(this);
-            mListeningToUsbEvents = false;
-        }
-    }
-
-    public boolean isConnected() {
-        return mConnected;
-    }
-
-    /**
-     * Interface definition for a callback to be invoked when usb connection is changed.
-     */
-    interface UsbConnectionListener {
-        void onUsbConnectionChanged(boolean connected);
-    }
-}
diff --git a/src/com/android/settings/connecteddevice/ConnectedUsbDeviceUpdater.java b/src/com/android/settings/connecteddevice/usb/ConnectedUsbDeviceUpdater.java
similarity index 65%
rename from src/com/android/settings/connecteddevice/ConnectedUsbDeviceUpdater.java
rename to src/com/android/settings/connecteddevice/usb/ConnectedUsbDeviceUpdater.java
index 0468b0f..dd29902 100644
--- a/src/com/android/settings/connecteddevice/ConnectedUsbDeviceUpdater.java
+++ b/src/com/android/settings/connecteddevice/usb/ConnectedUsbDeviceUpdater.java
@@ -13,22 +13,24 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.android.settings.connecteddevice;
+package com.android.settings.connecteddevice.usb;
 
 import android.content.Context;
-import android.content.Intent;
+import android.os.Bundle;
 import android.support.annotation.VisibleForTesting;
+import android.support.v14.preference.PreferenceFragment;
 
 import com.android.settings.R;
-import com.android.settings.deviceinfo.UsbBackend;
-import com.android.settings.deviceinfo.UsbModeChooserActivity;
+import com.android.settings.SettingsActivity;
+import com.android.settings.connecteddevice.DevicePreferenceCallback;
+import com.android.settings.dashboard.DashboardFragment;
 import com.android.settings.widget.GearPreference;
 
 /**
  * Controller to maintain connected usb device
  */
 public class ConnectedUsbDeviceUpdater {
-    private Context mContext;
+    private PreferenceFragment mFragment;
     private UsbBackend mUsbBackend;
     private DevicePreferenceCallback mDevicePreferenceCallback;
     @VisibleForTesting
@@ -36,8 +38,9 @@
     @VisibleForTesting
     UsbConnectionBroadcastReceiver mUsbReceiver;
 
-    private UsbConnectionBroadcastReceiver.UsbConnectionListener mUsbConnectionListener =
-            (connected) -> {
+    @VisibleForTesting
+    UsbConnectionBroadcastReceiver.UsbConnectionListener mUsbConnectionListener =
+            (connected, newMode) -> {
                 if (connected) {
                     mUsbPreference.setSummary(
                             UsbModePreferenceController.getSummary(mUsbBackend.getCurrentMode()));
@@ -47,18 +50,19 @@
                 }
             };
 
-    public ConnectedUsbDeviceUpdater(Context context,
+    public ConnectedUsbDeviceUpdater(DashboardFragment fragment,
             DevicePreferenceCallback devicePreferenceCallback) {
-        this(context, devicePreferenceCallback, new UsbBackend(context));
+        this(fragment, devicePreferenceCallback, new UsbBackend(fragment.getContext()));
     }
 
     @VisibleForTesting
-    ConnectedUsbDeviceUpdater(Context context, DevicePreferenceCallback devicePreferenceCallback,
-            UsbBackend usbBackend) {
-        mContext = context;
+    ConnectedUsbDeviceUpdater(DashboardFragment fragment,
+            DevicePreferenceCallback devicePreferenceCallback, UsbBackend usbBackend) {
+        mFragment = fragment;
         mDevicePreferenceCallback = devicePreferenceCallback;
         mUsbBackend = usbBackend;
-        mUsbReceiver = new UsbConnectionBroadcastReceiver(context, mUsbConnectionListener);
+        mUsbReceiver = new UsbConnectionBroadcastReceiver(fragment.getContext(),
+                mUsbConnectionListener, mUsbBackend);
     }
 
     public void registerCallback() {
@@ -76,8 +80,12 @@
         mUsbPreference.setIcon(R.drawable.ic_usb);
         mUsbPreference.setSelectable(false);
         mUsbPreference.setOnGearClickListener((GearPreference p) -> {
-            final Intent intent = new Intent(mContext, UsbModeChooserActivity.class);
-            mContext.startActivity(intent);
+            // New version - uses a separate screen.
+            final Bundle args = new Bundle();
+            final SettingsActivity activity = (SettingsActivity) mFragment.getContext();
+            activity.startPreferencePanel(mFragment,
+                    UsbDetailsFragment.class.getName(), args,
+                    R.string.device_details_title, null /* titleText */, null /* resultTo */, 0);
         });
 
         forceUpdate();
@@ -87,6 +95,5 @@
         // Register so we can get the connection state from sticky intent.
         //TODO(b/70336520): Use an API to get data instead of sticky intent
         mUsbReceiver.register();
-        mUsbConnectionListener.onUsbConnectionChanged(mUsbReceiver.isConnected());
     }
 }
diff --git a/src/com/android/settings/connecteddevice/usb/OWNERS b/src/com/android/settings/connecteddevice/usb/OWNERS
new file mode 100644
index 0000000..add985c
--- /dev/null
+++ b/src/com/android/settings/connecteddevice/usb/OWNERS
@@ -0,0 +1,3 @@
+# Default reviewers for this and subdirectories.
+zhangjerry@google.com
+badhri@google.com
diff --git a/src/com/android/settings/connecteddevice/usb/UsbBackend.java b/src/com/android/settings/connecteddevice/usb/UsbBackend.java
new file mode 100644
index 0000000..cdfb6b0
--- /dev/null
+++ b/src/com/android/settings/connecteddevice/usb/UsbBackend.java
@@ -0,0 +1,247 @@
+/*
+ * 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.connecteddevice.usb;
+
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.hardware.usb.UsbManager;
+import android.hardware.usb.UsbPort;
+import android.hardware.usb.UsbPortStatus;
+import android.net.ConnectivityManager;
+import android.os.UserHandle;
+import android.os.UserManager;
+import android.support.annotation.VisibleForTesting;
+
+public class UsbBackend {
+
+    public static final int MODE_POWER_MASK  = 0x01;
+    public static final int MODE_POWER_SINK   = 0x00;
+    public static final int MODE_POWER_SOURCE = 0x01;
+
+    public static final int MODE_DATA_MASK  = 0x0f << 1;
+    public static final int MODE_DATA_NONE   = 0;
+    public static final int MODE_DATA_MTP    = 0x01 << 1;
+    public static final int MODE_DATA_PTP    = 0x01 << 2;
+    public static final int MODE_DATA_MIDI   = 0x01 << 3;
+    public static final int MODE_DATA_TETHER   = 0x01 << 4;
+
+    private final boolean mFileTransferRestricted;
+    private final boolean mFileTransferRestrictedBySystem;
+    private final boolean mTetheringRestricted;
+    private final boolean mTetheringRestrictedBySystem;
+    private final boolean mMidiSupported;
+    private final boolean mTetheringSupported;
+
+    private UsbManager mUsbManager;
+    @VisibleForTesting
+    UsbManagerPassThrough mUsbManagerPassThrough;
+    private UsbPort mPort;
+    private UsbPortStatus mPortStatus;
+
+    private Context mContext;
+
+    public UsbBackend(Context context) {
+        this(context, new UserRestrictionUtil(context), null);
+    }
+
+    @VisibleForTesting
+    public UsbBackend(Context context, UserRestrictionUtil userRestrictionUtil,
+            UsbManagerPassThrough usbManagerPassThrough) {
+        mContext = context;
+        mUsbManager = context.getSystemService(UsbManager.class);
+
+        mUsbManagerPassThrough = usbManagerPassThrough;
+        if (mUsbManagerPassThrough == null) {
+            mUsbManagerPassThrough = new UsbManagerPassThrough(mUsbManager);
+        }
+
+        mFileTransferRestricted = userRestrictionUtil.isUsbFileTransferRestricted();
+        mFileTransferRestrictedBySystem = userRestrictionUtil.isUsbFileTransferRestrictedBySystem();
+        mTetheringRestricted = userRestrictionUtil.isUsbTetheringRestricted();
+        mTetheringRestrictedBySystem = userRestrictionUtil.isUsbTetheringRestrictedBySystem();
+
+        mMidiSupported = context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_MIDI);
+        ConnectivityManager cm =
+                (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
+        mTetheringSupported = cm.isTetheringSupported();
+
+        UsbPort[] ports = mUsbManager.getPorts();
+        if (ports == null) {
+            return;
+        }
+        // For now look for a connected port, in the future we should identify port in the
+        // notification and pick based on that.
+        final int N = ports.length;
+        for (int i = 0; i < N; i++) {
+            UsbPortStatus status = mUsbManager.getPortStatus(ports[i]);
+            if (status.isConnected()) {
+                mPort = ports[i];
+                mPortStatus = status;
+                break;
+            }
+        }
+    }
+
+    public int getCurrentMode() {
+        if (mPort != null) {
+            int power = mPortStatus.getCurrentPowerRole() == UsbPort.POWER_ROLE_SOURCE
+                    && mPortStatus.isConnected()
+                    ? MODE_POWER_SOURCE : MODE_POWER_SINK;
+            return power | getUsbDataMode();
+        }
+        return MODE_POWER_SINK | getUsbDataMode();
+    }
+
+    public int getUsbDataMode() {
+        long functions = mUsbManagerPassThrough.getCurrentFunctions();
+        if (functions == UsbManager.FUNCTION_MTP) {
+            return MODE_DATA_MTP;
+        } else if (functions == UsbManager.FUNCTION_PTP) {
+            return MODE_DATA_PTP;
+        } else if (functions == UsbManager.FUNCTION_MIDI) {
+            return MODE_DATA_MIDI;
+        } else if (functions == UsbManager.FUNCTION_RNDIS) {
+            return MODE_DATA_TETHER;
+        }
+        return MODE_DATA_NONE;
+    }
+
+    private void setUsbFunction(int mode) {
+        switch (mode) {
+            case MODE_DATA_MTP:
+                mUsbManager.setCurrentFunctions(UsbManager.FUNCTION_MTP);
+                break;
+            case MODE_DATA_PTP:
+                mUsbManager.setCurrentFunctions(UsbManager.FUNCTION_PTP);
+                break;
+            case MODE_DATA_MIDI:
+                mUsbManager.setCurrentFunctions(UsbManager.FUNCTION_MIDI);
+                break;
+            case MODE_DATA_TETHER:
+                mUsbManager.setCurrentFunctions(UsbManager.FUNCTION_RNDIS);
+                break;
+            default:
+                mUsbManager.setCurrentFunctions(UsbManager.FUNCTION_NONE);
+                break;
+        }
+    }
+
+    public void setMode(int mode) {
+        if (mPort != null) {
+            int powerRole = modeToPower(mode);
+            // If we aren't using any data modes and we support host mode, then go to host mode
+            // so maybe? the other device can provide data if it wants, otherwise go into device
+            // mode because we have no choice.
+            int dataRole = (mode & MODE_DATA_MASK) == MODE_DATA_NONE
+                    && mPortStatus.isRoleCombinationSupported(powerRole, UsbPort.DATA_ROLE_HOST)
+                    ? UsbPort.DATA_ROLE_HOST : UsbPort.DATA_ROLE_DEVICE;
+            mUsbManager.setPortRoles(mPort, powerRole, dataRole);
+        }
+        setUsbFunction(mode & MODE_DATA_MASK);
+    }
+
+    private int modeToPower(int mode) {
+        return (mode & MODE_POWER_MASK) == MODE_POWER_SOURCE
+                    ? UsbPort.POWER_ROLE_SOURCE : UsbPort.POWER_ROLE_SINK;
+    }
+
+    public boolean isModeDisallowed(int mode) {
+        if (mFileTransferRestricted && ((mode & MODE_DATA_MASK) == MODE_DATA_MTP
+                || (mode & MODE_DATA_MASK) == MODE_DATA_PTP)) {
+            return true;
+        } else if (mTetheringRestricted && ((mode & MODE_DATA_MASK) == MODE_DATA_TETHER)) {
+            return true;
+        }
+        return false;
+    }
+
+    public boolean isModeDisallowedBySystem(int mode) {
+        if (mFileTransferRestrictedBySystem && ((mode & MODE_DATA_MASK) == MODE_DATA_MTP
+                || (mode & MODE_DATA_MASK) == MODE_DATA_PTP)) {
+            return true;
+        } else if (mTetheringRestrictedBySystem && ((mode & MODE_DATA_MASK) == MODE_DATA_TETHER)) {
+            return true;
+        }
+        return false;
+    }
+
+    public boolean isModeSupported(int mode) {
+        if (!mMidiSupported && (mode & MODE_DATA_MASK) == MODE_DATA_MIDI) {
+            return false;
+        }
+        if (!mTetheringSupported && (mode & MODE_DATA_MASK) == MODE_DATA_TETHER) {
+                return false;
+        }
+        if (mPort != null) {
+            int power = modeToPower(mode);
+            if ((mode & MODE_DATA_MASK) != 0) {
+                // We have a port and data, need to be in device mode.
+                return mPortStatus.isRoleCombinationSupported(power,
+                        UsbPort.DATA_ROLE_DEVICE);
+            } else {
+                // No data needed, we can do this power mode in either device or host.
+                return mPortStatus.isRoleCombinationSupported(power, UsbPort.DATA_ROLE_DEVICE)
+                        || mPortStatus.isRoleCombinationSupported(power, UsbPort.DATA_ROLE_HOST);
+            }
+        }
+        // No port, support sink modes only.
+        return (mode & MODE_POWER_MASK) != MODE_POWER_SOURCE;
+    }
+
+    // Wrapper class to enable testing with UserManager APIs
+    public static class UserRestrictionUtil {
+        private UserManager mUserManager;
+
+        public UserRestrictionUtil(Context context) {
+            mUserManager = UserManager.get(context);
+        }
+
+        public boolean isUsbFileTransferRestricted() {
+            return mUserManager.hasUserRestriction(UserManager.DISALLOW_USB_FILE_TRANSFER);
+        }
+
+        public boolean isUsbTetheringRestricted() {
+            return mUserManager.hasUserRestriction(UserManager.DISALLOW_CONFIG_TETHERING);
+        }
+
+        public boolean isUsbFileTransferRestrictedBySystem() {
+            return mUserManager.hasBaseUserRestriction(
+                UserManager.DISALLOW_USB_FILE_TRANSFER, UserHandle.of(UserHandle.myUserId()));
+        }
+
+        public boolean isUsbTetheringRestrictedBySystem() {
+            return mUserManager.hasBaseUserRestriction(
+                UserManager.DISALLOW_CONFIG_TETHERING, UserHandle.of(UserHandle.myUserId()));
+        }
+    }
+
+    // Temporary pass-through to allow roboelectric to use getCurrentFunctions()
+    public static class UsbManagerPassThrough {
+        private UsbManager mUsbManager;
+
+        public UsbManagerPassThrough(UsbManager manager) {
+            mUsbManager = manager;
+        }
+
+        public long getCurrentFunctions() {
+            return mUsbManager.getCurrentFunctions();
+        }
+
+        public long usbFunctionsFromString(String str) {
+            return UsbManager.usbFunctionsFromString(str);
+        }
+    }
+}
diff --git a/src/com/android/settings/connecteddevice/usb/UsbConnectionBroadcastReceiver.java b/src/com/android/settings/connecteddevice/usb/UsbConnectionBroadcastReceiver.java
new file mode 100644
index 0000000..91d22dc
--- /dev/null
+++ b/src/com/android/settings/connecteddevice/usb/UsbConnectionBroadcastReceiver.java
@@ -0,0 +1,129 @@
+/*
+ * Copyright (C) 2017 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.connecteddevice.usb;
+
+
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.hardware.usb.UsbManager;
+import android.hardware.usb.UsbPort;
+import android.hardware.usb.UsbPortStatus;
+
+import com.android.settingslib.core.lifecycle.LifecycleObserver;
+import com.android.settingslib.core.lifecycle.events.OnResume;
+import com.android.settingslib.core.lifecycle.events.OnPause;
+
+/**
+ * Receiver to receive usb update and use {@link UsbConnectionListener} to invoke callback
+ */
+public class UsbConnectionBroadcastReceiver extends BroadcastReceiver implements LifecycleObserver,
+        OnResume, OnPause {
+    private Context mContext;
+    private UsbConnectionListener mUsbConnectionListener;
+    private boolean mListeningToUsbEvents;
+    private int mMode;
+    private boolean mConnected;
+    private UsbBackend mUsbBackend;
+
+    public UsbConnectionBroadcastReceiver(Context context,
+            UsbConnectionListener usbConnectionListener, UsbBackend backend) {
+        mContext = context;
+        mUsbConnectionListener = usbConnectionListener;
+        mUsbBackend = backend;
+    }
+
+    @Override
+    public void onReceive(Context context, Intent intent) {
+        if (UsbManager.ACTION_USB_STATE.equals(intent.getAction())) {
+            mConnected = intent.getExtras().getBoolean(UsbManager.USB_CONNECTED)
+                    || intent.getExtras().getBoolean(UsbManager.USB_HOST_CONNECTED);
+            if (mConnected) {
+                mMode &= UsbBackend.MODE_POWER_MASK;
+                if (intent.getExtras().getBoolean(UsbManager.USB_FUNCTION_MTP)
+                        && intent.getExtras().getBoolean(UsbManager.USB_DATA_UNLOCKED, false)) {
+                    mMode |= UsbBackend.MODE_DATA_MTP;
+                }
+                if (intent.getExtras().getBoolean(UsbManager.USB_FUNCTION_PTP)
+                        && intent.getExtras().getBoolean(UsbManager.USB_DATA_UNLOCKED, false)) {
+                    mMode |= UsbBackend.MODE_DATA_PTP;
+                }
+                if (intent.getExtras().getBoolean(UsbManager.USB_FUNCTION_MIDI)) {
+                    mMode |= UsbBackend.MODE_DATA_MIDI;
+                }
+                if (intent.getExtras().getBoolean(UsbManager.USB_FUNCTION_RNDIS)) {
+                    mMode |= UsbBackend.MODE_DATA_TETHER;
+                }
+            }
+        } else if (UsbManager.ACTION_USB_PORT_CHANGED.equals(intent.getAction())) {
+            mMode &= UsbBackend.MODE_DATA_MASK;
+            UsbPortStatus portStatus = intent.getExtras()
+                    .getParcelable(UsbManager.EXTRA_PORT_STATUS);
+            if (portStatus != null) {
+                mConnected = portStatus.isConnected();
+                if (mConnected) {
+                    mMode |= portStatus.getCurrentPowerRole() == UsbPort.POWER_ROLE_SOURCE
+                            ? UsbBackend.MODE_POWER_SOURCE : UsbBackend.MODE_POWER_SINK;
+                }
+            }
+        }
+        if (mUsbConnectionListener != null) {
+            mUsbConnectionListener.onUsbConnectionChanged(mConnected, mMode);
+        }
+    }
+
+    public void register() {
+        if (!mListeningToUsbEvents) {
+            mMode = mUsbBackend.getCurrentMode();
+            mConnected = false;
+            final IntentFilter intentFilter = new IntentFilter();
+            intentFilter.addAction(UsbManager.ACTION_USB_STATE);
+            intentFilter.addAction(UsbManager.ACTION_USB_PORT_CHANGED);
+            mContext.registerReceiver(this, intentFilter);
+            mListeningToUsbEvents = true;
+        }
+    }
+
+    public void unregister() {
+        if (mListeningToUsbEvents) {
+            mContext.unregisterReceiver(this);
+            mListeningToUsbEvents = false;
+        }
+    }
+
+    public boolean isConnected() {
+        return mConnected;
+    }
+
+    @Override
+    public void onResume() {
+        register();
+    }
+
+    @Override
+    public void onPause() {
+        unregister();
+    }
+
+    /**
+     * Interface definition for a callback to be invoked when usb connection is changed.
+     */
+    interface UsbConnectionListener {
+        void onUsbConnectionChanged(boolean connected, int newMode);
+    }
+}
diff --git a/src/com/android/settings/connecteddevice/usb/UsbDetailsController.java b/src/com/android/settings/connecteddevice/usb/UsbDetailsController.java
new file mode 100644
index 0000000..09c7554
--- /dev/null
+++ b/src/com/android/settings/connecteddevice/usb/UsbDetailsController.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2018 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.connecteddevice.usb;
+
+import android.content.Context;
+import android.support.annotation.UiThread;
+import android.support.v14.preference.PreferenceFragment;
+
+import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settingslib.core.AbstractPreferenceController;
+
+/**
+ * This class provides common members and refresh functionality for usb controllers.
+ */
+public abstract class UsbDetailsController extends AbstractPreferenceController
+        implements PreferenceControllerMixin {
+
+    protected final Context mContext;
+    protected final PreferenceFragment mFragment;
+    protected final UsbBackend mUsbBackend;
+
+    public UsbDetailsController(Context context, PreferenceFragment fragment, UsbBackend backend) {
+        super(context);
+        mContext = context;
+        mFragment = fragment;
+        mUsbBackend = backend;
+    }
+
+    @Override
+    public boolean isAvailable() {
+        return true;
+    }
+
+    /**
+     * This method is called when the USB mode has changed and the controller needs to update.
+     * @param newMode the new mode, made up of OR'd values from UsbBackend
+     */
+    @UiThread
+    protected abstract void refresh(int newMode);
+}
diff --git a/src/com/android/settings/connecteddevice/usb/UsbDetailsFragment.java b/src/com/android/settings/connecteddevice/usb/UsbDetailsFragment.java
new file mode 100644
index 0000000..c861188
--- /dev/null
+++ b/src/com/android/settings/connecteddevice/usb/UsbDetailsFragment.java
@@ -0,0 +1,131 @@
+/*
+ * Copyright (C) 2018 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.connecteddevice.usb;
+
+import android.content.Context;
+import android.hardware.usb.UsbManager;
+import android.os.Bundle;
+import android.provider.SearchIndexableResource;
+import android.support.annotation.VisibleForTesting;
+
+import com.android.internal.logging.nano.MetricsProto;
+import com.android.settings.R;
+
+import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.search.BaseSearchIndexProvider;
+import com.android.settings.search.Indexable;
+import com.android.settingslib.core.AbstractPreferenceController;
+
+import com.google.android.collect.Lists;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Controls the USB device details and provides updates to individual controllers.
+ */
+public class UsbDetailsFragment extends DashboardFragment {
+    private static final String TAG = UsbDetailsFragment.class.getSimpleName();
+
+    private List<UsbDetailsController> mControllers;
+    private UsbBackend mUsbBackend;
+
+    @VisibleForTesting
+    UsbConnectionBroadcastReceiver mUsbReceiver;
+
+    private UsbConnectionBroadcastReceiver.UsbConnectionListener mUsbConnectionListener =
+            (connected, newMode) -> {
+                if (!connected) {
+                    this.finish();
+                } else {
+                    for (UsbDetailsController controller : mControllers) {
+                        controller.refresh(newMode);
+                    }
+                }
+            };
+
+    @Override
+    public int getMetricsCategory() {
+        return MetricsProto.MetricsEvent.USB_DEVICE_DETAILS;
+    }
+
+    @Override
+    protected String getLogTag() {
+        return TAG;
+    }
+
+    @Override
+    protected int getPreferenceScreenResId() {
+        return R.xml.usb_details_fragment;
+    }
+
+    @Override
+    public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
+        super.onCreatePreferences(savedInstanceState, rootKey);
+    }
+
+    @Override
+    protected List<AbstractPreferenceController> getPreferenceControllers(Context context) {
+        mUsbBackend = new UsbBackend(context);
+        mControllers = createControllerList(context, mUsbBackend, this);
+        mUsbReceiver = new UsbConnectionBroadcastReceiver(context, mUsbConnectionListener,
+                mUsbBackend);
+        this.getLifecycle().addObserver(mUsbReceiver);
+
+        List<AbstractPreferenceController> ret = new ArrayList<>();
+        ret.addAll(mControllers);
+        return ret;
+    }
+
+    private static List<UsbDetailsController> createControllerList(Context context,
+            UsbBackend usbBackend, DashboardFragment fragment) {
+        List<UsbDetailsController> ret = new ArrayList<>();
+        ret.add(new UsbDetailsHeaderController(context, fragment, usbBackend));
+        ret.add(new UsbDetailsProfilesController(context, fragment,
+                usbBackend, Lists.newArrayList(UsbManager.USB_FUNCTION_MTP), "usb_main_options"));
+        ret.add(new UsbDetailsProfilesController(context, fragment,
+                usbBackend, Lists.newArrayList(UsbDetailsProfilesController.KEY_POWER,
+                UsbManager.USB_FUNCTION_RNDIS, UsbManager.USB_FUNCTION_MIDI,
+                UsbManager.USB_FUNCTION_PTP), "usb_secondary_options"));
+        return ret;
+    }
+
+    /**
+     * For Search.
+     */
+    public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+            new BaseSearchIndexProvider() {
+                @Override
+                public List<SearchIndexableResource> getXmlResourcesToIndex(
+                        Context context, boolean enabled) {
+                    return new ArrayList<>();
+                }
+
+                @Override
+                public List<String> getNonIndexableKeys(Context context) {
+                    return super.getNonIndexableKeys(context);
+                }
+
+                @Override
+                public List<AbstractPreferenceController> getPreferenceControllers(
+                        Context context) {
+                    List<AbstractPreferenceController> ret = new ArrayList<>();
+                    ret.addAll(createControllerList(context, new UsbBackend(context), null));
+                    return ret;
+                }
+            };
+}
diff --git a/src/com/android/settings/connecteddevice/usb/UsbDetailsHeaderController.java b/src/com/android/settings/connecteddevice/usb/UsbDetailsHeaderController.java
new file mode 100644
index 0000000..7ac0235
--- /dev/null
+++ b/src/com/android/settings/connecteddevice/usb/UsbDetailsHeaderController.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2018 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.connecteddevice.usb;
+
+import android.content.Context;
+import android.support.v14.preference.PreferenceFragment;
+import android.support.v7.preference.PreferenceScreen;
+
+import com.android.settings.R;
+import com.android.settings.applications.LayoutPreference;
+import com.android.settings.widget.EntityHeaderController;
+
+/**
+ * This class adds a header with device name and current function.
+ */
+public class UsbDetailsHeaderController extends UsbDetailsController {
+    private static final String KEY_DEVICE_HEADER = "usb_device_header";
+
+    private EntityHeaderController mHeaderController;
+
+    public UsbDetailsHeaderController(Context context, PreferenceFragment fragment,
+            UsbBackend backend) {
+        super(context, fragment, backend);
+    }
+
+    @Override
+    public void displayPreference(PreferenceScreen screen) {
+        super.displayPreference(screen);
+        final LayoutPreference headerPreference =
+                (LayoutPreference) screen.findPreference(KEY_DEVICE_HEADER);
+        mHeaderController = EntityHeaderController.newInstance(mFragment.getActivity(), mFragment,
+                headerPreference.findViewById(R.id.entity_header));
+        screen.addPreference(headerPreference);
+    }
+
+
+    @Override
+    protected void refresh(int newMode) {
+        mHeaderController.setLabel(mContext.getString(R.string.usb_pref));
+        mHeaderController.setIcon(mContext.getDrawable(R.drawable.ic_usb));
+        mHeaderController.setSummary(
+                mContext.getString(UsbModePreferenceController.getSummary(newMode)));
+        mHeaderController.done(mFragment.getActivity(), true /* rebindActions */);
+    }
+
+    @Override
+    public String getPreferenceKey() {
+        return KEY_DEVICE_HEADER;
+    }
+}
diff --git a/src/com/android/settings/connecteddevice/usb/UsbDetailsProfilesController.java b/src/com/android/settings/connecteddevice/usb/UsbDetailsProfilesController.java
new file mode 100644
index 0000000..1375b4c
--- /dev/null
+++ b/src/com/android/settings/connecteddevice/usb/UsbDetailsProfilesController.java
@@ -0,0 +1,147 @@
+/*
+ * Copyright (C) 2018 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.connecteddevice.usb;
+
+import com.android.settings.R;
+import android.content.Context;
+import android.hardware.usb.UsbManager;
+import android.support.v14.preference.PreferenceFragment;
+import android.support.v14.preference.SwitchPreference;
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceCategory;
+import android.support.v7.preference.PreferenceScreen;
+
+import java.util.List;
+
+/**
+ * This class adds switches for toggling individual USB options, such as "transfer files",
+ * "supply power", "usb tethering", etc.
+ */
+public class UsbDetailsProfilesController extends UsbDetailsController
+        implements Preference.OnPreferenceClickListener {
+
+    static final String KEY_POWER = "power";
+
+    private PreferenceCategory mProfilesContainer;
+    private List<String> mOptions;
+    private String mKey;
+
+    public UsbDetailsProfilesController(Context context, PreferenceFragment fragment,
+            UsbBackend backend, List<String> options, String key) {
+        super(context, fragment, backend);
+        mOptions = options;
+        mKey = key;
+    }
+
+    @Override
+    public void displayPreference(PreferenceScreen screen) {
+        super.displayPreference(screen);
+        mProfilesContainer = (PreferenceCategory) screen.findPreference(getPreferenceKey());
+    }
+
+    /**
+     * Gets a switch preference for the particular option, creating it if needed.
+     */
+    private SwitchPreference getProfilePreference(String key, int titleId) {
+        SwitchPreference pref = (SwitchPreference) mProfilesContainer.findPreference(key);
+        if (pref == null) {
+            pref = new SwitchPreference(mProfilesContainer.getContext());
+            pref.setKey(key);
+            pref.setTitle(titleId);
+            pref.setOnPreferenceClickListener(this);
+            mProfilesContainer.addPreference(pref);
+        }
+        return pref;
+    }
+
+    @Override
+    protected void refresh(int mode) {
+        SwitchPreference pref;
+        for (String option : mOptions) {
+            int newMode;
+            int summary = -1;
+            int title;
+            if (option.equals(UsbManager.USB_FUNCTION_MTP)) {
+                newMode = UsbBackend.MODE_DATA_MTP;
+                title = R.string.usb_use_file_transfers;
+            } else if (option.equals(KEY_POWER)) {
+                newMode = UsbBackend.MODE_POWER_SOURCE;
+                title = R.string.usb_use_power_only;
+                summary = R.string.usb_use_power_only_desc;
+            } else if (option.equals(UsbManager.USB_FUNCTION_PTP)) {
+                newMode = UsbBackend.MODE_DATA_PTP;
+                title = R.string.usb_use_photo_transfers;
+            } else if (option.equals(UsbManager.USB_FUNCTION_MIDI)) {
+                newMode = UsbBackend.MODE_DATA_MIDI;
+                title = R.string.usb_use_MIDI;
+            } else if (option.equals(UsbManager.USB_FUNCTION_RNDIS)) {
+                newMode = UsbBackend.MODE_DATA_TETHER;
+                title = R.string.usb_use_tethering;
+            } else {
+                continue;
+            }
+
+            pref = getProfilePreference(option, title);
+            // Only show supported and allowed options
+            if (mUsbBackend.isModeSupported(newMode)
+                    && !mUsbBackend.isModeDisallowedBySystem(newMode)
+                    && !mUsbBackend.isModeDisallowed(newMode)) {
+                if (summary != -1) {
+                    pref.setSummary(summary);
+                }
+                pref.setChecked((mode & newMode) != 0);
+            } else {
+                mProfilesContainer.removePreference(pref);
+            }
+        }
+    }
+
+    @Override
+    public boolean onPreferenceClick(Preference preference) {
+        SwitchPreference profilePref = (SwitchPreference) preference;
+        String key = profilePref.getKey();
+        int mode = mUsbBackend.getCurrentMode();
+        int thisMode = 0;
+        if (key.equals(KEY_POWER)) {
+            thisMode = UsbBackend.MODE_POWER_SOURCE;
+        } else if (key.equals(UsbManager.USB_FUNCTION_MTP)) {
+            thisMode = UsbBackend.MODE_DATA_MTP;
+        } else if (key.equals(UsbManager.USB_FUNCTION_PTP)) {
+            thisMode = UsbBackend.MODE_DATA_PTP;
+        } else if (key.equals(UsbManager.USB_FUNCTION_RNDIS)) {
+            thisMode = UsbBackend.MODE_DATA_TETHER;
+        } else if (key.equals(UsbManager.USB_FUNCTION_MIDI)) {
+            thisMode = UsbBackend.MODE_DATA_MIDI;
+        }
+        if (profilePref.isChecked()) {
+            if (!key.equals(KEY_POWER)) {
+                // Only one non power mode can currently be set at once.
+                mode &= UsbBackend.MODE_POWER_MASK;
+            }
+            mode |= thisMode;
+        } else {
+            mode &= ~thisMode;
+        }
+        mUsbBackend.setMode(mode);
+        return false;
+    }
+
+    @Override
+    public String getPreferenceKey() {
+        return mKey;
+    }
+}
diff --git a/src/com/android/settings/deviceinfo/UsbModeChooserActivity.java b/src/com/android/settings/connecteddevice/usb/UsbModeChooserActivity.java
similarity index 98%
rename from src/com/android/settings/deviceinfo/UsbModeChooserActivity.java
rename to src/com/android/settings/connecteddevice/usb/UsbModeChooserActivity.java
index 8ba3781..b3b0718 100644
--- a/src/com/android/settings/deviceinfo/UsbModeChooserActivity.java
+++ b/src/com/android/settings/connecteddevice/usb/UsbModeChooserActivity.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.settings.deviceinfo;
+package com.android.settings.connecteddevice.usb;
 
 import android.annotation.Nullable;
 import android.app.Activity;
diff --git a/src/com/android/settings/connecteddevice/UsbModePreferenceController.java b/src/com/android/settings/connecteddevice/usb/UsbModePreferenceController.java
similarity index 72%
rename from src/com/android/settings/connecteddevice/UsbModePreferenceController.java
rename to src/com/android/settings/connecteddevice/usb/UsbModePreferenceController.java
index 8693520..e342460 100644
--- a/src/com/android/settings/connecteddevice/UsbModePreferenceController.java
+++ b/src/com/android/settings/connecteddevice/usb/UsbModePreferenceController.java
@@ -13,15 +13,15 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.android.settings.connecteddevice;
+package com.android.settings.connecteddevice.usb;
 
 import android.content.Context;
 import android.support.v7.preference.Preference;
 import android.support.v7.preference.PreferenceScreen;
 
+import com.android.internal.annotations.VisibleForTesting;
 import com.android.settings.R;
 import com.android.settings.core.PreferenceControllerMixin;
-import com.android.settings.deviceinfo.UsbBackend;
 import com.android.settingslib.core.AbstractPreferenceController;
 import com.android.settingslib.core.lifecycle.LifecycleObserver;
 import com.android.settingslib.core.lifecycle.events.OnPause;
@@ -33,27 +33,27 @@
     private static final String KEY_USB_MODE = "usb_mode";
 
     private UsbBackend mUsbBackend;
-    private UsbConnectionBroadcastReceiver mUsbReceiver;
+    @VisibleForTesting
+    UsbConnectionBroadcastReceiver mUsbReceiver;
     private Preference mUsbPreference;
 
     public UsbModePreferenceController(Context context, UsbBackend usbBackend) {
         super(context);
         mUsbBackend = usbBackend;
-        mUsbReceiver = new UsbConnectionBroadcastReceiver(mContext, (connected) -> {
-            updateSummary(mUsbPreference);
-        });
+        mUsbReceiver = new UsbConnectionBroadcastReceiver(mContext, (connected, newMode) -> {
+            updateSummary(mUsbPreference, connected, newMode);
+        }, mUsbBackend);
     }
 
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
         mUsbPreference = screen.findPreference(KEY_USB_MODE);
-        updateSummary(mUsbPreference);
     }
 
     @Override
     public void updateState(Preference preference) {
-        updateSummary(preference);
+        updateSummary(preference, mUsbReceiver.isConnected(), mUsbBackend.getCurrentMode());
     }
 
     @Override
@@ -88,17 +88,24 @@
                 return R.string.usb_summary_photo_transfers;
             case UsbBackend.MODE_POWER_SINK | UsbBackend.MODE_DATA_MIDI:
                 return R.string.usb_summary_MIDI;
+            case UsbBackend.MODE_POWER_SINK | UsbBackend.MODE_DATA_TETHER:
+                return R.string.usb_summary_tether;
+            case UsbBackend.MODE_POWER_SOURCE | UsbBackend.MODE_DATA_MTP:
+                return R.string.usb_summary_file_transfers_power;
+            case UsbBackend.MODE_POWER_SOURCE | UsbBackend.MODE_DATA_PTP:
+                return R.string.usb_summary_photo_transfers_power;
+            case UsbBackend.MODE_POWER_SOURCE | UsbBackend.MODE_DATA_MIDI:
+                return R.string.usb_summary_MIDI_power;
+            case UsbBackend.MODE_POWER_SOURCE | UsbBackend.MODE_DATA_TETHER:
+                return R.string.usb_summary_tether_power;
+            default:
+                return R.string.usb_summary_charging_only;
         }
-        return 0;
     }
 
-    private void updateSummary(Preference preference) {
-        updateSummary(preference, mUsbBackend.getCurrentMode());
-    }
-
-    private void updateSummary(Preference preference, int mode) {
+    private void updateSummary(Preference preference, boolean connected, int mode) {
         if (preference != null) {
-            if (mUsbReceiver.isConnected()) {
+            if (connected) {
                 preference.setEnabled(true);
                 preference.setSummary(getSummary(mode));
             } else {
@@ -107,5 +114,4 @@
             }
         }
     }
-
 }
diff --git a/src/com/android/settings/core/FeatureFlags.java b/src/com/android/settings/core/FeatureFlags.java
index e1636b4..8fa1bb3 100644
--- a/src/com/android/settings/core/FeatureFlags.java
+++ b/src/com/android/settings/core/FeatureFlags.java
@@ -20,13 +20,10 @@
  * This class keeps track of all feature flags in Settings.
  */
 public class FeatureFlags {
-    public static final String APP_INFO_V2 = "settings_app_info_v2";
     public static final String CONNECTED_DEVICE_V2 = "settings_connected_device_v2";
     public static final String BATTERY_SETTINGS_V2 = "settings_battery_v2";
     public static final String BATTERY_DISPLAY_APP_LIST = "settings_battery_display_app_list";
-    public static final String SECURITY_SETTINGS_V2 = "settings_security_settings_v2";
     public static final String ZONE_PICKER_V2 = "settings_zone_picker_v2";
-    public static final String SUGGESTION_UI_V2 = "settings_suggestion_ui_v2";
     public static final String ABOUT_PHONE_V2 = "settings_about_phone_v2";
     public static final String BLUETOOTH_WHILE_DRIVING = "settings_bluetooth_while_driving";
 }
diff --git a/src/com/android/settings/core/gateway/SettingsGateway.java b/src/com/android/settings/core/gateway/SettingsGateway.java
index ecf0584..f43c3c8 100644
--- a/src/com/android/settings/core/gateway/SettingsGateway.java
+++ b/src/com/android/settings/core/gateway/SettingsGateway.java
@@ -39,9 +39,7 @@
 import com.android.settings.accounts.AccountDashboardFragment;
 import com.android.settings.applications.AppAndNotificationDashboardFragment;
 import com.android.settings.applications.DefaultAppSettings;
-import com.android.settings.applications.InstalledAppDetails;
 import com.android.settings.applications.ManageDomainUrls;
-import com.android.settings.applications.NotificationApps;
 import com.android.settings.applications.ProcessStatsSummary;
 import com.android.settings.applications.ProcessStatsUi;
 import com.android.settings.applications.DirectoryAccessDetails;
@@ -60,6 +58,7 @@
 import com.android.settings.connecteddevice.AdvancedConnectedDeviceDashboardFragment;
 import com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment;
 import com.android.settings.connecteddevice.ConnectedDeviceDashboardFragmentOld;
+import com.android.settings.connecteddevice.usb.UsbDetailsFragment;
 import com.android.settings.datausage.DataPlanUsageSummary;
 import com.android.settings.datausage.DataUsageList;
 import com.android.settings.datausage.DataUsageSummary;
@@ -116,7 +115,6 @@
 import com.android.settings.security.CryptKeeperSettings;
 import com.android.settings.security.LockscreenDashboardFragment;
 import com.android.settings.security.SecuritySettings;
-import com.android.settings.security.SecuritySettingsV2;
 import com.android.settings.sim.SimSettings;
 import com.android.settings.support.SupportDashboardActivity;
 import com.android.settings.system.ResetDashboardFragment;
@@ -159,13 +157,11 @@
             DisplaySettings.class.getName(),
             DeviceInfoSettings.class.getName(),
             ManageApplications.class.getName(),
-            NotificationApps.class.getName(),
             ManageAssist.class.getName(),
             ProcessStatsUi.class.getName(),
             NotificationStation.class.getName(),
             LocationSettings.class.getName(),
             SecuritySettings.class.getName(),
-            SecuritySettingsV2.class.getName(),
             UsageAccessDetails.class.getName(),
             PrivacySettings.class.getName(),
             DeviceAdminSettings.class.getName(),
@@ -209,7 +205,6 @@
             ConfigureNotificationSettings.class.getName(),
             ChooseLockPassword.ChooseLockPasswordFragment.class.getName(),
             ChooseLockPattern.ChooseLockPatternFragment.class.getName(),
-            InstalledAppDetails.class.getName(),
             AppInfoDashboardFragment.class.getName(),
             BatterySaverSettings.class.getName(),
             AppNotificationSettings.class.getName(),
@@ -248,6 +243,7 @@
             NetworkDashboardFragment.class.getName(),
             ConnectedDeviceDashboardFragment.class.getName(),
             ConnectedDeviceDashboardFragmentOld.class.getName(),
+            UsbDetailsFragment.class.getName(),
             AppAndNotificationDashboardFragment.class.getName(),
             AccountDashboardFragment.class.getName(),
             EnterprisePrivacySettings.class.getName(),
@@ -271,8 +267,7 @@
             Settings.PowerUsageSummaryActivity.class.getName(),
             Settings.PowerUsageSummaryLegacyActivity.class.getName(),
             Settings.AccountDashboardActivity.class.getName(),
-            Settings.SecuritySettingsActivity.class.getName(),
-            Settings.SecuritySettingsActivityV2.class.getName(),
+            Settings.SecurityDashboardActivity.class.getName(),
             Settings.AccessibilitySettingsActivity.class.getName(),
             Settings.SystemDashboardActivity.class.getName(),
             SupportDashboardActivity.class.getName(),
diff --git a/src/com/android/settings/dashboard/DashboardAdapter.java b/src/com/android/settings/dashboard/DashboardAdapter.java
index 9b23417..8646683 100644
--- a/src/com/android/settings/dashboard/DashboardAdapter.java
+++ b/src/com/android/settings/dashboard/DashboardAdapter.java
@@ -17,9 +17,6 @@
 
 import android.app.Activity;
 import android.content.Context;
-import android.content.res.Resources;
-import android.content.res.TypedArray;
-import android.graphics.Color;
 import android.graphics.drawable.Drawable;
 import android.graphics.drawable.Icon;
 import android.os.Bundle;
@@ -41,44 +38,37 @@
 import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
 import com.android.settings.R;
 import com.android.settings.R.id;
-import com.android.settings.dashboard.DashboardData.SuggestionConditionHeaderData;
+import com.android.settings.dashboard.DashboardData.ConditionHeaderData;
 import com.android.settings.dashboard.conditional.Condition;
 import com.android.settings.dashboard.conditional.ConditionAdapter;
 import com.android.settings.dashboard.suggestions.SuggestionAdapter;
-import com.android.settings.dashboard.suggestions.SuggestionDismissController;
 import com.android.settings.overlay.FeatureFactory;
-import com.android.settingslib.Utils;
 import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+import com.android.settingslib.core.lifecycle.LifecycleObserver;
+import com.android.settingslib.core.lifecycle.events.OnSaveInstanceState;
 import com.android.settingslib.drawer.DashboardCategory;
 import com.android.settingslib.drawer.Tile;
 import com.android.settingslib.suggestions.SuggestionControllerMixin;
 
-import java.util.ArrayList;
 import java.util.List;
 
 public class DashboardAdapter extends RecyclerView.Adapter<DashboardAdapter.DashboardItemHolder>
-        implements SummaryLoader.SummaryConsumer {
+    implements SummaryLoader.SummaryConsumer, SuggestionAdapter.Callback, LifecycleObserver,
+    OnSaveInstanceState {
     public static final String TAG = "DashboardAdapter";
-    private static final String STATE_SUGGESTION_LIST = "suggestion_list";
     private static final String STATE_CATEGORY_LIST = "category_list";
-    private static final String STATE_SUGGESTIONS_SHOWN_LOGGED = "suggestions_shown_logged";
 
     @VisibleForTesting
-    static final String STATE_SUGGESTION_CONDITION_MODE = "suggestion_condition_mode";
-    @VisibleForTesting
-    static final int SUGGESTION_CONDITION_HEADER_POSITION = 0;
+    static final String STATE_CONDITION_EXPANDED = "condition_expanded";
 
     private final IconCache mCache;
     private final Context mContext;
-    private final SuggestionControllerMixin mSuggestionControllerMixin;
     private final MetricsFeatureProvider mMetricsFeatureProvider;
     private final DashboardFeatureProvider mDashboardFeatureProvider;
-    private final ArrayList<String> mSuggestionsShownLogged;
     private boolean mFirstFrameDrawn;
     private RecyclerView mRecyclerView;
     private SuggestionAdapter mSuggestionAdapter;
-    private SuggestionDismissController mSuggestionDismissHandler;
-    private SuggestionDismissController.Callback mCallback;
 
     @VisibleForTesting
     DashboardData mDashboardData;
@@ -92,57 +82,54 @@
     };
 
     public DashboardAdapter(Context context, Bundle savedInstanceState,
-            List<Condition> conditions, SuggestionControllerMixin suggestionControllerMixin,
-            SuggestionDismissController.Callback callback) {
+        List<Condition> conditions, SuggestionControllerMixin suggestionControllerMixin,
+        Lifecycle lifecycle) {
 
-        List<Suggestion> suggestions = null;
         DashboardCategory category = null;
-        int suggestionConditionMode = DashboardData.HEADER_MODE_DEFAULT;
+        boolean conditionExpanded = false;
 
         mContext = context;
         final FeatureFactory factory = FeatureFactory.getFactory(context);
-        mSuggestionControllerMixin = suggestionControllerMixin;
         mMetricsFeatureProvider = factory.getMetricsFeatureProvider();
         mDashboardFeatureProvider = factory.getDashboardFeatureProvider(context);
         mCache = new IconCache(context);
-        mCallback = callback;
+        mSuggestionAdapter = new SuggestionAdapter(mContext, suggestionControllerMixin,
+            savedInstanceState, this /* callback */, lifecycle);
 
         setHasStableIds(true);
 
         if (savedInstanceState != null) {
-            suggestions = savedInstanceState.getParcelableArrayList(STATE_SUGGESTION_LIST);
             category = savedInstanceState.getParcelable(STATE_CATEGORY_LIST);
-            suggestionConditionMode = savedInstanceState.getInt(
-                    STATE_SUGGESTION_CONDITION_MODE, suggestionConditionMode);
-            mSuggestionsShownLogged = savedInstanceState.getStringArrayList(
-                    STATE_SUGGESTIONS_SHOWN_LOGGED);
-        } else {
-            mSuggestionsShownLogged = new ArrayList<>();
+            conditionExpanded = savedInstanceState.getBoolean(
+                STATE_CONDITION_EXPANDED, conditionExpanded);
+        }
+
+        if (lifecycle != null) {
+            lifecycle.addObserver(this);
         }
 
         mDashboardData = new DashboardData.Builder()
-                .setConditions(conditions)
-                .setSuggestions(suggestions)
-                .setCategory(category)
-                .setSuggestionConditionMode(suggestionConditionMode)
-                .build();
+            .setConditions(conditions)
+            .setSuggestions(mSuggestionAdapter.getSuggestions())
+            .setCategory(category)
+            .setConditionExpanded(conditionExpanded)
+            .build();
     }
 
     public void setSuggestions(List<Suggestion> data) {
         final DashboardData prevData = mDashboardData;
         mDashboardData = new DashboardData.Builder(prevData)
-                .setSuggestions(data)
-                .build();
+            .setSuggestions(data)
+            .build();
         notifyDashboardDataChanged(prevData);
     }
 
     public void setCategory(DashboardCategory category) {
-        tintIcons(category, null);
         final DashboardData prevData = mDashboardData;
         Log.d(TAG, "adapter setCategory called");
         mDashboardData = new DashboardData.Builder(prevData)
-                .setCategory(category)
-                .build();
+            .setCategory(category)
+            .build();
         notifyDashboardDataChanged(prevData);
     }
 
@@ -150,12 +137,13 @@
         final DashboardData prevData = mDashboardData;
         Log.d(TAG, "adapter setConditions called");
         mDashboardData = new DashboardData.Builder(prevData)
-                .setConditions(conditions)
-                .build();
+            .setConditions(conditions)
+            .build();
         notifyDashboardDataChanged(prevData);
     }
 
-    public void onSuggestionDismissed(Suggestion suggestion) {
+    @Override
+    public void onSuggestionClosed(Suggestion suggestion) {
         final List<Suggestion> list = mDashboardData.getSuggestions();
         if (list == null || list.size() == 0) {
             return;
@@ -163,13 +151,10 @@
         if (list.size() == 1) {
             // The only suggestion is dismissed, and the the empty suggestion container will
             // remain as the dashboard item. Need to refresh the dashboard list.
-            final DashboardData prevData = mDashboardData;
-            mDashboardData = new DashboardData.Builder(prevData)
-                    .setSuggestions(null)
-                    .build();
-            notifyDashboardDataChanged(prevData);
+            setSuggestions(null);
         } else {
             mSuggestionAdapter.removeSuggestion(suggestion);
+            notifyItemChanged(0, null);
         }
     }
 
@@ -186,11 +171,14 @@
     @Override
     public DashboardItemHolder onCreateViewHolder(ViewGroup parent, int viewType) {
         final View view = LayoutInflater.from(parent.getContext()).inflate(viewType, parent, false);
-        if (viewType == R.layout.suggestion_condition_header) {
-            return new SuggestionAndConditionHeaderHolder(view);
+        if (viewType == R.layout.condition_header) {
+            return new ConditionHeaderHolder(view);
         }
-        if (viewType == R.layout.suggestion_condition_container) {
-            return new SuggestionAndConditionContainerHolder(view);
+        if (viewType == R.layout.condition_container) {
+            return new ConditionContainerHolder(view);
+        }
+        if (viewType == R.layout.suggestion_container) {
+            return new SuggestionContainerHolder(view);
         }
         return new DashboardItemHolder(view);
     }
@@ -205,24 +193,25 @@
                 holder.itemView.setTag(tile);
                 holder.itemView.setOnClickListener(mTileClickListener);
                 break;
-            case R.layout.suggestion_condition_container:
-                onBindConditionAndSuggestion(
-                        (SuggestionAndConditionContainerHolder) holder, position);
+            case R.layout.suggestion_container:
+                onBindSuggestion((SuggestionContainerHolder) holder, position);
                 break;
-            case R.layout.suggestion_condition_header:
-                onBindSuggestionConditionHeader((SuggestionAndConditionHeaderHolder) holder,
-                        (SuggestionConditionHeaderData)
-                                mDashboardData.getItemEntityByPosition(position));
+            case R.layout.condition_container:
+                onBindCondition((ConditionContainerHolder) holder, position);
                 break;
-            case R.layout.suggestion_condition_footer:
+            case R.layout.condition_header:
+                onBindConditionHeader((ConditionHeaderHolder) holder,
+                    (ConditionHeaderData) mDashboardData.getItemEntityByPosition(position));
+                break;
+            case R.layout.condition_footer:
                 holder.itemView.setOnClickListener(v -> {
                     mMetricsFeatureProvider.action(mContext,
-                            MetricsEvent.ACTION_SETTINGS_CONDITION_EXPAND, false);
+                        MetricsEvent.ACTION_SETTINGS_CONDITION_EXPAND, false);
                     DashboardData prevData = mDashboardData;
-                    mDashboardData = new DashboardData.Builder(prevData).setSuggestionConditionMode(
-                            DashboardData.HEADER_MODE_COLLAPSED).build();
+                    mDashboardData = new DashboardData.Builder(prevData).
+                        setConditionExpanded(false).build();
                     notifyDashboardDataChanged(prevData);
-                    mRecyclerView.scrollToPosition(SUGGESTION_CONDITION_HEADER_POSITION);
+                    scrollToTopOfConditions();
                 });
                 break;
         }
@@ -263,7 +252,7 @@
     void notifyDashboardDataChanged(DashboardData prevData) {
         if (mFirstFrameDrawn && prevData != null) {
             final DiffUtil.DiffResult diffResult = DiffUtil.calculateDiff(new DashboardData
-                    .ItemsDataDiffCallback(prevData.getItemList(), mDashboardData.getItemList()));
+                .ItemsDataDiffCallback(prevData.getItemList(), mDashboardData.getItemList()));
             diffResult.dispatchUpdatesTo(this);
         } else {
             mFirstFrameDrawn = true;
@@ -272,120 +261,66 @@
     }
 
     @VisibleForTesting
-    void onBindSuggestionConditionHeader(final SuggestionAndConditionHeaderHolder holder,
-            SuggestionConditionHeaderData data) {
-        final int curMode = mDashboardData.getSuggestionConditionMode();
-        final int nextMode = data.hiddenSuggestionCount > 0
-                && data.conditionCount > 0
-                && curMode != DashboardData.HEADER_MODE_SUGGESTION_EXPANDED
-                ? DashboardData.HEADER_MODE_SUGGESTION_EXPANDED
-                : DashboardData.HEADER_MODE_FULLY_EXPANDED;
-
-        final boolean hasConditions = data.conditionCount > 0;
-        if (data.conditionCount > 0) {
-            holder.icon.setImageIcon(data.conditionIcons.get(0));
-            holder.icon.setVisibility(View.VISIBLE);
-            if (data.conditionCount == 1) {
-                holder.title.setText(data.title);
-                holder.title.setTextColor(Utils.getColorAccent(mContext));
-                holder.icons.setVisibility(View.INVISIBLE);
-            } else {
-                holder.title.setText(null);
-                updateConditionIcons(data.conditionIcons, holder.icons);
-                holder.icons.setVisibility(View.VISIBLE);
-            }
-        } else {
-            holder.icon.setVisibility(View.INVISIBLE);
-            holder.icons.setVisibility(View.INVISIBLE);
-        }
-
-        if (data.hiddenSuggestionCount > 0) {
-            holder.summary.setTextColor(Color.BLACK);
-            if (curMode == DashboardData.HEADER_MODE_COLLAPSED) {
-                if (data.conditionCount > 0) {
-                    holder.summary.setText(mContext.getResources().getQuantityString(
-                            R.plurals.suggestions_collapsed_summary,
-                            data.hiddenSuggestionCount, data.hiddenSuggestionCount));
-                } else {
-                    holder.title.setText(mContext.getResources().getQuantityString(
-                            R.plurals.suggestions_collapsed_title,
-                            data.hiddenSuggestionCount, data.hiddenSuggestionCount));
-                    holder.title.setTextColor(Color.BLACK);
-                    holder.summary.setText(null);
-                }
-            } else if (curMode == DashboardData.HEADER_MODE_DEFAULT) {
-                if (data.conditionCount > 0) {
-                    holder.summary.setText(mContext.getString(
-                            R.string.suggestions_summary, data.hiddenSuggestionCount));
-                } else {
-                    holder.title.setText(mContext.getString(
-                            R.string.suggestions_more_title, data.hiddenSuggestionCount));
-                    holder.title.setTextColor(Color.BLACK);
-                    holder.summary.setText(null);
-                }
-            }
-        } else if (data.conditionCount > 1) {
-            holder.summary.setTextColor(Utils.getColorAccent(mContext));
-            holder.summary.setText(
-                    mContext.getString(R.string.condition_summary, data.conditionCount));
-        } else {
+    void onBindConditionHeader(final ConditionHeaderHolder holder, ConditionHeaderData data) {
+        holder.icon.setImageIcon(data.conditionIcons.get(0));
+        if (data.conditionCount == 1) {
+            holder.title.setText(data.title);
             holder.summary.setText(null);
+            holder.icons.setVisibility(View.INVISIBLE);
+        } else {
+            holder.title.setText(null);
+            holder.summary.setText(
+                mContext.getString(R.string.condition_summary, data.conditionCount));
+            updateConditionIcons(data.conditionIcons, holder.icons);
+            holder.icons.setVisibility(View.VISIBLE);
         }
 
-        final Resources res = mContext.getResources();
-        final int padding = res.getDimensionPixelOffset(
-                curMode == DashboardData.HEADER_MODE_COLLAPSED
-                        ? R.dimen.suggestion_condition_header_padding_collapsed
-                        : R.dimen.suggestion_condition_header_padding_expanded);
-        holder.itemView.setPadding(0, padding, 0, padding);
-
         holder.itemView.setOnClickListener(v -> {
-            if (hasConditions) {
-                mMetricsFeatureProvider.action(mContext,
-                        MetricsEvent.ACTION_SETTINGS_CONDITION_EXPAND, true);
-            }
-            DashboardData prevData = mDashboardData;
-            final boolean wasCollapsed = curMode == DashboardData.HEADER_MODE_COLLAPSED;
+            mMetricsFeatureProvider.action(mContext,
+                MetricsEvent.ACTION_SETTINGS_CONDITION_EXPAND, true);
+            final DashboardData prevData = mDashboardData;
             mDashboardData = new DashboardData.Builder(prevData)
-                    .setSuggestionConditionMode(nextMode).build();
+                .setConditionExpanded(true).build();
             notifyDashboardDataChanged(prevData);
-            if (wasCollapsed) {
-                mRecyclerView.scrollToPosition(SUGGESTION_CONDITION_HEADER_POSITION);
-            }
+            scrollToTopOfConditions();
         });
     }
 
     @VisibleForTesting
-    void onBindConditionAndSuggestion(final SuggestionAndConditionContainerHolder holder,
-            int position) {
-        // If there is suggestions to show, it will be at position 0 as we don't show the suggestion
-        // header anymore.
-        final List<Suggestion> suggestions = mDashboardData.getSuggestions();
-
-        boolean conditionOnly = true;
-        if (position == SUGGESTION_CONDITION_HEADER_POSITION) {
-           if (suggestions != null && suggestions.size() > 0) {
-                conditionOnly = false;
-                mSuggestionAdapter = new SuggestionAdapter(mContext, mSuggestionControllerMixin,
-                        (List<Suggestion>) mDashboardData.getItemEntityByPosition(position),
-                        mSuggestionsShownLogged);
-                mSuggestionDismissHandler = new SuggestionDismissController(mContext,
-                        holder.data, mSuggestionControllerMixin, mCallback);
-                holder.data.setAdapter(mSuggestionAdapter);
-            }
-        }
-        if (conditionOnly) {
-            ConditionAdapter adapter = new ConditionAdapter(mContext,
-                    (List<Condition>) mDashboardData.getItemEntityByPosition(position),
-                    mDashboardData.getSuggestionConditionMode());
-            adapter.addDismissHandling(holder.data);
-            holder.data.setAdapter(adapter);
-        }
+    void onBindCondition(final ConditionContainerHolder holder, int position) {
+        final ConditionAdapter adapter = new ConditionAdapter(mContext,
+            (List<Condition>) mDashboardData.getItemEntityByPosition(position),
+            mDashboardData.isConditionExpanded());
+        adapter.addDismissHandling(holder.data);
+        holder.data.setAdapter(adapter);
         holder.data.setLayoutManager(new LinearLayoutManager(mContext));
     }
 
-    private void onBindTile(DashboardItemHolder holder, Tile tile) {
-        holder.icon.setImageDrawable(mCache.getIcon(tile.icon));
+    @VisibleForTesting
+    void onBindSuggestion(final SuggestionContainerHolder holder, int position) {
+        // If there is suggestions to show, it will be at position 0 as we don't show the suggestion
+        // header anymore.
+        final List<Suggestion> suggestions =
+            (List<Suggestion>) mDashboardData.getItemEntityByPosition(position);
+        final int suggestionCount = suggestions.size();
+        if (suggestions != null && suggestionCount > 0) {
+            holder.summary.setText("" + suggestionCount);
+            mSuggestionAdapter.setSuggestions(suggestions);
+            holder.data.setAdapter(mSuggestionAdapter);
+        }
+        final LinearLayoutManager layoutManager = new LinearLayoutManager(mContext);
+        layoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
+        holder.data.setLayoutManager(layoutManager);
+    }
+
+    @VisibleForTesting
+    void onBindTile(DashboardItemHolder holder, Tile tile) {
+        Drawable icon = mCache.getIcon(tile.icon);
+        if (!TextUtils.equals(tile.icon.getResPackage(), mContext.getPackageName())) {
+            icon = new RoundedHomepageIcon(mContext, icon);
+            mCache.updateIcon(tile.icon, icon);
+        }
+        holder.icon.setImageDrawable(icon);
         holder.title.setText(tile.title);
         if (!TextUtils.isEmpty(tile.summary)) {
             holder.summary.setText(tile.summary);
@@ -395,45 +330,13 @@
         }
     }
 
-    private void tintIcons(DashboardCategory category, List<Tile> suggestions) {
-        if (!mDashboardFeatureProvider.shouldTintIcon()) {
-            return;
-        }
-        // TODO: Better place for tinting?
-        final TypedArray a = mContext.obtainStyledAttributes(new int[]{
-                android.R.attr.colorControlNormal});
-        final int tintColor = a.getColor(0, mContext.getColor(R.color.fallback_tintColor));
-        a.recycle();
-        if (category != null) {
-            for (Tile tile : category.getTiles()) {
-                if (tile.isIconTintable) {
-                    // If this drawable is tintable, tint it to match the color.
-                    tile.icon.setTint(tintColor);
-                }
-            }
-        }
-        if (suggestions != null) {
-            for (Tile suggestion : suggestions) {
-                if (suggestion.isIconTintable) {
-                    suggestion.icon.setTint(tintColor);
-                }
-            }
-        }
-    }
-
-    void onSaveInstanceState(Bundle outState) {
+    @Override
+    public void onSaveInstanceState(Bundle outState) {
         final DashboardCategory category = mDashboardData.getCategory();
-        final List<Suggestion> suggestions = mDashboardData.getSuggestions();
-        if (suggestions != null) {
-            outState.putParcelableArrayList(STATE_SUGGESTION_LIST,
-                    new ArrayList<>(suggestions));
-        }
         if (category != null) {
             outState.putParcelable(STATE_CATEGORY_LIST, category);
         }
-        outState.putStringArrayList(STATE_SUGGESTIONS_SHOWN_LOGGED, mSuggestionsShownLogged);
-        outState.putInt(STATE_SUGGESTION_CONDITION_MODE,
-                mDashboardData.getSuggestionConditionMode());
+        outState.putBoolean(STATE_CONDITION_EXPANDED, mDashboardData.isConditionExpanded());
     }
 
     private void updateConditionIcons(List<Icon> icons, ViewGroup parent) {
@@ -452,6 +355,10 @@
         parent.setVisibility(View.VISIBLE);
     }
 
+    private void scrollToTopOfConditions() {
+        mRecyclerView.scrollToPosition(mDashboardData.hasSuggestion() ? 1 : 0);
+    }
+
     public static class IconCache {
         private final Context mContext;
         private final ArrayMap<Icon, Drawable> mMap = new ArrayMap<>();
@@ -467,10 +374,14 @@
             Drawable drawable = mMap.get(icon);
             if (drawable == null) {
                 drawable = icon.loadDrawable(mContext);
-                mMap.put(icon, drawable);
+                updateIcon(icon, drawable);
             }
             return drawable;
         }
+
+        public void updateIcon(Icon icon, Drawable drawable) {
+            mMap.put(icon, drawable);
+        }
     }
 
     public static class DashboardItemHolder extends RecyclerView.ViewHolder {
@@ -486,24 +397,33 @@
         }
     }
 
-    public static class SuggestionAndConditionHeaderHolder extends DashboardItemHolder {
+    public static class ConditionHeaderHolder extends DashboardItemHolder {
         public final LinearLayout icons;
         public final ImageView expandIndicator;
 
-        public SuggestionAndConditionHeaderHolder(View itemView) {
+        public ConditionHeaderHolder(View itemView) {
             super(itemView);
             icons = itemView.findViewById(id.additional_icons);
             expandIndicator = itemView.findViewById(id.expand_indicator);
         }
     }
 
-    public static class SuggestionAndConditionContainerHolder extends DashboardItemHolder {
+    public static class ConditionContainerHolder extends DashboardItemHolder {
         public final RecyclerView data;
 
-        public SuggestionAndConditionContainerHolder(View itemView) {
+        public ConditionContainerHolder(View itemView) {
             super(itemView);
             data = itemView.findViewById(id.data);
         }
     }
 
+    public static class SuggestionContainerHolder extends DashboardItemHolder {
+        public final RecyclerView data;
+
+        public SuggestionContainerHolder(View itemView) {
+            super(itemView);
+            data = itemView.findViewById(id.suggestion_list);
+        }
+    }
+
 }
diff --git a/src/com/android/settings/dashboard/DashboardAdapterV2.java b/src/com/android/settings/dashboard/DashboardAdapterV2.java
deleted file mode 100644
index 7cd4f38..0000000
--- a/src/com/android/settings/dashboard/DashboardAdapterV2.java
+++ /dev/null
@@ -1,432 +0,0 @@
-/*
- * Copyright (C) 2018 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.dashboard;
-
-import android.app.Activity;
-import android.content.Context;
-import android.graphics.drawable.Drawable;
-import android.graphics.drawable.Icon;
-import android.os.Bundle;
-import android.service.settings.suggestions.Suggestion;
-import android.support.annotation.VisibleForTesting;
-import android.support.v7.util.DiffUtil;
-import android.support.v7.widget.LinearLayoutManager;
-import android.support.v7.widget.RecyclerView;
-import android.text.TextUtils;
-import android.util.ArrayMap;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ImageView;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-
-import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.settings.R;
-import com.android.settings.R.id;
-import com.android.settings.dashboard.DashboardDataV2.ConditionHeaderData;
-import com.android.settings.dashboard.conditional.Condition;
-import com.android.settings.dashboard.conditional.ConditionAdapterV2;
-import com.android.settings.dashboard.suggestions.SuggestionAdapterV2;
-import com.android.settings.overlay.FeatureFactory;
-import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
-import com.android.settingslib.core.lifecycle.Lifecycle;
-import com.android.settingslib.core.lifecycle.LifecycleObserver;
-import com.android.settingslib.core.lifecycle.events.OnSaveInstanceState;
-import com.android.settingslib.drawer.DashboardCategory;
-import com.android.settingslib.drawer.Tile;
-import com.android.settingslib.suggestions.SuggestionControllerMixin;
-
-import java.util.List;
-
-public class DashboardAdapterV2 extends RecyclerView.Adapter<DashboardAdapterV2.DashboardItemHolder>
-        implements SummaryLoader.SummaryConsumer, SuggestionAdapterV2.Callback, LifecycleObserver,
-        OnSaveInstanceState {
-    public static final String TAG = "DashboardAdapterV2";
-    private static final String STATE_CATEGORY_LIST = "category_list";
-
-    @VisibleForTesting
-    static final String STATE_CONDITION_EXPANDED = "condition_expanded";
-
-    private final IconCache mCache;
-    private final Context mContext;
-    private final MetricsFeatureProvider mMetricsFeatureProvider;
-    private final DashboardFeatureProvider mDashboardFeatureProvider;
-    private boolean mFirstFrameDrawn;
-    private RecyclerView mRecyclerView;
-    private SuggestionAdapterV2 mSuggestionAdapter;
-
-    @VisibleForTesting
-    DashboardDataV2 mDashboardData;
-
-    private View.OnClickListener mTileClickListener = new View.OnClickListener() {
-        @Override
-        public void onClick(View v) {
-            //TODO: get rid of setTag/getTag
-            mDashboardFeatureProvider.openTileIntent((Activity) mContext, (Tile) v.getTag());
-        }
-    };
-
-    public DashboardAdapterV2(Context context, Bundle savedInstanceState,
-            List<Condition> conditions, SuggestionControllerMixin suggestionControllerMixin,
-            Lifecycle lifecycle) {
-
-        DashboardCategory category = null;
-        boolean conditionExpanded = false;
-
-        mContext = context;
-        final FeatureFactory factory = FeatureFactory.getFactory(context);
-        mMetricsFeatureProvider = factory.getMetricsFeatureProvider();
-        mDashboardFeatureProvider = factory.getDashboardFeatureProvider(context);
-        mCache = new IconCache(context);
-        mSuggestionAdapter = new SuggestionAdapterV2(mContext, suggestionControllerMixin,
-                savedInstanceState, this /* callback */, lifecycle);
-
-        setHasStableIds(true);
-
-        if (savedInstanceState != null) {
-            category = savedInstanceState.getParcelable(STATE_CATEGORY_LIST);
-            conditionExpanded = savedInstanceState.getBoolean(
-                    STATE_CONDITION_EXPANDED, conditionExpanded);
-        }
-
-        if (lifecycle != null) {
-            lifecycle.addObserver(this);
-        }
-
-        mDashboardData = new DashboardDataV2.Builder()
-                .setConditions(conditions)
-                .setSuggestions(mSuggestionAdapter.getSuggestions())
-                .setCategory(category)
-                .setConditionExpanded(conditionExpanded)
-                .build();
-    }
-
-    public void setSuggestions(List<Suggestion> data) {
-        final DashboardDataV2 prevData = mDashboardData;
-        mDashboardData = new DashboardDataV2.Builder(prevData)
-                .setSuggestions(data)
-                .build();
-        notifyDashboardDataChanged(prevData);
-    }
-
-    public void setCategory(DashboardCategory category) {
-        final DashboardDataV2 prevData = mDashboardData;
-        Log.d(TAG, "adapter setCategory called");
-        mDashboardData = new DashboardDataV2.Builder(prevData)
-                .setCategory(category)
-                .build();
-        notifyDashboardDataChanged(prevData);
-    }
-
-    public void setConditions(List<Condition> conditions) {
-        final DashboardDataV2 prevData = mDashboardData;
-        Log.d(TAG, "adapter setConditions called");
-        mDashboardData = new DashboardDataV2.Builder(prevData)
-                .setConditions(conditions)
-                .build();
-        notifyDashboardDataChanged(prevData);
-    }
-
-    @Override
-    public void onSuggestionClosed(Suggestion suggestion) {
-        final List<Suggestion> list = mDashboardData.getSuggestions();
-        if (list == null || list.size() == 0) {
-            return;
-        }
-        if (list.size() == 1) {
-            // The only suggestion is dismissed, and the the empty suggestion container will
-            // remain as the dashboard item. Need to refresh the dashboard list.
-            final DashboardDataV2 prevData = mDashboardData;
-            mDashboardData = new DashboardDataV2.Builder(prevData)
-                    .setSuggestions(null)
-                    .build();
-            notifyDashboardDataChanged(prevData);
-        } else {
-            mSuggestionAdapter.removeSuggestion(suggestion);
-        }
-    }
-
-    @Override
-    public void notifySummaryChanged(Tile tile) {
-        final int position = mDashboardData.getPositionByTile(tile);
-        if (position != DashboardDataV2.POSITION_NOT_FOUND) {
-            // Since usually tile in parameter and tile in mCategories are same instance,
-            // which is hard to be detected by DiffUtil, so we notifyItemChanged directly.
-            notifyItemChanged(position, mDashboardData.getItemTypeByPosition(position));
-        }
-    }
-
-    @Override
-    public DashboardItemHolder onCreateViewHolder(ViewGroup parent, int viewType) {
-        final View view = LayoutInflater.from(parent.getContext()).inflate(viewType, parent, false);
-        if (viewType == R.layout.suggestion_condition_header) {
-            return new ConditionHeaderHolder(view);
-        }
-        if (viewType == R.layout.condition_container) {
-            return new ConditionContainerHolder(view);
-        }
-        if (viewType == R.layout.suggestion_container) {
-            return new SuggestionContainerHolder(view);
-        }
-        return new DashboardItemHolder(view);
-    }
-
-    @Override
-    public void onBindViewHolder(DashboardItemHolder holder, int position) {
-        final int type = mDashboardData.getItemTypeByPosition(position);
-        switch (type) {
-            case R.layout.dashboard_tile:
-                final Tile tile = (Tile) mDashboardData.getItemEntityByPosition(position);
-                onBindTile(holder, tile);
-                holder.itemView.setTag(tile);
-                holder.itemView.setOnClickListener(mTileClickListener);
-                break;
-            case R.layout.suggestion_container:
-                onBindSuggestion((SuggestionContainerHolder) holder, position);
-                break;
-            case R.layout.condition_container:
-                onBindCondition((ConditionContainerHolder) holder, position);
-                break;
-            case R.layout.suggestion_condition_header:
-                onBindConditionHeader((ConditionHeaderHolder) holder,
-                        (ConditionHeaderData) mDashboardData.getItemEntityByPosition(position));
-                break;
-            case R.layout.suggestion_condition_footer:
-                holder.itemView.setOnClickListener(v -> {
-                    mMetricsFeatureProvider.action(mContext,
-                            MetricsEvent.ACTION_SETTINGS_CONDITION_EXPAND, false);
-                    DashboardDataV2 prevData = mDashboardData;
-                    mDashboardData = new DashboardDataV2.Builder(prevData).
-                            setConditionExpanded(false).build();
-                    notifyDashboardDataChanged(prevData);
-                    scrollToTopOfConditions();
-                });
-                break;
-        }
-    }
-
-    @Override
-    public long getItemId(int position) {
-        return mDashboardData.getItemIdByPosition(position);
-    }
-
-    @Override
-    public int getItemViewType(int position) {
-        return mDashboardData.getItemTypeByPosition(position);
-    }
-
-    @Override
-    public int getItemCount() {
-        return mDashboardData.size();
-    }
-
-    @Override
-    public void onAttachedToRecyclerView(RecyclerView recyclerView) {
-        super.onAttachedToRecyclerView(recyclerView);
-        // save the view so that we can scroll it when expanding/collapsing the suggestion and
-        // conditions.
-        mRecyclerView = recyclerView;
-    }
-
-    public Object getItem(long itemId) {
-        return mDashboardData.getItemEntityById(itemId);
-    }
-
-    public Suggestion getSuggestion(int position) {
-        return mSuggestionAdapter.getSuggestion(position);
-    }
-
-    @VisibleForTesting
-    void notifyDashboardDataChanged(DashboardDataV2 prevData) {
-        if (mFirstFrameDrawn && prevData != null) {
-            final DiffUtil.DiffResult diffResult = DiffUtil.calculateDiff(new DashboardDataV2
-                    .ItemsDataDiffCallback(prevData.getItemList(), mDashboardData.getItemList()));
-            diffResult.dispatchUpdatesTo(this);
-        } else {
-            mFirstFrameDrawn = true;
-            notifyDataSetChanged();
-        }
-    }
-
-    @VisibleForTesting
-    void onBindConditionHeader(final ConditionHeaderHolder holder, ConditionHeaderData data) {
-        holder.icon.setImageIcon(data.conditionIcons.get(0));
-        if (data.conditionCount == 1) {
-            holder.title.setText(data.title);
-            holder.summary.setText(null);
-            holder.icons.setVisibility(View.INVISIBLE);
-        } else {
-            holder.title.setText(null);
-            holder.summary.setText(
-                    mContext.getString(R.string.condition_summary, data.conditionCount));
-            updateConditionIcons(data.conditionIcons, holder.icons);
-            holder.icons.setVisibility(View.VISIBLE);
-        }
-
-        holder.itemView.setOnClickListener(v -> {
-            mMetricsFeatureProvider.action(mContext,
-                    MetricsEvent.ACTION_SETTINGS_CONDITION_EXPAND, true);
-            final DashboardDataV2 prevData = mDashboardData;
-            mDashboardData = new DashboardDataV2.Builder(prevData)
-                    .setConditionExpanded(true).build();
-            notifyDashboardDataChanged(prevData);
-            scrollToTopOfConditions();
-        });
-    }
-
-    @VisibleForTesting
-    void onBindCondition(final ConditionContainerHolder holder, int position) {
-        final ConditionAdapterV2 adapter = new ConditionAdapterV2(mContext,
-                (List<Condition>) mDashboardData.getItemEntityByPosition(position),
-                mDashboardData.isConditionExpanded());
-        adapter.addDismissHandling(holder.data);
-        holder.data.setAdapter(adapter);
-        holder.data.setLayoutManager(new LinearLayoutManager(mContext));
-    }
-
-    @VisibleForTesting
-    void onBindSuggestion(final SuggestionContainerHolder holder, int position) {
-        // If there is suggestions to show, it will be at position 0 as we don't show the suggestion
-        // header anymore.
-        final List<Suggestion> suggestions =
-                (List<Suggestion>) mDashboardData.getItemEntityByPosition(position);
-        final int suggestionCount = suggestions.size();
-        if (suggestions != null && suggestionCount > 0) {
-            holder.summary.setText("" + suggestionCount);
-            mSuggestionAdapter.setSuggestions(suggestions);
-            holder.data.setAdapter(mSuggestionAdapter);
-        }
-        final LinearLayoutManager layoutManager = new LinearLayoutManager(mContext);
-        layoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
-        holder.data.setLayoutManager(layoutManager);
-    }
-
-    @VisibleForTesting
-    void onBindTile(DashboardItemHolder holder, Tile tile) {
-        Drawable icon = mCache.getIcon(tile.icon);
-        if (!TextUtils.equals(tile.icon.getResPackage(), mContext.getPackageName())) {
-            icon = new RoundedHomepageIcon(mContext, icon);
-            mCache.updateIcon(tile.icon, icon);
-        }
-        holder.icon.setImageDrawable(icon);
-        holder.title.setText(tile.title);
-        if (!TextUtils.isEmpty(tile.summary)) {
-            holder.summary.setText(tile.summary);
-            holder.summary.setVisibility(View.VISIBLE);
-        } else {
-            holder.summary.setVisibility(View.GONE);
-        }
-    }
-
-    @Override
-    public void onSaveInstanceState(Bundle outState) {
-        final DashboardCategory category = mDashboardData.getCategory();
-        if (category != null) {
-            outState.putParcelable(STATE_CATEGORY_LIST, category);
-        }
-        outState.putBoolean(STATE_CONDITION_EXPANDED, mDashboardData.isConditionExpanded());
-    }
-
-    private void updateConditionIcons(List<Icon> icons, ViewGroup parent) {
-        if (icons == null || icons.size() < 2) {
-            parent.setVisibility(View.INVISIBLE);
-            return;
-        }
-        final LayoutInflater inflater = LayoutInflater.from(parent.getContext());
-        parent.removeAllViews();
-        for (int i = 1, size = icons.size(); i < size; i++) {
-            ImageView icon = (ImageView) inflater.inflate(
-                    R.layout.condition_header_icon, parent, false);
-            icon.setImageIcon(icons.get(i));
-            parent.addView(icon);
-        }
-        parent.setVisibility(View.VISIBLE);
-    }
-
-    private void scrollToTopOfConditions() {
-        mRecyclerView.scrollToPosition(mDashboardData.hasSuggestion() ? 1 : 0);
-    }
-
-    public static class IconCache {
-        private final Context mContext;
-        private final ArrayMap<Icon, Drawable> mMap = new ArrayMap<>();
-
-        public IconCache(Context context) {
-            mContext = context;
-        }
-
-        public Drawable getIcon(Icon icon) {
-            if (icon == null) {
-                return null;
-            }
-            Drawable drawable = mMap.get(icon);
-            if (drawable == null) {
-                drawable = icon.loadDrawable(mContext);
-                updateIcon(icon, drawable);
-            }
-            return drawable;
-        }
-
-        public void updateIcon(Icon icon, Drawable drawable) {
-            mMap.put(icon, drawable);
-        }
-    }
-
-    public static class DashboardItemHolder extends RecyclerView.ViewHolder {
-        public final ImageView icon;
-        public final TextView title;
-        public final TextView summary;
-
-        public DashboardItemHolder(View itemView) {
-            super(itemView);
-            icon = itemView.findViewById(android.R.id.icon);
-            title = itemView.findViewById(android.R.id.title);
-            summary = itemView.findViewById(android.R.id.summary);
-        }
-    }
-
-    public static class ConditionHeaderHolder extends DashboardItemHolder {
-        public final LinearLayout icons;
-        public final ImageView expandIndicator;
-
-        public ConditionHeaderHolder(View itemView) {
-            super(itemView);
-            icons = itemView.findViewById(id.additional_icons);
-            expandIndicator = itemView.findViewById(id.expand_indicator);
-        }
-    }
-
-    public static class ConditionContainerHolder extends DashboardItemHolder {
-        public final RecyclerView data;
-
-        public ConditionContainerHolder(View itemView) {
-            super(itemView);
-            data = itemView.findViewById(id.data);
-        }
-    }
-
-    public static class SuggestionContainerHolder extends DashboardItemHolder {
-        public final RecyclerView data;
-
-        public SuggestionContainerHolder(View itemView) {
-            super(itemView);
-            data = itemView.findViewById(id.suggestion_list);
-        }
-    }
-
-}
diff --git a/src/com/android/settings/dashboard/DashboardData.java b/src/com/android/settings/dashboard/DashboardData.java
index da2a526..49de94d 100644
--- a/src/com/android/settings/dashboard/DashboardData.java
+++ b/src/com/android/settings/dashboard/DashboardData.java
@@ -40,29 +40,17 @@
  * ItemsData has inner class Item, which represents the Item in data list.
  */
 public class DashboardData {
-    public static final int HEADER_MODE_DEFAULT = 0;
-    public static final int HEADER_MODE_SUGGESTION_EXPANDED = 1;
-    public static final int HEADER_MODE_FULLY_EXPANDED = 2;
-    public static final int HEADER_MODE_COLLAPSED = 3;
-
-    @Retention(RetentionPolicy.SOURCE)
-    @IntDef({HEADER_MODE_DEFAULT, HEADER_MODE_SUGGESTION_EXPANDED, HEADER_MODE_FULLY_EXPANDED,
-            HEADER_MODE_COLLAPSED})
-    public @interface HeaderMode {
-    }
-
     public static final int POSITION_NOT_FOUND = -1;
-    public static final int DEFAULT_SUGGESTION_COUNT = 2;
+    public static final int MAX_SUGGESTION_COUNT = 4;
 
     // stable id for different type of items.
     @VisibleForTesting
-    static final int STABLE_ID_SUGGESTION_CONDITION_TOP_HEADER = 0;
+    static final int STABLE_ID_SUGGESTION_CONTAINER = 0;
+    static final int STABLE_ID_SUGGESTION_CONDITION_DIVIDER = 1;
     @VisibleForTesting
-    static final int STABLE_ID_SUGGESTION_CONDITION_MIDDLE_HEADER = 1;
+    static final int STABLE_ID_CONDITION_HEADER = 2;
     @VisibleForTesting
-    static final int STABLE_ID_SUGGESTION_CONDITION_FOOTER = 2;
-    @VisibleForTesting
-    static final int STABLE_ID_SUGGESTION_CONTAINER = 3;
+    static final int STABLE_ID_CONDITION_FOOTER = 3;
     @VisibleForTesting
     static final int STABLE_ID_CONDITION_CONTAINER = 4;
 
@@ -70,15 +58,13 @@
     private final DashboardCategory mCategory;
     private final List<Condition> mConditions;
     private final List<Suggestion> mSuggestions;
-    @HeaderMode
-    private final int mSuggestionConditionMode;
+    private final boolean mConditionExpanded;
 
     private DashboardData(Builder builder) {
         mCategory = builder.mCategory;
         mConditions = builder.mConditions;
-        mSuggestions = builder.mSuggestionsV2;
-        mSuggestionConditionMode = builder.mSuggestionConditionMode;
-
+        mSuggestions = builder.mSuggestions;
+        mConditionExpanded = builder.mConditionExpanded;
         mItems = new ArrayList<>();
 
         buildItemsData();
@@ -125,8 +111,12 @@
         return mSuggestions;
     }
 
-    public int getSuggestionConditionMode() {
-        return mSuggestionConditionMode;
+    public boolean hasSuggestion() {
+        return sizeOf(mSuggestions) > 0;
+    }
+
+    public boolean isConditionExpanded() {
+        return mConditionExpanded;
     }
 
     /**
@@ -188,69 +178,42 @@
 
     /**
      * Build the mItems list using mConditions, mSuggestions, mCategories data
-     * and mIsShowingAll, mSuggestionConditionMode flag.
+     * and mIsShowingAll, mConditionExpanded flag.
      */
     private void buildItemsData() {
-        final boolean hasSuggestions = sizeOf(mSuggestions) > 0;
         final List<Condition> conditions = getConditionsToShow(mConditions);
         final boolean hasConditions = sizeOf(conditions) > 0;
 
         final List<Suggestion> suggestions = getSuggestionsToShow(mSuggestions);
+        final boolean hasSuggestions = sizeOf(suggestions) > 0;
 
-        final int hiddenSuggestion = hasSuggestions
-                ? sizeOf(mSuggestions) - sizeOf(suggestions)
-                : 0;
+        /* Suggestion container. This is the card view that contains the list of suggestions.
+         * This will be added whenever the suggestion list is not empty */
+        addToItemList(suggestions, R.layout.suggestion_container,
+            STABLE_ID_SUGGESTION_CONTAINER, hasSuggestions);
 
-        final boolean hasSuggestionAndCollapsed = hasSuggestions
-                && mSuggestionConditionMode == HEADER_MODE_COLLAPSED;
-        final boolean onlyHasConditionAndCollapsed = !hasSuggestions
-                && hasConditions
-                && mSuggestionConditionMode != HEADER_MODE_FULLY_EXPANDED;
+        /* Divider between suggestion and conditions if both are present. */
+        addToItemList(null /* item */, R.layout.horizontal_divider,
+            STABLE_ID_SUGGESTION_CONDITION_DIVIDER, hasSuggestions && hasConditions);
 
-        /* Top suggestion/condition header. This will be present when there is any suggestion
-         * and the mode is collapsed */
-        addToItemList(new SuggestionConditionHeaderData(conditions, hiddenSuggestion),
-                R.layout.suggestion_condition_header,
-                STABLE_ID_SUGGESTION_CONDITION_TOP_HEADER, hasSuggestionAndCollapsed);
+        /* Condition header. This will be present when there is condition and it is collapsed */
+        addToItemList(new ConditionHeaderData(conditions),
+            R.layout.condition_header,
+            STABLE_ID_CONDITION_HEADER, hasConditions && !mConditionExpanded);
 
-        /* Use mid header if there is only condition & it's in collapsed mode */
-        addToItemList(new SuggestionConditionHeaderData(conditions, hiddenSuggestion),
-                R.layout.suggestion_condition_header,
-                STABLE_ID_SUGGESTION_CONDITION_MIDDLE_HEADER, onlyHasConditionAndCollapsed);
+        /* Condition container. This is the card view that contains the list of conditions.
+         * This will be added whenever the condition list is not empty and expanded */
+        addToItemList(conditions, R.layout.condition_container,
+            STABLE_ID_CONDITION_CONTAINER, hasConditions && mConditionExpanded);
 
-        addToItemList(suggestions, R.layout.suggestion_condition_container,
-                STABLE_ID_SUGGESTION_CONTAINER, sizeOf(suggestions) > 0);
-
-        /* Second suggestion/condition header. This will be added when there is at least one
-         * suggestion or condition that is not currently displayed, and the user can expand the
-         * section to view more items. */
-        addToItemList(new SuggestionConditionHeaderData(conditions, hiddenSuggestion),
-                R.layout.suggestion_condition_header,
-                STABLE_ID_SUGGESTION_CONDITION_MIDDLE_HEADER,
-                mSuggestionConditionMode != HEADER_MODE_COLLAPSED
-                        && mSuggestionConditionMode != HEADER_MODE_FULLY_EXPANDED
-                        && (hiddenSuggestion > 0 || hasConditions && hasSuggestions));
-
-            /* Condition container. This is the card view that contains the list of conditions.
-             * This will be added whenever the condition list is not empty */
-        addToItemList(conditions, R.layout.suggestion_condition_container,
-                STABLE_ID_CONDITION_CONTAINER,
-                hasConditions && mSuggestionConditionMode == HEADER_MODE_FULLY_EXPANDED);
-
-            /* Suggestion/condition footer. This will be present when the section is fully expanded
-             * or when there is no conditions and no hidden suggestions */
-        addToItemList(null /* item */, R.layout.suggestion_condition_footer,
-                STABLE_ID_SUGGESTION_CONDITION_FOOTER,
-                (hasConditions || hasSuggestions)
-                        && mSuggestionConditionMode == HEADER_MODE_FULLY_EXPANDED
-                        || hasSuggestions
-                        && !hasConditions
-                        && hiddenSuggestion == 0);
+        /* Condition footer. This will be present when there is condition and it is expanded */
+        addToItemList(null /* item */, R.layout.condition_footer,
+            STABLE_ID_CONDITION_FOOTER, hasConditions && mConditionExpanded);
 
         if (mCategory != null) {
             final List<Tile> tiles = mCategory.getTiles();
-            for (int j = 0; j < tiles.size(); j++) {
-                final Tile tile = tiles.get(j);
+            for (int i = 0; i < tiles.size(); i++) {
+                final Tile tile = tiles.get(i);
                 addToItemList(tile, R.layout.dashboard_tile, Objects.hash(tile.title),
                         true /* add */);
             }
@@ -277,28 +240,23 @@
     }
 
     private List<Suggestion> getSuggestionsToShow(List<Suggestion> suggestions) {
-        if (suggestions == null || mSuggestionConditionMode == HEADER_MODE_COLLAPSED) {
+        if (suggestions == null) {
             return null;
         }
-        if (mSuggestionConditionMode != HEADER_MODE_DEFAULT
-                || suggestions.size() <= DEFAULT_SUGGESTION_COUNT) {
+        if (suggestions.size() <= MAX_SUGGESTION_COUNT) {
             return suggestions;
         }
-        return suggestions.subList(0, DEFAULT_SUGGESTION_COUNT);
+        return suggestions.subList(0, MAX_SUGGESTION_COUNT);
     }
 
     /**
      * Builder used to build the ItemsData
-     * <p>
-     * {@link #mSuggestionConditionMode} have default value while others are not.
      */
     public static class Builder {
-        @HeaderMode
-        private int mSuggestionConditionMode = HEADER_MODE_DEFAULT;
-
         private DashboardCategory mCategory;
         private List<Condition> mConditions;
-        private List<Suggestion> mSuggestionsV2;
+        private List<Suggestion> mSuggestions;
+        private boolean mConditionExpanded;
 
         public Builder() {
         }
@@ -306,8 +264,8 @@
         public Builder(DashboardData dashboardData) {
             mCategory = dashboardData.mCategory;
             mConditions = dashboardData.mConditions;
-            mSuggestionsV2 = dashboardData.mSuggestions;
-            mSuggestionConditionMode = dashboardData.mSuggestionConditionMode;
+            mSuggestions = dashboardData.mSuggestions;
+            mConditionExpanded = dashboardData.mConditionExpanded;
         }
 
         public Builder setCategory(DashboardCategory category) {
@@ -321,12 +279,12 @@
         }
 
         public Builder setSuggestions(List<Suggestion> suggestions) {
-            this.mSuggestionsV2 = suggestions;
+            this.mSuggestions = suggestions;
             return this;
         }
 
-        public Builder setSuggestionConditionMode(@HeaderMode int mode) {
-            this.mSuggestionConditionMode = mode;
+        public Builder setConditionExpanded(boolean expanded) {
+            this.mConditionExpanded = expanded;
             return this;
         }
 
@@ -376,17 +334,18 @@
     static class Item {
         // valid types in field type
         private static final int TYPE_DASHBOARD_TILE = R.layout.dashboard_tile;
-        private static final int TYPE_SUGGESTION_CONDITION_CONTAINER =
-                R.layout.suggestion_condition_container;
-        private static final int TYPE_SUGGESTION_CONDITION_HEADER =
-                R.layout.suggestion_condition_header;
-        private static final int TYPE_SUGGESTION_CONDITION_FOOTER =
-                R.layout.suggestion_condition_footer;
-        private static final int TYPE_DASHBOARD_SPACER = R.layout.dashboard_spacer;
+        private static final int TYPE_SUGGESTION_CONTAINER =
+            R.layout.suggestion_container;
+        private static final int TYPE_CONDITION_CONTAINER =
+            R.layout.condition_container;
+        private static final int TYPE_CONDITION_HEADER =
+            R.layout.condition_header;
+        private static final int TYPE_CONDITION_FOOTER =
+            R.layout.condition_footer;
+        private static final int TYPE_SUGGESTION_CONDITION_DIVIDER = R.layout.horizontal_divider;
 
-        @IntDef({TYPE_DASHBOARD_TILE, TYPE_SUGGESTION_CONDITION_CONTAINER,
-                TYPE_SUGGESTION_CONDITION_HEADER, TYPE_SUGGESTION_CONDITION_FOOTER,
-                TYPE_DASHBOARD_SPACER})
+        @IntDef({TYPE_DASHBOARD_TILE, TYPE_SUGGESTION_CONTAINER, TYPE_CONDITION_CONTAINER,
+            TYPE_CONDITION_HEADER, TYPE_CONDITION_FOOTER, TYPE_SUGGESTION_CONDITION_DIVIDER})
         @Retention(RetentionPolicy.SOURCE)
         public @interface ItemTypes {
         }
@@ -444,8 +403,9 @@
 
                     // Only check title and summary for dashboard tile
                     return TextUtils.equals(localTile.title, targetTile.title)
-                            && TextUtils.equals(localTile.summary, targetTile.summary);
-                case TYPE_SUGGESTION_CONDITION_CONTAINER:
+                        && TextUtils.equals(localTile.summary, targetTile.summary);
+                case TYPE_SUGGESTION_CONTAINER:
+                case TYPE_CONDITION_CONTAINER:
                     // If entity is suggestion and contains remote view, force refresh
                     final List entities = (List) entity;
                     if (!entities.isEmpty()) {
@@ -467,16 +427,13 @@
      * This class contains the data needed to build the suggestion/condition header. The data can
      * also be used to check the diff in DiffUtil.Callback
      */
-    public static class SuggestionConditionHeaderData {
+    public static class ConditionHeaderData {
         public final List<Icon> conditionIcons;
         public final CharSequence title;
         public final int conditionCount;
-        public final int hiddenSuggestionCount;
 
-        public SuggestionConditionHeaderData(List<Condition> conditions,
-                int hiddenSuggestionCount) {
+        public ConditionHeaderData(List<Condition> conditions) {
             conditionCount = sizeOf(conditions);
-            this.hiddenSuggestionCount = hiddenSuggestionCount;
             title = conditionCount > 0 ? conditions.get(0).getTitle() : null;
             conditionIcons = new ArrayList<>();
             for (int i = 0; conditions != null && i < conditions.size(); i++) {
diff --git a/src/com/android/settings/dashboard/DashboardDataV2.java b/src/com/android/settings/dashboard/DashboardDataV2.java
deleted file mode 100644
index e25ee05..0000000
--- a/src/com/android/settings/dashboard/DashboardDataV2.java
+++ /dev/null
@@ -1,446 +0,0 @@
-/*
- * Copyright (C) 2018 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.dashboard;
-
-import android.annotation.IntDef;
-import android.graphics.drawable.Icon;
-import android.service.settings.suggestions.Suggestion;
-import android.support.annotation.VisibleForTesting;
-import android.support.v7.util.DiffUtil;
-import android.text.TextUtils;
-
-import com.android.settings.R;
-import com.android.settings.dashboard.conditional.Condition;
-import com.android.settingslib.drawer.DashboardCategory;
-import com.android.settingslib.drawer.Tile;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
-
-/**
- * Description about data list used in the DashboardAdapter. In the data list each item can be
- * Condition, suggestion or category tile.
- * <p>
- * ItemsData has inner class Item, which represents the Item in data list.
- */
-public class DashboardDataV2 {
-    public static final int POSITION_NOT_FOUND = -1;
-    public static final int MAX_SUGGESTION_COUNT = 4;
-
-    // stable id for different type of items.
-    @VisibleForTesting
-    static final int STABLE_ID_SUGGESTION_CONTAINER = 0;
-    static final int STABLE_ID_SUGGESTION_CONDITION_DIVIDER = 1;
-    @VisibleForTesting
-    static final int STABLE_ID_CONDITION_HEADER = 2;
-    @VisibleForTesting
-    static final int STABLE_ID_CONDITION_FOOTER = 3;
-    @VisibleForTesting
-    static final int STABLE_ID_CONDITION_CONTAINER = 4;
-
-    private final List<Item> mItems;
-    private final DashboardCategory mCategory;
-    private final List<Condition> mConditions;
-    private final List<Suggestion> mSuggestions;
-    private final boolean mConditionExpanded;
-
-    private DashboardDataV2(Builder builder) {
-        mCategory = builder.mCategory;
-        mConditions = builder.mConditions;
-        mSuggestions = builder.mSuggestions;
-        mConditionExpanded = builder.mConditionExpanded;
-        mItems = new ArrayList<>();
-
-        buildItemsData();
-    }
-
-    public int getItemIdByPosition(int position) {
-        return mItems.get(position).id;
-    }
-
-    public int getItemTypeByPosition(int position) {
-        return mItems.get(position).type;
-    }
-
-    public Object getItemEntityByPosition(int position) {
-        return mItems.get(position).entity;
-    }
-
-    public List<Item> getItemList() {
-        return mItems;
-    }
-
-    public int size() {
-        return mItems.size();
-    }
-
-    public Object getItemEntityById(long id) {
-        for (final Item item : mItems) {
-            if (item.id == id) {
-                return item.entity;
-            }
-        }
-        return null;
-    }
-
-    public DashboardCategory getCategory() {
-        return mCategory;
-    }
-
-    public List<Condition> getConditions() {
-        return mConditions;
-    }
-
-    public List<Suggestion> getSuggestions() {
-        return mSuggestions;
-    }
-
-    public boolean hasSuggestion() {
-        return sizeOf(mSuggestions) > 0;
-    }
-
-    public boolean isConditionExpanded() {
-        return mConditionExpanded;
-    }
-
-    /**
-     * Find the position of the object in mItems list, using the equals method to compare
-     *
-     * @param entity the object that need to be found in list
-     * @return position of the object, return POSITION_NOT_FOUND if object isn't in the list
-     */
-    public int getPositionByEntity(Object entity) {
-        if (entity == null) return POSITION_NOT_FOUND;
-
-        final int size = mItems.size();
-        for (int i = 0; i < size; i++) {
-            final Object item = mItems.get(i).entity;
-            if (entity.equals(item)) {
-                return i;
-            }
-        }
-
-        return POSITION_NOT_FOUND;
-    }
-
-    /**
-     * Find the position of the Tile object.
-     * <p>
-     * First, try to find the exact identical instance of the tile object, if not found,
-     * then try to find a tile has the same title.
-     *
-     * @param tile tile that need to be found
-     * @return position of the object, return INDEX_NOT_FOUND if object isn't in the list
-     */
-    public int getPositionByTile(Tile tile) {
-        final int size = mItems.size();
-        for (int i = 0; i < size; i++) {
-            final Object entity = mItems.get(i).entity;
-            if (entity == tile) {
-                return i;
-            } else if (entity instanceof Tile && tile.title.equals(((Tile) entity).title)) {
-                return i;
-            }
-        }
-
-        return POSITION_NOT_FOUND;
-    }
-
-    /**
-     * Add item into list when {@paramref add} is true.
-     *
-     * @param item     maybe {@link Condition}, {@link Tile}, {@link DashboardCategory} or null
-     * @param type     type of the item, and value is the layout id
-     * @param stableId The stable id for this item
-     * @param add      flag about whether to add item into list
-     */
-    private void addToItemList(Object item, int type, int stableId, boolean add) {
-        if (add) {
-            mItems.add(new Item(item, type, stableId));
-        }
-    }
-
-    /**
-     * Build the mItems list using mConditions, mSuggestions, mCategories data
-     * and mIsShowingAll, mConditionExpanded flag.
-     */
-    private void buildItemsData() {
-        final List<Condition> conditions = getConditionsToShow(mConditions);
-        final boolean hasConditions = sizeOf(conditions) > 0;
-
-        final List<Suggestion> suggestions = getSuggestionsToShow(mSuggestions);
-        final boolean hasSuggestions = sizeOf(suggestions) > 0;
-
-        /* Suggestion container. This is the card view that contains the list of suggestions.
-         * This will be added whenever the suggestion list is not empty */
-        addToItemList(suggestions, R.layout.suggestion_container,
-            STABLE_ID_SUGGESTION_CONTAINER, hasSuggestions);
-
-        /* Divider between suggestion and conditions if both are present. */
-        addToItemList(suggestions, R.layout.horizontal_divider,
-            STABLE_ID_SUGGESTION_CONDITION_DIVIDER, hasSuggestions && hasConditions);
-
-        /* Condition header. This will be present when there is condition and it is collapsed */
-        addToItemList(new ConditionHeaderData(conditions),
-            R.layout.suggestion_condition_header,
-            STABLE_ID_CONDITION_HEADER, hasConditions && !mConditionExpanded);
-
-        /* Condition container. This is the card view that contains the list of conditions.
-         * This will be added whenever the condition list is not empty and expanded */
-        addToItemList(conditions, R.layout.condition_container,
-            STABLE_ID_CONDITION_CONTAINER, hasConditions && mConditionExpanded);
-
-        /* Condition footer. This will be present when there is condition and it is expanded */
-        addToItemList(null /* item */, R.layout.suggestion_condition_footer,
-            STABLE_ID_CONDITION_FOOTER, hasConditions && mConditionExpanded);
-
-        if (mCategory != null) {
-            final List<Tile> tiles = mCategory.getTiles();
-            for (int i = 0; i < tiles.size(); i++) {
-                final Tile tile = tiles.get(i);
-                addToItemList(tile, R.layout.dashboard_tile, Objects.hash(tile.title),
-                    true /* add */);
-            }
-        }
-    }
-
-    private static int sizeOf(List<?> list) {
-        return list == null ? 0 : list.size();
-    }
-
-    private List<Condition> getConditionsToShow(List<Condition> conditions) {
-        if (conditions == null) {
-            return null;
-        }
-        List<Condition> result = new ArrayList<>();
-        final int size = conditions == null ? 0 : conditions.size();
-        for (int i = 0; i < size; i++) {
-            final Condition condition = conditions.get(i);
-            if (condition.shouldShow()) {
-                result.add(condition);
-            }
-        }
-        return result;
-    }
-
-    private List<Suggestion> getSuggestionsToShow(List<Suggestion> suggestions) {
-        if (suggestions == null) {
-            return null;
-        }
-        if (suggestions.size() <= MAX_SUGGESTION_COUNT) {
-            return suggestions;
-        }
-        return suggestions.subList(0, MAX_SUGGESTION_COUNT);
-    }
-
-    /**
-     * Builder used to build the ItemsData
-     */
-    public static class Builder {
-        private DashboardCategory mCategory;
-        private List<Condition> mConditions;
-        private List<Suggestion> mSuggestions;
-        private boolean mConditionExpanded;
-
-        public Builder() {
-        }
-
-        public Builder(DashboardDataV2 dashboardData) {
-            mCategory = dashboardData.mCategory;
-            mConditions = dashboardData.mConditions;
-            mSuggestions = dashboardData.mSuggestions;
-            mConditionExpanded = dashboardData.mConditionExpanded;
-        }
-
-        public Builder setCategory(DashboardCategory category) {
-            this.mCategory = category;
-            return this;
-        }
-
-        public Builder setConditions(List<Condition> conditions) {
-            this.mConditions = conditions;
-            return this;
-        }
-
-        public Builder setSuggestions(List<Suggestion> suggestions) {
-            this.mSuggestions = suggestions;
-            return this;
-        }
-
-        public Builder setConditionExpanded(boolean expanded) {
-            this.mConditionExpanded = expanded;
-            return this;
-        }
-
-        public DashboardDataV2 build() {
-            return new DashboardDataV2(this);
-        }
-    }
-
-    /**
-     * A DiffCallback to calculate the difference between old and new Item
-     * List in DashboardDataV2
-     */
-    public static class ItemsDataDiffCallback extends DiffUtil.Callback {
-        final private List<Item> mOldItems;
-        final private List<Item> mNewItems;
-
-        public ItemsDataDiffCallback(List<Item> oldItems, List<Item> newItems) {
-            mOldItems = oldItems;
-            mNewItems = newItems;
-        }
-
-        @Override
-        public int getOldListSize() {
-            return mOldItems.size();
-        }
-
-        @Override
-        public int getNewListSize() {
-            return mNewItems.size();
-        }
-
-        @Override
-        public boolean areItemsTheSame(int oldItemPosition, int newItemPosition) {
-            return mOldItems.get(oldItemPosition).id == mNewItems.get(newItemPosition).id;
-        }
-
-        @Override
-        public boolean areContentsTheSame(int oldItemPosition, int newItemPosition) {
-            return mOldItems.get(oldItemPosition).equals(mNewItems.get(newItemPosition));
-        }
-
-    }
-
-    /**
-     * An item contains the data needed in the DashboardDataV2.
-     */
-    static class Item {
-        // valid types in field type
-        private static final int TYPE_DASHBOARD_TILE = R.layout.dashboard_tile;
-        private static final int TYPE_SUGGESTION_CONTAINER =
-            R.layout.suggestion_container;
-        private static final int TYPE_CONDITION_CONTAINER =
-            R.layout.condition_container;
-        private static final int TYPE_CONDITION_HEADER =
-            R.layout.suggestion_condition_header;
-        private static final int TYPE_CONDITION_FOOTER =
-            R.layout.suggestion_condition_footer;
-        private static final int TYPE_SUGGESTION_CONDITION_DIVIDER = R.layout.horizontal_divider;
-
-        @IntDef({TYPE_DASHBOARD_TILE, TYPE_SUGGESTION_CONTAINER, TYPE_CONDITION_CONTAINER,
-            TYPE_CONDITION_HEADER, TYPE_CONDITION_FOOTER, TYPE_SUGGESTION_CONDITION_DIVIDER})
-        @Retention(RetentionPolicy.SOURCE)
-        public @interface ItemTypes {
-        }
-
-        /**
-         * The main data object in item, usually is a {@link Tile}, {@link Condition}
-         * object. This object can also be null when the
-         * item is an divider line. Please refer to {@link #buildItemsData()} for
-         * detail usage of the Item.
-         */
-        public final Object entity;
-
-        /**
-         * The type of item, value inside is the layout id(e.g. R.layout.dashboard_tile)
-         */
-        @ItemTypes
-        public final int type;
-
-        /**
-         * Id of this item, used in the {@link ItemsDataDiffCallback} to identify the same item.
-         */
-        public final int id;
-
-        public Item(Object entity, @ItemTypes int type, int id) {
-            this.entity = entity;
-            this.type = type;
-            this.id = id;
-        }
-
-        /**
-         * Override it to make comparision in the {@link ItemsDataDiffCallback}
-         *
-         * @param obj object to compared with
-         * @return true if the same object or has equal value.
-         */
-        @Override
-        public boolean equals(Object obj) {
-            if (this == obj) {
-                return true;
-            }
-
-            if (!(obj instanceof Item)) {
-                return false;
-            }
-
-            final Item targetItem = (Item) obj;
-            if (type != targetItem.type || id != targetItem.id) {
-                return false;
-            }
-
-            switch (type) {
-                case TYPE_DASHBOARD_TILE:
-                    final Tile localTile = (Tile) entity;
-                    final Tile targetTile = (Tile) targetItem.entity;
-
-                    // Only check title and summary for dashboard tile
-                    return TextUtils.equals(localTile.title, targetTile.title)
-                        && TextUtils.equals(localTile.summary, targetTile.summary);
-                case TYPE_SUGGESTION_CONTAINER:
-                case TYPE_CONDITION_CONTAINER:
-                    // If entity is suggestion and contains remote view, force refresh
-                    final List entities = (List) entity;
-                    if (!entities.isEmpty()) {
-                        Object firstEntity = entities.get(0);
-                        if (firstEntity instanceof Tile
-                            && ((Tile) firstEntity).remoteViews != null) {
-                            return false;
-                        }
-                    }
-                    // Otherwise Fall through to default
-                default:
-                    return entity == null ? targetItem.entity == null
-                        : entity.equals(targetItem.entity);
-            }
-        }
-    }
-
-    /**
-     * This class contains the data needed to build the suggestion/condition header. The data can
-     * also be used to check the diff in DiffUtil.Callback
-     */
-    public static class ConditionHeaderData {
-        public final List<Icon> conditionIcons;
-        public final CharSequence title;
-        public final int conditionCount;
-
-        public ConditionHeaderData(List<Condition> conditions) {
-            conditionCount = sizeOf(conditions);
-            title = conditionCount > 0 ? conditions.get(0).getTitle() : null;
-            conditionIcons = new ArrayList<>();
-            for (int i = 0; conditions != null && i < conditions.size(); i++) {
-                final Condition condition = conditions.get(i);
-                conditionIcons.add(condition.getIcon());
-            }
-        }
-    }
-
-}
\ No newline at end of file
diff --git a/src/com/android/settings/dashboard/DashboardFeatureProvider.java b/src/com/android/settings/dashboard/DashboardFeatureProvider.java
index e0873f5..6c3f9cd 100644
--- a/src/com/android/settings/dashboard/DashboardFeatureProvider.java
+++ b/src/com/android/settings/dashboard/DashboardFeatureProvider.java
@@ -90,9 +90,4 @@
      */
     void openTileIntent(Activity activity, Tile tile);
 
-    /**
-     * Whether or not we should use the v2 of suggestions UI.
-     */
-    boolean useSuggestionUiV2();
-
 }
diff --git a/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java b/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
index a14d9e9..086a131 100644
--- a/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
+++ b/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
@@ -217,11 +217,6 @@
         launchIntentOrSelectProfile(activity, tile, intent, MetricsEvent.DASHBOARD_SUMMARY);
     }
 
-    @Override
-    public boolean useSuggestionUiV2() {
-        return FeatureFlagUtils.isEnabled(mContext, FeatureFlags.SUGGESTION_UI_V2);
-    }
-
     private void bindSummary(Preference preference, Tile tile) {
         if (tile.summary != null) {
             preference.setSummary(tile.summary);
diff --git a/src/com/android/settings/dashboard/DashboardFragmentRegistry.java b/src/com/android/settings/dashboard/DashboardFragmentRegistry.java
index bb575ea..275af3d 100644
--- a/src/com/android/settings/dashboard/DashboardFragmentRegistry.java
+++ b/src/com/android/settings/dashboard/DashboardFragmentRegistry.java
@@ -33,7 +33,7 @@
 import com.android.settings.notification.ConfigureNotificationSettings;
 import com.android.settings.notification.SoundSettings;
 import com.android.settings.security.LockscreenDashboardFragment;
-import com.android.settings.security.SecuritySettingsV2;
+import com.android.settings.security.SecuritySettings;
 import com.android.settings.system.SystemDashboardFragment;
 import com.android.settingslib.drawer.CategoryKey;
 
@@ -77,7 +77,7 @@
                 CategoryKey.CATEGORY_SOUND);
         PARENT_TO_CATEGORY_KEY_MAP.put(StorageDashboardFragment.class.getName(),
                 CategoryKey.CATEGORY_STORAGE);
-        PARENT_TO_CATEGORY_KEY_MAP.put(SecuritySettingsV2.class.getName(),
+        PARENT_TO_CATEGORY_KEY_MAP.put(SecuritySettings.class.getName(),
                 CategoryKey.CATEGORY_SECURITY);
         PARENT_TO_CATEGORY_KEY_MAP.put(AccountDetailDashboardFragment.class.getName(),
                 CategoryKey.CATEGORY_ACCOUNT_DETAIL);
diff --git a/src/com/android/settings/dashboard/DashboardSummary.java b/src/com/android/settings/dashboard/DashboardSummary.java
index fc82d41..4f045a2 100644
--- a/src/com/android/settings/dashboard/DashboardSummary.java
+++ b/src/com/android/settings/dashboard/DashboardSummary.java
@@ -38,7 +38,7 @@
 import com.android.settings.dashboard.conditional.ConditionManager.ConditionListener;
 import com.android.settings.dashboard.conditional.FocusRecyclerView;
 import com.android.settings.dashboard.conditional.FocusRecyclerView.FocusListener;
-import com.android.settings.dashboard.suggestions.SuggestionDismissController;
+import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
 import com.android.settings.overlay.FeatureFactory;
 import com.android.settings.widget.ActionBarShadowController;
 import com.android.settingslib.drawer.CategoryKey;
@@ -52,8 +52,7 @@
 
 public class DashboardSummary extends InstrumentedFragment
         implements CategoryListener, ConditionListener,
-        FocusListener, SuggestionDismissController.Callback,
-        SuggestionControllerMixin.SuggestionControllerHost {
+        FocusListener, SuggestionControllerMixin.SuggestionControllerHost {
     public static final boolean DEBUG = false;
     private static final boolean DEBUG_TIMING = false;
     private static final int MAX_WAIT_MILLIS = 700;
@@ -65,7 +64,6 @@
 
     private FocusRecyclerView mDashboard;
     private DashboardAdapter mAdapter;
-    private DashboardAdapterV2 mAdapterV2;
     private SummaryLoader mSummaryLoader;
     private ConditionManager mConditionManager;
     private LinearLayoutManager mLayoutManager;
@@ -86,10 +84,14 @@
     public void onAttach(Context context) {
         super.onAttach(context);
         Log.d(TAG, "Creating SuggestionControllerMixin");
-        mSuggestionControllerMixin = new SuggestionControllerMixin(context, this /* host */,
-                getLifecycle(), FeatureFactory.getFactory(context)
-                                    .getSuggestionFeatureProvider(context)
-                                    .getSuggestionServiceComponent());
+        final SuggestionFeatureProvider suggestionFeatureProvider = FeatureFactory
+                .getFactory(context)
+                .getSuggestionFeatureProvider(context);
+        if (suggestionFeatureProvider.isSuggestionEnabled(context)) {
+            mSuggestionControllerMixin = new SuggestionControllerMixin(context, this /* host */,
+                    getLifecycle(), suggestionFeatureProvider
+                    .getSuggestionServiceComponent());
+        }
     }
 
     @Override
@@ -176,13 +178,10 @@
     @Override
     public void onSaveInstanceState(Bundle outState) {
         super.onSaveInstanceState(outState);
-        if (mLayoutManager == null) return;
-        outState.putInt(EXTRA_SCROLL_POSITION, mLayoutManager.findFirstVisibleItemPosition());
-        if (!mDashboardFeatureProvider.useSuggestionUiV2()) {
-            if (mAdapter != null) {
-                mAdapter.onSaveInstanceState(outState);
-            }
+        if (mLayoutManager == null) {
+            return;
         }
+        outState.putInt(EXTRA_SCROLL_POSITION, mLayoutManager.findFirstVisibleItemPosition());
     }
 
     @Override
@@ -200,17 +199,10 @@
         mDashboard.setHasFixedSize(true);
         mDashboard.setListener(this);
         mDashboard.setItemAnimator(new DashboardItemAnimator());
-        if (mDashboardFeatureProvider.useSuggestionUiV2()) {
-            mAdapterV2 = new DashboardAdapterV2(getContext(), bundle,
-                mConditionManager.getConditions(), mSuggestionControllerMixin, getLifecycle());
-            mDashboard.setAdapter(mAdapterV2);
-            mSummaryLoader.setSummaryConsumer(mAdapterV2);
-        } else {
-            mAdapter = new DashboardAdapter(getContext(), bundle, mConditionManager.getConditions(),
-                mSuggestionControllerMixin, this /* SuggestionDismissController.Callback */);
-            mDashboard.setAdapter(mAdapter);
-            mSummaryLoader.setSummaryConsumer(mAdapter);
-        }
+        mAdapter = new DashboardAdapter(getContext(), bundle,
+            mConditionManager.getConditions(), mSuggestionControllerMixin, getLifecycle());
+        mDashboard.setAdapter(mAdapter);
+        mSummaryLoader.setSummaryConsumer(mAdapter);
         ActionBarShadowController.attachToRecyclerView(
                 getActivity().findViewById(R.id.search_bar_container), getLifecycle(), mDashboard);
         rebuildUI();
@@ -249,11 +241,7 @@
         if (mOnConditionsChangedCalled) {
             final boolean scrollToTop =
                     mLayoutManager.findFirstCompletelyVisibleItemPosition() <= 1;
-            if (mDashboardFeatureProvider.useSuggestionUiV2()) {
-                mAdapterV2.setConditions(mConditionManager.getConditions());
-            } else {
-                mAdapter.setConditions(mConditionManager.getConditions());
-            }
+            mAdapter.setConditions(mConditionManager.getConditions());
             if (scrollToTop) {
                 mDashboard.scrollToPosition(0);
             }
@@ -263,36 +251,13 @@
     }
 
     @Override
-    public Suggestion getSuggestionAt(int position) {
-        if (mDashboardFeatureProvider.useSuggestionUiV2()) {
-            return mAdapterV2.getSuggestion(position);
-        } else {
-            return mAdapter.getSuggestion(position);
-        }
-    }
-
-    @Override
-    public void onSuggestionDismissed(Suggestion suggestion) {
-        mAdapter.onSuggestionDismissed(suggestion);
-    }
-
-    @Override
     public void onSuggestionReady(List<Suggestion> suggestions) {
         mStagingSuggestions = suggestions;
-        if (mDashboardFeatureProvider.useSuggestionUiV2()) {
-            mAdapterV2.setSuggestions(suggestions);
-            if (mStagingCategory != null) {
-                Log.d(TAG, "Category has loaded, setting category from suggestionReady");
-                mHandler.removeCallbacksAndMessages(null);
-                mAdapterV2.setCategory(mStagingCategory);
-            }
-        } else {
-            mAdapter.setSuggestions(suggestions);
-            if (mStagingCategory != null) {
-                Log.d(TAG, "Category has loaded, setting category from suggestionReady");
-                mHandler.removeCallbacksAndMessages(null);
-                mAdapter.setCategory(mStagingCategory);
-            }
+        mAdapter.setSuggestions(suggestions);
+        if (mStagingCategory != null) {
+            Log.d(TAG, "Category has loaded, setting category from suggestionReady");
+            mHandler.removeCallbacksAndMessages(null);
+            mAdapter.setCategory(mStagingCategory);
         }
     }
 
@@ -302,29 +267,20 @@
                 CategoryKey.CATEGORY_HOMEPAGE);
         mSummaryLoader.updateSummaryToCache(category);
         mStagingCategory = category;
+        if (mSuggestionControllerMixin == null) {
+            return;
+        }
         if (mSuggestionControllerMixin.isSuggestionLoaded()) {
             Log.d(TAG, "Suggestion has loaded, setting suggestion/category");
             ThreadUtils.postOnMainThread(() -> {
-                if (mDashboardFeatureProvider.useSuggestionUiV2()) {
-                    if (mStagingSuggestions != null) {
-                        mAdapterV2.setSuggestions(mStagingSuggestions);
-                    }
-                    mAdapterV2.setCategory(mStagingCategory);
-                } else {
-                    if (mStagingSuggestions != null) {
-                        mAdapter.setSuggestions(mStagingSuggestions);
-                    }
-                    mAdapter.setCategory(mStagingCategory);
+                if (mStagingSuggestions != null) {
+                    mAdapter.setSuggestions(mStagingSuggestions);
                 }
+                mAdapter.setCategory(mStagingCategory);
             });
         } else {
             Log.d(TAG, "Suggestion NOT loaded, delaying setCategory by " + MAX_WAIT_MILLIS + "ms");
-            if (mDashboardFeatureProvider.useSuggestionUiV2()) {
-                mHandler.postDelayed(()
-                    -> mAdapterV2.setCategory(mStagingCategory), MAX_WAIT_MILLIS);
-            } else {
-                mHandler.postDelayed(() -> mAdapter.setCategory(mStagingCategory), MAX_WAIT_MILLIS);
-            }
+            mHandler.postDelayed(() -> mAdapter.setCategory(mStagingCategory), MAX_WAIT_MILLIS);
         }
     }
 }
diff --git a/src/com/android/settings/dashboard/conditional/ConditionAdapter.java b/src/com/android/settings/dashboard/conditional/ConditionAdapter.java
index d84aa7c..a540b3f 100644
--- a/src/com/android/settings/dashboard/conditional/ConditionAdapter.java
+++ b/src/com/android/settings/dashboard/conditional/ConditionAdapter.java
@@ -27,10 +27,7 @@
 
 import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
 import com.android.settings.R;
-import com.android.settings.dashboard.DashboardAdapter;
 import com.android.settings.dashboard.DashboardAdapter.DashboardItemHolder;
-import com.android.settings.dashboard.DashboardData;
-import com.android.settings.dashboard.DashboardData.HeaderMode;
 import com.android.settings.overlay.FeatureFactory;
 import com.android.settingslib.WirelessUtils;
 import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
@@ -44,7 +41,7 @@
     private final Context mContext;
     private final MetricsFeatureProvider mMetricsFeatureProvider;
     private List<Condition> mConditions;
-    private @HeaderMode int mMode;
+    private boolean mExpanded;
 
     private View.OnClickListener mConditionClickListener = new View.OnClickListener() {
 
@@ -84,10 +81,10 @@
         }
     };
 
-    public ConditionAdapter(Context context, List<Condition> conditions, @HeaderMode int mode) {
+    public ConditionAdapter(Context context, List<Condition> conditions, boolean expanded) {
         mContext = context;
         mConditions = conditions;
-        mMode = mode;
+        mExpanded = expanded;
         mMetricsFeatureProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
 
         setHasStableIds(true);
@@ -126,7 +123,7 @@
 
     @Override
     public int getItemCount() {
-        if (mMode == DashboardData.HEADER_MODE_FULLY_EXPANDED) {
+        if (mExpanded) {
             return mConditions.size();
         }
         return 0;
@@ -138,7 +135,7 @@
     }
 
     private void bindViews(final Condition condition,
-            DashboardAdapter.DashboardItemHolder view, boolean isLastItem,
+            DashboardItemHolder view, boolean isLastItem,
             View.OnClickListener onClickListener) {
         if (condition instanceof AirplaneModeCondition) {
             Log.d(TAG, "Airplane mode condition has been bound with "
diff --git a/src/com/android/settings/dashboard/conditional/ConditionAdapterV2.java b/src/com/android/settings/dashboard/conditional/ConditionAdapterV2.java
deleted file mode 100644
index 8db57f7..0000000
--- a/src/com/android/settings/dashboard/conditional/ConditionAdapterV2.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Copyright (C) 2018 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.dashboard.conditional;
-
-import android.content.Context;
-import android.support.annotation.VisibleForTesting;
-import android.support.v7.widget.RecyclerView;
-import android.support.v7.widget.helper.ItemTouchHelper;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.Button;
-
-import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.settings.R;
-import com.android.settings.dashboard.DashboardAdapterV2.DashboardItemHolder;
-import com.android.settings.overlay.FeatureFactory;
-import com.android.settingslib.WirelessUtils;
-import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
-
-import java.util.List;
-import java.util.Objects;
-
-public class ConditionAdapterV2 extends RecyclerView.Adapter<DashboardItemHolder> {
-    public static final String TAG = "ConditionAdapter";
-
-    private final Context mContext;
-    private final MetricsFeatureProvider mMetricsFeatureProvider;
-    private List<Condition> mConditions;
-    private boolean mExpanded;
-
-    private View.OnClickListener mConditionClickListener = new View.OnClickListener() {
-
-        @Override
-        public void onClick(View v) {
-            //TODO: get rid of setTag/getTag
-            Condition condition = (Condition) v.getTag();
-            mMetricsFeatureProvider.action(mContext,
-                MetricsEvent.ACTION_SETTINGS_CONDITION_CLICK,
-                condition.getMetricsConstant());
-            condition.onPrimaryClick();
-        }
-    };
-
-    @VisibleForTesting
-    ItemTouchHelper.SimpleCallback mSwipeCallback = new ItemTouchHelper.SimpleCallback(0,
-            ItemTouchHelper.START | ItemTouchHelper.END) {
-        @Override
-        public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder,
-                RecyclerView.ViewHolder target) {
-            return true;
-        }
-
-        @Override
-        public int getSwipeDirs(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
-            return viewHolder.getItemViewType() == R.layout.condition_tile
-                    ? super.getSwipeDirs(recyclerView, viewHolder) : 0;
-        }
-
-        @Override
-        public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
-            Object item = getItem(viewHolder.getItemId());
-            // item can become null when running monkey
-            if (item != null) {
-                ((Condition) item).silence();
-            }
-        }
-    };
-
-    public ConditionAdapterV2(Context context, List<Condition> conditions, boolean expanded) {
-        mContext = context;
-        mConditions = conditions;
-        mExpanded = expanded;
-        mMetricsFeatureProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
-
-        setHasStableIds(true);
-    }
-
-    public Object getItem(long itemId) {
-        for (Condition condition : mConditions) {
-            if (Objects.hash(condition.getTitle()) == itemId) {
-                return condition;
-            }
-        }
-        return null;
-    }
-
-    @Override
-    public DashboardItemHolder onCreateViewHolder(ViewGroup parent, int viewType) {
-        return new DashboardItemHolder(LayoutInflater.from(parent.getContext()).inflate(
-                viewType, parent, false));
-    }
-
-    @Override
-    public void onBindViewHolder(DashboardItemHolder holder, int position) {
-        bindViews(mConditions.get(position), holder,
-            position == mConditions.size() - 1, mConditionClickListener);
-    }
-
-    @Override
-    public long getItemId(int position) {
-        return Objects.hash(mConditions.get(position).getTitle());
-    }
-
-    @Override
-    public int getItemViewType(int position) {
-        return R.layout.condition_tile;
-    }
-
-    @Override
-    public int getItemCount() {
-        if (mExpanded) {
-            return mConditions.size();
-        }
-        return 0;
-    }
-
-    public void addDismissHandling(final RecyclerView recyclerView) {
-        final ItemTouchHelper itemTouchHelper = new ItemTouchHelper(mSwipeCallback);
-        itemTouchHelper.attachToRecyclerView(recyclerView);
-    }
-
-    private void bindViews(final Condition condition,
-            DashboardItemHolder view, boolean isLastItem,
-            View.OnClickListener onClickListener) {
-        if (condition instanceof AirplaneModeCondition) {
-            Log.d(TAG, "Airplane mode condition has been bound with "
-                    + "isActive=" + condition.isActive() + ". Airplane mode is currently " +
-                    WirelessUtils.isAirplaneModeOn(condition.mManager.getContext()));
-        }
-        View card = view.itemView.findViewById(R.id.content);
-        card.setTag(condition);
-        card.setOnClickListener(onClickListener);
-        view.icon.setImageIcon(condition.getIcon());
-        view.title.setText(condition.getTitle());
-
-        CharSequence[] actions = condition.getActions();
-        final boolean hasButtons = actions.length > 0;
-        setViewVisibility(view.itemView, R.id.buttonBar, hasButtons);
-
-        view.summary.setText(condition.getSummary());
-        for (int i = 0; i < 2; i++) {
-            Button button = (Button) view.itemView.findViewById(i == 0
-                    ? R.id.first_action : R.id.second_action);
-            if (actions.length > i) {
-                button.setVisibility(View.VISIBLE);
-                button.setText(actions[i]);
-                final int index = i;
-                button.setOnClickListener(new View.OnClickListener() {
-                    @Override
-                    public void onClick(View v) {
-                        Context context = v.getContext();
-                        FeatureFactory.getFactory(context).getMetricsFeatureProvider()
-                                .action(context, MetricsEvent.ACTION_SETTINGS_CONDITION_BUTTON,
-                                        condition.getMetricsConstant());
-                        condition.onActionClick(index);
-                    }
-                });
-            } else {
-                button.setVisibility(View.GONE);
-            }
-        }
-        setViewVisibility(view.itemView, R.id.divider, !isLastItem);
-    }
-
-    private void setViewVisibility(View containerView, int viewId, boolean visible) {
-        View view = containerView.findViewById(viewId);
-        if (view != null) {
-            view.setVisibility(visible ? View.VISIBLE : View.GONE);
-        }
-    }
-}
diff --git a/src/com/android/settings/dashboard/suggestions/SuggestionAdapter.java b/src/com/android/settings/dashboard/suggestions/SuggestionAdapter.java
index d1d7db2..9bcf2a2 100644
--- a/src/com/android/settings/dashboard/suggestions/SuggestionAdapter.java
+++ b/src/com/android/settings/dashboard/suggestions/SuggestionAdapter.java
@@ -17,6 +17,10 @@
 
 import android.app.PendingIntent;
 import android.content.Context;
+import android.content.res.Resources;
+import android.graphics.drawable.Drawable;
+import android.graphics.drawable.Icon;
+import android.os.Bundle;
 import android.service.settings.suggestions.Suggestion;
 import android.support.v7.widget.RecyclerView;
 import android.text.TextUtils;
@@ -24,37 +28,71 @@
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
 
 import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
 import com.android.settings.R;
 import com.android.settings.dashboard.DashboardAdapter.DashboardItemHolder;
 import com.android.settings.dashboard.DashboardAdapter.IconCache;
 import com.android.settings.overlay.FeatureFactory;
+import com.android.settingslib.Utils;
 import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+import com.android.settingslib.core.lifecycle.LifecycleObserver;
+import com.android.settingslib.core.lifecycle.events.OnSaveInstanceState;
 import com.android.settingslib.suggestions.SuggestionControllerMixin;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Objects;
 
-public class SuggestionAdapter extends RecyclerView.Adapter<DashboardItemHolder> {
+public class SuggestionAdapter extends RecyclerView.Adapter<DashboardItemHolder> implements
+    LifecycleObserver, OnSaveInstanceState {
     public static final String TAG = "SuggestionAdapter";
 
+    private static final String STATE_SUGGESTIONS_SHOWN_LOGGED = "suggestions_shown_logged";
+    private static final String STATE_SUGGESTION_LIST = "suggestion_list";
+
     private final Context mContext;
     private final MetricsFeatureProvider mMetricsFeatureProvider;
-    private final List<Suggestion> mSuggestions;
     private final IconCache mCache;
-    private final List<String> mSuggestionsShownLogged;
+    private final ArrayList<String> mSuggestionsShownLogged;
+    private final SuggestionFeatureProvider mSuggestionFeatureProvider;
     private final SuggestionControllerMixin mSuggestionControllerMixin;
+    private final Callback mCallback;
+    private final CardConfig mConfig;
+
+    private List<Suggestion> mSuggestions;
+
+    public interface Callback {
+        /**
+         * Called when the close button of the suggestion card is clicked.
+         */
+        void onSuggestionClosed(Suggestion suggestion);
+    }
 
     public SuggestionAdapter(Context context, SuggestionControllerMixin suggestionControllerMixin,
-            List<Suggestion> suggestions, List<String> suggestionsShownLogged) {
+        Bundle savedInstanceState, Callback callback, Lifecycle lifecycle) {
         mContext = context;
         mSuggestionControllerMixin = suggestionControllerMixin;
-        mSuggestions = suggestions;
-        mSuggestionsShownLogged = suggestionsShownLogged;
         mCache = new IconCache(context);
         final FeatureFactory factory = FeatureFactory.getFactory(context);
         mMetricsFeatureProvider = factory.getMetricsFeatureProvider();
+        mSuggestionFeatureProvider = factory.getSuggestionFeatureProvider(context);
+        mCallback = callback;
+        if (savedInstanceState != null) {
+            mSuggestions = savedInstanceState.getParcelableArrayList(STATE_SUGGESTION_LIST);
+            mSuggestionsShownLogged = savedInstanceState.getStringArrayList(
+                STATE_SUGGESTIONS_SHOWN_LOGGED);
+        } else {
+            mSuggestionsShownLogged = new ArrayList<>();
+        }
+
+        if (lifecycle != null) {
+            lifecycle.addObserver(this);
+        }
+        mConfig = CardConfig.get(context);
 
         setHasStableIds(true);
     }
@@ -67,31 +105,49 @@
 
     @Override
     public void onBindViewHolder(DashboardItemHolder holder, int position) {
-        bindSuggestion(holder, position);
-    }
-
-    private void bindSuggestion(DashboardItemHolder holder, int position) {
         final Suggestion suggestion = mSuggestions.get(position);
         final String id = suggestion.getId();
+        final int suggestionCount = mSuggestions.size();
         if (!mSuggestionsShownLogged.contains(id)) {
             mMetricsFeatureProvider.action(
                     mContext, MetricsEvent.ACTION_SHOW_SETTINGS_SUGGESTION, id);
             mSuggestionsShownLogged.add(id);
         }
-
-        holder.icon.setImageDrawable(mCache.getIcon(suggestion.getIcon()));
+        mConfig.setCardLayout(holder, suggestionCount, position);
+        final Icon icon = suggestion.getIcon();
+        final Drawable drawable = mCache.getIcon(icon);
+        if ((suggestion.getFlags() & Suggestion.FLAG_ICON_TINTABLE) != 0) {
+            drawable.setTint(Utils.getColorAccent(mContext));
+        }
+        holder.icon.setImageDrawable(drawable);
         holder.title.setText(suggestion.getTitle());
-        final CharSequence summary = suggestion.getSummary();
-        if (!TextUtils.isEmpty(summary)) {
-            holder.summary.setText(summary);
-            holder.summary.setVisibility(View.VISIBLE);
+        holder.title.setSingleLine(suggestionCount == 1);
+
+        if (suggestionCount == 1) {
+            final CharSequence summary = suggestion.getSummary();
+            if (!TextUtils.isEmpty(summary)) {
+                holder.summary.setText(summary);
+                holder.summary.setVisibility(View.VISIBLE);
+            } else {
+                holder.summary.setVisibility(View.GONE);
+            }
         } else {
+            // Do not show summary if there are more than 1 suggestions
             holder.summary.setVisibility(View.GONE);
+            holder.title.setMaxLines(3);
         }
-        final View divider = holder.itemView.findViewById(R.id.divider);
-        if (divider != null) {
-            divider.setVisibility(position < mSuggestions.size() - 1 ? View.VISIBLE : View.GONE);
+
+        final ImageView closeButton = holder.itemView.findViewById(R.id.close_button);
+        if (closeButton != null) {
+            closeButton.setOnClickListener(v -> {
+                mSuggestionFeatureProvider.dismissSuggestion(
+                    mContext, mSuggestionControllerMixin, suggestion);
+                if (mCallback != null) {
+                    mCallback.onSuggestionClosed(suggestion);
+                }
+            });
         }
+
         View clickHandler = holder.itemView;
         // If a view with @android:id/primary is defined, use that as the click handler
         // instead.
@@ -144,7 +200,83 @@
     }
 
     public void removeSuggestion(Suggestion suggestion) {
+        final int position = mSuggestions.indexOf(suggestion);
         mSuggestions.remove(suggestion);
-        notifyDataSetChanged();
+        notifyItemRemoved(position);
     }
+
+    @Override
+    public void onSaveInstanceState(Bundle outState) {
+        if (mSuggestions != null) {
+            outState.putParcelableArrayList(STATE_SUGGESTION_LIST,
+                new ArrayList<>(mSuggestions));
+        }
+        outState.putStringArrayList(STATE_SUGGESTIONS_SHOWN_LOGGED, mSuggestionsShownLogged);
+    }
+
+    public void setSuggestions(List<Suggestion> suggestions) {
+        mSuggestions = suggestions;
+    }
+
+    public List<Suggestion> getSuggestions() {
+        return mSuggestions;
+    }
+
+    private static class CardConfig {
+        // Card start/end margin
+        private final int mMarginInner;
+        private final int mMarginOuter;
+        // Card width for different numbers of cards
+        private final int mWidthSingleCard;
+        private final int mWidthTwoCards;
+        private final int mWidthMultipleCards;
+        // padding between icon and title
+        private final int mPaddingTitleTopSingleCard;
+        private final int mPaddingTitleTopMultipleCards;
+
+        private static CardConfig sConfig;
+
+        private CardConfig(Context context) {
+            final Resources res = context.getResources();
+            mMarginInner =
+                res.getDimensionPixelOffset(R.dimen.suggestion_card_inner_margin);
+            mMarginOuter =
+                res.getDimensionPixelOffset(R.dimen.suggestion_card_outer_margin);
+            mWidthSingleCard = res.getDimensionPixelOffset(R.dimen.suggestion_card_width_one_card);
+            mWidthTwoCards = res.getDimensionPixelOffset(R.dimen.suggestion_card_width_two_cards);
+            mWidthMultipleCards =
+                res.getDimensionPixelOffset(R.dimen.suggestion_card_width_multiple_cards);
+            mPaddingTitleTopSingleCard =
+                res.getDimensionPixelOffset(R.dimen.suggestion_card_title_padding_bottom_one_card);
+            mPaddingTitleTopMultipleCards = res.getDimensionPixelOffset(
+                R.dimen.suggestion_card_title_padding_bottom_multiple_cards);
+        }
+
+        public static CardConfig get(Context context) {
+            if (sConfig == null) {
+                sConfig = new CardConfig(context);
+            }
+            return sConfig;
+        }
+
+        private void setCardLayout(DashboardItemHolder holder, int suggestionCount,
+            int position) {
+            final LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
+                suggestionCount == 1
+                    ? mWidthSingleCard : suggestionCount == 2
+                    ? mWidthTwoCards : mWidthMultipleCards,
+                LinearLayout.LayoutParams.WRAP_CONTENT);
+            if (suggestionCount == 1) {
+                params.setMarginStart(mMarginOuter);
+                params.setMarginEnd(mMarginOuter);
+            } else {
+                params.setMarginStart(
+                    position == 0 ? mMarginOuter : mMarginInner);
+                params.setMarginEnd(position == suggestionCount - 1 ? mMarginOuter : 0);
+            }
+            holder.itemView.setLayoutParams(params);
+        }
+
+    }
+
 }
diff --git a/src/com/android/settings/dashboard/suggestions/SuggestionAdapterV2.java b/src/com/android/settings/dashboard/suggestions/SuggestionAdapterV2.java
deleted file mode 100644
index 483af92..0000000
--- a/src/com/android/settings/dashboard/suggestions/SuggestionAdapterV2.java
+++ /dev/null
@@ -1,272 +0,0 @@
-/*
- * Copyright (C) 2018 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.dashboard.suggestions;
-
-import android.app.PendingIntent;
-import android.content.Context;
-import android.content.res.Resources;
-import android.os.Bundle;
-import android.service.settings.suggestions.Suggestion;
-import android.support.v7.widget.RecyclerView;
-import android.text.TextUtils;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ImageView;
-import android.widget.LinearLayout;
-
-import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.settings.R;
-import com.android.settings.dashboard.DashboardAdapterV2.DashboardItemHolder;
-import com.android.settings.dashboard.DashboardAdapterV2.IconCache;
-import com.android.settings.overlay.FeatureFactory;
-import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
-import com.android.settingslib.core.lifecycle.Lifecycle;
-import com.android.settingslib.core.lifecycle.LifecycleObserver;
-import com.android.settingslib.core.lifecycle.events.OnSaveInstanceState;
-import com.android.settingslib.suggestions.SuggestionControllerMixin;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
-
-public class SuggestionAdapterV2 extends RecyclerView.Adapter<DashboardItemHolder> implements
-        LifecycleObserver, OnSaveInstanceState {
-    public static final String TAG = "SuggestionAdapterV2";
-
-    private static final String STATE_SUGGESTIONS_SHOWN_LOGGED = "suggestions_shown_logged";
-    private static final String STATE_SUGGESTION_LIST = "suggestion_list";
-
-    private final Context mContext;
-    private final MetricsFeatureProvider mMetricsFeatureProvider;
-    private final IconCache mCache;
-    private final ArrayList<String> mSuggestionsShownLogged;
-    private final SuggestionControllerMixin mSuggestionControllerMixin;
-    private final Callback mCallback;
-    private final CardConfig mConfig;
-
-    private List<Suggestion> mSuggestions;
-
-    public interface Callback {
-        /**
-         * Called when the close button of the suggestion card is clicked.
-         */
-        void onSuggestionClosed(Suggestion suggestion);
-    }
-
-    public SuggestionAdapterV2(Context context, SuggestionControllerMixin suggestionControllerMixin,
-            Bundle savedInstanceState, Callback callback, Lifecycle lifecycle) {
-        mContext = context;
-        mSuggestionControllerMixin = suggestionControllerMixin;
-        mCache = new IconCache(context);
-        final FeatureFactory factory = FeatureFactory.getFactory(context);
-        mMetricsFeatureProvider = factory.getMetricsFeatureProvider();
-        mCallback = callback;
-        if (savedInstanceState != null) {
-            mSuggestions = savedInstanceState.getParcelableArrayList(STATE_SUGGESTION_LIST);
-            mSuggestionsShownLogged = savedInstanceState.getStringArrayList(
-                STATE_SUGGESTIONS_SHOWN_LOGGED);
-        } else {
-            mSuggestionsShownLogged = new ArrayList<>();
-        }
-
-        if (lifecycle != null) {
-            lifecycle.addObserver(this);
-        }
-        mConfig = CardConfig.get(context);
-
-        setHasStableIds(true);
-    }
-
-    @Override
-    public DashboardItemHolder onCreateViewHolder(ViewGroup parent, int viewType) {
-        return new DashboardItemHolder(LayoutInflater.from(parent.getContext()).inflate(
-                viewType, parent, false));
-    }
-
-    @Override
-    public void onBindViewHolder(DashboardItemHolder holder, int position) {
-        final Suggestion suggestion = mSuggestions.get(position);
-        final String id = suggestion.getId();
-        final int suggestionCount = mSuggestions.size();
-        if (!mSuggestionsShownLogged.contains(id)) {
-            mMetricsFeatureProvider.action(
-                    mContext, MetricsEvent.ACTION_SHOW_SETTINGS_SUGGESTION, id);
-            mSuggestionsShownLogged.add(id);
-        }
-        mConfig.setCardLayout(holder, suggestionCount, position);
-        holder.icon.setImageDrawable(mCache.getIcon(suggestion.getIcon()));
-        holder.title.setText(suggestion.getTitle());
-        holder.title.setSingleLine(suggestionCount == 1);
-
-        if (suggestionCount == 1) {
-            final CharSequence summary = suggestion.getSummary();
-            if (!TextUtils.isEmpty(summary)) {
-                holder.summary.setText(summary);
-                holder.summary.setVisibility(View.VISIBLE);
-            } else {
-                holder.summary.setVisibility(View.GONE);
-            }
-        } else {
-            // Do not show summary if there are more than 1 suggestions
-            holder.summary.setVisibility(View.GONE);
-            holder.title.setMaxLines(3);
-        }
-
-        final ImageView closeButton = holder.itemView.findViewById(R.id.close_button);
-        if (closeButton != null) {
-            if (mCallback != null) {
-                closeButton.setOnClickListener(v -> {
-                    mCallback.onSuggestionClosed(suggestion);
-                });
-            } else {
-                closeButton.setOnClickListener(null);
-            }
-        }
-
-        View clickHandler = holder.itemView;
-        // If a view with @android:id/primary is defined, use that as the click handler
-        // instead.
-        final View primaryAction = holder.itemView.findViewById(android.R.id.primary);
-        if (primaryAction != null) {
-            clickHandler = primaryAction;
-        }
-        clickHandler.setOnClickListener(v -> {
-            mMetricsFeatureProvider.action(mContext, MetricsEvent.ACTION_SETTINGS_SUGGESTION, id);
-            try {
-                suggestion.getPendingIntent().send();
-                mSuggestionControllerMixin.launchSuggestion(suggestion);
-            } catch (PendingIntent.CanceledException e) {
-                Log.w(TAG, "Failed to start suggestion " + suggestion.getTitle());
-            }
-        });
-    }
-
-    @Override
-    public long getItemId(int position) {
-        return Objects.hash(mSuggestions.get(position).getId());
-    }
-
-    @Override
-    public int getItemViewType(int position) {
-        final Suggestion suggestion = getSuggestion(position);
-        if ((suggestion.getFlags() & Suggestion.FLAG_HAS_BUTTON) != 0) {
-            return R.layout.suggestion_tile_with_button_v2;
-        } else {
-            return R.layout.suggestion_tile_v2;
-        }
-    }
-
-    @Override
-    public int getItemCount() {
-        return mSuggestions.size();
-    }
-
-    public Suggestion getSuggestion(int position) {
-        final long itemId = getItemId(position);
-        if (mSuggestions == null) {
-            return null;
-        }
-        for (Suggestion suggestion : mSuggestions) {
-            if (Objects.hash(suggestion.getId()) == itemId) {
-                return suggestion;
-            }
-        }
-        return null;
-    }
-
-    public void removeSuggestion(Suggestion suggestion) {
-        final int position = mSuggestions.indexOf(suggestion);
-        mSuggestions.remove(suggestion);
-        notifyItemRemoved(position);
-    }
-
-    @Override
-    public void onSaveInstanceState(Bundle outState) {
-        if (mSuggestions != null) {
-            outState.putParcelableArrayList(STATE_SUGGESTION_LIST,
-                new ArrayList<>(mSuggestions));
-        }
-        outState.putStringArrayList(STATE_SUGGESTIONS_SHOWN_LOGGED, mSuggestionsShownLogged);
-    }
-
-    public void setSuggestions(List<Suggestion> suggestions) {
-        mSuggestions = suggestions;
-    }
-
-    public List<Suggestion> getSuggestions() {
-        return mSuggestions;
-    }
-
-    private static class CardConfig {
-        // Card start/end margin
-        private final int mMarginInner;
-        private final int mMarginOuter;
-        // Card width for different numbers of cards
-        private final int mWidthSingleCard;
-        private final int mWidthTwoCards;
-        private final int mWidthMultipleCards;
-        // padding between icon and title
-        private final int mPaddingTitleTopSingleCard;
-        private final int mPaddingTitleTopMultipleCards;
-
-        private static CardConfig sConfig;
-
-        private CardConfig(Context context) {
-            final Resources res = context.getResources();
-            mMarginInner =
-                res.getDimensionPixelOffset(R.dimen.suggestion_card_inner_margin);
-            mMarginOuter =
-                res.getDimensionPixelOffset(R.dimen.suggestion_card_outer_margin);
-            mWidthSingleCard = res.getDimensionPixelOffset(R.dimen.suggestion_card_width_one_card);
-            mWidthTwoCards = res.getDimensionPixelOffset(R.dimen.suggestion_card_width_two_cards);
-            mWidthMultipleCards =
-                res.getDimensionPixelOffset(R.dimen.suggestion_card_width_multiple_cards);
-            mPaddingTitleTopSingleCard =
-                res.getDimensionPixelOffset(R.dimen.suggestion_card_title_padding_bottom_one_card);
-            mPaddingTitleTopMultipleCards = res.getDimensionPixelOffset(
-                R.dimen.suggestion_card_title_padding_bottom_multiple_cards);
-        }
-
-        public static CardConfig get(Context context) {
-            if (sConfig == null) {
-                sConfig = new CardConfig(context);
-            }
-            return sConfig;
-        }
-
-        private void setCardLayout(DashboardItemHolder holder, int suggestionCount,
-            int position) {
-            final LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
-                suggestionCount == 1
-                    ? mWidthSingleCard : suggestionCount == 2
-                    ? mWidthTwoCards : mWidthMultipleCards,
-                LinearLayout.LayoutParams.WRAP_CONTENT);
-            if (suggestionCount == 1) {
-                params.setMarginStart(mMarginOuter);
-                params.setMarginEnd(mMarginOuter);
-            } else {
-                params.setMarginStart(
-                    position == 0 ? mMarginOuter : mMarginInner);
-                params.setMarginEnd(position == suggestionCount - 1 ? mMarginOuter : 0);
-            }
-            holder.itemView.setLayoutParams(params);
-        }
-
-    }
-
-}
diff --git a/src/com/android/settings/dashboard/suggestions/SuggestionDismissController.java b/src/com/android/settings/dashboard/suggestions/SuggestionDismissController.java
deleted file mode 100644
index 6a8db89..0000000
--- a/src/com/android/settings/dashboard/suggestions/SuggestionDismissController.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (C) 2017 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.dashboard.suggestions;
-
-import android.content.Context;
-import android.service.settings.suggestions.Suggestion;
-import android.support.v7.widget.RecyclerView;
-import android.support.v7.widget.helper.ItemTouchHelper;
-
-import com.android.settings.R;
-import com.android.settings.overlay.FeatureFactory;
-import com.android.settingslib.suggestions.SuggestionControllerMixin;
-
-/**
- * Deprecated as a close button is provided to dismiss the suggestion.
- */
-@Deprecated
-public class SuggestionDismissController extends ItemTouchHelper.SimpleCallback {
-
-    public interface Callback {
-        /**
-         * Returns suggestion tile data from the callback
-         */
-        Suggestion getSuggestionAt(int position);
-
-        /**
-         * Called when a suggestion is dismissed.
-         */
-        void onSuggestionDismissed(Suggestion suggestion);
-    }
-
-    private final Context mContext;
-    private final SuggestionFeatureProvider mSuggestionFeatureProvider;
-    private final SuggestionControllerMixin mSuggestionMixin;
-    private final Callback mCallback;
-
-    public SuggestionDismissController(Context context, RecyclerView recyclerView,
-            SuggestionControllerMixin suggestionMixin, Callback callback) {
-        super(0, ItemTouchHelper.START | ItemTouchHelper.END);
-        mSuggestionMixin = suggestionMixin;
-        mContext = context;
-        mSuggestionFeatureProvider = FeatureFactory.getFactory(context)
-                .getSuggestionFeatureProvider(context);
-        mCallback = callback;
-        final ItemTouchHelper itemTouchHelper = new ItemTouchHelper(this);
-        itemTouchHelper.attachToRecyclerView(recyclerView);
-    }
-
-    @Override
-    public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder,
-            RecyclerView.ViewHolder target) {
-        return true;
-    }
-
-    @Override
-    public int getSwipeDirs(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
-        final int layoutId = viewHolder.getItemViewType();
-        if (layoutId == R.layout.suggestion_tile
-                || layoutId == R.layout.suggestion_tile_with_button) {
-            // Only return swipe direction for suggestion tiles. All other types are not swipeable.
-            return super.getSwipeDirs(recyclerView, viewHolder);
-        }
-        return 0;
-    }
-
-    @Override
-    public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
-        if (mCallback == null) {
-            return;
-        }
-        final int position = viewHolder.getAdapterPosition();
-        final Suggestion suggestionV2 = mCallback.getSuggestionAt(position);
-        mSuggestionFeatureProvider.dismissSuggestion(mContext, mSuggestionMixin, suggestionV2);
-        mCallback.onSuggestionDismissed(suggestionV2);
-    }
-}
diff --git a/src/com/android/settings/dashboard/suggestions/SuggestionFeatureProvider.java b/src/com/android/settings/dashboard/suggestions/SuggestionFeatureProvider.java
index b700049..f913085 100644
--- a/src/com/android/settings/dashboard/suggestions/SuggestionFeatureProvider.java
+++ b/src/com/android/settings/dashboard/suggestions/SuggestionFeatureProvider.java
@@ -34,7 +34,7 @@
     /**
      * Whether or not the whole suggestion feature is enabled.
      */
-    boolean isSuggestionV2Enabled(Context context);
+    boolean isSuggestionEnabled(Context context);
 
     /**
      * Returns the component name for SuggestionService.
diff --git a/src/com/android/settings/dashboard/suggestions/SuggestionFeatureProviderImpl.java b/src/com/android/settings/dashboard/suggestions/SuggestionFeatureProviderImpl.java
index 4e5f688..8523273 100644
--- a/src/com/android/settings/dashboard/suggestions/SuggestionFeatureProviderImpl.java
+++ b/src/com/android/settings/dashboard/suggestions/SuggestionFeatureProviderImpl.java
@@ -54,7 +54,7 @@
     private final MetricsFeatureProvider mMetricsFeatureProvider;
 
     @Override
-    public boolean isSuggestionV2Enabled(Context context) {
+    public boolean isSuggestionEnabled(Context context) {
         final ActivityManager am =
                 (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
         return !am.isLowRamDevice();
diff --git a/src/com/android/settings/datausage/AppDataUsage.java b/src/com/android/settings/datausage/AppDataUsage.java
index 5470e63..a0d0ec0 100644
--- a/src/com/android/settings/datausage/AppDataUsage.java
+++ b/src/com/android/settings/datausage/AppDataUsage.java
@@ -33,7 +33,6 @@
 import android.os.RemoteException;
 import android.os.UserHandle;
 import android.support.annotation.VisibleForTesting;
-import android.support.v14.preference.SwitchPreference;
 import android.support.v7.preference.Preference;
 import android.support.v7.preference.PreferenceCategory;
 import android.text.format.Formatter;
@@ -48,6 +47,9 @@
 import com.android.settings.applications.AppInfoBase;
 import com.android.settings.widget.EntityHeaderController;
 import com.android.settingslib.AppItem;
+import com.android.settingslib.RestrictedLockUtils;
+import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
+import com.android.settingslib.RestrictedSwitchPreference;
 import com.android.settingslib.net.ChartData;
 import com.android.settingslib.net.ChartDataLoader;
 import com.android.settingslib.net.UidDetail;
@@ -80,7 +82,7 @@
     private Preference mForegroundUsage;
     private Preference mBackgroundUsage;
     private Preference mAppSettings;
-    private SwitchPreference mRestrictBackground;
+    private RestrictedSwitchPreference mRestrictBackground;
     private PreferenceCategory mAppList;
 
     private Drawable mIcon;
@@ -97,7 +99,7 @@
     private AppItem mAppItem;
     private Intent mAppSettingsIntent;
     private SpinnerPreference mCycle;
-    private SwitchPreference mUnrestrictedData;
+    private RestrictedSwitchPreference mUnrestrictedData;
     private DataSaverBackend mDataSaverBackend;
 
     @Override
@@ -160,9 +162,11 @@
                 removePreference(KEY_UNRESTRICTED_DATA);
                 removePreference(KEY_RESTRICT_BACKGROUND);
             } else {
-                mRestrictBackground = (SwitchPreference) findPreference(KEY_RESTRICT_BACKGROUND);
+                mRestrictBackground = (RestrictedSwitchPreference) findPreference(
+                        KEY_RESTRICT_BACKGROUND);
                 mRestrictBackground.setOnPreferenceChangeListener(this);
-                mUnrestrictedData = (SwitchPreference) findPreference(KEY_UNRESTRICTED_DATA);
+                mUnrestrictedData = (RestrictedSwitchPreference) findPreference(
+                        KEY_UNRESTRICTED_DATA);
                 mUnrestrictedData.setOnPreferenceChangeListener(this);
             }
             mDataSaverBackend = new DataSaverBackend(getContext());
@@ -261,8 +265,11 @@
     }
 
     private void updatePrefs(boolean restrictBackground, boolean unrestrictData) {
+        final EnforcedAdmin admin = RestrictedLockUtils.checkIfMeteredDataRestricted(
+                getContext(), mPackageName, UserHandle.getUserId(mAppItem.key));
         if (mRestrictBackground != null) {
             mRestrictBackground.setChecked(!restrictBackground);
+            mRestrictBackground.setDisabledByAdmin(admin);
         }
         if (mUnrestrictedData != null) {
             if (restrictBackground) {
@@ -270,6 +277,7 @@
             } else {
                 mUnrestrictedData.setVisible(true);
                 mUnrestrictedData.setChecked(unrestrictData);
+                mUnrestrictedData.setDisabledByAdmin(admin);
             }
         }
     }
diff --git a/src/com/android/settings/datausage/DataSaverPreference.java b/src/com/android/settings/datausage/DataSaverPreference.java
index 13ef9d7..f1f648a 100644
--- a/src/com/android/settings/datausage/DataSaverPreference.java
+++ b/src/com/android/settings/datausage/DataSaverPreference.java
@@ -37,7 +37,7 @@
     @Override
     public void onDetached() {
         super.onDetached();
-        mDataSaverBackend.addListener(this);
+        mDataSaverBackend.remListener(this);
     }
 
     @Override
diff --git a/src/com/android/settings/datausage/UnrestrictedDataAccess.java b/src/com/android/settings/datausage/UnrestrictedDataAccess.java
index e8a7bbf..2e20406 100644
--- a/src/com/android/settings/datausage/UnrestrictedDataAccess.java
+++ b/src/com/android/settings/datausage/UnrestrictedDataAccess.java
@@ -14,13 +14,14 @@
 
 package com.android.settings.datausage;
 
+import static com.android.settingslib.RestrictedLockUtils.checkIfMeteredDataRestricted;
+
 import android.app.Application;
 import android.content.Context;
 import android.os.Bundle;
 import android.os.UserHandle;
 import android.support.v7.preference.Preference;
 import android.support.v7.preference.PreferenceViewHolder;
-import android.util.FeatureFlagUtils;
 import android.view.Menu;
 import android.view.MenuInflater;
 import android.view.MenuItem;
@@ -31,12 +32,12 @@
 import com.android.settings.R;
 import com.android.settings.SettingsPreferenceFragment;
 import com.android.settings.applications.AppStateBaseBridge;
-import com.android.settings.applications.InstalledAppDetails;
 import com.android.settings.applications.appinfo.AppInfoDashboardFragment;
-import com.android.settings.core.FeatureFlags;
 import com.android.settings.datausage.AppStateDataUsageBridge.DataUsageState;
 import com.android.settings.overlay.FeatureFactory;
 import com.android.settings.widget.AppSwitchPreference;
+import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
+import com.android.settingslib.RestrictedPreferenceHelper;
 import com.android.settingslib.applications.ApplicationsState;
 import com.android.settingslib.applications.ApplicationsState.AppEntry;
 import com.android.settingslib.applications.ApplicationsState.AppFilter;
@@ -172,6 +173,8 @@
                 preference.setOnPreferenceChangeListener(this);
                 getPreferenceScreen().addPreference(preference);
             } else {
+                preference.setDisabledByAdmin(checkIfMeteredDataRestricted(getContext(),
+                        entry.info.packageName, UserHandle.getUserId(entry.info.uid)));
                 preference.reuse();
             }
             preference.setOrder(i);
@@ -242,16 +245,22 @@
         return app != null && UserHandle.isApp(app.info.uid);
     }
 
-    private class AccessPreference extends AppSwitchPreference
+    @VisibleForTesting
+    class AccessPreference extends AppSwitchPreference
             implements DataSaverBackend.Listener {
         private final AppEntry mEntry;
         private final DataUsageState mState;
+        private final RestrictedPreferenceHelper mHelper;
 
         public AccessPreference(final Context context, AppEntry entry) {
             super(context);
+            setWidgetLayoutResource(R.layout.restricted_switch_widget);
+            mHelper = new RestrictedPreferenceHelper(context, this, null);
             mEntry = entry;
             mState = (DataUsageState) mEntry.extraInfo;
             mEntry.ensureLabel(getContext());
+            setDisabledByAdmin(checkIfMeteredDataRestricted(context, entry.info.packageName,
+                    UserHandle.getUserId(entry.info.uid)));
             setState();
             if (mEntry.icon != null) {
                 setIcon(mEntry.icon);
@@ -274,29 +283,31 @@
         protected void onClick() {
             if (mState.isDataSaverBlacklisted) {
                 // app is blacklisted, launch App Data Usage screen
-                if (FeatureFlagUtils.isEnabled(getContext(), FeatureFlags.APP_INFO_V2)) {
-                    AppInfoDashboardFragment.startAppInfoFragment(AppDataUsage.class,
-                            R.string.app_data_usage,
-                            UnrestrictedDataAccess.this,
-                            mEntry);
-                } else {
-                    InstalledAppDetails.startAppInfoFragment(AppDataUsage.class,
-                            R.string.app_data_usage,
-                            UnrestrictedDataAccess.this,
-                            mEntry);
-                }
+                AppInfoDashboardFragment.startAppInfoFragment(AppDataUsage.class,
+                    R.string.app_data_usage,
+                    UnrestrictedDataAccess.this,
+                    mEntry);
             } else {
                 // app is not blacklisted, let superclass handle toggle switch
                 super.onClick();
             }
         }
 
+        @Override
+        public void performClick() {
+            if (!mHelper.performClick()) {
+                super.performClick();
+            }
+        }
+
         // Sets UI state based on whitelist/blacklist status.
         private void setState() {
             setTitle(mEntry.label);
             if (mState != null) {
                 setChecked(mState.isDataSaverWhitelisted);
-                if (mState.isDataSaverBlacklisted) {
+                if (isDisabledByAdmin()) {
+                    setSummary(R.string.disabled_by_admin);
+                } else if (mState.isDataSaverBlacklisted) {
                     setSummary(R.string.restrict_background_blacklisted);
                 } else {
                     setSummary("");
@@ -323,10 +334,21 @@
                     }
                 });
             }
-            holder.findViewById(android.R.id.widget_frame)
-                    .setVisibility(mState != null && mState.isDataSaverBlacklisted
-                            ? View.INVISIBLE : View.VISIBLE);
+            final boolean disabledByAdmin = isDisabledByAdmin();
+            final View widgetFrame = holder.findViewById(android.R.id.widget_frame);
+            if (disabledByAdmin) {
+                widgetFrame.setVisibility(View.VISIBLE);
+            } else {
+                widgetFrame.setVisibility(mState != null && mState.isDataSaverBlacklisted
+                        ? View.INVISIBLE : View.VISIBLE);
+            }
             super.onBindViewHolder(holder);
+
+            mHelper.onBindViewHolder(holder);
+            holder.findViewById(R.id.restricted_icon).setVisibility(
+                    disabledByAdmin ? View.VISIBLE : View.GONE);
+            holder.findViewById(android.R.id.switch_widget).setVisibility(
+                    disabledByAdmin ? View.GONE : View.VISIBLE);
         }
 
         @Override
@@ -348,6 +370,19 @@
                 reuse();
             }
         }
+
+        public void setDisabledByAdmin(EnforcedAdmin admin) {
+            mHelper.setDisabledByAdmin(admin);
+        }
+
+        public boolean isDisabledByAdmin() {
+            return mHelper.isDisabledByAdmin();
+        }
+
+        @VisibleForTesting
+        public AppEntry getEntryForTest() {
+            return mEntry;
+        }
     }
 
 }
diff --git a/src/com/android/settings/development/SelectUsbConfigPreferenceController.java b/src/com/android/settings/development/SelectUsbConfigPreferenceController.java
index 77a9a75..63eb24c 100644
--- a/src/com/android/settings/development/SelectUsbConfigPreferenceController.java
+++ b/src/com/android/settings/development/SelectUsbConfigPreferenceController.java
@@ -27,11 +27,11 @@
 import android.support.v7.preference.ListPreference;
 import android.support.v7.preference.Preference;
 import android.support.v7.preference.PreferenceScreen;
-import android.text.TextUtils;
 
 import com.android.settings.R;
 import com.android.settings.Utils;
 import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settings.connecteddevice.usb.UsbBackend;
 import com.android.settingslib.core.lifecycle.Lifecycle;
 import com.android.settingslib.core.lifecycle.LifecycleObserver;
 import com.android.settingslib.core.lifecycle.events.OnCreate;
@@ -48,6 +48,8 @@
     private final String[] mListValues;
     private final String[] mListSummaries;
     private final UsbManager mUsbManager;
+    @VisibleForTesting
+    UsbBackend.UsbManagerPassThrough mUsbManagerPassThrough;
     private BroadcastReceiver mUsbReceiver;
     private ListPreference mPreference;
 
@@ -57,6 +59,7 @@
         mListValues = context.getResources().getStringArray(R.array.usb_configuration_values);
         mListSummaries = context.getResources().getStringArray(R.array.usb_configuration_titles);
         mUsbManager = (UsbManager) context.getSystemService(Context.USB_SERVICE);
+        mUsbManagerPassThrough = new UsbBackend.UsbManagerPassThrough(mUsbManager);
         mUsbReceiver = new BroadcastReceiver() {
             @Override
             public void onReceive(Context context, Intent intent) {
@@ -95,7 +98,8 @@
             return false;
         }
 
-        writeUsbConfigurationOption(newValue.toString());
+        writeUsbConfigurationOption(mUsbManagerPassThrough
+                .usbFunctionsFromString(newValue.toString()));
         updateUsbConfigurationValues();
         return true;
     }
@@ -129,14 +133,15 @@
     }
 
     @VisibleForTesting
-    void setCurrentFunction(String newValue, boolean usbDataUnlocked) {
-        mUsbManager.setCurrentFunction(newValue, usbDataUnlocked);
+    void setCurrentFunctions(long functions) {
+        mUsbManager.setCurrentFunctions(functions);
     }
 
     private void updateUsbConfigurationValues() {
+        long functions = mUsbManagerPassThrough.getCurrentFunctions();
         int index = 0;
         for (int i = 0; i < mListValues.length; i++) {
-            if (mUsbManager.isFunctionEnabled(mListValues[i])) {
+            if (functions == mUsbManagerPassThrough.usbFunctionsFromString(mListValues[i])) {
                 index = i;
                 break;
             }
@@ -145,11 +150,7 @@
         mPreference.setSummary(mListSummaries[index]);
     }
 
-    private void writeUsbConfigurationOption(String newValue) {
-        if (TextUtils.equals(newValue, "none")) {
-            setCurrentFunction(newValue, false);
-        } else {
-            setCurrentFunction(newValue, true);
-        }
+    private void writeUsbConfigurationOption(long newValue) {
+        setCurrentFunctions(newValue);
     }
 }
diff --git a/src/com/android/settings/deviceinfo/UsbBackend.java b/src/com/android/settings/deviceinfo/UsbBackend.java
deleted file mode 100644
index 5d2502b..0000000
--- a/src/com/android/settings/deviceinfo/UsbBackend.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * 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.deviceinfo;
-
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.content.pm.PackageManager;
-import android.hardware.usb.UsbManager;
-import android.hardware.usb.UsbPort;
-import android.hardware.usb.UsbPortStatus;
-import android.os.UserHandle;
-import android.os.UserManager;
-import android.support.annotation.VisibleForTesting;
-
-public class UsbBackend {
-
-    public static final int MODE_POWER_MASK  = 0x01;
-    public static final int MODE_POWER_SINK   = 0x00;
-    public static final int MODE_POWER_SOURCE = 0x01;
-
-    public static final int MODE_DATA_MASK  = 0x03 << 1;
-    public static final int MODE_DATA_NONE   = 0x00 << 1;
-    public static final int MODE_DATA_MTP    = 0x01 << 1;
-    public static final int MODE_DATA_PTP    = 0x02 << 1;
-    public static final int MODE_DATA_MIDI   = 0x03 << 1;
-
-    private final boolean mRestricted;
-    private final boolean mRestrictedBySystem;
-    private final boolean mMidi;
-
-    private UsbManager mUsbManager;
-    private UsbPort mPort;
-    private UsbPortStatus mPortStatus;
-
-    private Context mContext;
-
-    public UsbBackend(Context context) {
-        this(context, new UserRestrictionUtil(context));
-    }
-
-    @VisibleForTesting
-    public UsbBackend(Context context, UserRestrictionUtil userRestrictionUtil) {
-        mContext = context;
-        mUsbManager = context.getSystemService(UsbManager.class);
-
-        mRestricted = userRestrictionUtil.isUsbFileTransferRestricted();
-        mRestrictedBySystem = userRestrictionUtil.isUsbFileTransferRestrictedBySystem();
-        mMidi = context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_MIDI);
-
-        UsbPort[] ports = mUsbManager.getPorts();
-        if (ports == null) {
-            return;
-        }
-        // For now look for a connected port, in the future we should identify port in the
-        // notification and pick based on that.
-        final int N = ports.length;
-        for (int i = 0; i < N; i++) {
-            UsbPortStatus status = mUsbManager.getPortStatus(ports[i]);
-            if (status.isConnected()) {
-                mPort = ports[i];
-                mPortStatus = status;
-                break;
-            }
-        }
-    }
-
-    public int getCurrentMode() {
-        if (mPort != null) {
-            int power = mPortStatus.getCurrentPowerRole() == UsbPort.POWER_ROLE_SOURCE
-                    ? MODE_POWER_SOURCE : MODE_POWER_SINK;
-            return power | getUsbDataMode();
-        }
-        return MODE_POWER_SINK | getUsbDataMode();
-    }
-
-    public int getUsbDataMode() {
-        if (!isUsbDataUnlocked()) {
-            return MODE_DATA_NONE;
-        } else if (mUsbManager.isFunctionEnabled(UsbManager.USB_FUNCTION_MTP)) {
-            return MODE_DATA_MTP;
-        } else if (mUsbManager.isFunctionEnabled(UsbManager.USB_FUNCTION_PTP)) {
-            return MODE_DATA_PTP;
-        } else if (mUsbManager.isFunctionEnabled(UsbManager.USB_FUNCTION_MIDI)) {
-            return MODE_DATA_MIDI;
-        }
-        return MODE_DATA_NONE; // ...
-    }
-
-    private boolean isUsbDataUnlocked() {
-        Intent intent = mContext.registerReceiver(null,
-            new IntentFilter(UsbManager.ACTION_USB_STATE));
-        return intent == null ?
-            false : intent.getBooleanExtra(UsbManager.USB_DATA_UNLOCKED, false);
-    }
-
-    private void setUsbFunction(int mode) {
-        switch (mode) {
-            case MODE_DATA_MTP:
-                mUsbManager.setCurrentFunction(UsbManager.USB_FUNCTION_MTP, true);
-                break;
-            case MODE_DATA_PTP:
-                mUsbManager.setCurrentFunction(UsbManager.USB_FUNCTION_PTP, true);
-                break;
-            case MODE_DATA_MIDI:
-                mUsbManager.setCurrentFunction(UsbManager.USB_FUNCTION_MIDI, true);
-                break;
-            default:
-                mUsbManager.setCurrentFunction(null, false);
-                break;
-        }
-    }
-
-    public void setMode(int mode) {
-        if (mPort != null) {
-            int powerRole = modeToPower(mode);
-            // If we aren't using any data modes and we support host mode, then go to host mode
-            // so maybe? the other device can provide data if it wants, otherwise go into device
-            // mode because we have no choice.
-            int dataRole = (mode & MODE_DATA_MASK) == MODE_DATA_NONE
-                    && mPortStatus.isRoleCombinationSupported(powerRole, UsbPort.DATA_ROLE_HOST)
-                    ? UsbPort.DATA_ROLE_HOST : UsbPort.DATA_ROLE_DEVICE;
-            mUsbManager.setPortRoles(mPort, powerRole, dataRole);
-        }
-        setUsbFunction(mode & MODE_DATA_MASK);
-    }
-
-    private int modeToPower(int mode) {
-        return (mode & MODE_POWER_MASK) == MODE_POWER_SOURCE
-                    ? UsbPort.POWER_ROLE_SOURCE : UsbPort.POWER_ROLE_SINK;
-    }
-
-    public boolean isModeDisallowed(int mode) {
-        if (mRestricted && (mode & MODE_DATA_MASK) != MODE_DATA_NONE
-                && (mode & MODE_DATA_MASK) != MODE_DATA_MIDI) {
-            // No USB data modes are supported.
-            return true;
-        }
-        return false;
-    }
-
-    public boolean isModeDisallowedBySystem(int mode) {
-        if (mRestrictedBySystem && (mode & MODE_DATA_MASK) != MODE_DATA_NONE
-                && (mode & MODE_DATA_MASK) != MODE_DATA_MIDI) {
-            // No USB data modes are supported.
-            return true;
-        }
-        return false;
-    }
-
-    public boolean isModeSupported(int mode) {
-        if (!mMidi && (mode & MODE_DATA_MASK) == MODE_DATA_MIDI) {
-            return false;
-        }
-
-        if (mPort != null) {
-            int power = modeToPower(mode);
-            if ((mode & MODE_DATA_MASK) != 0) {
-                // We have a port and data, need to be in device mode.
-                return mPortStatus.isRoleCombinationSupported(power,
-                        UsbPort.DATA_ROLE_DEVICE);
-            } else {
-                // No data needed, we can do this power mode in either device or host.
-                return mPortStatus.isRoleCombinationSupported(power, UsbPort.DATA_ROLE_DEVICE)
-                        || mPortStatus.isRoleCombinationSupported(power, UsbPort.DATA_ROLE_HOST);
-            }
-        }
-        // No port, support sink modes only.
-        return (mode & MODE_POWER_MASK) != MODE_POWER_SOURCE;
-    }
-
-    // Wrapper class to enable testing with UserManager APIs
-    public static class UserRestrictionUtil {
-        private UserManager mUserManager;
-
-        public UserRestrictionUtil(Context context) {
-            mUserManager = UserManager.get(context);
-        }
-
-        public boolean isUsbFileTransferRestricted() {
-            return mUserManager.hasUserRestriction(UserManager.DISALLOW_USB_FILE_TRANSFER);
-        }
-
-        public boolean isUsbFileTransferRestrictedBySystem() {
-            return mUserManager.hasBaseUserRestriction(
-                UserManager.DISALLOW_USB_FILE_TRANSFER, UserHandle.of(UserHandle.myUserId()));
-        }
-    }
-}
diff --git a/src/com/android/settings/display/BrightnessLevelPreferenceController.java b/src/com/android/settings/display/BrightnessLevelPreferenceController.java
index ee573eb..fc08511 100644
--- a/src/com/android/settings/display/BrightnessLevelPreferenceController.java
+++ b/src/com/android/settings/display/BrightnessLevelPreferenceController.java
@@ -45,7 +45,6 @@
 
     private static final String TAG = "BrightnessPrefCtrl";
     private static final String KEY_BRIGHTNESS = "brightness";
-    private static final Uri BRIGHTNESS_MODE_URI;
     private static final Uri BRIGHTNESS_URI;
     private static final Uri BRIGHTNESS_FOR_VR_URI;
     private static final Uri BRIGHTNESS_ADJ_URI;
@@ -59,7 +58,6 @@
     private Preference mPreference;
 
     static {
-        BRIGHTNESS_MODE_URI = System.getUriFor(System.SCREEN_BRIGHTNESS_MODE);
         BRIGHTNESS_URI = System.getUriFor(System.SCREEN_BRIGHTNESS);
         BRIGHTNESS_FOR_VR_URI = System.getUriFor(System.SCREEN_BRIGHTNESS_FOR_VR);
         BRIGHTNESS_ADJ_URI = System.getUriFor(System.SCREEN_AUTO_BRIGHTNESS_ADJ);
@@ -112,10 +110,8 @@
     public void updateState(Preference preference) {
         updatedSummary(preference);
     }
-
     @Override
     public void onStart() {
-        mContentResolver.registerContentObserver(BRIGHTNESS_MODE_URI, false, mBrightnessObserver);
         mContentResolver.registerContentObserver(BRIGHTNESS_URI, false, mBrightnessObserver);
         mContentResolver.registerContentObserver(BRIGHTNESS_FOR_VR_URI, false, mBrightnessObserver);
         mContentResolver.registerContentObserver(BRIGHTNESS_ADJ_URI, false, mBrightnessObserver);
@@ -137,18 +133,11 @@
             final double value = System.getInt(mContentResolver, System.SCREEN_BRIGHTNESS_FOR_VR,
                     mMaxBrightness);
             return getPercentage(value, mMinVrBrightness, mMaxVrBrightness);
+        } else {
+            final double value = Settings.System.getInt(mContentResolver, System.SCREEN_BRIGHTNESS,
+                    mMinBrightness);
+            return getPercentage(value, mMinBrightness, mMaxBrightness);
         }
-        final int brightnessMode = Settings.System.getInt(mContentResolver,
-                System.SCREEN_BRIGHTNESS_MODE, System.SCREEN_BRIGHTNESS_MODE_MANUAL);
-        if (brightnessMode == System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC) {
-            final float value = Settings.System.getFloat(mContentResolver,
-                    System.SCREEN_AUTO_BRIGHTNESS_ADJ, 0);
-            // auto brightness is between -1 and 1
-            return getPercentage(value, -1, 1);
-        }
-        final double value = Settings.System.getInt(mContentResolver, System.SCREEN_BRIGHTNESS,
-                mMinBrightness);
-        return getPercentage(value, mMinBrightness, mMaxBrightness);
     }
 
     private double getPercentage(double value, int min, int max) {
diff --git a/src/com/android/settings/fingerprint/FingerprintSettings.java b/src/com/android/settings/fingerprint/FingerprintSettings.java
index de7187c..caad988 100644
--- a/src/com/android/settings/fingerprint/FingerprintSettings.java
+++ b/src/com/android/settings/fingerprint/FingerprintSettings.java
@@ -35,7 +35,6 @@
 import android.support.annotation.VisibleForTesting;
 import android.support.v7.preference.Preference;
 import android.support.v7.preference.Preference.OnPreferenceChangeListener;
-import android.support.v7.preference.Preference.OnPreferenceClickListener;
 import android.support.v7.preference.PreferenceGroup;
 import android.support.v7.preference.PreferenceScreen;
 import android.support.v7.preference.PreferenceViewHolder;
@@ -921,49 +920,4 @@
             });
         }
     }
-
-    /**
-     * @deprecated in favor of new SecuritySettings.
-     */
-    @Deprecated
-    public static Preference getFingerprintPreferenceForUser(Context context, final int userId) {
-        final FingerprintManager fpm = Utils.getFingerprintManagerOrNull(context);
-        if (fpm == null || !fpm.isHardwareDetected()) {
-            Log.v(TAG, "No fingerprint hardware detected!!");
-            return null;
-        }
-        Preference fingerprintPreference = new Preference(context);
-        fingerprintPreference.setKey(KEY_FINGERPRINT_SETTINGS);
-        fingerprintPreference.setTitle(R.string.security_settings_fingerprint_preference_title);
-        final List<Fingerprint> items = fpm.getEnrolledFingerprints(userId);
-        final int fingerprintCount = items != null ? items.size() : 0;
-        final String clazz;
-        if (fingerprintCount > 0) {
-            fingerprintPreference.setSummary(context.getResources().getQuantityString(
-                    R.plurals.security_settings_fingerprint_preference_summary,
-                    fingerprintCount, fingerprintCount));
-            clazz = FingerprintSettings.class.getName();
-        } else {
-            fingerprintPreference.setSummary(
-                    R.string.security_settings_fingerprint_preference_summary_none);
-            clazz = FingerprintEnrollIntroduction.class.getName();
-        }
-        fingerprintPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
-            @Override
-            public boolean onPreferenceClick(Preference preference) {
-                final Context context = preference.getContext();
-                final UserManager userManager = UserManager.get(context);
-                if (Utils.startQuietModeDialogIfNecessary(context, userManager,
-                        userId)) {
-                    return false;
-                }
-                Intent intent = new Intent();
-                intent.setClassName("com.android.settings", clazz);
-                intent.putExtra(Intent.EXTRA_USER_ID, userId);
-                context.startActivity(intent);
-                return true;
-            }
-        });
-        return fingerprintPreference;
-    }
 }
diff --git a/src/com/android/settings/fuelgauge/AppButtonsPreferenceController.java b/src/com/android/settings/fuelgauge/AppButtonsPreferenceController.java
index a52433b..7bd1b3d 100644
--- a/src/com/android/settings/fuelgauge/AppButtonsPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/AppButtonsPreferenceController.java
@@ -74,7 +74,7 @@
  * An easy way to handle them is to delegate them to {@link #handleDialogClick(int)} and
  * {@link #handleActivityResult(int, int, Intent)} in this controller.
  */
-//TODO(b/35810915): Make InstalledAppDetails use this controller
+//TODO(b/35810915): Make AppInfoDashboardFragment use this controller
 public class AppButtonsPreferenceController extends AbstractPreferenceController implements
         PreferenceControllerMixin, LifecycleObserver, OnResume, OnDestroy,
         ApplicationsState.Callbacks {
diff --git a/src/com/android/settings/fuelgauge/PowerUsageSummary.java b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
index e0954e5..2a841f9 100644
--- a/src/com/android/settings/fuelgauge/PowerUsageSummary.java
+++ b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
@@ -93,14 +93,10 @@
     private static final int MENU_STATS_TYPE = Menu.FIRST;
     @VisibleForTesting
     static final int MENU_HIGH_POWER_APPS = Menu.FIRST + 3;
-    @VisibleForTesting
-    static final int MENU_TOGGLE_APPS = Menu.FIRST + 4;
     private static final int MENU_HELP = Menu.FIRST + 5;
     public static final int DEBUG_INFO_LOADER = 3;
 
     @VisibleForTesting
-    boolean mShowAllApps = false;
-    @VisibleForTesting
     PowerGaugePreference mScreenUsagePref;
     @VisibleForTesting
     PowerGaugePreference mLastFullChargePref;
@@ -221,7 +217,6 @@
         mAnomalySparseArray = new SparseArray<>();
 
         restartBatteryInfoLoader();
-        restoreSavedInstance(icicle);
     }
 
     @Override
@@ -230,12 +225,6 @@
     }
 
     @Override
-    public void onSaveInstanceState(Bundle outState) {
-        super.onSaveInstanceState(outState);
-        outState.putBoolean(KEY_SHOW_ALL_APPS, mShowAllApps);
-    }
-
-    @Override
     public boolean onPreferenceTreeClick(Preference preference) {
         if (KEY_BATTERY_HEADER.equals(preference.getKey())) {
             performBatteryHeaderClick();
@@ -284,11 +273,6 @@
 
         menu.add(Menu.NONE, MENU_HIGH_POWER_APPS, Menu.NONE, R.string.high_power_apps);
 
-        if (mPowerFeatureProvider.isPowerAccountingToggleEnabled()) {
-            menu.add(Menu.NONE, MENU_TOGGLE_APPS, Menu.NONE,
-                    mShowAllApps ? R.string.hide_extra_apps : R.string.show_all_apps);
-        }
-
         super.onCreateOptionsMenu(menu, inflater);
     }
 
@@ -322,25 +306,11 @@
                 metricsFeatureProvider.action(context,
                         MetricsEvent.ACTION_SETTINGS_MENU_BATTERY_OPTIMIZATION);
                 return true;
-            case MENU_TOGGLE_APPS:
-                mShowAllApps = !mShowAllApps;
-                item.setTitle(mShowAllApps ? R.string.hide_extra_apps : R.string.show_all_apps);
-                metricsFeatureProvider.action(context,
-                        MetricsEvent.ACTION_SETTINGS_MENU_BATTERY_APPS_TOGGLE, mShowAllApps);
-                restartBatteryStatsLoader(false /* clearHeader */);
-                return true;
             default:
                 return super.onOptionsItemSelected(item);
         }
     }
 
-    @VisibleForTesting
-    void restoreSavedInstance(Bundle savedInstance) {
-        if (savedInstance != null) {
-            mShowAllApps = savedInstance.getBoolean(KEY_SHOW_ALL_APPS, false);
-        }
-    }
-
     private void performBatteryHeaderClick() {
         if (mPowerFeatureProvider.isAdvancedUiEnabled()) {
             Utils.startWithFragment(getContext(), PowerUsageAdvanced.class.getName(), null,
@@ -375,8 +345,8 @@
 
         final CharSequence timeSequence = Utils.formatRelativeTime(context, lastFullChargeTime,
                 false);
-        mBatteryAppListPreferenceController.refreshAppListGroup(mStatsHelper, mShowAllApps,
-                timeSequence);
+        mBatteryAppListPreferenceController.refreshAppListGroup(mStatsHelper,
+                false /* showAllApps */, timeSequence);
     }
 
     @VisibleForTesting
diff --git a/src/com/android/settings/localepicker/LocaleDragAndDropAdapter.java b/src/com/android/settings/localepicker/LocaleDragAndDropAdapter.java
index 1d21c12..0d8cbaf 100644
--- a/src/com/android/settings/localepicker/LocaleDragAndDropAdapter.java
+++ b/src/com/android/settings/localepicker/LocaleDragAndDropAdapter.java
@@ -34,7 +34,7 @@
 import com.android.internal.app.LocalePicker;
 import com.android.internal.app.LocaleStore;
 
-import com.android.settings.CreateShortcut;
+import com.android.settings.shortcut.CreateShortcut;
 import com.android.settings.R;
 
 import java.text.NumberFormat;
diff --git a/src/com/android/settings/location/RecentLocationRequestPreferenceController.java b/src/com/android/settings/location/RecentLocationRequestPreferenceController.java
index 8cbe95c..b17d19e 100644
--- a/src/com/android/settings/location/RecentLocationRequestPreferenceController.java
+++ b/src/com/android/settings/location/RecentLocationRequestPreferenceController.java
@@ -20,19 +20,15 @@
 import android.support.v7.preference.Preference;
 import android.support.v7.preference.PreferenceCategory;
 import android.support.v7.preference.PreferenceScreen;
-import android.util.FeatureFlagUtils;
 
 import com.android.settings.R;
 import com.android.settings.SettingsActivity;
-import com.android.settings.applications.InstalledAppDetails;
 import com.android.settings.applications.appinfo.AppInfoDashboardFragment;
-import com.android.settings.core.FeatureFlags;
 import com.android.settings.widget.AppPreference;
 import com.android.settingslib.core.lifecycle.Lifecycle;
 import com.android.settingslib.location.RecentLocationApps;
 
 import java.util.ArrayList;
-import java.util.Comparator;
 import java.util.List;
 
 public class RecentLocationRequestPreferenceController extends LocationBasePreferenceController {
@@ -60,19 +56,11 @@
         public boolean onPreferenceClick(Preference preference) {
             // start new fragment to display extended information
             final Bundle args = new Bundle();
-            if (FeatureFlagUtils.isEnabled(mFragment.getActivity(), FeatureFlags.APP_INFO_V2)) {
-                args.putString(AppInfoDashboardFragment.ARG_PACKAGE_NAME, mPackage);
-                ((SettingsActivity) mFragment.getActivity()).startPreferencePanelAsUser(
-                        mFragment,
-                        AppInfoDashboardFragment.class.getName(), args,
-                        R.string.application_info_label, null, mUserHandle);
-            } else {
-                args.putString(InstalledAppDetails.ARG_PACKAGE_NAME, mPackage);
-                ((SettingsActivity) mFragment.getActivity()).startPreferencePanelAsUser(
-                        mFragment,
-                        InstalledAppDetails.class.getName(), args,
-                        R.string.application_info_label, null, mUserHandle);
-            }
+            args.putString(AppInfoDashboardFragment.ARG_PACKAGE_NAME, mPackage);
+            ((SettingsActivity) mFragment.getActivity()).startPreferencePanelAsUser(
+                mFragment,
+                AppInfoDashboardFragment.class.getName(), args,
+                R.string.application_info_label, null, mUserHandle);
             return true;
         }
     }
diff --git a/src/com/android/settings/notification/AllowSoundPreferenceController.java b/src/com/android/settings/notification/AllowSoundPreferenceController.java
index dcd5e45..7186be1 100644
--- a/src/com/android/settings/notification/AllowSoundPreferenceController.java
+++ b/src/com/android/settings/notification/AllowSoundPreferenceController.java
@@ -56,6 +56,7 @@
 
     }
 
+    @Override
     public void updateState(Preference preference) {
         if (mChannel != null) {
             RestrictedSwitchPreference pref = (RestrictedSwitchPreference) preference;
diff --git a/src/com/android/settings/notification/AppNotificationSettings.java b/src/com/android/settings/notification/AppNotificationSettings.java
index 333e060..14ccf23 100644
--- a/src/com/android/settings/notification/AppNotificationSettings.java
+++ b/src/com/android/settings/notification/AppNotificationSettings.java
@@ -120,7 +120,8 @@
         mControllers.add(new BadgePreferenceController(context, mBackend));
         mControllers.add(new AllowSoundPreferenceController(
                 context, mImportanceListener, mBackend));
-        mControllers.add(new ImportancePreferenceController(context));
+        mControllers.add(new ImportancePreferenceController(
+                context, mImportanceListener, mBackend));
         mControllers.add(new SoundPreferenceController(context, this,
                 mImportanceListener, mBackend));
         mControllers.add(new LightsPreferenceController(context, mBackend));
diff --git a/src/com/android/settings/notification/ChannelImportanceSettings.java b/src/com/android/settings/notification/ChannelImportanceSettings.java
deleted file mode 100644
index 27b23b8..0000000
--- a/src/com/android/settings/notification/ChannelImportanceSettings.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Copyright (C) 2017 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.notification;
-
-import static android.app.NotificationChannel.USER_LOCKED_IMPORTANCE;
-import static android.app.NotificationChannel.USER_LOCKED_SOUND;
-import static android.app.NotificationManager.IMPORTANCE_DEFAULT;
-import static android.app.NotificationManager.IMPORTANCE_HIGH;
-import static android.app.NotificationManager.IMPORTANCE_LOW;
-import static android.app.NotificationManager.IMPORTANCE_MAX;
-import static android.app.NotificationManager.IMPORTANCE_MIN;
-
-import android.content.Context;
-import android.media.RingtoneManager;
-import android.provider.SearchIndexableResource;
-import android.support.v7.preference.Preference;
-import android.support.v7.preference.PreferenceScreen;
-import android.text.TextUtils;
-import android.util.Log;
-
-import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.settings.R;
-import com.android.settings.search.BaseSearchIndexProvider;
-import com.android.settings.search.Indexable;
-import com.android.settings.widget.RadioButtonPreference;
-import com.android.settingslib.core.AbstractPreferenceController;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class ChannelImportanceSettings extends NotificationSettingsBase
-        implements RadioButtonPreference.OnClickListener, Indexable {
-    private static final String TAG = "NotiImportance";
-
-    private static final String KEY_IMPORTANCE_HIGH = "importance_high";
-    private static final String KEY_IMPORTANCE_DEFAULT = "importance_default";
-    private static final String KEY_IMPORTANCE_LOW = "importance_low";
-    private static final String KEY_IMPORTANCE_MIN = "importance_min";
-
-    List<RadioButtonPreference> mImportances = new ArrayList<>();
-
-    @Override
-    public int getMetricsCategory() {
-        return MetricsEvent.NOTIFICATION_CHANNEL_IMPORTANCE;
-    }
-
-    @Override
-    public void onResume() {
-        super.onResume();
-        if (mAppRow == null || mChannel == null) {
-            Log.w(TAG, "Missing package or channel");
-            finish();
-            return;
-        }
-        createPreferenceHierarchy();
-    }
-
-    @Override
-    protected String getLogTag() {
-        return TAG;
-    }
-
-    @Override
-    protected int getPreferenceScreenResId() {
-        return R.xml.notification_importance;
-    }
-
-    @Override
-    protected List<AbstractPreferenceController> getPreferenceControllers(Context context) {
-        return null;
-    }
-
-    @Override
-    public void onPause() {
-        super.onPause();
-    }
-
-    private PreferenceScreen createPreferenceHierarchy() {
-        PreferenceScreen root = getPreferenceScreen();
-
-        for (int i = 0; i < root.getPreferenceCount(); i++) {
-            Preference pref = root.getPreference(i);
-            if (pref instanceof RadioButtonPreference) {
-                RadioButtonPreference radioPref = (RadioButtonPreference) pref;
-                radioPref.setOnClickListener(this);
-                mImportances.add(radioPref);
-            }
-        }
-
-        switch (mChannel.getImportance()) {
-            case IMPORTANCE_MIN:
-                updateRadioButtons(KEY_IMPORTANCE_MIN);
-                break;
-            case IMPORTANCE_LOW:
-                updateRadioButtons(KEY_IMPORTANCE_LOW);
-                break;
-            case IMPORTANCE_DEFAULT:
-                updateRadioButtons(KEY_IMPORTANCE_DEFAULT);
-                break;
-            case IMPORTANCE_HIGH:
-            case IMPORTANCE_MAX:
-                updateRadioButtons(KEY_IMPORTANCE_HIGH);
-                break;
-        }
-
-        return root;
-    }
-
-    private void updateRadioButtons(String selectionKey) {
-        for (RadioButtonPreference pref : mImportances) {
-            if (selectionKey.equals(pref.getKey())) {
-                pref.setChecked(true);
-            } else {
-                pref.setChecked(false);
-            }
-        }
-    }
-
-    @Override
-    public void onRadioButtonClicked(RadioButtonPreference clicked) {
-        int oldImportance = mChannel.getImportance();
-        switch (clicked.getKey()) {
-            case KEY_IMPORTANCE_HIGH:
-                mChannel.setImportance(IMPORTANCE_HIGH);
-                break;
-            case KEY_IMPORTANCE_DEFAULT:
-                mChannel.setImportance(IMPORTANCE_DEFAULT);
-                break;
-            case KEY_IMPORTANCE_LOW:
-                mChannel.setImportance(IMPORTANCE_LOW);
-                break;
-            case KEY_IMPORTANCE_MIN:
-                mChannel.setImportance(IMPORTANCE_MIN);
-                break;
-        }
-        updateRadioButtons(clicked.getKey());
-
-        // If you are moving from an importance level without sound to one with sound,
-        // but the sound you had selected was "Silence",
-        // then set sound for this channel to your default sound,
-        // because you probably intended to cause this channel to actually start making sound.
-        if (oldImportance < IMPORTANCE_DEFAULT
-                && !SoundPreferenceController.hasValidSound(mChannel)
-                && mChannel.getImportance() >= IMPORTANCE_DEFAULT) {
-            mChannel.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION),
-                    mChannel.getAudioAttributes());
-            mChannel.lockFields(USER_LOCKED_SOUND);
-        }
-        mChannel.lockFields(USER_LOCKED_IMPORTANCE);
-        mBackend.updateChannel(mAppRow.pkg, mAppRow.uid, mChannel);
-    }
-}
diff --git a/src/com/android/settings/notification/ChannelNotificationSettings.java b/src/com/android/settings/notification/ChannelNotificationSettings.java
index ea17a05..23451ec 100644
--- a/src/com/android/settings/notification/ChannelNotificationSettings.java
+++ b/src/com/android/settings/notification/ChannelNotificationSettings.java
@@ -79,7 +79,8 @@
         mControllers = new ArrayList<>();
         mControllers.add(new HeaderPreferenceController(context, this));
         mControllers.add(new BlockPreferenceController(context, mImportanceListener, mBackend));
-        mControllers.add(new ImportancePreferenceController(context));
+        mControllers.add(new ImportancePreferenceController(
+                context, mImportanceListener, mBackend));
         mControllers.add(new AllowSoundPreferenceController(
                 context, mImportanceListener, mBackend));
         mControllers.add(new SoundPreferenceController(context, this,
diff --git a/src/com/android/settings/notification/ConfigureNotificationSettings.java b/src/com/android/settings/notification/ConfigureNotificationSettings.java
index 7cfa124..a3af471 100644
--- a/src/com/android/settings/notification/ConfigureNotificationSettings.java
+++ b/src/com/android/settings/notification/ConfigureNotificationSettings.java
@@ -30,9 +30,7 @@
 import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
 import com.android.settings.R;
 import com.android.settings.RingtonePreference;
-import com.android.settings.applications.NotificationApps;
 import com.android.settings.dashboard.DashboardFragment;
-import com.android.settings.dashboard.SummaryLoader;
 import com.android.settings.gestures.SwipeToNotificationPreferenceController;
 import com.android.settings.search.BaseSearchIndexProvider;
 import com.android.settings.search.Indexable;
@@ -153,15 +151,6 @@
         }
     }
 
-    public static final SummaryLoader.SummaryProviderFactory SUMMARY_PROVIDER_FACTORY
-        = new SummaryLoader.SummaryProviderFactory() {
-            @Override
-            public SummaryLoader.SummaryProvider createSummaryProvider(Activity activity,
-                    SummaryLoader summaryLoader) {
-                return new NotificationApps.SummaryProvider(activity, summaryLoader);
-            }
-    };
-
     /**
      * For Search.
      */
diff --git a/src/com/android/settings/notification/DeletedChannelsPreferenceController.java b/src/com/android/settings/notification/DeletedChannelsPreferenceController.java
index 16eb9ed..45fb8ec 100644
--- a/src/com/android/settings/notification/DeletedChannelsPreferenceController.java
+++ b/src/com/android/settings/notification/DeletedChannelsPreferenceController.java
@@ -55,7 +55,6 @@
             preference.setTitle(mContext.getResources().getQuantityString(
                     R.plurals.deleted_channels, deletedChannelCount, deletedChannelCount));
         }
-        preference.setEnabled(false);
         preference.setSelectable(false);
     }
 }
diff --git a/src/com/android/settings/notification/ImportancePreferenceController.java b/src/com/android/settings/notification/ImportancePreferenceController.java
index 977cd9a..f95c34a 100644
--- a/src/com/android/settings/notification/ImportancePreferenceController.java
+++ b/src/com/android/settings/notification/ImportancePreferenceController.java
@@ -16,41 +16,39 @@
 
 package com.android.settings.notification;
 
+import static android.app.NotificationChannel.USER_LOCKED_SOUND;
+import static android.app.NotificationManager.IMPORTANCE_DEFAULT;
+import static android.app.NotificationManager.IMPORTANCE_HIGH;
+import static android.app.NotificationManager.IMPORTANCE_MIN;
 import static android.app.NotificationManager.IMPORTANCE_UNSPECIFIED;
 
 import android.app.NotificationChannel;
 import android.app.NotificationManager;
 import android.content.Context;
-import android.content.Intent;
-import android.os.Bundle;
-import android.provider.Settings;
+import android.media.RingtoneManager;
 import android.support.v7.preference.Preference;
 
-import com.android.internal.logging.nano.MetricsProto;
 import com.android.settings.R;
-import com.android.settings.Utils;
-import com.android.settings.applications.AppInfoBase;
+import com.android.settings.RestrictedListPreference;
 import com.android.settings.core.PreferenceControllerMixin;
 
 public class ImportancePreferenceController extends NotificationPreferenceController
-        implements PreferenceControllerMixin {
+        implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener  {
 
     private static final String KEY_IMPORTANCE = "importance";
+    private NotificationSettingsBase.ImportanceListener mImportanceListener;
 
-    // Ironically doesn't take an importance listener because the importance is not changed
-    // by this controller's preference but by the screen it links to.
-    public ImportancePreferenceController(Context context) {
-        super(context, null);
+    public ImportancePreferenceController(Context context,
+            NotificationSettingsBase.ImportanceListener importanceListener,
+            NotificationBackend backend) {
+        super(context, backend);
+        mImportanceListener = importanceListener;
     }
 
     @Override
     public String getPreferenceKey() {
         return KEY_IMPORTANCE;
     }
-    
-    private int getMetricsCategory() {
-        return MetricsProto.MetricsEvent.NOTIFICATION_TOPIC_NOTIFICATION;
-    }
 
     @Override
     public boolean isAvailable() {
@@ -63,51 +61,82 @@
         return !NotificationChannel.DEFAULT_CHANNEL_ID.equals(mChannel.getId());
     }
 
+    @Override
     public void updateState(Preference preference) {
         if (mAppRow!= null && mChannel != null) {
             preference.setEnabled(mAdmin == null && isChannelConfigurable());
-            Bundle channelArgs = new Bundle();
-            channelArgs.putInt(AppInfoBase.ARG_PACKAGE_UID, mAppRow.uid);
-            channelArgs.putString(AppInfoBase.ARG_PACKAGE_NAME, mAppRow.pkg);
-            channelArgs.putString(Settings.EXTRA_CHANNEL_ID, mChannel.getId());
-            if (preference.isEnabled()) {
-                Intent channelIntent = Utils.onBuildStartFragmentIntent(mContext,
-                        ChannelImportanceSettings.class.getName(),
-                        channelArgs, null,
-                        R.string.notification_importance_title, null,
-                        false, getMetricsCategory());
-                preference.setIntent(channelIntent);
-                preference.setSummary(getImportanceSummary(mContext, mChannel));
+            preference.setSummary(getImportanceSummary(mChannel));
+
+            int importances = IMPORTANCE_HIGH - IMPORTANCE_MIN + 1;
+            CharSequence[] entries = new CharSequence[importances];
+            CharSequence[] values = new CharSequence[importances];
+
+            int index = 0;
+            for (int i = IMPORTANCE_HIGH; i >= IMPORTANCE_MIN; i--) {
+                NotificationChannel channel = new NotificationChannel("", "", i);
+                entries[index] = getImportanceSummary(channel);
+                values[index] = String.valueOf(i);
+                index++;
             }
+
+            RestrictedListPreference pref = (RestrictedListPreference) preference;
+            pref.setEntries(entries);
+            pref.setEntryValues(values);
+            pref.setValue(String.valueOf(mChannel.getImportance()));
         }
     }
 
-    protected static String getImportanceSummary(Context context, NotificationChannel channel) {
+    @Override
+    public boolean onPreferenceChange(Preference preference, Object newValue) {
+        if (mChannel != null) {
+            final int importance = Integer.parseInt((String) newValue);
+
+            // If you are moving from an importance level without sound to one with sound,
+            // but the sound you had selected was "Silence",
+            // then set sound for this channel to your default sound,
+            // because you probably intended to cause this channel to actually start making sound.
+            if (mChannel.getImportance() < IMPORTANCE_DEFAULT
+                    && !SoundPreferenceController.hasValidSound(mChannel)
+                    && importance >= IMPORTANCE_DEFAULT) {
+                mChannel.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION),
+                        mChannel.getAudioAttributes());
+                mChannel.lockFields(USER_LOCKED_SOUND);
+            }
+
+            mChannel.setImportance(importance);
+            mChannel.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE);
+            saveChannel();
+            mImportanceListener.onImportanceChanged();
+        }
+        return true;
+    }
+
+    protected String getImportanceSummary(NotificationChannel channel) {
         String summary = "";
         int importance = channel.getImportance();
         switch (importance) {
             case IMPORTANCE_UNSPECIFIED:
-                summary = context.getString(R.string.notification_importance_unspecified);
+                summary = mContext.getString(R.string.notification_importance_unspecified);
                 break;
             case NotificationManager.IMPORTANCE_MIN:
-                summary = context.getString(R.string.notification_importance_min);
+                summary = mContext.getString(R.string.notification_importance_min);
                 break;
             case NotificationManager.IMPORTANCE_LOW:
-                summary = context.getString(R.string.notification_importance_low);
+                summary = mContext.getString(R.string.notification_importance_low);
                 break;
             case NotificationManager.IMPORTANCE_DEFAULT:
                 if (SoundPreferenceController.hasValidSound(channel)) {
-                    summary = context.getString(R.string.notification_importance_default);
+                    summary = mContext.getString(R.string.notification_importance_default);
                 } else {
-                    summary = context.getString(R.string.notification_importance_low);
+                    summary = mContext.getString(R.string.notification_importance_low);
                 }
                 break;
             case NotificationManager.IMPORTANCE_HIGH:
             case NotificationManager.IMPORTANCE_MAX:
                 if (SoundPreferenceController.hasValidSound(channel)) {
-                    summary = context.getString(R.string.notification_importance_high);
+                    summary = mContext.getString(R.string.notification_importance_high);
                 } else {
-                    summary = context.getString(R.string.notification_importance_high_silent);
+                    summary = mContext.getString(R.string.notification_importance_high_silent);
                 }
                 break;
             default:
diff --git a/src/com/android/settings/notification/NotificationsOffPreferenceController.java b/src/com/android/settings/notification/NotificationsOffPreferenceController.java
index 74591cf..ba304de 100644
--- a/src/com/android/settings/notification/NotificationsOffPreferenceController.java
+++ b/src/com/android/settings/notification/NotificationsOffPreferenceController.java
@@ -57,7 +57,6 @@
                 preference.setTitle(R.string.app_notifications_off_desc);
             }
         }
-        preference.setEnabled(false);
         preference.setSelectable(false);
     }
 }
diff --git a/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java b/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java
index dbffc55..3240ae0 100644
--- a/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java
+++ b/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java
@@ -147,7 +147,8 @@
             @Override
             protected void onCountComplete(int num) {
                 if (mHasRecentApps) {
-                    mSeeAllPref.setTitle(mContext.getString(R.string.see_all_apps_title, num));
+                    mSeeAllPref.setTitle(
+                            mContext.getString(R.string.recent_notifications_see_all_title));
                 } else {
                     mSeeAllPref.setSummary(mContext.getString(R.string.apps_summary, num));
                 }
diff --git a/src/com/android/settings/password/ManagedLockPasswordProvider.java b/src/com/android/settings/password/ManagedLockPasswordProvider.java
index 82135cf..5786a5a 100644
--- a/src/com/android/settings/password/ManagedLockPasswordProvider.java
+++ b/src/com/android/settings/password/ManagedLockPasswordProvider.java
@@ -55,17 +55,6 @@
     CharSequence getPickerOptionTitle(boolean forFingerprint) { return ""; }
 
     /**
-     * Gets resource id of the lock screen preference that should be displayed in security settings
-     * if the current password quality is set to
-     * {@link android.app.admin.DevicePolicyManager#PASSWORD_QUALITY_MANAGED}.
-     * @param forProfile Whether the settings are shown for a user profile rather than a user.
-     */
-    public int getResIdForLockUnlockScreen(boolean forProfile) {
-        return forProfile ? R.xml.security_settings_password_profile
-                : R.xml.security_settings_password;
-    }
-
-    /**
      * Creates intent that should be launched when user chooses managed password in the lock
      * settings picker.
      * @param requirePasswordToDecrypt Whether a password is needed to decrypt the user.
diff --git a/src/com/android/settings/search/SearchIndexableResourcesImpl.java b/src/com/android/settings/search/SearchIndexableResourcesImpl.java
index faa4b8c..1edc2de 100644
--- a/src/com/android/settings/search/SearchIndexableResourcesImpl.java
+++ b/src/com/android/settings/search/SearchIndexableResourcesImpl.java
@@ -21,6 +21,7 @@
 import com.android.settings.DateTimeSettings;
 import com.android.settings.DisplaySettings;
 import com.android.settings.LegalSettings;
+import com.android.settings.connecteddevice.ConnectedDeviceDashboardFragmentOld;
 import com.android.settings.deviceinfo.aboutphone.MyDeviceInfoFragment;
 import com.android.settings.accessibility.AccessibilitySettings;
 import com.android.settings.accessibility.AccessibilityShortcutPreferenceFragment;
@@ -35,13 +36,14 @@
 import com.android.settings.bluetooth.BluetoothSettings;
 import com.android.settings.connecteddevice.AdvancedConnectedDeviceDashboardFragment;
 import com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment;
-import com.android.settings.connecteddevice.ConnectedDeviceDashboardFragmentOld;
+import com.android.settings.connecteddevice.usb.UsbDetailsFragment;
 import com.android.settings.datausage.DataUsageSummary;
 import com.android.settings.deletionhelper.AutomaticStorageManagerSettings;
 import com.android.settings.development.DevelopmentSettingsDashboardFragment;
 import com.android.settings.deviceinfo.DeviceInfoSettings;
 import com.android.settings.deviceinfo.StorageDashboardFragment;
 import com.android.settings.deviceinfo.StorageSettings;
+import com.android.settings.deviceinfo.aboutphone.MyDeviceInfoFragment;
 import com.android.settings.display.AmbientDisplaySettings;
 import com.android.settings.display.NightDisplaySettings;
 import com.android.settings.display.ScreenZoomSettings;
@@ -75,7 +77,7 @@
 import com.android.settings.security.EncryptionAndCredential;
 import com.android.settings.security.LockscreenDashboardFragment;
 import com.android.settings.security.ScreenPinningSettings;
-import com.android.settings.security.SecuritySettingsV2;
+import com.android.settings.security.SecuritySettings;
 import com.android.settings.security.screenlock.ScreenLockSettings;
 import com.android.settings.sim.SimSettings;
 import com.android.settings.support.SupportDashboardActivity;
@@ -132,7 +134,7 @@
         addIndex(LanguageAndInputSettings.class);
         addIndex(LocationSettings.class);
         addIndex(ScanningSettings.class);
-        addIndex(SecuritySettingsV2.class);
+        addIndex(SecuritySettings.class);
         addIndex(ScreenLockSettings.class);
         addIndex(EncryptionAndCredential.class);
         addIndex(ScreenPinningSettings.class);
@@ -167,6 +169,7 @@
         addIndex(PowerUsageSummary.class);
         addIndex(BatterySaverSettings.class);
         addIndex(LockscreenDashboardFragment.class);
+        addIndex(UsbDetailsFragment.class);
         addIndex(WifiDisplaySettings.class);
         addIndex(ZenModeBehaviorSettings.class);
         addIndex(ZenModeAutomationSettings.class);
diff --git a/src/com/android/settings/security/ChangeProfileScreenLockPreferenceController.java b/src/com/android/settings/security/ChangeProfileScreenLockPreferenceController.java
index 9a33ec3..91c4410 100644
--- a/src/com/android/settings/security/ChangeProfileScreenLockPreferenceController.java
+++ b/src/com/android/settings/security/ChangeProfileScreenLockPreferenceController.java
@@ -16,8 +16,7 @@
 
 package com.android.settings.security;
 
-import static com.android.settings.security
-        .SecuritySettingsV2.SET_OR_CHANGE_LOCK_METHOD_REQUEST_PROFILE;
+import static com.android.settings.security.SecuritySettings.SET_OR_CHANGE_LOCK_METHOD_REQUEST_PROFILE;
 
 import android.app.admin.DevicePolicyManager;
 import android.content.Context;
@@ -37,7 +36,7 @@
     private static final String KEY_UNLOCK_SET_OR_CHANGE_PROFILE = "unlock_set_or_change_profile";
 
     public ChangeProfileScreenLockPreferenceController(Context context,
-            SecuritySettingsV2 host) {
+            SecuritySettings host) {
         super(context, host);
     }
 
diff --git a/src/com/android/settings/security/ChangeScreenLockPreferenceController.java b/src/com/android/settings/security/ChangeScreenLockPreferenceController.java
index fdb9349..10143d2 100644
--- a/src/com/android/settings/security/ChangeScreenLockPreferenceController.java
+++ b/src/com/android/settings/security/ChangeScreenLockPreferenceController.java
@@ -16,7 +16,7 @@
 
 package com.android.settings.security;
 
-import static com.android.settings.security.SecuritySettingsV2.SET_OR_CHANGE_LOCK_METHOD_REQUEST;
+import static com.android.settings.security.SecuritySettings.SET_OR_CHANGE_LOCK_METHOD_REQUEST;
 
 import android.app.admin.DevicePolicyManager;
 import android.content.Context;
@@ -45,7 +45,7 @@
     private static final String KEY_UNLOCK_SET_OR_CHANGE = "unlock_set_or_change";
 
     protected final DevicePolicyManager mDPM;
-    protected final SecuritySettingsV2 mHost;
+    protected final SecuritySettings mHost;
     protected final UserManager mUm;
     protected final LockPatternUtils mLockPatternUtils;
 
@@ -54,7 +54,7 @@
 
     protected RestrictedPreference mPreference;
 
-    public ChangeScreenLockPreferenceController(Context context, SecuritySettingsV2 host) {
+    public ChangeScreenLockPreferenceController(Context context, SecuritySettings host) {
         super(context);
         mUm = (UserManager) context.getSystemService(Context.USER_SERVICE);
         mDPM = (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE);
diff --git a/src/com/android/settings/security/LockUnificationPreferenceController.java b/src/com/android/settings/security/LockUnificationPreferenceController.java
index 5486e29..abbf2f4 100644
--- a/src/com/android/settings/security/LockUnificationPreferenceController.java
+++ b/src/com/android/settings/security/LockUnificationPreferenceController.java
@@ -16,11 +16,10 @@
 
 package com.android.settings.security;
 
-import static com.android.settings.security
-        .SecuritySettingsV2.SET_OR_CHANGE_LOCK_METHOD_REQUEST_PROFILE;
-import static com.android.settings.security.SecuritySettingsV2.UNIFY_LOCK_CONFIRM_DEVICE_REQUEST;
-import static com.android.settings.security.SecuritySettingsV2.UNIFY_LOCK_CONFIRM_PROFILE_REQUEST;
-import static com.android.settings.security.SecuritySettingsV2.UNUNIFY_LOCK_CONFIRM_DEVICE_REQUEST;
+import static com.android.settings.security.SecuritySettings.SET_OR_CHANGE_LOCK_METHOD_REQUEST_PROFILE;
+import static com.android.settings.security.SecuritySettings.UNIFY_LOCK_CONFIRM_DEVICE_REQUEST;
+import static com.android.settings.security.SecuritySettings.UNIFY_LOCK_CONFIRM_PROFILE_REQUEST;
+import static com.android.settings.security.SecuritySettings.UNUNIFY_LOCK_CONFIRM_DEVICE_REQUEST;
 
 import android.app.Activity;
 import android.app.admin.DevicePolicyManager;
@@ -53,7 +52,7 @@
     private final UserManager mUm;
     private final LockPatternUtils mLockPatternUtils;
     private final int mProfileChallengeUserId;
-    private final SecuritySettingsV2 mHost;
+    private final SecuritySettings mHost;
 
     private RestrictedSwitchPreference mUnifyProfile;
 
@@ -67,7 +66,7 @@
         mUnifyProfile = (RestrictedSwitchPreference) screen.findPreference(KEY_UNIFICATION);
     }
 
-    public LockUnificationPreferenceController(Context context, SecuritySettingsV2 host) {
+    public LockUnificationPreferenceController(Context context, SecuritySettings host) {
         super(context);
         mHost = host;
         mUm = (UserManager) context.getSystemService(Context.USER_SERVICE);
@@ -212,7 +211,7 @@
                 mCurrentProfilePassword);
         mHost.startFragment(mHost, ChooseLockGeneric.ChooseLockGenericFragment.class.getName(),
                 R.string.lock_settings_picker_title,
-                SecuritySettingsV2.SET_OR_CHANGE_LOCK_METHOD_REQUEST, null);
+                SecuritySettings.SET_OR_CHANGE_LOCK_METHOD_REQUEST, null);
     }
 
 }
diff --git a/src/com/android/settings/security/SecurityFeatureProvider.java b/src/com/android/settings/security/SecurityFeatureProvider.java
index 35ff586..d533d1e 100644
--- a/src/com/android/settings/security/SecurityFeatureProvider.java
+++ b/src/com/android/settings/security/SecurityFeatureProvider.java
@@ -17,26 +17,14 @@
 package com.android.settings.security;
 
 import android.content.Context;
-import android.support.v7.preference.PreferenceScreen;
-import android.util.FeatureFlagUtils;
 
 import com.android.internal.widget.LockPatternUtils;
-import com.android.settings.core.FeatureFlags;
 import com.android.settings.security.trustagent.TrustAgentManager;
-import com.android.settingslib.drawer.DashboardCategory;
 
 
 /** FeatureProvider for security. */
 public interface SecurityFeatureProvider {
 
-    default boolean isSecuritySettingsV2Enabled(Context context) {
-        return FeatureFlagUtils.isEnabled(context, FeatureFlags.SECURITY_SETTINGS_V2);
-    }
-
-    /** Update preferences with data from associated tiles. */
-    void updatePreferences(Context context, PreferenceScreen preferenceScreen,
-            DashboardCategory dashboardCategory);
-
     /** Returns the {@link TrustAgentManager} bound to this {@link SecurityFeatureProvider}. */
     TrustAgentManager getTrustAgentManager();
 
diff --git a/src/com/android/settings/security/SecurityFeatureProviderImpl.java b/src/com/android/settings/security/SecurityFeatureProviderImpl.java
index 70b1ec1..56a0884 100644
--- a/src/com/android/settings/security/SecurityFeatureProviderImpl.java
+++ b/src/com/android/settings/security/SecurityFeatureProviderImpl.java
@@ -17,28 +17,9 @@
 package com.android.settings.security;
 
 import android.content.Context;
-import android.content.IContentProvider;
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.content.res.Resources;
-import android.graphics.drawable.Drawable;
-import android.support.annotation.VisibleForTesting;
-import android.support.v7.preference.Preference;
-import android.support.v7.preference.PreferenceScreen;
-import android.text.TextUtils;
-import android.util.ArrayMap;
-import android.util.Pair;
 
 import com.android.internal.widget.LockPatternUtils;
-import com.android.settings.R;
 import com.android.settings.security.trustagent.TrustAgentManager;
-import com.android.settingslib.drawer.DashboardCategory;
-import com.android.settingslib.drawer.Tile;
-import com.android.settingslib.drawer.TileUtils;
-import com.android.settingslib.utils.ThreadUtils;
-
-import java.util.Map;
-import java.util.TreeMap;
 
 /** Implementation for {@code SecurityFeatureProvider}. */
 public class SecurityFeatureProviderImpl implements SecurityFeatureProvider {
@@ -46,150 +27,6 @@
     private TrustAgentManager mTrustAgentManager;
     private LockPatternUtils mLockPatternUtils;
 
-    @VisibleForTesting
-    static final Drawable DEFAULT_ICON = null;
-
-    @VisibleForTesting
-    static Map<String, Pair<String, Integer>> sIconCache = new TreeMap<>();
-
-    @VisibleForTesting
-    static Map<String, String> sSummaryCache = new TreeMap<>();
-
-    /** Update preferences with data from associated tiles. */
-    public void updatePreferences(final Context context, final PreferenceScreen preferenceScreen,
-            final DashboardCategory dashboardCategory) {
-        if (preferenceScreen == null) {
-            return;
-        }
-        int tilesCount = (dashboardCategory != null) ? dashboardCategory.getTilesCount() : 0;
-        if (tilesCount == 0) {
-            return;
-        }
-
-        initPreferences(context, preferenceScreen, dashboardCategory);
-
-        // Fetching the summary and icon from the provider introduces latency, so do this on a
-        // separate thread.
-        ThreadUtils.postOnBackgroundThread(() ->
-                updatePreferencesToRunOnWorkerThread(context, preferenceScreen, dashboardCategory));
-    }
-
-    @VisibleForTesting
-    static void initPreferences(Context context, PreferenceScreen preferenceScreen,
-            DashboardCategory dashboardCategory) {
-        int tilesCount = (dashboardCategory != null) ? dashboardCategory.getTilesCount() : 0;
-        for (int i = 0; i < tilesCount; i++) {
-            Tile tile = dashboardCategory.getTile(i);
-            // If the tile does not have a key or appropriate meta data, skip it.
-            if (TextUtils.isEmpty(tile.key) || (tile.metaData == null)) {
-                continue;
-            }
-            Preference matchingPref = preferenceScreen.findPreference(tile.key);
-            // If the tile does not have a matching preference, skip it.
-            if (matchingPref == null) {
-                continue;
-            }
-            // Either remove an icon by replacing them with nothing, or use the cached one since
-            // there is a delay in fetching the injected icon, and we don't want an inappropriate
-            // icon to be displayed while waiting for the injected icon.
-            final String iconUri =
-                    tile.metaData.getString(TileUtils.META_DATA_PREFERENCE_ICON_URI, null);
-            Drawable drawable = DEFAULT_ICON;
-            if ((iconUri != null) && sIconCache.containsKey(iconUri)) {
-                Pair<String, Integer> icon = sIconCache.get(iconUri);
-                try {
-                    drawable = context.getPackageManager()
-                            .getResourcesForApplication(icon.first /* package name */)
-                                    .getDrawable(icon.second /* res id */,
-                                            context.getTheme());
-                } catch (PackageManager.NameNotFoundException e) {
-                    // Ignore and just load the default icon.
-                }
-            }
-            matchingPref.setIcon(drawable);
-            // Either reserve room for the summary or load the cached one. This prevents the title
-            // from shifting when the final summary is injected.
-            final String summaryUri =
-                    tile.metaData.getString(TileUtils.META_DATA_PREFERENCE_SUMMARY_URI, null);
-            String summary = context.getString(R.string.summary_placeholder);
-            if ((summaryUri != null) && sSummaryCache.containsKey(summaryUri)) {
-                summary = sSummaryCache.get(summaryUri);
-            }
-            matchingPref.setSummary(summary);
-        }
-    }
-
-    @VisibleForTesting
-    void updatePreferencesToRunOnWorkerThread(Context context, PreferenceScreen preferenceScreen,
-            DashboardCategory dashboardCategory) {
-
-        int tilesCount = (dashboardCategory != null) ? dashboardCategory.getTilesCount() : 0;
-        Map<String, IContentProvider> providerMap = new ArrayMap<>();
-        for (int i = 0; i < tilesCount; i++) {
-            Tile tile = dashboardCategory.getTile(i);
-            // If the tile does not have a key or appropriate meta data, skip it.
-            if (TextUtils.isEmpty(tile.key) || (tile.metaData == null)) {
-                continue;
-            }
-            Preference matchingPref = preferenceScreen.findPreference(tile.key);
-            // If the tile does not have a matching preference, skip it.
-            if (matchingPref == null) {
-                continue;
-            }
-            // Check if the tile has content providers for dynamically updatable content.
-            final String iconUri =
-                    tile.metaData.getString(TileUtils.META_DATA_PREFERENCE_ICON_URI, null);
-            final String summaryUri =
-                    tile.metaData.getString(TileUtils.META_DATA_PREFERENCE_SUMMARY_URI, null);
-            if (!TextUtils.isEmpty(iconUri)) {
-                String packageName = null;
-                if (tile.intent != null) {
-                    Intent intent = tile.intent;
-                    if (!TextUtils.isEmpty(intent.getPackage())) {
-                        packageName = intent.getPackage();
-                    } else if (intent.getComponent() != null) {
-                        packageName = intent.getComponent().getPackageName();
-                    }
-                }
-                Pair<String, Integer> icon =
-                        TileUtils.getIconFromUri(context, packageName, iconUri, providerMap);
-                if (icon != null) {
-                    sIconCache.put(iconUri, icon);
-                    // Icon is only returned if the icon belongs to Settings or the target app.
-                    // setIcon must be called on the UI thread.
-                    ThreadUtils.postOnMainThread(() -> {
-                        try {
-                            matchingPref.setIcon(context.getPackageManager()
-                                    .getResourcesForApplication(icon.first /* package name */)
-                                    .getDrawable(icon.second /* res id */,
-                                            context.getTheme()));
-                        } catch (PackageManager.NameNotFoundException
-                                | Resources.NotFoundException e) {
-                            // Intentionally ignored. If icon resources cannot be found, do not
-                            // update.
-                        }
-                    });
-                }
-            }
-            if (!TextUtils.isEmpty(summaryUri)) {
-                String summary = TileUtils.getTextFromUri(context, summaryUri, providerMap,
-                        TileUtils.META_DATA_PREFERENCE_SUMMARY);
-                sSummaryCache.put(summaryUri, summary);
-                // setSummary must be called on UI thread.
-                ThreadUtils.postOnMainThread(() -> {
-                    // Only update the summary if it has actually changed.
-                    if (summary == null) {
-                        if (matchingPref.getSummary() != null) {
-                            matchingPref.setSummary(summary);
-                        }
-                    } else if (!summary.equals(matchingPref.getSummary())) {
-                        matchingPref.setSummary(summary);
-                    }
-                });
-            }
-        }
-    }
-
     @Override
     public TrustAgentManager getTrustAgentManager() {
         if (mTrustAgentManager == null) {
diff --git a/src/com/android/settings/security/SecuritySettings.java b/src/com/android/settings/security/SecuritySettings.java
index f099b44..df3b455 100644
--- a/src/com/android/settings/security/SecuritySettings.java
+++ b/src/com/android/settings/security/SecuritySettings.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -13,744 +13,62 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package com.android.settings.security;
 
-import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
+import static com.android.settings.security.EncryptionStatusPreferenceController
+        .PREF_KEY_ENCRYPTION_SECURITY_PAGE;
 
 import android.app.Activity;
-import android.app.AlertDialog;
-import android.app.Dialog;
-import android.app.FragmentManager;
-import android.app.admin.DevicePolicyManager;
 import android.content.Context;
-import android.content.DialogInterface;
 import android.content.Intent;
-import android.content.res.Resources;
 import android.hardware.fingerprint.FingerprintManager;
-import android.os.Bundle;
-import android.os.PersistableBundle;
-import android.os.UserHandle;
-import android.os.UserManager;
-import android.os.storage.StorageManager;
 import android.provider.SearchIndexableResource;
-import android.provider.Settings;
-import android.support.annotation.VisibleForTesting;
-import android.support.v14.preference.SwitchPreference;
-import android.support.v7.preference.Preference;
-import android.support.v7.preference.Preference.OnPreferenceChangeListener;
-import android.support.v7.preference.PreferenceGroup;
-import android.support.v7.preference.PreferenceScreen;
-import android.telephony.CarrierConfigManager;
-import android.telephony.SubscriptionInfo;
-import android.telephony.SubscriptionManager;
-import android.telephony.TelephonyManager;
-import android.text.TextUtils;
 
-import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.internal.widget.LockPatternUtils;
+import com.android.internal.logging.nano.MetricsProto;
 import com.android.settings.R;
-import com.android.settings.SettingsPreferenceFragment;
 import com.android.settings.Utils;
-import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
-import com.android.settings.dashboard.DashboardFeatureProvider;
+import com.android.settings.dashboard.DashboardFragment;
 import com.android.settings.dashboard.SummaryLoader;
 import com.android.settings.enterprise.EnterprisePrivacyPreferenceController;
 import com.android.settings.enterprise.ManageDeviceAdminPreferenceController;
-import com.android.settings.fingerprint.FingerprintSettings;
+import com.android.settings.fingerprint.FingerprintProfileStatusPreferenceController;
+import com.android.settings.fingerprint.FingerprintStatusPreferenceController;
 import com.android.settings.location.LocationPreferenceController;
-import com.android.settings.notification.LockScreenNotificationPreferenceController;
-import com.android.settings.overlay.FeatureFactory;
-import com.android.settings.password.ChooseLockGeneric.ChooseLockGenericFragment;
-import com.android.settings.password.ChooseLockSettingsHelper;
-import com.android.settings.password.ManagedLockPasswordProvider;
 import com.android.settings.search.BaseSearchIndexProvider;
-import com.android.settings.search.Indexable;
-import com.android.settings.search.SearchIndexableRaw;
-import com.android.settings.security.screenlock.ScreenLockSettings;
-import com.android.settings.security.trustagent.TrustAgentManager;
-import com.android.settings.security.trustagent.TrustAgentManager.TrustAgentComponentInfo;
-import com.android.settings.widget.GearPreference;
-import com.android.settingslib.RestrictedLockUtils;
-import com.android.settingslib.RestrictedPreference;
-import com.android.settingslib.RestrictedSwitchPreference;
-import com.android.settingslib.drawer.CategoryKey;
+import com.android.settings.security.screenlock.LockScreenPreferenceController;
+import com.android.settings.security.trustagent.ManageTrustAgentsPreferenceController;
+import com.android.settings.security.trustagent.TrustAgentListPreferenceController;
+import com.android.settings.widget.PreferenceCategoryController;
+import com.android.settingslib.core.AbstractPreferenceController;
+import com.android.settingslib.core.lifecycle.Lifecycle;
 
 import java.util.ArrayList;
 import java.util.List;
 
-/**
- * Gesture lock pattern settings.
- */
-public class SecuritySettings extends SettingsPreferenceFragment
-        implements OnPreferenceChangeListener, Indexable,
-        GearPreference.OnGearClickListener {
+public class SecuritySettings extends DashboardFragment {
 
     private static final String TAG = "SecuritySettings";
 
-    private static final String TRUST_AGENT_CLICK_INTENT = "trust_agent_click_intent";
-
-    // Lock Settings
-    private static final String KEY_UNLOCK_SET_OR_CHANGE = "unlock_set_or_change";
-    private static final String KEY_UNLOCK_SET_OR_CHANGE_PROFILE = "unlock_set_or_change_profile";
-    private static final String KEY_VISIBLE_PATTERN_PROFILE = "visiblepattern_profile";
-    private static final String KEY_SECURITY_CATEGORY = "security_category";
-    @VisibleForTesting
-    static final String KEY_MANAGE_TRUST_AGENTS = "manage_trust_agents";
-    private static final String KEY_UNIFICATION = "unification";
-    @VisibleForTesting
-    static final String KEY_LOCKSCREEN_PREFERENCES = "lockscreen_preferences";
-    private static final String KEY_ENCRYPTION_AND_CREDENTIALS = "encryption_and_credential";
-    private static final String KEY_LOCATION_SCANNING  = "location_scanning";
-    private static final String KEY_LOCATION = "location";
-
-    private static final int SET_OR_CHANGE_LOCK_METHOD_REQUEST = 123;
-    private static final int CHANGE_TRUST_AGENT_SETTINGS = 126;
-    private static final int SET_OR_CHANGE_LOCK_METHOD_REQUEST_PROFILE = 127;
-    private static final int UNIFY_LOCK_CONFIRM_DEVICE_REQUEST = 128;
-    private static final int UNIFY_LOCK_CONFIRM_PROFILE_REQUEST = 129;
-    private static final int UNUNIFY_LOCK_CONFIRM_DEVICE_REQUEST = 130;
-    private static final String TAG_UNIFICATION_DIALOG = "unification_dialog";
-
-    // Misc Settings
-    private static final String KEY_SIM_LOCK = "sim_lock_settings";
-    private static final String KEY_SHOW_PASSWORD = "show_password";
-    private static final String KEY_TRUST_AGENT = "trust_agent";
-    private static final String KEY_SCREEN_PINNING = "screen_pinning_settings";
-
-    // Security status
-    private static final String KEY_SECURITY_STATUS = "security_status";
-    private static final String SECURITY_STATUS_KEY_PREFIX = "security_status_";
-
-    // Device management settings
-    private static final String KEY_ENTERPRISE_PRIVACY = "enterprise_privacy";
-    private static final String KEY_MANAGE_DEVICE_ADMIN = "manage_device_admin";
-
-    // These switch preferences need special handling since they're not all stored in Settings.
-    private static final String SWITCH_PREFERENCE_KEYS[] = {
-            KEY_SHOW_PASSWORD, KEY_UNIFICATION, KEY_VISIBLE_PATTERN_PROFILE
-    };
-
-    private static final int MY_USER_ID = UserHandle.myUserId();
-
-    private DashboardFeatureProvider mDashboardFeatureProvider;
-    private DevicePolicyManager mDPM;
-    private SecurityFeatureProvider mSecurityFeatureProvider;
-    private TrustAgentManager mTrustAgentManager;
-    private SubscriptionManager mSubscriptionManager;
-    private UserManager mUm;
-
-    private ChooseLockSettingsHelper mChooseLockSettingsHelper;
-    private LockPatternUtils mLockPatternUtils;
-    private ManagedLockPasswordProvider mManagedPasswordProvider;
-
-    private SwitchPreference mVisiblePatternProfile;
-    private RestrictedSwitchPreference mUnifyProfile;
-
-    private SwitchPreference mShowPassword;
-
-    private boolean mIsAdmin;
-
-    private Intent mTrustAgentClickIntent;
-
-    private int mProfileChallengeUserId;
-
-    private String mCurrentDevicePassword;
-    private String mCurrentProfilePassword;
-
-    private LocationPreferenceController mLocationcontroller;
-    private ManageDeviceAdminPreferenceController mManageDeviceAdminPreferenceController;
-    private EnterprisePrivacyPreferenceController mEnterprisePrivacyPreferenceController;
+    public static final int SET_OR_CHANGE_LOCK_METHOD_REQUEST = 123;
+    public static final int CHANGE_TRUST_AGENT_SETTINGS = 126;
+    public static final int SET_OR_CHANGE_LOCK_METHOD_REQUEST_PROFILE = 127;
+    public static final int UNIFY_LOCK_CONFIRM_DEVICE_REQUEST = 128;
+    public static final int UNIFY_LOCK_CONFIRM_PROFILE_REQUEST = 129;
+    public static final int UNUNIFY_LOCK_CONFIRM_DEVICE_REQUEST = 130;
 
     @Override
     public int getMetricsCategory() {
-        return MetricsEvent.SECURITY;
+        return MetricsProto.MetricsEvent.SECURITY;
     }
 
     @Override
-    public void onAttach(Context context) {
-        super.onAttach(context);
-        mLocationcontroller = new LocationPreferenceController(context, getLifecycle());
+    protected int getPreferenceScreenResId() {
+        return R.xml.security_dashboard_settings;
     }
 
     @Override
-    public void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-
-        final Activity activity = getActivity();
-
-        mSubscriptionManager = SubscriptionManager.from(activity);
-
-        mLockPatternUtils = new LockPatternUtils(activity);
-
-        mManagedPasswordProvider = ManagedLockPasswordProvider.get(activity, MY_USER_ID);
-
-        mDPM = (DevicePolicyManager)getSystemService(Context.DEVICE_POLICY_SERVICE);
-
-        mUm = UserManager.get(activity);
-
-        mChooseLockSettingsHelper = new ChooseLockSettingsHelper(activity);
-
-        mDashboardFeatureProvider = FeatureFactory.getFactory(activity)
-                .getDashboardFeatureProvider(activity);
-
-        mSecurityFeatureProvider = FeatureFactory.getFactory(activity).getSecurityFeatureProvider();
-
-        mTrustAgentManager = mSecurityFeatureProvider.getTrustAgentManager();
-
-        if (savedInstanceState != null
-                && savedInstanceState.containsKey(TRUST_AGENT_CLICK_INTENT)) {
-            mTrustAgentClickIntent = savedInstanceState.getParcelable(TRUST_AGENT_CLICK_INTENT);
-        }
-
-        mManageDeviceAdminPreferenceController
-                = new ManageDeviceAdminPreferenceController(activity);
-        mEnterprisePrivacyPreferenceController
-                = new EnterprisePrivacyPreferenceController(activity);
-    }
-
-    private static int getResIdForLockUnlockScreen(LockPatternUtils lockPatternUtils,
-            ManagedLockPasswordProvider managedPasswordProvider, int userId) {
-        final boolean isMyUser = userId == MY_USER_ID;
-        int resid = 0;
-        if (!lockPatternUtils.isSecure(userId)) {
-            if (!isMyUser) {
-                resid = R.xml.security_settings_lockscreen_profile;
-            } else if (lockPatternUtils.isLockScreenDisabled(userId)) {
-                resid = R.xml.security_settings_lockscreen;
-            } else {
-                resid = R.xml.security_settings_chooser;
-            }
-        } else {
-            switch (lockPatternUtils.getKeyguardStoredPasswordQuality(userId)) {
-                case DevicePolicyManager.PASSWORD_QUALITY_SOMETHING:
-                    resid = isMyUser ? R.xml.security_settings_pattern
-                            : R.xml.security_settings_pattern_profile;
-                    break;
-                case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC:
-                case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC_COMPLEX:
-                    resid = isMyUser ? R.xml.security_settings_pin
-                            : R.xml.security_settings_pin_profile;
-                    break;
-                case DevicePolicyManager.PASSWORD_QUALITY_ALPHABETIC:
-                case DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC:
-                case DevicePolicyManager.PASSWORD_QUALITY_COMPLEX:
-                    resid = isMyUser ? R.xml.security_settings_password
-                            : R.xml.security_settings_password_profile;
-                    break;
-                case DevicePolicyManager.PASSWORD_QUALITY_MANAGED:
-                    resid = managedPasswordProvider.getResIdForLockUnlockScreen(!isMyUser);
-                    break;
-            }
-        }
-        return resid;
-    }
-
-    /**
-     * Important!
-     *
-     * Don't forget to update the SecuritySearchIndexProvider if you are doing any change in the
-     * logic or adding/removing preferences here.
-     */
-    private PreferenceScreen createPreferenceHierarchy() {
-        PreferenceScreen root = getPreferenceScreen();
-        if (root != null) {
-            root.removeAll();
-        }
-        addPreferencesFromResource(R.xml.security_settings);
-        root = getPreferenceScreen();
-
-        // Add category for security status
-        addPreferencesFromResource(R.xml.security_settings_status);
-
-        // Add options for lock/unlock screen
-        final int resid = getResIdForLockUnlockScreen(mLockPatternUtils,
-                mManagedPasswordProvider, MY_USER_ID);
-        addPreferencesFromResource(resid);
-
-        // DO or PO installed in the user may disallow to change password.
-        disableIfPasswordQualityManaged(KEY_UNLOCK_SET_OR_CHANGE, MY_USER_ID);
-
-        mProfileChallengeUserId = Utils.getManagedProfileId(mUm, MY_USER_ID);
-        if (mProfileChallengeUserId != UserHandle.USER_NULL
-                && mLockPatternUtils.isSeparateProfileChallengeAllowed(mProfileChallengeUserId)) {
-            addPreferencesFromResource(R.xml.security_settings_profile);
-            addPreferencesFromResource(R.xml.security_settings_unification);
-            final int profileResid = getResIdForLockUnlockScreen(mLockPatternUtils,
-                    mManagedPasswordProvider, mProfileChallengeUserId);
-            addPreferencesFromResource(profileResid);
-            maybeAddFingerprintPreference(root, mProfileChallengeUserId);
-            if (!mLockPatternUtils.isSeparateProfileChallengeEnabled(mProfileChallengeUserId)) {
-                final Preference lockPreference =
-                        root.findPreference(KEY_UNLOCK_SET_OR_CHANGE_PROFILE);
-                final String summary = getContext().getString(
-                        R.string.lock_settings_profile_unified_summary);
-                lockPreference.setSummary(summary);
-                lockPreference.setEnabled(false);
-                // PO may disallow to change password for the profile, but screen lock and managed
-                // profile's lock is the same. Disable main "Screen lock" menu.
-                disableIfPasswordQualityManaged(KEY_UNLOCK_SET_OR_CHANGE, mProfileChallengeUserId);
-            } else {
-                // PO may disallow to change profile password, and the profile's password is
-                // separated from screen lock password. Disable profile specific "Screen lock" menu.
-                disableIfPasswordQualityManaged(KEY_UNLOCK_SET_OR_CHANGE_PROFILE,
-                        mProfileChallengeUserId);
-            }
-        }
-
-        Preference unlockSetOrChange = findPreference(KEY_UNLOCK_SET_OR_CHANGE);
-        if (unlockSetOrChange instanceof GearPreference) {
-            ((GearPreference) unlockSetOrChange).setOnGearClickListener(this);
-        }
-
-        mIsAdmin = mUm.isAdminUser();
-
-        // Fingerprint and trust agents
-        int numberOfTrustAgent = 0;
-        PreferenceGroup securityCategory = (PreferenceGroup)
-                root.findPreference(KEY_SECURITY_CATEGORY);
-        if (securityCategory != null) {
-            maybeAddFingerprintPreference(securityCategory, UserHandle.myUserId());
-            numberOfTrustAgent = addTrustAgentSettings(securityCategory);
-            setLockscreenPreferencesSummary(securityCategory);
-        }
-
-        mVisiblePatternProfile =
-                (SwitchPreference) root.findPreference(KEY_VISIBLE_PATTERN_PROFILE);
-        mUnifyProfile = (RestrictedSwitchPreference) root.findPreference(KEY_UNIFICATION);
-
-        // Append the rest of the settings
-        addPreferencesFromResource(R.xml.security_settings_misc);
-
-        // Do not display SIM lock for devices without an Icc card
-        TelephonyManager tm = TelephonyManager.getDefault();
-        CarrierConfigManager cfgMgr = (CarrierConfigManager)
-                getActivity().getSystemService(Context.CARRIER_CONFIG_SERVICE);
-        PersistableBundle b = cfgMgr.getConfig();
-        if (!mIsAdmin || !isSimIccReady() ||
-                b.getBoolean(CarrierConfigManager.KEY_HIDE_SIM_LOCK_SETTINGS_BOOL)) {
-            root.removePreference(root.findPreference(KEY_SIM_LOCK));
-        } else {
-            // Disable SIM lock if there is no ready SIM card.
-            root.findPreference(KEY_SIM_LOCK).setEnabled(isSimReady());
-        }
-        if (Settings.System.getInt(getContentResolver(),
-                Settings.System.LOCK_TO_APP_ENABLED, 0) != 0) {
-            root.findPreference(KEY_SCREEN_PINNING).setSummary(
-                    getResources().getString(R.string.switch_on_text));
-        }
-
-        // Encryption status of device
-        if (LockPatternUtils.isDeviceEncryptionEnabled()) {
-            root.findPreference(KEY_ENCRYPTION_AND_CREDENTIALS).setSummary(
-                R.string.encryption_and_credential_settings_summary);
-        } else {
-            root.findPreference(KEY_ENCRYPTION_AND_CREDENTIALS).setSummary(
-                R.string.summary_placeholder);
-        }
-
-        // Show password
-        mShowPassword = (SwitchPreference) root.findPreference(KEY_SHOW_PASSWORD);
-
-        // Credential storage
-        final UserManager um = (UserManager) getActivity().getSystemService(Context.USER_SERVICE);
-
-        // Advanced Security features
-        initTrustAgentPreference(root, numberOfTrustAgent);
-
-        PreferenceGroup securityStatusPreferenceGroup =
-                (PreferenceGroup) root.findPreference(KEY_SECURITY_STATUS);
-        final List<Preference> tilePrefs = mDashboardFeatureProvider.getPreferencesForCategory(
-            getActivity(), getPrefContext(), getMetricsCategory(),
-            CategoryKey.CATEGORY_SECURITY);
-        int numSecurityStatusPrefs = 0;
-        if (tilePrefs != null && !tilePrefs.isEmpty()) {
-            for (Preference preference : tilePrefs) {
-                if (!TextUtils.isEmpty(preference.getKey())
-                    && preference.getKey().startsWith(SECURITY_STATUS_KEY_PREFIX)) {
-                    // Injected security status settings are placed under the Security status
-                    // category.
-                    securityStatusPreferenceGroup.addPreference(preference);
-                    numSecurityStatusPrefs++;
-                } else {
-                    // Other injected settings are placed under the Security preference screen.
-                    root.addPreference(preference);
-                }
-            }
-        }
-
-        if (numSecurityStatusPrefs == 0) {
-            root.removePreference(securityStatusPreferenceGroup);
-        } else if (numSecurityStatusPrefs > 0) {
-            // Update preference data with tile data. Security feature provider only updates the
-            // data if it actually needs to be changed.
-            mSecurityFeatureProvider.updatePreferences(getActivity(), root,
-                mDashboardFeatureProvider.getTilesForCategory(
-                    CategoryKey.CATEGORY_SECURITY));
-        }
-
-        for (int i = 0; i < SWITCH_PREFERENCE_KEYS.length; i++) {
-            final Preference pref = findPreference(SWITCH_PREFERENCE_KEYS[i]);
-            if (pref != null) pref.setOnPreferenceChangeListener(this);
-        }
-
-        mLocationcontroller.displayPreference(root);
-        mManageDeviceAdminPreferenceController.updateState(
-                root.findPreference(KEY_MANAGE_DEVICE_ADMIN));
-        mEnterprisePrivacyPreferenceController.displayPreference(root);
-        final Preference enterprisePrivacyPreference = root.findPreference(
-                mEnterprisePrivacyPreferenceController.getPreferenceKey());
-        mEnterprisePrivacyPreferenceController.updateState(enterprisePrivacyPreference);
-
-        return root;
-    }
-
-    @VisibleForTesting
-    void initTrustAgentPreference(PreferenceScreen root, int numberOfTrustAgent) {
-        Preference manageAgents = root.findPreference(KEY_MANAGE_TRUST_AGENTS);
-        if (manageAgents != null) {
-            if (!mLockPatternUtils.isSecure(MY_USER_ID)) {
-                manageAgents.setEnabled(false);
-                manageAgents.setSummary(R.string.disabled_because_no_backup_security);
-            } else if (numberOfTrustAgent > 0) {
-                manageAgents.setSummary(getActivity().getResources().getQuantityString(
-                    R.plurals.manage_trust_agents_summary_on,
-                    numberOfTrustAgent, numberOfTrustAgent));
-            } else {
-                manageAgents.setSummary(R.string.manage_trust_agents_summary);
-            }
-        }
-    }
-
-    @VisibleForTesting
-    void setLockscreenPreferencesSummary(PreferenceGroup group) {
-        final Preference lockscreenPreferences = group.findPreference(KEY_LOCKSCREEN_PREFERENCES);
-        if (lockscreenPreferences != null) {
-            lockscreenPreferences.setSummary(
-                LockScreenNotificationPreferenceController.getSummaryResource(getContext()));
-        }
-    }
-
-    /*
-     * Sets the preference as disabled by admin if PASSWORD_QUALITY_MANAGED is set.
-     * The preference must be a RestrictedPreference.
-     */
-    private void disableIfPasswordQualityManaged(String preferenceKey, int userId) {
-        final EnforcedAdmin admin = RestrictedLockUtils.checkIfPasswordQualityIsSet(
-                getActivity(), userId);
-        if (admin != null && mDPM.getPasswordQuality(admin.component, userId) ==
-                DevicePolicyManager.PASSWORD_QUALITY_MANAGED) {
-            final RestrictedPreference pref =
-                    (RestrictedPreference) getPreferenceScreen().findPreference(preferenceKey);
-            pref.setDisabledByAdmin(admin);
-        }
-    }
-
-    private void maybeAddFingerprintPreference(PreferenceGroup securityCategory, int userId) {
-        Preference fingerprintPreference =
-                FingerprintSettings.getFingerprintPreferenceForUser(
-                        securityCategory.getContext(), userId);
-        if (fingerprintPreference != null) {
-            securityCategory.addPreference(fingerprintPreference);
-        }
-    }
-
-    // Return the number of trust agents being added
-    private int addTrustAgentSettings(PreferenceGroup securityCategory) {
-        final boolean hasSecurity = mLockPatternUtils.isSecure(MY_USER_ID);
-        final List<TrustAgentComponentInfo> agents = mTrustAgentManager.getActiveTrustAgents(
-                getActivity(), mLockPatternUtils);
-        for (TrustAgentComponentInfo agent : agents) {
-            final RestrictedPreference trustAgentPreference =
-                    new RestrictedPreference(securityCategory.getContext());
-            trustAgentPreference.setKey(KEY_TRUST_AGENT);
-            trustAgentPreference.setTitle(agent.title);
-            trustAgentPreference.setSummary(agent.summary);
-            // Create intent for this preference.
-            Intent intent = new Intent();
-            intent.setComponent(agent.componentName);
-            intent.setAction(Intent.ACTION_MAIN);
-            trustAgentPreference.setIntent(intent);
-            // Add preference to the settings menu.
-            securityCategory.addPreference(trustAgentPreference);
-
-            trustAgentPreference.setDisabledByAdmin(agent.admin);
-            if (!trustAgentPreference.isDisabledByAdmin() && !hasSecurity) {
-                trustAgentPreference.setEnabled(false);
-                trustAgentPreference.setSummary(R.string.disabled_because_no_backup_security);
-            }
-        }
-        return agents.size();
-    }
-
-    /* Return true if a there is a Slot that has Icc.
-     */
-    private boolean isSimIccReady() {
-        TelephonyManager tm = TelephonyManager.getDefault();
-        final List<SubscriptionInfo> subInfoList =
-                mSubscriptionManager.getActiveSubscriptionInfoList();
-
-        if (subInfoList != null) {
-            for (SubscriptionInfo subInfo : subInfoList) {
-                if (tm.hasIccCard(subInfo.getSimSlotIndex())) {
-                    return true;
-                }
-            }
-        }
-
-        return false;
-    }
-
-    /* Return true if a SIM is ready for locking.
-     * TODO: consider adding to TelephonyManager or SubscritpionManasger.
-     */
-    private boolean isSimReady() {
-        int simState = TelephonyManager.SIM_STATE_UNKNOWN;
-        final List<SubscriptionInfo> subInfoList =
-                mSubscriptionManager.getActiveSubscriptionInfoList();
-        if (subInfoList != null) {
-            for (SubscriptionInfo subInfo : subInfoList) {
-                simState = TelephonyManager.getDefault().getSimState(subInfo.getSimSlotIndex());
-                if((simState != TelephonyManager.SIM_STATE_ABSENT) &&
-                            (simState != TelephonyManager.SIM_STATE_UNKNOWN)){
-                    return true;
-                }
-            }
-        }
-        return false;
-    }
-
-    @Override
-    public void onGearClick(GearPreference p) {
-        if (KEY_UNLOCK_SET_OR_CHANGE.equals(p.getKey())) {
-            startFragment(this, ScreenLockSettings.class.getName(), 0, 0, null);
-        }
-    }
-
-    @Override
-    public void onSaveInstanceState(Bundle outState) {
-        super.onSaveInstanceState(outState);
-        if (mTrustAgentClickIntent != null) {
-            outState.putParcelable(TRUST_AGENT_CLICK_INTENT, mTrustAgentClickIntent);
-        }
-    }
-
-    @Override
-    public void onResume() {
-        super.onResume();
-
-        // Make sure we reload the preference hierarchy since some of these settings
-        // depend on others...
-        createPreferenceHierarchy();
-
-        if (mVisiblePatternProfile != null) {
-            mVisiblePatternProfile.setChecked(mLockPatternUtils.isVisiblePatternEnabled(
-                    mProfileChallengeUserId));
-        }
-
-        updateUnificationPreference();
-
-        if (mShowPassword != null) {
-            mShowPassword.setChecked(Settings.System.getInt(getContentResolver(),
-                    Settings.System.TEXT_SHOW_PASSWORD, 1) != 0);
-        }
-
-        mLocationcontroller.updateSummary();
-    }
-
-    @VisibleForTesting
-    void updateUnificationPreference() {
-        if (mUnifyProfile != null) {
-            final boolean separate =
-                    mLockPatternUtils.isSeparateProfileChallengeEnabled(mProfileChallengeUserId);
-            mUnifyProfile.setChecked(!separate);
-            if (separate) {
-                mUnifyProfile.setDisabledByAdmin(RestrictedLockUtils.checkIfRestrictionEnforced(
-                        getContext(), UserManager.DISALLOW_UNIFIED_PASSWORD,
-                        mProfileChallengeUserId));
-            }
-        }
-    }
-
-    @Override
-    public boolean onPreferenceTreeClick(Preference preference) {
-        final String key = preference.getKey();
-        if (KEY_UNLOCK_SET_OR_CHANGE.equals(key)) {
-            // TODO(b/35930129): Remove once existing password can be passed into vold directly.
-            // Currently we need this logic to ensure that the QUIET_MODE is off for any work
-            // profile with unified challenge on FBE-enabled devices. Otherwise, vold would not be
-            // able to complete the operation due to the lack of (old) encryption key.
-            if (mProfileChallengeUserId != UserHandle.USER_NULL
-                    && !mLockPatternUtils.isSeparateProfileChallengeEnabled(mProfileChallengeUserId)
-                    && StorageManager.isFileEncryptedNativeOnly()) {
-                if (Utils.startQuietModeDialogIfNecessary(this.getActivity(), mUm,
-                        mProfileChallengeUserId)) {
-                    return false;
-                }
-            }
-            startFragment(this, ChooseLockGenericFragment.class.getName(),
-                    R.string.lock_settings_picker_title, SET_OR_CHANGE_LOCK_METHOD_REQUEST, null);
-        } else if (KEY_UNLOCK_SET_OR_CHANGE_PROFILE.equals(key)) {
-            if (Utils.startQuietModeDialogIfNecessary(this.getActivity(), mUm,
-                    mProfileChallengeUserId)) {
-                return false;
-            }
-            Bundle extras = new Bundle();
-            extras.putInt(Intent.EXTRA_USER_ID, mProfileChallengeUserId);
-            startFragment(this, ChooseLockGenericFragment.class.getName(),
-                    R.string.lock_settings_picker_title_profile,
-                    SET_OR_CHANGE_LOCK_METHOD_REQUEST_PROFILE, extras);
-        } else if (KEY_TRUST_AGENT.equals(key)) {
-            ChooseLockSettingsHelper helper =
-                    new ChooseLockSettingsHelper(this.getActivity(), this);
-            mTrustAgentClickIntent = preference.getIntent();
-            boolean confirmationLaunched = helper.launchConfirmationActivity(
-                    CHANGE_TRUST_AGENT_SETTINGS, preference.getTitle());
-            if (!confirmationLaunched&&  mTrustAgentClickIntent != null) {
-                // If this returns false, it means no password confirmation is required.
-                startActivity(mTrustAgentClickIntent);
-                mTrustAgentClickIntent = null;
-            }
-        } else {
-            // If we didn't handle it, let preferences handle it.
-            return super.onPreferenceTreeClick(preference);
-        }
-        return true;
-    }
-
-    /**
-     * see confirmPatternThenDisableAndClear
-     */
-    @Override
-    public void onActivityResult(int requestCode, int resultCode, Intent data) {
-        super.onActivityResult(requestCode, resultCode, data);
-        if (requestCode == CHANGE_TRUST_AGENT_SETTINGS && resultCode == Activity.RESULT_OK) {
-            if (mTrustAgentClickIntent != null) {
-                startActivity(mTrustAgentClickIntent);
-                mTrustAgentClickIntent = null;
-            }
-            return;
-        } else if (requestCode == UNIFY_LOCK_CONFIRM_DEVICE_REQUEST
-                && resultCode == Activity.RESULT_OK) {
-            mCurrentDevicePassword =
-                    data.getStringExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
-            launchConfirmProfileLockForUnification();
-            return;
-        } else if (requestCode == UNIFY_LOCK_CONFIRM_PROFILE_REQUEST
-                && resultCode == Activity.RESULT_OK) {
-            mCurrentProfilePassword =
-                    data.getStringExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
-            unifyLocks();
-            return;
-        } else if (requestCode == UNUNIFY_LOCK_CONFIRM_DEVICE_REQUEST
-                && resultCode == Activity.RESULT_OK) {
-            ununifyLocks();
-            return;
-        }
-        createPreferenceHierarchy();
-    }
-
-    private void launchConfirmDeviceLockForUnification() {
-        final String title = getActivity().getString(
-                R.string.unlock_set_unlock_launch_picker_title);
-        final ChooseLockSettingsHelper helper =
-                new ChooseLockSettingsHelper(getActivity(), this);
-        if (!helper.launchConfirmationActivity(
-                UNIFY_LOCK_CONFIRM_DEVICE_REQUEST, title, true, MY_USER_ID)) {
-            launchConfirmProfileLockForUnification();
-        }
-    }
-
-    private void launchConfirmProfileLockForUnification() {
-        final String title = getActivity().getString(
-                R.string.unlock_set_unlock_launch_picker_title_profile);
-        final ChooseLockSettingsHelper helper =
-                new ChooseLockSettingsHelper(getActivity(), this);
-        if (!helper.launchConfirmationActivity(
-                UNIFY_LOCK_CONFIRM_PROFILE_REQUEST, title, true, mProfileChallengeUserId)) {
-            unifyLocks();
-            createPreferenceHierarchy();
-        }
-    }
-
-    private void unifyLocks() {
-        int profileQuality =
-                mLockPatternUtils.getKeyguardStoredPasswordQuality(mProfileChallengeUserId);
-        if (profileQuality == DevicePolicyManager.PASSWORD_QUALITY_SOMETHING) {
-            mLockPatternUtils.saveLockPattern(
-                    LockPatternUtils.stringToPattern(mCurrentProfilePassword),
-                    mCurrentDevicePassword, MY_USER_ID);
-        } else {
-            mLockPatternUtils.saveLockPassword(
-                    mCurrentProfilePassword, mCurrentDevicePassword,
-                    profileQuality, MY_USER_ID);
-        }
-        mLockPatternUtils.setSeparateProfileChallengeEnabled(mProfileChallengeUserId, false,
-                mCurrentProfilePassword);
-        final boolean profilePatternVisibility =
-                mLockPatternUtils.isVisiblePatternEnabled(mProfileChallengeUserId);
-        mLockPatternUtils.setVisiblePatternEnabled(profilePatternVisibility, MY_USER_ID);
-        mCurrentDevicePassword = null;
-        mCurrentProfilePassword = null;
-    }
-
-    private void unifyUncompliantLocks() {
-        mLockPatternUtils.setSeparateProfileChallengeEnabled(mProfileChallengeUserId, false,
-                mCurrentProfilePassword);
-        startFragment(this, ChooseLockGenericFragment.class.getName(),
-                R.string.lock_settings_picker_title, SET_OR_CHANGE_LOCK_METHOD_REQUEST, null);
-    }
-
-    private void ununifyLocks() {
-        Bundle extras = new Bundle();
-        extras.putInt(Intent.EXTRA_USER_ID, mProfileChallengeUserId);
-        startFragment(this,
-                ChooseLockGenericFragment.class.getName(),
-                R.string.lock_settings_picker_title_profile,
-                SET_OR_CHANGE_LOCK_METHOD_REQUEST_PROFILE, extras);
-    }
-
-    @Override
-    public boolean onPreferenceChange(Preference preference, Object value) {
-        boolean result = true;
-        final String key = preference.getKey();
-        final LockPatternUtils lockPatternUtils = mChooseLockSettingsHelper.utils();
-        if (KEY_VISIBLE_PATTERN_PROFILE.equals(key)) {
-            if (Utils.startQuietModeDialogIfNecessary(this.getActivity(), mUm,
-                    mProfileChallengeUserId)) {
-                return false;
-            }
-            lockPatternUtils.setVisiblePatternEnabled((Boolean) value, mProfileChallengeUserId);
-        } else if (KEY_UNIFICATION.equals(key)) {
-            if (Utils.startQuietModeDialogIfNecessary(this.getActivity(), mUm,
-                    mProfileChallengeUserId)) {
-                return false;
-            }
-            if ((Boolean) value) {
-                final boolean compliantForDevice =
-                        (mLockPatternUtils.getKeyguardStoredPasswordQuality(mProfileChallengeUserId)
-                                >= DevicePolicyManager.PASSWORD_QUALITY_SOMETHING
-                        && mLockPatternUtils.isSeparateProfileChallengeAllowedToUnify(
-                                mProfileChallengeUserId));
-                UnificationConfirmationDialog dialog =
-                        UnificationConfirmationDialog.newIntance(compliantForDevice);
-                dialog.show(getChildFragmentManager(), TAG_UNIFICATION_DIALOG);
-            } else {
-                final String title = getActivity().getString(
-                        R.string.unlock_set_unlock_launch_picker_title);
-                final ChooseLockSettingsHelper helper =
-                        new ChooseLockSettingsHelper(getActivity(), this);
-                if(!helper.launchConfirmationActivity(
-                        UNUNIFY_LOCK_CONFIRM_DEVICE_REQUEST, title, true, MY_USER_ID)) {
-                    ununifyLocks();
-                }
-            }
-        } else if (KEY_SHOW_PASSWORD.equals(key)) {
-            Settings.System.putInt(getContentResolver(), Settings.System.TEXT_SHOW_PASSWORD,
-                    ((Boolean) value) ? 1 : 0);
-            lockPatternUtils.setVisiblePasswordEnabled((Boolean) value, MY_USER_ID);
-        }
-        return result;
+    protected String getLogTag() {
+        return TAG;
     }
 
     @Override
@@ -758,206 +76,95 @@
         return R.string.help_url_security;
     }
 
+    @Override
+    protected List<AbstractPreferenceController> getPreferenceControllers(Context context) {
+        return buildPreferenceControllers(context, getLifecycle(), this /* host*/);
+    }
+
+    /**
+     * see confirmPatternThenDisableAndClear
+     */
+    @Override
+    public void onActivityResult(int requestCode, int resultCode, Intent data) {
+        if (getPreferenceController(TrustAgentListPreferenceController.class)
+                .handleActivityResult(requestCode, resultCode)) {
+            return;
+        }
+        if (getPreferenceController(LockUnificationPreferenceController.class)
+                .handleActivityResult(requestCode, resultCode, data)) {
+            return;
+        }
+        super.onActivityResult(requestCode, resultCode, data);
+    }
+
+    void launchConfirmDeviceLockForUnification() {
+        getPreferenceController(LockUnificationPreferenceController.class)
+                .launchConfirmDeviceLockForUnification();
+    }
+
+    void unifyUncompliantLocks() {
+        getPreferenceController(LockUnificationPreferenceController.class).unifyUncompliantLocks();
+    }
+
+    void updateUnificationPreference() {
+        getPreferenceController(LockUnificationPreferenceController.class).updateState(null);
+    }
+
+    private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
+            Lifecycle lifecycle, SecuritySettings host) {
+        final List<AbstractPreferenceController> controllers = new ArrayList<>();
+        controllers.add(new LocationPreferenceController(context, lifecycle));
+        controllers.add(new ManageDeviceAdminPreferenceController(context));
+        controllers.add(new EnterprisePrivacyPreferenceController(context));
+        controllers.add(new ManageTrustAgentsPreferenceController(context));
+        controllers.add(new ScreenPinningPreferenceController(context));
+        controllers.add(new SimLockPreferenceController(context));
+        controllers.add(new ShowPasswordPreferenceController(context));
+        controllers.add(new FingerprintStatusPreferenceController(context));
+        controllers.add(new EncryptionStatusPreferenceController(context,
+                PREF_KEY_ENCRYPTION_SECURITY_PAGE));
+        controllers.add(new TrustAgentListPreferenceController(context, host, lifecycle));
+        controllers.add(new LockScreenPreferenceController(context, lifecycle));
+        controllers.add(new ChangeScreenLockPreferenceController(context, host));
+
+        final List<AbstractPreferenceController> profileSecurityControllers = new ArrayList<>();
+        profileSecurityControllers.add(new ChangeProfileScreenLockPreferenceController(
+                context, host));
+        profileSecurityControllers.add(new LockUnificationPreferenceController(context, host));
+        profileSecurityControllers.add(new VisiblePatternProfilePreferenceController(
+                context, lifecycle));
+        profileSecurityControllers.add(new FingerprintProfileStatusPreferenceController(context));
+        controllers.add(new PreferenceCategoryController(context, "security_category_profile",
+                profileSecurityControllers));
+        controllers.addAll(profileSecurityControllers);
+
+        return controllers;
+    }
+
     /**
      * For Search. Please keep it in sync when updating "createPreferenceHierarchy()"
      */
     public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
-            new SecuritySearchIndexProvider();
+            new BaseSearchIndexProvider() {
 
-    private static class SecuritySearchIndexProvider extends BaseSearchIndexProvider {
-
-        // TODO (b/68001777) Refactor indexing to include all XML and block other settings.
-
-        @Override
-        public List<SearchIndexableResource> getXmlResourcesToIndex(
-                Context context, boolean enabled) {
-            final List<SearchIndexableResource> index = new ArrayList<>();
-
-            final LockPatternUtils lockPatternUtils = new LockPatternUtils(context);
-            final ManagedLockPasswordProvider managedPasswordProvider =
-                    ManagedLockPasswordProvider.get(context, MY_USER_ID);
-            final DevicePolicyManager dpm = (DevicePolicyManager)
-                    context.getSystemService(Context.DEVICE_POLICY_SERVICE);
-            final UserManager um = UserManager.get(context);
-            final int profileUserId = Utils.getManagedProfileId(um, MY_USER_ID);
-
-            // To add option for unlock screen, user's password must not be managed and
-            // must not be unified with managed profile, whose password is managed.
-            if (!isPasswordManaged(MY_USER_ID, context, dpm)
-                    && (profileUserId == UserHandle.USER_NULL
-                            || lockPatternUtils.isSeparateProfileChallengeAllowed(profileUserId)
-                            || !isPasswordManaged(profileUserId, context, dpm))) {
-                // Add options for lock/unlock screen
-                final int resId = getResIdForLockUnlockScreen(lockPatternUtils,
-                        managedPasswordProvider, MY_USER_ID);
-                index.add(getSearchResource(context, resId));
-            }
-
-            if (profileUserId != UserHandle.USER_NULL
-                    && lockPatternUtils.isSeparateProfileChallengeAllowed(profileUserId)
-                    && !isPasswordManaged(profileUserId, context, dpm)) {
-                index.add(getSearchResource(context, getResIdForLockUnlockScreen(
-                        lockPatternUtils, managedPasswordProvider, profileUserId)));
-            }
-
-            // Append the rest of the settings
-            index.add(getSearchResource(context, R.xml.security_settings_misc));
-
-            return index;
-        }
-
-        private SearchIndexableResource getSearchResource(Context context, int xmlResId) {
-            final SearchIndexableResource sir = new SearchIndexableResource(context);
-            sir.xmlResId = xmlResId;
-            return sir;
-        }
-
-        private boolean isPasswordManaged(int userId, Context context, DevicePolicyManager dpm) {
-            final EnforcedAdmin admin = RestrictedLockUtils.checkIfPasswordQualityIsSet(
-                    context, userId);
-            return admin != null && dpm.getPasswordQuality(admin.component, userId) ==
-                    DevicePolicyManager.PASSWORD_QUALITY_MANAGED;
-        }
-
-        @Override
-        public List<SearchIndexableRaw> getRawDataToIndex(Context context, boolean enabled) {
-            final List<SearchIndexableRaw> result = new ArrayList<SearchIndexableRaw>();
-            final Resources res = context.getResources();
-
-            final String screenTitle = res.getString(R.string.security_settings_title);
-
-            SearchIndexableRaw data = new SearchIndexableRaw(context);
-            data.title = screenTitle;
-            data.key = "security_settings_screen";
-            data.screenTitle = screenTitle;
-            result.add(data);
-
-            final UserManager um = UserManager.get(context);
-
-            // Fingerprint
-            final FingerprintManager fpm = Utils.getFingerprintManagerOrNull(context);
-            if (fpm != null && fpm.isHardwareDetected()) {
-                // This catches the title which can be overloaded in an overlay
-                data = new SearchIndexableRaw(context);
-                data.title = res.getString(R.string.security_settings_fingerprint_preference_title);
-                data.key = "security_fingerprint";
-                data.screenTitle = screenTitle;
-                result.add(data);
-                // Fallback for when the above doesn't contain "fingerprint"
-                data = new SearchIndexableRaw(context);
-                data.title = res.getString(R.string.fingerprint_manage_category_title);
-                data.key = "security_managed_fingerprint";
-                data.screenTitle = screenTitle;
-                result.add(data);
-            }
-
-            final LockPatternUtils lockPatternUtils = new LockPatternUtils(context);
-            final int profileUserId = Utils.getManagedProfileId(um, MY_USER_ID);
-            if (profileUserId != UserHandle.USER_NULL
-                    && lockPatternUtils.isSeparateProfileChallengeAllowed(profileUserId)) {
-                if (lockPatternUtils.getKeyguardStoredPasswordQuality(profileUserId)
-                        >= DevicePolicyManager.PASSWORD_QUALITY_SOMETHING
-                        && lockPatternUtils.isSeparateProfileChallengeAllowedToUnify(
-                                profileUserId)) {
-                    data = new SearchIndexableRaw(context);
-                    data.title = res.getString(R.string.lock_settings_profile_unification_title);
-                    data.key = "security_use_one_lock";
-                    data.screenTitle = screenTitle;
-                    result.add(data);
+                @Override
+                public List<SearchIndexableResource> getXmlResourcesToIndex(
+                        Context context, boolean enabled) {
+                    final List<SearchIndexableResource> index = new ArrayList<>();
+                    // Append the rest of the settings
+                    final SearchIndexableResource sir = new SearchIndexableResource(context);
+                    sir.xmlResId = R.xml.security_dashboard_settings;
+                    index.add(sir);
+                    return index;
                 }
-            }
-            return result;
-        }
 
-        @Override
-        public List<String> getNonIndexableKeys(Context context) {
-            final List<String> keys = super.getNonIndexableKeys(context);
-
-            LockPatternUtils lockPatternUtils = new LockPatternUtils(context);
-
-            // Do not display SIM lock for devices without an Icc card
-            final UserManager um = UserManager.get(context);
-            final TelephonyManager tm = TelephonyManager.from(context);
-            if (!um.isAdminUser() || !tm.hasIccCard()) {
-                keys.add(KEY_SIM_LOCK);
-            }
-
-            // TrustAgent settings disappear when the user has no primary security.
-            if (!lockPatternUtils.isSecure(MY_USER_ID)) {
-                keys.add(KEY_TRUST_AGENT);
-                keys.add(KEY_MANAGE_TRUST_AGENTS);
-            }
-
-            if (!(new EnterprisePrivacyPreferenceController(context))
-                    .isAvailable()) {
-                keys.add(KEY_ENTERPRISE_PRIVACY);
-            }
-
-            // Duplicate in special app access
-            keys.add(KEY_MANAGE_DEVICE_ADMIN);
-            // Duplicates between parent-child
-            keys.add(KEY_LOCATION);
-            keys.add(KEY_ENCRYPTION_AND_CREDENTIALS);
-            keys.add(KEY_SCREEN_PINNING);
-            keys.add(KEY_LOCATION_SCANNING);
-
-            return keys;
-        }
-    }
-
-    public static class UnificationConfirmationDialog extends InstrumentedDialogFragment {
-        private static final String EXTRA_COMPLIANT = "compliant";
-
-        public static UnificationConfirmationDialog newIntance(boolean compliant) {
-            UnificationConfirmationDialog dialog = new UnificationConfirmationDialog();
-            Bundle args = new Bundle();
-            args.putBoolean(EXTRA_COMPLIANT, compliant);
-            dialog.setArguments(args);
-            return dialog;
-        }
-
-        @Override
-        public void show(FragmentManager manager, String tag) {
-            if (manager.findFragmentByTag(tag) == null) {
-                // Prevent opening multiple dialogs if tapped on button quickly
-                super.show(manager, tag);
-            }
-        }
-
-        @Override
-        public Dialog onCreateDialog(Bundle savedInstanceState) {
-            final SecuritySettings parentFragment = ((SecuritySettings) getParentFragment());
-            final boolean compliant = getArguments().getBoolean(EXTRA_COMPLIANT);
-            return new AlertDialog.Builder(getActivity())
-                    .setTitle(R.string.lock_settings_profile_unification_dialog_title)
-                    .setMessage(compliant ? R.string.lock_settings_profile_unification_dialog_body
-                            : R.string.lock_settings_profile_unification_dialog_uncompliant_body)
-                    .setPositiveButton(
-                            compliant ? R.string.lock_settings_profile_unification_dialog_confirm
-                            : R.string.lock_settings_profile_unification_dialog_uncompliant_confirm,
-                            (dialog, whichButton) -> {
-                                if (compliant) {
-                                    parentFragment.launchConfirmDeviceLockForUnification();
-                                }    else {
-                                    parentFragment.unifyUncompliantLocks();
-                                }
-                            }
-                    )
-                    .setNegativeButton(R.string.cancel, null)
-                    .create();
-        }
-
-        @Override
-        public void onDismiss(DialogInterface dialog) {
-            super.onDismiss(dialog);
-            ((SecuritySettings) getParentFragment()).updateUnificationPreference();
-        }
-
-        @Override
-        public int getMetricsCategory() {
-            return MetricsEvent.DIALOG_UNIFICATION_CONFIRMATION;
-        }
-    }
+                @Override
+                public List<AbstractPreferenceController> getPreferenceControllers(Context
+                        context) {
+                    return buildPreferenceControllers(context, null /* lifecycle */,
+                            null /* host*/);
+                }
+            };
 
     static class SummaryProvider implements SummaryLoader.SummaryProvider {
 
@@ -973,13 +180,13 @@
         public void setListening(boolean listening) {
             if (listening) {
                 final FingerprintManager fpm =
-                    Utils.getFingerprintManagerOrNull(mContext);
+                        Utils.getFingerprintManagerOrNull(mContext);
                 if (fpm != null && fpm.isHardwareDetected()) {
                     mSummaryLoader.setSummary(this,
-                        mContext.getString(R.string.security_dashboard_summary));
+                            mContext.getString(R.string.security_dashboard_summary));
                 } else {
                     mSummaryLoader.setSummary(this, mContext.getString(
-                        R.string.security_dashboard_summary_no_fingerprint));
+                            R.string.security_dashboard_summary_no_fingerprint));
                 }
             }
         }
@@ -987,11 +194,10 @@
 
     public static final SummaryLoader.SummaryProviderFactory SUMMARY_PROVIDER_FACTORY =
             new SummaryLoader.SummaryProviderFactory() {
-        @Override
-        public SummaryLoader.SummaryProvider createSummaryProvider(Activity activity,
-                SummaryLoader summaryLoader) {
-            return new SummaryProvider(activity, summaryLoader);
-        }
-    };
-
+                @Override
+                public SummaryLoader.SummaryProvider createSummaryProvider(Activity activity,
+                        SummaryLoader summaryLoader) {
+                    return new SummaryProvider(activity, summaryLoader);
+                }
+            };
 }
diff --git a/src/com/android/settings/security/SecuritySettingsV2.java b/src/com/android/settings/security/SecuritySettingsV2.java
deleted file mode 100644
index 323c0f4..0000000
--- a/src/com/android/settings/security/SecuritySettingsV2.java
+++ /dev/null
@@ -1,188 +0,0 @@
-package com.android.settings.security;
-
-import static com.android.settings.security.EncryptionStatusPreferenceController
-        .PREF_KEY_ENCRYPTION_SECURITY_PAGE;
-
-import android.app.Activity;
-import android.content.Context;
-import android.content.Intent;
-import android.hardware.fingerprint.FingerprintManager;
-import android.provider.SearchIndexableResource;
-
-import com.android.internal.logging.nano.MetricsProto;
-import com.android.settings.R;
-import com.android.settings.Utils;
-import com.android.settings.dashboard.DashboardFragment;
-import com.android.settings.dashboard.SummaryLoader;
-import com.android.settings.enterprise.EnterprisePrivacyPreferenceController;
-import com.android.settings.enterprise.ManageDeviceAdminPreferenceController;
-import com.android.settings.fingerprint.FingerprintProfileStatusPreferenceController;
-import com.android.settings.fingerprint.FingerprintStatusPreferenceController;
-import com.android.settings.location.LocationPreferenceController;
-import com.android.settings.search.BaseSearchIndexProvider;
-import com.android.settings.security.screenlock.LockScreenPreferenceController;
-import com.android.settings.security.trustagent.ManageTrustAgentsPreferenceController;
-import com.android.settings.security.trustagent.TrustAgentListPreferenceController;
-import com.android.settings.widget.PreferenceCategoryController;
-import com.android.settingslib.core.AbstractPreferenceController;
-import com.android.settingslib.core.lifecycle.Lifecycle;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class SecuritySettingsV2 extends DashboardFragment {
-
-    private static final String TAG = "SecuritySettingsV2";
-
-    public static final int SET_OR_CHANGE_LOCK_METHOD_REQUEST = 123;
-    public static final int CHANGE_TRUST_AGENT_SETTINGS = 126;
-    public static final int SET_OR_CHANGE_LOCK_METHOD_REQUEST_PROFILE = 127;
-    public static final int UNIFY_LOCK_CONFIRM_DEVICE_REQUEST = 128;
-    public static final int UNIFY_LOCK_CONFIRM_PROFILE_REQUEST = 129;
-    public static final int UNUNIFY_LOCK_CONFIRM_DEVICE_REQUEST = 130;
-
-    @Override
-    public int getMetricsCategory() {
-        return MetricsProto.MetricsEvent.SECURITY;
-    }
-
-    @Override
-    protected int getPreferenceScreenResId() {
-        return R.xml.security_settings_v2;
-    }
-
-    @Override
-    protected String getLogTag() {
-        return TAG;
-    }
-
-    @Override
-    public int getHelpResource() {
-        return R.string.help_url_security;
-    }
-
-    @Override
-    protected List<AbstractPreferenceController> getPreferenceControllers(Context context) {
-        return buildPreferenceControllers(context, getLifecycle(), this /* host*/);
-    }
-
-    /**
-     * see confirmPatternThenDisableAndClear
-     */
-    @Override
-    public void onActivityResult(int requestCode, int resultCode, Intent data) {
-        if (getPreferenceController(TrustAgentListPreferenceController.class)
-                .handleActivityResult(requestCode, resultCode)) {
-            return;
-        }
-        if (getPreferenceController(LockUnificationPreferenceController.class)
-                .handleActivityResult(requestCode, resultCode, data)) {
-            return;
-        }
-        super.onActivityResult(requestCode, resultCode, data);
-    }
-
-    void launchConfirmDeviceLockForUnification() {
-        getPreferenceController(LockUnificationPreferenceController.class)
-                .launchConfirmDeviceLockForUnification();
-    }
-
-    void unifyUncompliantLocks() {
-        getPreferenceController(LockUnificationPreferenceController.class).unifyUncompliantLocks();
-    }
-
-    void updateUnificationPreference() {
-        getPreferenceController(LockUnificationPreferenceController.class).updateState(null);
-    }
-
-    private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
-            Lifecycle lifecycle, SecuritySettingsV2 host) {
-        final List<AbstractPreferenceController> controllers = new ArrayList<>();
-        controllers.add(new LocationPreferenceController(context, lifecycle));
-        controllers.add(new ManageDeviceAdminPreferenceController(context));
-        controllers.add(new EnterprisePrivacyPreferenceController(context));
-        controllers.add(new ManageTrustAgentsPreferenceController(context));
-        controllers.add(new ScreenPinningPreferenceController(context));
-        controllers.add(new SimLockPreferenceController(context));
-        controllers.add(new ShowPasswordPreferenceController(context));
-        controllers.add(new FingerprintStatusPreferenceController(context));
-        controllers.add(new EncryptionStatusPreferenceController(context,
-                PREF_KEY_ENCRYPTION_SECURITY_PAGE));
-        controllers.add(new TrustAgentListPreferenceController(context, host, lifecycle));
-        controllers.add(new LockScreenPreferenceController(context, lifecycle));
-        controllers.add(new ChangeScreenLockPreferenceController(context, host));
-
-        final List<AbstractPreferenceController> profileSecurityControllers = new ArrayList<>();
-        profileSecurityControllers.add(new ChangeProfileScreenLockPreferenceController(
-                context, host));
-        profileSecurityControllers.add(new LockUnificationPreferenceController(context, host));
-        profileSecurityControllers.add(new VisiblePatternProfilePreferenceController(
-                context, lifecycle));
-        profileSecurityControllers.add(new FingerprintProfileStatusPreferenceController(context));
-        controllers.add(new PreferenceCategoryController(context, "security_category_profile",
-                profileSecurityControllers));
-        controllers.addAll(profileSecurityControllers);
-
-        return controllers;
-    }
-
-    /**
-     * For Search. Please keep it in sync when updating "createPreferenceHierarchy()"
-     */
-    public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
-            new BaseSearchIndexProvider() {
-
-                @Override
-                public List<SearchIndexableResource> getXmlResourcesToIndex(
-                        Context context, boolean enabled) {
-                    final List<SearchIndexableResource> index = new ArrayList<>();
-                    // Append the rest of the settings
-                    final SearchIndexableResource sir = new SearchIndexableResource(context);
-                    sir.xmlResId = R.xml.security_settings_v2;
-                    index.add(sir);
-                    return index;
-                }
-
-                @Override
-                public List<AbstractPreferenceController> getPreferenceControllers(Context
-                        context) {
-                    return buildPreferenceControllers(context, null /* lifecycle */,
-                            null /* host*/);
-                }
-            };
-
-    static class SummaryProvider implements SummaryLoader.SummaryProvider {
-
-        private final Context mContext;
-        private final SummaryLoader mSummaryLoader;
-
-        public SummaryProvider(Context context, SummaryLoader summaryLoader) {
-            mContext = context;
-            mSummaryLoader = summaryLoader;
-        }
-
-        @Override
-        public void setListening(boolean listening) {
-            if (listening) {
-                final FingerprintManager fpm =
-                        Utils.getFingerprintManagerOrNull(mContext);
-                if (fpm != null && fpm.isHardwareDetected()) {
-                    mSummaryLoader.setSummary(this,
-                            mContext.getString(R.string.security_dashboard_summary));
-                } else {
-                    mSummaryLoader.setSummary(this, mContext.getString(
-                            R.string.security_dashboard_summary_no_fingerprint));
-                }
-            }
-        }
-    }
-
-    public static final SummaryLoader.SummaryProviderFactory SUMMARY_PROVIDER_FACTORY =
-            new SummaryLoader.SummaryProviderFactory() {
-                @Override
-                public SummaryLoader.SummaryProvider createSummaryProvider(Activity activity,
-                        SummaryLoader summaryLoader) {
-                    return new SummaryProvider(activity, summaryLoader);
-                }
-            };
-}
diff --git a/src/com/android/settings/security/UnificationConfirmationDialog.java b/src/com/android/settings/security/UnificationConfirmationDialog.java
index 482e268..029e64f 100644
--- a/src/com/android/settings/security/UnificationConfirmationDialog.java
+++ b/src/com/android/settings/security/UnificationConfirmationDialog.java
@@ -40,7 +40,7 @@
         return dialog;
     }
 
-    public void show(SecuritySettingsV2 host) {
+    public void show(SecuritySettings host) {
         final FragmentManager manager = host.getChildFragmentManager();
         if (manager.findFragmentByTag(TAG_UNIFICATION_DIALOG) == null) {
             // Prevent opening multiple dialogs if tapped on button quickly
@@ -50,7 +50,7 @@
 
     @Override
     public Dialog onCreateDialog(Bundle savedInstanceState) {
-        final SecuritySettingsV2 parentFragment = ((SecuritySettingsV2) getParentFragment());
+        final SecuritySettings parentFragment = ((SecuritySettings) getParentFragment());
         final boolean compliant = getArguments().getBoolean(EXTRA_COMPLIANT);
         return new AlertDialog.Builder(getActivity())
                 .setTitle(R.string.lock_settings_profile_unification_dialog_title)
@@ -75,7 +75,7 @@
     @Override
     public void onDismiss(DialogInterface dialog) {
         super.onDismiss(dialog);
-        ((SecuritySettingsV2) getParentFragment()).updateUnificationPreference();
+        ((SecuritySettings) getParentFragment()).updateUnificationPreference();
     }
 
     @Override
diff --git a/src/com/android/settings/security/trustagent/TrustAgentListPreferenceController.java b/src/com/android/settings/security/trustagent/TrustAgentListPreferenceController.java
index 0c591ed..ec81aad 100644
--- a/src/com/android/settings/security/trustagent/TrustAgentListPreferenceController.java
+++ b/src/com/android/settings/security/trustagent/TrustAgentListPreferenceController.java
@@ -16,7 +16,7 @@
 
 package com.android.settings.security.trustagent;
 
-import static com.android.settings.security.SecuritySettingsV2.CHANGE_TRUST_AGENT_SETTINGS;
+import static com.android.settings.security.SecuritySettings.CHANGE_TRUST_AGENT_SETTINGS;
 
 import android.app.Activity;
 import android.content.Context;
@@ -35,7 +35,7 @@
 import com.android.settings.overlay.FeatureFactory;
 import com.android.settings.password.ChooseLockSettingsHelper;
 import com.android.settings.security.SecurityFeatureProvider;
-import com.android.settings.security.SecuritySettingsV2;
+import com.android.settings.security.SecuritySettings;
 import com.android.settingslib.RestrictedPreference;
 import com.android.settingslib.core.AbstractPreferenceController;
 import com.android.settingslib.core.lifecycle.Lifecycle;
@@ -59,12 +59,12 @@
 
     private final LockPatternUtils mLockPatternUtils;
     private final TrustAgentManager mTrustAgentManager;
-    private final SecuritySettingsV2 mHost;
+    private final SecuritySettings mHost;
 
     private Intent mTrustAgentClickIntent;
     private PreferenceCategory mSecurityCategory;
 
-    public TrustAgentListPreferenceController(Context context, SecuritySettingsV2 host,
+    public TrustAgentListPreferenceController(Context context, SecuritySettings host,
             Lifecycle lifecycle) {
         super(context);
         final SecurityFeatureProvider provider = FeatureFactory.getFactory(context)
diff --git a/src/com/android/settings/CreateShortcut.java b/src/com/android/settings/shortcut/CreateShortcut.java
similarity index 92%
rename from src/com/android/settings/CreateShortcut.java
rename to src/com/android/settings/shortcut/CreateShortcut.java
index 8bc801b..2bd9b761 100644
--- a/src/com/android/settings/CreateShortcut.java
+++ b/src/com/android/settings/shortcut/CreateShortcut.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.settings;
+package com.android.settings.shortcut;
 
 import android.app.LauncherActivity;
 import android.content.ComponentName;
@@ -28,7 +28,9 @@
 import android.graphics.Bitmap;
 import android.graphics.Bitmap.Config;
 import android.graphics.Canvas;
+import android.graphics.drawable.Drawable;
 import android.graphics.drawable.Icon;
+import android.graphics.drawable.LayerDrawable;
 import android.net.ConnectivityManager;
 import android.os.AsyncTask;
 import android.support.annotation.VisibleForTesting;
@@ -40,6 +42,7 @@
 import android.widget.ListView;
 
 import com.android.internal.logging.nano.MetricsProto;
+import com.android.settings.R;
 import com.android.settings.Settings.TetherSettingsActivity;
 import com.android.settings.overlay.FeatureFactory;
 
@@ -65,7 +68,8 @@
         finish();
     }
 
-    protected Intent createResultIntent(Intent shortcutIntent, ResolveInfo resolveInfo,
+    @VisibleForTesting
+    Intent createResultIntent(Intent shortcutIntent, ResolveInfo resolveInfo,
             CharSequence label) {
         shortcutIntent.setFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
         ShortcutManager sm = getSystemService(ShortcutManager.class);
@@ -94,8 +98,8 @@
 
         if (activityInfo.icon != 0) {
             intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, createIcon(activityInfo.icon,
-                R.layout.shortcut_badge,
-                getResources().getDimensionPixelSize(R.dimen.shortcut_size)));
+                    R.layout.shortcut_badge,
+                    getResources().getDimensionPixelSize(R.dimen.shortcut_size)));
         }
         return intent;
     }
@@ -112,7 +116,11 @@
     private Bitmap createIcon(int resource, int layoutRes, int size) {
         Context context = new ContextThemeWrapper(this, android.R.style.Theme_Material);
         View view = LayoutInflater.from(context).inflate(layoutRes, null);
-        ((ImageView) view.findViewById(android.R.id.icon)).setImageResource(resource);
+        Drawable iconDrawable = getDrawable(resource);
+        if (iconDrawable instanceof LayerDrawable) {
+            iconDrawable = ((LayerDrawable) iconDrawable).getDrawable(1);
+        }
+        ((ImageView) view.findViewById(android.R.id.icon)).setImageDrawable(iconDrawable);
 
         int spec = MeasureSpec.makeMeasureSpec(size, MeasureSpec.EXACTLY);
         view.measure(spec, spec);
diff --git a/src/com/android/settings/deviceinfo/AdditionalSystemUpdatePreferenceController.java b/src/com/android/settings/system/AdditionalSystemUpdatePreferenceController.java
similarity index 88%
rename from src/com/android/settings/deviceinfo/AdditionalSystemUpdatePreferenceController.java
rename to src/com/android/settings/system/AdditionalSystemUpdatePreferenceController.java
index f91ed4e..1fbf835 100644
--- a/src/com/android/settings/deviceinfo/AdditionalSystemUpdatePreferenceController.java
+++ b/src/com/android/settings/system/AdditionalSystemUpdatePreferenceController.java
@@ -13,13 +13,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.android.settings.deviceinfo;
+package com.android.settings.system;
 
 import android.content.Context;
 
 import com.android.settings.core.BasePreferenceController;
-import com.android.settings.core.PreferenceControllerMixin;
-import com.android.settingslib.core.AbstractPreferenceController;
 
 public class AdditionalSystemUpdatePreferenceController extends BasePreferenceController {
 
diff --git a/src/com/android/settings/system/SystemDashboardFragment.java b/src/com/android/settings/system/SystemDashboardFragment.java
index 323a2d4..deabf54 100644
--- a/src/com/android/settings/system/SystemDashboardFragment.java
+++ b/src/com/android/settings/system/SystemDashboardFragment.java
@@ -17,7 +17,6 @@
 
 import android.content.Context;
 import android.os.Bundle;
-import android.os.UserManager;
 import android.provider.SearchIndexableResource;
 import android.support.v7.preference.Preference;
 import android.support.v7.preference.PreferenceGroup;
@@ -27,8 +26,6 @@
 import com.android.settings.R;
 import com.android.settings.backup.BackupSettingsActivityPreferenceController;
 import com.android.settings.dashboard.DashboardFragment;
-import com.android.settings.deviceinfo.AdditionalSystemUpdatePreferenceController;
-import com.android.settings.deviceinfo.SystemUpdatePreferenceController;
 import com.android.settings.gestures.GesturesSettingPreferenceController;
 import com.android.settings.search.BaseSearchIndexProvider;
 import com.android.settings.search.Indexable;
diff --git a/src/com/android/settings/deviceinfo/SystemUpdatePreferenceController.java b/src/com/android/settings/system/SystemUpdatePreferenceController.java
similarity index 73%
rename from src/com/android/settings/deviceinfo/SystemUpdatePreferenceController.java
rename to src/com/android/settings/system/SystemUpdatePreferenceController.java
index 2806275..20f43ef 100644
--- a/src/com/android/settings/deviceinfo/SystemUpdatePreferenceController.java
+++ b/src/com/android/settings/system/SystemUpdatePreferenceController.java
@@ -13,14 +13,17 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.android.settings.deviceinfo;
+package com.android.settings.system;
 
 import static android.content.Context.CARRIER_CONFIG_SERVICE;
+import static android.content.Context.SYSTEM_UPDATE_SERVICE;
 
 import android.content.Context;
 import android.content.Intent;
 import android.os.Build;
+import android.os.Bundle;
 import android.os.PersistableBundle;
+import android.os.SystemUpdateManager;
 import android.os.UserManager;
 import android.support.v7.preference.Preference;
 import android.support.v7.preference.PreferenceScreen;
@@ -39,10 +42,12 @@
     private static final String KEY_SYSTEM_UPDATE_SETTINGS = "system_update_settings";
 
     private final UserManager mUm;
+    private final SystemUpdateManager mUpdateManager;
 
     public SystemUpdatePreferenceController(Context context) {
         super(context, KEY_SYSTEM_UPDATE_SETTINGS);
         mUm = UserManager.get(context);
+        mUpdateManager = (SystemUpdateManager) context.getSystemService(SYSTEM_UPDATE_SERVICE);
     }
 
     @Override
@@ -84,7 +89,27 @@
 
     @Override
     public String getSummary() {
-        return mContext.getString(R.string.about_summary, Build.VERSION.RELEASE);
+        final Bundle updateInfo = mUpdateManager.retrieveSystemUpdateInfo();
+        String summary = mContext.getString(R.string.android_version_summary,
+                Build.VERSION.RELEASE);
+        switch (updateInfo.getInt(SystemUpdateManager.KEY_STATUS)) {
+            case SystemUpdateManager.STATUS_WAITING_DOWNLOAD:
+            case SystemUpdateManager.STATUS_IN_PROGRESS:
+            case SystemUpdateManager.STATUS_WAITING_INSTALL:
+            case SystemUpdateManager.STATUS_WAITING_REBOOT:
+                summary = mContext.getString(R.string.android_version_pending_update_summary);
+                break;
+            case SystemUpdateManager.STATUS_UNKNOWN:
+                Log.d(TAG, "Update statue unknown");
+                // fall through to next branch
+            case SystemUpdateManager.STATUS_IDLE:
+                final String version = updateInfo.getString(SystemUpdateManager.KEY_TITLE);
+                if (!TextUtils.isEmpty(version)) {
+                    summary = mContext.getString(R.string.android_version_summary, version);
+                }
+                break;
+        }
+        return summary;
     }
 
     /**
diff --git a/src/com/android/settings/users/UserCapabilities.java b/src/com/android/settings/users/UserCapabilities.java
index 084a5db..f1bfae9 100644
--- a/src/com/android/settings/users/UserCapabilities.java
+++ b/src/com/android/settings/users/UserCapabilities.java
@@ -34,6 +34,7 @@
     boolean mCanAddGuest;
     boolean mDisallowAddUser;
     boolean mDisallowAddUserSetByAdmin;
+    boolean mDisallowSwitchUser;
     RestrictedLockUtils.EnforcedAdmin mEnforcedAdmin;
 
     private UserCapabilities() {}
@@ -79,6 +80,9 @@
         final boolean canAddUsersWhenLocked = mIsAdmin || Settings.Global.getInt(
                 context.getContentResolver(), Settings.Global.ADD_USERS_WHEN_LOCKED, 0) == 1;
         mCanAddGuest = !mIsGuest && !mDisallowAddUser && canAddUsersWhenLocked;
+
+        UserManager userManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
+        mDisallowSwitchUser = userManager.hasUserRestriction(UserManager.DISALLOW_USER_SWITCH);
     }
 
     public boolean isAdmin() {
@@ -109,6 +113,7 @@
                 ", mCanAddGuest=" + mCanAddGuest +
                 ", mDisallowAddUser=" + mDisallowAddUser +
                 ", mEnforcedAdmin=" + mEnforcedAdmin +
+                ", mDisallowSwitchUser=" + mDisallowSwitchUser +
                 '}';
     }
 }
diff --git a/src/com/android/settings/users/UserSettings.java b/src/com/android/settings/users/UserSettings.java
index a8fab13..edeab23 100644
--- a/src/com/android/settings/users/UserSettings.java
+++ b/src/com/android/settings/users/UserSettings.java
@@ -249,11 +249,14 @@
         mAddUser.useAdminDisabledSummary(false);
         // Determine if add user/profile button should be visible
         if (mUserCaps.mCanAddUser && Utils.isDeviceProvisioned(getActivity())) {
+            mAddUser.setVisible(true);
             mAddUser.setOnPreferenceClickListener(this);
             // change label to only mention user, if restricted profiles are not supported
             if (!mUserCaps.mCanAddRestrictedProfile) {
                 mAddUser.setTitle(R.string.user_add_user_menu);
             }
+        } else {
+            mAddUser.setVisible(false);
         }
         final IntentFilter filter = new IntentFilter(Intent.ACTION_USER_REMOVED);
         filter.addAction(Intent.ACTION_USER_INFO_CHANGED);
@@ -754,8 +757,12 @@
                     synchronized (mUserLock) {
                         if (userType == USER_TYPE_USER) {
                             mHandler.sendEmptyMessage(MESSAGE_UPDATE_LIST);
-                            mHandler.sendMessage(mHandler.obtainMessage(
-                                    MESSAGE_SETUP_USER, user.id, user.serialNumber));
+                            // Skip setting up user which results in user switching when the
+                            // restriction is set.
+                            if (!mUserCaps.mDisallowSwitchUser) {
+                                mHandler.sendMessage(mHandler.obtainMessage(
+                                        MESSAGE_SETUP_USER, user.id, user.serialNumber));
+                            }
                         } else {
                             mHandler.sendMessage(mHandler.obtainMessage(
                                     MESSAGE_CONFIG_USER, user.id, user.serialNumber));
@@ -842,8 +849,12 @@
                 } else {
                     pref.setSummary(R.string.user_summary_not_set_up);
                 }
-                pref.setOnPreferenceClickListener(this);
-                pref.setSelectable(true);
+                // Disallow setting up user which results in user switching when the restriction is
+                // set.
+                if (!mUserCaps.mDisallowSwitchUser) {
+                    pref.setOnPreferenceClickListener(this);
+                    pref.setSelectable(true);
+                }
             } else if (user.isRestricted()) {
                 pref.setSummary(R.string.user_summary_restricted_profile);
             }
@@ -882,8 +893,13 @@
             pref.setTitle(R.string.user_guest);
             pref.setIcon(getEncircledDefaultIcon());
             userPreferences.add(pref);
-            pref.setDisabledByAdmin(
-                    mUserCaps.mDisallowAddUser ? mUserCaps.mEnforcedAdmin : null);
+            if (mUserCaps.mDisallowAddUser) {
+                pref.setDisabledByAdmin(mUserCaps.mEnforcedAdmin);
+            } else if (mUserCaps.mDisallowSwitchUser) {
+                pref.setDisabledByAdmin(RestrictedLockUtils.getDeviceOwner(context));
+            } else {
+                pref.setDisabledByAdmin(null);
+            }
             int finalGuestId = guestId;
             pref.setOnPreferenceClickListener(preference -> {
                 int id = finalGuestId;
diff --git a/src/com/android/settings/widget/EntityHeaderController.java b/src/com/android/settings/widget/EntityHeaderController.java
index 8607211..4ebc369 100644
--- a/src/com/android/settings/widget/EntityHeaderController.java
+++ b/src/com/android/settings/widget/EntityHeaderController.java
@@ -37,7 +37,6 @@
 import android.support.annotation.VisibleForTesting;
 import android.support.v7.widget.RecyclerView;
 import android.text.TextUtils;
-import android.util.FeatureFlagUtils;
 import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
@@ -48,10 +47,8 @@
 import com.android.settings.R;
 import com.android.settings.Utils;
 import com.android.settings.applications.AppInfoBase;
-import com.android.settings.applications.InstalledAppDetails;
 import com.android.settings.applications.LayoutPreference;
 import com.android.settings.applications.appinfo.AppInfoDashboardFragment;
-import com.android.settings.core.FeatureFlags;
 import com.android.settings.overlay.FeatureFactory;
 import com.android.settingslib.applications.ApplicationsState;
 import com.android.settingslib.core.lifecycle.Lifecycle;
@@ -285,17 +282,10 @@
         entityHeaderContent.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
-                if (FeatureFlagUtils.isEnabled(mAppContext, FeatureFlags.APP_INFO_V2)) {
-                    AppInfoBase.startAppInfoFragment(
-                            AppInfoDashboardFragment.class, R.string.application_info_label,
-                            mPackageName, mUid, mFragment, 0 /* request */,
-                            mMetricsCategory);
-                } else {
-                    AppInfoBase.startAppInfoFragment(
-                            InstalledAppDetails.class, R.string.application_info_label,
-                            mPackageName, mUid, mFragment, 0 /* request */,
-                            mMetricsCategory);
-                }
+                AppInfoBase.startAppInfoFragment(
+                    AppInfoDashboardFragment.class, R.string.application_info_label,
+                    mPackageName, mUid, mFragment, 0 /* request */,
+                    mMetricsCategory);
             }
         });
         return;
diff --git a/src/com/android/settings/wifi/SavedAccessPointsWifiSettings.java b/src/com/android/settings/wifi/SavedAccessPointsWifiSettings.java
index 9f52159..3079f8d 100644
--- a/src/com/android/settings/wifi/SavedAccessPointsWifiSettings.java
+++ b/src/com/android/settings/wifi/SavedAccessPointsWifiSettings.java
@@ -161,7 +161,7 @@
         final int accessPointsSize = accessPoints.size();
         for (int i = 0; i < accessPointsSize; ++i) {
             AccessPoint ap = accessPoints.get(i);
-            String key = AccessPointPreference.generatePreferenceKey(ap);
+            String key = ap.getKey();
             LongPressAccessPointPreference preference =
                     (LongPressAccessPointPreference) getCachedPreference(key);
             if (preference == null) {
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index 83d9c18..e32bef4 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -777,7 +777,7 @@
             AccessPoint accessPoint = accessPoints.get(index);
             // Ignore access points that are out of range.
             if (accessPoint.isReachable()) {
-                String key = AccessPointPreference.generatePreferenceKey(accessPoint);
+                String key = accessPoint.getKey();
                 hasAvailableAccessPoints = true;
                 LongPressAccessPointPreference pref =
                         (LongPressAccessPointPreference) getCachedPreference(key);
diff --git a/tests/robotests/assets/grandfather_not_implementing_index_provider b/tests/robotests/assets/grandfather_not_implementing_index_provider
index be910e1..43697bd 100644
--- a/tests/robotests/assets/grandfather_not_implementing_index_provider
+++ b/tests/robotests/assets/grandfather_not_implementing_index_provider
@@ -10,7 +10,6 @@
 com.android.settings.development.qstile.DevelopmentTileConfigFragment
 com.android.settings.deviceinfo.StorageProfileFragment
 com.android.settings.notification.ChannelNotificationSettings
-com.android.settings.notification.ChannelImportanceSettings
 com.android.settings.notification.ChannelGroupNotificationSettings
 com.android.settings.notification.AppNotificationSettings
 com.android.settings.wifi.details.WifiNetworkDetailsFragment
diff --git a/tests/robotests/assets/grandfather_not_implementing_indexable b/tests/robotests/assets/grandfather_not_implementing_indexable
index 9d593a0..ece35fb 100644
--- a/tests/robotests/assets/grandfather_not_implementing_indexable
+++ b/tests/robotests/assets/grandfather_not_implementing_indexable
@@ -43,7 +43,6 @@
 com.android.settings.applications.RunningServices
 com.android.settings.applications.ConfirmConvertToFbe
 com.android.settings.deviceinfo.PublicVolumeSettings
-com.android.settings.applications.InstalledAppDetails
 com.android.settings.accessibility.ToggleAccessibilityServicePreferenceFragment
 com.android.settings.print.PrintServiceSettingsFragment
 com.android.settings.deviceinfo.PrivateVolumeSettings
diff --git a/tests/robotests/assets/grandfather_not_in_search_index_provider_registry b/tests/robotests/assets/grandfather_not_in_search_index_provider_registry
index 6a831b0..666b224 100644
--- a/tests/robotests/assets/grandfather_not_in_search_index_provider_registry
+++ b/tests/robotests/assets/grandfather_not_in_search_index_provider_registry
@@ -1,3 +1,2 @@
 com.android.settings.display.ScreenZoomPreferenceFragmentForSetupWizard
-com.android.settings.search.indexing.FakeSettingsFragment
-com.android.settings.security.SecuritySettings
\ No newline at end of file
+com.android.settings.search.indexing.FakeSettingsFragment
\ No newline at end of file
diff --git a/tests/robotests/src/android/hardware/usb/UsbManagerExtras.java b/tests/robotests/src/android/hardware/usb/UsbManagerExtras.java
new file mode 100644
index 0000000..b9bccd2
--- /dev/null
+++ b/tests/robotests/src/android/hardware/usb/UsbManagerExtras.java
@@ -0,0 +1,110 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.usb;
+
+import android.annotation.SystemService;
+import android.content.Context;
+import android.hardware.usb.gadget.V1_0.GadgetFunction;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.StringJoiner;
+
+/**
+ * Definitions that were added to UsbManager in P.
+ *
+ * Copied partially from frameworks/base/core/java/android/hardware/usb/UsbManager to
+ * fix issues with roboelectric during test.
+ */
+@SystemService(Context.USB_SERVICE)
+public class UsbManagerExtras {
+    public static final long NONE = 0;
+    public static final long MTP = GadgetFunction.MTP;
+    public static final long PTP = GadgetFunction.PTP;
+    public static final long RNDIS = GadgetFunction.RNDIS;
+    public static final long MIDI = GadgetFunction.MIDI;
+    public static final long ACCESSORY = GadgetFunction.ACCESSORY;
+    public static final long AUDIO_SOURCE = GadgetFunction.AUDIO_SOURCE;
+    public static final long ADB = GadgetFunction.ADB;
+
+    private static final long SETTABLE_FUNCTIONS = MTP | PTP | RNDIS | MIDI;
+
+    private static final Map<String, Long> STR_MAP = new HashMap<>();
+
+    static {
+        STR_MAP.put(UsbManager.USB_FUNCTION_MTP, MTP);
+        STR_MAP.put(UsbManager.USB_FUNCTION_PTP, PTP);
+        STR_MAP.put(UsbManager.USB_FUNCTION_RNDIS, RNDIS);
+        STR_MAP.put(UsbManager.USB_FUNCTION_MIDI, MIDI);
+        STR_MAP.put(UsbManager.USB_FUNCTION_ACCESSORY, ACCESSORY);
+        STR_MAP.put(UsbManager.USB_FUNCTION_AUDIO_SOURCE, AUDIO_SOURCE);
+        STR_MAP.put(UsbManager.USB_FUNCTION_ADB, ADB);
+    }
+
+    /**
+     * Returns whether the given functions are valid inputs to UsbManager.
+     * Currently the empty functions or any of MTP, PTP, RNDIS, MIDI are accepted.
+     */
+    public static boolean isSettableFunctions(long functions) {
+        return (~SETTABLE_FUNCTIONS & functions) == 0;
+    }
+
+    /**
+     * Returns the string representation of the given functions.
+     */
+    public static String usbFunctionsToString(long functions) {
+        StringJoiner joiner = new StringJoiner(",");
+        if ((functions | MTP) != 0) {
+            joiner.add(UsbManager.USB_FUNCTION_MTP);
+        }
+        if ((functions | PTP) != 0) {
+            joiner.add(UsbManager.USB_FUNCTION_PTP);
+        }
+        if ((functions | RNDIS) != 0) {
+            joiner.add(UsbManager.USB_FUNCTION_RNDIS);
+        }
+        if ((functions | MIDI) != 0) {
+            joiner.add(UsbManager.USB_FUNCTION_MIDI);
+        }
+        if ((functions | ACCESSORY) != 0) {
+            joiner.add(UsbManager.USB_FUNCTION_ACCESSORY);
+        }
+        if ((functions | AUDIO_SOURCE) != 0) {
+            joiner.add(UsbManager.USB_FUNCTION_AUDIO_SOURCE);
+        }
+        if ((functions | ADB) != 0) {
+            joiner.add(UsbManager.USB_FUNCTION_ADB);
+        }
+        return joiner.toString();
+    }
+
+    /**
+     * Parses a string of usb functions and returns a mask of the same functions.
+     */
+    public static long usbFunctionsFromString(String functions) {
+        if (functions == null) {
+            return 0;
+        }
+        long ret = 0;
+        for (String function : functions.split(",")) {
+            if (STR_MAP.containsKey(function)) {
+                ret |= STR_MAP.get(function);
+            }
+        }
+        return ret;
+    }
+}
diff --git a/tests/robotests/src/android/os/SystemUpdateManager.java b/tests/robotests/src/android/os/SystemUpdateManager.java
new file mode 100644
index 0000000..f81df36
--- /dev/null
+++ b/tests/robotests/src/android/os/SystemUpdateManager.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.os;
+
+/**
+ * Duplicate class for platform SystemUpdateManager to get around Robolectric sdk problem.
+ */
+public class SystemUpdateManager {
+
+    public static final String KEY_STATUS = "status";
+    public static final String KEY_TITLE = "title";
+
+    public static final int STATUS_UNKNOWN = 0;
+    public static final int STATUS_IDLE = 1;
+    public static final int STATUS_WAITING_DOWNLOAD = 2;
+    public static final int STATUS_IN_PROGRESS = 3;
+    public static final int STATUS_WAITING_INSTALL = 4;
+    public static final int STATUS_WAITING_REBOOT = 5;
+
+    public Bundle retrieveSystemUpdateInfo() {
+        return null;
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/MasterClearTest.java b/tests/robotests/src/com/android/settings/MasterClearTest.java
index 776025f..3ba3edb 100644
--- a/tests/robotests/src/com/android/settings/MasterClearTest.java
+++ b/tests/robotests/src/com/android/settings/MasterClearTest.java
@@ -18,11 +18,14 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
+import static org.junit.Assert.assertEquals;
 import static org.mockito.Mockito.any;
 import static org.mockito.Mockito.eq;
 import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 import static org.robolectric.Shadows.shadowOf;
 
@@ -86,6 +89,9 @@
     @Mock
     private Activity mMockActivity;
 
+    @Mock
+    private Intent mMockIntent;
+
     private ShadowActivity mShadowActivity;
     private ShadowAccountManager mShadowAccountManager;
     private Activity mActivity;
@@ -110,7 +116,7 @@
         MockitoAnnotations.initMocks(this);
         mMasterClear = spy(new MasterClear());
         mActivity = Robolectric.setupActivity(Activity.class);
-        mShadowActivity = shadowOf(mActivity);
+        mShadowActivity = shadowOf(mActivity);https://stackoverflow.com/questions/14889951/how-to-verify-a-method-is-called-two-times-with-mockito-verify
         // mShadowAccountManager = shadowOf(AccountManager.get(mActivity));
         mContentView = LayoutInflater.from(mActivity).inflate(R.layout.master_clear, null);
 
@@ -213,38 +219,115 @@
     }
 
     @Test
-    public void testTryShowAccountConfirmation_unsupported() {
-        when(mMasterClear.getActivity()).thenReturn(mActivity);
-        /* Using the default resources, account confirmation shouldn't trigger */
-        assertThat(mMasterClear.tryShowAccountConfirmation()).isFalse();
+    public void testOnActivityResultInternal_invalideRequest() {
+        int invalidRequestCode = -1;
+        doReturn(false).when(mMasterClear).isValidRequestCode(eq(invalidRequestCode));
+
+        mMasterClear.onActivityResultInternal(invalidRequestCode, Activity.RESULT_OK, null);
+
+        verify(mMasterClear, times(1)).isValidRequestCode(eq(invalidRequestCode));
+        verify(mMasterClear, times(0)).establishInitialState();
+        verify(mMasterClear, times(0)).getAccountConfirmationIntent();
+        verify(mMasterClear, times(0)).showFinalConfirmation();
     }
 
     @Test
-    public void testTryShowAccountConfirmation_no_relevant_accounts() {
+    public void testOnActivityResultInternal_resultCanceled() {
+        doReturn(true).when(mMasterClear).isValidRequestCode(eq(MasterClear.KEYGUARD_REQUEST));
+        doNothing().when(mMasterClear).establishInitialState();
+
+        mMasterClear.onActivityResultInternal(
+            MasterClear.KEYGUARD_REQUEST, Activity.RESULT_CANCELED, null);
+
+        verify(mMasterClear, times(1)).isValidRequestCode(eq(MasterClear.KEYGUARD_REQUEST));
+        verify(mMasterClear, times(1)).establishInitialState();
+        verify(mMasterClear, times(0)).getAccountConfirmationIntent();
+        verify(mMasterClear, times(0)).showFinalConfirmation();
+    }
+
+    @Test
+    public void testOnActivityResultInternal_keyguardRequestTriggeringConfirmAccount() {
+        doReturn(true).when(mMasterClear).isValidRequestCode(eq(MasterClear.KEYGUARD_REQUEST));
+        doReturn(mMockIntent).when(mMasterClear).getAccountConfirmationIntent();
+        doNothing().when(mMasterClear).showAccountCredentialConfirmation(eq(mMockIntent));
+
+        mMasterClear.onActivityResultInternal(
+            MasterClear.KEYGUARD_REQUEST, Activity.RESULT_OK, null);
+
+        verify(mMasterClear, times(1)).isValidRequestCode(eq(MasterClear.KEYGUARD_REQUEST));
+        verify(mMasterClear, times(0)).establishInitialState();
+        verify(mMasterClear, times(1)).getAccountConfirmationIntent();
+        verify(mMasterClear, times(1)).showAccountCredentialConfirmation(eq(mMockIntent));
+    }
+
+    @Test
+    public void testOnActivityResultInternal_keyguardRequestTriggeringShowFinal() {
+        doReturn(true).when(mMasterClear).isValidRequestCode(eq(MasterClear.KEYGUARD_REQUEST));
+        doReturn(null).when(mMasterClear).getAccountConfirmationIntent();
+        doNothing().when(mMasterClear).showFinalConfirmation();
+
+        mMasterClear.onActivityResultInternal(
+            MasterClear.KEYGUARD_REQUEST, Activity.RESULT_OK, null);
+
+        verify(mMasterClear, times(1)).isValidRequestCode(eq(MasterClear.KEYGUARD_REQUEST));
+        verify(mMasterClear, times(0)).establishInitialState();
+        verify(mMasterClear, times(1)).getAccountConfirmationIntent();
+        verify(mMasterClear, times(1)).showFinalConfirmation();
+    }
+
+    @Test
+    public void testOnActivityResultInternal_confirmRequestTriggeringShowFinal() {
+        doReturn(true).when(mMasterClear)
+            .isValidRequestCode(eq(MasterClear.CREDENTIAL_CONFIRM_REQUEST));
+        doNothing().when(mMasterClear).showFinalConfirmation();
+
+        mMasterClear.onActivityResultInternal(
+            MasterClear.CREDENTIAL_CONFIRM_REQUEST, Activity.RESULT_OK, null);
+
+        verify(mMasterClear, times(1))
+            .isValidRequestCode(eq(MasterClear.CREDENTIAL_CONFIRM_REQUEST));
+        verify(mMasterClear, times(0)).establishInitialState();
+        verify(mMasterClear, times(0)).getAccountConfirmationIntent();
+        verify(mMasterClear, times(1)).showFinalConfirmation();
+    }
+
+    @Test
+    public void testGetAccountConfirmationIntent_unsupported() {
+        when(mMasterClear.getActivity()).thenReturn(mActivity);
+        /* Using the default resources, account confirmation shouldn't trigger */
+        assertThat(mMasterClear.getAccountConfirmationIntent()).isNull();
+    }
+
+    @Test
+    public void testGetAccountConfirmationIntent_no_relevant_accounts() {
         when(mMasterClear.getActivity()).thenReturn(mMockActivity);
         when(mMockActivity.getString(R.string.account_type)).thenReturn(TEST_ACCOUNT_TYPE);
-        when(mMockActivity.getString(R.string.account_confirmation_package)).thenReturn(TEST_CONFIRMATION_PACKAGE);
-        when(mMockActivity.getString(R.string.account_confirmation_class)).thenReturn(TEST_CONFIRMATION_CLASS);
+        when(mMockActivity.getString(R.string.account_confirmation_package))
+            .thenReturn(TEST_CONFIRMATION_PACKAGE);
+        when(mMockActivity.getString(R.string.account_confirmation_class))
+            .thenReturn(TEST_CONFIRMATION_CLASS);
 
         Account[] accounts = new Account[0];
         when(mMockActivity.getSystemService(Context.ACCOUNT_SERVICE)).thenReturn(mAccountManager);
         when(mAccountManager.getAccountsByType(TEST_ACCOUNT_TYPE)).thenReturn(accounts);
-        assertThat(mMasterClear.tryShowAccountConfirmation()).isFalse();
+        assertThat(mMasterClear.getAccountConfirmationIntent()).isNull();
     }
 
     @Test
-    public void testTryShowAccountConfirmation_unresolved() {
+    public void testGetAccountConfirmationIntent_unresolved() {
         when(mMasterClear.getActivity()).thenReturn(mMockActivity);
         when(mMockActivity.getString(R.string.account_type)).thenReturn(TEST_ACCOUNT_TYPE);
-        when(mMockActivity.getString(R.string.account_confirmation_package)).thenReturn(TEST_CONFIRMATION_PACKAGE);
-        when(mMockActivity.getString(R.string.account_confirmation_class)).thenReturn(TEST_CONFIRMATION_CLASS);
+        when(mMockActivity.getString(R.string.account_confirmation_package))
+            .thenReturn(TEST_CONFIRMATION_PACKAGE);
+        when(mMockActivity.getString(R.string.account_confirmation_class))
+            .thenReturn(TEST_CONFIRMATION_CLASS);
         Account[] accounts = new Account[] { new Account(TEST_ACCOUNT_NAME, TEST_ACCOUNT_TYPE) };
         when(mMockActivity.getSystemService(Context.ACCOUNT_SERVICE)).thenReturn(mAccountManager);
         when(mAccountManager.getAccountsByType(TEST_ACCOUNT_TYPE)).thenReturn(accounts);
         // The package manager should not resolve the confirmation intent targeting the non-existent
         // confirmation package.
         when(mMockActivity.getPackageManager()).thenReturn(mPackageManager);
-        assertThat(mMasterClear.tryShowAccountConfirmation()).isFalse();
+        assertThat(mMasterClear.getAccountConfirmationIntent()).isNull();
     }
 
     @Test
@@ -252,8 +335,10 @@
         when(mMasterClear.getActivity()).thenReturn(mMockActivity);
         // Only try to show account confirmation if the appropriate resource overlays are available.
         when(mMockActivity.getString(R.string.account_type)).thenReturn(TEST_ACCOUNT_TYPE);
-        when(mMockActivity.getString(R.string.account_confirmation_package)).thenReturn(TEST_CONFIRMATION_PACKAGE);
-        when(mMockActivity.getString(R.string.account_confirmation_class)).thenReturn(TEST_CONFIRMATION_CLASS);
+        when(mMockActivity.getString(R.string.account_confirmation_package))
+            .thenReturn(TEST_CONFIRMATION_PACKAGE);
+        when(mMockActivity.getString(R.string.account_confirmation_class))
+            .thenReturn(TEST_CONFIRMATION_CLASS);
         // Add accounts to trigger the search for a resolving intent.
         Account[] accounts = new Account[] { new Account(TEST_ACCOUNT_NAME, TEST_ACCOUNT_TYPE) };
         when(mMockActivity.getSystemService(Context.ACCOUNT_SERVICE)).thenReturn(mAccountManager);
@@ -268,10 +353,18 @@
         resolveInfo.activityInfo = activityInfo;
         when(mPackageManager.resolveActivity(any(), eq(0))).thenReturn(resolveInfo);
 
-        // Finally mock out the startActivityForResultCall
-        doNothing().when(mMasterClear).startActivityForResult(any(), eq(MasterClear.CREDENTIAL_CONFIRM_REQUEST));
+        Intent actualIntent = mMasterClear.getAccountConfirmationIntent();
+        assertEquals(TEST_CONFIRMATION_PACKAGE, actualIntent.getComponent().getPackageName());
+        assertEquals(TEST_CONFIRMATION_CLASS, actualIntent.getComponent().getClassName());
+    }
 
-        assertThat(mMasterClear.tryShowAccountConfirmation()).isTrue();
+    public void testShowAccountCredentialConfirmation() {
+        // Finally mock out the startActivityForResultCall
+        doNothing().when(mMasterClear)
+            .startActivityForResult(eq(mMockIntent), eq(MasterClear.CREDENTIAL_CONFIRM_REQUEST));
+        mMasterClear.showAccountCredentialConfirmation(mMockIntent);
+        verify(mMasterClear, times(1))
+            .startActivityForResult(eq(mMockIntent), eq(MasterClear.CREDENTIAL_CONFIRM_REQUEST));
     }
 
     @Test
diff --git a/tests/robotests/src/com/android/settings/accounts/AccountDashboardFragmentTest.java b/tests/robotests/src/com/android/settings/accounts/AccountDashboardFragmentTest.java
index aeffd20..9371019 100644
--- a/tests/robotests/src/com/android/settings/accounts/AccountDashboardFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/accounts/AccountDashboardFragmentTest.java
@@ -27,11 +27,13 @@
 import android.provider.SearchIndexableResource;
 import android.text.TextUtils;
 
+import com.android.settings.R;
 import com.android.settings.TestConfig;
 import com.android.settings.dashboard.SummaryLoader;
 import com.android.settingslib.accounts.AuthenticatorHelper;
 import com.android.settingslib.drawer.CategoryKey;
 
+import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -41,6 +43,7 @@
 import org.robolectric.annotation.Config;
 import org.robolectric.annotation.Implementation;
 import org.robolectric.annotation.Implements;
+import org.robolectric.annotation.Resetter;
 import org.robolectric.shadows.ShadowApplication;
 
 import java.util.List;
@@ -57,6 +60,11 @@
         mFragment = new AccountDashboardFragment();
     }
 
+    @After
+    public void tearDown() {
+        ShadowAuthenticationHelper.reset();
+    }
+
     @Test
     public void testCategory_isAccount() {
         assertThat(mFragment.getCategoryKey()).isEqualTo(CategoryKey.CATEGORY_ACCOUNT);
@@ -66,7 +74,8 @@
     @Config(shadows = {
             ShadowAuthenticationHelper.class
     })
-    public void updateSummary_shouldDisplayUpTo3AccountTypes() {
+    public void updateSummary_hasAccount_shouldDisplayUpTo3AccountTypes() {
+        ShadowAuthenticationHelper.setHasAccount(true);
         final SummaryLoader loader = mock(SummaryLoader.class);
         final Activity activity = Robolectric.buildActivity(Activity.class).setup().get();
 
@@ -78,6 +87,23 @@
     }
 
     @Test
+    @Config(shadows = {
+            ShadowAuthenticationHelper.class
+    })
+    public void updateSummary_noAccount_shouldDisplayDefaultSummary() {
+        ShadowAuthenticationHelper.setHasAccount(false);
+        final SummaryLoader loader = mock(SummaryLoader.class);
+        final Activity activity = Robolectric.buildActivity(Activity.class).setup().get();
+
+        final SummaryLoader.SummaryProvider provider = mFragment.SUMMARY_PROVIDER_FACTORY
+                .createSummaryProvider(activity, loader);
+        provider.setListening(true);
+
+        verify(loader).setSummary(provider,
+                activity.getString(R.string.account_dashboard_default_summary));
+    }
+
+    @Test
     public void testSearchIndexProvider_shouldIndexResource() {
         final List<SearchIndexableResource> indexRes =
                 AccountDashboardFragment.SEARCH_INDEX_DATA_PROVIDER.getXmlResourcesToIndex(
@@ -94,15 +120,24 @@
         static final String[] TYPES = new String[] {"type1", "type2", "type3", "type4"};
         static final String[] LABELS = new String[] {"LABEL1", "LABEL2",
                 "LABEL3", "LABEL4"};
+        private static boolean sHasAccount = true;
 
         public void __constructor__(Context context, UserHandle userHandle,
                 AuthenticatorHelper.OnAccountsUpdateListener listener) {
+        }
 
+        public static void setHasAccount(boolean hasAccount) {
+            sHasAccount = hasAccount;
+        }
+
+        @Resetter
+        public static void reset() {
+            sHasAccount = true;
         }
 
         @Implementation
         public String[] getEnabledAccountTypes() {
-            return TYPES;
+            return sHasAccount ? TYPES : null;
         }
 
         @Implementation
diff --git a/tests/robotests/src/com/android/settings/applications/InstalledAppDetailsTest.java b/tests/robotests/src/com/android/settings/applications/InstalledAppDetailsTest.java
deleted file mode 100644
index 21e7848..0000000
--- a/tests/robotests/src/com/android/settings/applications/InstalledAppDetailsTest.java
+++ /dev/null
@@ -1,591 +0,0 @@
-/*
- * Copyright (C) 2017 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 static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.ArgumentMatchers.nullable;
-import static org.mockito.Matchers.anyDouble;
-import static org.mockito.Matchers.anyInt;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.app.AlertDialog;
-import android.app.AppOpsManager;
-import android.app.Fragment;
-import android.app.LoaderManager;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager;
-import android.content.res.Resources;
-import android.os.BatteryStats;
-import android.os.Bundle;
-import android.os.UserManager;
-import android.support.v7.preference.Preference;
-import android.support.v7.preference.PreferenceManager;
-import android.support.v7.preference.PreferenceScreen;
-import android.view.View;
-
-import com.android.internal.os.BatterySipper;
-import com.android.internal.os.BatteryStatsHelper;
-import com.android.settings.R;
-import com.android.settings.SettingsActivity;
-import com.android.settings.TestConfig;
-import com.android.settings.applications.instantapps.InstantAppButtonsController;
-import com.android.settings.applications.instantapps.InstantAppButtonsController.ShowDialogDelegate;
-import com.android.settings.fuelgauge.BatteryUtils;
-import com.android.settings.testutils.FakeFeatureFactory;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settings.widget.ActionButtonPreferenceTest;
-import com.android.settings.wrapper.DevicePolicyManagerWrapper;
-import com.android.settingslib.Utils;
-import com.android.settingslib.applications.AppUtils;
-import com.android.settingslib.applications.ApplicationsState.AppEntry;
-import com.android.settingslib.applications.StorageStatsSource.AppStorageStats;
-import com.android.settingslib.applications.instantapps.InstantAppDataProvider;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Answers;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.RuntimeEnvironment;
-import org.robolectric.annotation.Config;
-import org.robolectric.annotation.Implementation;
-import org.robolectric.annotation.Implements;
-import org.robolectric.util.ReflectionHelpers;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-
-
-@RunWith(SettingsRobolectricTestRunner.class)
-@Config(
-        manifest = TestConfig.MANIFEST_PATH,
-        sdk = TestConfig.SDK_VERSION,
-        shadows = InstalledAppDetailsTest.ShadowUtils.class
-)
-public final class InstalledAppDetailsTest {
-
-    private static final String PACKAGE_NAME = "test_package_name";
-    private static final int TARGET_UID = 111;
-    private static final int OTHER_UID = 222;
-    private static final double BATTERY_LEVEL = 60;
-    private static final String BATTERY_LEVEL_STRING = "60%";
-
-    @Mock(answer = Answers.RETURNS_DEEP_STUBS)
-    private Context mContext;
-    @Mock(answer = Answers.RETURNS_DEEP_STUBS)
-    private UserManager mUserManager;
-    @Mock(answer = Answers.RETURNS_DEEP_STUBS)
-    private SettingsActivity mActivity;
-    @Mock
-    private DevicePolicyManagerWrapper mDevicePolicyManager;
-    @Mock
-    private BatterySipper mBatterySipper;
-    @Mock
-    private BatterySipper mOtherBatterySipper;
-    @Mock(answer = Answers.RETURNS_DEEP_STUBS)
-    private BatteryStatsHelper mBatteryStatsHelper;
-    @Mock
-    private BatteryStats.Uid mUid;
-    @Mock
-    private PackageManager mPackageManager;
-    @Mock
-    private BatteryUtils mBatteryUtils;
-    @Mock
-    private LoaderManager mLoaderManager;
-    @Mock
-    private AppOpsManager mAppOpsManager;
-
-    private FakeFeatureFactory mFeatureFactory;
-    private InstalledAppDetails mAppDetail;
-    private Context mShadowContext;
-    private Preference mBatteryPreference;
-
-
-    @Before
-    public void setUp() {
-        MockitoAnnotations.initMocks(this);
-        mFeatureFactory = FakeFeatureFactory.setupForTest();
-        mShadowContext = RuntimeEnvironment.application;
-        mAppDetail = spy(new InstalledAppDetails());
-        mAppDetail.mBatteryUtils = mBatteryUtils;
-
-        mBatteryPreference = new Preference(mShadowContext);
-        mAppDetail.mBatteryPreference = mBatteryPreference;
-        mAppDetail.mActionButtons = ActionButtonPreferenceTest.createMock();
-
-        mBatterySipper.drainType = BatterySipper.DrainType.IDLE;
-        mBatterySipper.uidObj = mUid;
-        doReturn(TARGET_UID).when(mBatterySipper).getUid();
-        doReturn(OTHER_UID).when(mOtherBatterySipper).getUid();
-        doReturn(mActivity).when(mAppDetail).getActivity();
-        doReturn(mShadowContext).when(mAppDetail).getContext();
-        doReturn(mPackageManager).when(mActivity).getPackageManager();
-        doReturn(mAppOpsManager).when(mActivity).getSystemService(Context.APP_OPS_SERVICE);
-
-        // Default to not considering any apps to be instant (individual tests can override this).
-        ReflectionHelpers.setStaticField(AppUtils.class, "sInstantAppDataProvider",
-                (InstantAppDataProvider) (i -> false));
-    }
-
-    @Test
-    public void shouldShowUninstallForAll_installForOneOtherUserOnly_shouldReturnTrue() {
-        when(mDevicePolicyManager.packageHasActiveAdmins(nullable(String.class))).thenReturn(false);
-        when(mUserManager.getUsers().size()).thenReturn(2);
-        ReflectionHelpers.setField(mAppDetail, "mDpm", mDevicePolicyManager);
-        ReflectionHelpers.setField(mAppDetail, "mUserManager", mUserManager);
-        final ApplicationInfo info = new ApplicationInfo();
-        info.enabled = true;
-        final AppEntry appEntry = mock(AppEntry.class);
-        appEntry.info = info;
-        final PackageInfo packageInfo = mock(PackageInfo.class);
-        ReflectionHelpers.setField(mAppDetail, "mPackageInfo", packageInfo);
-
-        assertThat(mAppDetail.shouldShowUninstallForAll(appEntry)).isTrue();
-    }
-
-    @Test
-    public void shouldShowUninstallForAll_installForSelfOnly_shouldReturnFalse() {
-        when(mDevicePolicyManager.packageHasActiveAdmins(nullable(String.class))).thenReturn(false);
-        when(mUserManager.getUsers().size()).thenReturn(2);
-        ReflectionHelpers.setField(mAppDetail, "mDpm", mDevicePolicyManager);
-        ReflectionHelpers.setField(mAppDetail, "mUserManager", mUserManager);
-        final ApplicationInfo info = new ApplicationInfo();
-        info.flags = ApplicationInfo.FLAG_INSTALLED;
-        info.enabled = true;
-        final AppEntry appEntry = mock(AppEntry.class);
-        appEntry.info = info;
-        final PackageInfo packageInfo = mock(PackageInfo.class);
-        ReflectionHelpers.setField(mAppDetail, "mPackageInfo", packageInfo);
-
-        assertThat(mAppDetail.shouldShowUninstallForAll(appEntry)).isFalse();
-    }
-
-    @Test
-    public void getStorageSummary_shouldWorkForExternal() {
-        Context context = RuntimeEnvironment.application.getApplicationContext();
-        AppStorageStats stats = mock(AppStorageStats.class);
-        when(stats.getTotalBytes()).thenReturn(1L);
-
-        assertThat(InstalledAppDetails.getStorageSummary(context, stats, true))
-                .isEqualTo("1 B used in external storage");
-    }
-
-    @Test
-    public void getStorageSummary_shouldWorkForInternal() {
-        Context context = RuntimeEnvironment.application.getApplicationContext();
-        AppStorageStats stats = mock(AppStorageStats.class);
-        when(stats.getTotalBytes()).thenReturn(1L);
-
-        assertThat(InstalledAppDetails.getStorageSummary(context, stats, false))
-                .isEqualTo("1 B used in internal storage");
-    }
-
-    @Test
-    public void launchFragment_hasNoPackageInfo_shouldFinish() {
-        ReflectionHelpers.setField(mAppDetail, "mPackageInfo", null);
-
-        assertThat(mAppDetail.ensurePackageInfoAvailable(mActivity)).isFalse();
-        verify(mActivity).finishAndRemoveTask();
-    }
-
-    @Test
-    public void launchFragment_hasPackageInfo_shouldReturnTrue() {
-        final PackageInfo packageInfo = mock(PackageInfo.class);
-        ReflectionHelpers.setField(mAppDetail, "mPackageInfo", packageInfo);
-
-        assertThat(mAppDetail.ensurePackageInfoAvailable(mActivity)).isTrue();
-        verify(mActivity, never()).finishAndRemoveTask();
-    }
-
-    @Test
-    public void packageSizeChange_isOtherPackage_shouldNotRefreshUi() {
-        ReflectionHelpers.setField(mAppDetail, "mPackageName", PACKAGE_NAME);
-        mAppDetail.onPackageSizeChanged("Not_" + PACKAGE_NAME);
-
-        verify(mAppDetail, never()).refreshUi();
-    }
-
-    @Test
-    public void packageSizeChange_isOwnPackage_shouldRefreshUi() {
-        doReturn(Boolean.TRUE).when(mAppDetail).refreshUi();
-        ReflectionHelpers.setField(mAppDetail, "mPackageName", PACKAGE_NAME);
-
-        mAppDetail.onPackageSizeChanged(PACKAGE_NAME);
-
-        verify(mAppDetail).refreshUi();
-    }
-
-    @Test
-    public void launchPowerUsageDetailFragment_shouldNotCrash() {
-        mAppDetail.mBatteryPreference = mBatteryPreference;
-        mAppDetail.mSipper = mBatterySipper;
-        mAppDetail.mBatteryHelper = mBatteryStatsHelper;
-
-        // Should not crash
-        mAppDetail.onPreferenceClick(mBatteryPreference);
-    }
-
-    // Tests that we don't show the "uninstall for all users" button for instant apps.
-    @Test
-    public void instantApps_noUninstallForAllButton() {
-        // Make this app appear to be instant.
-        ReflectionHelpers.setStaticField(AppUtils.class, "sInstantAppDataProvider",
-                (InstantAppDataProvider) (i -> true));
-        when(mDevicePolicyManager.packageHasActiveAdmins(nullable(String.class))).thenReturn(false);
-        when(mUserManager.getUsers().size()).thenReturn(2);
-
-        final ApplicationInfo info = new ApplicationInfo();
-        info.enabled = true;
-        final AppEntry appEntry = mock(AppEntry.class);
-        appEntry.info = info;
-        final PackageInfo packageInfo = mock(PackageInfo.class);
-
-        ReflectionHelpers.setField(mAppDetail, "mDpm", mDevicePolicyManager);
-        ReflectionHelpers.setField(mAppDetail, "mUserManager", mUserManager);
-        ReflectionHelpers.setField(mAppDetail, "mPackageInfo", packageInfo);
-
-        assertThat(mAppDetail.shouldShowUninstallForAll(appEntry)).isFalse();
-    }
-
-    // Tests that we don't show the uninstall button for instant apps"
-    @Test
-    public void instantApps_noUninstallButton() {
-        // Make this app appear to be instant.
-        ReflectionHelpers.setStaticField(AppUtils.class, "sInstantAppDataProvider",
-                (InstantAppDataProvider) (i -> true));
-        final ApplicationInfo info = new ApplicationInfo();
-        info.flags = ApplicationInfo.FLAG_INSTALLED;
-        info.enabled = true;
-        final AppEntry appEntry = mock(AppEntry.class);
-        appEntry.info = info;
-        final PackageInfo packageInfo = mock(PackageInfo.class);
-        packageInfo.applicationInfo = info;
-
-        ReflectionHelpers.setField(mAppDetail, "mUserManager", mUserManager);
-        ReflectionHelpers.setField(mAppDetail, "mAppEntry", appEntry);
-        ReflectionHelpers.setField(mAppDetail, "mPackageInfo", packageInfo);
-
-        mAppDetail.initUninstallButtonForUserApp();
-        verify(mAppDetail.mActionButtons).setButton1Visible(false);
-    }
-
-    // Tests that we don't show the force stop button for instant apps (they aren't allowed to run
-    // when they aren't in the foreground).
-    @Test
-    public void instantApps_noForceStop() {
-        // Make this app appear to be instant.
-        ReflectionHelpers.setStaticField(AppUtils.class, "sInstantAppDataProvider",
-                (InstantAppDataProvider) (i -> true));
-        final PackageInfo packageInfo = mock(PackageInfo.class);
-        final AppEntry appEntry = mock(AppEntry.class);
-        final ApplicationInfo info = new ApplicationInfo();
-        appEntry.info = info;
-
-        ReflectionHelpers.setField(mAppDetail, "mDpm", mDevicePolicyManager);
-        ReflectionHelpers.setField(mAppDetail, "mPackageInfo", packageInfo);
-        ReflectionHelpers.setField(mAppDetail, "mAppEntry", appEntry);
-
-        mAppDetail.checkForceStop();
-        verify(mAppDetail.mActionButtons).setButton2Visible(false);
-    }
-
-    @Test
-    public void instantApps_buttonControllerHandlesDialog() {
-        InstantAppButtonsController mockController = mock(InstantAppButtonsController.class);
-        ReflectionHelpers.setField(
-                mAppDetail, "mInstantAppButtonsController", mockController);
-        // Make sure first that button controller is not called for supported dialog id
-        AlertDialog mockDialog = mock(AlertDialog.class);
-        when(mockController.createDialog(InstantAppButtonsController.DLG_CLEAR_APP))
-                .thenReturn(mockDialog);
-        assertThat(mAppDetail.createDialog(InstantAppButtonsController.DLG_CLEAR_APP, 0))
-                .isEqualTo(mockDialog);
-        verify(mockController).createDialog(InstantAppButtonsController.DLG_CLEAR_APP);
-    }
-
-    // A helper class for testing the InstantAppButtonsController - it lets us look up the
-    // preference associated with a key for instant app buttons and get back a mock
-    // LayoutPreference (to avoid a null pointer exception).
-    public static class InstalledAppDetailsWithMockInstantButtons extends InstalledAppDetails {
-        @Mock
-        private LayoutPreference mInstantButtons;
-
-        public InstalledAppDetailsWithMockInstantButtons() {
-            super();
-            MockitoAnnotations.initMocks(this);
-        }
-
-        @Override
-        public Preference findPreference(CharSequence key) {
-            if (key == "instant_app_buttons") {
-                return mInstantButtons;
-            }
-            return super.findPreference(key);
-        }
-    }
-
-    @Test
-    public void instantApps_instantSpecificButtons() {
-        // Make this app appear to be instant.
-        ReflectionHelpers.setStaticField(AppUtils.class, "sInstantAppDataProvider",
-                (InstantAppDataProvider) (i -> true));
-        final PackageInfo packageInfo = mock(PackageInfo.class);
-
-        final InstalledAppDetailsWithMockInstantButtons
-                fragment = new InstalledAppDetailsWithMockInstantButtons();
-        ReflectionHelpers.setField(fragment, "mPackageInfo", packageInfo);
-        ReflectionHelpers.setField(fragment, "mApplicationFeatureProvider",
-                mFeatureFactory.applicationFeatureProvider);
-
-        final InstantAppButtonsController buttonsController =
-                mock(InstantAppButtonsController.class);
-        when(buttonsController.setPackageName(nullable(String.class)))
-                .thenReturn(buttonsController);
-        when(mFeatureFactory.applicationFeatureProvider.newInstantAppButtonsController(
-                nullable(Fragment.class), nullable(View.class), nullable(ShowDialogDelegate.class)))
-                .thenReturn(buttonsController);
-
-        fragment.maybeAddInstantAppButtons();
-        verify(buttonsController).setPackageName(nullable(String.class));
-        verify(buttonsController).show();
-    }
-
-    @Test
-    public void instantApps_removeCorrectPref() {
-        PreferenceScreen mockPreferenceScreen = mock(PreferenceScreen.class);
-        PreferenceManager mockPreferenceManager = mock(PreferenceManager.class);
-        AppDomainsPreference mockAppDomainsPref = mock(AppDomainsPreference.class);
-        Preference mockLaunchPreference = mock(Preference.class);
-        PackageInfo mockPackageInfo = mock(PackageInfo.class);
-        PackageManager mockPackageManager = mock(PackageManager.class);
-        ReflectionHelpers.setField(
-                mAppDetail, "mLaunchPreference", mockLaunchPreference);
-        ReflectionHelpers.setField(
-                mAppDetail, "mInstantAppDomainsPreference", mockAppDomainsPref);
-        ReflectionHelpers.setField(
-                mAppDetail, "mPreferenceManager", mockPreferenceManager);
-        ReflectionHelpers.setField(
-                mAppDetail, "mPackageInfo", mockPackageInfo);
-        ReflectionHelpers.setField(
-                mAppDetail, "mPm", mockPackageManager);
-        when(mockPreferenceManager.getPreferenceScreen()).thenReturn(mockPreferenceScreen);
-
-        ReflectionHelpers.setStaticField(AppUtils.class, "sInstantAppDataProvider",
-                (InstantAppDataProvider) (i -> false));
-        mAppDetail.prepareInstantAppPrefs();
-
-        // For the non instant case we remove the app domain pref, and leave the launch pref
-        verify(mockPreferenceScreen).removePreference(mockAppDomainsPref);
-        verify(mockPreferenceScreen, never()).removePreference(mockLaunchPreference);
-
-        // For the instant app case we remove the launch preff, and leave the app domain pref
-        ReflectionHelpers.setStaticField(AppUtils.class, "sInstantAppDataProvider",
-                (InstantAppDataProvider) (i -> true));
-
-        mAppDetail.prepareInstantAppPrefs();
-        verify(mockPreferenceScreen).removePreference(mockLaunchPreference);
-        // Will be 1 still due to above call
-        verify(mockPreferenceScreen, times(1))
-                .removePreference(mockAppDomainsPref);
-    }
-
-    @Test
-    public void onActivityResult_uninstalledUpdates_shouldInvalidateOptionsMenu() {
-        doReturn(true).when(mAppDetail).refreshUi();
-
-        mAppDetail.onActivityResult(InstalledAppDetails.REQUEST_UNINSTALL, 0, mock(Intent.class));
-
-        verify(mActivity).invalidateOptionsMenu();
-    }
-
-    @Test
-    public void findTargetSipper_findCorrectSipper() {
-        List<BatterySipper> usageList = new ArrayList<>();
-        usageList.add(mBatterySipper);
-        usageList.add(mOtherBatterySipper);
-        doReturn(usageList).when(mBatteryStatsHelper).getUsageList();
-
-        assertThat(mAppDetail.findTargetSipper(mBatteryStatsHelper, TARGET_UID)).isEqualTo(
-                mBatterySipper);
-    }
-
-    @Test
-    public void updateBattery_noBatteryStats_summaryNo() {
-        doReturn(mShadowContext.getString(R.string.no_battery_summary)).when(mAppDetail).getString(
-                R.string.no_battery_summary);
-        mAppDetail.updateBattery();
-
-        assertThat(mBatteryPreference.getSummary()).isEqualTo(
-                "No battery use since last full charge");
-    }
-
-    @Test
-    public void updateBattery_hasBatteryStats_summaryPercent() {
-        mAppDetail.mBatteryHelper = mBatteryStatsHelper;
-        mAppDetail.mSipper = mBatterySipper;
-        doReturn(BATTERY_LEVEL).when(mBatteryUtils).calculateBatteryPercent(anyDouble(),
-                anyDouble(), anyDouble(), anyInt());
-        doReturn(mShadowContext.getString(R.string.battery_summary, BATTERY_LEVEL_STRING)).when(
-                mAppDetail).getString(R.string.battery_summary, BATTERY_LEVEL_STRING);
-        doReturn(new ArrayList<>()).when(mBatteryStatsHelper).getUsageList();
-
-        mAppDetail.updateBattery();
-
-        assertThat(mBatteryPreference.getSummary()).isEqualTo("60% use since last full charge");
-    }
-
-    @Test
-    public void isBatteryStatsAvailable_hasBatteryStatsHelperAndSipper_returnTrue() {
-        mAppDetail.mBatteryHelper = mBatteryStatsHelper;
-        mAppDetail.mSipper = mBatterySipper;
-
-        assertThat(mAppDetail.isBatteryStatsAvailable()).isTrue();
-    }
-
-    @Test
-    public void isBatteryStatsAvailable_parametersNull_returnFalse() {
-        assertThat(mAppDetail.isBatteryStatsAvailable()).isFalse();
-    }
-
-    @Test
-    public void handleDisableable_appIsHomeApp_buttonShouldNotWork() {
-        final ApplicationInfo info = new ApplicationInfo();
-        info.packageName = "pkg";
-        info.enabled = true;
-        final AppEntry appEntry = mock(AppEntry.class);
-        appEntry.info = info;
-        final HashSet<String> homePackages = new HashSet<>();
-        homePackages.add(info.packageName);
-
-        ReflectionHelpers.setField(mAppDetail, "mHomePackages", homePackages);
-        ReflectionHelpers.setField(mAppDetail, "mAppEntry", appEntry);
-
-        assertThat(mAppDetail.handleDisableable()).isFalse();
-        verify(mAppDetail.mActionButtons).setButton1Text(R.string.disable_text);
-    }
-
-    @Test
-    public void handleDisableable_appIsEnabled_buttonShouldWork() {
-        final ApplicationInfo info = new ApplicationInfo();
-        info.packageName = "pkg";
-        info.enabled = true;
-        info.enabledSetting = PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
-
-        final AppEntry appEntry = mock(AppEntry.class);
-        appEntry.info = info;
-        when(mFeatureFactory.applicationFeatureProvider.getKeepEnabledPackages()).thenReturn(
-                new HashSet<>());
-
-        ReflectionHelpers.setField(mAppDetail, "mApplicationFeatureProvider",
-                mFeatureFactory.applicationFeatureProvider);
-        ReflectionHelpers.setField(mAppDetail, "mAppEntry", appEntry);
-
-        assertThat(mAppDetail.handleDisableable()).isTrue();
-        verify(mAppDetail.mActionButtons).setButton1Text(R.string.disable_text);
-    }
-
-    @Test
-    @Config(shadows = ShadowUtils.class)
-    public void handleDisableable_appIsDisabled_buttonShouldShowEnable() {
-        final ApplicationInfo info = new ApplicationInfo();
-        info.packageName = "pkg";
-        info.enabled = false;
-        info.enabledSetting = PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
-
-        final AppEntry appEntry = mock(AppEntry.class);
-        appEntry.info = info;
-        when(mFeatureFactory.applicationFeatureProvider.getKeepEnabledPackages()).thenReturn(
-                new HashSet<>());
-
-        ReflectionHelpers.setField(mAppDetail, "mApplicationFeatureProvider",
-                mFeatureFactory.applicationFeatureProvider);
-        ReflectionHelpers.setField(mAppDetail, "mAppEntry", appEntry);
-
-        assertThat(mAppDetail.handleDisableable()).isTrue();
-        verify(mAppDetail.mActionButtons).setButton1Text(R.string.enable_text);
-        verify(mAppDetail.mActionButtons).setButton1Positive(true);
-    }
-
-    @Test
-    public void handleDisableable_appIsEnabledAndInKeepEnabledWhitelist_buttonShouldNotWork() {
-        final ApplicationInfo info = new ApplicationInfo();
-        info.packageName = "pkg";
-        info.enabled = true;
-        info.enabledSetting = PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
-
-        final AppEntry appEntry = mock(AppEntry.class);
-        appEntry.info = info;
-
-        final HashSet<String> packages = new HashSet<>();
-        packages.add(info.packageName);
-        when(mFeatureFactory.applicationFeatureProvider.getKeepEnabledPackages()).thenReturn(
-                packages);
-
-        ReflectionHelpers.setField(mAppDetail, "mApplicationFeatureProvider",
-                mFeatureFactory.applicationFeatureProvider);
-        ReflectionHelpers.setField(mAppDetail, "mAppEntry", appEntry);
-
-        assertThat(mAppDetail.handleDisableable()).isFalse();
-        verify(mAppDetail.mActionButtons).setButton1Text(R.string.disable_text);
-    }
-
-    @Test
-    public void testRestartBatteryStatsLoader() {
-        doReturn(mLoaderManager).when(mAppDetail).getLoaderManager();
-
-        mAppDetail.restartBatteryStatsLoader();
-
-        verify(mLoaderManager).restartLoader(InstalledAppDetails.LOADER_BATTERY, Bundle.EMPTY,
-                mAppDetail.mBatteryCallbacks);
-    }
-
-    @Test
-    public void initUninstallButtonForUserApp_shouldSetNegativeButton() {
-        final ApplicationInfo info = new ApplicationInfo();
-        info.flags = ApplicationInfo.FLAG_INSTALLED;
-        info.enabled = true;
-        final PackageInfo packageInfo = mock(PackageInfo.class);
-        packageInfo.applicationInfo = info;
-        ReflectionHelpers.setField(mAppDetail, "mUserManager", mUserManager);
-        ReflectionHelpers.setField(mAppDetail, "mPackageInfo", packageInfo);
-
-        mAppDetail.initUninstallButtonForUserApp();
-
-        verify(mAppDetail.mActionButtons).setButton1Positive(false);
-    }
-
-    @Implements(Utils.class)
-    public static class ShadowUtils {
-        @Implementation
-        public static boolean isSystemPackage(Resources resources, PackageManager pm,
-                PackageInfo pkg) {
-            return false;
-        }
-    }
-}
diff --git a/tests/robotests/src/com/android/settings/applications/NotificationAppsTest.java b/tests/robotests/src/com/android/settings/applications/NotificationAppsTest.java
deleted file mode 100644
index 11d757f..0000000
--- a/tests/robotests/src/com/android/settings/applications/NotificationAppsTest.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright (C) 2017 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.pm.ApplicationInfo;
-import android.content.pm.UserInfo;
-import android.os.UserManager;
-
-import com.android.settings.R;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settings.TestConfig;
-import com.android.settings.dashboard.SummaryLoader;
-import com.android.settings.notification.NotificationBackend;
-import com.android.settingslib.wrapper.PackageManagerWrapper;
-
-import java.util.List;
-import java.util.ArrayList;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.annotation.Config;
-import org.robolectric.shadows.ShadowApplication;
-import org.robolectric.util.ReflectionHelpers;
-
-import static org.mockito.Matchers.anyInt;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
-public class NotificationAppsTest {
-
-    @Mock
-    private PackageManagerWrapper mPackageManager;
-    @Mock
-    private UserManager mUserManager;
-    @Mock
-    private SummaryLoader mSummaryLoader;
-    @Mock
-    private NotificationBackend mBackend;
-
-    private Context mContext;
-    private NotificationApps.SummaryProvider mSummaryProvider;
-
-    @Before
-    public void setUp() {
-        MockitoAnnotations.initMocks(this);
-        ShadowApplication shadowApplication = ShadowApplication.getInstance();
-        shadowApplication.setSystemService(Context.USER_SERVICE, mUserManager);
-        mContext = shadowApplication.getApplicationContext();
-        mSummaryProvider = spy(new NotificationApps.SummaryProvider(mContext, mSummaryLoader));
-        ReflectionHelpers.setField(mSummaryProvider, "mNotificationBackend", mBackend);
-        ReflectionHelpers.setField(mSummaryProvider, "mPackageManager", mPackageManager);
-    }
-
-    @Test
-    public void setListening_shouldSetSummary() {
-        List<UserInfo> userInfos = new ArrayList<>();
-        userInfos.add(new UserInfo(1, "user1", 0));
-        when(mUserManager.getProfiles(anyInt())).thenReturn(userInfos);
-        List<ApplicationInfo> appInfos = new ArrayList<>();
-        ApplicationInfo info1 = new ApplicationInfo();
-        info1.packageName = "package1";
-        appInfos.add(info1);
-        ApplicationInfo info2 = new ApplicationInfo();
-        info2.packageName = "package2";
-        appInfos.add(info2);
-        when(mPackageManager.getInstalledApplicationsAsUser(anyInt(), anyInt()))
-            .thenReturn(appInfos);
-
-        // no notification off
-        when(mBackend.getNotificationsBanned(anyString(), anyInt())).thenReturn(false);
-        mSummaryProvider.setListening(true);
-        ShadowApplication.runBackgroundTasks();
-        verify(mSummaryLoader).setSummary(mSummaryProvider,
-            mContext.getString(R.string.notification_summary_none));
-
-        // some notification off
-        when(mBackend.getNotificationsBanned(eq("package1"), anyInt())).thenReturn(true);
-        mSummaryProvider.setListening(true);
-        ShadowApplication.runBackgroundTasks();
-        verify(mSummaryLoader).setSummary(mSummaryProvider,
-            mContext.getResources().getQuantityString(R.plurals.notification_summary, 1, 1));
-
-        when(mBackend.getNotificationsBanned(eq("package2"), anyInt())).thenReturn(true);
-        mSummaryProvider.setListening(true);
-        ShadowApplication.runBackgroundTasks();
-        verify(mSummaryLoader).setSummary(mSummaryProvider,
-            mContext.getResources().getQuantityString(R.plurals.notification_summary, 2, 2));
-    }
-
-}
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/AppActionButtonPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/AppActionButtonPreferenceControllerTest.java
index 7d5eb31..70b9cc9 100644
--- a/tests/robotests/src/com/android/settings/applications/appinfo/AppActionButtonPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/AppActionButtonPreferenceControllerTest.java
@@ -18,27 +18,18 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyInt;
-import static org.mockito.ArgumentMatchers.argThat;
-import static org.mockito.ArgumentMatchers.nullable;
 import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
-import android.content.BroadcastReceiver;
 import android.content.Context;
-import android.content.Intent;
 import android.content.pm.ApplicationInfo;
 import android.content.pm.PackageInfo;
 import android.content.pm.PackageManager;
 import android.content.pm.UserInfo;
 import android.content.res.Resources;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.UserHandle;
 import android.os.UserManager;
 import android.support.v7.preference.PreferenceScreen;
 
@@ -120,16 +111,14 @@
     }
 
     @Test
-    public void displayPreference_shouldInitializeForceStopButton() {
+    public void displayPreference_shouldSetButton2Invisible() {
         final PreferenceScreen screen = mock(PreferenceScreen.class);
         final ActionButtonPreference preference = spy(new ActionButtonPreference(mContext));
         when(screen.findPreference(mController.getPreferenceKey())).thenReturn(preference);
 
         mController.displayPreference(screen);
 
-        verify(preference).setButton2Positive(false);
-        verify(preference).setButton2Text(R.string.force_stop);
-        verify(preference).setButton2Enabled(false);
+        verify(preference).setButton2Visible(false);
     }
 
     @Test
@@ -138,14 +127,12 @@
         final ApplicationsState.AppEntry appEntry = mock(ApplicationsState.AppEntry.class);
         final ApplicationInfo info = new ApplicationInfo();
         appEntry.info = info;
-        doNothing().when(mController).checkForceStop(appEntry, packageInfo);
         doNothing().when(mController).initUninstallButtons(appEntry, packageInfo);
         when(mFragment.getAppEntry()).thenReturn(appEntry);
         when(mFragment.getPackageInfo()).thenReturn(packageInfo);
 
         mController.refreshUi();
 
-        verify(mController).checkForceStop(appEntry, packageInfo);
         verify(mController).initUninstallButtons(appEntry, packageInfo);
     }
 
@@ -198,71 +185,6 @@
         assertThat(mController.initUninstallButtonForUserApp()).isFalse();
     }
 
-    // Tests that we don't show the force stop button for instant apps (they aren't allowed to run
-    // when they aren't in the foreground).
-    @Test
-    public void checkForceStop_instantApps_shouldNotShowForceStop() {
-        // Make this app appear to be instant.
-        ReflectionHelpers.setStaticField(AppUtils.class, "sInstantAppDataProvider",
-                (InstantAppDataProvider) (i -> true));
-        final PackageInfo packageInfo = mock(PackageInfo.class);
-        final ApplicationsState.AppEntry appEntry = mock(ApplicationsState.AppEntry.class);
-        final ApplicationInfo info = new ApplicationInfo();
-        appEntry.info = info;
-
-        mController.checkForceStop(appEntry, packageInfo);
-
-        verify(mController.mActionButtons).setButton2Visible(false);
-    }
-
-    @Test
-    public void checkForceStop_hasActiveAdmin_shouldDisableForceStop() {
-        ReflectionHelpers.setStaticField(AppUtils.class, "sInstantAppDataProvider",
-                (InstantAppDataProvider) (i -> false));
-        final String packageName = "Package1";
-        final PackageInfo packageInfo = new PackageInfo();
-        packageInfo.packageName = packageName;
-        final ApplicationsState.AppEntry appEntry = mock(ApplicationsState.AppEntry.class);
-        when(mDevicePolicyManager.packageHasActiveAdmins(packageName)).thenReturn(true);
-
-        mController.checkForceStop(appEntry, packageInfo);
-
-        verify(mController.mActionButtons).setButton2Enabled(false);
-    }
-
-    @Test
-    public void checkForceStop_appRunning_shouldEnableForceStop() {
-        ReflectionHelpers.setStaticField(AppUtils.class, "sInstantAppDataProvider",
-                (InstantAppDataProvider) (i -> false));
-        final PackageInfo packageInfo = mock(PackageInfo.class);
-        final ApplicationsState.AppEntry appEntry = mock(ApplicationsState.AppEntry.class);
-        final ApplicationInfo info = new ApplicationInfo();
-        appEntry.info = info;
-
-        mController.checkForceStop(appEntry, packageInfo);
-
-        verify(mController.mActionButtons).setButton2Enabled(true);
-    }
-
-    @Test
-    public void checkForceStop_appStopped_shouldQueryPackageRestart() {
-        ReflectionHelpers.setStaticField(AppUtils.class, "sInstantAppDataProvider",
-                (InstantAppDataProvider) (i -> false));
-        final PackageInfo packageInfo = mock(PackageInfo.class);
-        final ApplicationsState.AppEntry appEntry = mock(ApplicationsState.AppEntry.class);
-        final ApplicationInfo info = new ApplicationInfo();
-        appEntry.info = info;
-        info.flags = ApplicationInfo.FLAG_STOPPED;
-        info.packageName = "com.android.setting";
-
-        mController.checkForceStop(appEntry, packageInfo);
-
-        verify(mContext).sendOrderedBroadcastAsUser(argThat(intent-> intent != null
-                        && intent.getAction().equals(Intent.ACTION_QUERY_PACKAGE_RESTART)),
-                any(UserHandle.class), nullable(String.class), any(BroadcastReceiver.class),
-                nullable(Handler.class), anyInt(), nullable(String.class), nullable(Bundle.class));
-    }
-
     @Test
     public void handleDisableable_appIsHomeApp_buttonShouldNotWork() {
         final ApplicationInfo info = new ApplicationInfo();
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/AppHeaderViewPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/AppHeaderViewPreferenceControllerTest.java
index ee870b7..7108ef0 100644
--- a/tests/robotests/src/com/android/settings/applications/appinfo/AppHeaderViewPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/AppHeaderViewPreferenceControllerTest.java
@@ -42,7 +42,9 @@
 import com.android.settings.TestConfig;
 import com.android.settings.applications.LayoutPreference;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settingslib.applications.AppUtils;
 import com.android.settingslib.applications.ApplicationsState;
+import com.android.settingslib.applications.instantapps.InstantAppDataProvider;
 import com.android.settingslib.core.lifecycle.Lifecycle;
 
 import org.junit.Before;
@@ -53,6 +55,7 @@
 import org.robolectric.Robolectric;
 import org.robolectric.RuntimeEnvironment;
 import org.robolectric.annotation.Config;
+import org.robolectric.util.ReflectionHelpers;
 
 @RunWith(SettingsRobolectricTestRunner.class)
 @Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@@ -103,7 +106,8 @@
         appEntry.info = info;
         when(mFragment.getAppEntry()).thenReturn(appEntry);
         when(mFragment.getPackageInfo()).thenReturn(packageInfo);
-
+        ReflectionHelpers.setStaticField(AppUtils.class, "sInstantAppDataProvider",
+            (InstantAppDataProvider) (i -> false));
 
         final TextView title = mHeader.findViewById(R.id.entity_header_title);
         final TextView summary = mHeader.findViewById(R.id.entity_header_summary);
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/ForceStopOptionsMenuControllerTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/ForceStopOptionsMenuControllerTest.java
new file mode 100644
index 0000000..4719008
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/ForceStopOptionsMenuControllerTest.java
@@ -0,0 +1,215 @@
+/*
+ * Copyright (C) 2018 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.appinfo;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.argThat;
+import static org.mockito.ArgumentMatchers.nullable;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.UserHandle;
+import android.os.UserManager;
+import android.view.Menu;
+import android.view.MenuItem;
+
+import com.android.settings.R;
+import com.android.settings.SettingsActivity;
+import com.android.settings.TestConfig;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.wrapper.DevicePolicyManagerWrapper;
+import com.android.settingslib.applications.AppUtils;
+import com.android.settingslib.applications.ApplicationsState.AppEntry;
+import com.android.settingslib.applications.instantapps.InstantAppDataProvider;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Answers;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+import org.robolectric.util.ReflectionHelpers;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(
+    manifest = TestConfig.MANIFEST_PATH,
+    sdk = TestConfig.SDK_VERSION
+)
+public final class ForceStopOptionsMenuControllerTest {
+
+    private static final String PACKAGE_NAME = "test_package_name";
+
+    @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+    private UserManager mUserManager;
+    @Mock
+    private SettingsActivity mActivity;
+    @Mock
+    private DevicePolicyManagerWrapper mDevicePolicyManager;
+    @Mock
+    private PackageManager mPackageManager;
+
+    private AppInfoDashboardFragment mFragment;
+    private ForceStopOptionsMenuController mController;
+    private Context mShadowContext;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+        mShadowContext = spy(RuntimeEnvironment.application);
+        mFragment = spy(new AppInfoDashboardFragment());
+        ReflectionHelpers.setField(mFragment, "mDpm", mDevicePolicyManager);
+        ReflectionHelpers.setField(mFragment, "mUserManager", mUserManager);
+        doReturn(mActivity).when(mFragment).getActivity();
+        doReturn(mShadowContext).when(mFragment).getContext();
+        doReturn(mPackageManager).when(mActivity).getPackageManager();
+        when(mShadowContext.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
+        mController = spy(new ForceStopOptionsMenuController(
+            mShadowContext, mFragment, mDevicePolicyManager,
+            null /* metricsFeatureProvider */, null /* lifecycle */));
+
+        // Default to not considering any apps to be instant (individual tests can override this).
+        ReflectionHelpers.setStaticField(AppUtils.class, "sInstantAppDataProvider",
+                (InstantAppDataProvider) (i -> false));
+    }
+
+    @Test
+    public void onCreateOptionsMenu_shouldAddForceStop() {
+        final Menu menu = mock(Menu.class);
+        when(menu.add(anyInt(), anyInt(), anyInt(), anyInt())).thenReturn(mock(MenuItem.class));
+
+        mController.onCreateOptionsMenu(menu, null /* inflater */);
+
+        verify(menu).add(anyInt(), eq(AppInfoDashboardFragment.FORCE_STOP_MENU), anyInt(),
+            eq(R.string.force_stop));
+    }
+
+    @Test
+    public void onPrepareOptionsMenu_shouldUpdateForceStopMenu() {
+        final Menu menu = mock(Menu.class);
+        doNothing().when(mController).updateForceStopMenu(any(), any());
+        doReturn(mock(AppEntry.class)).when(mFragment).getAppEntry();
+        doReturn(mock(PackageInfo.class)).when(mFragment).getPackageInfo();
+
+        mController.onPrepareOptionsMenu(menu);
+
+        verify(mController).updateForceStopMenu(any(), any());
+    }
+
+    @Test
+    public void onOptionsItemSelected_shouldHandleForceStopMenuClick() {
+        doReturn(mock(AppEntry.class)).when(mFragment).getAppEntry();
+        doNothing().when(mController).handleForceStopMenuClick();
+        final MenuItem menu = mock(MenuItem.class);
+        when(menu.getItemId()).thenReturn(AppInfoDashboardFragment.FORCE_STOP_MENU);
+
+        mController.onOptionsItemSelected(menu);
+
+        verify(mController).handleForceStopMenuClick();
+    }
+
+    // Tests that we don't show the force stop button for instant apps (they aren't allowed to run
+    // when they aren't in the foreground).
+    @Test
+    public void updateForceStopMenu_instantApps_shouldNotShowForceStop() {
+        when(mDevicePolicyManager.packageHasActiveAdmins(nullable(String.class))).thenReturn(false);
+        final MenuItem forceStopMenu = mock(MenuItem.class);
+        ReflectionHelpers.setField(mController, "mForceStopMenu", forceStopMenu);
+        // Make this app appear to be instant.
+        ReflectionHelpers.setStaticField(AppUtils.class, "sInstantAppDataProvider",
+            (InstantAppDataProvider) (i -> true));
+        final PackageInfo packageInfo = mock(PackageInfo.class);
+        final AppEntry appEntry = mock(AppEntry.class);
+        final ApplicationInfo info = new ApplicationInfo();
+        appEntry.info = info;
+
+        mController.updateForceStopMenu(appEntry, packageInfo);
+
+        verify(forceStopMenu).setVisible(false);
+    }
+
+    @Test
+    public void updateForceStopMenu_hasActiveAdmin_shouldDisableForceStop() {
+        when(mDevicePolicyManager.packageHasActiveAdmins(nullable(String.class))).thenReturn(false);
+        final MenuItem forceStopMenu = mock(MenuItem.class);
+        ReflectionHelpers.setField(mController, "mForceStopMenu", forceStopMenu);
+        ReflectionHelpers.setStaticField(AppUtils.class, "sInstantAppDataProvider",
+            (InstantAppDataProvider) (i -> false));
+        final String packageName = "Package1";
+        final PackageInfo packageInfo = new PackageInfo();
+        packageInfo.packageName = packageName;
+        final AppEntry appEntry = mock(AppEntry.class);
+        when(mDevicePolicyManager.packageHasActiveAdmins(packageName)).thenReturn(true);
+
+        mController.updateForceStopMenu(appEntry, packageInfo);
+
+        verify(forceStopMenu).setEnabled(false);
+    }
+
+    @Test
+    public void updateForceStopMenu_appRunning_shouldEnableForceStop() {
+        when(mDevicePolicyManager.packageHasActiveAdmins(nullable(String.class))).thenReturn(false);
+        final MenuItem forceStopMenu = mock(MenuItem.class);
+        ReflectionHelpers.setField(mController, "mForceStopMenu", forceStopMenu);
+        ReflectionHelpers.setStaticField(AppUtils.class, "sInstantAppDataProvider",
+            (InstantAppDataProvider) (i -> false));
+        final PackageInfo packageInfo = mock(PackageInfo.class);
+        final AppEntry appEntry = mock(AppEntry.class);
+        final ApplicationInfo info = new ApplicationInfo();
+        appEntry.info = info;
+
+        mController.updateForceStopMenu(appEntry, packageInfo);
+
+        verify(forceStopMenu).setEnabled(true);
+    }
+
+    @Test
+    public void updateForceStopMenu_appStopped_shouldQueryPackageRestart() {
+        when(mDevicePolicyManager.packageHasActiveAdmins(nullable(String.class))).thenReturn(false);
+        ReflectionHelpers.setStaticField(AppUtils.class, "sInstantAppDataProvider",
+            (InstantAppDataProvider) (i -> false));
+        final PackageInfo packageInfo = mock(PackageInfo.class);
+        final AppEntry appEntry = mock(AppEntry.class);
+        final ApplicationInfo info = new ApplicationInfo();
+        appEntry.info = info;
+        info.flags = ApplicationInfo.FLAG_STOPPED;
+        info.packageName = "com.android.setting";
+
+        mController.updateForceStopMenu(appEntry, packageInfo);
+
+        verify(mShadowContext).sendOrderedBroadcastAsUser(argThat(intent-> intent != null
+                && intent.getAction().equals(Intent.ACTION_QUERY_PACKAGE_RESTART)),
+            any(UserHandle.class), nullable(String.class), any(BroadcastReceiver.class),
+            nullable(Handler.class), anyInt(), nullable(String.class), nullable(Bundle.class));
+    }
+
+}
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/ConnectedDeviceGroupControllerTest.java b/tests/robotests/src/com/android/settings/connecteddevice/ConnectedDeviceGroupControllerTest.java
index 78be742..b478c4e 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/ConnectedDeviceGroupControllerTest.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/ConnectedDeviceGroupControllerTest.java
@@ -31,6 +31,7 @@
 
 import com.android.settings.TestConfig;
 import com.android.settings.bluetooth.ConnectedBluetoothDeviceUpdater;
+import com.android.settings.connecteddevice.usb.ConnectedUsbDeviceUpdater;
 import com.android.settings.dashboard.DashboardFragment;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
 import com.android.settingslib.core.lifecycle.Lifecycle;
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/ConnectedUsbDeviceUpdaterTest.java b/tests/robotests/src/com/android/settings/connecteddevice/usb/ConnectedUsbDeviceUpdaterTest.java
similarity index 79%
rename from tests/robotests/src/com/android/settings/connecteddevice/ConnectedUsbDeviceUpdaterTest.java
rename to tests/robotests/src/com/android/settings/connecteddevice/usb/ConnectedUsbDeviceUpdaterTest.java
index 16cd3a7..011d620 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/ConnectedUsbDeviceUpdaterTest.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/usb/ConnectedUsbDeviceUpdaterTest.java
@@ -13,18 +13,20 @@
  * See the License for the specific language governing permissions and
  * limitations under the License
  */
-package com.android.settings.connecteddevice;
+package com.android.settings.connecteddevice.usb;
 
 import static com.google.common.truth.Truth.assertThat;
 
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
 
 import android.content.Context;
 
 import com.android.settings.R;
 import com.android.settings.TestConfig;
-import com.android.settings.deviceinfo.UsbBackend;
+import com.android.settings.connecteddevice.DevicePreferenceCallback;
+import com.android.settings.dashboard.DashboardFragment;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
 
 import org.junit.Before;
@@ -42,6 +44,8 @@
     private ConnectedUsbDeviceUpdater mDeviceUpdater;
 
     @Mock
+    private DashboardFragment mFragment;
+    @Mock
     private UsbConnectionBroadcastReceiver mUsbReceiver;
     @Mock
     private DevicePreferenceCallback mDevicePreferenceCallback;
@@ -53,7 +57,8 @@
         MockitoAnnotations.initMocks(this);
 
         mContext = RuntimeEnvironment.application;
-        mDeviceUpdater = new ConnectedUsbDeviceUpdater(mContext, mDevicePreferenceCallback,
+        when(mFragment.getContext()).thenReturn(mContext);
+        mDeviceUpdater = new ConnectedUsbDeviceUpdater(mFragment, mDevicePreferenceCallback,
                 mUsbBackend);
         mDeviceUpdater.mUsbReceiver = mUsbReceiver;
     }
@@ -70,18 +75,18 @@
 
     @Test
     public void testInitUsbPreference_usbConnected_preferenceAdded() {
-        doReturn(true).when(mUsbReceiver).isConnected();
-
         mDeviceUpdater.initUsbPreference(mContext);
+        mDeviceUpdater.mUsbConnectionListener.onUsbConnectionChanged(true /* connected */,
+                UsbBackend.MODE_DATA_NONE);
 
         verify(mDevicePreferenceCallback).onDeviceAdded(mDeviceUpdater.mUsbPreference);
     }
 
     @Test
     public void testInitUsbPreference_usbDisconnected_preferenceRemoved() {
-        doReturn(false).when(mUsbReceiver).isConnected();
-
         mDeviceUpdater.initUsbPreference(mContext);
+        mDeviceUpdater.mUsbConnectionListener.onUsbConnectionChanged(false /* connected */,
+                UsbBackend.MODE_DATA_NONE);
 
         verify(mDevicePreferenceCallback).onDeviceRemoved(mDeviceUpdater.mUsbPreference);
     }
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/UsbBackendTest.java b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbBackendTest.java
similarity index 81%
rename from tests/robotests/src/com/android/settings/deviceinfo/UsbBackendTest.java
rename to tests/robotests/src/com/android/settings/connecteddevice/usb/UsbBackendTest.java
index ce384a5..40cfd73 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/UsbBackendTest.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbBackendTest.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.settings.deviceinfo;
+package com.android.settings.connecteddevice.usb;
 
 import static org.mockito.Answers.RETURNS_DEEP_STUBS;
 import static org.mockito.Matchers.argThat;
@@ -25,7 +25,9 @@
 import android.content.Context;
 import android.content.pm.PackageManager;
 import android.hardware.usb.UsbManager;
+import android.net.ConnectivityManager;
 
+import com.android.settings.connecteddevice.usb.UsbBackend;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
 import com.android.settings.TestConfig;
 
@@ -46,6 +48,8 @@
     private UsbManager mUsbManager;
     @Mock
     private UsbBackend.UserRestrictionUtil mUserRestrictionUtil;
+    @Mock
+    private ConnectivityManager mConnectivityManager;
 
     @Before
     public void setUp() {
@@ -53,22 +57,13 @@
         when(mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_MIDI))
             .thenReturn(true);
         when((Object)mContext.getSystemService(UsbManager.class)).thenReturn(mUsbManager);
+        when(mContext.getSystemService(Context.CONNECTIVITY_SERVICE))
+                .thenReturn((Object) mConnectivityManager);
     }
 
     @Test
     public void constructor_noUsbPort_shouldNotCrash() {
-        UsbBackend usbBackend = new UsbBackend(mContext, mUserRestrictionUtil);
+        UsbBackend usbBackend = new UsbBackend(mContext, mUserRestrictionUtil, null);
         // Should not crash
     }
-
-    @Test
-    public void getCurrentMode_shouldRegisterReceiverToGetUsbState() {
-        UsbBackend usbBackend = new UsbBackend(mContext, mUserRestrictionUtil);
-
-        usbBackend.getCurrentMode();
-
-        verify(mContext).registerReceiver(eq(null),
-            argThat(intentFilter -> intentFilter != null &&
-                UsbManager.ACTION_USB_STATE.equals(intentFilter.getAction(0))));
-    }
 }
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/UsbConnectionBroadcastReceiverTest.java b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbConnectionBroadcastReceiverTest.java
similarity index 81%
rename from tests/robotests/src/com/android/settings/connecteddevice/UsbConnectionBroadcastReceiverTest.java
rename to tests/robotests/src/com/android/settings/connecteddevice/usb/UsbConnectionBroadcastReceiverTest.java
index 06bd5b7..50b47e0 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/UsbConnectionBroadcastReceiverTest.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbConnectionBroadcastReceiverTest.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License
  */
-package com.android.settings.connecteddevice;
+package com.android.settings.connecteddevice.usb;
 
 import static com.google.common.truth.Truth.assertThat;
 import static com.google.common.truth.Truth.assertWithMessage;
@@ -52,6 +52,8 @@
 
     @Mock
     private UsbConnectionBroadcastReceiver.UsbConnectionListener mListener;
+    @Mock
+    private UsbBackend mUsbBackend;
 
     @Before
     public void setUp() {
@@ -59,27 +61,42 @@
 
         mShadowApplication = ShadowApplication.getInstance();
         mContext = RuntimeEnvironment.application;
-        mReceiver = new UsbConnectionBroadcastReceiver(mContext, mListener);
+        mReceiver = new UsbConnectionBroadcastReceiver(mContext, mListener, mUsbBackend);
     }
 
     @Test
     public void testOnReceive_usbConnected_invokeCallback() {
         final Intent intent = new Intent();
+        intent.setAction(UsbManager.ACTION_USB_STATE);
         intent.putExtra(UsbManager.USB_CONNECTED, true);
 
         mReceiver.onReceive(mContext, intent);
 
-        verify(mListener).onUsbConnectionChanged(true);
+        verify(mListener).onUsbConnectionChanged(true /* connected */, UsbBackend.MODE_DATA_NONE);
     }
 
     @Test
     public void testOnReceive_usbDisconnected_invokeCallback() {
         final Intent intent = new Intent();
+        intent.setAction(UsbManager.ACTION_USB_STATE);
         intent.putExtra(UsbManager.USB_CONNECTED, false);
 
         mReceiver.onReceive(mContext, intent);
 
-        verify(mListener).onUsbConnectionChanged(false);
+        verify(mListener).onUsbConnectionChanged(false /* connected */, UsbBackend.MODE_DATA_NONE);
+    }
+
+    @Test
+    public void testOnReceive_usbConnectedMtpEnabled_invokeCallback() {
+        final Intent intent = new Intent();
+        intent.setAction(UsbManager.ACTION_USB_STATE);
+        intent.putExtra(UsbManager.USB_CONNECTED, true);
+        intent.putExtra(UsbManager.USB_FUNCTION_MTP, true);
+        intent.putExtra(UsbManager.USB_DATA_UNLOCKED, true);
+
+        mReceiver.onReceive(mContext, intent);
+
+        verify(mListener).onUsbConnectionChanged(true /* connected */, UsbBackend.MODE_DATA_MTP);
     }
 
     @Test
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDetailsHeaderControllerTest.java b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDetailsHeaderControllerTest.java
new file mode 100644
index 0000000..e1f9078
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDetailsHeaderControllerTest.java
@@ -0,0 +1,122 @@
+/*
+ * Copyright (C) 2018 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.connecteddevice.usb;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.app.Activity;
+import android.arch.lifecycle.LifecycleOwner;
+import android.content.Context;
+import android.support.v7.preference.PreferenceManager;
+import android.support.v7.preference.PreferenceScreen;
+import android.support.v14.preference.PreferenceFragment;
+
+import com.android.settings.R;
+import com.android.settings.TestConfig;
+import com.android.settings.applications.LayoutPreference;
+import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.testutils.shadow.SettingsShadowResources;
+import com.android.settings.testutils.shadow.ShadowEntityHeaderController;
+import com.android.settings.widget.EntityHeaderController;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Answers;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
+        shadows = {ShadowEntityHeaderController.class, SettingsShadowResources.class})
+public class UsbDetailsHeaderControllerTest {
+
+    private UsbDetailsHeaderController mDetailsHeaderController;
+    private Context mContext;
+    private Lifecycle mLifecycle;
+    private LifecycleOwner mLifecycleOwner;
+    private LayoutPreference mPreference;
+    private PreferenceManager mPreferenceManager;
+    private PreferenceScreen mScreen;
+
+    @Mock
+    private UsbBackend mUsbBackend;
+    @Mock
+    private PreferenceFragment mFragment;
+    @Mock
+    private Activity mActivity;
+    @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+    private EntityHeaderController mHeaderController;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+
+        mContext = RuntimeEnvironment.application;
+        mLifecycleOwner = () -> mLifecycle;
+        mLifecycle = new Lifecycle(mLifecycleOwner);
+        mPreferenceManager = new PreferenceManager(mContext);
+        mScreen = mPreferenceManager.createPreferenceScreen(mContext);
+
+        when(mFragment.getActivity()).thenReturn(mActivity);
+        when(mActivity.getApplicationContext()).thenReturn(mContext);
+        when(mFragment.getContext()).thenReturn(mContext);
+        when(mFragment.getPreferenceManager()).thenReturn(mPreferenceManager);
+        when(mFragment.getPreferenceScreen()).thenReturn(mScreen);
+
+        ShadowEntityHeaderController.setUseMock(mHeaderController);
+        mDetailsHeaderController = new UsbDetailsHeaderController(mContext, mFragment, mUsbBackend);
+        mPreference = new LayoutPreference(mContext, R.layout.settings_entity_header);
+        mPreference.setKey(mDetailsHeaderController.getPreferenceKey());
+        mScreen.addPreference(mPreference);
+    }
+
+    @After
+    public void tearDown() {
+        ShadowEntityHeaderController.reset();
+    }
+
+    @Test
+    public void displayRefresh_charging_shouldSetHeader() {
+        mDetailsHeaderController.displayPreference(mScreen);
+        mDetailsHeaderController.refresh(UsbBackend.MODE_DATA_NONE);
+        verify(mHeaderController).setLabel(mContext.getString(R.string.usb_pref));
+        verify(mHeaderController).setIcon(mContext.getDrawable(R.drawable.ic_usb));
+        verify(mHeaderController).setSummary(
+                mContext.getString(R.string.usb_summary_charging_only));
+        verify(mHeaderController).done(mActivity, true);
+    }
+
+    @Test
+    public void displayRefresh_mtp_shouldSetHeader() {
+        mDetailsHeaderController.displayPreference(mScreen);
+        mDetailsHeaderController.refresh(UsbBackend.MODE_DATA_MTP);
+        verify(mHeaderController).setLabel(mContext.getString(R.string.usb_pref));
+        verify(mHeaderController).setIcon(mContext.getDrawable(R.drawable.ic_usb));
+        verify(mHeaderController).setSummary(
+                mContext.getString(R.string.usb_summary_file_transfers));
+        verify(mHeaderController).done(mActivity, true);
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDetailsProfilesControllerTest.java b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDetailsProfilesControllerTest.java
new file mode 100644
index 0000000..557d836
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDetailsProfilesControllerTest.java
@@ -0,0 +1,238 @@
+/*
+ * Copyright (C) 2018 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.connecteddevice.usb;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.app.Activity;
+import android.content.Context;
+import android.hardware.usb.UsbManager;
+import android.support.v7.preference.PreferenceCategory;
+import android.support.v7.preference.PreferenceManager;
+import android.support.v7.preference.PreferenceScreen;
+import android.support.v14.preference.PreferenceFragment;
+import android.support.v14.preference.SwitchPreference;
+
+import com.android.settings.R;
+import com.android.settings.TestConfig;
+import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.testutils.shadow.SettingsShadowResources;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+
+import com.google.android.collect.Lists;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Answers;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class UsbDetailsProfilesControllerTest {
+
+    private UsbDetailsProfilesController mDetailsProfilesController;
+    private Context mContext;
+    private Lifecycle mLifecycle;
+    private PreferenceCategory mPreference;
+    private PreferenceManager mPreferenceManager;
+    private PreferenceScreen mScreen;
+    private List<String> mOptions;
+
+    @Mock
+    private UsbBackend mUsbBackend;
+    @Mock
+    private PreferenceFragment mFragment;
+    @Mock
+    private Activity mActivity;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+
+        mContext = RuntimeEnvironment.application;
+        mLifecycle = new Lifecycle(() -> mLifecycle);
+        mPreferenceManager = new PreferenceManager(mContext);
+        mScreen = mPreferenceManager.createPreferenceScreen(mContext);
+
+        when(mFragment.getActivity()).thenReturn(mActivity);
+        when(mActivity.getApplicationContext()).thenReturn(mContext);
+        when(mFragment.getContext()).thenReturn(mContext);
+        when(mFragment.getPreferenceManager()).thenReturn(mPreferenceManager);
+        when(mFragment.getPreferenceScreen()).thenReturn(mScreen);
+
+        mOptions = Lists.newArrayList(UsbManager.USB_FUNCTION_MTP, UsbManager.USB_FUNCTION_PTP,
+                UsbManager.USB_FUNCTION_MIDI, UsbDetailsProfilesController.KEY_POWER);
+        mDetailsProfilesController = new UsbDetailsProfilesController(mContext, mFragment,
+                mUsbBackend, mOptions, "usb_options");
+        mPreference = new PreferenceCategory(mContext);
+        mPreference.setKey(mDetailsProfilesController.getPreferenceKey());
+        mScreen.addPreference(mPreference);
+    }
+
+    @Test
+    public void testDisplayRefresh_allAllowed_shouldCreateSwitches() {
+        when(mUsbBackend.isModeSupported(anyInt())).thenReturn(true);
+        when(mUsbBackend.isModeDisallowed(anyInt())).thenReturn(false);
+        when(mUsbBackend.isModeDisallowedBySystem(anyInt())).thenReturn(false);
+
+        mDetailsProfilesController.displayPreference(mScreen);
+        mDetailsProfilesController.refresh(UsbBackend.MODE_DATA_NONE);
+        List<SwitchPreference> switches = getProfileSwitches();
+
+        for (int i = 0; i < switches.size(); i++) {
+            assertThat(switches.get(i).getKey().equals(mOptions.get(i)));
+        }
+    }
+
+    @Test
+    public void testDisplayRefresh_onlyMidiAllowed_shouldCreateOnlyMidiSwitch() {
+        when(mUsbBackend.isModeSupported(anyInt())).thenReturn(true);
+        when(mUsbBackend.isModeDisallowed(anyInt())).thenReturn(false);
+        when(mUsbBackend.isModeDisallowedBySystem(UsbBackend.MODE_DATA_MIDI)).thenReturn(false);
+        when(mUsbBackend.isModeDisallowedBySystem(UsbBackend.MODE_DATA_MTP)).thenReturn(true);
+        when(mUsbBackend.isModeDisallowedBySystem(UsbBackend.MODE_DATA_PTP)).thenReturn(true);
+        when(mUsbBackend.isModeDisallowedBySystem(UsbBackend.MODE_POWER_SOURCE)).thenReturn(true);
+
+        mDetailsProfilesController.displayPreference(mScreen);
+        mDetailsProfilesController.refresh(UsbBackend.MODE_DATA_NONE);
+        List<SwitchPreference> switches = getProfileSwitches();
+        assertThat(switches.size()).isEqualTo(1);
+        assertThat(switches.get(0).getKey()).isEqualTo(UsbManager.USB_FUNCTION_MIDI);
+    }
+
+    @Test
+    public void testDisplayRefresh_mtpEnabled_shouldCheckSwitches() {
+        when(mUsbBackend.isModeSupported(anyInt())).thenReturn(true);
+        when(mUsbBackend.isModeDisallowed(anyInt())).thenReturn(false);
+        when(mUsbBackend.isModeDisallowedBySystem(anyInt())).thenReturn(false);
+
+        mDetailsProfilesController.displayPreference(mScreen);
+        mDetailsProfilesController.refresh(UsbBackend.MODE_DATA_MTP);
+        List<SwitchPreference> switches = getProfileSwitches();
+
+        assertThat(switches.get(0).getKey().equals(UsbManager.USB_FUNCTION_MTP));
+        assertThat(switches.get(0).isChecked());
+    }
+
+    @Test
+    public void testDisplayRefresh_mtpSupplyPowerEnabled_shouldCheckSwitches() {
+        when(mUsbBackend.isModeSupported(anyInt())).thenReturn(true);
+        when(mUsbBackend.isModeDisallowed(anyInt())).thenReturn(false);
+        when(mUsbBackend.isModeDisallowedBySystem(anyInt())).thenReturn(false);
+
+        mDetailsProfilesController.displayPreference(mScreen);
+        mDetailsProfilesController.refresh(UsbBackend.MODE_DATA_MTP | UsbBackend.MODE_POWER_SOURCE);
+        List<SwitchPreference> switches = getProfileSwitches();
+
+        assertThat(switches.get(0).getKey()).isEqualTo(UsbManager.USB_FUNCTION_MTP);
+        assertThat(switches.get(0).isChecked());
+        assertThat(switches.get(3).getKey()).isEqualTo(UsbDetailsProfilesController.KEY_POWER);
+        assertThat(switches.get(3).isChecked());
+    }
+
+    @Test
+    public void testOnClickMtp_noneEnabled_shouldEnableMtp() {
+        when(mUsbBackend.isModeSupported(anyInt())).thenReturn(true);
+        when(mUsbBackend.isModeDisallowed(anyInt())).thenReturn(false);
+        when(mUsbBackend.isModeDisallowedBySystem(anyInt())).thenReturn(false);
+
+        mDetailsProfilesController.displayPreference(mScreen);
+        mDetailsProfilesController.refresh(UsbBackend.MODE_DATA_NONE);
+        List<SwitchPreference> switches = getProfileSwitches();
+        switches.get(0).performClick();
+
+        assertThat(switches.get(0).getKey()).isEqualTo(UsbManager.USB_FUNCTION_MTP);
+        verify(mUsbBackend).setMode(UsbBackend.MODE_DATA_MTP);
+        assertThat(switches.get(0).isChecked());
+    }
+
+    @Test
+    public void testOnClickMtp_supplyingPowerEnabled_shouldEnableBoth() {
+        when(mUsbBackend.isModeSupported(anyInt())).thenReturn(true);
+        when(mUsbBackend.isModeDisallowed(anyInt())).thenReturn(false);
+        when(mUsbBackend.isModeDisallowedBySystem(anyInt())).thenReturn(false);
+
+        mDetailsProfilesController.displayPreference(mScreen);
+        mDetailsProfilesController.refresh(UsbBackend.MODE_POWER_SOURCE);
+        when(mUsbBackend.getCurrentMode()).thenReturn(UsbBackend.MODE_POWER_SOURCE);
+        List<SwitchPreference> switches = getProfileSwitches();
+        switches.get(0).performClick();
+
+        assertThat(switches.get(0).getKey()).isEqualTo(UsbManager.USB_FUNCTION_MTP);
+        verify(mUsbBackend).setMode(UsbBackend.MODE_DATA_MTP | UsbBackend.MODE_POWER_SOURCE);
+        assertThat(switches.get(0).isChecked());
+        assertThat(switches.get(3).getKey()).isEqualTo(UsbDetailsProfilesController.KEY_POWER);
+        assertThat(switches.get(3).isChecked());
+    }
+
+    @Test
+    public void testOnClickMtp_ptpEnabled_shouldEnableMtpOnly() {
+        when(mUsbBackend.isModeSupported(anyInt())).thenReturn(true);
+        when(mUsbBackend.isModeDisallowed(anyInt())).thenReturn(false);
+        when(mUsbBackend.isModeDisallowedBySystem(anyInt())).thenReturn(false);
+
+        mDetailsProfilesController.displayPreference(mScreen);
+        mDetailsProfilesController.refresh(UsbBackend.MODE_DATA_PTP);
+        when(mUsbBackend.getCurrentMode()).thenReturn(UsbBackend.MODE_DATA_PTP);
+        List<SwitchPreference> switches = getProfileSwitches();
+        switches.get(0).performClick();
+
+        assertThat(switches.get(0).getKey()).isEqualTo(UsbManager.USB_FUNCTION_MTP);
+        verify(mUsbBackend).setMode(UsbBackend.MODE_DATA_MTP);
+        assertThat(switches.get(0).isChecked());
+        assertThat(switches.get(1).getKey()).isEqualTo(UsbManager.USB_FUNCTION_PTP);
+        assertThat(!switches.get(1).isChecked());
+    }
+
+    @Test
+    public void testOnClickMtp_mtpEnabled_shouldDisableMtp() {
+        when(mUsbBackend.isModeSupported(anyInt())).thenReturn(true);
+        when(mUsbBackend.isModeDisallowed(anyInt())).thenReturn(false);
+        when(mUsbBackend.isModeDisallowedBySystem(anyInt())).thenReturn(false);
+
+        mDetailsProfilesController.displayPreference(mScreen);
+        mDetailsProfilesController.refresh(UsbBackend.MODE_DATA_MTP);
+        when(mUsbBackend.getCurrentMode()).thenReturn(UsbBackend.MODE_DATA_MTP);
+        List<SwitchPreference> switches = getProfileSwitches();
+        switches.get(0).performClick();
+
+        assertThat(switches.get(0).getKey()).isEqualTo(UsbManager.USB_FUNCTION_MTP);
+        verify(mUsbBackend).setMode(UsbBackend.MODE_DATA_NONE);
+        assertThat(!switches.get(0).isChecked());
+    }
+
+    private List<SwitchPreference> getProfileSwitches() {
+        ArrayList<SwitchPreference> result = new ArrayList<>();
+        for (int i = 0; i < mPreference.getPreferenceCount(); i++) {
+            result.add((SwitchPreference) mPreference.getPreference(i));
+        }
+        return result;
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/UsbModeChooserActivityTest.java b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbModeChooserActivityTest.java
similarity index 96%
rename from tests/robotests/src/com/android/settings/deviceinfo/UsbModeChooserActivityTest.java
rename to tests/robotests/src/com/android/settings/connecteddevice/usb/UsbModeChooserActivityTest.java
index 1817bfb..c02212b 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/UsbModeChooserActivityTest.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbModeChooserActivityTest.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.android.settings.deviceinfo;
+package com.android.settings.connecteddevice.usb;
 
 import static com.google.common.truth.Truth.assertThat;
 import static org.mockito.Matchers.anyInt;
@@ -22,6 +22,7 @@
 
 import android.widget.TextView;
 import com.android.settings.R;
+import com.android.settings.connecteddevice.usb.UsbModeChooserActivity;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
 import com.android.settings.TestConfig;
 import org.junit.Before;
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/UsbModePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbModePreferenceControllerTest.java
similarity index 67%
rename from tests/robotests/src/com/android/settings/connecteddevice/UsbModePreferenceControllerTest.java
rename to tests/robotests/src/com/android/settings/connecteddevice/usb/UsbModePreferenceControllerTest.java
index 7edde6e..d15a57f 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/UsbModePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbModePreferenceControllerTest.java
@@ -1,16 +1,12 @@
-package com.android.settings.connecteddevice;
+package com.android.settings.connecteddevice.usb;
 
 import android.content.Context;
-import android.content.Intent;
-import android.hardware.usb.UsbManager;
 import android.support.v7.preference.Preference;
 import android.support.v7.preference.PreferenceScreen;
 
 import com.android.settings.R;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
 import com.android.settings.TestConfig;
-import com.android.settings.deviceinfo.UsbBackend;
-import com.android.settings.deviceinfo.UsbModeChooserActivity;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -24,6 +20,7 @@
 import static org.mockito.Answers.RETURNS_DEEP_STUBS;
 import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.when;
+import static org.mockito.Mockito.verify;
 
 @RunWith(SettingsRobolectricTestRunner.class)
 @Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@@ -33,6 +30,8 @@
     private UsbBackend mUsbBackend;
     @Mock(answer = RETURNS_DEEP_STUBS)
     private PreferenceScreen mScreen;
+    @Mock
+    private UsbConnectionBroadcastReceiver mUsbConnectionBroadcastReceiver;
 
     private Context mContext;
     private UsbModePreferenceController mController;
@@ -42,61 +41,67 @@
         MockitoAnnotations.initMocks(this);
         mContext = ShadowApplication.getInstance().getApplicationContext();
         mController = new UsbModePreferenceController(mContext, mUsbBackend);
+        mController.mUsbReceiver = mUsbConnectionBroadcastReceiver;
     }
 
     @Test
     public void testGetSummary_chargeDevice() {
-        assertThat(mController.getSummary(UsbModeChooserActivity.DEFAULT_MODES[0]))
+        assertThat(mController.getSummary(0))
                 .isEqualTo(R.string.usb_summary_charging_only);
     }
 
     @Test
     public void testGetSummary_supplyPower() {
-        assertThat(mController.getSummary(UsbModeChooserActivity.DEFAULT_MODES[1]))
+        assertThat(mController.getSummary(UsbBackend.MODE_POWER_SOURCE))
                 .isEqualTo(R.string.usb_summary_power_only);
     }
 
     @Test
     public void testGetSummary_TransferFiles() {
-        assertThat(mController.getSummary(UsbModeChooserActivity.DEFAULT_MODES[2]))
+        assertThat(mController.getSummary(UsbBackend.MODE_DATA_MTP))
                 .isEqualTo(R.string.usb_summary_file_transfers);
     }
 
     @Test
     public void testGetSummary_TransferPhoto() {
-        assertThat(mController.getSummary(UsbModeChooserActivity.DEFAULT_MODES[3]))
+        assertThat(mController.getSummary(UsbBackend.MODE_DATA_PTP))
                 .isEqualTo(R.string.usb_summary_photo_transfers);
     }
 
     @Test
     public void testGetSummary_MIDI() {
-        assertThat(mController.getSummary(UsbModeChooserActivity.DEFAULT_MODES[4]))
+        assertThat(mController.getSummary(UsbBackend.MODE_DATA_MIDI))
                 .isEqualTo(R.string.usb_summary_MIDI);
     }
 
     @Test
+    public void testGetSummary_Tethering() {
+        assertThat(mController.getSummary(UsbBackend.MODE_DATA_TETHER))
+                .isEqualTo(R.string.usb_summary_tether);
+    }
+
+    @Test
     public void testPreferenceSummary_usbDisconnected() {
         final Preference preference = new Preference(mContext);
         preference.setKey("usb_mode");
         preference.setEnabled(true);
+        when(mUsbBackend.getCurrentMode()).thenReturn(UsbBackend.MODE_POWER_SINK);
+        when(mUsbConnectionBroadcastReceiver.isConnected()).thenReturn(false);
         mController.updateState(preference);
+
+        assertThat(preference.getKey()).isEqualTo("usb_mode");
         assertThat(preference.getSummary()).isEqualTo(
                 mContext.getString(R.string.disconnected));
     }
 
     @Test
-    public void testUsbBoradcastReceiver_usbConnected_shouldUpdateSummary() {
+    public void testUsbBroadcastReceiver_usbConnected_shouldUpdateSummary() {
         final Preference preference = new Preference(mContext);
         preference.setKey("usb_mode");
         preference.setEnabled(true);
-        when(mUsbBackend.getCurrentMode()).thenReturn(UsbModeChooserActivity.DEFAULT_MODES[0]);
-        when(mScreen.findPreference("usb_mode")).thenReturn(preference);
-
-        mController.displayPreference(mScreen);
-        mController.onResume();
-        final Intent intent = new Intent(UsbManager.ACTION_USB_STATE);
-        intent.putExtra(UsbManager.USB_CONNECTED, true);
-        mContext.sendStickyBroadcast(intent);
+        when(mUsbBackend.getCurrentMode()).thenReturn(UsbBackend.MODE_POWER_SINK);
+        when(mUsbConnectionBroadcastReceiver.isConnected()).thenReturn(true);
+        mController.updateState(preference);
 
         assertThat(preference.getSummary()).isEqualTo(
                 mContext.getString(R.string.usb_summary_charging_only));
diff --git a/tests/robotests/src/com/android/settings/core/XmlControllerAttributeTest.java b/tests/robotests/src/com/android/settings/core/XmlControllerAttributeTest.java
index e6ca59b..e69b97e 100644
--- a/tests/robotests/src/com/android/settings/core/XmlControllerAttributeTest.java
+++ b/tests/robotests/src/com/android/settings/core/XmlControllerAttributeTest.java
@@ -19,7 +19,6 @@
 import com.android.settings.search.SearchFeatureProviderImpl;
 import com.android.settings.search.XmlParserUtils;
 import com.android.settings.security.SecuritySettings;
-import com.android.settings.security.SecuritySettingsV2;
 import com.android.settings.testutils.FakeFeatureFactory;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
 
@@ -32,7 +31,6 @@
 import org.xmlpull.v1.XmlPullParser;
 
 import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -47,25 +45,13 @@
     // List of classes that are too hard to mock in order to retrieve xml information.
     private final List<Class> illegalClasses = new ArrayList<>(
             Arrays.asList(
-                    SecuritySettings.class,
-                    SecuritySettingsV2.class
+                    SecuritySettings.class
             ));
 
     // List of XML that could be retrieved from the illegalClasses list.
     private final List<Integer> whitelistXml = new ArrayList<>(
             Arrays.asList(
-                    R.xml.security_settings_misc,
-                    R.xml.security_settings_lockscreen_profile,
-                    R.xml.security_settings_lockscreen,
-                    R.xml.security_settings_chooser,
-                    R.xml.security_settings_pattern_profile,
-                    R.xml.security_settings_pin_profile,
-                    R.xml.security_settings_password_profile,
-                    R.xml.security_settings_pattern,
-                    R.xml.security_settings_pin,
-                    R.xml.security_settings_password,
-                    R.xml.security_settings,
-                    R.xml.security_settings_status
+                    R.xml.security_dashboard_settings
             ));
 
     private static final String NO_VALID_CONSTRUCTOR_ERROR =
diff --git a/tests/robotests/src/com/android/settings/dashboard/DashboardAdapterTest.java b/tests/robotests/src/com/android/settings/dashboard/DashboardAdapterTest.java
index f9ef424..2d22e04 100644
--- a/tests/robotests/src/com/android/settings/dashboard/DashboardAdapterTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/DashboardAdapterTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -16,10 +16,8 @@
 package com.android.settings.dashboard;
 
 import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.ArgumentMatchers.anyInt;
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.any;
-import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.reset;
@@ -30,14 +28,14 @@
 import android.app.PendingIntent;
 import android.content.Context;
 import android.content.res.Resources;
-import android.content.res.TypedArray;
+import android.graphics.drawable.Drawable;
 import android.graphics.drawable.Icon;
 import android.service.settings.suggestions.Suggestion;
 import android.support.v7.widget.RecyclerView;
 import android.util.DisplayMetrics;
 import android.view.LayoutInflater;
 import android.view.View;
-import android.widget.RelativeLayout;
+import android.widget.TextView;
 
 import com.android.settings.R;
 import com.android.settings.SettingsActivity;
@@ -47,7 +45,6 @@
 import com.android.settings.testutils.FakeFeatureFactory;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
 import com.android.settings.testutils.shadow.SettingsShadowResources;
-import com.android.settingslib.drawer.DashboardCategory;
 import com.android.settingslib.drawer.Tile;
 
 import org.junit.Before;
@@ -58,6 +55,7 @@
 import org.mockito.MockitoAnnotations;
 import org.robolectric.RuntimeEnvironment;
 import org.robolectric.annotation.Config;
+import org.robolectric.util.ReflectionHelpers;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -81,8 +79,6 @@
     private Resources mResources;
     private FakeFeatureFactory mFactory;
     private DashboardAdapter mDashboardAdapter;
-    private DashboardAdapter.SuggestionAndConditionHeaderHolder mSuggestionHolder;
-    private DashboardData.SuggestionConditionHeaderData mSuggestionHeaderData;
     private List<Condition> mConditionList;
 
     @Before
@@ -98,30 +94,17 @@
         mConditionList = new ArrayList<>();
         mConditionList.add(mCondition);
         when(mCondition.shouldShow()).thenReturn(true);
-        mDashboardAdapter = new DashboardAdapter(mContext, null, mConditionList, null, null);
-        mSuggestionHeaderData = new DashboardData.SuggestionConditionHeaderData(mConditionList, 1);
+        mDashboardAdapter = new DashboardAdapter(mContext, null /* savedInstanceState */,
+            mConditionList, null /* suggestionControllerMixin */, null /* lifecycle */);
         when(mView.getTag()).thenReturn(mCondition);
     }
 
     @Test
-    public void testSuggestionsLogs_nullSuggestionsList_shouldNotCrash() {
-        setupSuggestions(makeSuggestionsV2("pkg1", "pkg2", "pkg3", "pkg4", "pkg5"));
-        mDashboardAdapter.onBindSuggestionConditionHeader(mSuggestionHolder, mSuggestionHeaderData);
-
-        // set suggestions to null
-        final DashboardData prevData = mDashboardAdapter.mDashboardData;
-        mDashboardAdapter.mDashboardData = new DashboardData.Builder(prevData)
-                .setSuggestions(null)
-                .build();
-
-        mSuggestionHolder.itemView.callOnClick();
-        // no crash
-    }
-
-    @Test
     public void testSuggestionDismissed_notOnlySuggestion_updateSuggestionOnly() {
         final DashboardAdapter adapter =
-                spy(new DashboardAdapter(mContext, null, null, null, null));
+            spy(new DashboardAdapter(mContext, null /* savedInstanceState */,
+                null /* conditions */, null /* suggestionControllerMixin */, null /*
+                        lifecycle */));
         final List<Suggestion> suggestions = makeSuggestionsV2("pkg1", "pkg2", "pkg3");
         adapter.setSuggestions(suggestions);
 
@@ -130,18 +113,18 @@
         when(data.getContext()).thenReturn(mContext);
         when(mResources.getDisplayMetrics()).thenReturn(mock(DisplayMetrics.class));
         final View itemView = mock(View.class);
-        when(itemView.findViewById(R.id.data)).thenReturn(data);
-        final DashboardAdapter.SuggestionAndConditionContainerHolder holder =
-                new DashboardAdapter.SuggestionAndConditionContainerHolder(itemView);
+        when(itemView.findViewById(R.id.suggestion_list)).thenReturn(data);
+        when(itemView.findViewById(android.R.id.summary)).thenReturn(mock(TextView.class));
+        final DashboardAdapter.SuggestionContainerHolder holder =
+            new DashboardAdapter.SuggestionContainerHolder(itemView);
 
-        adapter.onBindConditionAndSuggestion(
-                holder, DashboardAdapter.SUGGESTION_CONDITION_HEADER_POSITION);
+        adapter.onBindSuggestion(holder, 0);
 
         final DashboardData dashboardData = adapter.mDashboardData;
         reset(adapter); // clear interactions tracking
 
         final Suggestion suggestionToRemove = suggestions.get(1);
-        adapter.onSuggestionDismissed(suggestionToRemove);
+        adapter.onSuggestionClosed(suggestionToRemove);
 
         assertThat(adapter.mDashboardData).isEqualTo(dashboardData);
         assertThat(suggestions.size()).isEqualTo(2);
@@ -150,25 +133,25 @@
     }
 
     @Test
-    public void testSuggestionDismissed_moreThanTwoSuggestions_defaultMode_shouldNotCrash() {
+    public void testSuggestionDismissed_moreThanTwoSuggestions_shouldNotCrash() {
         final RecyclerView data = new RecyclerView(RuntimeEnvironment.application);
         final View itemView = mock(View.class);
-        when(itemView.findViewById(R.id.data)).thenReturn(data);
-        final DashboardAdapter.SuggestionAndConditionContainerHolder holder =
-                new DashboardAdapter.SuggestionAndConditionContainerHolder(itemView);
+        when(itemView.findViewById(R.id.suggestion_list)).thenReturn(data);
+        when(itemView.findViewById(android.R.id.summary)).thenReturn(mock(TextView.class));
+        final DashboardAdapter.SuggestionContainerHolder holder =
+            new DashboardAdapter.SuggestionContainerHolder(itemView);
         final List<Suggestion> suggestions = makeSuggestionsV2("pkg1", "pkg2", "pkg3", "pkg4");
-        final DashboardAdapter adapter = spy(new DashboardAdapter(mContext, null /*savedInstance */,
-                null /* conditions */,
-                null /* suggestionControllerMixin */, null /* callback */));
+        final DashboardAdapter adapter = spy(new DashboardAdapter(mContext,
+            null /*savedInstance */, null /* conditions */,
+            null /* suggestionControllerMixin */,
+            null /* lifecycle */));
         adapter.setSuggestions(suggestions);
-        adapter.onBindConditionAndSuggestion(
-                holder, DashboardAdapter.SUGGESTION_CONDITION_HEADER_POSITION);
-        // default mode, only displaying 2 suggestions
+        adapter.onBindSuggestion(holder, 0);
 
-        adapter.onSuggestionDismissed(suggestions.get(1));
+        adapter.onSuggestionClosed(suggestions.get(1));
 
         // verify operations that access the lists will not cause ConcurrentModificationException
-        assertThat(holder.data.getAdapter().getItemCount()).isEqualTo(1);
+        assertThat(holder.data.getAdapter().getItemCount()).isEqualTo(3);
         adapter.setSuggestions(suggestions);
         // should not crash
     }
@@ -176,42 +159,25 @@
     @Test
     public void testSuggestionDismissed_onlySuggestion_updateDashboardData() {
         DashboardAdapter adapter =
-                spy(new DashboardAdapter(mContext, null, null, null, null));
+            spy(new DashboardAdapter(mContext, null /* savedInstanceState */,
+                null /* conditions */, null /* suggestionControllerMixin */, null /*
+                        lifecycle */));
         final List<Suggestion> suggestions = makeSuggestionsV2("pkg1");
         adapter.setSuggestions(suggestions);
         final DashboardData dashboardData = adapter.mDashboardData;
         reset(adapter); // clear interactions tracking
 
-        adapter.onSuggestionDismissed(suggestions.get(0));
+        adapter.onSuggestionClosed(suggestions.get(0));
 
         assertThat(adapter.mDashboardData).isNotEqualTo(dashboardData);
         verify(adapter).notifyDashboardDataChanged(any());
     }
 
     @Test
-    public void testSetCategories_iconTinted() {
-        TypedArray mockTypedArray = mock(TypedArray.class);
-        doReturn(mockTypedArray).when(mContext).obtainStyledAttributes(any(int[].class));
-        doReturn(0x89000000).when(mockTypedArray).getColor(anyInt(), anyInt());
-
-        final DashboardCategory category = new DashboardCategory();
-        final Icon mockIcon = mock(Icon.class);
-        final Tile tile = new Tile();
-        tile.isIconTintable = true;
-        tile.icon = mockIcon;
-        category.addTile(tile);
-
-        mDashboardAdapter.setCategory(category);
-
-        verify(mockIcon).setTint(eq(0x89000000));
-    }
-
-    @Test
-    public void testBindConditionAndSuggestion_v2_shouldSetSuggestionAdapterAndNoCrash() {
-        mDashboardAdapter = new DashboardAdapter(mContext, null, null, null, null);
+    public void testBindSuggestion_shouldSetSuggestionAdapterAndNoCrash() {
+        mDashboardAdapter = new DashboardAdapter(mContext, null /* savedInstanceState */,
+            null /* conditions */, null /* suggestionControllerMixin */, null /* lifecycle */);
         final List<Suggestion> suggestions = makeSuggestionsV2("pkg1");
-        final DashboardCategory category = new DashboardCategory();
-        category.addTile(mock(Tile.class));
 
         mDashboardAdapter.setSuggestions(suggestions);
 
@@ -220,17 +186,88 @@
         when(data.getContext()).thenReturn(mContext);
         when(mResources.getDisplayMetrics()).thenReturn(mock(DisplayMetrics.class));
         final View itemView = mock(View.class);
-        when(itemView.findViewById(R.id.data)).thenReturn(data);
-        final DashboardAdapter.SuggestionAndConditionContainerHolder holder =
-                new DashboardAdapter.SuggestionAndConditionContainerHolder(itemView);
+        when(itemView.findViewById(R.id.suggestion_list)).thenReturn(data);
+        when(itemView.findViewById(android.R.id.summary)).thenReturn(mock(TextView.class));
+        final DashboardAdapter.SuggestionContainerHolder holder =
+            new DashboardAdapter.SuggestionContainerHolder(itemView);
 
-        mDashboardAdapter.onBindConditionAndSuggestion(
-                holder, DashboardAdapter.SUGGESTION_CONDITION_HEADER_POSITION);
+        mDashboardAdapter.onBindSuggestion(holder, 0);
 
         verify(data).setAdapter(any(SuggestionAdapter.class));
         // should not crash
     }
 
+    @Test
+    public void testBindSuggestion_shouldSetSummary() {
+        mDashboardAdapter = new DashboardAdapter(mContext, null /* savedInstanceState */,
+            null /* conditions */, null /* suggestionControllerMixin */, null /* lifecycle */);
+        final List<Suggestion> suggestions = makeSuggestionsV2("pkg1");
+
+        mDashboardAdapter.setSuggestions(suggestions);
+
+        final RecyclerView data = mock(RecyclerView.class);
+        when(data.getResources()).thenReturn(mResources);
+        when(data.getContext()).thenReturn(mContext);
+        when(mResources.getDisplayMetrics()).thenReturn(mock(DisplayMetrics.class));
+        final View itemView = mock(View.class);
+        when(itemView.findViewById(R.id.suggestion_list)).thenReturn(data);
+        final TextView summary = mock(TextView.class);
+        when(itemView.findViewById(android.R.id.summary)).thenReturn(summary);
+        final DashboardAdapter.SuggestionContainerHolder holder =
+            new DashboardAdapter.SuggestionContainerHolder(itemView);
+
+        mDashboardAdapter.onBindSuggestion(holder, 0);
+
+        verify(summary).setText("1");
+
+        suggestions.addAll(makeSuggestionsV2("pkg2", "pkg3", "pkg4"));
+        mDashboardAdapter.setSuggestions(suggestions);
+
+        mDashboardAdapter.onBindSuggestion(holder, 0);
+
+        verify(summary).setText("4");
+    }
+
+    @Test
+    public void onBindTile_internalTile_shouldNotUseGenericBackgroundIcon() {
+        final Context context = RuntimeEnvironment.application;
+        final View view = LayoutInflater.from(context).inflate(R.layout.dashboard_tile, null);
+        final DashboardAdapter.DashboardItemHolder holder =
+            new DashboardAdapter.DashboardItemHolder(view);
+        final Tile tile = new Tile();
+        tile.icon = Icon.createWithResource(context, R.drawable.ic_settings);
+        final DashboardAdapter.IconCache iconCache = mock(DashboardAdapter.IconCache.class);
+        when(iconCache.getIcon(tile.icon)).thenReturn(context.getDrawable(R.drawable.ic_settings));
+
+        mDashboardAdapter = new DashboardAdapter(context, null /* savedInstanceState */,
+            null /* conditions */, null /* suggestionControllerMixin */, null /* lifecycle */);
+        ReflectionHelpers.setField(mDashboardAdapter, "mCache", iconCache);
+        mDashboardAdapter.onBindTile(holder, tile);
+
+        verify(iconCache, never()).updateIcon(any(Icon.class), any(Drawable.class));
+    }
+
+    @Test
+    public void onBindTile_externalTile_shouldNotUseGenericBackgroundIcon() {
+        final Context context = RuntimeEnvironment.application;
+        final View view = LayoutInflater.from(context).inflate(R.layout.dashboard_tile, null);
+        final DashboardAdapter.DashboardItemHolder holder =
+            new DashboardAdapter.DashboardItemHolder(view);
+        final Tile tile = new Tile();
+        tile.icon = mock(Icon.class);
+        when(tile.icon.getResPackage()).thenReturn("another.package");
+
+        final DashboardAdapter.IconCache iconCache = mock(DashboardAdapter.IconCache.class);
+        when(iconCache.getIcon(tile.icon)).thenReturn(context.getDrawable(R.drawable.ic_settings));
+
+        mDashboardAdapter = new DashboardAdapter(context, null /* savedInstanceState */,
+            null /* conditions */, null /* suggestionControllerMixin */, null /* lifecycle */);
+        ReflectionHelpers.setField(mDashboardAdapter, "mCache", iconCache);
+        mDashboardAdapter.onBindTile(holder, tile);
+
+        verify(iconCache).updateIcon(eq(tile.icon), any(RoundedHomepageIcon.class));
+    }
+
     private List<Suggestion> makeSuggestionsV2(String... pkgNames) {
         final List<Suggestion> suggestions = new ArrayList<>();
         for (String pkgName : pkgNames) {
@@ -245,8 +282,5 @@
     private void setupSuggestions(List<Suggestion> suggestions) {
         final Context context = RuntimeEnvironment.application;
         mDashboardAdapter.setSuggestions(suggestions);
-        mSuggestionHolder = new DashboardAdapter.SuggestionAndConditionHeaderHolder(
-                LayoutInflater.from(context).inflate(
-                        R.layout.suggestion_condition_header, new RelativeLayout(context), true));
     }
 }
diff --git a/tests/robotests/src/com/android/settings/dashboard/DashboardAdapterV2Test.java b/tests/robotests/src/com/android/settings/dashboard/DashboardAdapterV2Test.java
deleted file mode 100644
index 40150cb..0000000
--- a/tests/robotests/src/com/android/settings/dashboard/DashboardAdapterV2Test.java
+++ /dev/null
@@ -1,286 +0,0 @@
-/*
- * Copyright (C) 2018 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.dashboard;
-
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.reset;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.app.PendingIntent;
-import android.content.Context;
-import android.content.res.Resources;
-import android.graphics.drawable.Drawable;
-import android.graphics.drawable.Icon;
-import android.service.settings.suggestions.Suggestion;
-import android.support.v7.widget.RecyclerView;
-import android.util.DisplayMetrics;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.widget.TextView;
-
-import com.android.settings.R;
-import com.android.settings.SettingsActivity;
-import com.android.settings.TestConfig;
-import com.android.settings.dashboard.conditional.Condition;
-import com.android.settings.dashboard.suggestions.SuggestionAdapterV2;
-import com.android.settings.testutils.FakeFeatureFactory;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settings.testutils.shadow.SettingsShadowResources;
-import com.android.settingslib.drawer.Tile;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Answers;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.RuntimeEnvironment;
-import org.robolectric.annotation.Config;
-import org.robolectric.util.ReflectionHelpers;
-
-import java.util.ArrayList;
-import java.util.List;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH,
-        sdk = TestConfig.SDK_VERSION,
-        shadows = {
-                SettingsShadowResources.class,
-                SettingsShadowResources.SettingsShadowTheme.class,
-        })
-public class DashboardAdapterV2Test {
-
-    @Mock(answer = Answers.RETURNS_DEEP_STUBS)
-    private SettingsActivity mContext;
-    @Mock
-    private View mView;
-    @Mock
-    private Condition mCondition;
-    @Mock
-    private Resources mResources;
-    private FakeFeatureFactory mFactory;
-    private DashboardAdapterV2 mDashboardAdapter;
-    private List<Condition> mConditionList;
-
-    @Before
-    public void setUp() {
-        MockitoAnnotations.initMocks(this);
-        mFactory = FakeFeatureFactory.setupForTest();
-        when(mFactory.dashboardFeatureProvider.shouldTintIcon()).thenReturn(true);
-
-        when(mContext.getResources()).thenReturn(mResources);
-        when(mResources.getQuantityString(any(int.class), any(int.class), any()))
-                .thenReturn("");
-
-        mConditionList = new ArrayList<>();
-        mConditionList.add(mCondition);
-        when(mCondition.shouldShow()).thenReturn(true);
-        mDashboardAdapter = new DashboardAdapterV2(mContext, null /* savedInstanceState */,
-                mConditionList, null /* suggestionControllerMixin */, null /* lifecycle */);
-        when(mView.getTag()).thenReturn(mCondition);
-    }
-
-    @Test
-    public void testSuggestionDismissed_notOnlySuggestion_updateSuggestionOnly() {
-        final DashboardAdapterV2 adapter =
-                spy(new DashboardAdapterV2(mContext, null /* savedInstanceState */,
-                        null /* conditions */, null /* suggestionControllerMixin */, null /*
-                        lifecycle */));
-        final List<Suggestion> suggestions = makeSuggestionsV2("pkg1", "pkg2", "pkg3");
-        adapter.setSuggestions(suggestions);
-
-        final RecyclerView data = mock(RecyclerView.class);
-        when(data.getResources()).thenReturn(mResources);
-        when(data.getContext()).thenReturn(mContext);
-        when(mResources.getDisplayMetrics()).thenReturn(mock(DisplayMetrics.class));
-        final View itemView = mock(View.class);
-        when(itemView.findViewById(R.id.suggestion_list)).thenReturn(data);
-        when(itemView.findViewById(android.R.id.summary)).thenReturn(mock(TextView.class));
-        final DashboardAdapterV2.SuggestionContainerHolder holder =
-                new DashboardAdapterV2.SuggestionContainerHolder(itemView);
-
-        adapter.onBindSuggestion(holder, 0);
-
-        final DashboardDataV2 dashboardData = adapter.mDashboardData;
-        reset(adapter); // clear interactions tracking
-
-        final Suggestion suggestionToRemove = suggestions.get(1);
-        adapter.onSuggestionClosed(suggestionToRemove);
-
-        assertThat(adapter.mDashboardData).isEqualTo(dashboardData);
-        assertThat(suggestions.size()).isEqualTo(2);
-        assertThat(suggestions.contains(suggestionToRemove)).isFalse();
-        verify(adapter, never()).notifyDashboardDataChanged(any());
-    }
-
-    @Test
-    public void testSuggestionDismissed_moreThanTwoSuggestions_shouldNotCrash() {
-        final RecyclerView data = new RecyclerView(RuntimeEnvironment.application);
-        final View itemView = mock(View.class);
-        when(itemView.findViewById(R.id.suggestion_list)).thenReturn(data);
-        when(itemView.findViewById(android.R.id.summary)).thenReturn(mock(TextView.class));
-        final DashboardAdapterV2.SuggestionContainerHolder holder =
-                new DashboardAdapterV2.SuggestionContainerHolder(itemView);
-        final List<Suggestion> suggestions = makeSuggestionsV2("pkg1", "pkg2", "pkg3", "pkg4");
-        final DashboardAdapterV2 adapter = spy(new DashboardAdapterV2(mContext,
-                null /*savedInstance */, null /* conditions */,
-                null /* suggestionControllerMixin */,
-                null /* lifecycle */));
-        adapter.setSuggestions(suggestions);
-        adapter.onBindSuggestion(holder, 0);
-
-        adapter.onSuggestionClosed(suggestions.get(1));
-
-        // verify operations that access the lists will not cause ConcurrentModificationException
-        assertThat(holder.data.getAdapter().getItemCount()).isEqualTo(3);
-        adapter.setSuggestions(suggestions);
-        // should not crash
-    }
-
-    @Test
-    public void testSuggestionDismissed_onlySuggestion_updateDashboardData() {
-        DashboardAdapterV2 adapter =
-                spy(new DashboardAdapterV2(mContext, null /* savedInstanceState */,
-                        null /* conditions */, null /* suggestionControllerMixin */, null /*
-                        lifecycle */));
-        final List<Suggestion> suggestions = makeSuggestionsV2("pkg1");
-        adapter.setSuggestions(suggestions);
-        final DashboardDataV2 dashboardData = adapter.mDashboardData;
-        reset(adapter); // clear interactions tracking
-
-        adapter.onSuggestionClosed(suggestions.get(0));
-
-        assertThat(adapter.mDashboardData).isNotEqualTo(dashboardData);
-        verify(adapter).notifyDashboardDataChanged(any());
-    }
-
-    @Test
-    public void testBindSuggestion_shouldSetSuggestionAdapterAndNoCrash() {
-        mDashboardAdapter = new DashboardAdapterV2(mContext, null /* savedInstanceState */,
-                null /* conditions */, null /* suggestionControllerMixin */, null /* lifecycle */);
-        final List<Suggestion> suggestions = makeSuggestionsV2("pkg1");
-
-        mDashboardAdapter.setSuggestions(suggestions);
-
-        final RecyclerView data = mock(RecyclerView.class);
-        when(data.getResources()).thenReturn(mResources);
-        when(data.getContext()).thenReturn(mContext);
-        when(mResources.getDisplayMetrics()).thenReturn(mock(DisplayMetrics.class));
-        final View itemView = mock(View.class);
-        when(itemView.findViewById(R.id.suggestion_list)).thenReturn(data);
-        when(itemView.findViewById(android.R.id.summary)).thenReturn(mock(TextView.class));
-        final DashboardAdapterV2.SuggestionContainerHolder holder =
-                new DashboardAdapterV2.SuggestionContainerHolder(itemView);
-
-        mDashboardAdapter.onBindSuggestion(holder, 0);
-
-        verify(data).setAdapter(any(SuggestionAdapterV2.class));
-        // should not crash
-    }
-
-    @Test
-    public void testBindSuggestion_shouldSetSummary() {
-        mDashboardAdapter = new DashboardAdapterV2(mContext, null /* savedInstanceState */,
-                null /* conditions */, null /* suggestionControllerMixin */, null /* lifecycle */);
-        final List<Suggestion> suggestions = makeSuggestionsV2("pkg1");
-
-        mDashboardAdapter.setSuggestions(suggestions);
-
-        final RecyclerView data = mock(RecyclerView.class);
-        when(data.getResources()).thenReturn(mResources);
-        when(data.getContext()).thenReturn(mContext);
-        when(mResources.getDisplayMetrics()).thenReturn(mock(DisplayMetrics.class));
-        final View itemView = mock(View.class);
-        when(itemView.findViewById(R.id.suggestion_list)).thenReturn(data);
-        final TextView summary = mock(TextView.class);
-        when(itemView.findViewById(android.R.id.summary)).thenReturn(summary);
-        final DashboardAdapterV2.SuggestionContainerHolder holder =
-                new DashboardAdapterV2.SuggestionContainerHolder(itemView);
-
-        mDashboardAdapter.onBindSuggestion(holder, 0);
-
-        verify(summary).setText("1");
-
-        suggestions.addAll(makeSuggestionsV2("pkg2", "pkg3", "pkg4"));
-        mDashboardAdapter.setSuggestions(suggestions);
-
-        mDashboardAdapter.onBindSuggestion(holder, 0);
-
-        verify(summary).setText("4");
-    }
-
-    @Test
-    public void onBindTile_internalTile_shouldNotUseGenericBackgroundIcon() {
-        final Context context = RuntimeEnvironment.application;
-        final View view = LayoutInflater.from(context).inflate(R.layout.dashboard_tile, null);
-        final DashboardAdapterV2.DashboardItemHolder holder =
-                new DashboardAdapterV2.DashboardItemHolder(view);
-        final Tile tile = new Tile();
-        tile.icon = Icon.createWithResource(context, R.drawable.ic_settings);
-        final DashboardAdapterV2.IconCache iconCache = mock(DashboardAdapterV2.IconCache.class);
-        when(iconCache.getIcon(tile.icon)).thenReturn(context.getDrawable(R.drawable.ic_settings));
-
-        mDashboardAdapter = new DashboardAdapterV2(context, null /* savedInstanceState */,
-                null /* conditions */, null /* suggestionControllerMixin */, null /* lifecycle */);
-        ReflectionHelpers.setField(mDashboardAdapter, "mCache", iconCache);
-        mDashboardAdapter.onBindTile(holder, tile);
-
-        verify(iconCache, never()).updateIcon(any(Icon.class), any(Drawable.class));
-    }
-
-    @Test
-    public void onBindTile_externalTile_shouldNotUseGenericBackgroundIcon() {
-        final Context context = RuntimeEnvironment.application;
-        final View view = LayoutInflater.from(context).inflate(R.layout.dashboard_tile, null);
-        final DashboardAdapterV2.DashboardItemHolder holder =
-                new DashboardAdapterV2.DashboardItemHolder(view);
-        final Tile tile = new Tile();
-        tile.icon = mock(Icon.class);
-        when(tile.icon.getResPackage()).thenReturn("another.package");
-
-        final DashboardAdapterV2.IconCache iconCache = mock(DashboardAdapterV2.IconCache.class);
-        when(iconCache.getIcon(tile.icon)).thenReturn(context.getDrawable(R.drawable.ic_settings));
-
-        mDashboardAdapter = new DashboardAdapterV2(context, null /* savedInstanceState */,
-                null /* conditions */, null /* suggestionControllerMixin */, null /* lifecycle */);
-        ReflectionHelpers.setField(mDashboardAdapter, "mCache", iconCache);
-        mDashboardAdapter.onBindTile(holder, tile);
-
-        verify(iconCache).updateIcon(eq(tile.icon), any(RoundedHomepageIcon.class));
-    }
-
-    private List<Suggestion> makeSuggestionsV2(String... pkgNames) {
-        final List<Suggestion> suggestions = new ArrayList<>();
-        for (String pkgName : pkgNames) {
-            final Suggestion suggestion = new Suggestion.Builder(pkgName)
-                    .setPendingIntent(mock(PendingIntent.class))
-                    .build();
-            suggestions.add(suggestion);
-        }
-        return suggestions;
-    }
-
-    private void setupSuggestions(List<Suggestion> suggestions) {
-        final Context context = RuntimeEnvironment.application;
-        mDashboardAdapter.setSuggestions(suggestions);
-    }
-}
diff --git a/tests/robotests/src/com/android/settings/dashboard/DashboardDataTest.java b/tests/robotests/src/com/android/settings/dashboard/DashboardDataTest.java
index 1116d7d..35f525e 100644
--- a/tests/robotests/src/com/android/settings/dashboard/DashboardDataTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/DashboardDataTest.java
@@ -17,8 +17,9 @@
 package com.android.settings.dashboard;
 
 import static com.android.settings.dashboard.DashboardData.STABLE_ID_CONDITION_CONTAINER;
-import static com.android.settings.dashboard.DashboardData.STABLE_ID_SUGGESTION_CONDITION_FOOTER;
+import static com.android.settings.dashboard.DashboardData.STABLE_ID_CONDITION_FOOTER;
 import static com.android.settings.dashboard.DashboardData.STABLE_ID_SUGGESTION_CONTAINER;
+import static com.android.settings.dashboard.DashboardData.STABLE_ID_SUGGESTION_CONDITION_DIVIDER;
 import static com.google.common.truth.Truth.assertThat;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
@@ -103,14 +104,14 @@
                 .setConditions(oneItemConditions)
                 .setCategory(mDashboardCategory)
                 .setSuggestions(suggestions)
-                .setSuggestionConditionMode(DashboardData.HEADER_MODE_FULLY_EXPANDED)
+                .setConditionExpanded(true)
                 .build();
 
         mDashboardDataWithTwoConditions = new DashboardData.Builder()
                 .setConditions(twoItemsConditions)
                 .setCategory(mDashboardCategory)
                 .setSuggestions(suggestions)
-                .setSuggestionConditionMode(DashboardData.HEADER_MODE_FULLY_EXPANDED)
+                .setConditionExpanded(true)
                 .build();
 
         mDashboardDataWithNoItems = new DashboardData.Builder()
@@ -124,21 +125,23 @@
     public void testBuildItemsData_shouldSetstableId() {
         final List<DashboardData.Item> items = mDashboardDataWithOneConditions.getItemList();
 
-        // Header, suggestion, condition, footer, 1 tile
-        assertThat(items).hasSize(4);
+        // suggestion, seperator, condition, footer, 1 tile
+        assertThat(items).hasSize(5);
 
         assertThat(items.get(0).id).isEqualTo(STABLE_ID_SUGGESTION_CONTAINER);
-        assertThat(items.get(1).id).isEqualTo(STABLE_ID_CONDITION_CONTAINER);
-        assertThat(items.get(2).id).isEqualTo(STABLE_ID_SUGGESTION_CONDITION_FOOTER);
-        assertThat(items.get(3).id).isEqualTo(Objects.hash(mTestCategoryTile.title));
+        assertThat(items.get(1).id).isEqualTo(STABLE_ID_SUGGESTION_CONDITION_DIVIDER);
+        assertThat(items.get(2).id).isEqualTo(STABLE_ID_CONDITION_CONTAINER);
+        assertThat(items.get(3).id).isEqualTo(STABLE_ID_CONDITION_FOOTER);
+        assertThat(items.get(4).id).isEqualTo(Objects.hash(mTestCategoryTile.title));
     }
 
     @Test
     public void testBuildItemsData_containsAllData() {
         final Object[] expectedObjects = {
                 mDashboardDataWithOneConditions.getSuggestions(),
+                null /* divider */,
                 mDashboardDataWithOneConditions.getConditions(),
-                null, mTestCategoryTile};
+                null /* footer */, mTestCategoryTile};
         final int expectedSize = expectedObjects.length;
 
         assertThat(mDashboardDataWithOneConditions.getItemList()).hasSize(expectedSize);
@@ -147,14 +150,13 @@
             final Object item = mDashboardDataWithOneConditions.getItemEntityByPosition(i);
             if (item instanceof List) {
                 assertThat(item).isEqualTo(expectedObjects[i]);
-            } else if (item instanceof DashboardData.SuggestionConditionHeaderData) {
-                DashboardData.SuggestionConditionHeaderData i1 =
-                        (DashboardData.SuggestionConditionHeaderData) item;
-                DashboardData.SuggestionConditionHeaderData i2 =
-                        (DashboardData.SuggestionConditionHeaderData) expectedObjects[i];
+            } else if (item instanceof DashboardData.ConditionHeaderData) {
+                DashboardData.ConditionHeaderData i1 =
+                        (DashboardData.ConditionHeaderData) item;
+                DashboardData.ConditionHeaderData i2 =
+                        (DashboardData.ConditionHeaderData) expectedObjects[i];
                 assertThat(i1.title).isEqualTo(i2.title);
                 assertThat(i1.conditionCount).isEqualTo(i2.conditionCount);
-                assertThat(i1.hiddenSuggestionCount).isEqualTo(i2.hiddenSuggestionCount);
             } else {
                 assertThat(item).isSameAs(expectedObjects[i]);
             }
@@ -209,10 +211,10 @@
     public void testDiffUtil_InsertOneCondition_ResultDataOneChanged() {
         //Build testResultData
         final List<ListUpdateResult.ResultData> testResultData = new ArrayList<>();
-        // Item in position 2 is the condition container containing the list of conditions, which
+        // Item in position 3 is the condition container containing the list of conditions, which
         // gets 1 more item
         testResultData.add(new ListUpdateResult.ResultData(
-                ListUpdateResult.ResultData.TYPE_OPERATION_CHANGE, 1, 1));
+                ListUpdateResult.ResultData.TYPE_OPERATION_CHANGE, 2, 1));
 
         testDiffUtil(mDashboardDataWithOneConditions,
                 mDashboardDataWithTwoConditions, testResultData);
@@ -222,10 +224,11 @@
     public void testDiffUtil_RemoveOneSuggestion_causeItemRemoveAndChange() {
         //Build testResultData
         final List<ListUpdateResult.ResultData> testResultData = new ArrayList<>();
+        // removed suggestion and the divider
         testResultData.add(new ListUpdateResult.ResultData(
-                ListUpdateResult.ResultData.TYPE_OPERATION_REMOVE, 0, 1));
+                ListUpdateResult.ResultData.TYPE_OPERATION_REMOVE, 0, 2));
         testResultData.add(new ListUpdateResult.ResultData(
-                ListUpdateResult.ResultData.TYPE_OPERATION_CHANGE, 1, 1));
+                ListUpdateResult.ResultData.TYPE_OPERATION_CHANGE, 2, 1));
         // Build DashboardData
         final List<Condition> oneItemConditions = new ArrayList<>();
         when(mTestCondition.shouldShow()).thenReturn(true);
@@ -237,13 +240,13 @@
                 .setConditions(oneItemConditions)
                 .setCategory(mDashboardCategory)
                 .setSuggestions(suggestions)
-                .setSuggestionConditionMode(DashboardData.HEADER_MODE_DEFAULT)
+                .setConditionExpanded(false)
                 .build();
         final DashboardData newData = new DashboardData.Builder()
                 .setConditions(oneItemConditions)
                 .setSuggestions(null)
                 .setCategory(mDashboardCategory)
-                .setSuggestionConditionMode(DashboardData.HEADER_MODE_DEFAULT)
+                .setConditionExpanded(false)
                 .build();
 
         testDiffUtil(oldData, newData, testResultData);
@@ -254,7 +257,7 @@
         //Build testResultData
         final List<ListUpdateResult.ResultData> testResultData = new ArrayList<>();
         testResultData.add(new ListUpdateResult.ResultData(
-                ListUpdateResult.ResultData.TYPE_OPERATION_REMOVE, 0, 4));
+                ListUpdateResult.ResultData.TYPE_OPERATION_REMOVE, 0, 5));
 
         testDiffUtil(mDashboardDataWithOneConditions, mDashboardDataWithNoItems, testResultData);
     }
diff --git a/tests/robotests/src/com/android/settings/dashboard/DashboardSummaryTest.java b/tests/robotests/src/com/android/settings/dashboard/DashboardSummaryTest.java
index 59823ec..a1c8d67 100644
--- a/tests/robotests/src/com/android/settings/dashboard/DashboardSummaryTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/DashboardSummaryTest.java
@@ -16,6 +16,7 @@
 
 package com.android.settings.dashboard;
 
+import static com.google.common.truth.Truth.assertThat;
 import static org.mockito.ArgumentMatchers.nullable;
 import static org.mockito.Mockito.any;
 import static org.mockito.Mockito.doNothing;
@@ -34,9 +35,11 @@
 import com.android.settings.TestConfig;
 import com.android.settings.dashboard.conditional.ConditionManager;
 import com.android.settings.dashboard.conditional.FocusRecyclerView;
+import com.android.settings.testutils.FakeFeatureFactory;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
 import com.android.settingslib.drawer.CategoryKey;
 import com.android.settingslib.drawer.DashboardCategory;
+import com.android.settingslib.suggestions.SuggestionControllerMixin;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -67,10 +70,12 @@
 
     private Context mContext;
     private DashboardSummary mSummary;
+    private FakeFeatureFactory mFeatureFactory;
 
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
+        mFeatureFactory = FakeFeatureFactory.setupForTest();
         mContext = RuntimeEnvironment.application;
         mSummary = spy(new DashboardSummary());
         ReflectionHelpers.setField(mSummary, "mAdapter", mAdapter);
@@ -83,6 +88,28 @@
     }
 
     @Test
+    public void onAttach_suggestionDisabled_shouldNotStartSuggestionControllerMixin() {
+        when(mFeatureFactory.suggestionsFeatureProvider.isSuggestionEnabled(any(Context.class)))
+                .thenReturn(false);
+
+        mSummary.onAttach(mContext);
+        final SuggestionControllerMixin mixin = ReflectionHelpers
+                .getField(mSummary, "mSuggestionControllerMixin");
+        assertThat(mixin).isNull();
+    }
+
+    @Test
+    public void onAttach_suggestionEnabled_shouldStartSuggestionControllerMixin() {
+        when(mFeatureFactory.suggestionsFeatureProvider.isSuggestionEnabled(any(Context.class)))
+                .thenReturn(true);
+
+        mSummary.onAttach(mContext);
+        final SuggestionControllerMixin mixin = ReflectionHelpers
+                .getField(mSummary, "mSuggestionControllerMixin");
+        assertThat(mixin).isNotNull();
+    }
+
+    @Test
     public void updateCategory_shouldGetCategoryFromFeatureProvider() {
         doReturn(mock(Activity.class)).when(mSummary).getActivity();
         mSummary.onAttach(mContext);
@@ -137,10 +164,4 @@
         mSummary.onCategoriesChanged();
         verify(mSummary).rebuildUI();
     }
-
-    @Test
-    public void onSuggestionDismissed_shouldNotRebuildUI() {
-        mSummary.onSuggestionDismissed(mock(Suggestion.class));
-        verify(mSummary, never()).rebuildUI();
-    }
 }
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/dashboard/conditional/ConditionAdapterTest.java b/tests/robotests/src/com/android/settings/dashboard/conditional/ConditionAdapterTest.java
index d943fe3..e33db6e 100644
--- a/tests/robotests/src/com/android/settings/dashboard/conditional/ConditionAdapterTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/conditional/ConditionAdapterTest.java
@@ -15,6 +15,11 @@
  */
 package com.android.settings.dashboard.conditional;
 
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
 import android.content.Context;
 import android.support.v7.widget.RecyclerView;
 import android.view.LayoutInflater;
@@ -22,13 +27,9 @@
 import android.widget.LinearLayout;
 
 import com.android.settings.R;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
 import com.android.settings.TestConfig;
 import com.android.settings.dashboard.DashboardAdapter;
-import com.android.settings.dashboard.DashboardData;
-
-import java.util.ArrayList;
-import java.util.List;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -38,9 +39,8 @@
 import org.robolectric.RuntimeEnvironment;
 import org.robolectric.annotation.Config;
 
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
+import java.util.ArrayList;
+import java.util.List;
 
 @RunWith(SettingsRobolectricTestRunner.class)
 @Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
@@ -70,35 +70,23 @@
     }
 
     @Test
-    public void getItemCount_notFullyExpanded_shouldReturn0() {
-        mConditionAdapter = new ConditionAdapter(
-            mContext, mOneCondition, DashboardData.HEADER_MODE_DEFAULT);
-        assertThat(mConditionAdapter.getItemCount()).isEqualTo(0);
-
-        mConditionAdapter = new ConditionAdapter(
-            mContext, mOneCondition, DashboardData.HEADER_MODE_SUGGESTION_EXPANDED);
-        assertThat(mConditionAdapter.getItemCount()).isEqualTo(0);
-
-        mConditionAdapter = new ConditionAdapter(
-            mContext, mOneCondition, DashboardData.HEADER_MODE_COLLAPSED);
+    public void getItemCount_notExpanded_shouldReturn0() {
+        mConditionAdapter = new ConditionAdapter(mContext, mOneCondition, false);
         assertThat(mConditionAdapter.getItemCount()).isEqualTo(0);
     }
 
     @Test
-    public void getItemCount_fullyExpanded_shouldReturnListSize() {
-        mConditionAdapter = new ConditionAdapter(
-            mContext, mOneCondition, DashboardData.HEADER_MODE_FULLY_EXPANDED);
+    public void getItemCount_expanded_shouldReturnListSize() {
+        mConditionAdapter = new ConditionAdapter(mContext, mOneCondition, true);
         assertThat(mConditionAdapter.getItemCount()).isEqualTo(1);
 
-        mConditionAdapter = new ConditionAdapter(
-            mContext, mTwoConditions, DashboardData.HEADER_MODE_FULLY_EXPANDED);
+        mConditionAdapter = new ConditionAdapter(mContext, mTwoConditions, true);
         assertThat(mConditionAdapter.getItemCount()).isEqualTo(2);
     }
 
     @Test
     public void getItemViewType_shouldReturnConditionTile() {
-        mConditionAdapter = new ConditionAdapter(
-            mContext, mTwoConditions, DashboardData.HEADER_MODE_FULLY_EXPANDED);
+        mConditionAdapter = new ConditionAdapter(mContext, mTwoConditions, true);
         assertThat(mConditionAdapter.getItemViewType(0)).isEqualTo(R.layout.condition_tile);
     }
 
@@ -108,8 +96,7 @@
             R.layout.condition_tile, new LinearLayout(mContext), true);
         final DashboardAdapter.DashboardItemHolder viewHolder =
             new DashboardAdapter.DashboardItemHolder(view);
-        mConditionAdapter = new ConditionAdapter(
-            mContext, mOneCondition, DashboardData.HEADER_MODE_SUGGESTION_EXPANDED);
+        mConditionAdapter = new ConditionAdapter(mContext, mOneCondition, true);
 
         mConditionAdapter.onBindViewHolder(viewHolder, 0);
         final View card = view.findViewById(R.id.content);
@@ -122,8 +109,7 @@
             R.layout.condition_tile, new LinearLayout(mContext), true);
         final DashboardAdapter.DashboardItemHolder viewHolder =
             new DashboardAdapter.DashboardItemHolder(view);
-        mConditionAdapter = new ConditionAdapter(
-            mContext, mOneCondition, DashboardData.HEADER_MODE_SUGGESTION_EXPANDED);
+        mConditionAdapter = new ConditionAdapter(mContext, mOneCondition, true);
 
         mConditionAdapter.onBindViewHolder(viewHolder, 0);
         final View card = view.findViewById(R.id.content);
@@ -137,9 +123,8 @@
         final View view = LayoutInflater.from(mContext).inflate(
                 R.layout.condition_tile, new LinearLayout(mContext), true);
         final DashboardAdapter.DashboardItemHolder viewHolder =
-                new DashboardAdapter.DashboardItemHolder(view);
-        mConditionAdapter = new ConditionAdapter(
-                mContext, mOneCondition, DashboardData.HEADER_MODE_SUGGESTION_EXPANDED);
+            new DashboardAdapter.DashboardItemHolder(view);
+        mConditionAdapter = new ConditionAdapter(mContext, mOneCondition, true);
         mConditionAdapter.addDismissHandling(recyclerView);
 
         // do not bind viewholder to simulate the null condition scenario
diff --git a/tests/robotests/src/com/android/settings/dashboard/conditional/ConditionAdapterV2Test.java b/tests/robotests/src/com/android/settings/dashboard/conditional/ConditionAdapterV2Test.java
deleted file mode 100644
index 5e0ecec..0000000
--- a/tests/robotests/src/com/android/settings/dashboard/conditional/ConditionAdapterV2Test.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright (C) 2018 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.dashboard.conditional;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.content.Context;
-import android.support.v7.widget.RecyclerView;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.widget.LinearLayout;
-
-import com.android.settings.R;
-import com.android.settings.TestConfig;
-import com.android.settings.dashboard.DashboardAdapterV2;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.RuntimeEnvironment;
-import org.robolectric.annotation.Config;
-
-import java.util.ArrayList;
-import java.util.List;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
-public class ConditionAdapterV2Test {
-    @Mock
-    private Condition mCondition1;
-    @Mock
-    private Condition mCondition2;
-
-    private Context mContext;
-    private ConditionAdapterV2 mConditionAdapter;
-    private List<Condition> mOneCondition;
-    private List<Condition> mTwoConditions;
-
-    @Before
-    public void setUp() {
-        MockitoAnnotations.initMocks(this);
-        mContext = RuntimeEnvironment.application;
-        final CharSequence[] actions = new CharSequence[2];
-        when(mCondition1.getActions()).thenReturn(actions);
-        when(mCondition1.shouldShow()).thenReturn(true);
-        mOneCondition = new ArrayList<>();
-        mOneCondition.add(mCondition1);
-        mTwoConditions = new ArrayList<>();
-        mTwoConditions.add(mCondition1);
-        mTwoConditions.add(mCondition2);
-    }
-
-    @Test
-    public void getItemCount_notExpanded_shouldReturn0() {
-        mConditionAdapter = new ConditionAdapterV2(mContext, mOneCondition, false);
-        assertThat(mConditionAdapter.getItemCount()).isEqualTo(0);
-    }
-
-    @Test
-    public void getItemCount_expanded_shouldReturnListSize() {
-        mConditionAdapter = new ConditionAdapterV2(mContext, mOneCondition, true);
-        assertThat(mConditionAdapter.getItemCount()).isEqualTo(1);
-
-        mConditionAdapter = new ConditionAdapterV2(mContext, mTwoConditions, true);
-        assertThat(mConditionAdapter.getItemCount()).isEqualTo(2);
-    }
-
-    @Test
-    public void getItemViewType_shouldReturnConditionTile() {
-        mConditionAdapter = new ConditionAdapterV2(mContext, mTwoConditions, true);
-        assertThat(mConditionAdapter.getItemViewType(0)).isEqualTo(R.layout.condition_tile);
-    }
-
-    @Test
-    public void onBindViewHolder_shouldSetListener() {
-        final View view = LayoutInflater.from(mContext).inflate(
-            R.layout.condition_tile, new LinearLayout(mContext), true);
-        final DashboardAdapterV2.DashboardItemHolder viewHolder =
-            new DashboardAdapterV2.DashboardItemHolder(view);
-        mConditionAdapter = new ConditionAdapterV2(mContext, mOneCondition, true);
-
-        mConditionAdapter.onBindViewHolder(viewHolder, 0);
-        final View card = view.findViewById(R.id.content);
-        assertThat(card.hasOnClickListeners()).isTrue();
-    }
-
-    @Test
-    public void viewClick_shouldInvokeConditionPrimaryClick() {
-        final View view = LayoutInflater.from(mContext).inflate(
-            R.layout.condition_tile, new LinearLayout(mContext), true);
-        final DashboardAdapterV2.DashboardItemHolder viewHolder =
-            new DashboardAdapterV2.DashboardItemHolder(view);
-        mConditionAdapter = new ConditionAdapterV2(mContext, mOneCondition, true);
-
-        mConditionAdapter.onBindViewHolder(viewHolder, 0);
-        final View card = view.findViewById(R.id.content);
-        card.performClick();
-        verify(mCondition1).onPrimaryClick();
-    }
-
-    @Test
-    public void onSwiped_nullCondition_shouldNotCrash() {
-        final RecyclerView recyclerView = new RecyclerView(mContext);
-        final View view = LayoutInflater.from(mContext).inflate(
-                R.layout.condition_tile, new LinearLayout(mContext), true);
-        final DashboardAdapterV2.DashboardItemHolder viewHolder =
-                new DashboardAdapterV2.DashboardItemHolder(view);
-        mConditionAdapter = new ConditionAdapterV2(mContext, mOneCondition, true);
-        mConditionAdapter.addDismissHandling(recyclerView);
-
-        // do not bind viewholder to simulate the null condition scenario
-        mConditionAdapter.mSwipeCallback.onSwiped(viewHolder, 0);
-        // no crash
-    }
-
-}
diff --git a/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionAdapterTest.java b/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionAdapterTest.java
index 49e82e4..825aee9 100644
--- a/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionAdapterTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionAdapterTest.java
@@ -16,12 +16,19 @@
 package com.android.settings.dashboard.suggestions;
 
 import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyInt;
 import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
 
 import android.app.PendingIntent;
 import android.content.Context;
+import android.content.res.TypedArray;
+import android.graphics.drawable.Drawable;
 import android.graphics.drawable.Icon;
 import android.service.settings.suggestions.Suggestion;
 import android.view.LayoutInflater;
@@ -46,6 +53,7 @@
 import org.mockito.MockitoAnnotations;
 import org.robolectric.RuntimeEnvironment;
 import org.robolectric.annotation.Config;
+import org.robolectric.util.ReflectionHelpers;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -87,20 +95,21 @@
     @Test
     public void getItemCount_shouldReturnListSize() {
         mSuggestionAdapter = new SuggestionAdapter(mContext, mSuggestionControllerMixin,
-                mOneSuggestion, new ArrayList<>());
+            null /* savedInstanceState */, null /* callback */, null /* lifecycle */);
+        mSuggestionAdapter.setSuggestions(mOneSuggestion);
         assertThat(mSuggestionAdapter.getItemCount()).isEqualTo(1);
 
-        mSuggestionAdapter = new SuggestionAdapter(mContext, mSuggestionControllerMixin,
-                mTwoSuggestions, new ArrayList<>());
+        mSuggestionAdapter.setSuggestions(mTwoSuggestions);
         assertThat(mSuggestionAdapter.getItemCount()).isEqualTo(2);
     }
 
     @Test
     public void getItemViewType_shouldReturnSuggestionTile() {
         mSuggestionAdapter = new SuggestionAdapter(mContext, mSuggestionControllerMixin,
-                mOneSuggestion, new ArrayList<>());
+            null /* savedInstanceState */, null /* callback */, null /* lifecycle */);
+        mSuggestionAdapter.setSuggestions(mOneSuggestion);
         assertThat(mSuggestionAdapter.getItemViewType(0))
-                .isEqualTo(R.layout.suggestion_tile);
+            .isEqualTo(R.layout.suggestion_tile);
     }
 
     @Test
@@ -112,19 +121,21 @@
                 .setSummary("456")
                 .build());
         mSuggestionAdapter = new SuggestionAdapter(mContext, mSuggestionControllerMixin,
-                suggestions, new ArrayList<>());
+            null /* savedInstanceState */, null /* callback */, null /* lifecycle */);
+        mSuggestionAdapter.setSuggestions(suggestions);
 
         assertThat(mSuggestionAdapter.getItemViewType(0))
-                .isEqualTo(R.layout.suggestion_tile_with_button);
+            .isEqualTo(R.layout.suggestion_tile_with_button);
     }
 
     @Test
     public void onBindViewHolder_shouldLog() {
         final View view = spy(LayoutInflater.from(mContext).inflate(
-                R.layout.suggestion_tile, new LinearLayout(mContext), true));
+            R.layout.suggestion_tile, new LinearLayout(mContext), true));
         mSuggestionHolder = new DashboardAdapter.DashboardItemHolder(view);
         mSuggestionAdapter = new SuggestionAdapter(mContext, mSuggestionControllerMixin,
-                mOneSuggestion, new ArrayList<>());
+            null /* savedInstanceState */, null /* callback */, null /* lifecycle */);
+        mSuggestionAdapter.setSuggestions(mOneSuggestion);
 
         // Bind twice
         mSuggestionAdapter.onBindViewHolder(mSuggestionHolder, 0);
@@ -150,6 +161,31 @@
     }
 
     @Test
+    public void onBindViewHolder_hasButton_buttonShouldHandleClick()
+        throws PendingIntent.CanceledException {
+        final List<Suggestion> suggestions = new ArrayList<>();
+        final PendingIntent pendingIntent = mock(PendingIntent.class);
+        suggestions.add(new Suggestion.Builder("id")
+            .setFlags(Suggestion.FLAG_HAS_BUTTON)
+            .setTitle("123")
+            .setSummary("456")
+            .setPendingIntent(pendingIntent)
+            .build());
+        mSuggestionAdapter = new SuggestionAdapter(mContext, mSuggestionControllerMixin,
+            null /* savedInstanceState */, null /* callback */, null /* lifecycle */);
+        mSuggestionAdapter.setSuggestions(suggestions);
+        mSuggestionHolder = mSuggestionAdapter.onCreateViewHolder(
+            new FrameLayout(RuntimeEnvironment.application),
+            mSuggestionAdapter.getItemViewType(0));
+
+        mSuggestionAdapter.onBindViewHolder(mSuggestionHolder, 0);
+        mSuggestionHolder.itemView.findViewById(android.R.id.primary).performClick();
+
+        verify(mSuggestionControllerMixin).launchSuggestion(suggestions.get(0));
+        verify(pendingIntent).send();
+    }
+
+    @Test
     public void getSuggestions_shouldReturnSuggestionWhenMatch() {
         final List<Suggestion> suggestions = makeSuggestions("pkg1");
         setupSuggestions(mActivity, suggestions);
@@ -157,9 +193,89 @@
         assertThat(mSuggestionAdapter.getSuggestion(0)).isNotNull();
     }
 
+    @Test
+    public void onBindViewHolder_closeButtonShouldHandleClick()
+        throws PendingIntent.CanceledException {
+        final List<Suggestion> suggestions = makeSuggestions("pkg1");
+        final SuggestionAdapter.Callback callback = mock(SuggestionAdapter.Callback.class);
+        mSuggestionAdapter = new SuggestionAdapter(mActivity, mSuggestionControllerMixin,
+            null /* savedInstanceState */, callback, null /* lifecycle */);
+        mSuggestionAdapter.setSuggestions(suggestions);
+        mSuggestionHolder = mSuggestionAdapter.onCreateViewHolder(
+            new FrameLayout(RuntimeEnvironment.application),
+            mSuggestionAdapter.getItemViewType(0));
+
+        mSuggestionAdapter.onBindViewHolder(mSuggestionHolder, 0);
+        mSuggestionHolder.itemView.findViewById(R.id.close_button).performClick();
+
+        final Suggestion suggestion = suggestions.get(0);
+        verify(mFeatureFactory.suggestionsFeatureProvider).dismissSuggestion(
+            mActivity, mSuggestionControllerMixin, suggestion);
+        verify(callback).onSuggestionClosed(suggestion);
+    }
+
+    @Test
+    public void onBindViewHolder_iconNotTintable_shouldNotTintIcon()
+            throws PendingIntent.CanceledException {
+        final Icon icon = mock(Icon.class);
+        final Suggestion suggestion = new Suggestion.Builder("pkg1")
+            .setPendingIntent(mock(PendingIntent.class))
+            .setIcon(icon)
+            .build();
+        final List<Suggestion> suggestions = new ArrayList<>();
+        suggestions.add(suggestion);
+        mSuggestionAdapter = new SuggestionAdapter(mActivity, mSuggestionControllerMixin,
+            null /* savedInstanceState */, null /* callback */, null /* lifecycle */);
+        mSuggestionAdapter.setSuggestions(suggestions);
+        mSuggestionHolder = mSuggestionAdapter.onCreateViewHolder(
+            new FrameLayout(RuntimeEnvironment.application),
+            mSuggestionAdapter.getItemViewType(0));
+        DashboardAdapter.IconCache cache = mock(DashboardAdapter.IconCache.class);
+        final Drawable drawable = mock(Drawable.class);
+        when(cache.getIcon(icon)).thenReturn(drawable);
+        ReflectionHelpers.setField(mSuggestionAdapter, "mCache", cache);
+
+        mSuggestionAdapter.onBindViewHolder(mSuggestionHolder, 0);
+
+        verify(drawable, never()).setTint(anyInt());
+    }
+
+    @Test
+    public void onBindViewHolder_iconTintable_shouldTintIcon()
+            throws PendingIntent.CanceledException {
+        final Icon icon = mock(Icon.class);
+        final int FLAG_ICON_TINTABLE = 1 << 1;
+        final Suggestion suggestion = new Suggestion.Builder("pkg1")
+            .setPendingIntent(mock(PendingIntent.class))
+            .setIcon(icon)
+            .setFlags(FLAG_ICON_TINTABLE)
+            .build();
+        final List<Suggestion> suggestions = new ArrayList<>();
+        suggestions.add(suggestion);
+        mSuggestionAdapter = new SuggestionAdapter(mActivity, mSuggestionControllerMixin,
+            null /* savedInstanceState */, null /* callback */, null /* lifecycle */);
+        mSuggestionAdapter.setSuggestions(suggestions);
+        mSuggestionHolder = mSuggestionAdapter.onCreateViewHolder(
+            new FrameLayout(RuntimeEnvironment.application),
+            mSuggestionAdapter.getItemViewType(0));
+        DashboardAdapter.IconCache cache = mock(DashboardAdapter.IconCache.class);
+        final Drawable drawable = mock(Drawable.class);
+        when(cache.getIcon(icon)).thenReturn(drawable);
+        ReflectionHelpers.setField(mSuggestionAdapter, "mCache", cache);
+        TypedArray typedArray = mock(TypedArray.class);
+        final int colorAccent = 1234;
+        when(mActivity.obtainStyledAttributes(any())).thenReturn(typedArray);
+        when(typedArray.getColor(anyInt(), anyInt())).thenReturn(colorAccent);
+
+        mSuggestionAdapter.onBindViewHolder(mSuggestionHolder, 0);
+
+        verify(drawable).setTint(colorAccent);
+    }
+
     private void setupSuggestions(Context context, List<Suggestion> suggestions) {
         mSuggestionAdapter = new SuggestionAdapter(context, mSuggestionControllerMixin,
-                suggestions, new ArrayList<>());
+            null /* savedInstanceState */, null /* callback */, null /* lifecycle */);
+        mSuggestionAdapter.setSuggestions(suggestions);
         mSuggestionHolder = mSuggestionAdapter.onCreateViewHolder(
                 new FrameLayout(RuntimeEnvironment.application),
                 mSuggestionAdapter.getItemViewType(0));
diff --git a/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionAdapterV2Test.java b/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionAdapterV2Test.java
deleted file mode 100644
index 1e76e2d..0000000
--- a/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionAdapterV2Test.java
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * Copyright (C) 2018 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.dashboard.suggestions;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.verify;
-
-import android.app.PendingIntent;
-import android.content.Context;
-import android.service.settings.suggestions.Suggestion;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.widget.FrameLayout;
-import android.widget.LinearLayout;
-
-import com.android.internal.logging.nano.MetricsProto;
-import com.android.settings.R;
-import com.android.settings.SettingsActivity;
-import com.android.settings.TestConfig;
-import com.android.settings.dashboard.DashboardAdapterV2;
-import com.android.settings.testutils.FakeFeatureFactory;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settingslib.suggestions.SuggestionControllerMixin;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Answers;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.RuntimeEnvironment;
-import org.robolectric.annotation.Config;
-
-import java.util.ArrayList;
-import java.util.List;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
-public class SuggestionAdapterV2Test {
-
-    @Mock(answer = Answers.RETURNS_DEEP_STUBS)
-    private SettingsActivity mActivity;
-    @Mock
-    private SuggestionControllerMixin mSuggestionControllerMixin;
-    private FakeFeatureFactory mFeatureFactory;
-    private Context mContext;
-    private SuggestionAdapterV2 mSuggestionAdapter;
-    private DashboardAdapterV2.DashboardItemHolder mSuggestionHolder;
-    private List<Suggestion> mOneSuggestion;
-    private List<Suggestion> mTwoSuggestions;
-
-    @Before
-    public void setUp() {
-        MockitoAnnotations.initMocks(this);
-        mContext = RuntimeEnvironment.application;
-        mFeatureFactory = FakeFeatureFactory.setupForTest();
-
-        final Suggestion suggestion1 = new Suggestion.Builder("id1")
-                .setTitle("Test suggestion 1")
-                .build();
-        final Suggestion suggestion2 = new Suggestion.Builder("id2")
-                .setTitle("Test suggestion 2")
-                .build();
-        mOneSuggestion = new ArrayList<>();
-        mOneSuggestion.add(suggestion1);
-        mTwoSuggestions = new ArrayList<>();
-        mTwoSuggestions.add(suggestion1);
-        mTwoSuggestions.add(suggestion2);
-    }
-
-    @Test
-    public void getItemCount_shouldReturnListSize() {
-        mSuggestionAdapter = new SuggestionAdapterV2(mContext, mSuggestionControllerMixin,
-                null /* savedInstanceState */, null /* callback */, null /* lifecycle */);
-        mSuggestionAdapter.setSuggestions(mOneSuggestion);
-        assertThat(mSuggestionAdapter.getItemCount()).isEqualTo(1);
-
-        mSuggestionAdapter.setSuggestions(mTwoSuggestions);
-        assertThat(mSuggestionAdapter.getItemCount()).isEqualTo(2);
-    }
-
-    @Test
-    public void getItemViewType_shouldReturnSuggestionTile() {
-        mSuggestionAdapter = new SuggestionAdapterV2(mContext, mSuggestionControllerMixin,
-                null /* savedInstanceState */, null /* callback */, null /* lifecycle */);
-        mSuggestionAdapter.setSuggestions(mOneSuggestion);
-        assertThat(mSuggestionAdapter.getItemViewType(0))
-                .isEqualTo(R.layout.suggestion_tile_v2);
-    }
-
-    @Test
-    public void getItemType_hasButton_shouldReturnSuggestionWithButton() {
-        final List<Suggestion> suggestions = new ArrayList<>();
-        suggestions.add(new Suggestion.Builder("id")
-                .setFlags(Suggestion.FLAG_HAS_BUTTON)
-                .setTitle("123")
-                .setSummary("456")
-                .build());
-        mSuggestionAdapter = new SuggestionAdapterV2(mContext, mSuggestionControllerMixin,
-                null /* savedInstanceState */, null /* callback */, null /* lifecycle */);
-        mSuggestionAdapter.setSuggestions(suggestions);
-
-        assertThat(mSuggestionAdapter.getItemViewType(0))
-                .isEqualTo(R.layout.suggestion_tile_with_button_v2);
-    }
-
-    @Test
-    public void onBindViewHolder_shouldLog() {
-        final View view = spy(LayoutInflater.from(mContext).inflate(
-                R.layout.suggestion_tile, new LinearLayout(mContext), true));
-        mSuggestionHolder = new DashboardAdapterV2.DashboardItemHolder(view);
-        mSuggestionAdapter = new SuggestionAdapterV2(mContext, mSuggestionControllerMixin,
-                null /* savedInstanceState */, null /* callback */, null /* lifecycle */);
-        mSuggestionAdapter.setSuggestions(mOneSuggestion);
-
-        // Bind twice
-        mSuggestionAdapter.onBindViewHolder(mSuggestionHolder, 0);
-        mSuggestionAdapter.onBindViewHolder(mSuggestionHolder, 0);
-
-        // Log once
-        verify(mFeatureFactory.metricsFeatureProvider).action(
-                mContext, MetricsProto.MetricsEvent.ACTION_SHOW_SETTINGS_SUGGESTION,
-                mOneSuggestion.get(0).getId());
-    }
-
-    @Test
-    public void onBindViewHolder_itemViewShouldHandleClick()
-            throws PendingIntent.CanceledException {
-        final List<Suggestion> suggestions = makeSuggestions("pkg1");
-        setupSuggestions(mActivity, suggestions);
-
-        mSuggestionAdapter.onBindViewHolder(mSuggestionHolder, 0);
-        mSuggestionHolder.itemView.performClick();
-
-        verify(mSuggestionControllerMixin).launchSuggestion(suggestions.get(0));
-        verify(suggestions.get(0).getPendingIntent()).send();
-    }
-
-    @Test
-    public void onBindViewHolder_hasButton_buttonShouldHandleClick()
-        throws PendingIntent.CanceledException {
-        final List<Suggestion> suggestions = new ArrayList<>();
-        final PendingIntent pendingIntent = mock(PendingIntent.class);
-        suggestions.add(new Suggestion.Builder("id")
-            .setFlags(Suggestion.FLAG_HAS_BUTTON)
-            .setTitle("123")
-            .setSummary("456")
-            .setPendingIntent(pendingIntent)
-            .build());
-        mSuggestionAdapter = new SuggestionAdapterV2(mContext, mSuggestionControllerMixin,
-            null /* savedInstanceState */, null /* callback */, null /* lifecycle */);
-        mSuggestionAdapter.setSuggestions(suggestions);
-        mSuggestionHolder = mSuggestionAdapter.onCreateViewHolder(
-            new FrameLayout(RuntimeEnvironment.application),
-            mSuggestionAdapter.getItemViewType(0));
-
-        mSuggestionAdapter.onBindViewHolder(mSuggestionHolder, 0);
-        mSuggestionHolder.itemView.findViewById(android.R.id.primary).performClick();
-
-        verify(mSuggestionControllerMixin).launchSuggestion(suggestions.get(0));
-        verify(pendingIntent).send();
-    }
-
-    @Test
-    public void getSuggestions_shouldReturnSuggestionWhenMatch() {
-        final List<Suggestion> suggestions = makeSuggestions("pkg1");
-        setupSuggestions(mActivity, suggestions);
-
-        assertThat(mSuggestionAdapter.getSuggestion(0)).isNotNull();
-    }
-
-    @Test
-    public void onBindViewHolder_closeButtonShouldHandleClick()
-        throws PendingIntent.CanceledException {
-        final List<Suggestion> suggestions = makeSuggestions("pkg1");
-        final SuggestionAdapterV2.Callback callback = mock(SuggestionAdapterV2.Callback.class);
-        mSuggestionAdapter = new SuggestionAdapterV2(mActivity, mSuggestionControllerMixin,
-            null /* savedInstanceState */, callback, null /* lifecycle */);
-        mSuggestionAdapter.setSuggestions(suggestions);
-        mSuggestionHolder = mSuggestionAdapter.onCreateViewHolder(
-            new FrameLayout(RuntimeEnvironment.application),
-            mSuggestionAdapter.getItemViewType(0));
-
-        mSuggestionAdapter.onBindViewHolder(mSuggestionHolder, 0);
-        mSuggestionHolder.itemView.findViewById(R.id.close_button).performClick();
-
-        verify(callback).onSuggestionClosed(suggestions.get(0));
-    }
-
-    private void setupSuggestions(Context context, List<Suggestion> suggestions) {
-        mSuggestionAdapter = new SuggestionAdapterV2(context, mSuggestionControllerMixin,
-                null /* savedInstanceState */, null /* callback */, null /* lifecycle */);
-        mSuggestionAdapter.setSuggestions(suggestions);
-        mSuggestionHolder = mSuggestionAdapter.onCreateViewHolder(
-                new FrameLayout(RuntimeEnvironment.application),
-                mSuggestionAdapter.getItemViewType(0));
-    }
-
-    private List<Suggestion> makeSuggestions(String... pkgNames) {
-        final List<Suggestion> suggestions = new ArrayList<>();
-        for (String pkgName : pkgNames) {
-            final Suggestion suggestion = new Suggestion.Builder(pkgName)
-                    .setPendingIntent(mock(PendingIntent.class))
-                    .build();
-            suggestions.add(suggestion);
-        }
-        return suggestions;
-    }
-}
diff --git a/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionDismissControllerTest.java b/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionDismissControllerTest.java
deleted file mode 100644
index f10f5ec..0000000
--- a/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionDismissControllerTest.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright (C) 2017 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.dashboard.suggestions;
-
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.ArgumentMatchers.nullable;
-import static org.mockito.Matchers.anyInt;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.content.Context;
-import android.service.settings.suggestions.Suggestion;
-import android.support.v7.widget.RecyclerView;
-import android.support.v7.widget.helper.ItemTouchHelper;
-
-import com.android.settings.R;
-import com.android.settings.TestConfig;
-import com.android.settings.testutils.FakeFeatureFactory;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settingslib.suggestions.SuggestionControllerMixin;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Answers;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.annotation.Config;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
-public class SuggestionDismissControllerTest {
-
-    @Mock(answer = Answers.RETURNS_DEEP_STUBS)
-    private Context mContext;
-    @Mock(answer = Answers.RETURNS_DEEP_STUBS)
-    private RecyclerView mRecyclerView;
-    @Mock
-    private SuggestionControllerMixin mSuggestionControllerMixin;
-    @Mock
-    private SuggestionDismissController.Callback mCallback;
-
-    private FakeFeatureFactory mFactory;
-    private SuggestionDismissController mController;
-
-    @Before
-    public void setUp() {
-        MockitoAnnotations.initMocks(this);
-        mFactory = FakeFeatureFactory.setupForTest();
-
-        when(mRecyclerView.getResources().getDimension(anyInt())).thenReturn(50F);
-
-        mController = new SuggestionDismissController(mContext, mRecyclerView,
-                mSuggestionControllerMixin, mCallback);
-    }
-
-    @Test
-    public void onMove_alwaysReturnTrue() {
-        assertThat(mController.onMove(null, null, null)).isTrue();
-    }
-
-    @Test
-    public void getSwipeDirs_isSuggestionTile_shouldReturnDirection() {
-        final RecyclerView.ViewHolder vh = mock(RecyclerView.ViewHolder.class);
-        when(vh.getItemViewType()).thenReturn(R.layout.suggestion_tile);
-
-        assertThat(mController.getSwipeDirs(mRecyclerView, vh))
-                .isEqualTo(ItemTouchHelper.START | ItemTouchHelper.END);
-    }
-
-    @Test
-    public void getSwipeDirs_isSuggestionTileCard_shouldReturnDirection() {
-        final RecyclerView.ViewHolder vh = mock(RecyclerView.ViewHolder.class);
-        when(vh.getItemViewType()).thenReturn(R.layout.suggestion_tile_with_button);
-
-        assertThat(mController.getSwipeDirs(mRecyclerView, vh))
-                .isEqualTo(ItemTouchHelper.START | ItemTouchHelper.END);
-    }
-
-    @Test
-    public void getSwipeDirs_isNotSuggestionTile_shouldReturn0() {
-        final RecyclerView.ViewHolder vh = mock(RecyclerView.ViewHolder.class);
-        when(vh.getItemViewType()).thenReturn(R.layout.condition_tile);
-
-        assertThat(mController.getSwipeDirs(mRecyclerView, vh))
-                .isEqualTo(0);
-    }
-
-    @Test
-    public void onSwiped_shouldTriggerDismissSuggestion() {
-        final RecyclerView.ViewHolder vh = mock(RecyclerView.ViewHolder.class);
-        when(mCallback.getSuggestionAt(anyInt())).thenReturn(
-                new Suggestion.Builder("id").build());
-
-        mController.onSwiped(vh, ItemTouchHelper.START);
-
-        verify(mFactory.suggestionsFeatureProvider).dismissSuggestion(
-                eq(mContext), eq(mSuggestionControllerMixin), nullable(Suggestion.class));
-        verify(mCallback).onSuggestionDismissed(nullable(Suggestion.class));
-    }
-}
diff --git a/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionFeatureProviderImplTest.java b/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionFeatureProviderImplTest.java
index 54af308..e9c8805 100644
--- a/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionFeatureProviderImplTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionFeatureProviderImplTest.java
@@ -114,13 +114,13 @@
     public void isSuggestionEnabled_isLowMemoryDevice_shouldReturnFalse() {
         when(mActivityManager.isLowRamDevice()).thenReturn(true);
 
-        assertThat(mProvider.isSuggestionV2Enabled(mContext)).isFalse();
+        assertThat(mProvider.isSuggestionEnabled(mContext)).isFalse();
     }
 
     @Test
     public void isSuggestionV2Enabled_isNotLowMemoryDevice_shouldReturnTrue() {
         when(mActivityManager.isLowRamDevice()).thenReturn(false);
-        assertThat(mProvider.isSuggestionV2Enabled(mContext)).isTrue();
+        assertThat(mProvider.isSuggestionEnabled(mContext)).isTrue();
     }
 
     @Test
diff --git a/tests/robotests/src/com/android/settings/datausage/AppDataUsageTest.java b/tests/robotests/src/com/android/settings/datausage/AppDataUsageTest.java
index 7cd09de..58643b6 100644
--- a/tests/robotests/src/com/android/settings/datausage/AppDataUsageTest.java
+++ b/tests/robotests/src/com/android/settings/datausage/AppDataUsageTest.java
@@ -29,8 +29,8 @@
 import static org.mockito.Mockito.when;
 
 import android.content.pm.PackageManager;
+import android.net.NetworkPolicyManager;
 import android.os.Bundle;
-import android.support.v14.preference.SwitchPreference;
 import android.support.v7.preference.PreferenceManager;
 import android.support.v7.preference.PreferenceScreen;
 import android.util.ArraySet;
@@ -40,8 +40,11 @@
 import com.android.settings.testutils.FakeFeatureFactory;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
 import com.android.settings.testutils.shadow.ShadowEntityHeaderController;
+import com.android.settings.testutils.shadow.ShadowRestrictedLockUtils;
 import com.android.settings.widget.EntityHeaderController;
 import com.android.settingslib.AppItem;
+import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
+import com.android.settingslib.RestrictedSwitchPreference;
 import com.android.settingslib.wrapper.PackageManagerWrapper;
 
 import org.junit.After;
@@ -57,7 +60,10 @@
 
 @RunWith(SettingsRobolectricTestRunner.class)
 @Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
-        shadows = ShadowEntityHeaderController.class)
+        shadows = {
+                ShadowEntityHeaderController.class,
+                ShadowRestrictedLockUtils.class
+        })
 public class AppDataUsageTest {
 
     @Mock(answer = Answers.RETURNS_DEEP_STUBS)
@@ -134,7 +140,7 @@
     public void changePreference_backgroundData_shouldUpdateUI() {
         mFragment = spy(new AppDataUsage());
         final AppItem appItem = new AppItem(123456789);
-        final SwitchPreference pref = mock(SwitchPreference.class);
+        final RestrictedSwitchPreference pref = mock(RestrictedSwitchPreference.class);
         final DataSaverBackend dataSaverBackend = mock(DataSaverBackend.class);
         ReflectionHelpers.setField(mFragment, "mAppItem", appItem);
         ReflectionHelpers.setField(mFragment, "mRestrictBackground", pref);
@@ -146,4 +152,31 @@
 
         verify(mFragment).updatePrefs();
     }
+
+    @Test
+    public void updatePrefs_restrictedByAdmin_shouldDisablePreference() {
+        mFragment = spy(new AppDataUsage());
+        final int testUid = 123123;
+        final AppItem appItem = new AppItem(testUid);
+        final RestrictedSwitchPreference restrictBackgroundPref
+                = mock(RestrictedSwitchPreference.class);
+        final RestrictedSwitchPreference unrestrictedDataPref
+                = mock(RestrictedSwitchPreference.class);
+        final DataSaverBackend dataSaverBackend = mock(DataSaverBackend.class);
+        final NetworkPolicyManager networkPolicyManager = mock(NetworkPolicyManager.class);
+        ReflectionHelpers.setField(mFragment, "mAppItem", appItem);
+        ReflectionHelpers.setField(mFragment, "mRestrictBackground", restrictBackgroundPref);
+        ReflectionHelpers.setField(mFragment, "mUnrestrictedData", unrestrictedDataPref);
+        ReflectionHelpers.setField(mFragment, "mDataSaverBackend", dataSaverBackend);
+        ReflectionHelpers.setField(mFragment.services, "mPolicyManager", networkPolicyManager);
+
+        ShadowRestrictedLockUtils.setRestricted(true);
+        doReturn(NetworkPolicyManager.POLICY_NONE).when(networkPolicyManager)
+                .getUidPolicy(testUid);
+
+        mFragment.updatePrefs();
+
+        verify(restrictBackgroundPref).setDisabledByAdmin(any(EnforcedAdmin.class));
+        verify(unrestrictedDataPref).setDisabledByAdmin(any(EnforcedAdmin.class));
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/datausage/UnrestrictedDataAccessTest.java b/tests/robotests/src/com/android/settings/datausage/UnrestrictedDataAccessTest.java
index 53cb7ed..fff879f 100644
--- a/tests/robotests/src/com/android/settings/datausage/UnrestrictedDataAccessTest.java
+++ b/tests/robotests/src/com/android/settings/datausage/UnrestrictedDataAccessTest.java
@@ -16,41 +16,68 @@
 package com.android.settings.datausage;
 
 import static com.google.common.truth.Truth.assertThat;
+
+import static org.junit.Assert.fail;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyBoolean;
 import static org.mockito.ArgumentMatchers.nullable;
 import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.verify;
 
 import android.content.Context;
 import android.content.pm.ApplicationInfo;
 import android.os.Process;
+import android.support.v7.preference.PreferenceManager;
+import android.support.v7.preference.PreferenceScreen;
 
 import com.android.internal.logging.nano.MetricsProto;
+import com.android.settings.R;
 import com.android.settings.TestConfig;
+import com.android.settings.datausage.AppStateDataUsageBridge.DataUsageState;
+import com.android.settings.datausage.UnrestrictedDataAccess.AccessPreference;
 import com.android.settings.testutils.FakeFeatureFactory;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settingslib.applications.ApplicationsState;
+import com.android.settings.testutils.shadow.ShadowRestrictedLockUtils;
+import com.android.settingslib.applications.ApplicationsState.AppEntry;
 
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
 import org.robolectric.annotation.Config;
+import org.robolectric.util.ReflectionHelpers;
+
+import java.util.ArrayList;
 
 @RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
+        shadows = {
+                ShadowRestrictedLockUtils.class
+        })
 public class UnrestrictedDataAccessTest {
 
     @Mock
-    private ApplicationsState.AppEntry mAppEntry;
+    private AppEntry mAppEntry;
     private UnrestrictedDataAccess mFragment;
     private FakeFeatureFactory mFeatureFactory;
+    @Mock
+    private PreferenceScreen mPreferenceScreen;
+    @Mock
+    private PreferenceManager mPreferenceManager;
+    @Mock
+    private DataSaverBackend mDataSaverBackend;
 
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
         mFeatureFactory = FakeFeatureFactory.setupForTest();
-        mFragment = new UnrestrictedDataAccess();
+        mFragment = spy(new UnrestrictedDataAccess());
     }
 
     @Test
@@ -80,4 +107,66 @@
                 eq(MetricsProto.MetricsEvent.APP_SPECIAL_PERMISSION_UNL_DATA_DENY), eq("app"));
     }
 
+    @Test
+    public void testOnRebuildComplete_restricted_shouldBeDisabled() {
+        final Context context = RuntimeEnvironment.application;
+        doReturn(context).when(mFragment).getContext();
+        doReturn(context).when(mPreferenceManager).getContext();
+        doReturn(true).when(mFragment).shouldAddPreference(any(AppEntry.class));
+        doNothing().when(mFragment).setLoading(anyBoolean(), anyBoolean());
+        doReturn(mPreferenceScreen).when(mFragment).getPreferenceScreen();
+        doReturn(mPreferenceManager).when(mFragment).getPreferenceManager();
+        ReflectionHelpers.setField(mFragment, "mDataSaverBackend", mDataSaverBackend);
+
+        final String testPkg1 = "com.example.one";
+        final String testPkg2 = "com.example.two";
+        ShadowRestrictedLockUtils.setRestrictedPkgs(testPkg2);
+
+        doAnswer((invocation) -> {
+            final AccessPreference preference = invocation.getArgument(0);
+            final AppEntry entry = preference.getEntryForTest();
+            // Verify preference is disabled by admin and the summary is changed accordingly.
+            if (testPkg1.equals(entry.info.packageName)) {
+                assertThat(preference.isDisabledByAdmin()).isFalse();
+                assertThat(preference.getSummary()).isEqualTo("");
+            } else if (testPkg2.equals(entry.info.packageName)) {
+                assertThat(preference.isDisabledByAdmin()).isTrue();
+                assertThat(preference.getSummary()).isEqualTo(
+                        context.getString(R.string.disabled_by_admin));
+            }
+            assertThat(preference.isChecked()).isFalse();
+            preference.performClick();
+            // Verify that when the preference is clicked, support details intent is launched
+            // if the preference is disabled by admin, otherwise the switch is toggled.
+            if (testPkg1.equals(entry.info.packageName)) {
+                assertThat(preference.isChecked()).isTrue();
+                assertThat(ShadowRestrictedLockUtils.hasAdminSupportDetailsIntentLaunched())
+                        .isFalse();
+            } else if (testPkg2.equals(entry.info.packageName)) {
+                assertThat(preference.isChecked()).isFalse();
+                assertThat(ShadowRestrictedLockUtils.hasAdminSupportDetailsIntentLaunched())
+                        .isTrue();
+            }
+            ShadowRestrictedLockUtils.clearAdminSupportDetailsIntentLaunch();
+            return null;
+        }).when(mPreferenceScreen).addPreference(any(AccessPreference.class));
+        mFragment.onRebuildComplete(createAppEntries(testPkg1, testPkg2));
+    }
+
+    private ArrayList<AppEntry> createAppEntries(String... packageNames) {
+        final ArrayList<AppEntry> appEntries = new ArrayList<>();
+        for (int i = 0; i < packageNames.length; ++i) {
+            final ApplicationInfo info = new ApplicationInfo();
+            info.packageName = packageNames[i];
+            info.uid = Process.FIRST_APPLICATION_UID + i;
+            info.sourceDir = info.packageName;
+            final AppEntry appEntry = spy(new AppEntry(RuntimeEnvironment.application,
+                    info, i));
+            appEntry.extraInfo = new DataUsageState(false, false);
+            doNothing().when(appEntry).ensureLabel(any(Context.class));
+            ReflectionHelpers.setField(appEntry, "info", info);
+            appEntries.add(appEntry);
+        }
+        return appEntries;
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/development/SelectUsbConfigPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/SelectUsbConfigPreferenceControllerTest.java
index 8719bb4..67a6d6b 100644
--- a/tests/robotests/src/com/android/settings/development/SelectUsbConfigPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/SelectUsbConfigPreferenceControllerTest.java
@@ -25,6 +25,7 @@
 
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyBoolean;
+import static org.mockito.ArgumentMatchers.anyLong;
 import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.doReturn;
@@ -37,11 +38,13 @@
 import android.content.Context;
 import android.content.pm.PackageManager;
 import android.hardware.usb.UsbManager;
+import android.hardware.usb.UsbManagerExtras;
 import android.support.v7.preference.ListPreference;
 import android.support.v7.preference.PreferenceScreen;
 
 import com.android.settings.R;
 import com.android.settings.TestConfig;
+import com.android.settings.connecteddevice.usb.UsbBackend;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
 import com.android.settings.testutils.shadow.ShadowUtils;
 import com.android.settingslib.core.lifecycle.Lifecycle;
@@ -69,6 +72,8 @@
     private UsbManager mUsbManager;
     @Mock
     private PackageManager mPackageManager;
+    @Mock
+    private UsbBackend.UsbManagerPassThrough mUsbManagerPassThrough;
 
     private Context mContext;
     private LifecycleOwner mLifecycleOwner;
@@ -101,6 +106,13 @@
         mController = spy(new SelectUsbConfigPreferenceController(mContext, mLifecycle));
         when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
         mController.displayPreference(mScreen);
+        mController.mUsbManagerPassThrough = mUsbManagerPassThrough;
+
+        when(mUsbManagerPassThrough.usbFunctionsFromString("mtp")).thenReturn(UsbManagerExtras.MTP);
+        when(mUsbManagerPassThrough.usbFunctionsFromString("rndis"))
+                .thenReturn(UsbManagerExtras.RNDIS);
+        when(mUsbManagerPassThrough.usbFunctionsFromString("none"))
+                .thenReturn(UsbManagerExtras.NONE);
 
     }
 
@@ -111,11 +123,13 @@
 
     @Test
     public void onPreferenceChange_setCharging_shouldEnableCharging() {
-        when(mUsbManager.isFunctionEnabled(mValues[0])).thenReturn(true);
-        doNothing().when(mController).setCurrentFunction(anyString(), anyBoolean());
+        when(mUsbManagerPassThrough.getCurrentFunctions()).thenReturn(
+                UsbManagerExtras.usbFunctionsFromString(mValues[0]));
+        doNothing().when(mController).setCurrentFunctions(anyLong());
         mController.onPreferenceChange(mPreference, mValues[0]);
 
-        verify(mController).setCurrentFunction(mValues[0], false /* usb data unlock */);
+        verify(mController).setCurrentFunctions(
+                UsbManagerExtras.usbFunctionsFromString(mValues[0]));
     }
 
     @Test
@@ -144,28 +158,32 @@
 
     @Test
     public void onPreferenceChange_setMtp_shouldEnableMtp() {
-        when(mUsbManager.isFunctionEnabled(mValues[1])).thenReturn(true);
-        doNothing().when(mController).setCurrentFunction(anyString(), anyBoolean());
+        when(mUsbManagerPassThrough.getCurrentFunctions())
+                .thenReturn(UsbManagerExtras.usbFunctionsFromString(mValues[1]));
+        doNothing().when(mController).setCurrentFunctions(anyLong());
         mController.onPreferenceChange(mPreference, mValues[1]);
 
-        verify(mController).setCurrentFunction(mValues[1], true /* usb data unlock */);
+        verify(mController).setCurrentFunctions(
+                UsbManagerExtras.usbFunctionsFromString(mValues[1]));
     }
 
     @Test
     public void onPreferenceChange_monkeyUser_shouldReturnFalse() {
-        when(mUsbManager.isFunctionEnabled(mValues[1])).thenReturn(true);
+        when(mUsbManagerPassThrough.getCurrentFunctions())
+                .thenReturn(UsbManagerExtras.usbFunctionsFromString(mValues[1]));
         ShadowUtils.setIsUserAMonkey(true);
-        doNothing().when(mController).setCurrentFunction(anyString(), anyBoolean());
+        doNothing().when(mController).setCurrentFunctions(anyLong());
 
         final boolean isHandled = mController.onPreferenceChange(mPreference, mValues[1]);
 
         assertThat(isHandled).isFalse();
-        verify(mController, never()).setCurrentFunction(any(), anyBoolean());
+        verify(mController, never()).setCurrentFunctions(anyLong());
     }
 
     @Test
     public void updateState_chargingEnabled_shouldSetPreferenceToCharging() {
-        when(mUsbManager.isFunctionEnabled(mValues[0])).thenReturn(true);
+        when(mUsbManagerPassThrough.getCurrentFunctions())
+                .thenReturn(UsbManagerExtras.usbFunctionsFromString(mValues[0]));
 
         mController.updateState(mPreference);
 
@@ -175,7 +193,8 @@
 
     @Test
     public void updateState_RndisEnabled_shouldEnableRndis() {
-        when(mUsbManager.isFunctionEnabled(mValues[3])).thenReturn(true);
+        when(mUsbManagerPassThrough.getCurrentFunctions())
+                .thenReturn(UsbManagerExtras.usbFunctionsFromString(mValues[3]));
 
         mController.updateState(mPreference);
 
@@ -185,6 +204,7 @@
 
     @Test
     public void updateState_noValueSet_shouldEnableChargingAsDefault() {
+        when(mUsbManagerPassThrough.getCurrentFunctions()).thenReturn(UsbManagerExtras.NONE);
         mController.updateState(mPreference);
 
         verify(mPreference).setValue(mValues[0]);
diff --git a/tests/robotests/src/com/android/settings/display/BrightnessLevelPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/BrightnessLevelPreferenceControllerTest.java
index 95144bd..f1cf79e 100644
--- a/tests/robotests/src/com/android/settings/display/BrightnessLevelPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/BrightnessLevelPreferenceControllerTest.java
@@ -90,8 +90,6 @@
         controller.onStart();
 
         assertThat(shadowContentResolver.getContentObservers(
-            System.getUriFor(System.SCREEN_BRIGHTNESS_MODE))).isNotEmpty();
-        assertThat(shadowContentResolver.getContentObservers(
             System.getUriFor(System.SCREEN_BRIGHTNESS))).isNotEmpty();
         assertThat(shadowContentResolver.getContentObservers(
             System.getUriFor(System.SCREEN_BRIGHTNESS_FOR_VR))).isNotEmpty();
@@ -111,8 +109,6 @@
         controller.onStop();
 
         assertThat(shadowContentResolver.getContentObservers(
-            System.getUriFor(System.SCREEN_BRIGHTNESS_MODE))).isEmpty();
-        assertThat(shadowContentResolver.getContentObservers(
             System.getUriFor(System.SCREEN_BRIGHTNESS))).isEmpty();
         assertThat(shadowContentResolver.getContentObservers(
             System.getUriFor(System.SCREEN_BRIGHTNESS_FOR_VR))).isEmpty();
@@ -136,11 +132,11 @@
         System.putInt(mContentResolver, System.SCREEN_BRIGHTNESS_MODE,
             System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC);
 
-        System.putFloat(mContentResolver, System.SCREEN_AUTO_BRIGHTNESS_ADJ, 0.0f);
+        System.putInt(mContentResolver, System.SCREEN_BRIGHTNESS, 31);
 
         mController.updateState(mPreference);
 
-        verify(mPreference).setSummary("50%");
+        verify(mPreference).setSummary("31%");
     }
 
     @Test
@@ -175,11 +171,11 @@
                 System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC);
 
         reset(mPreference);
-        System.putFloat(mContentResolver, System.SCREEN_AUTO_BRIGHTNESS_ADJ, 1.5f);
+        System.putInt(mContentResolver, System.SCREEN_BRIGHTNESS, 115);
         mController.updateState(mPreference);
         verify(mPreference).setSummary("100%");
 
-        System.putFloat(mContentResolver, System.SCREEN_AUTO_BRIGHTNESS_ADJ, -1.5f);
+        System.putInt(mContentResolver, System.SCREEN_BRIGHTNESS, -10);
         mController.updateState(mPreference);
         verify(mPreference).setSummary("0%");
 
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryLegacyTest.java b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryLegacyTest.java
index 45448a9..e707ede 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryLegacyTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryLegacyTest.java
@@ -15,8 +15,8 @@
  */
 package com.android.settings.fuelgauge;
 
-import static com.android.settings.fuelgauge.PowerUsageSummary.MENU_HIGH_POWER_APPS;
-import static com.android.settings.fuelgauge.PowerUsageSummary.MENU_TOGGLE_APPS;
+import static com.android.settings.fuelgauge.PowerUsageSummaryLegacy.MENU_HIGH_POWER_APPS;
+import static com.android.settings.fuelgauge.PowerUsageSummaryLegacy.MENU_TOGGLE_APPS;
 import static com.google.common.truth.Truth.assertThat;
 import static org.mockito.Matchers.any;
 import static org.mockito.Matchers.anyInt;
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryTest.java b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryTest.java
index 6fecf3c..35af8bb 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryTest.java
@@ -16,7 +16,6 @@
 package com.android.settings.fuelgauge;
 
 import static com.android.settings.fuelgauge.PowerUsageSummary.MENU_HIGH_POWER_APPS;
-import static com.android.settings.fuelgauge.PowerUsageSummary.MENU_TOGGLE_APPS;
 
 import static com.google.common.truth.Truth.assertThat;
 
@@ -170,7 +169,6 @@
         doReturn(mock(LoaderManager.class)).when(mFragment).getLoaderManager();
 
         when(mFragment.getActivity()).thenReturn(mSettingsActivity);
-        when(mToggleAppsMenu.getItemId()).thenReturn(MENU_TOGGLE_APPS);
         when(mHighPowerMenu.getItemId()).thenReturn(MENU_HIGH_POWER_APPS);
         when(mFeatureFactory.powerUsageFeatureProvider.getAdditionalBatteryInfoIntent())
                 .thenReturn(sAdditionalBatteryInfoIntent);
@@ -215,39 +213,6 @@
     }
 
     @Test
-    public void testOptionsMenu_menuAppToggle_metricEventInvoked() {
-        mFragment.onOptionsItemSelected(mToggleAppsMenu);
-        mFragment.mShowAllApps = false;
-
-        verify(mFeatureFactory.metricsFeatureProvider).action(mContext,
-                MetricsProto.MetricsEvent.ACTION_SETTINGS_MENU_BATTERY_APPS_TOGGLE, true);
-    }
-
-    @Test
-    public void testOptionsMenu_toggleAppsEnabled() {
-        when(mFeatureFactory.powerUsageFeatureProvider.isPowerAccountingToggleEnabled())
-                .thenReturn(true);
-        mFragment.mShowAllApps = false;
-
-        mFragment.onCreateOptionsMenu(mMenu, mMenuInflater);
-
-        verify(mMenu).add(Menu.NONE, MENU_TOGGLE_APPS, Menu.NONE, R.string.show_all_apps);
-    }
-
-    @Test
-    public void testOptionsMenu_clickToggleAppsMenu_dataChanged() {
-        testToggleAllApps(true);
-        testToggleAllApps(false);
-    }
-
-    private void testToggleAllApps(final boolean isShowApps) {
-        mFragment.mShowAllApps = isShowApps;
-
-        mFragment.onOptionsItemSelected(mToggleAppsMenu);
-        assertThat(mFragment.mShowAllApps).isEqualTo(!isShowApps);
-    }
-
-    @Test
     public void testUpdateLastFullChargePreference_showCorrectSummary() {
         doReturn(mRealContext).when(mFragment).getContext();
 
@@ -324,18 +289,6 @@
     }
 
     @Test
-    public void testSaveInstanceState_showAllAppsRestored() {
-        Bundle bundle = new Bundle();
-        mFragment.mShowAllApps = true;
-        doReturn(mPreferenceScreen).when(mFragment).getPreferenceScreen();
-
-        mFragment.onSaveInstanceState(bundle);
-        mFragment.restoreSavedInstance(bundle);
-
-        assertThat(mFragment.mShowAllApps).isTrue();
-    }
-
-    @Test
     public void testDebugMode() {
         doReturn(true).when(mFeatureFactory.powerUsageFeatureProvider).isEstimateDebugEnabled();
 
diff --git a/tests/robotests/src/com/android/settings/location/RecentLocationRequestPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/location/RecentLocationRequestPreferenceControllerTest.java
index f114ff3..7f495ab 100644
--- a/tests/robotests/src/com/android/settings/location/RecentLocationRequestPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/location/RecentLocationRequestPreferenceControllerTest.java
@@ -33,14 +33,11 @@
 import android.support.v7.preference.PreferenceCategory;
 import android.support.v7.preference.PreferenceScreen;
 import android.text.TextUtils;
-import android.util.FeatureFlagUtils;
 
 import com.android.settings.R;
 import com.android.settings.SettingsActivity;
 import com.android.settings.TestConfig;
-import com.android.settings.applications.InstalledAppDetails;
 import com.android.settings.applications.appinfo.AppInfoDashboardFragment;
-import com.android.settings.core.FeatureFlags;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
 import com.android.settings.widget.AppPreference;
 import com.android.settingslib.core.lifecycle.Lifecycle;
@@ -179,15 +176,9 @@
 
         preference.performClick();
 
-        if (FeatureFlagUtils.isEnabled(mContext, FeatureFlags.APP_INFO_V2)) {
-            verify(activity).startPreferencePanelAsUser(any(),
-                    eq(AppInfoDashboardFragment.class.getName()),
-                    any(Bundle.class), anyInt(), any(), any());
-        } else {
-            verify(activity).startPreferencePanelAsUser(any(),
-                    eq(InstalledAppDetails.class.getName()),
-                    any(Bundle.class), anyInt(), any(), any());
-        }
+        verify(activity).startPreferencePanelAsUser(any(),
+            eq(AppInfoDashboardFragment.class.getName()),
+            any(Bundle.class), anyInt(), any(), any());
     }
 
     private static ArgumentMatcher<Preference> titleMatches(String expected) {
diff --git a/tests/robotests/src/com/android/settings/notification/DeletedChannelsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/DeletedChannelsPreferenceControllerTest.java
index fd903f9..0d8b430 100644
--- a/tests/robotests/src/com/android/settings/notification/DeletedChannelsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/DeletedChannelsPreferenceControllerTest.java
@@ -119,7 +119,6 @@
         Preference pref = mock(Preference.class);
         mController.updateState(pref);
 
-        verify(pref, times(1)).setEnabled(false);
         verify(pref, times(1)).setSelectable(false);
         verify(mBackend, times(1)).getDeletedChannelCount(any(), anyInt());
         ArgumentCaptor<CharSequence> argumentCaptor = ArgumentCaptor.forClass(CharSequence.class);
diff --git a/tests/robotests/src/com/android/settings/notification/ImportancePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/ImportancePreferenceControllerTest.java
index 0065e30..229a212 100644
--- a/tests/robotests/src/com/android/settings/notification/ImportancePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/ImportancePreferenceControllerTest.java
@@ -21,6 +21,7 @@
 import static android.app.NotificationManager.IMPORTANCE_LOW;
 import static android.app.NotificationManager.IMPORTANCE_NONE;
 
+import static junit.framework.Assert.assertEquals;
 import static junit.framework.Assert.assertFalse;
 import static junit.framework.Assert.assertNull;
 import static junit.framework.Assert.assertTrue;
@@ -30,13 +31,16 @@
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.when;
 
+import android.app.Notification;
 import android.app.NotificationChannel;
 import android.app.NotificationManager;
 import android.content.Context;
 import android.os.UserManager;
 import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceScreen;
 import android.text.TextUtils;
 
+import com.android.settings.RestrictedListPreference;
 import com.android.settings.TestConfig;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
 import com.android.settingslib.RestrictedLockUtils;
@@ -44,6 +48,7 @@
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.mockito.Answers;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 import org.robolectric.RuntimeEnvironment;
@@ -58,7 +63,13 @@
     @Mock
     private NotificationManager mNm;
     @Mock
+    private NotificationBackend mBackend;
+    @Mock
+    NotificationSettingsBase.ImportanceListener mImportanceListener;
+    @Mock
     private UserManager mUm;
+    @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+    private PreferenceScreen mScreen;
 
     private ImportancePreferenceController mController;
 
@@ -69,7 +80,8 @@
         shadowApplication.setSystemService(Context.NOTIFICATION_SERVICE, mNm);
         shadowApplication.setSystemService(Context.USER_SERVICE, mUm);
         mContext = shadowApplication.getApplicationContext();
-        mController = spy(new ImportancePreferenceController(mContext));
+        mController = spy(new ImportancePreferenceController(
+                mContext, mImportanceListener, mBackend));
     }
 
     @Test
@@ -123,14 +135,15 @@
     @Test
     public void testUpdateState_disabledByAdmin() throws Exception {
         NotificationChannel channel = mock(NotificationChannel.class);
+        when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
         mController.onResume(new NotificationBackend.AppRow(), channel, null, mock(
                 RestrictedLockUtils.EnforcedAdmin.class));
 
-        Preference pref = new Preference(RuntimeEnvironment.application);
+        Preference pref = new RestrictedListPreference(RuntimeEnvironment.application, null);
         mController.updateState(pref);
 
         assertFalse(pref.isEnabled());
-        assertNull(pref.getIntent());
+        assertFalse(TextUtils.isEmpty(pref.getSummary()));
     }
 
     @Test
@@ -140,13 +153,14 @@
         appRow.lockedChannelId = lockedId;
         NotificationChannel channel = mock(NotificationChannel.class);
         when(channel.getId()).thenReturn(lockedId);
+        when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
         mController.onResume(appRow, channel, null, null);
 
-        Preference pref = new Preference(RuntimeEnvironment.application);
+        Preference pref = new RestrictedListPreference(RuntimeEnvironment.application, null);
         mController.updateState(pref);
 
         assertFalse(pref.isEnabled());
-        assertNull(pref.getIntent());
+        assertFalse(TextUtils.isEmpty(pref.getSummary()));
     }
 
     @Test
@@ -155,11 +169,50 @@
         NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_HIGH);
         mController.onResume(appRow, channel, null, null);
 
-        Preference pref = new Preference(RuntimeEnvironment.application);
+        Preference pref = new RestrictedListPreference(RuntimeEnvironment.application, null);
         mController.updateState(pref);
 
         assertTrue(pref.isEnabled());
-        assertNotNull(pref.getIntent());
         assertFalse(TextUtils.isEmpty(pref.getSummary()));
     }
+    
+    @Test
+    public void testImportanceLowToHigh() {
+        NotificationChannel channel =
+                new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_LOW);
+        channel.setSound(null, Notification.AUDIO_ATTRIBUTES_DEFAULT);
+        mController.onResume(new NotificationBackend.AppRow(), channel, null, null);
+
+        RestrictedListPreference pref =
+                new RestrictedListPreference(RuntimeEnvironment.application, null);
+        when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
+        mController.displayPreference(mScreen);
+        mController.updateState(pref);
+
+        pref.setValue(String.valueOf(IMPORTANCE_HIGH));
+        mController.onPreferenceChange(pref, pref.getValue());
+
+        assertEquals(IMPORTANCE_HIGH, channel.getImportance());
+        assertNotNull(channel.getSound());
+    }
+
+    @Test
+    public void testImportanceHightToLow() {
+        NotificationChannel channel =
+                new NotificationChannel(DEFAULT_CHANNEL_ID, "a", IMPORTANCE_HIGH);
+        channel.setSound(null, Notification.AUDIO_ATTRIBUTES_DEFAULT);
+        mController.onResume(new NotificationBackend.AppRow(), channel, null, null);
+
+        RestrictedListPreference pref =
+                new RestrictedListPreference(RuntimeEnvironment.application, null);
+        when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
+        mController.displayPreference(mScreen);
+        mController.updateState(pref);
+
+        pref.setValue(String.valueOf(IMPORTANCE_LOW));
+        mController.onPreferenceChange(pref, pref.getValue());
+
+        assertEquals(IMPORTANCE_LOW, channel.getImportance());
+        assertNull(channel.getSound());
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/notification/NotificationsOffPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/NotificationsOffPreferenceControllerTest.java
index 654d90c..82ef6fd 100644
--- a/tests/robotests/src/com/android/settings/notification/NotificationsOffPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/NotificationsOffPreferenceControllerTest.java
@@ -110,7 +110,6 @@
         mController.updateState(pref);
 
         assertTrue(pref.getTitle().toString().contains("category"));
-        assertFalse(pref.isEnabled());
         assertFalse(pref.isSelectable());
     }
 
@@ -125,7 +124,6 @@
         mController.updateState(pref);
 
         assertTrue(pref.getTitle().toString().contains("group"));
-        assertFalse(pref.isEnabled());
         assertFalse(pref.isSelectable());
     }
 
@@ -139,7 +137,6 @@
         mController.updateState(pref);
 
         assertTrue(pref.getTitle().toString().contains("app"));
-        assertFalse(pref.isEnabled());
         assertFalse(pref.isSelectable());
     }
 }
diff --git a/tests/robotests/src/com/android/settings/security/LockUnificationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/security/LockUnificationPreferenceControllerTest.java
index 7a5a9fa..2b612e1 100644
--- a/tests/robotests/src/com/android/settings/security/LockUnificationPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/security/LockUnificationPreferenceControllerTest.java
@@ -55,7 +55,7 @@
     @Mock
     private PreferenceScreen mScreen;
     @Mock
-    private SecuritySettingsV2 mHost;
+    private SecuritySettings mHost;
 
     private FakeFeatureFactory mFeatureFactory;
     private Context mContext;
diff --git a/tests/robotests/src/com/android/settings/security/SecurityFeatureProviderImplTest.java b/tests/robotests/src/com/android/settings/security/SecurityFeatureProviderImplTest.java
index 627ecf5..86ba40f 100644
--- a/tests/robotests/src/com/android/settings/security/SecurityFeatureProviderImplTest.java
+++ b/tests/robotests/src/com/android/settings/security/SecurityFeatureProviderImplTest.java
@@ -16,192 +16,51 @@
 
 package com.android.settings.security;
 
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyInt;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyNoMoreInteractions;
-import static org.mockito.Mockito.when;
+import static com.google.common.truth.Truth.assertThat;
 
 import android.content.Context;
-import android.content.Intent;
 import android.content.pm.PackageManager;
-import android.content.res.Resources;
-import android.graphics.drawable.Drawable;
-import android.os.Bundle;
-import android.support.v7.preference.Preference;
-import android.support.v7.preference.PreferenceScreen;
 
-import com.android.settings.R;
+import com.android.internal.widget.LockPatternUtils;
 import com.android.settings.TestConfig;
+import com.android.settings.security.trustagent.TrustAgentManager;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settings.testutils.shadow.ShadowTileUtils;
-import com.android.settingslib.drawer.DashboardCategory;
-import com.android.settingslib.drawer.Tile;
-import com.android.settingslib.drawer.TileUtils;
 
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 import org.robolectric.RuntimeEnvironment;
 import org.robolectric.annotation.Config;
-import org.robolectric.shadows.ShadowLooper;
 
 @RunWith(SettingsRobolectricTestRunner.class)
 @Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
 public class SecurityFeatureProviderImplTest {
 
-    private static final String MOCK_KEY = "key";
-    private static final String MOCK_SUMMARY = "summary";
-    private static final String URI_GET_SUMMARY = "content://package/text/summary";
-    private static final String URI_GET_ICON = "content://package/icon/my_icon";
-
-    @Mock
-    private Drawable mMockDrawable;
-    @Mock
     private Context mContext;
-    @Mock
-    private PackageManager mPackageManager;
-    @Mock
-    private Resources mResources;
-
     private SecurityFeatureProviderImpl mImpl;
 
     @Before
     public void setUp() throws PackageManager.NameNotFoundException {
         MockitoAnnotations.initMocks(this);
-        mContext = spy(RuntimeEnvironment.application);
+        mContext = RuntimeEnvironment.application;
         mImpl = new SecurityFeatureProviderImpl();
-        when(mContext.getPackageManager()).thenReturn(mPackageManager);
-        when(mPackageManager.getResourcesForApplication(anyString())).thenReturn(mResources);
-        when(mResources.getDrawable(anyInt(), any())).thenReturn(mMockDrawable);
     }
 
     @Test
-    public void updateTilesData_shouldNotProcessEmptyScreenOrTiles() {
-        mImpl.updatePreferencesToRunOnWorkerThread(mContext, null, null);
-        ShadowLooper.runUiThreadTasks();
-        mImpl.updatePreferencesToRunOnWorkerThread(
-                mContext, new PreferenceScreen(mContext, null), null);
-        ShadowLooper.runUiThreadTasks();
-        verifyNoMoreInteractions(mPackageManager);
+    public void getTrustAgentManager_shouldReturnCache() {
+        final TrustAgentManager m1 = mImpl.getTrustAgentManager();
+        final TrustAgentManager m2 = mImpl.getTrustAgentManager();
+
+        assertThat(m1).isSameAs(m2);
     }
 
     @Test
-    public void updateTilesData_shouldNotProcessNonMatchingPreference() {
-        DashboardCategory dashboardCategory = new DashboardCategory();
-        dashboardCategory.addTile(new Tile());
-        mImpl.updatePreferencesToRunOnWorkerThread(
-                mContext, getPreferenceScreen(), dashboardCategory);
-        ShadowLooper.runUiThreadTasks();
-        verifyNoMoreInteractions(mPackageManager);
+    public void getLockPatternUtils_shouldReturnCache() {
+        final LockPatternUtils l1 = mImpl.getLockPatternUtils(mContext);
+        final LockPatternUtils l2 = mImpl.getLockPatternUtils(mContext);
+
+        assertThat(l1).isSameAs(l2);
     }
 
-    @Test
-    public void updateTilesData_shouldNotProcessMatchingPreferenceWithNoData() {
-        mImpl.updatePreferencesToRunOnWorkerThread(
-                mContext, getPreferenceScreen(), getDashboardCategory());
-        ShadowLooper.runUiThreadTasks();
-        verifyNoMoreInteractions(mPackageManager);
-    }
-
-    @Test
-    @Config(shadows = {
-            ShadowTileUtils.class,
-    })
-    public void updateTilesData_shouldUpdateMatchingPreference() {
-        Bundle bundle = new Bundle();
-        bundle.putString(TileUtils.META_DATA_PREFERENCE_ICON_URI, URI_GET_ICON);
-        bundle.putString(TileUtils.META_DATA_PREFERENCE_SUMMARY_URI, URI_GET_SUMMARY);
-
-        PreferenceScreen screen = getPreferenceScreen();
-        DashboardCategory dashboardCategory = getDashboardCategory();
-        dashboardCategory.getTile(0).intent = new Intent().setPackage("package");
-        dashboardCategory.getTile(0).metaData = bundle;
-
-        mImpl.updatePreferencesToRunOnWorkerThread(mContext, screen, dashboardCategory);
-        ShadowLooper.runUiThreadTasks();
-        verify(screen.findPreference(MOCK_KEY)).setIcon(mMockDrawable);
-        verify(screen.findPreference(MOCK_KEY)).setSummary(MOCK_SUMMARY);
-    }
-
-    @Test
-    @Config(shadows = {
-            ShadowTileUtils.class,
-    })
-    public void updateTilesData_shouldNotUpdateAlreadyUpdatedPreference() {
-        Bundle bundle = new Bundle();
-        bundle.putString(TileUtils.META_DATA_PREFERENCE_ICON_URI, URI_GET_ICON);
-        bundle.putString(TileUtils.META_DATA_PREFERENCE_SUMMARY_URI, URI_GET_SUMMARY);
-
-        PreferenceScreen screen = getPreferenceScreen();
-        when(screen.findPreference(MOCK_KEY).getSummary()).thenReturn(MOCK_SUMMARY);
-        when(screen.findPreference(MOCK_KEY).getIcon()).thenReturn(mMockDrawable);
-
-        DashboardCategory dashboardCategory = getDashboardCategory();
-        dashboardCategory.getTile(0).intent = new Intent().setPackage("package");
-        dashboardCategory.getTile(0).metaData = bundle;
-
-        mImpl.updatePreferencesToRunOnWorkerThread(mContext, screen, dashboardCategory);
-        ShadowLooper.runUiThreadTasks();
-        verify(screen.findPreference(MOCK_KEY), never()).setSummary(anyString());
-    }
-
-    @Test
-    public void initPreferences_shouldLoadDefaults() {
-        PreferenceScreen screen = getPreferenceScreen();
-        DashboardCategory dashboardCategory = getDashboardCategory();
-        dashboardCategory.getTile(0).metaData = new Bundle();
-
-        mImpl.initPreferences(mContext, screen, dashboardCategory);
-        verify(screen.findPreference(MOCK_KEY)).setIcon(SecurityFeatureProviderImpl.DEFAULT_ICON);
-        verify(screen.findPreference(MOCK_KEY))
-                .setSummary(mContext.getString(R.string.summary_placeholder));
-    }
-
-    @Test
-    @Config(shadows = {
-            ShadowTileUtils.class,
-    })
-    public void initPreferences_shouldLoadCached() {
-        Bundle bundle = new Bundle();
-        bundle.putString(TileUtils.META_DATA_PREFERENCE_ICON_URI, URI_GET_ICON);
-        bundle.putString(TileUtils.META_DATA_PREFERENCE_SUMMARY_URI, URI_GET_SUMMARY);
-
-        PreferenceScreen screen = getPreferenceScreen();
-        DashboardCategory dashboardCategory = getDashboardCategory();
-        dashboardCategory.getTile(0).metaData = bundle;
-
-        SecurityFeatureProviderImpl.sIconCache.put(
-                URI_GET_ICON,
-                ShadowTileUtils.getIconFromUri(null, null, null, null));
-        SecurityFeatureProviderImpl.sSummaryCache.put(
-                URI_GET_SUMMARY,
-                MOCK_SUMMARY);
-
-        mImpl.initPreferences(mContext, screen, dashboardCategory);
-        verify(screen.findPreference(MOCK_KEY)).setIcon(mMockDrawable);
-        verify(screen.findPreference(MOCK_KEY)).setSummary(MOCK_SUMMARY);
-    }
-
-    private PreferenceScreen getPreferenceScreen() {
-        final PreferenceScreen screen = mock(PreferenceScreen.class);
-        final Preference pref = mock(Preference.class);
-        when(screen.findPreference(MOCK_KEY)).thenReturn(pref);
-        when(pref.getKey()).thenReturn(MOCK_KEY);
-        return screen;
-    }
-
-    private static DashboardCategory getDashboardCategory() {
-        DashboardCategory dashboardCategory = new DashboardCategory();
-        Tile tile = new Tile();
-        tile.key = MOCK_KEY;
-        dashboardCategory.addTile(tile);
-        return dashboardCategory;
-    }
 }
diff --git a/tests/robotests/src/com/android/settings/security/SecuritySettingsTest.java b/tests/robotests/src/com/android/settings/security/SecuritySettingsTest.java
index 3171c3d..421efe8 100644
--- a/tests/robotests/src/com/android/settings/security/SecuritySettingsTest.java
+++ b/tests/robotests/src/com/android/settings/security/SecuritySettingsTest.java
@@ -16,34 +16,18 @@
 
 package com.android.settings.security;
 
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Matchers.anyInt;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.reset;
-import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
 import static org.mockito.Mockito.when;
 
-import android.app.Activity;
 import android.content.Context;
-import android.os.UserHandle;
-import android.os.UserManager;
-import android.os.UserManager.EnforcingUser;
-import android.support.v7.preference.Preference;
-import android.support.v7.preference.PreferenceScreen;
+import android.content.pm.PackageManager;
+import android.hardware.fingerprint.FingerprintManager;
 
-import com.android.internal.widget.LockPatternUtils;
 import com.android.settings.R;
 import com.android.settings.TestConfig;
 import com.android.settings.dashboard.SummaryLoader;
-import com.android.settings.testutils.FakeFeatureFactory;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settings.testutils.XmlTestUtils;
-import com.android.settings.testutils.shadow.ShadowLockPatternUtils;
-import com.android.settings.testutils.shadow.ShadowUserManager;
-import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
-import com.android.settingslib.RestrictedSwitchPreference;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -51,123 +35,65 @@
 import org.mockito.Answers;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
-import org.robolectric.RuntimeEnvironment;
 import org.robolectric.annotation.Config;
-import org.robolectric.shadows.ShadowApplication;
-import org.robolectric.util.ReflectionHelpers;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
 
 @RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
-        shadows = {
-                ShadowLockPatternUtils.class,
-                ShadowUserManager.class,
-        })
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
 public class SecuritySettingsTest {
 
-
     @Mock(answer = Answers.RETURNS_DEEP_STUBS)
     private Context mContext;
     @Mock
     private SummaryLoader mSummaryLoader;
-
+    @Mock
+    private FingerprintManager mFingerprintManager;
     private SecuritySettings.SummaryProvider mSummaryProvider;
 
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
-        FakeFeatureFactory.setupForTest();
+        when(mContext.getSystemService(Context.FINGERPRINT_SERVICE))
+                .thenReturn(mFingerprintManager);
+
         mSummaryProvider = new SecuritySettings.SummaryProvider(mContext, mSummaryLoader);
     }
 
     @Test
-    public void testInitTrustAgentPreference_secure_shouldSetSummaryToNumberOfTrustAgent() {
-        final Preference preference = mock(Preference.class);
-        final PreferenceScreen screen = mock(PreferenceScreen.class);
-        when(screen.findPreference(SecuritySettings.KEY_MANAGE_TRUST_AGENTS))
-                .thenReturn(preference);
-        final LockPatternUtils utils = mock(LockPatternUtils.class);
-        when(utils.isSecure(anyInt())).thenReturn(true);
-        final Context context = ShadowApplication.getInstance().getApplicationContext();
-        final Activity activity = mock(Activity.class);
-        when(activity.getResources()).thenReturn(context.getResources());
-        final SecuritySettings securitySettings = spy(new SecuritySettings());
-        when(securitySettings.getActivity()).thenReturn(activity);
+    public void testSummaryProvider_notListening() {
+        mSummaryProvider.setListening(false);
 
-        ReflectionHelpers.setField(securitySettings, "mLockPatternUtils", utils);
-
-        securitySettings.initTrustAgentPreference(screen, 0);
-        verify(preference).setSummary(R.string.manage_trust_agents_summary);
-
-        securitySettings.initTrustAgentPreference(screen, 2);
-        verify(preference).setSummary(context.getResources().getQuantityString(
-                R.plurals.manage_trust_agents_summary_on, 2, 2));
+        verifyNoMoreInteractions(mSummaryLoader);
     }
 
     @Test
-    public void testNonIndexableKeys_existInXmlLayout() {
-        final Context context = spy(RuntimeEnvironment.application);
-        UserManager manager = mock(UserManager.class);
-        when(manager.isAdminUser()).thenReturn(false);
-        doReturn(manager).when(context).getSystemService(Context.USER_SERVICE);
-        final List<String> niks = SecuritySettings.SEARCH_INDEX_DATA_PROVIDER
-                .getNonIndexableKeys(context);
+    public void testSummaryProvider_hasFingerPrint_hasStaticSummary() {
+        when(mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FINGERPRINT))
+                .thenReturn(true);
+        when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
 
-        final List<String> keys = XmlTestUtils.getKeysFromPreferenceXml(context,
-                R.xml.security_settings_misc);
-        keys.addAll(XmlTestUtils.getKeysFromPreferenceXml(context,
-                R.xml.location_settings));
-        keys.addAll(XmlTestUtils.getKeysFromPreferenceXml(context,
-                R.xml.encryption_and_credential));
+        mSummaryProvider.setListening(true);
 
-        assertThat(keys).containsAllIn(niks);
+        verify(mContext).getString(R.string.security_dashboard_summary);
     }
 
     @Test
-    public void testUnifyLockRestriction() {
-        // Set up instance under test.
-        final Context context = spy(RuntimeEnvironment.application);
-        final SecuritySettings securitySettings = spy(new SecuritySettings());
-        when(securitySettings.getContext()).thenReturn(context);
+    public void testSummaryProvider_noFpFeature_shouldSetSummaryWithNoFingerprint() {
+        when(mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FINGERPRINT))
+                .thenReturn(false);
 
-        final int userId = 123;
-        ReflectionHelpers.setField(securitySettings, "mProfileChallengeUserId", userId);
+        mSummaryProvider.setListening(true);
 
-        final LockPatternUtils utils = mock(LockPatternUtils.class);
-        when(utils.isSeparateProfileChallengeEnabled(userId)).thenReturn(true);
-        ReflectionHelpers.setField(securitySettings, "mLockPatternUtils", utils);
+        verify(mContext).getString(R.string.security_dashboard_summary_no_fingerprint);
+    }
 
-        final RestrictedSwitchPreference unifyProfile = mock(RestrictedSwitchPreference.class);
-        ReflectionHelpers.setField(securitySettings, "mUnifyProfile", unifyProfile);
+    @Test
+    public void testSummaryProvider_noFpHardware_shouldSetSummaryWithNoFingerprint() {
+        when(mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FINGERPRINT))
+                .thenReturn(true);
+        when(mFingerprintManager.isHardwareDetected()).thenReturn(false);
 
-        // Pretend that no admins enforce the restriction.
-        ShadowUserManager.getShadow().setUserRestrictionSources(
-                UserManager.DISALLOW_UNIFIED_PASSWORD,
-                UserHandle.of(userId),
-                Collections.emptyList());
+        mSummaryProvider.setListening(true);
 
-        securitySettings.updateUnificationPreference();
-
-        verify(unifyProfile).setDisabledByAdmin(null);
-
-        reset(unifyProfile);
-
-        // Pretend that the restriction is enforced by several admins. Having just one would
-        // require more mocking of implementation details.
-        final EnforcingUser enforcer1 = new EnforcingUser(
-                userId, UserManager.RESTRICTION_SOURCE_PROFILE_OWNER);
-        final EnforcingUser enforcer2 = new EnforcingUser(
-                UserHandle.USER_SYSTEM, UserManager.RESTRICTION_SOURCE_DEVICE_OWNER);
-        ShadowUserManager.getShadow().setUserRestrictionSources(
-                UserManager.DISALLOW_UNIFIED_PASSWORD,
-                UserHandle.of(userId),
-                Arrays.asList(enforcer1, enforcer2));
-
-        securitySettings.updateUnificationPreference();
-
-        verify(unifyProfile).setDisabledByAdmin(EnforcedAdmin.MULTIPLE_ENFORCED_ADMIN);
+        verify(mContext).getString(R.string.security_dashboard_summary_no_fingerprint);
     }
 }
diff --git a/tests/robotests/src/com/android/settings/security/SecuritySettingsV2Test.java b/tests/robotests/src/com/android/settings/security/SecuritySettingsV2Test.java
deleted file mode 100644
index f77903b..0000000
--- a/tests/robotests/src/com/android/settings/security/SecuritySettingsV2Test.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (C) 2018 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.security;
-
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyNoMoreInteractions;
-import static org.mockito.Mockito.when;
-
-import android.content.Context;
-import android.content.pm.PackageManager;
-import android.hardware.fingerprint.FingerprintManager;
-
-import com.android.settings.R;
-import com.android.settings.TestConfig;
-import com.android.settings.dashboard.SummaryLoader;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Answers;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.annotation.Config;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
-public class SecuritySettingsV2Test {
-
-    @Mock(answer = Answers.RETURNS_DEEP_STUBS)
-    private Context mContext;
-    @Mock
-    private SummaryLoader mSummaryLoader;
-    @Mock
-    private FingerprintManager mFingerprintManager;
-    private SecuritySettings.SummaryProvider mSummaryProvider;
-
-    @Before
-    public void setUp() {
-        MockitoAnnotations.initMocks(this);
-        when(mContext.getSystemService(Context.FINGERPRINT_SERVICE))
-                .thenReturn(mFingerprintManager);
-
-        mSummaryProvider = new SecuritySettings.SummaryProvider(mContext, mSummaryLoader);
-    }
-
-    @Test
-    public void testSummaryProvider_notListening() {
-        mSummaryProvider.setListening(false);
-
-        verifyNoMoreInteractions(mSummaryLoader);
-    }
-
-    @Test
-    public void testSummaryProvider_hasFingerPrint_hasStaticSummary() {
-        when(mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FINGERPRINT))
-                .thenReturn(true);
-        when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
-
-        mSummaryProvider.setListening(true);
-
-        verify(mContext).getString(R.string.security_dashboard_summary);
-    }
-
-    @Test
-    public void testSummaryProvider_noFpFeature_shouldSetSummaryWithNoFingerprint() {
-        when(mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FINGERPRINT))
-                .thenReturn(false);
-
-        mSummaryProvider.setListening(true);
-
-        verify(mContext).getString(R.string.security_dashboard_summary_no_fingerprint);
-    }
-
-    @Test
-    public void testSummaryProvider_noFpHardware_shouldSetSummaryWithNoFingerprint() {
-        when(mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FINGERPRINT))
-                .thenReturn(true);
-        when(mFingerprintManager.isHardwareDetected()).thenReturn(false);
-
-        mSummaryProvider.setListening(true);
-
-        verify(mContext).getString(R.string.security_dashboard_summary_no_fingerprint);
-    }
-}
diff --git a/tests/robotests/src/com/android/settings/security/trustagent/TrustAgentListPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/security/trustagent/TrustAgentListPreferenceControllerTest.java
index 7dd04c6..258833e 100644
--- a/tests/robotests/src/com/android/settings/security/trustagent/TrustAgentListPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/security/trustagent/TrustAgentListPreferenceControllerTest.java
@@ -40,7 +40,7 @@
 import com.android.internal.widget.LockPatternUtils;
 import com.android.settings.TestConfig;
 import com.android.settings.core.PreferenceControllerMixin;
-import com.android.settings.security.SecuritySettingsV2;
+import com.android.settings.security.SecuritySettings;
 import com.android.settings.testutils.FakeFeatureFactory;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
 import com.android.settingslib.core.lifecycle.Lifecycle;
@@ -69,7 +69,7 @@
     @Mock
     private PreferenceCategory mCategory;
     @Mock
-    private SecuritySettingsV2 mFragment;
+    private SecuritySettings mFragment;
 
     private Lifecycle mLifecycle;
     private LifecycleOwner mLifecycleOwner;
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/AdditionalSystemUpdatePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/system/AdditionalSystemUpdatePreferenceControllerTest.java
similarity index 94%
rename from tests/robotests/src/com/android/settings/deviceinfo/AdditionalSystemUpdatePreferenceControllerTest.java
rename to tests/robotests/src/com/android/settings/system/AdditionalSystemUpdatePreferenceControllerTest.java
index e5708ba..43f48c0 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/AdditionalSystemUpdatePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/system/AdditionalSystemUpdatePreferenceControllerTest.java
@@ -13,20 +13,18 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.android.settings.deviceinfo;
+package com.android.settings.system;
 
 import static com.google.common.truth.Truth.assertThat;
 
 import android.content.Context;
 
-import com.android.settings.R;
 import com.android.settings.TestConfig;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
 
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 import org.robolectric.RuntimeEnvironment;
 import org.robolectric.annotation.Config;
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/SystemUpdatePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/system/SystemUpdatePreferenceControllerTest.java
similarity index 64%
rename from tests/robotests/src/com/android/settings/deviceinfo/SystemUpdatePreferenceControllerTest.java
rename to tests/robotests/src/com/android/settings/system/SystemUpdatePreferenceControllerTest.java
index b5b84da..95a18a1 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/SystemUpdatePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/system/SystemUpdatePreferenceControllerTest.java
@@ -13,17 +13,20 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.android.settings.deviceinfo;
+package com.android.settings.system;
 
+import static android.os.SystemUpdateManager.KEY_STATUS;
+import static android.os.SystemUpdateManager.KEY_TITLE;
+import static android.os.SystemUpdateManager.STATUS_IDLE;
+import static android.os.SystemUpdateManager.STATUS_UNKNOWN;
+import static android.os.SystemUpdateManager.STATUS_WAITING_DOWNLOAD;
 import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.Answers.RETURNS_DEEP_STUBS;
-import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.when;
 
 import android.content.Context;
 import android.os.Build;
-import android.os.UserManager;
+import android.os.Bundle;
+import android.os.SystemUpdateManager;
 import android.support.v7.preference.Preference;
 import android.support.v7.preference.PreferenceScreen;
 
@@ -55,6 +58,8 @@
 
     @Mock
     private PreferenceScreen mScreen;
+    @Mock
+    private SystemUpdateManager mSystemUpdateManager;
 
     private Context mContext;
     private SystemUpdatePreferenceController mController;
@@ -64,7 +69,8 @@
     public void setUp() {
         MockitoAnnotations.initMocks(this);
         mContext = RuntimeEnvironment.application;
-
+        ShadowApplication.getInstance().setSystemService(Context.SYSTEM_UPDATE_SERVICE,
+                mSystemUpdateManager);
         mController = new SystemUpdatePreferenceController(mContext);
         mPreference = new Preference(RuntimeEnvironment.application);
         mPreference.setKey(mController.getPreferenceKey());
@@ -118,11 +124,41 @@
     }
 
     @Test
-    public void updateState_shouldSetToAndroidVersion() {
+    public void updateState_systemUpdateStatusUnknown_shouldSetToAndroidVersion() {
+        final Bundle bundle = new Bundle();
+        bundle.putInt(KEY_STATUS, STATUS_UNKNOWN);
+        when(mSystemUpdateManager.retrieveSystemUpdateInfo()).thenReturn(bundle);
+
         mController.updateState(mPreference);
 
-        assertThat(mPreference.getSummary())
-                .isEqualTo(RuntimeEnvironment.application.getString(R.string.about_summary,
-                        Build.VERSION.RELEASE));
+        assertThat(mPreference.getSummary()).isEqualTo(
+                mContext.getString(R.string.android_version_summary, Build.VERSION.RELEASE));
+    }
+
+    @Test
+    public void updateState_systemUpdateStatusIdle_shouldSetToAndroidVersion() {
+        final String testReleaseName = "ANDROID TEST VERSION";
+
+        final Bundle bundle = new Bundle();
+        bundle.putInt(KEY_STATUS, STATUS_IDLE);
+        bundle.putString(KEY_TITLE, testReleaseName);
+        when(mSystemUpdateManager.retrieveSystemUpdateInfo()).thenReturn(bundle);
+
+        mController.updateState(mPreference);
+
+        assertThat(mPreference.getSummary()).isEqualTo(
+                mContext.getString(R.string.android_version_summary, testReleaseName));
+    }
+
+    @Test
+    public void updateState_systemUpdateInProgress_shouldSetToUpdatePending() {
+        final Bundle bundle = new Bundle();
+        bundle.putInt(KEY_STATUS, STATUS_WAITING_DOWNLOAD);
+        when(mSystemUpdateManager.retrieveSystemUpdateInfo()).thenReturn(bundle);
+
+        mController.updateState(mPreference);
+
+        assertThat(mPreference.getSummary()).isEqualTo(
+                mContext.getString(R.string.android_version_pending_update_summary));
     }
 }
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowConnectivityManager.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowConnectivityManager.java
index 742fbf8..fc19b44 100644
--- a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowConnectivityManager.java
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowConnectivityManager.java
@@ -26,6 +26,7 @@
 public class ShadowConnectivityManager extends org.robolectric.shadows.ShadowConnectivityManager {
 
     private final SparseBooleanArray mSupportedNetworkTypes = new SparseBooleanArray();
+    private boolean mTetheringSupported = false;
 
     public void setNetworkSupported(int networkType, boolean supported) {
         mSupportedNetworkTypes.put(networkType, supported);
@@ -35,4 +36,13 @@
     public boolean isNetworkSupported(int networkType) {
         return mSupportedNetworkTypes.get(networkType);
     }
+
+    public void setTetheringSupported(boolean supported) {
+        mTetheringSupported = supported;
+    }
+
+    @Implementation
+    public boolean isTetheringSupported() {
+        return mTetheringSupported;
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowRestrictedLockUtils.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowRestrictedLockUtils.java
new file mode 100644
index 0000000..afede1a
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowRestrictedLockUtils.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2018 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.testutils.shadow;
+
+import android.content.Context;
+
+import com.android.internal.util.ArrayUtils;
+import com.android.settingslib.RestrictedLockUtils;
+import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
+
+import org.robolectric.annotation.Implementation;
+import org.robolectric.annotation.Implements;
+
+@Implements(RestrictedLockUtils.class)
+public class ShadowRestrictedLockUtils {
+    private static boolean isRestricted;
+    private static String[] restrictedPkgs;
+    private static boolean adminSupportDetailsIntentLaunched;
+
+    @Implementation
+    public static RestrictedLockUtils.EnforcedAdmin checkIfMeteredDataRestricted(Context context,
+            String packageName, int userId) {
+        if (isRestricted) {
+            return new EnforcedAdmin();
+        }
+        if (ArrayUtils.contains(restrictedPkgs, packageName)) {
+            return new EnforcedAdmin();
+        }
+        return null;
+    }
+
+    @Implementation
+    public static void sendShowAdminSupportDetailsIntent(Context context, EnforcedAdmin admin) {
+        adminSupportDetailsIntentLaunched = true;
+    }
+
+    public static boolean hasAdminSupportDetailsIntentLaunched() {
+        return adminSupportDetailsIntentLaunched;
+    }
+
+    public static void clearAdminSupportDetailsIntentLaunch() {
+        adminSupportDetailsIntentLaunched = false;
+    }
+
+    public static void setRestricted(boolean restricted) {
+        isRestricted = restricted;
+    }
+
+    public static void setRestrictedPkgs(String... pkgs) {
+        restrictedPkgs = pkgs;
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/users/UserCapabilitiesTest.java b/tests/robotests/src/com/android/settings/users/UserCapabilitiesTest.java
new file mode 100644
index 0000000..4228ca0
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/users/UserCapabilitiesTest.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2018 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.users;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.os.UserManager;
+
+import com.android.settings.TestConfig;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.annotation.Config;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class UserCapabilitiesTest {
+
+    @Mock
+    private Context mContext;
+    @Mock
+    private UserManager mUserManager;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+        when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
+    }
+
+    @Test
+    public void disallowUserSwitchWhenRestrictionIsSet() {
+        when(mUserManager.hasUserRestriction(UserManager.DISALLOW_USER_SWITCH)).thenReturn(true);
+
+        UserCapabilities userCapabilities = UserCapabilities.create(mContext);
+        userCapabilities.updateAddUserCapabilities(mContext);
+
+        assertThat(userCapabilities.mDisallowSwitchUser).isTrue();
+    }
+
+    @Test
+    public void allowUserSwitchWhenRestrictionIsNotSet() {
+        when(mUserManager.hasUserRestriction(UserManager.DISALLOW_USER_SWITCH)).thenReturn(false);
+
+        UserCapabilities userCapabilities = UserCapabilities.create(mContext);
+        userCapabilities.updateAddUserCapabilities(mContext);
+
+        assertThat(userCapabilities.mDisallowSwitchUser).isFalse();
+    }
+}
diff --git a/tests/uitests/Android.mk b/tests/uitests/Android.mk
index 870f59c..d52911d 100644
--- a/tests/uitests/Android.mk
+++ b/tests/uitests/Android.mk
@@ -19,16 +19,22 @@
 LOCAL_COMPATIBILITY_SUITE := device-tests
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 LOCAL_MODULE_TAGS := tests
-LOCAL_JAVA_LIBRARIES := android.test.runner android.test.base
+
+LOCAL_JAVA_LIBRARIES := \
+    android.test.runner \
+    android.test.base
+
 LOCAL_STATIC_JAVA_LIBRARIES := \
+    android-support-test \
     app-helpers-core \
     launcher-helper-lib \
-    settings-helper \
-    timeresult-helper-lib \
-    ub-uiautomator \
-    sysui-helper \
     metrics-helper-lib \
     platform-test-annotations \
+    settings-helper \
+    sysui-helper \
+    timeresult-helper-lib \
+    truth-prebuilt \
+    ub-uiautomator \
 
 #LOCAL_SDK_VERSION := current
 
diff --git a/tests/uitests/src/com/android/settings/ui/AboutPhoneSettingsTests.java b/tests/uitests/src/com/android/settings/ui/AboutPhoneSettingsTests.java
index 57f9bc2..b92a707 100644
--- a/tests/uitests/src/com/android/settings/ui/AboutPhoneSettingsTests.java
+++ b/tests/uitests/src/com/android/settings/ui/AboutPhoneSettingsTests.java
@@ -16,57 +16,55 @@
 
 package com.android.settings.ui;
 
+import static com.android.settings.ui.testutils.SettingsTestUtils.SETTINGS_PACKAGE;
+import static com.google.common.truth.Truth.assertThat;
+import static com.google.common.truth.Truth.assertWithMessage;
+
+import android.app.Instrumentation;
 import android.content.Intent;
 import android.os.RemoteException;
 import android.provider.Settings;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.filters.SmallTest;
+import android.support.test.runner.AndroidJUnit4;
 import android.support.test.uiautomator.By;
 import android.support.test.uiautomator.Direction;
 import android.support.test.uiautomator.UiDevice;
 import android.support.test.uiautomator.UiObject2;
 import android.support.test.uiautomator.Until;
-import android.test.InstrumentationTestCase;
-import android.test.suitebuilder.annotation.MediumTest;
-import android.test.suitebuilder.annotation.Suppress;
 import android.text.TextUtils;
-import android.util.Log;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
 
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Iterator;
 
 /** Verifies basic functionality of the About Phone screen */
-public class AboutPhoneSettingsTests extends InstrumentationTestCase {
-    private static final boolean LOCAL_LOGV = false;
-    private static final String TAG = "AboutPhoneSettingsTest";
+@RunWith(AndroidJUnit4.class)
+@SmallTest
+public class AboutPhoneSettingsTests {
     private static final int TIMEOUT = 2000;
-    private static final String SETTINGS_PACKAGE = "com.android.settings";
-
-    private UiDevice mDevice;
 
     // TODO: retrieve using name/ids from com.android.settings package
     private static final String[] sResourceTexts = {
-        "Status",
-        "Legal information",
-        "Regulatory labels",
-        "Model",
-        "Android version",
-        "Android security patch level",
-        "Baseband version",
-        "Kernel version",
-        "Build number"
+            "Phone number",
+            "SIM status",
+            "Model & hardware",
+            "MEID",
+            "Android version"
     };
 
-    private static final String[] sClickableResourceTexts = {
-        "Status", "Legal information", "Regulatory labels",
-    };
+    private UiDevice mDevice;
+    private Instrumentation mInstrumentation;
 
-    @Override
+    @Before
     public void setUp() throws Exception {
-        if (LOCAL_LOGV) {
-            Log.d(TAG, "-------");
-        }
-        super.setUp();
-        mDevice = UiDevice.getInstance(getInstrumentation());
+        mInstrumentation = InstrumentationRegistry.getInstrumentation();
+        mDevice = UiDevice.getInstance(mInstrumentation);
         try {
             mDevice.setOrientationNatural();
         } catch (RemoteException e) {
@@ -82,84 +80,40 @@
         UiObject2 view =
                 mDevice.wait(
                         Until.findObject(By.res(SETTINGS_PACKAGE + ":id/main_content")), TIMEOUT);
-        assertNotNull("Could not find main About Phone screen", view);
+        assertThat(view).isNotNull();
         view.scroll(Direction.UP, 1.0f);
     }
 
-    @Override
-    protected void tearDown() throws Exception {
+    @After
+    public void tearDown() throws Exception {
         // Adding an extra pressBack so we exit About Phone Settings
         // and finish the test cleanly
         mDevice.pressBack();
         mDevice.pressHome(); // finish settings activity
         mDevice.waitForIdle(TIMEOUT * 2); // give UI time to finish animating
-        super.tearDown();
+    }
+
+    @Test
+    public void testAllMenuEntriesExist() throws Exception {
+        searchForItemsAndTakeAction(mDevice, sResourceTexts);
     }
 
     private void launchAboutPhoneSettings(String aboutSetting) throws Exception {
         Intent aboutIntent = new Intent(aboutSetting);
         aboutIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-        getInstrumentation().getContext().startActivity(aboutIntent);
-    }
-
-    /**
-     * Callable actions that can be taken when a UIObject2 is found
-     *
-     * @param device The current UiDevice
-     * @param item The UiObject2 that was found and can be acted on
-     *
-     * @return {@code true} if the call was successful, and {@code false} otherwise
-     */
-    public interface UIObject2Callback {
-        boolean call(UiDevice device, UiObject2 item) throws Exception;
-    }
-
-    /**
-     * Clicks the given item and then presses the Back button
-     *
-     * <p>Used to test whether a given UiObject2 can be successfully clicked.
-     * Presses Back to restore state to the previous screen.
-     *
-     * @param device The device that can be used to press Back
-     * @param item The item to click
-     *
-     * @return {@code true} if clicking the item succeeded, and {@code false} otherwise
-     */
-    public class UiObject2Clicker implements UIObject2Callback {
-        public boolean call(UiDevice device, UiObject2 item) throws Exception {
-            item.click();
-            Thread.sleep(TIMEOUT * 2); // give UI time to finish animating
-            boolean pressWorked = device.pressBack();
-            Thread.sleep(TIMEOUT * 2);
-            return pressWorked;
-        }
+        InstrumentationRegistry.getTargetContext().startActivity(aboutIntent);
     }
 
     /**
      * Removes items found in the view and optionally takes some action.
-     *
-     * @param device The current UiDevice
-     * @param itemsLeftToFind The items to search for in the current view
-     * @param action Action to call on each item that is found; pass {@code null} to take no action
      */
-    private void removeItemsAndTakeAction(
-            UiDevice device, ArrayList<String> itemsLeftToFind, UIObject2Callback action) throws Exception {
+    private void removeItemsAndTakeAction(UiDevice device, ArrayList<String> itemsLeftToFind)
+            throws Exception {
         for (Iterator<String> iterator = itemsLeftToFind.iterator(); iterator.hasNext(); ) {
             String itemText = iterator.next();
             UiObject2 item = device.wait(Until.findObject(By.text(itemText)), TIMEOUT);
             if (item != null) {
-                if (LOCAL_LOGV) {
-                    Log.d(TAG, itemText + " is present");
-                }
                 iterator.remove();
-                if (action != null) {
-                    boolean success = action.call(device, item);
-                    assertTrue("Calling action after " + itemText + " did not work", success);
-                }
-            } else {
-                if (LOCAL_LOGV) {
-                    Log.d(TAG, "Could not find " + itemText);
-                }
             }
         }
     }
@@ -169,25 +123,18 @@
      *
      * <p>Will scroll down the screen until it has found all elements or reached the bottom.
      * This allows elements to be found and acted on even if they change order.
-     *
-     * @param device The current UiDevice
-     * @param itemsToFind The items to search for in the current view
-     * @param action Action to call on each item that is found; pass {@code null} to take no action
      */
-    public void searchForItemsAndTakeAction(UiDevice device, String[] itemsToFind, UIObject2Callback action)
+    private void searchForItemsAndTakeAction(UiDevice device, String[] itemsToFind)
             throws Exception {
 
-        ArrayList<String> itemsLeftToFind = new ArrayList<String>(Arrays.asList(itemsToFind));
-        assertFalse(
-                "There must be at least one item to search for on the screen!",
-                itemsLeftToFind.isEmpty());
+        ArrayList<String> itemsLeftToFind = new ArrayList<>(Arrays.asList(itemsToFind));
+        assertWithMessage("There must be at least one item to search for on the screen!")
+                .that(itemsLeftToFind)
+                .isNotEmpty();
 
-        if (LOCAL_LOGV) {
-            Log.d(TAG, "items: " + TextUtils.join(", ", itemsLeftToFind));
-        }
         boolean canScrollDown = true;
         while (canScrollDown && !itemsLeftToFind.isEmpty()) {
-            removeItemsAndTakeAction(device, itemsLeftToFind, action);
+            removeItemsAndTakeAction(device, itemsLeftToFind);
 
             // when we've finished searching the current view, scroll down
             UiObject2 view =
@@ -201,24 +148,11 @@
             }
         }
         // check the last items once we have reached the bottom of the view
-        removeItemsAndTakeAction(device, itemsLeftToFind, action);
+        removeItemsAndTakeAction(device, itemsLeftToFind);
 
-        assertTrue(
-                "The following items were not found on the screen: "
-                        + TextUtils.join(", ", itemsLeftToFind),
-                itemsLeftToFind.isEmpty());
-    }
-
-    @MediumTest // UI interaction
-    public void testAllMenuEntriesExist() throws Exception {
-        searchForItemsAndTakeAction(mDevice, sResourceTexts, null);
-    }
-
-    // Suppressing this test as it might be causing other test failures
-    // Will verify that this test is the cause before proceeding with solution
-    @Suppress
-    @MediumTest // UI interaction
-    public void testClickableEntriesCanBeClicked() throws Exception {
-        searchForItemsAndTakeAction(mDevice, sClickableResourceTexts, new UiObject2Clicker());
+        assertWithMessage("The following items were not found on the screen: "
+                + TextUtils.join(", ", itemsLeftToFind))
+                .that(itemsLeftToFind)
+                .isEmpty();
     }
 }
diff --git a/tests/uitests/src/com/android/settings/ui/BatterySettingsUITest.java b/tests/uitests/src/com/android/settings/ui/BatterySettingsUITest.java
new file mode 100644
index 0000000..8b34fff
--- /dev/null
+++ b/tests/uitests/src/com/android/settings/ui/BatterySettingsUITest.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2018 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.ui;
+
+import android.content.Intent;
+import android.os.RemoteException;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.filters.MediumTest;
+import android.support.test.runner.AndroidJUnit4;
+import android.support.test.uiautomator.UiDevice;
+import android.system.helpers.SettingsHelper;
+
+import com.android.settings.ui.testutils.SettingsTestUtils;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@MediumTest
+@RunWith(AndroidJUnit4.class)
+public class BatterySettingsUITest {
+    // Items we really want to always show
+    private static final String[] CATEGORIES = new String[] {
+            "Battery Saver",
+            "Battery percentage",
+            "Battery usage data is approximate and can change based on usage",
+    };
+
+    private UiDevice mDevice;
+    private SettingsHelper mHelper;
+
+    @Before
+    public void setUp() throws Exception {
+        mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
+        mHelper = SettingsHelper.getInstance();
+        try {
+            mDevice.setOrientationNatural();
+        } catch (RemoteException e) {
+            throw new RuntimeException("failed to freeze device orientaion", e);
+        }
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        // Go back to home for next test.
+        mDevice.pressHome();
+    }
+
+    @Test
+    public void launchSecuritySettings() throws Exception {
+        // Launch Settings
+        SettingsHelper.launchSettingsPage(
+                InstrumentationRegistry.getTargetContext(), Intent.ACTION_POWER_USAGE_SUMMARY);
+        mHelper.scrollVert(false);
+        for (String category : CATEGORIES) {
+            SettingsTestUtils.assertTitleMatch(mDevice, category);
+        }
+    }
+}
diff --git a/tests/uitests/src/com/android/settings/ui/HomepageDisplayTests.java b/tests/uitests/src/com/android/settings/ui/HomepageDisplayTests.java
index 7931d30..3b7b006 100644
--- a/tests/uitests/src/com/android/settings/ui/HomepageDisplayTests.java
+++ b/tests/uitests/src/com/android/settings/ui/HomepageDisplayTests.java
@@ -16,6 +16,9 @@
 
 package com.android.settings.ui;
 
+import static com.android.settings.ui.testutils.SettingsTestUtils.SETTINGS_PACKAGE;
+import static com.android.settings.ui.testutils.SettingsTestUtils.TIMEOUT;
+
 import android.os.RemoteException;
 import android.platform.test.annotations.Presubmit;
 import android.provider.Settings;
@@ -36,9 +39,6 @@
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
-import static com.android.settings.ui.testutils.SettingsTestUtils.SETTINGS_PACKAGE;
-import static com.android.settings.ui.testutils.SettingsTestUtils.TIMEOUT;
-
 @MediumTest
 @RunWith(AndroidJUnit4.class)
 public class HomepageDisplayTests {
@@ -52,19 +52,17 @@
             "Sound",
             "Storage",
             "Security & location",
-            "Users & accounts",
+            "Accounts",
             "Accessibility",
             "System",
             "Support & tips"
     };
 
     private UiDevice mDevice;
-    private SettingsHelper mSettingsHelper;
 
     @Before
     public void setUp() throws Exception {
         mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
-        mSettingsHelper = new SettingsHelper();
         try {
             mDevice.setOrientationNatural();
         } catch (RemoteException e) {
diff --git a/tests/uitests/src/com/android/settings/ui/MoreWirelessSettingsTest2.java b/tests/uitests/src/com/android/settings/ui/MoreWirelessSettingsTest2.java
new file mode 100644
index 0000000..971c7d7
--- /dev/null
+++ b/tests/uitests/src/com/android/settings/ui/MoreWirelessSettingsTest2.java
@@ -0,0 +1,766 @@
+/*
+ * Copyright (C) 2018 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.ui;
+
+import android.content.Context;
+import android.net.wifi.WifiManager;
+import android.os.RemoteException;
+import android.platform.test.annotations.Presubmit;
+import android.provider.Settings;
+import android.support.test.uiautomator.By;
+import android.support.test.uiautomator.BySelector;
+import android.support.test.uiautomator.Direction;
+import android.support.test.uiautomator.StaleObjectException;
+import android.support.test.uiautomator.UiDevice;
+import android.support.test.uiautomator.UiObject2;
+import android.support.test.uiautomator.Until;
+import android.system.helpers.CommandsHelper;
+import android.system.helpers.SettingsHelper;
+import android.test.InstrumentationTestCase;
+import android.test.suitebuilder.annotation.MediumTest;
+import android.test.suitebuilder.annotation.Suppress;
+import android.util.Log;
+
+/**
+ * Additional tests for Wifi Settings.
+ */
+public class MoreWirelessSettingsTest2 extends InstrumentationTestCase {
+    // These back button presses are performed in tearDown() to exit Wifi
+    // Settings sub-menus that a test might finish in. This number should be
+    // high enough to account for the deepest sub-menu a test might enter.
+    private static final int NUM_BACK_BUTTON_PRESSES = 5;
+    private static final int TIMEOUT = 2000;
+    private static final int SLEEP_TIME = 500;
+    private static final String AIRPLANE_MODE_BROADCAST =
+            "am broadcast -a android.intent.action.AIRPLANE_MODE";
+    private static final String TAG="WirelessNetworkSettingsTests";
+
+    // Note: The values of these variables might affect flakiness in tests that involve
+    // scrolling. Adjust where necessary.
+    private static final float SCROLL_UP_PERCENT = 10.0f;
+    private static final float SCROLL_DOWN_PERCENT = 0.5f;
+    private static final int MAX_SCROLL_ATTEMPTS = 10;
+    private static final int MAX_ADD_NETWORK_BUTTON_ATTEMPTS = 3;
+    private static final int SCROLL_SPEED = 2000;
+
+    private static final String TEST_SSID = "testSsid";
+    private static final String TEST_PW_GE_8_CHAR = "testPasswordGreaterThan8Char";
+    private static final String TEST_PW_LT_8_CHAR = "lt8Char";
+    private static final String TEST_DOMAIN = "testDomain.com";
+
+    private static final String SETTINGS_PACKAGE = "com.android.settings";
+
+    private static final String CHECKBOX_CLASS = "android.widget.CheckBox";
+    private static final String SPINNER_CLASS = "android.widget.Spinner";
+    private static final String EDIT_TEXT_CLASS = "android.widget.EditText";
+    private static final String SCROLLVIEW_CLASS = "android.widget.ScrollView";
+    private static final String LISTVIEW_CLASS = "android.widget.ListView";
+
+    private static final String ADD_NETWORK_MENU_CANCEL_BUTTON_TEXT = "CANCEL";
+    private static final String ADD_NETWORK_MENU_SAVE_BUTTON_TEXT = "SAVE";
+    private static final String ADD_NETWORK_PREFERENCE_TEXT = "Add network";
+    private static final String CONFIGURE_WIFI_PREFERENCE_TEXT = "Wi‑Fi preferences";
+    private static final String CONFIGURE_WIFI_ADVANCED_PREFERENCE_TEXT = "Advanced";
+    private static final String CACERT_MENU_PLEASE_SELECT_TEXT = "Please select";
+    private static final String CACERT_MENU_USE_SYSTEM_CERTS_TEXT = "Use system certificates";
+    private static final String CACERT_MENU_DO_NOT_VALIDATE_TEXT = "Do not validate";
+    private static final String USERCERT_MENU_PLEASE_SELECT_TEXT = "Please select";
+    private static final String USERCERT_MENU_DO_NOT_PROVIDE_TEXT = "Do not provide";
+    private static final String SECURITY_OPTION_NONE_TEXT = "None";
+    private static final String SECURITY_OPTION_WEP_TEXT = "WEP";
+    private static final String SECURITY_OPTION_PSK_TEXT = "WPA/WPA2 PSK";
+    private static final String SECURITY_OPTION_EAP_TEXT = "802.1x EAP";
+    private static final String EAP_METHOD_PEAP_TEXT = "PEAP";
+    private static final String EAP_METHOD_TLS_TEXT = "TLS";
+    private static final String EAP_METHOD_TTLS_TEXT = "TTLS";
+    private static final String EAP_METHOD_PWD_TEXT = "PWD";
+    private static final String EAP_METHOD_SIM_TEXT = "SIM";
+    private static final String EAP_METHOD_AKA_TEXT = "AKA";
+    private static final String EAP_METHOD_AKA_PRIME_TEXT = "AKA'";
+    private static final String PHASE2_MENU_NONE_TEXT = "None";
+    private static final String PHASE2_MENU_MSCHAPV2_TEXT = "MSCHAPV2";
+    private static final String PHASE2_MENU_GTC_TEXT = "GTC";
+
+    private static final String ADD_NETWORK_MENU_ADV_TOGGLE_RES_ID = "wifi_advanced_togglebox";
+    private static final String ADD_NETWORK_MENU_IP_SETTINGS_RES_ID = "ip_settings";
+    private static final String ADD_NETWORK_MENU_PROXY_SETTINGS_RES_ID = "proxy_settings";
+    private static final String ADD_NETWORK_MENU_SECURITY_OPTION_RES_ID = "security";
+    private static final String ADD_NETWORK_MENU_EAP_METHOD_RES_ID = "method";
+    private static final String ADD_NETWORK_MENU_SSID_RES_ID = "ssid";
+    private static final String ADD_NETWORK_MENU_PHASE2_RES_ID = "phase2";
+    private static final String ADD_NETWORK_MENU_CACERT_RES_ID = "ca_cert";
+    private static final String ADD_NETWORK_MENU_USERCERT_RES_ID = "user_cert";
+    private static final String ADD_NETWORK_MENU_NO_DOMAIN_WARNING_RES_ID = "no_domain_warning";
+    private static final String ADD_NETWORK_MENU_NO_CACERT_WARNING_RES_ID = "no_ca_cert_warning";
+    private static final String ADD_NETWORK_MENU_DOMAIN_LAYOUT_RES_ID = "l_domain";
+    private static final String ADD_NETWORK_MENU_DOMAIN_RES_ID = "domain";
+    private static final String ADD_NETWORK_MENU_IDENTITY_LAYOUT_RES_ID = "l_identity";
+    private static final String ADD_NETWORK_MENU_ANONYMOUS_LAYOUT_RES_ID = "l_anonymous";
+    private static final String ADD_NETWORK_MENU_PASSWORD_LAYOUT_RES_ID = "password_layout";
+    private static final String ADD_NETWORK_MENU_SHOW_PASSWORD_LAYOUT_RES_ID =
+            "show_password_layout";
+    private static final String ADD_NETWORK_MENU_PASSWORD_RES_ID = "password";
+
+    private static final BySelector ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR =
+            By.scrollable(true).clazz(SCROLLVIEW_CLASS);
+    private static final BySelector SPINNER_OPTIONS_SCROLLABLE_BY_SELECTOR =
+            By.scrollable(true).clazz(LISTVIEW_CLASS);
+
+    private UiDevice mDevice;
+    private CommandsHelper mCommandsHelper;
+
+    @Override
+    public void setUp() throws Exception {
+        super.setUp();
+        mDevice = UiDevice.getInstance(getInstrumentation());
+        try {
+            mDevice.setOrientationNatural();
+        } catch (RemoteException e) {
+            throw new RuntimeException("failed to freeze device orientation", e);
+        }
+        // Ensure airplane mode is OFF so that wifi can be enabled using WiFiManager.
+        Settings.Global.putString(getInstrumentation().getContext().getContentResolver(),
+                Settings.Global.AIRPLANE_MODE_ON, "0");
+        Log.d(TAG, "sending airplane mode broadcast to device");
+        mCommandsHelper = CommandsHelper.getInstance();
+        mCommandsHelper.executeShellCommand(AIRPLANE_MODE_BROADCAST);
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        // Exit all settings sub-menus.
+        for (int i = 0; i < NUM_BACK_BUTTON_PRESSES; ++i) {
+            mDevice.pressBack();
+        }
+        mDevice.pressHome();
+        super.tearDown();
+    }
+
+    @MediumTest
+    public void testWifiMenuLoadConfigure() throws Exception {
+        loadWiFiConfigureMenu();
+        Thread.sleep(SLEEP_TIME);
+        UiObject2 configureWiFiHeading = mDevice.wait(Until.findObject
+                (By.text(CONFIGURE_WIFI_PREFERENCE_TEXT)), TIMEOUT);
+        assertNotNull("Configure WiFi menu has not loaded correctly", configureWiFiHeading);
+    }
+
+    @MediumTest
+    public void testNetworkNotificationsOn() throws Exception {
+        verifyNetworkNotificationsOnOrOff(true);
+    }
+
+    @MediumTest
+    public void testNetworkNotificationsOff() throws Exception {
+        verifyNetworkNotificationsOnOrOff(false);
+    }
+
+    @MediumTest
+    public void testAddNetworkMenu_Default() throws Exception {
+        loadAddNetworkMenu();
+
+        // Submit button should be disabled by default, while cancel button should be enabled.
+        assertFalse(mDevice.wait(Until.findObject(
+                By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
+        assertTrue(mDevice.wait(Until.findObject(
+                By.text(ADD_NETWORK_MENU_CANCEL_BUTTON_TEXT)), TIMEOUT).isEnabled());
+
+        // Check that the SSID field is defaults to the hint.
+        assertEquals("Enter the SSID", mDevice.wait(Until.findObject(By
+                .res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_SSID_RES_ID)
+                .clazz(EDIT_TEXT_CLASS)), TIMEOUT*2)
+                .getText());
+
+        // Check Security defaults to None.
+        assertEquals("None", mDevice.wait(Until.findObject(By
+                .res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_SECURITY_OPTION_RES_ID)
+                .clazz(SPINNER_CLASS)), TIMEOUT)
+                .getChildren().get(0).getText());
+
+        // Check advanced options are collapsed by default.
+        assertFalse(mDevice.wait(Until.findObject(By
+                .res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_ADV_TOGGLE_RES_ID)
+                .clazz(CHECKBOX_CLASS)), TIMEOUT).isChecked());
+
+    }
+
+    @Suppress
+    @MediumTest
+    public void testAddNetworkMenu_Proxy() throws Exception {
+        loadAddNetworkMenu();
+
+        // Toggle advanced options.
+        mDevice.wait(Until.findObject(By
+                .res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_ADV_TOGGLE_RES_ID)
+                .clazz(CHECKBOX_CLASS)), TIMEOUT).click();
+
+        // Verify Proxy defaults to None.
+        BySelector proxySettingsBySelector =
+                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_PROXY_SETTINGS_RES_ID)
+                .clazz(SPINNER_CLASS);
+        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR, proxySettingsBySelector);
+        assertEquals("None", mDevice.wait(Until.findObject(proxySettingsBySelector), TIMEOUT)
+                .getChildren().get(0).getText());
+
+        // Verify that Proxy Manual fields appear.
+        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR, proxySettingsBySelector);
+        mDevice.wait(Until.findObject(proxySettingsBySelector), TIMEOUT).click();
+        mDevice.wait(Until.findObject(By.text("Manual")), TIMEOUT).click();
+        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
+                By.res(SETTINGS_PACKAGE, "proxy_warning_limited_support"));
+        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
+                By.res(SETTINGS_PACKAGE, "proxy_hostname"));
+        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
+                By.res(SETTINGS_PACKAGE, "proxy_exclusionlist"));
+
+        // Verify that Proxy Auto-Config options appear.
+        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR, proxySettingsBySelector);
+        mDevice.wait(Until.findObject(proxySettingsBySelector), TIMEOUT).click();
+        mDevice.wait(Until.findObject(By.text("Proxy Auto-Config")), TIMEOUT).click();
+        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
+                By.res(SETTINGS_PACKAGE, "proxy_pac"));
+    }
+
+    @Suppress
+    @MediumTest
+    public void testAddNetworkMenu_IpSettings() throws Exception {
+        loadAddNetworkMenu();
+
+        // Toggle advanced options.
+        mDevice.wait(Until.findObject(By
+                .res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_ADV_TOGGLE_RES_ID)
+                .clazz(CHECKBOX_CLASS)), TIMEOUT).click();
+
+        // Verify IP settings defaults to DHCP.
+        BySelector ipSettingsBySelector =
+                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_IP_SETTINGS_RES_ID).clazz(SPINNER_CLASS);
+        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR, ipSettingsBySelector);
+        assertEquals("DHCP", mDevice.wait(Until.findObject(ipSettingsBySelector), TIMEOUT)
+                .getChildren().get(0).getText());
+
+        // Verify that Static IP settings options appear.
+        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR, ipSettingsBySelector).click();
+        mDevice.wait(Until.findObject(By.text("Static")), TIMEOUT).click();
+        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
+                By.res(SETTINGS_PACKAGE, "ipaddress"));
+        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
+                By.res(SETTINGS_PACKAGE, "gateway"));
+        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
+                By.res(SETTINGS_PACKAGE, "network_prefix_length"));
+        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
+                By.res(SETTINGS_PACKAGE, "dns1"));
+        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
+                By.res(SETTINGS_PACKAGE, "dns2"));
+    }
+
+    @Suppress
+    @MediumTest
+    public void testPhase2Settings() throws Exception {
+        loadAddNetworkMenu();
+        selectSecurityOption(SECURITY_OPTION_EAP_TEXT);
+
+        BySelector phase2SettingsBySelector =
+                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_PHASE2_RES_ID).clazz(SPINNER_CLASS);
+        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR, phase2SettingsBySelector);
+        assertEquals(PHASE2_MENU_NONE_TEXT, mDevice.wait(Until
+                .findObject(phase2SettingsBySelector), TIMEOUT).getChildren().get(0).getText());
+        mDevice.wait(Until.findObject(phase2SettingsBySelector), TIMEOUT).click();
+        Thread.sleep(SLEEP_TIME);
+
+        // Verify Phase 2 authentication spinner options.
+        assertNotNull(mDevice.wait(Until.findObject(By.text(PHASE2_MENU_NONE_TEXT)), TIMEOUT));
+        assertNotNull(mDevice.wait(Until.findObject(By.text(PHASE2_MENU_MSCHAPV2_TEXT)), TIMEOUT));
+        assertNotNull(mDevice.wait(Until.findObject(By.text(PHASE2_MENU_GTC_TEXT)), TIMEOUT));
+    }
+
+    @Suppress
+    @MediumTest
+    public void testCaCertSettings() throws Exception {
+        loadAddNetworkMenu();
+        selectSecurityOption(SECURITY_OPTION_EAP_TEXT);
+
+        BySelector caCertSettingsBySelector =
+                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_CACERT_RES_ID).clazz(SPINNER_CLASS);
+        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR, caCertSettingsBySelector);
+        assertEquals(CACERT_MENU_PLEASE_SELECT_TEXT, mDevice.wait(Until
+                .findObject(caCertSettingsBySelector), TIMEOUT).getChildren().get(0).getText());
+        mDevice.wait(Until.findObject(caCertSettingsBySelector), TIMEOUT).click();
+        Thread.sleep(SLEEP_TIME);
+
+        // Verify CA certificate spinner options.
+        assertNotNull(mDevice.wait(Until.findObject(
+                By.text(CACERT_MENU_PLEASE_SELECT_TEXT)), TIMEOUT));
+        assertNotNull(mDevice.wait(Until.findObject(
+                By.text(CACERT_MENU_USE_SYSTEM_CERTS_TEXT)), TIMEOUT));
+        assertNotNull(mDevice.wait(Until.findObject(
+                By.text(CACERT_MENU_DO_NOT_VALIDATE_TEXT)), TIMEOUT));
+
+        // Verify that a domain field and warning appear when the user selects the
+        // "Use system certificates" option.
+        mDevice.wait(Until.findObject(By.text(CACERT_MENU_USE_SYSTEM_CERTS_TEXT)), TIMEOUT).click();
+        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
+                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_DOMAIN_LAYOUT_RES_ID));
+        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
+                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_NO_DOMAIN_WARNING_RES_ID));
+
+        // Verify that a warning appears when the user chooses the "Do Not Validate" option.
+        mDevice.wait(Until.findObject(caCertSettingsBySelector), TIMEOUT).click();
+        mDevice.wait(Until.findObject(By.text(CACERT_MENU_DO_NOT_VALIDATE_TEXT)), TIMEOUT).click();
+        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
+                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_NO_CACERT_WARNING_RES_ID));
+    }
+
+    @Suppress
+    @MediumTest
+    public void testAddNetwork_NoSecurity() throws Exception {
+        loadAddNetworkMenu();
+        selectSecurityOption(SECURITY_OPTION_NONE_TEXT);
+
+        // Entering an SSID is enough to enable the submit button. // TODO THIS GUY
+        enterSSID(TEST_SSID);
+        assertTrue(mDevice.wait(Until
+                .findObject(By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
+    }
+
+    @Suppress
+    @MediumTest
+    public void testAddNetwork_WEP() throws Exception {
+        loadAddNetworkMenu();
+        selectSecurityOption(SECURITY_OPTION_WEP_TEXT);
+        assertFalse(mDevice.wait(Until.findObject(
+                By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
+
+        // Verify that WEP fields appear.
+        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
+                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_PASSWORD_LAYOUT_RES_ID));
+        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
+                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_SHOW_PASSWORD_LAYOUT_RES_ID));
+
+        // Entering an SSID alone does not enable the submit button.
+        enterSSID(TEST_SSID);
+        assertFalse(mDevice.wait(Until.findObject(
+                By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
+
+        // Submit button is only enabled after a password is entered.
+        enterPassword(TEST_PW_GE_8_CHAR);
+        assertTrue(mDevice.wait(Until
+                .findObject(By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
+    }
+
+    @Suppress
+    @MediumTest
+    public void testAddNetwork_PSK() throws Exception {
+        loadAddNetworkMenu();
+        selectSecurityOption(SECURITY_OPTION_PSK_TEXT);
+        assertFalse(mDevice.wait(Until.findObject(
+                By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
+
+        // Verify that PSK fields appear.
+        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
+                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_PASSWORD_LAYOUT_RES_ID));
+        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
+                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_SHOW_PASSWORD_LAYOUT_RES_ID));
+
+        // Entering an SSID alone does not enable the submit button.
+        enterSSID(TEST_SSID);
+        assertFalse(mDevice.wait(Until.findObject(
+                By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
+
+        // Entering an password that is too short does not enable submit button.
+        enterPassword(TEST_PW_LT_8_CHAR);
+        assertFalse(mDevice.wait(Until.findObject(
+                By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
+
+        // Submit button is only enabled after a password of valid length is entered.
+        enterPassword(TEST_PW_GE_8_CHAR);
+        assertTrue(mDevice.wait(Until.findObject(
+                By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
+    }
+
+    @Suppress
+    @MediumTest
+    public void testAddNetwork_EAP_PEAP() throws Exception {
+        loadAddNetworkMenu();
+        selectSecurityOption(SECURITY_OPTION_EAP_TEXT);
+        assertFalse(mDevice.wait(Until.findObject(
+                By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
+
+        selectEAPMethod(EAP_METHOD_PEAP_TEXT);
+
+        // Verify that EAP-PEAP fields appear.
+        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
+                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_PHASE2_RES_ID));
+        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
+                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_CACERT_RES_ID));
+        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
+                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_IDENTITY_LAYOUT_RES_ID));
+        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
+                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_ANONYMOUS_LAYOUT_RES_ID));
+        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
+                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_PASSWORD_LAYOUT_RES_ID));
+        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
+                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_SHOW_PASSWORD_LAYOUT_RES_ID));
+
+        // Entering an SSID alone does not enable the submit button.
+        enterSSID(TEST_SSID);
+        assertFalse(mDevice.wait(Until.findObject(
+                By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
+
+        verifyCaCertificateSubmitConditions();
+    }
+
+    @Suppress
+    @MediumTest
+    public void testAddNetwork_EAP_TLS() throws Exception {
+        loadAddNetworkMenu();
+        selectSecurityOption(SECURITY_OPTION_EAP_TEXT);
+        assertFalse(mDevice.wait(Until.findObject(
+                By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
+
+        selectEAPMethod(EAP_METHOD_TLS_TEXT);
+
+        // Verify that EAP-TLS fields appear.
+        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
+                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_CACERT_RES_ID));
+        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
+                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_USERCERT_RES_ID));
+        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
+                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_IDENTITY_LAYOUT_RES_ID));
+
+        // Entering an SSID alone does not enable the submit button.
+        enterSSID(TEST_SSID);
+        assertFalse(mDevice.wait(Until.findObject(
+                By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
+
+        // Selecting the User certificate "Do not provide" option alone does not enable the submit
+        // button.
+        selectUserCertificateOption(USERCERT_MENU_DO_NOT_PROVIDE_TEXT);
+        assertFalse(mDevice.wait(Until.findObject(
+                By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
+
+        verifyCaCertificateSubmitConditions();
+    }
+
+    @Suppress
+    @MediumTest
+    public void testAddNetwork_EAP_TTLS() throws Exception {
+        loadAddNetworkMenu();
+        selectSecurityOption(SECURITY_OPTION_EAP_TEXT);
+        assertFalse(mDevice.wait(Until.findObject(
+                By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
+
+        selectEAPMethod(EAP_METHOD_TTLS_TEXT);
+
+        // Verify that EAP-TLS fields appear.
+        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
+                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_PHASE2_RES_ID));
+        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
+                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_CACERT_RES_ID));
+        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
+                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_IDENTITY_LAYOUT_RES_ID));
+        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
+                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_ANONYMOUS_LAYOUT_RES_ID));
+        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
+                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_PASSWORD_LAYOUT_RES_ID));
+
+        // Entering an SSID alone does not enable the submit button.
+        enterSSID(TEST_SSID);
+        assertFalse(mDevice.wait(Until.findObject(
+                By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
+
+        verifyCaCertificateSubmitConditions();
+    }
+
+    @Suppress
+    @MediumTest
+    public void testAddNetwork_EAP_PWD() throws Exception {
+        loadAddNetworkMenu();
+        selectSecurityOption(SECURITY_OPTION_EAP_TEXT);
+        assertFalse(mDevice.wait(Until.findObject(
+                By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
+
+        selectEAPMethod(EAP_METHOD_PWD_TEXT);
+
+        // Verify that EAP-TLS fields appear.
+        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
+                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_IDENTITY_LAYOUT_RES_ID));
+        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
+                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_PASSWORD_LAYOUT_RES_ID));
+
+        // Entering an SSID alone enables the submit button.
+        enterSSID(TEST_SSID);
+        assertTrue(mDevice.wait(Until.findObject(
+                By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
+    }
+
+    @Suppress
+    @MediumTest
+    public void testAddNetwork_EAP_SIM() throws Exception {
+        loadAddNetworkMenu();
+        selectSecurityOption(SECURITY_OPTION_EAP_TEXT);
+        assertFalse(mDevice.wait(Until.findObject(
+                By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
+
+        selectEAPMethod(EAP_METHOD_SIM_TEXT);
+
+        // Entering an SSID alone enables the submit button.
+        enterSSID(TEST_SSID);
+        assertTrue(mDevice.wait(Until.findObject(
+                By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
+    }
+
+    @Suppress
+    @MediumTest
+    public void testAddNetwork_EAP_AKA() throws Exception {
+        loadAddNetworkMenu();
+        selectSecurityOption(SECURITY_OPTION_EAP_TEXT);
+        assertFalse(mDevice.wait(Until.findObject(
+                By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
+
+        selectEAPMethod(EAP_METHOD_AKA_TEXT);
+
+        // Entering an SSID alone enables the submit button.
+        enterSSID(TEST_SSID);
+        assertTrue(mDevice.wait(Until.findObject(
+                By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
+    }
+
+    @Suppress
+    @MediumTest
+    public void testAddNetwork_EAP_AKA_PRIME() throws Exception {
+        loadAddNetworkMenu();
+        selectSecurityOption(SECURITY_OPTION_EAP_TEXT);
+        assertFalse(mDevice.wait(Until.findObject(
+                By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
+
+        selectEAPMethod(EAP_METHOD_AKA_PRIME_TEXT);
+
+        // Entering an SSID alone enables the submit button.
+        enterSSID(TEST_SSID);
+        assertTrue(mDevice.wait(Until.findObject(
+                By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
+    }
+
+    private void verifyKeepWiFiOnDuringSleep(String settingToBeVerified, int settingValue)
+            throws Exception {
+        loadWiFiConfigureMenu();
+        mDevice.wait(Until.findObject(By.text("Keep Wi‑Fi on during sleep")), TIMEOUT)
+                .click();
+        mDevice.wait(Until.findObject(By.clazz("android.widget.CheckedTextView")
+                .text(settingToBeVerified)), TIMEOUT).click();
+        Thread.sleep(SLEEP_TIME);
+        int keepWiFiOnSetting =
+                Settings.Global.getInt(getInstrumentation().getContext().getContentResolver(),
+                Settings.Global.WIFI_SLEEP_POLICY);
+        assertEquals(settingValue, keepWiFiOnSetting);
+    }
+
+    private void verifyNetworkNotificationsOnOrOff(boolean verifyOn)
+            throws Exception {
+        // Enable network recommendations to enable the toggle switch for Network
+        // notifications
+        Settings.Global.putString(getInstrumentation().getContext().getContentResolver(),
+                Settings.Global.NETWORK_RECOMMENDATIONS_ENABLED, "1");
+        if (verifyOn) {
+            Settings.Global.putString(getInstrumentation().getContext().getContentResolver(),
+                    Settings.Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, "0");
+        }
+        else {
+            Settings.Global.putString(getInstrumentation().getContext().getContentResolver(),
+                    Settings.Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, "1");
+        }
+        loadWiFiConfigureMenu();
+        mDevice.wait(Until.findObject(By.text("Open network notification")), TIMEOUT)
+                .click();
+        Thread.sleep(SLEEP_TIME);
+        String wifiNotificationValue =
+                Settings.Global.getString(getInstrumentation().getContext().getContentResolver(),
+                Settings.Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON);
+        if (verifyOn) {
+            assertEquals("1", wifiNotificationValue);
+        }
+        else {
+            assertEquals("0", wifiNotificationValue);
+        }
+    }
+
+    private void verifyWiFiOnOrOff(boolean verifyOn) throws Exception {
+         String switchText = "On";
+         if (verifyOn) {
+             switchText = "Off";
+         }
+         loadWiFiSettingsPage(!verifyOn);
+         mDevice.wait(Until
+                 .findObject(By.res(SETTINGS_PACKAGE, "switch_bar").text(switchText)), TIMEOUT)
+                 .click();
+         Thread.sleep(SLEEP_TIME);
+         String wifiValue =
+                 Settings.Global.getString(getInstrumentation().getContext().getContentResolver(),
+                 Settings.Global.WIFI_ON);
+         if (verifyOn) {
+             // 1 is Enabled, 2 is Enabled while airplane mode is ON.
+             assertTrue(wifiValue.equals("1") || wifiValue.equals("2"));
+         }
+         else {
+             assertEquals("0", wifiValue);
+         }
+    }
+
+    private void verifyCaCertificateSubmitConditions() throws Exception {
+        // Selecting the CA certificate "Do not validate" option enables the submit button.
+        selectCaCertificateOption(CACERT_MENU_DO_NOT_VALIDATE_TEXT);
+        assertTrue(mDevice.wait(Until.findObject(
+                By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
+
+        // However, selecting the CA certificate "Use system certificates option" is not enough to
+        // enable the submit button.
+        selectCaCertificateOption(CACERT_MENU_USE_SYSTEM_CERTS_TEXT);
+        assertFalse(mDevice.wait(Until.findObject(
+                By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
+
+        // Submit button is only enabled after a domain is entered as well.
+        enterDomain(TEST_DOMAIN);
+        assertTrue(mDevice.wait(Until.findObject(
+                By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
+    }
+
+    private void loadWiFiSettingsPage(boolean wifiEnabled) throws Exception {
+        WifiManager wifiManager = (WifiManager)getInstrumentation().getContext()
+                .getSystemService(Context.WIFI_SERVICE);
+        wifiManager.setWifiEnabled(wifiEnabled);
+        SettingsHelper.launchSettingsPage(getInstrumentation().getContext(),
+                Settings.ACTION_WIFI_SETTINGS);
+    }
+
+    private void loadWiFiConfigureMenu() throws Exception {
+        loadWiFiSettingsPage(false);
+        Thread.sleep(TIMEOUT);
+        mDevice.wait(Until.findObject(By.text(CONFIGURE_WIFI_PREFERENCE_TEXT)), TIMEOUT).click();
+        mDevice.wait(Until.findObject(
+                By.text(CONFIGURE_WIFI_ADVANCED_PREFERENCE_TEXT)), TIMEOUT).click();
+    }
+
+    private void loadAddNetworkMenu() throws Exception {
+        loadWiFiSettingsPage(true);
+        for (int attempts = 0; attempts < MAX_ADD_NETWORK_BUTTON_ATTEMPTS; ++attempts) {
+            try {
+                findOrScrollToObject(By.scrollable(true), By.text(ADD_NETWORK_PREFERENCE_TEXT))
+                        .click();
+            } catch (StaleObjectException e) {
+                // The network list might have been updated between when the Add network button was
+                // found, and when it UI automator attempted to click on it. Retry.
+                continue;
+            }
+            // If we get here, we successfully clicked on the Add network button, so we are done.
+            Thread.sleep(SLEEP_TIME*5);
+            return;
+        }
+
+        fail("Failed to load Add Network Menu after " + MAX_ADD_NETWORK_BUTTON_ATTEMPTS
+                + " retries");
+    }
+
+    private void selectSecurityOption(String securityOption) throws Exception {
+        // We might not need to scroll to the security options if not enough add network menu
+        // options are visible.
+        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
+                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_SECURITY_OPTION_RES_ID)
+                .clazz(SPINNER_CLASS)).click();
+        Thread.sleep(SLEEP_TIME);
+        mDevice.wait(Until.findObject(By.text(securityOption)), TIMEOUT).click();
+    }
+
+    private void selectEAPMethod(String eapMethod) throws Exception {
+        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
+                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_EAP_METHOD_RES_ID).clazz(SPINNER_CLASS))
+                .click();
+        Thread.sleep(SLEEP_TIME);
+        findOrScrollToObject(SPINNER_OPTIONS_SCROLLABLE_BY_SELECTOR, By.text(eapMethod)).click();
+    }
+
+    private void selectUserCertificateOption(String userCertificateOption) throws Exception {
+        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
+                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_USERCERT_RES_ID).clazz(SPINNER_CLASS))
+                .click();
+        mDevice.wait(Until.findObject(By.text(userCertificateOption)), TIMEOUT).click();
+    }
+
+    private void selectCaCertificateOption(String caCertificateOption) throws Exception {
+        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
+                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_CACERT_RES_ID).clazz(SPINNER_CLASS))
+                .click();
+        mDevice.wait(Until.findObject(By.text(caCertificateOption)), TIMEOUT).click();
+    }
+
+    private void enterSSID(String ssid) throws Exception {
+        // We might not need to scroll to the SSID option if not enough add network menu options
+        // are visible.
+        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
+                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_SSID_RES_ID).clazz(EDIT_TEXT_CLASS))
+                .setText(ssid);
+    }
+
+    private void enterPassword(String password) throws Exception {
+        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
+                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_PASSWORD_RES_ID).clazz(EDIT_TEXT_CLASS))
+                .setText(password);
+    }
+
+    private void enterDomain(String domain) throws Exception {
+        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
+                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_DOMAIN_RES_ID)).setText(domain);
+    }
+
+    // Use this if the UI object might or might not need to be scrolled to.
+    private UiObject2 findOrScrollToObject(BySelector scrollableSelector, BySelector objectSelector)
+            throws Exception {
+        UiObject2 object = mDevice.wait(Until.findObject(objectSelector), TIMEOUT);
+        if (object == null) {
+            object = scrollToObject(scrollableSelector, objectSelector);
+        }
+        return object;
+    }
+
+    private UiObject2 scrollToObject(BySelector scrollableSelector, BySelector objectSelector)
+            throws Exception {
+        UiObject2 scrollable = mDevice.wait(Until.findObject(scrollableSelector), TIMEOUT);
+        if (scrollable == null) {
+            fail("Could not find scrollable UI object identified by " + scrollableSelector);
+        }
+        UiObject2 found = null;
+        // Scroll all the way up first, then all the way down.
+        while (true) {
+            // Optimization: terminate if we find the object while scrolling up to reset, so
+            // we save the time spent scrolling down again.
+            boolean canScrollAgain = scrollable.scroll(Direction.UP, SCROLL_UP_PERCENT,
+                    SCROLL_SPEED);
+            found = mDevice.findObject(objectSelector);
+            if (found != null) return found;
+            if (!canScrollAgain) break;
+        }
+        for (int attempts = 0; found == null && attempts < MAX_SCROLL_ATTEMPTS; ++attempts) {
+            // Return value of UiObject2.scroll() is not reliable, so do not use it in loop
+            // condition, in case it causes this loop to terminate prematurely.
+            scrollable.scroll(Direction.DOWN, SCROLL_DOWN_PERCENT, SCROLL_SPEED);
+            found = mDevice.findObject(objectSelector);
+        }
+        if (found == null) {
+            fail("Could not scroll to UI object identified by " + objectSelector);
+        }
+        return found;
+    }
+}
diff --git a/tests/uitests/src/com/android/settings/ui/SecuritySettingsLaunchTest.java b/tests/uitests/src/com/android/settings/ui/SecuritySettingsLaunchTest.java
index b730690..6803c7e 100644
--- a/tests/uitests/src/com/android/settings/ui/SecuritySettingsLaunchTest.java
+++ b/tests/uitests/src/com/android/settings/ui/SecuritySettingsLaunchTest.java
@@ -66,7 +66,7 @@
     public void launchSecuritySettings() throws Exception {
         // Launch Settings
         SettingsHelper.launchSettingsPage(
-                InstrumentationRegistry.getContext(), Settings.ACTION_SECURITY_SETTINGS);
+                InstrumentationRegistry.getTargetContext(), Settings.ACTION_SECURITY_SETTINGS);
         mHelper.scrollVert(false);
         for (String category : CATEGORIES) {
             SettingsTestUtils.assertTitleMatch(mDevice, category);
diff --git a/tests/uitests/src/com/android/settings/ui/StorageSettingsUITest.java b/tests/uitests/src/com/android/settings/ui/StorageSettingsUITest.java
new file mode 100644
index 0000000..a301cc3
--- /dev/null
+++ b/tests/uitests/src/com/android/settings/ui/StorageSettingsUITest.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2018 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.ui;
+
+import android.os.RemoteException;
+import android.provider.Settings;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.runner.AndroidJUnit4;
+import android.support.test.uiautomator.UiDevice;
+import android.system.helpers.SettingsHelper;
+import android.test.suitebuilder.annotation.MediumTest;
+
+import com.android.settings.ui.testutils.SettingsTestUtils;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(AndroidJUnit4.class)
+@MediumTest
+public class StorageSettingsUITest {
+
+    private static final String[] TITLES = {
+            "Photos & videos",
+            "Music & audio",
+            "Games",
+            "Movie & TV apps",
+            "Other apps",
+            "Files",
+            "System",
+    };
+    private UiDevice mDevice;
+    private SettingsHelper mHelper;
+
+
+    @Before
+    public void setUp() throws Exception {
+        mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
+        mHelper = SettingsHelper.getInstance();
+
+        try {
+            mDevice.setOrientationNatural();
+        } catch (RemoteException e) {
+            throw new RuntimeException("failed to freeze device orientation", e);
+        }
+    }
+
+    @After
+    public void tearDown() {
+        mDevice.pressHome();
+    }
+
+    @Test
+    public void launchStorageSettings() throws Exception {
+        // Launch Settings
+        SettingsHelper.launchSettingsPage(
+                InstrumentationRegistry.getTargetContext(),
+                Settings.ACTION_INTERNAL_STORAGE_SETTINGS);
+        mHelper.scrollVert(false);
+        for (String category : TITLES) {
+            SettingsTestUtils.assertTitleMatch(mDevice, category);
+        }
+    }
+}
diff --git a/tests/uitests/src/com/android/settings/ui/WirelessNetworkSettingsTests.java b/tests/uitests/src/com/android/settings/ui/WirelessNetworkSettingsTests.java
index 1e3b978..dd700ac 100644
--- a/tests/uitests/src/com/android/settings/ui/WirelessNetworkSettingsTests.java
+++ b/tests/uitests/src/com/android/settings/ui/WirelessNetworkSettingsTests.java
@@ -16,762 +16,108 @@
 
 package com.android.settings.ui;
 
+import static com.android.settings.ui.testutils.SettingsTestUtils.SETTINGS_PACKAGE;
+import static com.google.common.truth.Truth.assertThat;
+
 import android.content.Context;
-import android.content.Intent;
 import android.net.wifi.WifiManager;
 import android.os.RemoteException;
 import android.platform.test.annotations.Presubmit;
 import android.provider.Settings;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.runner.AndroidJUnit4;
+import android.support.test.uiautomator.By;
+import android.support.test.uiautomator.UiDevice;
+import android.support.test.uiautomator.Until;
 import android.system.helpers.CommandsHelper;
 import android.system.helpers.SettingsHelper;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.BySelector;
-import android.support.test.uiautomator.Direction;
-import android.support.test.uiautomator.StaleObjectException;
-import android.support.test.uiautomator.UiDevice;
-import android.support.test.uiautomator.UiObject2;
-import android.support.test.uiautomator.Until;
-import android.test.InstrumentationTestCase;
 import android.test.suitebuilder.annotation.MediumTest;
-import android.test.suitebuilder.annotation.Suppress;
 import android.util.Log;
-import junit.framework.AssertionFailedError;
 
-public class WirelessNetworkSettingsTests extends InstrumentationTestCase {
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Core tests for Wifi Settings.
+ */
+@RunWith(AndroidJUnit4.class)
+@MediumTest
+public class WirelessNetworkSettingsTests {
     // These back button presses are performed in tearDown() to exit Wifi
     // Settings sub-menus that a test might finish in. This number should be
     // high enough to account for the deepest sub-menu a test might enter.
     private static final int NUM_BACK_BUTTON_PRESSES = 5;
-    private static final int TIMEOUT = 2000;
+    private static final int TIMEOUT = 20000;
     private static final int SLEEP_TIME = 500;
     private static final String AIRPLANE_MODE_BROADCAST =
             "am broadcast -a android.intent.action.AIRPLANE_MODE";
-    private static final String TAG="WirelessNetworkSettingsTests";
+    private static final String TAG = "WirelessNetworkTests";
 
-    // Note: The values of these variables might affect flakiness in tests that involve
-    // scrolling. Adjust where necessary.
-    private static final float SCROLL_UP_PERCENT = 10.0f;
-    private static final float SCROLL_DOWN_PERCENT = 0.5f;
-    private static final int MAX_SCROLL_ATTEMPTS = 10;
-    private static final int MAX_ADD_NETWORK_BUTTON_ATTEMPTS = 3;
-    private static final int SCROLL_SPEED = 2000;
-
-    private static final String TEST_SSID = "testSsid";
-    private static final String TEST_PW_GE_8_CHAR = "testPasswordGreaterThan8Char";
-    private static final String TEST_PW_LT_8_CHAR = "lt8Char";
-    private static final String TEST_DOMAIN = "testDomain.com";
-
-    private static final String SETTINGS_PACKAGE = "com.android.settings";
-
-    private static final String CHECKBOX_CLASS = "android.widget.CheckBox";
-    private static final String SPINNER_CLASS = "android.widget.Spinner";
-    private static final String EDIT_TEXT_CLASS = "android.widget.EditText";
-    private static final String SCROLLVIEW_CLASS = "android.widget.ScrollView";
-    private static final String LISTVIEW_CLASS = "android.widget.ListView";
-
-    private static final String ADD_NETWORK_MENU_CANCEL_BUTTON_TEXT = "CANCEL";
-    private static final String ADD_NETWORK_MENU_SAVE_BUTTON_TEXT = "SAVE";
-    private static final String ADD_NETWORK_PREFERENCE_TEXT = "Add network";
-    private static final String CONFIGURE_WIFI_PREFERENCE_TEXT = "Wi‑Fi preferences";
-    private static final String CONFIGURE_WIFI_ADVANCED_PREFERENCE_TEXT = "Advanced";
-    private static final String CACERT_MENU_PLEASE_SELECT_TEXT = "Please select";
-    private static final String CACERT_MENU_USE_SYSTEM_CERTS_TEXT = "Use system certificates";
-    private static final String CACERT_MENU_DO_NOT_VALIDATE_TEXT = "Do not validate";
-    private static final String USERCERT_MENU_PLEASE_SELECT_TEXT = "Please select";
-    private static final String USERCERT_MENU_DO_NOT_PROVIDE_TEXT = "Do not provide";
-    private static final String SECURITY_OPTION_NONE_TEXT = "None";
-    private static final String SECURITY_OPTION_WEP_TEXT = "WEP";
-    private static final String SECURITY_OPTION_PSK_TEXT = "WPA/WPA2 PSK";
-    private static final String SECURITY_OPTION_EAP_TEXT = "802.1x EAP";
-    private static final String EAP_METHOD_PEAP_TEXT = "PEAP";
-    private static final String EAP_METHOD_TLS_TEXT = "TLS";
-    private static final String EAP_METHOD_TTLS_TEXT = "TTLS";
-    private static final String EAP_METHOD_PWD_TEXT = "PWD";
-    private static final String EAP_METHOD_SIM_TEXT = "SIM";
-    private static final String EAP_METHOD_AKA_TEXT = "AKA";
-    private static final String EAP_METHOD_AKA_PRIME_TEXT = "AKA'";
-    private static final String PHASE2_MENU_NONE_TEXT = "None";
-    private static final String PHASE2_MENU_MSCHAPV2_TEXT = "MSCHAPV2";
-    private static final String PHASE2_MENU_GTC_TEXT = "GTC";
-
-    private static final String ADD_NETWORK_MENU_ADV_TOGGLE_RES_ID = "wifi_advanced_togglebox";
-    private static final String ADD_NETWORK_MENU_IP_SETTINGS_RES_ID = "ip_settings";
-    private static final String ADD_NETWORK_MENU_PROXY_SETTINGS_RES_ID = "proxy_settings";
-    private static final String ADD_NETWORK_MENU_SECURITY_OPTION_RES_ID = "security";
-    private static final String ADD_NETWORK_MENU_EAP_METHOD_RES_ID = "method";
-    private static final String ADD_NETWORK_MENU_SSID_RES_ID = "ssid";
-    private static final String ADD_NETWORK_MENU_PHASE2_RES_ID = "phase2";
-    private static final String ADD_NETWORK_MENU_CACERT_RES_ID = "ca_cert";
-    private static final String ADD_NETWORK_MENU_USERCERT_RES_ID = "user_cert";
-    private static final String ADD_NETWORK_MENU_NO_DOMAIN_WARNING_RES_ID = "no_domain_warning";
-    private static final String ADD_NETWORK_MENU_NO_CACERT_WARNING_RES_ID = "no_ca_cert_warning";
-    private static final String ADD_NETWORK_MENU_DOMAIN_LAYOUT_RES_ID = "l_domain";
-    private static final String ADD_NETWORK_MENU_DOMAIN_RES_ID = "domain";
-    private static final String ADD_NETWORK_MENU_IDENTITY_LAYOUT_RES_ID = "l_identity";
-    private static final String ADD_NETWORK_MENU_ANONYMOUS_LAYOUT_RES_ID = "l_anonymous";
-    private static final String ADD_NETWORK_MENU_PASSWORD_LAYOUT_RES_ID = "password_layout";
-    private static final String ADD_NETWORK_MENU_SHOW_PASSWORD_LAYOUT_RES_ID =
-            "show_password_layout";
-    private static final String ADD_NETWORK_MENU_PASSWORD_RES_ID = "password";
-
-    private static final BySelector ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR =
-            By.scrollable(true).clazz(SCROLLVIEW_CLASS);
-    private static final BySelector SPINNER_OPTIONS_SCROLLABLE_BY_SELECTOR =
-            By.scrollable(true).clazz(LISTVIEW_CLASS);
 
     private UiDevice mDevice;
     private CommandsHelper mCommandsHelper;
 
-    @Override
+    @Before
     public void setUp() throws Exception {
-        super.setUp();
-        mDevice = UiDevice.getInstance(getInstrumentation());
+        mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
         try {
             mDevice.setOrientationNatural();
         } catch (RemoteException e) {
             throw new RuntimeException("failed to freeze device orientation", e);
         }
         // Ensure airplane mode is OFF so that wifi can be enabled using WiFiManager.
-        Settings.Global.putString(getInstrumentation().getContext().getContentResolver(),
+        Settings.Global.putString(InstrumentationRegistry.getTargetContext().getContentResolver(),
                 Settings.Global.AIRPLANE_MODE_ON, "0");
+
         Log.d(TAG, "sending airplane mode broadcast to device");
-        mCommandsHelper = CommandsHelper.getInstance();
+        mCommandsHelper = CommandsHelper.getInstance(InstrumentationRegistry.getInstrumentation());
         mCommandsHelper.executeShellCommand(AIRPLANE_MODE_BROADCAST);
     }
 
-    @Override
-    protected void tearDown() throws Exception {
+    @After
+    public void tearDown() {
         // Exit all settings sub-menus.
         for (int i = 0; i < NUM_BACK_BUTTON_PRESSES; ++i) {
             mDevice.pressBack();
         }
         mDevice.pressHome();
-        super.tearDown();
     }
 
     @Presubmit
-    @MediumTest
+    @Test
     public void testWiFiEnabled() throws Exception {
         verifyWiFiOnOrOff(true);
     }
 
     @Presubmit
-    @MediumTest
+    @Test
     public void testWiFiDisabled() throws Exception {
         verifyWiFiOnOrOff(false);
     }
 
-    @MediumTest
-    public void testWifiMenuLoadConfigure() throws Exception {
-        loadWiFiConfigureMenu();
-        Thread.sleep(SLEEP_TIME);
-        UiObject2 configureWiFiHeading = mDevice.wait(Until.findObject
-                (By.text(CONFIGURE_WIFI_PREFERENCE_TEXT)), TIMEOUT);
-        assertNotNull("Configure WiFi menu has not loaded correctly", configureWiFiHeading);
-    }
-
-    @MediumTest
-    public void testNetworkNotificationsOn() throws Exception {
-        verifyNetworkNotificationsOnOrOff(true);
-    }
-
-    @MediumTest
-    public void testNetworkNotificationsOff() throws Exception {
-        verifyNetworkNotificationsOnOrOff(false);
-    }
-
-    @MediumTest
-    public void testAddNetworkMenu_Default() throws Exception {
-        loadAddNetworkMenu();
-
-        // Submit button should be disabled by default, while cancel button should be enabled.
-        assertFalse(mDevice.wait(Until.findObject(
-                By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
-        assertTrue(mDevice.wait(Until.findObject(
-                By.text(ADD_NETWORK_MENU_CANCEL_BUTTON_TEXT)), TIMEOUT).isEnabled());
-
-        // Check that the SSID field is defaults to the hint.
-        assertEquals("Enter the SSID", mDevice.wait(Until.findObject(By
-                .res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_SSID_RES_ID)
-                .clazz(EDIT_TEXT_CLASS)), TIMEOUT*2)
-                .getText());
-
-        // Check Security defaults to None.
-        assertEquals("None", mDevice.wait(Until.findObject(By
-                .res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_SECURITY_OPTION_RES_ID)
-                .clazz(SPINNER_CLASS)), TIMEOUT)
-                .getChildren().get(0).getText());
-
-        // Check advanced options are collapsed by default.
-        assertFalse(mDevice.wait(Until.findObject(By
-                .res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_ADV_TOGGLE_RES_ID)
-                .clazz(CHECKBOX_CLASS)), TIMEOUT).isChecked());
-
-    }
-
-    @Suppress
-    @MediumTest
-    public void testAddNetworkMenu_Proxy() throws Exception {
-        loadAddNetworkMenu();
-
-        // Toggle advanced options.
-        mDevice.wait(Until.findObject(By
-                .res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_ADV_TOGGLE_RES_ID)
-                .clazz(CHECKBOX_CLASS)), TIMEOUT).click();
-
-        // Verify Proxy defaults to None.
-        BySelector proxySettingsBySelector =
-                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_PROXY_SETTINGS_RES_ID)
-                .clazz(SPINNER_CLASS);
-        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR, proxySettingsBySelector);
-        assertEquals("None", mDevice.wait(Until.findObject(proxySettingsBySelector), TIMEOUT)
-                .getChildren().get(0).getText());
-
-        // Verify that Proxy Manual fields appear.
-        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR, proxySettingsBySelector);
-        mDevice.wait(Until.findObject(proxySettingsBySelector), TIMEOUT).click();
-        mDevice.wait(Until.findObject(By.text("Manual")), TIMEOUT).click();
-        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
-                By.res(SETTINGS_PACKAGE, "proxy_warning_limited_support"));
-        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
-                By.res(SETTINGS_PACKAGE, "proxy_hostname"));
-        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
-                By.res(SETTINGS_PACKAGE, "proxy_exclusionlist"));
-
-        // Verify that Proxy Auto-Config options appear.
-        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR, proxySettingsBySelector);
-        mDevice.wait(Until.findObject(proxySettingsBySelector), TIMEOUT).click();
-        mDevice.wait(Until.findObject(By.text("Proxy Auto-Config")), TIMEOUT).click();
-        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
-                By.res(SETTINGS_PACKAGE, "proxy_pac"));
-    }
-
-    @Suppress
-    @MediumTest
-    public void testAddNetworkMenu_IpSettings() throws Exception {
-        loadAddNetworkMenu();
-
-        // Toggle advanced options.
-        mDevice.wait(Until.findObject(By
-                .res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_ADV_TOGGLE_RES_ID)
-                .clazz(CHECKBOX_CLASS)), TIMEOUT).click();
-
-        // Verify IP settings defaults to DHCP.
-        BySelector ipSettingsBySelector =
-                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_IP_SETTINGS_RES_ID).clazz(SPINNER_CLASS);
-        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR, ipSettingsBySelector);
-        assertEquals("DHCP", mDevice.wait(Until.findObject(ipSettingsBySelector), TIMEOUT)
-                .getChildren().get(0).getText());
-
-        // Verify that Static IP settings options appear.
-        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR, ipSettingsBySelector).click();
-        mDevice.wait(Until.findObject(By.text("Static")), TIMEOUT).click();
-        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
-                By.res(SETTINGS_PACKAGE, "ipaddress"));
-        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
-                By.res(SETTINGS_PACKAGE, "gateway"));
-        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
-                By.res(SETTINGS_PACKAGE, "network_prefix_length"));
-        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
-                By.res(SETTINGS_PACKAGE, "dns1"));
-        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
-                By.res(SETTINGS_PACKAGE, "dns2"));
-    }
-
-    @Suppress
-    @MediumTest
-    public void testPhase2Settings() throws Exception {
-        loadAddNetworkMenu();
-        selectSecurityOption(SECURITY_OPTION_EAP_TEXT);
-
-        BySelector phase2SettingsBySelector =
-                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_PHASE2_RES_ID).clazz(SPINNER_CLASS);
-        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR, phase2SettingsBySelector);
-        assertEquals(PHASE2_MENU_NONE_TEXT, mDevice.wait(Until
-                .findObject(phase2SettingsBySelector), TIMEOUT).getChildren().get(0).getText());
-        mDevice.wait(Until.findObject(phase2SettingsBySelector), TIMEOUT).click();
-        Thread.sleep(SLEEP_TIME);
-
-        // Verify Phase 2 authentication spinner options.
-        assertNotNull(mDevice.wait(Until.findObject(By.text(PHASE2_MENU_NONE_TEXT)), TIMEOUT));
-        assertNotNull(mDevice.wait(Until.findObject(By.text(PHASE2_MENU_MSCHAPV2_TEXT)), TIMEOUT));
-        assertNotNull(mDevice.wait(Until.findObject(By.text(PHASE2_MENU_GTC_TEXT)), TIMEOUT));
-    }
-
-    @Suppress
-    @MediumTest
-    public void testCaCertSettings() throws Exception {
-        loadAddNetworkMenu();
-        selectSecurityOption(SECURITY_OPTION_EAP_TEXT);
-
-        BySelector caCertSettingsBySelector =
-                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_CACERT_RES_ID).clazz(SPINNER_CLASS);
-        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR, caCertSettingsBySelector);
-        assertEquals(CACERT_MENU_PLEASE_SELECT_TEXT, mDevice.wait(Until
-                .findObject(caCertSettingsBySelector), TIMEOUT).getChildren().get(0).getText());
-        mDevice.wait(Until.findObject(caCertSettingsBySelector), TIMEOUT).click();
-        Thread.sleep(SLEEP_TIME);
-
-        // Verify CA certificate spinner options.
-        assertNotNull(mDevice.wait(Until.findObject(
-                By.text(CACERT_MENU_PLEASE_SELECT_TEXT)), TIMEOUT));
-        assertNotNull(mDevice.wait(Until.findObject(
-                By.text(CACERT_MENU_USE_SYSTEM_CERTS_TEXT)), TIMEOUT));
-        assertNotNull(mDevice.wait(Until.findObject(
-                By.text(CACERT_MENU_DO_NOT_VALIDATE_TEXT)), TIMEOUT));
-
-        // Verify that a domain field and warning appear when the user selects the
-        // "Use system certificates" option.
-        mDevice.wait(Until.findObject(By.text(CACERT_MENU_USE_SYSTEM_CERTS_TEXT)), TIMEOUT).click();
-        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
-                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_DOMAIN_LAYOUT_RES_ID));
-        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
-                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_NO_DOMAIN_WARNING_RES_ID));
-
-        // Verify that a warning appears when the user chooses the "Do Not Validate" option.
-        mDevice.wait(Until.findObject(caCertSettingsBySelector), TIMEOUT).click();
-        mDevice.wait(Until.findObject(By.text(CACERT_MENU_DO_NOT_VALIDATE_TEXT)), TIMEOUT).click();
-        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
-                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_NO_CACERT_WARNING_RES_ID));
-    }
-
-    @Suppress
-    @MediumTest
-    public void testAddNetwork_NoSecurity() throws Exception {
-        loadAddNetworkMenu();
-        selectSecurityOption(SECURITY_OPTION_NONE_TEXT);
-
-        // Entering an SSID is enough to enable the submit button. // TODO THIS GUY
-        enterSSID(TEST_SSID);
-        assertTrue(mDevice.wait(Until
-                .findObject(By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
-    }
-
-    @Suppress
-    @MediumTest
-    public void testAddNetwork_WEP() throws Exception {
-        loadAddNetworkMenu();
-        selectSecurityOption(SECURITY_OPTION_WEP_TEXT);
-        assertFalse(mDevice.wait(Until.findObject(
-                By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
-
-        // Verify that WEP fields appear.
-        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
-                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_PASSWORD_LAYOUT_RES_ID));
-        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
-                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_SHOW_PASSWORD_LAYOUT_RES_ID));
-
-        // Entering an SSID alone does not enable the submit button.
-        enterSSID(TEST_SSID);
-        assertFalse(mDevice.wait(Until.findObject(
-                By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
-
-        // Submit button is only enabled after a password is entered.
-        enterPassword(TEST_PW_GE_8_CHAR);
-        assertTrue(mDevice.wait(Until
-                .findObject(By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
-    }
-
-    @Suppress
-    @MediumTest
-    public void testAddNetwork_PSK() throws Exception {
-        loadAddNetworkMenu();
-        selectSecurityOption(SECURITY_OPTION_PSK_TEXT);
-        assertFalse(mDevice.wait(Until.findObject(
-                By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
-
-        // Verify that PSK fields appear.
-        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
-                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_PASSWORD_LAYOUT_RES_ID));
-        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
-                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_SHOW_PASSWORD_LAYOUT_RES_ID));
-
-        // Entering an SSID alone does not enable the submit button.
-        enterSSID(TEST_SSID);
-        assertFalse(mDevice.wait(Until.findObject(
-                By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
-
-        // Entering an password that is too short does not enable submit button.
-        enterPassword(TEST_PW_LT_8_CHAR);
-        assertFalse(mDevice.wait(Until.findObject(
-                By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
-
-        // Submit button is only enabled after a password of valid length is entered.
-        enterPassword(TEST_PW_GE_8_CHAR);
-        assertTrue(mDevice.wait(Until.findObject(
-                By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
-    }
-
-    @Suppress
-    @MediumTest
-    public void testAddNetwork_EAP_PEAP() throws Exception {
-        loadAddNetworkMenu();
-        selectSecurityOption(SECURITY_OPTION_EAP_TEXT);
-        assertFalse(mDevice.wait(Until.findObject(
-                By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
-
-        selectEAPMethod(EAP_METHOD_PEAP_TEXT);
-
-        // Verify that EAP-PEAP fields appear.
-        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
-                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_PHASE2_RES_ID));
-        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
-                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_CACERT_RES_ID));
-        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
-                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_IDENTITY_LAYOUT_RES_ID));
-        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
-                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_ANONYMOUS_LAYOUT_RES_ID));
-        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
-                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_PASSWORD_LAYOUT_RES_ID));
-        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
-                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_SHOW_PASSWORD_LAYOUT_RES_ID));
-
-        // Entering an SSID alone does not enable the submit button.
-        enterSSID(TEST_SSID);
-        assertFalse(mDevice.wait(Until.findObject(
-                By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
-
-        verifyCaCertificateSubmitConditions();
-    }
-
-    @Suppress
-    @MediumTest
-    public void testAddNetwork_EAP_TLS() throws Exception {
-        loadAddNetworkMenu();
-        selectSecurityOption(SECURITY_OPTION_EAP_TEXT);
-        assertFalse(mDevice.wait(Until.findObject(
-                By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
-
-        selectEAPMethod(EAP_METHOD_TLS_TEXT);
-
-        // Verify that EAP-TLS fields appear.
-        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
-                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_CACERT_RES_ID));
-        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
-                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_USERCERT_RES_ID));
-        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
-                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_IDENTITY_LAYOUT_RES_ID));
-
-        // Entering an SSID alone does not enable the submit button.
-        enterSSID(TEST_SSID);
-        assertFalse(mDevice.wait(Until.findObject(
-                By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
-
-        // Selecting the User certificate "Do not provide" option alone does not enable the submit
-        // button.
-        selectUserCertificateOption(USERCERT_MENU_DO_NOT_PROVIDE_TEXT);
-        assertFalse(mDevice.wait(Until.findObject(
-                By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
-
-        verifyCaCertificateSubmitConditions();
-    }
-
-    @Suppress
-    @MediumTest
-    public void testAddNetwork_EAP_TTLS() throws Exception {
-        loadAddNetworkMenu();
-        selectSecurityOption(SECURITY_OPTION_EAP_TEXT);
-        assertFalse(mDevice.wait(Until.findObject(
-                By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
-
-        selectEAPMethod(EAP_METHOD_TTLS_TEXT);
-
-        // Verify that EAP-TLS fields appear.
-        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
-                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_PHASE2_RES_ID));
-        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
-                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_CACERT_RES_ID));
-        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
-                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_IDENTITY_LAYOUT_RES_ID));
-        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
-                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_ANONYMOUS_LAYOUT_RES_ID));
-        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
-                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_PASSWORD_LAYOUT_RES_ID));
-
-        // Entering an SSID alone does not enable the submit button.
-        enterSSID(TEST_SSID);
-        assertFalse(mDevice.wait(Until.findObject(
-                By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
-
-        verifyCaCertificateSubmitConditions();
-    }
-
-    @Suppress
-    @MediumTest
-    public void testAddNetwork_EAP_PWD() throws Exception {
-        loadAddNetworkMenu();
-        selectSecurityOption(SECURITY_OPTION_EAP_TEXT);
-        assertFalse(mDevice.wait(Until.findObject(
-                By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
-
-        selectEAPMethod(EAP_METHOD_PWD_TEXT);
-
-        // Verify that EAP-TLS fields appear.
-        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
-                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_IDENTITY_LAYOUT_RES_ID));
-        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
-                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_PASSWORD_LAYOUT_RES_ID));
-
-        // Entering an SSID alone enables the submit button.
-        enterSSID(TEST_SSID);
-        assertTrue(mDevice.wait(Until.findObject(
-                By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
-    }
-
-    @Suppress
-    @MediumTest
-    public void testAddNetwork_EAP_SIM() throws Exception {
-        loadAddNetworkMenu();
-        selectSecurityOption(SECURITY_OPTION_EAP_TEXT);
-        assertFalse(mDevice.wait(Until.findObject(
-                By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
-
-        selectEAPMethod(EAP_METHOD_SIM_TEXT);
-
-        // Entering an SSID alone enables the submit button.
-        enterSSID(TEST_SSID);
-        assertTrue(mDevice.wait(Until.findObject(
-                By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
-    }
-
-    @Suppress
-    @MediumTest
-    public void testAddNetwork_EAP_AKA() throws Exception {
-        loadAddNetworkMenu();
-        selectSecurityOption(SECURITY_OPTION_EAP_TEXT);
-        assertFalse(mDevice.wait(Until.findObject(
-                By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
-
-        selectEAPMethod(EAP_METHOD_AKA_TEXT);
-
-        // Entering an SSID alone enables the submit button.
-        enterSSID(TEST_SSID);
-        assertTrue(mDevice.wait(Until.findObject(
-                By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
-    }
-
-    @Suppress
-    @MediumTest
-    public void testAddNetwork_EAP_AKA_PRIME() throws Exception {
-        loadAddNetworkMenu();
-        selectSecurityOption(SECURITY_OPTION_EAP_TEXT);
-        assertFalse(mDevice.wait(Until.findObject(
-                By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
-
-        selectEAPMethod(EAP_METHOD_AKA_PRIME_TEXT);
-
-        // Entering an SSID alone enables the submit button.
-        enterSSID(TEST_SSID);
-        assertTrue(mDevice.wait(Until.findObject(
-                By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
-    }
-
-    private void verifyKeepWiFiOnDuringSleep(String settingToBeVerified, int settingValue)
-            throws Exception {
-        loadWiFiConfigureMenu();
-        mDevice.wait(Until.findObject(By.text("Keep Wi‑Fi on during sleep")), TIMEOUT)
-                .click();
-        mDevice.wait(Until.findObject(By.clazz("android.widget.CheckedTextView")
-                .text(settingToBeVerified)), TIMEOUT).click();
-        Thread.sleep(SLEEP_TIME);
-        int keepWiFiOnSetting =
-                Settings.Global.getInt(getInstrumentation().getContext().getContentResolver(),
-                Settings.Global.WIFI_SLEEP_POLICY);
-        assertEquals(settingValue, keepWiFiOnSetting);
-    }
-
-    private void verifyNetworkNotificationsOnOrOff(boolean verifyOn)
-            throws Exception {
-        // Enable network recommendations to enable the toggle switch for Network
-        // notifications
-        Settings.Global.putString(getInstrumentation().getContext().getContentResolver(),
-                Settings.Global.NETWORK_RECOMMENDATIONS_ENABLED, "1");
-        if (verifyOn) {
-            Settings.Global.putString(getInstrumentation().getContext().getContentResolver(),
-                    Settings.Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, "0");
-        }
-        else {
-            Settings.Global.putString(getInstrumentation().getContext().getContentResolver(),
-                    Settings.Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, "1");
-        }
-        loadWiFiConfigureMenu();
-        mDevice.wait(Until.findObject(By.text("Open network notification")), TIMEOUT)
-                .click();
-        Thread.sleep(SLEEP_TIME);
-        String wifiNotificationValue =
-                Settings.Global.getString(getInstrumentation().getContext().getContentResolver(),
-                Settings.Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON);
-        if (verifyOn) {
-            assertEquals("1", wifiNotificationValue);
-        }
-        else {
-            assertEquals("0", wifiNotificationValue);
-        }
-    }
-
     private void verifyWiFiOnOrOff(boolean verifyOn) throws Exception {
-         String switchText = "On";
-         if (verifyOn) {
-             switchText = "Off";
-         }
-         loadWiFiSettingsPage(!verifyOn);
-         mDevice.wait(Until
-                 .findObject(By.res(SETTINGS_PACKAGE, "switch_bar").text(switchText)), TIMEOUT)
-                 .click();
-         Thread.sleep(SLEEP_TIME);
-         String wifiValue =
-                 Settings.Global.getString(getInstrumentation().getContext().getContentResolver(),
-                 Settings.Global.WIFI_ON);
-         if (verifyOn) {
-             // 1 is Enabled, 2 is Enabled while airplane mode is ON.
-             assertTrue(wifiValue.equals("1") || wifiValue.equals("2"));
-         }
-         else {
-             assertEquals("0", wifiValue);
-         }
-    }
-
-    private void verifyCaCertificateSubmitConditions() throws Exception {
-        // Selecting the CA certificate "Do not validate" option enables the submit button.
-        selectCaCertificateOption(CACERT_MENU_DO_NOT_VALIDATE_TEXT);
-        assertTrue(mDevice.wait(Until.findObject(
-                By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
-
-        // However, selecting the CA certificate "Use system certificates option" is not enough to
-        // enable the submit button.
-        selectCaCertificateOption(CACERT_MENU_USE_SYSTEM_CERTS_TEXT);
-        assertFalse(mDevice.wait(Until.findObject(
-                By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
-
-        // Submit button is only enabled after a domain is entered as well.
-        enterDomain(TEST_DOMAIN);
-        assertTrue(mDevice.wait(Until.findObject(
-                By.text(ADD_NETWORK_MENU_SAVE_BUTTON_TEXT)), TIMEOUT).isEnabled());
+        loadWiFiSettingsPage(!verifyOn);
+        mDevice.wait(Until.findObject(By.res(SETTINGS_PACKAGE, "switch_widget")), TIMEOUT)
+                .click();
+        Thread.sleep(SLEEP_TIME);
+        final String wifiValue = Settings.Global.getString(
+                InstrumentationRegistry.getTargetContext().getContentResolver(),
+                Settings.Global.WIFI_ON);
+        if (verifyOn) {
+            // 1 is Enabled, 2 is Enabled while airplane mode is ON.
+            assertThat(wifiValue).isAnyOf("1", "2");
+        } else {
+            assertThat(wifiValue).isEqualTo("0");
+        }
     }
 
     private void loadWiFiSettingsPage(boolean wifiEnabled) throws Exception {
-        WifiManager wifiManager = (WifiManager)getInstrumentation().getContext()
+        WifiManager wifiManager = (WifiManager) InstrumentationRegistry.getTargetContext()
                 .getSystemService(Context.WIFI_SERVICE);
         wifiManager.setWifiEnabled(wifiEnabled);
-        SettingsHelper.launchSettingsPage(getInstrumentation().getContext(),
+        SettingsHelper.launchSettingsPage(InstrumentationRegistry.getTargetContext(),
                 Settings.ACTION_WIFI_SETTINGS);
     }
-
-    private void loadWiFiConfigureMenu() throws Exception {
-        loadWiFiSettingsPage(false);
-        Thread.sleep(TIMEOUT);
-        mDevice.wait(Until.findObject(By.text(CONFIGURE_WIFI_PREFERENCE_TEXT)), TIMEOUT).click();
-        mDevice.wait(Until.findObject(
-                By.text(CONFIGURE_WIFI_ADVANCED_PREFERENCE_TEXT)), TIMEOUT).click();
-    }
-
-    private void loadAddNetworkMenu() throws Exception {
-        loadWiFiSettingsPage(true);
-        for (int attempts = 0; attempts < MAX_ADD_NETWORK_BUTTON_ATTEMPTS; ++attempts) {
-            try {
-                findOrScrollToObject(By.scrollable(true), By.text(ADD_NETWORK_PREFERENCE_TEXT))
-                        .click();
-            } catch (StaleObjectException e) {
-                // The network list might have been updated between when the Add network button was
-                // found, and when it UI automator attempted to click on it. Retry.
-                continue;
-            }
-            // If we get here, we successfully clicked on the Add network button, so we are done.
-            Thread.sleep(SLEEP_TIME*5);
-            return;
-        }
-
-        fail("Failed to load Add Network Menu after " + MAX_ADD_NETWORK_BUTTON_ATTEMPTS
-                + " retries");
-    }
-
-    private void selectSecurityOption(String securityOption) throws Exception {
-        // We might not need to scroll to the security options if not enough add network menu
-        // options are visible.
-        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
-                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_SECURITY_OPTION_RES_ID)
-                .clazz(SPINNER_CLASS)).click();
-        Thread.sleep(SLEEP_TIME);
-        mDevice.wait(Until.findObject(By.text(securityOption)), TIMEOUT).click();
-    }
-
-    private void selectEAPMethod(String eapMethod) throws Exception {
-        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
-                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_EAP_METHOD_RES_ID).clazz(SPINNER_CLASS))
-                .click();
-        Thread.sleep(SLEEP_TIME);
-        findOrScrollToObject(SPINNER_OPTIONS_SCROLLABLE_BY_SELECTOR, By.text(eapMethod)).click();
-    }
-
-    private void selectUserCertificateOption(String userCertificateOption) throws Exception {
-        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
-                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_USERCERT_RES_ID).clazz(SPINNER_CLASS))
-                .click();
-        mDevice.wait(Until.findObject(By.text(userCertificateOption)), TIMEOUT).click();
-    }
-
-    private void selectCaCertificateOption(String caCertificateOption) throws Exception {
-        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
-                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_CACERT_RES_ID).clazz(SPINNER_CLASS))
-                .click();
-        mDevice.wait(Until.findObject(By.text(caCertificateOption)), TIMEOUT).click();
-    }
-
-    private void enterSSID(String ssid) throws Exception {
-        // We might not need to scroll to the SSID option if not enough add network menu options
-        // are visible.
-        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
-                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_SSID_RES_ID).clazz(EDIT_TEXT_CLASS))
-                .setText(ssid);
-    }
-
-    private void enterPassword(String password) throws Exception {
-        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
-                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_PASSWORD_RES_ID).clazz(EDIT_TEXT_CLASS))
-                .setText(password);
-    }
-
-    private void enterDomain(String domain) throws Exception {
-        findOrScrollToObject(ADD_NETWORK_MENU_SCROLLABLE_BY_SELECTOR,
-                By.res(SETTINGS_PACKAGE, ADD_NETWORK_MENU_DOMAIN_RES_ID)).setText(domain);
-    }
-
-    // Use this if the UI object might or might not need to be scrolled to.
-    private UiObject2 findOrScrollToObject(BySelector scrollableSelector, BySelector objectSelector)
-            throws Exception {
-        UiObject2 object = mDevice.wait(Until.findObject(objectSelector), TIMEOUT);
-        if (object == null) {
-            object = scrollToObject(scrollableSelector, objectSelector);
-        }
-        return object;
-    }
-
-    private UiObject2 scrollToObject(BySelector scrollableSelector, BySelector objectSelector)
-            throws Exception {
-        UiObject2 scrollable = mDevice.wait(Until.findObject(scrollableSelector), TIMEOUT);
-        if (scrollable == null) {
-            fail("Could not find scrollable UI object identified by " + scrollableSelector);
-        }
-        UiObject2 found = null;
-        // Scroll all the way up first, then all the way down.
-        while (true) {
-            // Optimization: terminate if we find the object while scrolling up to reset, so
-            // we save the time spent scrolling down again.
-            boolean canScrollAgain = scrollable.scroll(Direction.UP, SCROLL_UP_PERCENT,
-                    SCROLL_SPEED);
-            found = mDevice.findObject(objectSelector);
-            if (found != null) return found;
-            if (!canScrollAgain) break;
-        }
-        for (int attempts = 0; found == null && attempts < MAX_SCROLL_ATTEMPTS; ++attempts) {
-            // Return value of UiObject2.scroll() is not reliable, so do not use it in loop
-            // condition, in case it causes this loop to terminate prematurely.
-            scrollable.scroll(Direction.DOWN, SCROLL_DOWN_PERCENT, SCROLL_SPEED);
-            found = mDevice.findObject(objectSelector);
-        }
-        if (found == null) {
-            fail("Could not scroll to UI object identified by " + objectSelector);
-        }
-        return found;
-    }
 }
diff --git a/tests/uitests/src/com/android/settings/ui/ZonePickerSettingsTest.java b/tests/uitests/src/com/android/settings/ui/ZonePickerSettingsTest.java
new file mode 100644
index 0000000..109c3bc
--- /dev/null
+++ b/tests/uitests/src/com/android/settings/ui/ZonePickerSettingsTest.java
@@ -0,0 +1,226 @@
+/*
+ * Copyright (C) 2018 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.ui;
+
+import android.os.RemoteException;
+import android.os.SystemProperties;
+import android.provider.Settings;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.filters.MediumTest;
+import android.support.test.runner.AndroidJUnit4;
+import android.support.test.uiautomator.By;
+import android.support.test.uiautomator.BySelector;
+import android.support.test.uiautomator.UiDevice;
+import android.support.test.uiautomator.UiObject;
+import android.support.test.uiautomator.UiObject2;
+import android.support.test.uiautomator.UiObjectNotFoundException;
+import android.support.test.uiautomator.UiScrollable;
+import android.support.test.uiautomator.UiSelector;
+import android.support.test.uiautomator.Until;
+import android.system.helpers.SettingsHelper;
+import android.system.helpers.SettingsHelper.SettingsType;
+import android.widget.ListView;
+import android.widget.Spinner;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.util.TimeZone;
+
+import static com.android.settings.ui.testutils.SettingsTestUtils.SETTINGS_PACKAGE;
+import static com.android.settings.ui.testutils.SettingsTestUtils.TIMEOUT;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+@MediumTest
+@RunWith(AndroidJUnit4.class)
+public class ZonePickerSettingsTest {
+
+    private static final BySelector SELECTOR_SELECT_TIME_ZONE =
+            By.hasChild(By.text("Select time zone"));
+
+    private UiDevice mDevice;
+    private SettingsHelper mHelper;
+    private String mIsV2EnabledByDefault;
+    private int mIsAutoZoneEnabled;
+
+    @Before
+    public void setUp() throws Exception {
+        mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
+        mHelper = SettingsHelper.getInstance();
+        try {
+            mDevice.setOrientationNatural();
+        } catch (RemoteException e) {
+            throw new RuntimeException("failed to freeze device orientation", e);
+        }
+        mIsV2EnabledByDefault = mHelper.getStringSetting(SettingsType.GLOBAL,
+                "settings_zone_picker_v2");
+        mHelper.setStringSetting(SettingsType.GLOBAL, "settings_zone_picker_v2", "true");
+        mIsAutoZoneEnabled = mHelper.getIntSetting(SettingsType.GLOBAL,
+                Settings.Global.AUTO_TIME_ZONE);
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        // Go back to home for next test.
+        mDevice.pressBack();
+        mDevice.pressBack();
+        mDevice.pressHome();
+        mDevice.waitForIdle(TIMEOUT * 2);
+        mHelper.setStringSetting(SettingsType.GLOBAL, "settings_zone_picker_v2",
+                mIsV2EnabledByDefault);
+        mHelper.setIntSetting(SettingsType.GLOBAL, Settings.Global.AUTO_TIME_ZONE,
+                mIsAutoZoneEnabled);
+    }
+
+    @Test
+    public void zonePickerDisabled() throws Exception {
+        mHelper.setIntSetting(SettingsType.GLOBAL, Settings.Global.AUTO_TIME_ZONE, 1);
+
+        SettingsHelper.launchSettingsPage(
+                InstrumentationRegistry.getContext(), Settings.ACTION_DATE_SETTINGS);
+        UiObject2 selectTimeZone = wait(SELECTOR_SELECT_TIME_ZONE);
+        assertFalse(selectTimeZone.isEnabled());
+    }
+
+    // Test 2 time zones with no DST
+    @Test
+    public void testSelectReykjavik() throws Exception {
+        testSelectTimeZone("Iceland", "Reykjavik", "GMT+00:00", "Atlantic/Reykjavik");
+    }
+
+    @Test
+    public void testSelectPhoenix() throws Exception {
+        testSelectTimeZone("United States", "Phoenix", "GMT-07:00", "America/Phoenix");
+    }
+
+    private void testSelectTimeZone(String region, String timezone, String expectedTimeZoneOffset,
+            String expectedTimeZoneId) throws Exception {
+        mHelper.setIntSetting(SettingsType.GLOBAL, Settings.Global.AUTO_TIME_ZONE, 0);
+
+        SettingsHelper.launchSettingsPage(
+                InstrumentationRegistry.getContext(), Settings.ACTION_DATE_SETTINGS);
+
+        UiObject2 selectTimeZone = wait(SELECTOR_SELECT_TIME_ZONE);
+        assertTrue(selectTimeZone.isEnabled());
+        selectTimeZone.click();
+
+        // Select region in the dropdown list
+        selectScrollableItem(selectDropDownInSpinner(By.clazz(Spinner.class)),
+                new UiSelector().textContains(region))
+                .click();
+
+        // Select time zone
+        selectScrollableItem(selectTimeZoneList(),
+                new UiSelector().textContains(timezone))
+                .click();
+
+        // The select button should include the GMT offset in the summary
+        BySelector summarySelector = By.res("android:id/summary");
+        UiObject2 selectedTimeZone = selectTimeZone.findObject(summarySelector);
+        assertUiObjectFound(selectedTimeZone, summarySelector);
+        assertTrue("Expect " + expectedTimeZoneOffset + " is shown for " + timezone,
+                selectedTimeZone.getText().startsWith(expectedTimeZoneOffset));
+
+        waitAndAssertTimeGetDefault(expectedTimeZoneId);
+        assertEquals("Time zone change in Settings should update persist.sys.timezone",
+                expectedTimeZoneId, SystemProperties.get("persist.sys.timezone"));
+    }
+
+    private static final long CHECK_DEFAULT_TIMEZONE_INTERVAL = 200L;
+    private static final long CHECK_DEFAULT_TIMEZONE_TIMEOUT = 3000L;
+
+    /**
+     * Wait for the broadcast ACTION_TIMEZONE_CHANGED propagated, and update the default TimeZone
+     * by ApplicationThread.
+     */
+    private static void waitAndAssertTimeGetDefault(String expectedTimeZoneId)
+            throws InterruptedException {
+        for (int i = 0; i < CHECK_DEFAULT_TIMEZONE_TIMEOUT / CHECK_DEFAULT_TIMEZONE_INTERVAL; i++) {
+            if (expectedTimeZoneId.equals(TimeZone.getDefault().getID())) {
+                return;
+            }
+            Thread.sleep(CHECK_DEFAULT_TIMEZONE_INTERVAL);
+        }
+
+        assertEquals(expectedTimeZoneId, TimeZone.getDefault().getID());
+    }
+
+    /**
+     * Perform click on {@link Spinner} and return the pop-up dropdown list.
+     * @return UiScrollable representing the pop-up dropdown after clicking on the spinner
+     */
+    private UiScrollable selectDropDownInSpinner(BySelector spinnerSelector)
+            throws UiObjectNotFoundException {
+        UiObject2 spinner = wait(spinnerSelector);
+        spinner.click();
+
+        UiSelector dropDownSelector = new UiSelector().className(ListView.class);
+        return new UiScrollable(dropDownSelector);
+    }
+
+    private UiScrollable selectTimeZoneList() {
+        return new UiScrollable(new UiSelector().resourceId(SETTINGS_PACKAGE + ":id/tz_list"));
+    }
+
+    /**
+     * Select the child object in the UiScrollable
+     * @throws UiObjectNotFoundException if scrollable or child is not found
+     */
+    private UiObject selectScrollableItem(UiScrollable scrollable, UiSelector childSelector)
+            throws UiObjectNotFoundException {
+        if (!scrollable.waitForExists(TIMEOUT)) {
+            throw newUiObjectNotFoundException(scrollable.getSelector());
+        }
+        scrollable.scrollIntoView(childSelector);
+
+        UiObject child = mDevice.findObject(childSelector);
+        assertUiObjectFound(child, childSelector);
+        return child;
+    }
+
+    /**
+     * @throws UiObjectNotFoundException if UiDevice.wait returns null
+     */
+    private UiObject2 wait(BySelector selector) throws UiObjectNotFoundException {
+        UiObject2 item = mDevice.wait(Until.findObject(selector), TIMEOUT);
+        assertUiObjectFound(item, selector);
+        return item;
+    }
+
+    private static void assertUiObjectFound(UiObject2 obj, BySelector selector)
+            throws UiObjectNotFoundException {
+        if (obj == null) {
+            throw newUiObjectNotFoundException(selector);
+        }
+    }
+
+
+    private static void assertUiObjectFound(UiObject obj, UiSelector selector)
+            throws UiObjectNotFoundException {
+        if (obj == null) {
+            throw newUiObjectNotFoundException(selector);
+        }
+    }
+
+    private static UiObjectNotFoundException newUiObjectNotFoundException(Object selector) {
+        return new UiObjectNotFoundException(
+                String.format("UI object not found: %s", selector.toString()));
+    }
+}
diff --git a/tests/unit/src/com/android/settings/applications/PackageUtilTest.java b/tests/unit/src/com/android/settings/applications/PackageUtilTest.java
deleted file mode 100644
index 0e3c402..0000000
--- a/tests/unit/src/com/android/settings/applications/PackageUtilTest.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (C) 2016 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.pm.ApplicationInfo;
-import android.content.pm.PackageManager;
-import android.content.pm.UserInfo;
-import android.os.UserManager;
-import android.support.test.filters.SmallTest;
-import android.support.test.runner.AndroidJUnit4;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import static junit.framework.Assert.assertEquals;
-import static org.mockito.Mockito.when;
-
-@RunWith(AndroidJUnit4.class)
-@SmallTest
-@Deprecated
-public class PackageUtilTest {
-    private static final String ALL_USERS_APP_NAME = "com.google.allusers.app";
-    private static final String ONE_USER_APP_NAME = "com.google.oneuser.app";
-    private static final int USER1_ID = 1;
-    private static final int USER2_ID = 11;
-
-    @Mock
-    private PackageManager mMockPackageManager;
-    @Mock
-    private UserManager mMockUserManager;
-
-    private InstalledAppDetails.PackageUtil mPackageUtil;
-    private List<UserInfo> mUserInfos;
-
-    @Before
-    public void setUp() throws PackageManager.NameNotFoundException {
-        MockitoAnnotations.initMocks(this);
-
-        mUserInfos = new ArrayList<>();
-        mUserInfos.add(new UserInfo(USER1_ID, "lei", 0));
-        mUserInfos.add(new UserInfo(USER2_ID, "yue", 0));
-        when(mMockUserManager.getUsers(true)).thenReturn(mUserInfos);
-
-        ApplicationInfo usersApp = new ApplicationInfo();
-        usersApp.flags = ApplicationInfo.FLAG_INSTALLED;
-
-        when(mMockPackageManager.getApplicationInfoAsUser(
-                ALL_USERS_APP_NAME, PackageManager.GET_META_DATA, USER1_ID))
-                .thenReturn(usersApp);
-        when(mMockPackageManager.getApplicationInfoAsUser(
-                ALL_USERS_APP_NAME, PackageManager.GET_META_DATA, USER2_ID))
-                .thenReturn(usersApp);
-
-        when(mMockPackageManager.getApplicationInfoAsUser(
-                ONE_USER_APP_NAME, PackageManager.GET_META_DATA, USER1_ID))
-                .thenReturn(usersApp);
-
-        when(mMockPackageManager.getApplicationInfoAsUser(
-                ONE_USER_APP_NAME, PackageManager.GET_META_DATA, USER2_ID))
-                .thenThrow(new PackageManager.NameNotFoundException());
-
-        mPackageUtil = new InstalledAppDetails.PackageUtil();
-    }
-
-    @Test
-    public void testCountPackageInUsers_twoUsersInstalled_returnTwo() {
-        assertEquals(2, mPackageUtil.countPackageInUsers(
-                mMockPackageManager, mMockUserManager, ALL_USERS_APP_NAME));
-    }
-
-    @Test
-    public void testCountPackageInUsers_oneUsersInstalled_returnOne() {
-        assertEquals(1, mPackageUtil.countPackageInUsers(
-                mMockPackageManager, mMockUserManager, ONE_USER_APP_NAME));
-    }
-}
diff --git a/tests/unit/src/com/android/settings/CreateShortcutTest.java b/tests/unit/src/com/android/settings/shortcut/CreateShortcutTest.java
similarity index 90%
rename from tests/unit/src/com/android/settings/CreateShortcutTest.java
rename to tests/unit/src/com/android/settings/shortcut/CreateShortcutTest.java
index 4ae9bd7..5ec008b 100644
--- a/tests/unit/src/com/android/settings/CreateShortcutTest.java
+++ b/tests/unit/src/com/android/settings/shortcut/CreateShortcutTest.java
@@ -14,12 +14,10 @@
  * limitations under the License.
  */
 
-package com.android.settings;
+package com.android.settings.shortcut;
 
 import static android.support.test.espresso.Espresso.onView;
 import static android.support.test.espresso.assertion.ViewAssertions.doesNotExist;
-import static android.support.test.espresso.matcher.ViewMatchers.withText;
-
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.mockito.Mockito.any;
@@ -39,9 +37,13 @@
 import android.content.pm.ShortcutInfo;
 import android.content.pm.ShortcutManager;
 import android.support.test.InstrumentationRegistry;
+import android.support.test.espresso.matcher.ViewMatchers;
 import android.support.test.filters.SmallTest;
 import android.support.test.runner.AndroidJUnit4;
 
+import com.android.settings.R;
+import com.android.settings.Settings;
+
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -55,12 +57,6 @@
 
 /**
  * Tests for {@link CreateShortcutTest}
- *
- m SettingsTests &&
- adb install \
- -r -g  ${ANDROID_PRODUCT_OUT}/data/app/SettingsTests/SettingsTests.apk &&
- adb shell am instrument -e class com.android.settings.CreateShortcutTest \
- -w com.android.settings.tests/android.support.test.runner.AndroidJUnitRunner
  */
 @RunWith(AndroidJUnit4.class)
 @SmallTest
@@ -71,8 +67,10 @@
     private Instrumentation mInstrumentation;
     private Context mContext;
 
-    @Mock ShortcutManager mShortcutManager;
-    @Captor ArgumentCaptor<List<ShortcutInfo>> mListCaptor;
+    @Mock
+    ShortcutManager mShortcutManager;
+    @Captor
+    ArgumentCaptor<List<ShortcutInfo>> mListCaptor;
 
     @Before
     public void setup() {
@@ -84,15 +82,17 @@
     @Test
     public void test_layoutDoesNotHaveCancelButton() {
         mInstrumentation.startActivitySync(new Intent(Intent.ACTION_CREATE_SHORTCUT)
-                .setClassName(mContext, CreateShortcut.class.getName()));
-        onView(withText(R.string.cancel)).check(doesNotExist());
+                .setClassName(mContext, CreateShortcut.class.getName())
+                .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
+        onView(ViewMatchers.withText(R.string.cancel)).check(doesNotExist());
     }
 
     @Test
     public void createResultIntent() {
         CreateShortcut orgActivity = (CreateShortcut) mInstrumentation.startActivitySync(
                 new Intent(Intent.ACTION_CREATE_SHORTCUT)
-                        .setClassName(mContext, CreateShortcut.class.getName()));
+                        .setClassName(mContext, CreateShortcut.class.getName())
+                        .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
         CreateShortcut activity = spy(orgActivity);
         doReturn(mShortcutManager).when(activity).getSystemService(eq(Context.SHORTCUT_SERVICE));