Merge "Align the profile calculation with other screens."
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 5ef5caf..b3db932 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -122,38 +122,6 @@
             <meta-data android:name="android.app.shortcuts" android:resource="@xml/shortcuts"/>
         </activity-alias>
 
-        <activity android:name=".Settings$WirelessSettings"
-            android:label="@string/header_category_wireless_networks">
-            <intent-filter android:priority="4">
-                <action android:name="com.android.settings.category.wireless" />
-                <category android:name="android.intent.category.DEFAULT" />
-            </intent-filter>
-        </activity>
-
-        <activity android:name=".Settings$DeviceSettings"
-            android:label="@string/header_category_device">
-            <intent-filter android:priority="3">
-                <action android:name="com.android.settings.category.device" />
-                <category android:name="android.intent.category.DEFAULT" />
-            </intent-filter>
-        </activity>
-
-        <activity android:name=".Settings$PersonalSettings"
-            android:label="@string/header_category_personal">
-            <intent-filter android:priority="2">
-                <action android:name="com.android.settings.category.personal" />
-                <category android:name="android.intent.category.DEFAULT" />
-            </intent-filter>
-        </activity>
-
-        <activity android:name=".SystemSettings"
-            android:label="@string/header_category_system">
-            <intent-filter android:priority="1">
-                <action android:name="com.android.settings.category.system" />
-                <category android:name="android.intent.category.DEFAULT" />
-            </intent-filter>
-        </activity>
-
         <receiver android:name=".SettingsInitialize">
             <intent-filter>
                 <action android:name="android.intent.action.USER_INITIALIZE"/>
@@ -179,7 +147,7 @@
         <activity android:name=".Settings$NetworkDashboardActivity"
             android:taskAffinity="com.android.settings"
             android:label="@string/network_dashboard_title"
-            android:icon="@drawable/ic_dashboard_network"
+            android:icon="@drawable/ic_settings_wireless"
             android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.WIRELESS_SETTINGS" />
@@ -265,11 +233,6 @@
                 <category android:name="android.intent.category.VOICE_LAUNCH" />
                 <category android:name="com.android.settings.SHORTCUT" />
             </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.wireless" />
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                 android:value="com.android.settings.wifi.WifiSettings" />
             <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
@@ -440,11 +403,6 @@
                 <category android:name="com.android.settings.SHORTCUT" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
-            <intent-filter android:priority="3">
-                <action android:name="com.android.settings.action.SETTINGS" />
-            </intent-filter>
-            <meta-data android:name="com.android.settings.category"
-                android:value="com.android.settings.category.wireless" />
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                 android:value="com.android.settings.bluetooth.BluetoothSettings" />
         </activity>
@@ -916,7 +874,7 @@
 
         <activity android:name="Settings$DisplaySettingsActivity"
                 android:label="@string/display_settings"
-                android:icon="@drawable/ic_dashboard_display"
+                android:icon="@drawable/ic_settings_display"
                 android:taskAffinity="">
             <intent-filter android:priority="1">
                 <action android:name="com.android.settings.DISPLAY_SETTINGS" />
@@ -1020,11 +978,11 @@
                 <category android:name="android.intent.category.VOICE_LAUNCH" />
                 <category android:name="com.android.settings.SHORTCUT" />
             </intent-filter>
-            <intent-filter android:priority="6">
+            <intent-filter android:priority="200">
                 <action android:name="com.android.settings.action.SETTINGS" />
             </intent-filter>
             <meta-data android:name="com.android.settings.category"
-                android:value="com.android.settings.category.device" />
+                android:value="com.android.settings.category.ia.apps" />
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                 android:value="com.android.settings.applications.ManageApplications" />
             <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
@@ -1039,8 +997,6 @@
                 <action android:name="android.settings.MANAGE_DOMAIN_URLS" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
-            <meta-data android:name="com.android.settings.category"
-                       android:value="com.android.settings.category.device" />
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                        android:value="com.android.settings.applications.ManageDomainUrls" />
         </activity>
@@ -1069,8 +1025,6 @@
                 <action android:name="android.settings.APP_MEMORY_USAGE" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
-            <meta-data android:name="com.android.settings.category"
-                       android:value="com.android.settings.category.device" />
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                        android:value="com.android.settings.applications.ProcessStatsUi" />
         </activity>
@@ -1285,11 +1239,6 @@
                 <category android:name="android.intent.category.VOICE_LAUNCH" />
                 <category android:name="com.android.settings.SHORTCUT" />
             </intent-filter>
-            <intent-filter android:priority="3">
-                <action android:name="com.android.settings.action.SETTINGS" />
-            </intent-filter>
-            <meta-data android:name="com.android.settings.category"
-                android:value="com.android.settings.category.personal" />
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                 android:value="com.android.settings.location.LocationSettings" />
             <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
@@ -1298,7 +1247,7 @@
 
         <activity android:name="Settings$SecuritySettingsActivity"
                 android:label="@string/security_settings_title"
-                android:icon="@drawable/ic_dashboard_security"
+                android:icon="@drawable/ic_settings_security"
                 android:configChanges="orientation|keyboardHidden|screenSize"
                 android:taskAffinity=""
                 android:parentActivityName="Settings">
@@ -1500,8 +1449,6 @@
                 <action android:name="android.settings.ACCESSIBILITY_SETTINGS_FOR_SUW" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
-            <meta-data android:name="com.android.settings.category"
-                android:value="com.android.settings.category.system" />
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                 android:value="com.android.settings.accessibility.AccessibilitySettingsForSetupWizard" />
             <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
@@ -1814,8 +1761,8 @@
                 android:value="com.android.settings.deviceinfo.ImeiInformation" />
         </activity>
 
-        <activity android:name="Settings$StorageSettingsActivity"
-                android:label="@string/storage_settings_title"
+        <activity android:name=".Settings$StorageDashboardActivity"
+                android:label="@string/storage_settings"
                 android:icon="@drawable/ic_settings_storage"
                 android:taskAffinity="com.android.settings"
                 android:parentActivityName="Settings">
@@ -1833,7 +1780,7 @@
                 <action android:name="com.android.settings.action.SETTINGS" />
             </intent-filter>
             <meta-data android:name="com.android.settings.category"
-                android:value="com.android.settings.category.device" />
+                android:value="com.android.settings.category.ia.homepage" />
             <meta-data android:name="com.android.settings.title"
                 android:resource="@string/storage_usb_settings" />
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
@@ -1845,7 +1792,7 @@
         <activity android:name="Settings$PrivateVolumeSettingsActivity"
                 android:label="@string/storage_settings_title"
                 android:taskAffinity="com.android.settings"
-                android:parentActivityName="Settings$StorageSettingsActivity">
+                android:parentActivityName="Settings$StorageDashboardActivity">
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                 android:value="com.android.settings.deviceinfo.PrivateVolumeSettings" />
         </activity>
@@ -1853,7 +1800,7 @@
         <activity android:name="Settings$PublicVolumeSettingsActivity"
                 android:label="@string/storage_settings_title"
                 android:taskAffinity="com.android.settings"
-                android:parentActivityName="Settings$StorageSettingsActivity">
+                android:parentActivityName="Settings$StorageDashboardActivity">
             <intent-filter>
                 <action android:name="android.provider.action.DOCUMENT_ROOT_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -1869,7 +1816,7 @@
         <activity android:name="Settings$PrivateVolumeForgetActivity"
                 android:label="@string/storage_settings_title"
                 android:taskAffinity="com.android.settings"
-                android:parentActivityName="Settings$StorageSettingsActivity"
+                android:parentActivityName="Settings$StorageDashboardActivity"
                 android:exported="true"
                 android:permission="android.permission.MOUNT_UNMOUNT_FILESYSTEMS">
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
@@ -2443,11 +2390,11 @@
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
-            <intent-filter android:priority="2">
+            <intent-filter android:priority="8">
                 <action android:name="com.android.settings.action.SETTINGS" />
             </intent-filter>
             <meta-data android:name="com.android.settings.category"
-                android:value="com.android.settings.category.device" />
+                android:value="com.android.settings.category.ia.accounts" />
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                 android:value="com.android.settings.users.UserSettings" />
             <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
@@ -2466,11 +2413,11 @@
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
-            <intent-filter android:priority="1">
+            <intent-filter android:priority="10">
                 <action android:name="com.android.settings.action.SETTINGS" />
             </intent-filter>
             <meta-data android:name="com.android.settings.category"
-                android:value="com.android.settings.category.device" />
+                android:value="com.android.settings.category.ia.apps.default" />
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                 android:value="com.android.settings.nfc.PaymentSettings" />
             <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
@@ -2631,14 +2578,14 @@
         <!-- 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_settings_notifications"
+                android:icon="@drawable/ic_notifications"
                 android:exported="true"
                 android:taskAffinity="">
-            <intent-filter android:priority="8">
+            <intent-filter android:priority="150">
                 <action android:name="com.android.settings.action.SETTINGS" />
             </intent-filter>
             <meta-data android:name="com.android.settings.category"
-                       android:value="com.android.settings.category.device" />
+                       android:value="com.android.settings.category.ia.apps" />
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                 android:value="com.android.settings.applications.NotificationApps" />
         </activity>
@@ -2989,7 +2936,7 @@
         <!-- Alias for battery settings in new IA. Remove and merge metadata into TargetActivity -->
         <activity android:name=".Settings$AppAndNotificationDashboardActivity"
                   android:label="@string/app_and_notification_dashboard_title"
-                  android:icon="@drawable/ic_dashboard_apps">
+                  android:icon="@drawable/ic_apps">
             <intent-filter android:priority="9">
                 <action android:name="com.android.settings.action.SETTINGS"/>
             </intent-filter>
@@ -3001,23 +2948,9 @@
                        android:value="@string/app_and_notification_dashboard_summary"/>
         </activity>
 
-        <activity android:name=".Settings$StorageDashboardActivity"
-                  android:label="@string/storage_settings"
-                  android:icon="@drawable/ic_dashboard_storage">
-            <intent-filter android:priority="5">
-                <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.deviceinfo.StorageSettings" />
-            <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
-                       android:value="true" />
-        </activity>
-
         <activity android:name=".Settings$UserAndAccountDashboardActivity"
                   android:label="@string/account_dashboard_title"
-                  android:icon="@drawable/ic_dashboard_user">
+                  android:icon="@drawable/ic_settings_accounts">
             <intent-filter android:priority="3">
                 <action android:name="com.android.settings.action.SETTINGS"/>
             </intent-filter>
@@ -3035,7 +2968,7 @@
 
         <activity android:name=".Settings$SystemDashboardActivity"
                   android:label="@string/header_category_system"
-                  android:icon="@drawable/ic_dashboard_system">
+                  android:icon="@drawable/ic_settings_about">
             <intent-filter android:priority="1">
                 <action android:name="com.android.settings.action.SETTINGS"/>
             </intent-filter>
@@ -3062,32 +2995,6 @@
                        android:resource="@string/support_summary"/>
         </activity>
 
-        <activity-alias android:name="ManageApplicationsDashboardAlias"
-                        android:targetActivity="Settings$ManageApplicationsActivity">
-            <intent-filter android:priority="200">
-                <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.apps" />
-            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
-                       android:value="com.android.settings.applications.ManageApplications" />
-            <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
-                       android:value="true" />
-        </activity-alias>
-
-        <activity-alias android:name="AppNotificationDashboardAlias"
-                        android:targetActivity="Settings$NotificationAppListActivity"
-                        android:icon="@drawable/ic_notifications">
-            <intent-filter android:priority="150">
-                <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.apps"/>
-            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
-                       android:value="com.android.settings.applications.NotificationApps"/>
-
-        </activity-alias>
-
         <activity-alias android:name="ConfigureNotificationDashboardAlias"
                   android:targetActivity="Settings$ConfigureNotificationSettingsActivity">
             <intent-filter android:priority="120">
@@ -3101,19 +3008,6 @@
                        android:value="true" />
         </activity-alias>
 
-        <activity-alias android:name="UsersDashboardAlias"
-                        android:targetActivity="Settings$UserSettingsActivity">
-            <intent-filter android:priority="8">
-                <action android:name="com.android.settings.action.SETTINGS"/>
-            </intent-filter>
-            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
-                       android:value="com.android.settings.users.UserSettings" />
-            <meta-data android:name="com.android.settings.category"
-                       android:value="com.android.settings.category.ia.accounts" />
-            <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
-                       android:value="true" />
-        </activity-alias>
-
         <activity-alias android:name="AppDefaultDashboardAlias"
                         android:targetActivity="Settings$AdvancedAppsActivity"
                         android:label="@string/app_default_dashboard_title"
@@ -3129,19 +3023,6 @@
                        android:value="true" />
         </activity-alias>
 
-        <activity-alias android:name="PaymentSettingsDashboardAlias"
-                        android:targetActivity="Settings$PaymentSettingsActivity">
-            <intent-filter android:priority="10">
-                <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.apps.default"/>
-            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
-                       android:value="com.android.settings.nfc.PaymentSettings"/>
-            <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
-                       android:value="true"/>
-        </activity-alias>
-
         <!-- End of information architecture host activities -->
 
         <service
diff --git a/res/drawable/ic_dashboard_apps.xml b/res/drawable/ic_dashboard_apps.xml
deleted file mode 100644
index c0083a6..0000000
--- a/res/drawable/ic_dashboard_apps.xml
+++ /dev/null
@@ -1,25 +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.
--->
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
-        android:width="24dp"
-        android:height="24dp"
-        android:viewportWidth="24.0"
-        android:viewportHeight="24.0">
-    <path
-        android:pathData="M4,8h4L8,4L4,4v4zM10,20h4v-4h-4v4zM4,20h4v-4L4,16v4zM4,14h4v-4L4,10v4zM10,14h4v-4h-4v4zM16,4v4h4L20,4h-4zM10,8h4L14,4h-4v4zM16,14h4v-4h-4v4zM16,20h4v-4h-4v4z"
-        android:fillColor="#ec8122"/>
-</vector>
diff --git a/res/drawable/ic_dashboard_display.xml b/res/drawable/ic_dashboard_display.xml
deleted file mode 100644
index ae367cf..0000000
--- a/res/drawable/ic_dashboard_display.xml
+++ /dev/null
@@ -1,26 +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.
-  -->
-
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
-        android:width="24.0dp"
-        android:height="24.0dp"
-        android:viewportWidth="24.0"
-        android:viewportHeight="24.0">
-    <path
-        android:fillColor="#4184f3"
-        android:pathData="M20.0,15.31L23.31,12.0 20.0,8.69L20.0,4.0l-4.69,0.0L12.0,0.69 8.69,4.0L4.0,4.0l0.0,4.69L0.69,12.0 4.0,15.31L4.0,20.0l4.69,0.0L12.0,23.31 15.31,20.0L20.0,20.0l0.0,-4.69zM12.0,18.0L12.0,6.0c3.31,0.0 6.0,2.69 6.0,6.0s-2.69,6.0 -6.0,6.0z"/>
-</vector>
\ No newline at end of file
diff --git a/res/drawable/ic_dashboard_security.xml b/res/drawable/ic_dashboard_security.xml
deleted file mode 100644
index 1e6a1e8..0000000
--- a/res/drawable/ic_dashboard_security.xml
+++ /dev/null
@@ -1,26 +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.
-  -->
-
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
-        android:width="24.0dp"
-        android:height="24.0dp"
-        android:viewportWidth="24.0"
-        android:viewportHeight="24.0">
-    <path
-        android:fillColor="#7a1ea1"
-        android:pathData="M18.0,8.0l-1.0,0.0L17.0,6.0c0.0,-2.76 -2.24,-5.0 -5.0,-5.0S7.0,3.24 7.0,6.0l0.0,2.0L6.0,8.0c-1.1,0.0 -2.0,0.9 -2.0,2.0l0.0,10.0c0.0,1.0 0.9,2.0 2.0,2.0l12.0,0.0c1.1,0.0 2.0,-0.9 2.0,-2.0L20.0,10.0c0.0,-1.1 -0.9,-2.0 -2.0,-2.0zm-6.0,9.0c-1.1,0.0 -2.0,-0.9 -2.0,-2.0s0.9,-2.0 2.0,-2.0 2.0,0.9 2.0,2.0 -0.9,2.0 -2.0,2.0zm3.1,-9.0L8.9,8.0L8.9,6.0c0.0,-1.71 1.39,-3.1 3.1,-3.1 1.71,0.0 3.1,1.39 3.1,3.1l0.0,2.0z"/>
-</vector>
\ No newline at end of file
diff --git a/res/drawable/ic_dashboard_sound.xml b/res/drawable/ic_dashboard_sound.xml
deleted file mode 100644
index 0cd3b04..0000000
--- a/res/drawable/ic_dashboard_sound.xml
+++ /dev/null
@@ -1,26 +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.
-  -->
-
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
-        android:width="24.0dp"
-        android:height="24.0dp"
-        android:viewportWidth="24.0"
-        android:viewportHeight="24.0">
-    <path
-        android:fillColor="#4184f3"
-        android:pathData="M3.0,9.0l0.0,6.0l4.0,0.0l5.0,5.0L12.0,4.0L7.0,9.0L3.0,9.0zm13.5,3.0c0.0,-1.77 -1.02,-3.29 -2.5,-4.03l0.0,8.05c1.48,-0.73 2.5,-2.25 2.5,-4.02zM14.0,3.23l0.0,2.06c2.8,0.86 5.0,3.54 5.0,6.71s-2.11,5.85 -5.0,6.71l0.0,2.06c4.01,-0.91 7.0,-4.49 7.0,-8.77s-2.99,-7.86 -7.0,-8.77z"/>
-</vector>
\ No newline at end of file
diff --git a/res/drawable/ic_dashboard_storage.xml b/res/drawable/ic_dashboard_storage.xml
deleted file mode 100644
index 2b6160e..0000000
--- a/res/drawable/ic_dashboard_storage.xml
+++ /dev/null
@@ -1,26 +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.
-  -->
-
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
-        android:width="24.0dp"
-        android:height="24.0dp"
-        android:viewportWidth="24.0"
-        android:viewportHeight="24.0">
-    <path
-        android:fillColor="#4184f3"
-        android:pathData="M2.0,20.0l20.0,0.0l0.0,-4.0L2.0,16.0l0.0,4.0zm2.0,-3.0l2.0,0.0l0.0,2.0L4.0,19.0l0.0,-2.0zM2.0,4.0l0.0,4.0l20.0,0.0L22.0,4.0L2.0,4.0zm4.0,3.0L4.0,7.0L4.0,5.0l2.0,0.0l0.0,2.0zm-4.0,7.0l20.0,0.0l0.0,-4.0L2.0,10.0l0.0,4.0zm2.0,-3.0l2.0,0.0l0.0,2.0L4.0,13.0l0.0,-2.0z"/>
-</vector>
diff --git a/res/drawable/ic_dashboard_system.xml b/res/drawable/ic_dashboard_system.xml
deleted file mode 100644
index fdd9214..0000000
--- a/res/drawable/ic_dashboard_system.xml
+++ /dev/null
@@ -1,26 +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.
-  -->
-
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
-        android:width="24.0dp"
-        android:height="24.0dp"
-        android:viewportWidth="24.0"
-        android:viewportHeight="24.0">
-    <path
-        android:fillColor="#606060"
-        android:pathData="M11.0,17.0l2.0,0.0l0.0,-6.0l-2.0,0.0l0.0,6.0zm1.0,-15.0C6.48,2.0 2.0,6.48 2.0,12.0s4.48,10.0 10.0,10.0 10.0,-4.48 10.0,-10.0S17.52,2.0 12.0,2.0zm0.0,18.0c-4.41,0.0 -8.0,-3.59 -8.0,-8.0s3.59,-8.0 8.0,-8.0 8.0,3.59 8.0,8.0 -3.59,8.0 -8.0,8.0zM11.0,9.0l2.0,0.0L13.0,7.0l-2.0,0.0l0.0,2.0z"/>
-</vector>
diff --git a/res/drawable/ic_dashboard_user.xml b/res/drawable/ic_dashboard_user.xml
deleted file mode 100644
index 302d33e..0000000
--- a/res/drawable/ic_dashboard_user.xml
+++ /dev/null
@@ -1,30 +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.
-  -->
-
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
-        android:width="24.0dp"
-        android:height="24.0dp"
-        android:viewportWidth="24.0"
-        android:viewportHeight="24.0">
-    <path
-        android:fillColor="#aeb32a"
-        android:pathData="M3.0,5.0
-        l0.0,14.0c0.0,1.0 0.89,2.0 2.0,2.0l14.0,0.0c1.1,0.0 2.0,-0.9 2.0,-2.0
-        L21.0,5.0c0.0,-1.1 -0.9,-2.0 -2.0,-2.0
-        L5.0,3.0c-1.11,0.0 -2.0,0.9 -2.0,2.0zm12.0,4.0c0.0,1.66 -1.34,3.0 -3.0,3.0s-3.0,-1.34 -3.0,-3.0 1.34,-3.0 3.0,-3.0 3.0,1.34 3.0,3.0zm-9.0,8.0c0.0,-2.0 4.0,-3.1 6.0,-3.1s6.0,1.1 6.0,3.1l0.0,1.0
-        l-12.0,0l0.0,-1.0z"/>
-</vector>
\ No newline at end of file
diff --git a/res/drawable/ic_devices_other.xml b/res/drawable/ic_devices_other.xml
index 73407a3..20639a3 100644
--- a/res/drawable/ic_devices_other.xml
+++ b/res/drawable/ic_devices_other.xml
@@ -17,8 +17,9 @@
         android:width="24dp"
         android:height="24dp"
         android:viewportWidth="24.0"
-        android:viewportHeight="24.0">
+        android:viewportHeight="24.0"
+        android:tint="?android:attr/colorControlNormal">
     <path
         android:pathData="M3,6h18L21,4L3,4c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h4v-2L3,18L3,6zM13,12L9,12v1.78c-0.61,0.55 -1,1.33 -1,2.22s0.39,1.67 1,2.22L9,20h4v-1.78c0.61,-0.55 1,-1.34 1,-2.22s-0.39,-1.67 -1,-2.22L13,12zM11,17.5c-0.83,0 -1.5,-0.67 -1.5,-1.5s0.67,-1.5 1.5,-1.5 1.5,0.67 1.5,1.5 -0.67,1.5 -1.5,1.5zM22,8h-6c-0.5,0 -1,0.5 -1,1v10c0,0.5 0.5,1 1,1h6c0.5,0 1,-0.5 1,-1L23,9c0,-0.5 -0.5,-1 -1,-1zM21,18h-4v-8h4v8z"
-        android:fillColor="#0b9c57"/>
+        android:fillColor="#FFFFFFFF"/>
 </vector>
diff --git a/res/drawable/ic_help.xml b/res/drawable/ic_help.xml
index 5b056e7..7a225e5 100644
--- a/res/drawable/ic_help.xml
+++ b/res/drawable/ic_help.xml
@@ -17,8 +17,9 @@
         android:width="24dp"
         android:height="24dp"
         android:viewportWidth="24.0"
-        android:viewportHeight="24.0">
+        android:viewportHeight="24.0"
+        android:tint="?android:attr/colorControlNormal">
     <path
         android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM13,19h-2v-2h2v2zM15.07,11.25l-0.9,0.92C13.45,12.9 13,13.5 13,15h-2v-0.5c0,-1.1 0.45,-2.1 1.17,-2.83l1.24,-1.26c0.37,-0.36 0.59,-0.86 0.59,-1.41 0,-1.1 -0.9,-2 -2,-2s-2,0.9 -2,2L8,9c0,-2.21 1.79,-4 4,-4s4,1.79 4,4c0,0.88 -0.36,1.68 -0.93,2.25z"
-        android:fillColor="#f3501d"/>
+        android:fillColor="#FFFFFFFF"/>
 </vector>
diff --git a/res/drawable/ic_settings_accessibility.xml b/res/drawable/ic_settings_accessibility.xml
index a689c4a..34c0bdd 100644
--- a/res/drawable/ic_settings_accessibility.xml
+++ b/res/drawable/ic_settings_accessibility.xml
@@ -17,8 +17,9 @@
         android:width="24.0dp"
         android:height="24.0dp"
         android:viewportWidth="24.0"
-        android:viewportHeight="24.0">
+        android:viewportHeight="24.0"
+        android:tint="?android:attr/colorControlNormal">
     <path
-        android:fillColor="#3e50b4"
+        android:fillColor="#FFFFFFFF"
         android:pathData="M12.0,2.0c1.1,0.0 2.0,0.9 2.0,2.0s-0.9,2.0 -2.0,2.0 -2.0,-0.9 -2.0,-2.0 0.9,-2.0 2.0,-2.0zm9.0,7.0l-6.0,0.0l0.0,13.0l-2.0,0.0l0.0,-6.0l-2.0,0.0l0.0,6.0L9.0,22.0L9.0,9.0L3.0,9.0L3.0,7.0l18.0,0.0l0.0,2.0z"/>
 </vector>
diff --git a/res/drawable/ic_settings_battery.xml b/res/drawable/ic_settings_battery.xml
index f1e56d8..c8e053d 100644
--- a/res/drawable/ic_settings_battery.xml
+++ b/res/drawable/ic_settings_battery.xml
@@ -17,9 +17,10 @@
         android:width="24.0dp"
         android:height="24.0dp"
         android:viewportWidth="24.0"
-        android:viewportHeight="24.0">
+        android:viewportHeight="24.0"
+        android:tint="?android:attr/colorControlNormal">
     <path
-        android:fillColor="#4184f3"
+        android:fillColor="#FFFFFFFF"
         android:pathData="M15.67,4.0L14.0,4.0L14.0,2.0l-4.0,0.0l0.0,2.0L8.33,4.0C7.6,4.0 7.0,4.6 7.0,5.33l0.0,15.33C7.0,21.4 7.6,22.0 8.33,22.0l7.33,0.0c0.74,0.0 1.34,-0.6 1.34,-1.33L17.0,5.33C17.0,4.6 16.4,4.0 15.67,4.0z
         M16,5l0,5.5l-8,0l0,-5.5l3,0l0,-2l2,0l0,2l3,0z"/>
 </vector>
diff --git a/res/values/config.xml b/res/values/config.xml
index 0fa2b71..f81bf9b 100755
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -67,4 +67,36 @@
     <!-- If the support features are enabled. -->
     <bool name="config_support_enabled">false</bool>
 
+    <!-- List containing the component names of pre-installed screen reader services. -->
+    <string-array name="config_preinstalled_screen_reader_services" translatable="false">
+        <!--
+        <item>com.example.package.first/com.example.class.FirstService</item>
+        <item>com.example.package.second/com.example.class.SecondService</item>
+        -->
+    </string-array>
+
+    <!-- List containing the component names of pre-installed audio and captioning services. -->
+    <string-array name="config_preinstalled_audio_and_caption_services" translatable="false">
+        <!--
+        <item>com.example.package.first/com.example.class.FirstService</item>
+        <item>com.example.package.second/com.example.class.SecondService</item>
+        -->
+    </string-array>
+
+    <!-- List containing the component names of pre-installed display services. -->
+    <string-array name="config_preinstalled_display_services" translatable="false">
+        <!--
+        <item>com.example.package.first/com.example.class.FirstService</item>
+        <item>com.example.package.second/com.example.class.SecondService</item>
+        -->
+    </string-array>
+
+    <!-- List containing the component names of pre-installed interaction control services. -->
+    <string-array name="config_preinstalled_interaction_control_services" translatable="false">
+        <!--
+        <item>com.example.package.first/com.example.class.FirstService</item>
+        <item>com.example.package.second/com.example.class.SecondService</item>
+        -->
+    </string-array>
+
 </resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 1e1304e..8673359 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -3013,6 +3013,10 @@
     <string name="sms_change_default_dialog_text" translatable="true">Use <xliff:g id="new_app">%1$s</xliff:g> instead of <xliff:g id="current_app">%2$s</xliff:g> as your SMS app?</string>
     <string name="sms_change_default_no_previous_dialog_text" translatable="true">Use <xliff:g id="new_app">%s</xliff:g> as your SMS app?</string>
 
+    <!-- Network Scorer Picker title [CHAR LIMIT=40]-->
+    <string name="network_scorer_picker_title">Network Scorer</string>
+    <string name="network_scorer_picker_none_preference">None</string>
+
     <!-- Wifi Assistant change wi-fi assistant title.  [CHAR LIMIT=40] -->
     <string name="network_scorer_change_active_dialog_title">Change Wi\u2011Fi assistant?</string>
     <!-- Wifi Assistant request message.  This message asks the user if it is okay for an app to become the Wifi Assistant instead of the current Wifi Assistant app. [CHAR LIMIT=100] -->
@@ -3974,18 +3978,22 @@
     <string name="vision_settings_title">Vision Settings</string>
     <!-- Settings description for a brief version of Vision-Related Accessibility Settings. Tells the user that they can adjust these settings now to help them through the remainder of the Setup Wizard and that they can later be changed in Settings. Displayed in Setup Wizard only. [CHAR LIMIT=none] -->
     <string name="vision_settings_description">You can customize this device to fit your needs. These accessibility features can be changed later in Settings.</string>
-    <!-- Title for the accessibility preference category of accessibility services. [CHAR LIMIT=25] -->
-    <string name="accessibility_services_title">Services</string>
+    <!-- Title for the accessibility preference category of screen reader services and settings. [CHAR LIMIT=50] -->
+    <string name="screen_reader_category_title">Screen readers</string>
+    <!-- Title for the accessibility preference category of audio services and settings. [CHAR LIMIT=50] -->
+    <string name="audio_and_captions_category_title">Audio &amp; on-screen text</string>
+    <!-- Title for the accessibility preference category of display services and settings. [CHAR LIMIT=50] -->
+    <string name="display_category_title">Display</string>
+    <!-- Title for the accessibility preference category of interaction control services and settings. [CHAR LIMIT=50] -->
+    <string name="interaction_control_category_title">Interaction controls</string>
+    <!-- Title for the accessibility preference category of services downloaded by the user. [CHAR LIMIT=50] -->
+    <string name="user_installed_services_category_title">Downloaded services</string>
     <!-- Title for the Talkback Accessibility Service. Displayed on the Accessibility Settings screen in Setup Wizard. [CHAR_LIMIT=25] -->
     <string name="talkback_title">Talkback</string>
     <!-- Summary for the Talkback Accessibility Service. Lets the user know that Talkback is a screenreader and that it is usually most helpful to blind and low vision users and whether the service is on. [CHAR_LIMIT=none] -->
     <string name="talkback_summary">Screen reader primarily for people with blindness and low vision</string>
     <!-- Summary for the Select to Speak Accessibility Service. [CHAR_LIMIT=none] -->
     <string name="select_to_speak_summary">Tap items on your screen to hear them read aloud</string>
-    <!-- Title for the accessibility preference category of system related preferences. [CHAR LIMIT=25] -->
-    <string name="accessibility_system_title">System</string>
-    <!-- Title for the accessibility preference category of display related preferences. [CHAR LIMIT=25] -->
-    <string name="accessibility_display_title">Display</string>
     <!-- Title for the accessibility preference screen to enable video captioning. [CHAR LIMIT=35] -->
     <string name="accessibility_captioning_title">Captions</string>
     <!-- Title for the accessibility preference screen to enable screen magnification. [CHAR LIMIT=35] -->
@@ -4176,10 +4184,10 @@
     <string name="disable_service_message">Tapping OK will
         stop <xliff:g id="service" example="TalkBack">%1$s</xliff:g>.</string>
 
-    <!-- Title for the prompt shown as a placeholder if no accessibility serivices are installed. [CHAR LIMIT=50] -->
+    <!-- Title for the prompt shown as a placeholder if no accessibility services are installed. [CHAR LIMIT=50] -->
     <string name="accessibility_no_services_installed">No services installed</string>
 
-    <!-- Default description for an accessibility serivice if the latter doesn't provide one. [CHAR LIMIT=NONE] -->
+    <!-- Default description for an accessibility service if the latter doesn't provide one. [CHAR LIMIT=NONE] -->
     <string name="accessibility_service_default_description">No description provided.</string>
 
     <!-- Accessibility settings: button for lauching settings for an accessibility service -->
@@ -4200,7 +4208,7 @@
     <!-- Title for print service settings screen [CHAR LIMIT=25] -->
     <string name="print_settings_title">Print services</string>
 
-    <!-- Title for the prompt shown as a placeholder if no print serivices are installed. [CHAR LIMIT=50] -->
+    <!-- Title for the prompt shown as a placeholder if no print services are installed. [CHAR LIMIT=50] -->
     <string name="print_no_services_installed">No services installed</string>
 
     <!-- Title for the prompt shown as a placeholder if no printers are found while searching. [CHAR LIMIT=50] -->
diff --git a/res/xml/accessibility_settings.xml b/res/xml/accessibility_settings.xml
index ee21017..478dfe5 100644
--- a/res/xml/accessibility_settings.xml
+++ b/res/xml/accessibility_settings.xml
@@ -18,38 +18,42 @@
         android:title="@string/accessibility_settings"
         android:persistent="true">
 
+    <ListPreference
+            android:key="accessibility_shortcut_preference"
+            android:title="@string/accessibility_global_gesture_preference_title"/>
+
     <PreferenceCategory
-            android:key="services_category"
-            android:title="@string/accessibility_services_title">
+            android:key="user_installed_services_category"
+            android:title="@string/user_installed_services_category_title">
     </PreferenceCategory>
 
     <PreferenceCategory
-            android:key="system_category"
-            android:title="@string/accessibility_system_title">
+            android:key="screen_reader_category"
+            android:title="@string/screen_reader_category_title">
 
         <Preference
-            android:fragment="com.android.settings.accessibility.CaptionPropertiesFragment"
-            android:key="captioning_preference_screen"
-            android:title="@string/accessibility_captioning_title" />
+                android:key="tts_settings_preference"
+                android:fragment="com.android.settings.tts.TextToSpeechSettings"
+                android:title="@string/tts_settings_title"/>
+    </PreferenceCategory>
+
+    <PreferenceCategory
+            android:key="display_category"
+            android:title="@string/display_category_title">
 
         <Preference
-            android:fragment="com.android.settings.accessibility.ToggleScreenMagnificationPreferenceFragment"
-            android:key="screen_magnification_preference_screen"
-            android:title="@string/accessibility_screen_magnification_title"/>
-
-        <Preference
-            android:fragment="com.android.settings.accessibility.ToggleFontSizePreferenceFragment"
-            android:key="font_size_preference_screen"
-            android:title="@string/title_font_size"/>
+                android:fragment="com.android.settings.accessibility.ToggleFontSizePreferenceFragment"
+                android:key="font_size_preference_screen"
+                android:title="@string/title_font_size"/>
 
         <com.android.settings.display.ScreenZoomPreference
-            android:key="screen_zoom"
-            android:title="@string/screen_zoom_title"/>
+                android:key="screen_zoom"
+                android:title="@string/screen_zoom_title"/>
 
         <Preference
-            android:fragment="com.android.settings.accessibility.ToggleAutoclickPreferenceFragment"
-            android:key="autoclick_preference_screen"
-            android:title="@string/accessibility_autoclick_preference_title"/>
+                android:fragment="com.android.settings.accessibility.ToggleScreenMagnificationPreferenceFragment"
+                android:key="screen_magnification_preference_screen"
+                android:title="@string/accessibility_screen_magnification_title"/>
 
         <SwitchPreference
                 android:key="toggle_high_text_contrast_preference"
@@ -57,6 +61,31 @@
                 android:summary="@string/experimental_preference"/>
 
         <SwitchPreference
+                android:key="toggle_inversion_preference"
+                android:title="@string/accessibility_display_inversion_preference_title"
+                android:summary="@string/accessibility_display_inversion_preference_subtitle"
+                android:persistent="false" />
+
+        <Preference
+                android:fragment="com.android.settings.accessibility.ToggleDaltonizerPreferenceFragment"
+                android:key="daltonizer_preference_screen"
+                android:title="@string/accessibility_display_daltonizer_preference_title" />
+
+        <SwitchPreference
+                android:key="toggle_large_pointer_icon"
+                android:title="@string/accessibility_toggle_large_pointer_icon_title" />
+    </PreferenceCategory>
+
+    <PreferenceCategory
+            android:key="interaction_control_category"
+            android:title="@string/interaction_control_category_title">
+
+        <Preference
+                android:fragment="com.android.settings.accessibility.ToggleAutoclickPreferenceFragment"
+                android:key="autoclick_preference_screen"
+                android:title="@string/accessibility_autoclick_preference_title"/>
+
+        <SwitchPreference
                 android:key="toggle_power_button_ends_call_preference"
                 android:title="@string/accessibility_power_button_ends_call_prerefence_title"
                 android:persistent="false"/>
@@ -66,9 +95,17 @@
                 android:title="@string/accelerometer_title"
                 android:persistent="false"/>
 
-        <SwitchPreference
-                android:key="toggle_large_pointer_icon"
-                android:title="@string/accessibility_toggle_large_pointer_icon_title" />
+        <ListPreference
+                android:key="select_long_press_timeout_preference"
+                android:title="@string/accessibility_long_press_timeout_preference_title"
+                android:entries="@array/long_press_timeout_selector_titles"
+                android:entryValues="@array/long_press_timeout_selector_values"
+                android:persistent="false"/>
+    </PreferenceCategory>
+
+    <PreferenceCategory
+            android:key="audio_and_captions_category"
+            android:title="@string/audio_and_captions_category_title">
 
         <SwitchPreference
                 android:key="toggle_master_mono"
@@ -76,35 +113,9 @@
                 android:summary="@string/accessibility_toggle_master_mono_summary"
                 android:persistent="false"/>
 
-        <ListPreference
-                android:key="accessibility_shortcut_preference"
-                android:title="@string/accessibility_global_gesture_preference_title"/>
-
         <Preference
-                android:key="tts_settings_preference"
-                android:fragment="com.android.settings.tts.TextToSpeechSettings"
-                android:title="@string/tts_settings_title"/>
-
-        <ListPreference android:key="select_long_press_timeout_preference"
-                android:title="@string/accessibility_long_press_timeout_preference_title"
-                android:entries="@array/long_press_timeout_selector_titles"
-                android:entryValues="@array/long_press_timeout_selector_values"
-                android:persistent="false"/>
-
+                android:fragment="com.android.settings.accessibility.CaptionPropertiesFragment"
+                android:key="captioning_preference_screen"
+                android:title="@string/accessibility_captioning_title" />
     </PreferenceCategory>
-
-    <PreferenceCategory
-        android:key="display_category"
-        android:title="@string/accessibility_display_title" >
-        <SwitchPreference
-            android:key="toggle_inversion_preference"
-            android:title="@string/accessibility_display_inversion_preference_title"
-            android:summary="@string/accessibility_display_inversion_preference_subtitle"
-            android:persistent="false" />
-        <Preference
-            android:fragment="com.android.settings.accessibility.ToggleDaltonizerPreferenceFragment"
-            android:key="daltonizer_preference_screen"
-            android:title="@string/accessibility_display_daltonizer_preference_title" />
-    </PreferenceCategory>
-
 </PreferenceScreen>
diff --git a/res/drawable/ic_dashboard_network.xml b/res/xml/network_scorer_picker_prefs.xml
similarity index 62%
rename from res/drawable/ic_dashboard_network.xml
rename to res/xml/network_scorer_picker_prefs.xml
index 6c7ee2e..fab69e7 100644
--- a/res/drawable/ic_dashboard_network.xml
+++ b/res/xml/network_scorer_picker_prefs.xml
@@ -15,12 +15,7 @@
   limitations under the License.
   -->
 
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
-        android:width="24.0dp"
-        android:height="24.0dp"
-        android:viewportWidth="18.0"
-        android:viewportHeight="18.0">
-    <path
-        android:fillColor="#0b9c57"
-        android:pathData="M9.01,15.99l8.8,-10.96C17.47,4.77 14.08,2.0 9.0,2.0S0.53,4.7 0.19,5.03l8.8,10.96l0.02,0.0z"/>
-</vector>
+<PreferenceScreen
+        xmlns:android="http://schemas.android.com/apk/res/android"
+        android:title="@string/network_scorer_picker_title">
+</PreferenceScreen>
\ No newline at end of file
diff --git a/res/xml/wifi_configure_settings.xml b/res/xml/wifi_configure_settings.xml
index bf1dc75..8e51009 100644
--- a/res/xml/wifi_configure_settings.xml
+++ b/res/xml/wifi_configure_settings.xml
@@ -59,6 +59,11 @@
             settings:keywords="@string/keywords_wifi_calling"/>
 
     <Preference
+            android:key="network_scorer_picker"
+            android:title="@string/network_scorer_picker_title"
+            android:fragment="com.android.settings.network.NetworkScorerPicker"/>
+
+    <Preference
             android:key="wifi_direct"
             android:title="@string/wifi_menu_p2p">
         <intent android:targetPackage="com.android.settings"
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index a96fb1e..2b486aa 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -33,7 +33,6 @@
     public static class TetherSettingsActivity extends SettingsActivity { /* empty */ }
     public static class VpnSettingsActivity extends SettingsActivity { /* empty */ }
     public static class DateTimeSettingsActivity extends SettingsActivity { /* empty */ }
-    public static class StorageSettingsActivity extends SettingsActivity { /* empty */ }
     public static class PrivateVolumeForgetActivity extends SettingsActivity { /* empty */ }
     public static class PrivateVolumeSettingsActivity extends SettingsActivity { /* empty */ }
     public static class PublicVolumeSettingsActivity extends SettingsActivity { /* empty */ }
@@ -156,12 +155,6 @@
     public static class EnterprisePrivacySettingsActivity extends SettingsActivity { /* empty */ }
     public static class WebViewAppPickerActivity extends SettingsActivity { /* empty */ }
 
-    // Categories.
-    public static class WirelessSettings extends SettingsActivity { /* empty */ }
-    public static class DeviceSettings extends SettingsActivity { /* empty */ }
-    public static class PersonalSettings extends SettingsActivity { /* empty */ }
-    public static class SystemSettings extends SettingsActivity { /* empty */ }
-
     // Top level categories for new IA
     public static class NetworkDashboardActivity extends SettingsActivity {}
     public static class ConnectedDeviceDashboardActivity extends SettingsActivity {}
diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java
index d5e886f..ffc051e 100644
--- a/src/com/android/settings/SettingsActivity.java
+++ b/src/com/android/settings/SettingsActivity.java
@@ -383,11 +383,7 @@
         final ComponentName cn = intent.getComponent();
         final String className = cn.getClassName();
 
-        mIsShowingDashboard = className.equals(Settings.class.getName())
-                || className.equals(Settings.WirelessSettings.class.getName())
-                || className.equals(Settings.DeviceSettings.class.getName())
-                || className.equals(Settings.PersonalSettings.class.getName())
-                || className.equals(Settings.WirelessSettings.class.getName());
+        mIsShowingDashboard = className.equals(Settings.class.getName());
 
         // This is a "Sub Settings" when:
         // - this is a real SubSettings
@@ -936,11 +932,6 @@
                 pm.hasSystemFeature(PackageManager.FEATURE_NFC)
                         && pm.hasSystemFeature(PackageManager.FEATURE_NFC_HOST_CARD_EMULATION)
                         && adapter != null && adapter.isEnabled(), isAdmin);
-        setTileEnabled(new ComponentName(packageName,
-                        "com.android.settings.PaymentSettingsDashboardAlias"),
-                pm.hasSystemFeature(PackageManager.FEATURE_NFC)
-                        && pm.hasSystemFeature(PackageManager.FEATURE_NFC_HOST_CARD_EMULATION)
-                        && adapter != null && adapter.isEnabled(), isAdmin);
 
         setTileEnabled(new ComponentName(packageName,
                 Settings.PrintSettingsActivity.class.getName()),
diff --git a/src/com/android/settings/accessibility/AccessibilitySettings.java b/src/com/android/settings/accessibility/AccessibilitySettings.java
index 807371e..672f4ed 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettings.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettings.java
@@ -25,6 +25,7 @@
 import android.content.pm.PackageManager;
 import android.content.pm.ServiceInfo;
 import android.content.res.Resources;
+import android.graphics.drawable.Drawable;
 import android.net.Uri;
 import android.os.Bundle;
 import android.os.Handler;
@@ -35,7 +36,9 @@
 import android.support.v7.preference.ListPreference;
 import android.support.v7.preference.Preference;
 import android.support.v7.preference.PreferenceCategory;
+import android.support.v7.preference.PreferenceScreen;
 import android.text.TextUtils;
+import android.util.ArrayMap;
 import android.view.KeyCharacterMap;
 import android.view.KeyEvent;
 import android.view.accessibility.AccessibilityManager;
@@ -46,18 +49,17 @@
 import com.android.internal.view.RotationPolicy.RotationPolicyListener;
 import com.android.settings.R;
 import com.android.settings.SettingsPreferenceFragment;
+import com.android.settings.SingleLineSummaryPreference;
 import com.android.settings.Utils;
 import com.android.settings.search.BaseSearchIndexProvider;
 import com.android.settings.search.Indexable;
 import com.android.settings.search.SearchIndexableRaw;
 import com.android.settingslib.RestrictedLockUtils;
 import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
-import com.android.settingslib.RestrictedPreference;
 import com.android.settingslib.accessibility.AccessibilityUtils;
 
 import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -68,9 +70,20 @@
 public class AccessibilitySettings extends SettingsPreferenceFragment implements
         Preference.OnPreferenceChangeListener, Indexable {
 
+    // Index of the first preference in a preference category.
+    private static final int FIRST_PREFERENCE_IN_CATEGORY_INDEX = 0;
+
     // Preference categories
-    private static final String SERVICES_CATEGORY = "services_category";
-    private static final String SYSTEM_CATEGORY = "system_category";
+    private static final String CATEGORY_SCREEN_READER = "screen_reader_category";
+    private static final String CATEGORY_AUDIO_AND_CAPTIONS = "audio_and_captions_category";
+    private static final String CATEGORY_DISPLAY = "display_category";
+    private static final String CATEGORY_INTERACTION_CONTROL = "interaction_control_category";
+    private static final String CATEGORY_DOWNLOADED_SERVICES = "user_installed_services_category";
+
+    private static final String[] CATEGORIES = new String[] {
+        CATEGORY_SCREEN_READER, CATEGORY_AUDIO_AND_CAPTIONS, CATEGORY_DISPLAY,
+        CATEGORY_INTERACTION_CONTROL, CATEGORY_DOWNLOADED_SERVICES
+    };
 
     // Preferences
     private static final String TOGGLE_HIGH_TEXT_CONTRAST_PREFERENCE =
@@ -118,10 +131,7 @@
     // ID for dialog that confirms shortcut capabilities
     private static final int DIALOG_ID_ADD_SHORTCUT_WARNING = 1;
 
-    // Auxiliary members.
-    static final Set<ComponentName> sInstalledServices = new HashSet<>();
-
-    private final Map<String, String> mLongPressTimeoutValuetoTitleMap = new HashMap<>();
+    private final Map<String, String> mLongPressTimeoutValueToTitleMap = new HashMap<>();
 
     private final Handler mHandler = new Handler();
 
@@ -129,7 +139,7 @@
         @Override
         public void run() {
             if (getActivity() != null) {
-                updateServicesPreferences();
+                updateServicePreferences();
             }
         }
     };
@@ -164,7 +174,7 @@
             new SettingsContentObserver(mHandler) {
                 @Override
                 public void onChange(boolean selfChange, Uri uri) {
-                    updateServicesPreferences();
+                    updateServicePreferences();
                 }
             };
 
@@ -175,9 +185,12 @@
         }
     };
 
-    // Preference controls.
-    private PreferenceCategory mServicesCategory;
-    private PreferenceCategory mSystemsCategory;
+    private final Map<String, PreferenceCategory> mCategoryToPrefCategoryMap =
+            new ArrayMap<>();
+    private final Map<Preference, PreferenceCategory> mServicePreferenceToPreferenceCategoryMap =
+            new ArrayMap<>();
+    private final Map<ComponentName, PreferenceCategory> mPreBundledServiceComponentToCategoryMap =
+            new ArrayMap<>();
 
     private SwitchPreference mToggleHighTextContrastPreference;
     private SwitchPreference mTogglePowerButtonEndsCallPreference;
@@ -260,7 +273,7 @@
         Settings.Secure.putInt(getContentResolver(),
                 Settings.Secure.LONG_PRESS_TIMEOUT, Integer.parseInt(stringValue));
         mSelectLongPressTimeoutPreference.setSummary(
-                mLongPressTimeoutValuetoTitleMap.get(stringValue));
+                mLongPressTimeoutValueToTitleMap.get(stringValue));
     }
 
     private void handleToggleInversionPreferenceChange(boolean checked) {
@@ -386,8 +399,10 @@
     }
 
     private void initializeAllPreferences() {
-        mServicesCategory = (PreferenceCategory) findPreference(SERVICES_CATEGORY);
-        mSystemsCategory = (PreferenceCategory) findPreference(SYSTEM_CATEGORY);
+        for (int i = 0; i < CATEGORIES.length; i++) {
+            PreferenceCategory prefCategory = (PreferenceCategory) findPreference(CATEGORIES[i]);
+            mCategoryToPrefCategoryMap.put(CATEGORIES[i], prefCategory);
+        }
 
         // Text contrast.
         mToggleHighTextContrastPreference =
@@ -402,14 +417,16 @@
                 (SwitchPreference) findPreference(TOGGLE_POWER_BUTTON_ENDS_CALL_PREFERENCE);
         if (!KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_POWER)
                 || !Utils.isVoiceCapable(getActivity())) {
-            mSystemsCategory.removePreference(mTogglePowerButtonEndsCallPreference);
+            mCategoryToPrefCategoryMap.get(CATEGORY_INTERACTION_CONTROL)
+                    .removePreference(mTogglePowerButtonEndsCallPreference);
         }
 
         // Lock screen rotation.
         mToggleLockScreenRotationPreference =
                 (SwitchPreference) findPreference(TOGGLE_LOCK_SCREEN_ROTATION_PREFERENCE);
         if (!RotationPolicy.isRotationSupported(getActivity())) {
-            mSystemsCategory.removePreference(mToggleLockScreenRotationPreference);
+            mCategoryToPrefCategoryMap.get(CATEGORY_INTERACTION_CONTROL)
+                    .removePreference(mToggleLockScreenRotationPreference);
         }
 
         // Large pointer icon.
@@ -424,7 +441,7 @@
         mSelectLongPressTimeoutPreference =
                 (ListPreference) findPreference(SELECT_LONG_PRESS_TIMEOUT_PREFERENCE);
         mSelectLongPressTimeoutPreference.setOnPreferenceChangeListener(this);
-        if (mLongPressTimeoutValuetoTitleMap.size() == 0) {
+        if (mLongPressTimeoutValueToTitleMap.size() == 0) {
             String[] timeoutValues = getResources().getStringArray(
                     R.array.long_press_timeout_selector_values);
             mLongPressTimeoutDefault = Integer.parseInt(timeoutValues[0]);
@@ -432,7 +449,7 @@
                     R.array.long_press_timeout_selector_titles);
             final int timeoutValueCount = timeoutValues.length;
             for (int i = 0; i < timeoutValueCount; i++) {
-                mLongPressTimeoutValuetoTitleMap.put(timeoutValues[i], timeoutTitles[i]);
+                mLongPressTimeoutValueToTitleMap.put(timeoutValues[i], timeoutTitles[i]);
             }
         }
 
@@ -459,17 +476,32 @@
     }
 
     private void updateAllPreferences() {
-        updateServicesPreferences();
         updateSystemPreferences();
+        updateServicePreferences();
     }
 
-    private void updateServicesPreferences() {
+    private void updateServicePreferences() {
         // Since services category is auto generated we have to do a pass
         // to generate it since services can come and go and then based on
         // the global accessibility state to decided whether it is enabled.
 
         // Generate.
-        mServicesCategory.removeAll();
+        ArrayList<Preference> servicePreferences =
+                new ArrayList<>(mServicePreferenceToPreferenceCategoryMap.keySet());
+        for (int i = 0; i < servicePreferences.size(); i++) {
+            Preference service = servicePreferences.get(i);
+            PreferenceCategory category = mServicePreferenceToPreferenceCategoryMap.get(service);
+            category.removePreference(service);
+        }
+
+        initializePreBundledServicesMapFromArray(CATEGORY_SCREEN_READER,
+                R.array.config_preinstalled_screen_reader_services);
+        initializePreBundledServicesMapFromArray(CATEGORY_AUDIO_AND_CAPTIONS,
+                R.array.config_preinstalled_audio_and_caption_services);
+        initializePreBundledServicesMapFromArray(CATEGORY_DISPLAY,
+                R.array.config_preinstalled_display_services);
+        initializePreBundledServicesMapFromArray(CATEGORY_INTERACTION_CONTROL,
+                R.array.config_preinstalled_interaction_control_services);
 
         AccessibilityManager accessibilityManager = AccessibilityManager.getInstance(getActivity());
 
@@ -482,36 +514,49 @@
         final boolean accessibilityEnabled = Settings.Secure.getInt(getContentResolver(),
                 Settings.Secure.ACCESSIBILITY_ENABLED, 0) == 1;
 
+        PreferenceCategory downloadedServicesCategory =
+                mCategoryToPrefCategoryMap.get(CATEGORY_DOWNLOADED_SERVICES);
+        // Temporarily add the downloaded services category back if it was previously removed.
+        if (findPreference(CATEGORY_DOWNLOADED_SERVICES) == null) {
+            getPreferenceScreen().addPreference(downloadedServicesCategory);
+        }
+
         for (int i = 0, count = installedServices.size(); i < count; ++i) {
             AccessibilityServiceInfo info = installedServices.get(i);
 
-            RestrictedPreference preference =
-                    new RestrictedPreference(mServicesCategory.getContext());
+            SingleLineSummaryPreference preference =
+                    new SingleLineSummaryPreference(downloadedServicesCategory.getContext(), null);
             String title = info.getResolveInfo().loadLabel(getPackageManager()).toString();
 
+            Drawable icon = info.getResolveInfo().loadIcon(getPackageManager());
+            if (icon == null) {
+                // todo (saigem): add a default
+            }
+
             ServiceInfo serviceInfo = info.getResolveInfo().serviceInfo;
-            ComponentName componentName = new ComponentName(serviceInfo.packageName,
-                    serviceInfo.name);
+            String packageName = serviceInfo.packageName;
+            ComponentName componentName = new ComponentName(packageName, serviceInfo.name);
+            String componentNameKey = componentName.flattenToString();
 
             preference.setKey(componentName.flattenToString());
 
             preference.setTitle(title);
+            preference.setIcon(icon);
             final boolean serviceEnabled = accessibilityEnabled
                     && enabledServices.contains(componentName);
-            String serviceEnabledString;
-            if (serviceEnabled) {
-                serviceEnabledString = getString(R.string.accessibility_feature_state_on);
-            } else {
-                serviceEnabledString = getString(R.string.accessibility_feature_state_off);
-            }
+            String serviceState = serviceEnabled ?
+                    getString(R.string.accessibility_feature_state_on) :
+                    getString(R.string.accessibility_feature_state_off);
+            String serviceSummary = info.loadSummary(getPackageManager());
+            serviceSummary = (TextUtils.isEmpty(serviceSummary)) ? serviceState.toUpperCase() :
+                    serviceState.toUpperCase() + " / " + serviceSummary;
 
             // Disable all accessibility services that are not permitted.
-            String packageName = serviceInfo.packageName;
             boolean serviceAllowed =
                     permittedServices == null || permittedServices.contains(packageName);
             if (!serviceAllowed && !serviceEnabled) {
                 EnforcedAdmin admin = RestrictedLockUtils.checkIfAccessibilityServiceDisallowed(
-                        getActivity(), serviceInfo.packageName, UserHandle.myUserId());
+                        getActivity(), packageName, UserHandle.myUserId());
                 if (admin != null) {
                     preference.setDisabledByAdmin(admin);
                 } else {
@@ -521,9 +566,7 @@
                 preference.setEnabled(true);
             }
 
-            preference.setSummary(serviceEnabledString);
-
-            preference.setOrder(i);
+            preference.setSummary(serviceSummary);
             preference.setFragment(ToggleAccessibilityServicePreferenceFragment.class.getName());
             preference.setPersistent(true);
 
@@ -543,26 +586,33 @@
                 extras.putString(EXTRA_SETTINGS_TITLE,
                         getString(R.string.accessibility_menu_item_settings));
                 extras.putString(EXTRA_SETTINGS_COMPONENT_NAME,
-                        new ComponentName(info.getResolveInfo().serviceInfo.packageName,
-                                settingsClassName).flattenToString());
+                        new ComponentName(packageName, settingsClassName).flattenToString());
             }
-
             extras.putParcelable(EXTRA_COMPONENT_NAME, componentName);
 
-            mServicesCategory.addPreference(preference);
+            PreferenceCategory prefCategory = downloadedServicesCategory;
+            // Set the appropriate category if the service comes pre-installed.
+            if (mPreBundledServiceComponentToCategoryMap.containsKey(componentName)) {
+                prefCategory = mPreBundledServiceComponentToCategoryMap.get(componentName);
+            }
+            preference.setOrder(FIRST_PREFERENCE_IN_CATEGORY_INDEX);
+            prefCategory.addPreference(preference);
+            mServicePreferenceToPreferenceCategoryMap.put(preference, prefCategory);
         }
 
-        if (mServicesCategory.getPreferenceCount() == 0) {
-            if (mNoServicesMessagePreference == null) {
-                mNoServicesMessagePreference = new Preference(getPrefContext());
-                mNoServicesMessagePreference.setPersistent(false);
-                mNoServicesMessagePreference.setLayoutResource(
-                        R.layout.text_description_preference);
-                mNoServicesMessagePreference.setSelectable(false);
-                mNoServicesMessagePreference.setSummary(
-                        getString(R.string.accessibility_no_services_installed));
-            }
-            mServicesCategory.addPreference(mNoServicesMessagePreference);
+        // If the user has not installed any additional services, hide the category.
+        if (downloadedServicesCategory.getPreferenceCount() == 0) {
+            PreferenceScreen screen = getPreferenceScreen();
+            screen.removePreference(downloadedServicesCategory);
+        }
+    }
+
+    private void initializePreBundledServicesMapFromArray(String categoryKey, int key) {
+        String[] services = getResources().getStringArray(key);
+        PreferenceCategory category = mCategoryToPrefCategoryMap.get(categoryKey);
+        for (int i = 0; i < services.length; i++) {
+            ComponentName component = ComponentName.unflattenFromString(services[i]);
+            mPreBundledServiceComponentToCategoryMap.put(component, category);
         }
     }
 
@@ -602,7 +652,7 @@
                 Settings.Secure.LONG_PRESS_TIMEOUT, mLongPressTimeoutDefault);
         String value = String.valueOf(longPressTimeout);
         mSelectLongPressTimeoutPreference.setValue(value);
-        mSelectLongPressTimeoutPreference.setSummary(mLongPressTimeoutValuetoTitleMap.get(value));
+        mSelectLongPressTimeoutPreference.setSummary(mLongPressTimeoutValueToTitleMap.get(value));
 
         updateFeatureSummary(Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED,
                 mCaptioningPreferenceScreen);
diff --git a/src/com/android/settings/accounts/AccountDetailDashboardFragment.java b/src/com/android/settings/accounts/AccountDetailDashboardFragment.java
index 801a20b..65959b4 100644
--- a/src/com/android/settings/accounts/AccountDetailDashboardFragment.java
+++ b/src/com/android/settings/accounts/AccountDetailDashboardFragment.java
@@ -76,7 +76,7 @@
             }
         }
         mAccountSynController.init(mAccount, userHandle);
-        mRemoveAccountController.setAccount(mAccount);
+        mRemoveAccountController.init(mAccount, userHandle);
     }
 
     @Override
diff --git a/src/com/android/settings/accounts/RemoveAccountPreferenceController.java b/src/com/android/settings/accounts/RemoveAccountPreferenceController.java
index c8dbe4c..f331144 100644
--- a/src/com/android/settings/accounts/RemoveAccountPreferenceController.java
+++ b/src/com/android/settings/accounts/RemoveAccountPreferenceController.java
@@ -27,8 +27,10 @@
 import android.app.Fragment;
 import android.content.Context;
 import android.content.DialogInterface;
+import android.content.Intent;
 import android.os.Bundle;
 import android.os.Process;
+import android.os.UserHandle;
 import android.support.v7.preference.PreferenceScreen;
 import android.view.View;
 import android.view.View.OnClickListener;
@@ -49,6 +51,7 @@
 
     private Account mAccount;
     private Fragment mParentFragment;
+    private UserHandle mUserHandle;
 
     public RemoveAccountPreferenceController(Context context, Fragment parent) {
         super(context);
@@ -76,11 +79,12 @@
 
     @Override
     public void onClick(View v) {
-        ConfirmRemoveAccountDialog.show(mParentFragment, mAccount);
+        ConfirmRemoveAccountDialog.show(mParentFragment, mAccount, mUserHandle);
     }
 
-    public void setAccount(Account account) {
+    public void init(Account account, UserHandle userHandle) {
         mAccount = account;
+        mUserHandle = userHandle;
     }
 
     /**
@@ -88,27 +92,37 @@
      */
     public static class ConfirmRemoveAccountDialog extends InstrumentedDialogFragment implements
             DialogInterface.OnClickListener {
-        private static final String SAVE_ACCOUNT = "account";
+        private static final String KEY_ACCOUNT = "account";
         private static final String REMOVE_ACCOUNT_DIALOG = "confirmRemoveAccount";
         private Account mAccount;
+        private UserHandle mUserHandle;
 
-        public static ConfirmRemoveAccountDialog show(Fragment parent, Account account) {
+        public static ConfirmRemoveAccountDialog show(
+                Fragment parent, Account account, UserHandle userHandle) {
             if (!parent.isAdded()) {
                 return null;
             }
             final ConfirmRemoveAccountDialog dialog = new ConfirmRemoveAccountDialog();
-            dialog.mAccount = account;
+            Bundle bundle = new Bundle();
+            bundle.putParcelable(KEY_ACCOUNT, account);
+            bundle.putParcelable(Intent.EXTRA_USER, userHandle);
+            dialog.setArguments(bundle);
             dialog.setTargetFragment(parent, 0);
             dialog.show(parent.getFragmentManager(), REMOVE_ACCOUNT_DIALOG);
             return dialog;
         }
 
         @Override
+        public void onCreate(Bundle savedInstanceState) {
+            super.onCreate(savedInstanceState);
+            final Bundle arguments = getArguments();
+            mAccount = arguments.getParcelable(KEY_ACCOUNT);
+            mUserHandle = arguments.getParcelable(Intent.EXTRA_USER);
+        }
+
+        @Override
         public Dialog onCreateDialog(Bundle savedInstanceState) {
             final Context context = getActivity();
-            if (savedInstanceState != null) {
-                mAccount = (Account) savedInstanceState.getParcelable(SAVE_ACCOUNT);
-            }
             return new AlertDialog.Builder(context)
                 .setTitle(R.string.really_remove_account_title)
                 .setMessage(R.string.really_remove_account_message)
@@ -118,12 +132,6 @@
         }
 
         @Override
-        public void onSaveInstanceState(Bundle outState) {
-            super.onSaveInstanceState(outState);
-            outState.putParcelable(SAVE_ACCOUNT, mAccount);
-        }
-
-        @Override
         public int getMetricsCategory() {
             return MetricsProto.MetricsEvent.DIALOG_ACCOUNT_SYNC_REMOVE;
         }
@@ -159,7 +167,7 @@
                                 activity.finish();
                             }
                         }
-                    }, null, Process.myUserHandle());
+                    }, null, mUserHandle);
         }
     }
 
diff --git a/src/com/android/settings/applications/AppStorageSettings.java b/src/com/android/settings/applications/AppStorageSettings.java
index b4d7526..32c8d32 100644
--- a/src/com/android/settings/applications/AppStorageSettings.java
+++ b/src/com/android/settings/applications/AppStorageSettings.java
@@ -615,28 +615,6 @@
         }
     };
 
-    public static CharSequence getSummary(AppEntry appEntry, Context context) {
-        if (appEntry.size == ApplicationsState.SIZE_INVALID
-                || appEntry.size == ApplicationsState.SIZE_UNKNOWN) {
-            return context.getText(R.string.computing_size);
-        } else {
-            CharSequence storageType = context.getString(
-                    (appEntry.info.flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0
-                    ? R.string.storage_type_external
-                    : R.string.storage_type_internal);
-            return context.getString(R.string.storage_summary_format,
-                    getSize(appEntry, context), storageType);
-        }
-    }
-
-    private static CharSequence getSize(AppEntry appEntry, Context context) {
-        long size = appEntry.size;
-        if (size == SIZE_INVALID) {
-            return context.getText(R.string.invalid_size_value);
-        }
-        return Formatter.formatFileSize(context, size);
-    }
-
     @Override
     public int getMetricsCategory() {
         return MetricsEvent.APPLICATIONS_APP_STORAGE;
diff --git a/src/com/android/settings/applications/InstalledAppDetails.java b/src/com/android/settings/applications/InstalledAppDetails.java
index 3427d9e..5a32531 100755
--- a/src/com/android/settings/applications/InstalledAppDetails.java
+++ b/src/com/android/settings/applications/InstalledAppDetails.java
@@ -16,10 +16,13 @@
 
 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.app.admin.DevicePolicyManager;
 import android.content.ActivityNotFoundException;
@@ -103,6 +106,8 @@
 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.net.ChartData;
 import com.android.settingslib.net.ChartDataLoader;
 
@@ -111,8 +116,6 @@
 import java.util.HashSet;
 import java.util.List;
 
-import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
-
 /**
  * Activity to display application information from Settings. This activity presents
  * extended information associated with a package like code, data, total size, permissions
@@ -123,7 +126,8 @@
  * uninstall the application.
  */
 public class InstalledAppDetails extends AppInfoBase
-        implements View.OnClickListener, OnPreferenceClickListener {
+        implements View.OnClickListener, OnPreferenceClickListener,
+        LoaderManager.LoaderCallbacks<AppStorageStats> {
 
     private static final String LOG_TAG = "InstalledAppDetails";
 
@@ -138,6 +142,7 @@
     private static final int SUB_INFO_FRAGMENT = 1;
 
     private static final int LOADER_CHART_DATA = 2;
+    private static final int LOADER_STORAGE = 3;
 
     private static final int DLG_FORCE_STOP = DLG_BASE + 1;
     private static final int DLG_DISABLE = DLG_BASE + 2;
@@ -191,6 +196,8 @@
     protected ProcStatsData mStatsManager;
     protected ProcStatsPackageEntry mStats;
 
+    private AppStorageStats mLastResult;
+
     private boolean handleDisableable(Button button) {
         boolean disableable = false;
         // Try to prevent the user from bricking their phone
@@ -359,13 +366,14 @@
         if (mFinishing) {
             return;
         }
-        mState.requestSize(mPackageName, mUserId);
         AppItem app = new AppItem(mAppEntry.info.uid);
         app.addUid(mAppEntry.info.uid);
         if (mStatsSession != null) {
-            getLoaderManager().restartLoader(LOADER_CHART_DATA,
+            LoaderManager loaderManager = getLoaderManager();
+            loaderManager.restartLoader(LOADER_CHART_DATA,
                     ChartDataLoader.buildArgs(getTemplate(getContext()), app),
                     mDataCallbacks);
+            loaderManager.restartLoader(LOADER_STORAGE, Bundle.EMPTY, this);
         }
         new BatteryUpdater().execute();
         new MemoryUpdater().execute();
@@ -536,6 +544,23 @@
         }
     }
 
+    @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 set application label and icon.
     private void setAppLabelAndIcon(PackageInfo pkgInfo) {
         final View appSnippet = mHeader.findViewById(R.id.app_snippet);
@@ -638,7 +663,8 @@
 
         // Update the preference summaries.
         Activity context = getActivity();
-        mStoragePreference.setSummary(AppStorageSettings.getSummary(mAppEntry, context));
+        boolean isExternal = ((mAppEntry.info.flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0);
+        mStoragePreference.setSummary(getStorageSummary(context, mLastResult, isExternal));
 
         PermissionsSummaryHelper.getPermissionSummary(getContext(),
                 mPackageName, mPermissionCallback);
@@ -707,6 +733,25 @@
         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);
+        }
+    }
+
+    private static CharSequence getSize(Context context, AppStorageStats stats) {
+        return Formatter.formatFileSize(context, stats.getTotalBytes());
+    }
+
+
     @Override
     protected AlertDialog createDialog(int id, int errorCode) {
         switch (id) {
diff --git a/src/com/android/settings/bluetooth/BluetoothSettings.java b/src/com/android/settings/bluetooth/BluetoothSettings.java
index 99c46bf..acb99a6 100644
--- a/src/com/android/settings/bluetooth/BluetoothSettings.java
+++ b/src/com/android/settings/bluetooth/BluetoothSettings.java
@@ -99,6 +99,8 @@
 
     private final IntentFilter mIntentFilter;
 
+    // For Search
+    private static final String DATA_KEY_REFERENCE = "main_toggle_bluetooth";
 
     // accessed from inner class (not private to avoid thunks)
     FooterPreference mMyDevicePreference;
@@ -567,6 +569,7 @@
                     SearchIndexableRaw data = new SearchIndexableRaw(context);
                     data.title = res.getString(R.string.bluetooth_settings);
                     data.screenTitle = res.getString(R.string.bluetooth_settings);
+                    data.key = DATA_KEY_REFERENCE;
                     result.add(data);
 
                     // Add cached paired BT devices
diff --git a/src/com/android/settings/core/gateway/SettingsGateway.java b/src/com/android/settings/core/gateway/SettingsGateway.java
index 742f727..59c5014 100644
--- a/src/com/android/settings/core/gateway/SettingsGateway.java
+++ b/src/com/android/settings/core/gateway/SettingsGateway.java
@@ -243,47 +243,38 @@
     };
 
     public static final String[] SETTINGS_FOR_RESTRICTED = {
-            //wireless_section
-            Settings.WifiSettingsActivity.class.getName(),
-            Settings.BluetoothSettingsActivity.class.getName(),
-            Settings.SimSettingsActivity.class.getName(),
-            //device_section
-            Settings.SoundSettingsActivity.class.getName(),
-            Settings.DisplaySettingsActivity.class.getName(),
-            Settings.StorageSettingsActivity.class.getName(),
-            Settings.ManageApplicationsActivity.class.getName(),
-            Settings.PowerUsageSummaryActivity.class.getName(),
-            //personal_section
-            Settings.LocationSettingsActivity.class.getName(),
-            Settings.SecuritySettingsActivity.class.getName(),
-            Settings.UserSettingsActivity.class.getName(),
-            //system_section
-            Settings.DateTimeSettingsActivity.class.getName(),
-            Settings.DeviceInfoSettingsActivity.class.getName(),
-            Settings.AccessibilitySettingsActivity.class.getName(),
-            Settings.PrintSettingsActivity.class.getName(),
-            Settings.PaymentSettingsActivity.class.getName(),
-
-
             // New IA
             // Home page
             Settings.NetworkDashboardActivity.class.getName(),
             Settings.ConnectedDeviceDashboardActivity.class.getName(),
-            Settings.WifiDisplaySettingsActivity.class.getName(),
             Settings.AppAndNotificationDashboardActivity.class.getName(),
+            Settings.DisplaySettingsActivity.class.getName(),
+            Settings.SoundSettingsActivity.class.getName(),
             Settings.StorageDashboardActivity.class.getName(),
-            "com.android.settings.SoundDashboardAlias",
-            "com.android.settings.UsersDashboardAlias",
+            Settings.PowerUsageSummaryActivity.class.getName(),
             Settings.UserAndAccountDashboardActivity.class.getName(),
+            Settings.SecuritySettingsActivity.class.getName(),
+            Settings.AccessibilitySettingsActivity.class.getName(),
             Settings.SystemDashboardActivity.class.getName(),
             Settings.SupportDashboardActivity.class.getName(),
-            // Home page > Apps & Notifications
-            "com.android.settings.ManageApplicationsDashboardAlias",
-            "com.android.settings.PaymentSettingsDashboardAlias",
             // Home page > Network & Internet
+            Settings.WifiSettingsActivity.class.getName(),
             Settings.DataUsageSummaryActivity.class.getName(),
+            Settings.SimSettingsActivity.class.getName(),
+            // Home page > Connected devices
+            Settings.BluetoothSettingsActivity.class.getName(),
+            Settings.WifiDisplaySettingsActivity.class.getName(),
+            Settings.PrintSettingsActivity.class.getName(),
+            // Home page > Apps & Notifications
+            Settings.UserSettingsActivity.class.getName(),
+            Settings.ManageApplicationsActivity.class.getName(),
+            Settings.PaymentSettingsActivity.class.getName(),
+            // Home page > Security & screen lock
+            Settings.LocationSettingsActivity.class.getName(),
             // Home page > System
             Settings.LanguageAndInputSettingsActivity.class.getName(),
+            Settings.DateTimeSettingsActivity.class.getName(),
+            Settings.DeviceInfoSettingsActivity.class.getName(),
             Settings.EnterprisePrivacySettingsActivity.class.getName(),
     };
 }
diff --git a/src/com/android/settings/core/instrumentation/SharedPreferencesLogger.java b/src/com/android/settings/core/instrumentation/SharedPreferencesLogger.java
index a5efcc1..6c23b39 100644
--- a/src/com/android/settings/core/instrumentation/SharedPreferencesLogger.java
+++ b/src/com/android/settings/core/instrumentation/SharedPreferencesLogger.java
@@ -21,6 +21,7 @@
 import android.content.pm.PackageManager;
 import android.os.AsyncTask;
 import android.text.TextUtils;
+import android.util.Pair;
 
 import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
 import com.android.settings.overlay.FeatureFactory;
@@ -111,13 +112,17 @@
             return;
         }
         // Pref key exists in set, log it's change in metrics.
-        mMetricsFeature.count(mContext, prefKey + "|" + value, 1);
+        mMetricsFeature.action(mContext, MetricsEvent.ACTION_SETTINGS_PREFERENCE_CHANGE,
+                Pair.create(MetricsEvent.FIELD_SETTINGS_PREFERENCE_CHANGE_NAME, prefKey),
+                Pair.create(MetricsEvent.FIELD_SETTINGS_PREFERENCE_CHANGE_VALUE, value));
     }
 
     private void logPackageName(String key, String value) {
-        mMetricsFeature.count(mContext, mTag + "/" + key, 1);
+        final String prefKey = mTag + "/" + key;
+        mMetricsFeature.action(mContext, MetricsEvent.ACTION_SETTINGS_PREFERENCE_CHANGE,
+                Pair.create(MetricsEvent.FIELD_SETTINGS_PREFERENCE_CHANGE_NAME, prefKey));
         mMetricsFeature.action(mContext, MetricsEvent.ACTION_GENERIC_PACKAGE,
-                mTag + "/" + key + "|" + value);
+                prefKey + "|" + value);
     }
 
     private void safeLogValue(String key, String value) {
diff --git a/src/com/android/settings/fuelgauge/PowerUsageAdvanced.java b/src/com/android/settings/fuelgauge/PowerUsageAdvanced.java
index fc96340..f18ae65 100644
--- a/src/com/android/settings/fuelgauge/PowerUsageAdvanced.java
+++ b/src/com/android/settings/fuelgauge/PowerUsageAdvanced.java
@@ -59,7 +59,8 @@
             UsageType.BLUETOOTH,
             UsageType.USER,
             UsageType.IDLE,
-            UsageType.APP};
+            UsageType.APP,
+            UsageType.UNACCOUNTED};
     private BatteryHistoryPreference mHistPref;
     private PreferenceGroup mUsageListGroup;
     private PowerUsageFeatureProvider mPowerUsageFeatureProvider;
@@ -114,7 +115,7 @@
         mUsageListGroup.removeAll();
         for (int i = 0, size = dataList.size(); i < size; i++) {
             final PowerUsageData batteryData = dataList.get(i);
-            final PowerGaugePreference pref = new PowerGaugePreference(getContext());
+            final PowerGaugePreference pref = new PowerGaugePreference(getPrefContext());
 
             pref.setTitle(batteryData.titleResId);
             pref.setSummary(batteryData.summary);
@@ -139,6 +140,8 @@
             return UsageType.USER;
         } else if (drainType == DrainType.CELL) {
             return UsageType.CELL;
+        } else if (drainType == DrainType.UNACCOUNTED) {
+            return UsageType.UNACCOUNTED;
         } else if (mPowerUsageFeatureProvider.isTypeSystem(sipper)) {
             return UsageType.SYSTEM;
         } else if (mPowerUsageFeatureProvider.isTypeService(sipper)) {
@@ -200,7 +203,8 @@
                 UsageType.SYSTEM,
                 UsageType.BLUETOOTH,
                 UsageType.USER,
-                UsageType.IDLE})
+                UsageType.IDLE,
+                UsageType.UNACCOUNTED})
         public @interface UsageType {
             int APP = 0;
             int WIFI = 1;
@@ -210,6 +214,7 @@
             int BLUETOOTH = 5;
             int USER = 6;
             int IDLE = 7;
+            int UNACCOUNTED = 8;
         }
 
         @StringRes
@@ -249,6 +254,8 @@
                     return R.string.power_user;
                 case UsageType.IDLE:
                     return R.string.power_idle;
+                case UsageType.UNACCOUNTED:
+                    return R.string.power_unaccounted;
                 case UsageType.APP:
                 default:
                     return R.string.power_apps;
diff --git a/src/com/android/settings/network/NetworkScoreManagerWrapper.java b/src/com/android/settings/network/NetworkScoreManagerWrapper.java
new file mode 100644
index 0000000..0d35378
--- /dev/null
+++ b/src/com/android/settings/network/NetworkScoreManagerWrapper.java
@@ -0,0 +1,73 @@
+/*
+ * 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.network;
+
+import android.annotation.Nullable;
+import android.net.NetworkScoreManager;
+import android.net.NetworkScorerAppData;
+
+import java.util.List;
+
+/**
+ * Wrapper around {@link NetworkScoreManager} to facilitate unit testing.
+ *
+ * TODO: delete this class once robolectric supports Android O
+ */
+public class NetworkScoreManagerWrapper {
+    private final NetworkScoreManager mNetworkScoreManager;
+
+    public NetworkScoreManagerWrapper(NetworkScoreManager networkScoreManager) {
+        mNetworkScoreManager = networkScoreManager;
+    }
+
+    /**
+     * Returns the list of available scorer apps. The list will be empty if there are
+     * no valid scorers.
+     */
+    public List<NetworkScorerAppData> getAllValidScorers() {
+        return mNetworkScoreManager.getAllValidScorers();
+    }
+
+    /**
+     * Obtain the package name of the current active network scorer.
+     *
+     * <p>At any time, only one scorer application will receive {@link #ACTION_SCORE_NETWORKS}
+     * broadcasts and be allowed to call {@link #updateScores}. Applications may use this method to
+     * determine the current scorer and offer the user the ability to select a different scorer via
+     * the {@link #ACTION_CHANGE_ACTIVE} intent.
+     * @return the full package name of the current active scorer, or null if there is no active
+     *         scorer.
+     */
+    @Nullable
+    public String getActiveScorerPackage() {
+        return mNetworkScoreManager.getActiveScorerPackage();
+    }
+
+
+    /**
+     * Set the active scorer to a new package and clear existing scores.
+     *
+     * <p>Should never be called directly without obtaining user consent. This can be done by using
+     * the {@link #ACTION_CHANGE_ACTIVE} broadcast, or using a custom configuration activity.
+     *
+     * @return true if the operation succeeded, or false if the new package is not a valid scorer.
+     * @throws SecurityException if the caller is not a system process or does not hold the
+     *         {@link android.Manifest.permission#REQUEST_NETWORK_SCORES} permission
+     */
+    public boolean setActiveScorer(String packageName) throws SecurityException {
+        return mNetworkScoreManager.setActiveScorer(packageName);
+    }
+}
\ No newline at end of file
diff --git a/src/com/android/settings/network/NetworkScorerPicker.java b/src/com/android/settings/network/NetworkScorerPicker.java
new file mode 100644
index 0000000..da9d84f
--- /dev/null
+++ b/src/com/android/settings/network/NetworkScorerPicker.java
@@ -0,0 +1,135 @@
+/*
+ * 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.network;
+
+import android.content.Context;
+import android.net.NetworkScoreManager;
+import android.net.NetworkScorerAppData;
+import android.os.Bundle;
+import android.support.annotation.VisibleForTesting;
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceScreen;
+import android.text.TextUtils;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import com.android.settings.R;
+import com.android.settings.core.InstrumentedPreferenceFragment;
+import com.android.settings.core.instrumentation.Instrumentable;
+import com.android.settings.widget.RadioButtonPreference;
+
+import java.util.List;
+
+/**
+ * Fragment for choosing default network scorer.
+ */
+public class NetworkScorerPicker extends InstrumentedPreferenceFragment implements
+        RadioButtonPreference.OnClickListener {
+
+    private NetworkScoreManagerWrapper mNetworkScoreManager;
+
+    @Override
+    public int getMetricsCategory() {
+        //TODO(35854268): Add logging.
+        return Instrumentable.METRICS_CATEGORY_UNKNOWN;
+    }
+
+    @Override
+    public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
+        super.onCreatePreferences(savedInstanceState, rootKey);
+        addPreferencesFromResource(R.xml.network_scorer_picker_prefs);
+        updateCandidates();
+    }
+
+    @Override
+    public void onAttach(Context context) {
+        super.onAttach(context);
+        mNetworkScoreManager = createNetworkScorerManagerWrapper(context);
+    }
+
+    @Override
+    public View onCreateView(LayoutInflater inflater, ViewGroup container,
+                             Bundle savedInstanceState) {
+        final View view = super.onCreateView(inflater, container, savedInstanceState);
+        // this is needed so the back button goes back to previous fragment
+        setHasOptionsMenu(true);
+        return view;
+    }
+
+    @VisibleForTesting
+    public void updateCandidates() {
+        final PreferenceScreen screen = getPreferenceScreen();
+        screen.removeAll();
+
+        final List<NetworkScorerAppData> scorers = mNetworkScoreManager.getAllValidScorers();
+        if (scorers.isEmpty()) {
+            final RadioButtonPreference nonePref = new RadioButtonPreference(getPrefContext());
+            nonePref.setTitle(R.string.network_scorer_picker_none_preference);
+            nonePref.setChecked(true);
+            screen.addPreference(nonePref);
+            return;
+        }
+        final String defaultAppKey = getActiveScorerPackage();
+        final int numScorers = scorers.size();
+        for (int i = 0; i < numScorers; i++) {
+            final RadioButtonPreference pref = new RadioButtonPreference(getPrefContext());
+            final NetworkScorerAppData appData = scorers.get(i);
+            final String appKey = appData.getRecommendationServicePackageName();
+            pref.setTitle(appData.getRecommendationServiceLabel());
+            pref.setKey(appKey);
+            pref.setChecked(TextUtils.equals(defaultAppKey, appKey));
+            pref.setOnClickListener(this);
+            screen.addPreference(pref);
+        }
+    }
+
+    private String getActiveScorerPackage() {
+        return mNetworkScoreManager.getActiveScorerPackage();
+    }
+
+    private boolean setActiveScorer(String key) {
+        if (!TextUtils.equals(key, getActiveScorerPackage())) {
+            return mNetworkScoreManager.setActiveScorer(key);
+        }
+        return false;
+    }
+
+    @Override
+    public void onRadioButtonClicked(RadioButtonPreference selected) {
+        final String selectedKey = selected.getKey();
+        final boolean success = setActiveScorer(selectedKey);
+        if (success) {
+            updateCheckedState(selectedKey);
+        }
+    }
+
+    private void updateCheckedState(String selectedKey) {
+        final PreferenceScreen screen = getPreferenceScreen();
+        final int count = screen.getPreferenceCount();
+        for (int i = 0; i < count; i++) {
+            final Preference pref = screen.getPreference(i);
+            if (pref instanceof RadioButtonPreference) {
+                final RadioButtonPreference radioPref = (RadioButtonPreference) pref;
+                radioPref.setChecked(TextUtils.equals(pref.getKey(), selectedKey));
+            }
+        }
+    }
+
+    @VisibleForTesting
+    NetworkScoreManagerWrapper createNetworkScorerManagerWrapper(Context context) {
+        return new NetworkScoreManagerWrapper(context.getSystemService(NetworkScoreManager.class));
+    }
+}
diff --git a/src/com/android/settings/search2/CursorToSearchResultConverter.java b/src/com/android/settings/search2/CursorToSearchResultConverter.java
index 880a65b..71d999e 100644
--- a/src/com/android/settings/search2/CursorToSearchResultConverter.java
+++ b/src/com/android/settings/search2/CursorToSearchResultConverter.java
@@ -35,6 +35,7 @@
 import com.android.settings.dashboard.SiteMapManager;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -77,6 +78,22 @@
 
     private final Set<String> mKeys;
 
+    private final int LONG_TITLE_LENGTH = 20;
+
+    private static final String[] whiteList = {
+            "main_toggle_wifi",
+            "main_toggle_bluetooth",
+            "toggle_airplane",
+            "tether_settings",
+            "battery_saver",
+            "toggle_nfc",
+            "restrict_background",
+            "data_usage_enable",
+            "button_roaming_key",
+    };
+    private static final Set<String> prioritySettings = new HashSet(Arrays.asList(whiteList));
+
+
     public CursorToSearchResultConverter(Context context, String queryText) {
         mContext = context;
         mKeys = new HashSet<>();
@@ -135,7 +152,7 @@
         }
 
         final List<String> breadcrumbs = getBreadcrumbs(sitemapManager, cursor);
-        final int rank = getRank(breadcrumbs, baseRank);
+        final int rank = getRank(title, breadcrumbs, baseRank, key);
 
         final SearchResult.Builder builder = new SearchResult.Builder();
         builder.addTitle(title)
@@ -225,18 +242,32 @@
     }
 
     /** Uses the breadcrumbs to determine the offset to the base rank.
-     *  There are two checks
-     *  A) If the query matches the highest level menu title
-     *  B) If the query matches a subsequent menu title
+     *  There are three checks
+     *  A) If the result is prioritized and the highest base level
+     *  B) If the query matches the highest level menu title
+     *  C) If the query matches a subsequent menu title
+     *  D) Is the title longer than 20
      *
-     *  If the query matches A and B, the offset is 0.
-     *  If the query matches A only, the offset is 1.
-     *  If the query matches neither A nor B, the offset is 2.
+     *  If the query matches A, set it to TOP_RANK
+     *  If the query matches B and C, the offset is 0.
+     *  If the query matches C only, the offset is 1.
+     *  If the query matches neither B nor C, the offset is 2.
+     *  If the query matches D, the offset is 2
+
+     * @param title of the result.
      * @param crumbs from the Information Architecture
      * @param baseRank of the result. Lower if it's a better result.
      * @return
      */
-    private int getRank(List<String> crumbs, int baseRank) {
+    private int getRank(String title, List<String> crumbs, int baseRank, String key) {
+        // The result can only be prioritized if it is a top ranked result.
+        if (prioritySettings.contains(key) && baseRank < DatabaseResultLoader.BASE_RANKS[1]) {
+            return SearchResult.TOP_RANK;
+        }
+        if (title.length() > LONG_TITLE_LENGTH) {
+            return baseRank + 2;
+        }
         return baseRank;
     }
+
 }
diff --git a/src/com/android/settings/search2/DatabaseResultLoader.java b/src/com/android/settings/search2/DatabaseResultLoader.java
index ad1e6a9..5892ebc 100644
--- a/src/com/android/settings/search2/DatabaseResultLoader.java
+++ b/src/com/android/settings/search2/DatabaseResultLoader.java
@@ -97,7 +97,7 @@
      * If the query only matches keywords or entries, the best rank it can be is 9
      *
      */
-    private static final int[] BASE_RANKS = {1, 3, 7, 9};
+    public static final int[] BASE_RANKS = {1, 3, 7, 9};
 
     private final String mQueryText;
     private final Context mContext;
diff --git a/src/com/android/settings/search2/SearchResult.java b/src/com/android/settings/search2/SearchResult.java
index a82c47f..6b27d89 100644
--- a/src/com/android/settings/search2/SearchResult.java
+++ b/src/com/android/settings/search2/SearchResult.java
@@ -27,10 +27,15 @@
 public class SearchResult implements Comparable<SearchResult> {
 
     /**
-     * Defines the max rank for a search result to be considered as ranked. Results with ranks
+     * Defines the lowest rank for a search result to be considered as ranked. Results with ranks
      * higher than this have no guarantee for sorting order.
      */
-    public static final int MAX_RANK  = 10;
+    public static final int BOTTOM_RANK = 10;
+
+    /**
+     * Defines the highest rank for a search result. Used for special search results only.
+     */
+    public static final int TOP_RANK = 0;
 
     /**
      * The title of the result and main text displayed.
diff --git a/src/com/android/settings/search2/SearchResultsAdapter.java b/src/com/android/settings/search2/SearchResultsAdapter.java
index afe432a..5151b64 100644
--- a/src/com/android/settings/search2/SearchResultsAdapter.java
+++ b/src/com/android/settings/search2/SearchResultsAdapter.java
@@ -32,7 +32,8 @@
 import java.util.List;
 import java.util.Map;
 
-import static com.android.settings.search2.SearchResult.MAX_RANK;
+import static com.android.settings.search2.SearchResult.TOP_RANK;
+import static com.android.settings.search2.SearchResult.BOTTOM_RANK;
 
 public class SearchResultsAdapter extends Adapter<SearchViewHolder> {
 
@@ -117,9 +118,9 @@
 
         int dbIndex = 0;
         int appIndex = 0;
-        int rank = 1;
+        int rank = TOP_RANK;
 
-        while (rank <= MAX_RANK) {
+        while (rank <= BOTTOM_RANK) {
             while ((dbIndex < dbSize) && (databaseResults.get(dbIndex).rank == rank)) {
                 results.add(databaseResults.get(dbIndex++));
             }
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index d652efa..9405e8c 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -168,6 +168,9 @@
 
     private MenuItem mScanMenuItem;
 
+    // For Search
+    private static final String DATA_KEY_REFERENCE = "main_toggle_wifi";
+
     /* End of "used in Wifi Setup context" */
 
     public WifiSettings() {
@@ -1028,6 +1031,7 @@
                 data.title = res.getString(R.string.wifi_settings);
                 data.screenTitle = res.getString(R.string.wifi_settings);
                 data.keywords = res.getString(R.string.keywords_wifi);
+                data.key = DATA_KEY_REFERENCE;
                 result.add(data);
 
                 // Add saved Wi-Fi access points
diff --git a/tests/robotests/Android.mk b/tests/robotests/Android.mk
index 3fc034d..b448433 100644
--- a/tests/robotests/Android.mk
+++ b/tests/robotests/Android.mk
@@ -38,4 +38,6 @@
 
 LOCAL_TEST_PACKAGE := Settings
 
+LOCAL_INSTRUMENT_SOURCE_DIRS := $(dir $(LOCAL_PATH))../src
+
 include prebuilts/misc/common/robolectric/run_robotests.mk
\ No newline at end of file
diff --git a/tests/robotests/src/android/net/NetworkScorerAppData.java b/tests/robotests/src/android/net/NetworkScorerAppData.java
new file mode 100644
index 0000000..1eaa8a7
--- /dev/null
+++ b/tests/robotests/src/android/net/NetworkScorerAppData.java
@@ -0,0 +1,112 @@
+package android.net;
+
+import android.annotation.Nullable;
+import android.content.ComponentName;
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import java.util.Objects;
+
+/**
+ * Holds metadata about a discovered network scorer/recommendation application.
+ *
+ * TODO: delete this class once robolectric supports Android O
+ */
+public final class NetworkScorerAppData implements Parcelable {
+    /** UID of the scorer app. */
+    public final int packageUid;
+    private final ComponentName mRecommendationService;
+    /** User visible label in Settings for the recommendation service. */
+    private final String mRecommendationServiceLabel;
+    /**
+     * The {@link ComponentName} of the Activity to start before enabling the "connect to open
+     * wifi networks automatically" feature.
+     */
+    private final ComponentName mEnableUseOpenWifiActivity;
+
+    public NetworkScorerAppData(int packageUid, ComponentName recommendationServiceComp,
+            String recommendationServiceLabel, ComponentName enableUseOpenWifiActivity) {
+        this.packageUid = packageUid;
+        this.mRecommendationService = recommendationServiceComp;
+        this.mRecommendationServiceLabel = recommendationServiceLabel;
+        this.mEnableUseOpenWifiActivity = enableUseOpenWifiActivity;
+    }
+
+    protected NetworkScorerAppData(Parcel in) {
+        packageUid = in.readInt();
+        mRecommendationService = ComponentName.readFromParcel(in);
+        mRecommendationServiceLabel = in.readString();
+        mEnableUseOpenWifiActivity = ComponentName.readFromParcel(in);
+    }
+
+    @Override
+    public void writeToParcel(Parcel dest, int flags) {
+        dest.writeInt(packageUid);
+        ComponentName.writeToParcel(mRecommendationService, dest);
+        dest.writeString(mRecommendationServiceLabel);
+        ComponentName.writeToParcel(mEnableUseOpenWifiActivity, dest);
+    }
+
+    @Override
+    public int describeContents() {
+        return 0;
+    }
+
+    public static final Creator<NetworkScorerAppData> CREATOR =
+            new Creator<NetworkScorerAppData>() {
+                @Override
+                public NetworkScorerAppData createFromParcel(Parcel in) {
+                    return new NetworkScorerAppData(in);
+                }
+
+                @Override
+                public NetworkScorerAppData[] newArray(int size) {
+                    return new NetworkScorerAppData[size];
+                }
+            };
+
+    public String getRecommendationServicePackageName() {
+        return mRecommendationService.getPackageName();
+    }
+
+    public ComponentName getRecommendationServiceComponent() {
+        return mRecommendationService;
+    }
+
+    @Nullable
+    public ComponentName getEnableUseOpenWifiActivity() {
+        return mEnableUseOpenWifiActivity;
+    }
+
+    @Nullable
+    public String getRecommendationServiceLabel() {
+        return mRecommendationServiceLabel;
+    }
+
+    @Override
+    public String toString() {
+        return "NetworkScorerAppData{" +
+                "packageUid=" + packageUid +
+                ", mRecommendationService=" + mRecommendationService +
+                ", mRecommendationServiceLabel=" + mRecommendationServiceLabel +
+                ", mEnableUseOpenWifiActivity=" + mEnableUseOpenWifiActivity +
+                '}';
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+        NetworkScorerAppData that = (NetworkScorerAppData) o;
+        return packageUid == that.packageUid &&
+                Objects.equals(mRecommendationService, that.mRecommendationService) &&
+                Objects.equals(mRecommendationServiceLabel, that.mRecommendationServiceLabel) &&
+                Objects.equals(mEnableUseOpenWifiActivity, that.mEnableUseOpenWifiActivity);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(packageUid, mRecommendationService, mRecommendationServiceLabel,
+                mEnableUseOpenWifiActivity);
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/accounts/RemoveAccountPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accounts/RemoveAccountPreferenceControllerTest.java
index 50f3ac6..033465b 100644
--- a/tests/robotests/src/com/android/settings/accounts/RemoveAccountPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accounts/RemoveAccountPreferenceControllerTest.java
@@ -23,6 +23,7 @@
 import android.app.FragmentManager;
 import android.app.FragmentTransaction;
 import android.content.Context;
+import android.os.Bundle;
 import android.os.Handler;
 import android.os.UserHandle;
 import android.support.v7.preference.PreferenceScreen;
@@ -127,11 +128,13 @@
         when(mFragment.getActivity()).thenReturn(activity);
 
         Account account = new Account("Account11", "com.acct1");
+        UserHandle userHandle = new UserHandle(10);
         RemoveAccountPreferenceController.ConfirmRemoveAccountDialog dialog =
-            RemoveAccountPreferenceController.ConfirmRemoveAccountDialog.show(mFragment, account);
-
+            RemoveAccountPreferenceController.ConfirmRemoveAccountDialog.show(
+                    mFragment, account, userHandle);
+        dialog.onCreate(new Bundle());
         dialog.onClick(null, 0);
         verify(mAccountManager).removeAccountAsUser(eq(account), any(Activity.class),
-            any(AccountManagerCallback.class), any(Handler.class), any(UserHandle.class));
+            any(AccountManagerCallback.class), any(Handler.class), eq(userHandle));
     }
 }
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/applications/InstalledAppDetailsTest.java b/tests/robotests/src/com/android/settings/applications/InstalledAppDetailsTest.java
index 2a703ef..4fe6293 100644
--- a/tests/robotests/src/com/android/settings/applications/InstalledAppDetailsTest.java
+++ b/tests/robotests/src/com/android/settings/applications/InstalledAppDetailsTest.java
@@ -16,7 +16,14 @@
 
 package com.android.settings.applications;
 
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
 import android.app.admin.DevicePolicyManager;
+import android.content.Context;
 import android.content.pm.ApplicationInfo;
 import android.content.pm.PackageInfo;
 import android.os.UserManager;
@@ -25,6 +32,7 @@
 import com.android.settings.SettingsRobolectricTestRunner;
 import com.android.settings.TestConfig;
 import com.android.settingslib.applications.ApplicationsState.AppEntry;
+import com.android.settingslib.applications.StorageStatsSource.AppStorageStats;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -32,14 +40,10 @@
 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 static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
 @RunWith(SettingsRobolectricTestRunner.class)
 @Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
 public final class InstalledAppDetailsTest {
@@ -117,4 +121,24 @@
         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.00B 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.00B used in Internal storage");
+
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/core/instrumentation/SharedPreferenceLoggerTest.java b/tests/robotests/src/com/android/settings/core/instrumentation/SharedPreferenceLoggerTest.java
index eeaa175..763d6e3 100644
--- a/tests/robotests/src/com/android/settings/core/instrumentation/SharedPreferenceLoggerTest.java
+++ b/tests/robotests/src/com/android/settings/core/instrumentation/SharedPreferenceLoggerTest.java
@@ -17,6 +17,7 @@
 
 import android.content.Context;
 import android.content.SharedPreferences;
+import android.util.Pair;
 
 import com.android.settings.SettingsRobolectricTestRunner;
 import com.android.settings.TestConfig;
@@ -32,7 +33,6 @@
 
 import static org.mockito.Matchers.any;
 import static org.mockito.Matchers.anyInt;
-import static org.mockito.Matchers.anyString;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 
@@ -71,7 +71,8 @@
         editor.putInt(TEST_KEY, 2);
         editor.putInt(TEST_KEY, 2);
 
-        verify(mMetricsFeature, times(6)).count(any(Context.class), anyString(), anyInt());
+        verify(mMetricsFeature, times(6)).action(any(Context.class), anyInt(),
+                any(Pair.class), any(Pair.class));
     }
 
     @Test
@@ -83,7 +84,8 @@
         editor.putBoolean(TEST_KEY, false);
         editor.putBoolean(TEST_KEY, false);
 
-        verify(mMetricsFeature, times(4)).count(any(Context.class), anyString(), anyInt());
+        verify(mMetricsFeature, times(4)).action(any(Context.class), anyInt(),
+                any(Pair.class), any(Pair.class));
     }
 
     @Test
@@ -95,7 +97,8 @@
         editor.putLong(TEST_KEY, 1);
         editor.putLong(TEST_KEY, 2);
 
-        verify(mMetricsFeature, times(4)).count(any(Context.class), anyString(), anyInt());
+        verify(mMetricsFeature, times(4)).action(any(Context.class), anyInt(),
+                any(Pair.class), any(Pair.class));
     }
 
     @Test
@@ -107,7 +110,8 @@
         editor.putFloat(TEST_KEY, 1);
         editor.putFloat(TEST_KEY, 2);
 
-        verify(mMetricsFeature, times(4)).count(any(Context.class), anyString(), anyInt());
+        verify(mMetricsFeature, times(4)).action(any(Context.class), anyInt(),
+                any(Pair.class), any(Pair.class));
     }
 
 }
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageAdvancedTest.java b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageAdvancedTest.java
index ed7e48b..494ac67 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageAdvancedTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageAdvancedTest.java
@@ -94,9 +94,9 @@
     @Test
     public void testExtractUsageType_TypeEqualsToDrainType_ReturnRelevantType() {
         final DrainType drainTypes[] = {DrainType.WIFI, DrainType.BLUETOOTH, DrainType.IDLE,
-                DrainType.USER, DrainType.CELL};
+                DrainType.USER, DrainType.CELL, DrainType.UNACCOUNTED};
         final int usageTypes[] = {UsageType.WIFI, UsageType.BLUETOOTH, UsageType.IDLE,
-                UsageType.USER, UsageType.CELL};
+                UsageType.USER, UsageType.CELL, UsageType.UNACCOUNTED};
 
         assertThat(drainTypes.length).isEqualTo(usageTypes.length);
         for (int i = 0, size = drainTypes.length; i < size; i++) {
@@ -147,7 +147,7 @@
 
         assertThat(usageTypeSet).asList().containsExactly(UsageType.APP, UsageType.WIFI,
                 UsageType.CELL, UsageType.BLUETOOTH, UsageType.IDLE, UsageType.SERVICE,
-                UsageType.USER, UsageType.SYSTEM);
+                UsageType.USER, UsageType.SYSTEM, UsageType.UNACCOUNTED);
     }
 
     @Test
diff --git a/tests/robotests/src/com/android/settings/network/NetworkScorerPickerTest.java b/tests/robotests/src/com/android/settings/network/NetworkScorerPickerTest.java
new file mode 100644
index 0000000..fef6f85
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/network/NetworkScorerPickerTest.java
@@ -0,0 +1,172 @@
+/*
+ * 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.network;
+
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.content.ComponentName;
+import android.content.Context;
+import android.net.NetworkScorerAppData;
+import android.support.v7.preference.PreferenceManager;
+import android.support.v7.preference.PreferenceScreen;
+import com.android.settings.R;
+import com.android.settings.SettingsRobolectricTestRunner;
+import com.android.settings.TestConfig;
+import com.android.settings.widget.RadioButtonPreference;
+import com.google.android.collect.Lists;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+import java.util.ArrayList;
+
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class NetworkScorerPickerTest {
+
+    private static final String TEST_SCORER_PACKAGE_1 = "Test Package 1";
+    private static final String TEST_SCORER_CLASS_1 = "Test Class 1";
+    private static final String TEST_SCORER_LABEL_1 = "Test Label 1";
+    private static final String TEST_SCORER_PACKAGE_2 = "Test Package 2";
+
+    private Context mContext;
+    @Mock
+    private NetworkScoreManagerWrapper mNetworkScoreManager;
+    @Mock
+    private PreferenceScreen mPreferenceScreen;
+
+    private TestFragment mFragment;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+        mContext = RuntimeEnvironment.application;
+        mFragment = new TestFragment(mContext, mPreferenceScreen, mNetworkScoreManager);
+        mFragment.onAttach(mContext);
+    }
+
+    @Test
+    public void testOnRadioButtonClicked_success() {
+        RadioButtonPreference pref = new RadioButtonPreference(mContext);
+        pref.setKey(TEST_SCORER_PACKAGE_1);
+        when(mPreferenceScreen.getPreference(anyInt())).thenReturn(pref);
+        when(mPreferenceScreen.getPreferenceCount()).thenReturn(1);
+        when(mNetworkScoreManager.setActiveScorer(TEST_SCORER_PACKAGE_1)).thenReturn(true);
+        when(mNetworkScoreManager.getActiveScorerPackage()).thenReturn(TEST_SCORER_PACKAGE_2);
+
+        mFragment.onRadioButtonClicked(pref);
+
+        verify(mNetworkScoreManager).setActiveScorer(TEST_SCORER_PACKAGE_1);
+        assertThat(pref.isChecked()).isTrue();
+    }
+
+    @Test
+    public void testOnRadioButtonClicked_currentScorer_doNothing() {
+        RadioButtonPreference pref = new RadioButtonPreference(mContext);
+        pref.setKey(TEST_SCORER_PACKAGE_1);
+        pref.setChecked(true);
+        when(mPreferenceScreen.getPreference(anyInt())).thenReturn(pref);
+        when(mPreferenceScreen.getPreferenceCount()).thenReturn(1);
+        when(mNetworkScoreManager.setActiveScorer(TEST_SCORER_PACKAGE_1)).thenReturn(true);
+        when(mNetworkScoreManager.getActiveScorerPackage()).thenReturn(TEST_SCORER_PACKAGE_1);
+
+        mFragment.onRadioButtonClicked(pref);
+
+        verify(mNetworkScoreManager, never()).setActiveScorer(any());
+        assertThat(pref.isChecked()).isTrue();
+    }
+
+    @Test
+    public void testUpdateCandidates_noValidScorers_nonePreference() {
+        when(mNetworkScoreManager.getAllValidScorers()).thenReturn(new ArrayList<>());
+        ArgumentCaptor<RadioButtonPreference> arg =
+                ArgumentCaptor.forClass(RadioButtonPreference.class);
+
+        mFragment.updateCandidates();
+
+        verify(mPreferenceScreen).addPreference(arg.capture());
+        assertThat(arg.getValue().getTitle()).isEqualTo(
+                mContext.getString(R.string.network_scorer_picker_none_preference));
+    }
+
+    @Test
+    public void testUpdateCandidates_validScorer() {
+        ComponentName scorer = new ComponentName(TEST_SCORER_PACKAGE_1, TEST_SCORER_CLASS_1);
+        NetworkScorerAppData scorerAppData = new NetworkScorerAppData(
+                0, scorer, TEST_SCORER_LABEL_1, null /* enableUseOpenWifiActivity */);
+        when(mNetworkScoreManager.getAllValidScorers()).thenReturn(
+                Lists.newArrayList(scorerAppData));
+        when(mNetworkScoreManager.getActiveScorerPackage()).thenReturn(TEST_SCORER_PACKAGE_1);
+        ArgumentCaptor<RadioButtonPreference> arg =
+                ArgumentCaptor.forClass(RadioButtonPreference.class);
+
+        mFragment.updateCandidates();
+
+        verify(mPreferenceScreen).addPreference(arg.capture());
+        RadioButtonPreference pref = arg.getValue();
+        assertThat(pref.getTitle()).isEqualTo(TEST_SCORER_LABEL_1);
+        assertThat(pref.isChecked()).isTrue();
+    }
+
+    public static class TestFragment extends NetworkScorerPicker {
+
+        private final Context mContext;
+        private final PreferenceScreen mScreen;
+        private final PreferenceManager mPrefManager;
+        private final NetworkScoreManagerWrapper mNetworkScoreManagerWrapper;
+
+        public TestFragment(Context context, PreferenceScreen preferenceScreen,
+                NetworkScoreManagerWrapper networkScoreManagerWrapper) {
+            mContext = context;
+            mScreen = preferenceScreen;
+            mNetworkScoreManagerWrapper = networkScoreManagerWrapper;
+            mPrefManager = mock(PreferenceManager.class);
+            when(mPrefManager.getContext()).thenReturn(context);
+        }
+
+        @Override
+        public Context getContext() {
+            return mContext;
+        }
+
+        @Override
+        public PreferenceManager getPreferenceManager() {
+            return mPrefManager;
+        }
+
+        @Override
+        public PreferenceScreen getPreferenceScreen() {
+            return mScreen;
+        }
+
+        @Override
+        NetworkScoreManagerWrapper createNetworkScorerManagerWrapper(Context context) {
+            return mNetworkScoreManagerWrapper;
+        }
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/search2/CursorToSearchResultConverterTest.java b/tests/robotests/src/com/android/settings/search2/CursorToSearchResultConverterTest.java
index 6f326ab..ab55605 100644
--- a/tests/robotests/src/com/android/settings/search2/CursorToSearchResultConverterTest.java
+++ b/tests/robotests/src/com/android/settings/search2/CursorToSearchResultConverterTest.java
@@ -24,6 +24,7 @@
 import android.graphics.drawable.Drawable;
 import android.util.ArrayMap;
 
+import com.android.settings.DisplaySettings;
 import com.android.settings.R;
 import com.android.settings.SettingsRobolectricTestRunner;
 import com.android.settings.SubSettings;
@@ -32,6 +33,7 @@
 import com.android.settings.gestures.SwipeToNotificationSettings;
 import com.android.settings.search2.ResultPayload.PayloadType;
 
+import com.android.settings.wifi.WifiSettings;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -147,6 +149,29 @@
     }
 
     @Test
+    public void testLongTitle_PenalizedInRank() {
+        MatrixCursor cursor = new MatrixCursor(DatabaseResultLoader.SELECT_COLUMNS);
+        final String BLANK = "";
+        cursor.addRow(new Object[]{
+                ID,      // Doc ID
+                "Longer than 20 characters", // Title
+                SUMMARY, // Summary on
+                SUMMARY, // summary off
+                DisplaySettings.class.getName(),
+                BLANK,   // screen title
+                null,    // icon
+                BLANK,   // action
+                null,    // target package
+                BLANK,   // target class
+                BLANK,   // Key
+                0,       // Payload Type
+                null     // Payload
+        });
+        List<SearchResult> results = mConverter.convertCursor(mSiteMapManager, cursor, BASE_RANK);
+        assertThat(results.get(0).rank).isEqualTo(BASE_RANK + 2);
+    }
+
+    @Test
     public void testParseCursor_MatchesIntentForSubSettings() {
         MatrixCursor cursor = new MatrixCursor(DatabaseResultLoader.SELECT_COLUMNS);
         final String BLANK = "";
@@ -246,6 +271,245 @@
         assertThat(newPayload.valueMap.get(0)).isFalse();
     }
 
+    // The following tests are temporary, and should be removed when we replace the Search
+    // White-list solution for elevating ranking.
+
+    @Test
+    public void testWifiKey_PrioritizedResult() {
+        MatrixCursor cursor = new MatrixCursor(DatabaseResultLoader.SELECT_COLUMNS);
+        final String BLANK = "";
+        final String key = "main_toggle_wifi";
+
+        cursor.addRow(new Object[]{
+                ID,      // Doc ID
+                TITLES[0], // Title
+                SUMMARY, // Summary on
+                SUMMARY, // summary off
+                WifiSettings.class.getName(),   // ClassName
+                BLANK,   // screen title
+                null,    // icon
+                BLANK,   // action
+                null,    // target package
+                BLANK,   // target class
+                key,     // Key
+                0,   // Payload Type
+                null     // Payload
+        });
+        List<SearchResult> results = mConverter.convertCursor(mSiteMapManager, cursor, BASE_RANK);
+
+        assertThat(results.get(0).rank).isEqualTo(SearchResult.TOP_RANK);
+    }
+
+    @Test
+    public void testBluetoothKey_PrioritizedResult() {
+        MatrixCursor cursor = new MatrixCursor(DatabaseResultLoader.SELECT_COLUMNS);
+        final String BLANK = "";
+        final String key = "main_toggle_bluetooth";
+
+        cursor.addRow(new Object[]{
+                ID,      // Doc ID
+                TITLES[0], // Title
+                SUMMARY, // Summary on
+                SUMMARY, // summary off
+                WifiSettings.class.getName(),   // ClassName
+                BLANK,   // screen title
+                null,    // icon
+                BLANK,   // action
+                null,    // target package
+                BLANK,   // target class
+                key,     // Key
+                0,   // Payload Type
+                null     // Payload
+        });
+        List<SearchResult> results = mConverter.convertCursor(mSiteMapManager, cursor, BASE_RANK);
+
+        assertThat(results.get(0).rank).isEqualTo(SearchResult.TOP_RANK);
+    }
+
+    @Test
+    public void testAirplaneKey_PrioritizedResult() {
+        MatrixCursor cursor = new MatrixCursor(DatabaseResultLoader.SELECT_COLUMNS);
+        final String BLANK = "";
+        final String key = "toggle_airplane";
+
+        cursor.addRow(new Object[]{
+                ID,      // Doc ID
+                TITLES[0], // Title
+                SUMMARY, // Summary on
+                SUMMARY, // summary off
+                WifiSettings.class.getName(),   // ClassName
+                BLANK,   // screen title
+                null,    // icon
+                BLANK,   // action
+                null,    // target package
+                BLANK,   // target class
+                key,     // Key
+                0,   // Payload Type
+                null     // Payload
+        });
+        List<SearchResult> results = mConverter.convertCursor(mSiteMapManager, cursor, BASE_RANK);
+
+        assertThat(results.get(0).rank).isEqualTo(SearchResult.TOP_RANK);
+    }
+
+    @Test
+    public void testHotspotKey_PrioritizedResult() {
+        MatrixCursor cursor = new MatrixCursor(DatabaseResultLoader.SELECT_COLUMNS);
+        final String BLANK = "";
+        final String key = "tether_settings";
+
+        cursor.addRow(new Object[]{
+                ID,      // Doc ID
+                TITLES[0], // Title
+                SUMMARY, // Summary on
+                SUMMARY, // summary off
+                WifiSettings.class.getName(),   // ClassName
+                BLANK,   // screen title
+                null,    // icon
+                BLANK,   // action
+                null,    // target package
+                BLANK,   // target class
+                key,     // Key
+                0,   // Payload Type
+                null     // Payload
+        });
+        List<SearchResult> results = mConverter.convertCursor(mSiteMapManager, cursor, BASE_RANK);
+
+        assertThat(results.get(0).rank).isEqualTo(SearchResult.TOP_RANK);
+    }
+
+    @Test
+    public void testBatterySaverKey_PrioritizedResult() {
+        MatrixCursor cursor = new MatrixCursor(DatabaseResultLoader.SELECT_COLUMNS);
+        final String BLANK = "";
+        final String key = "battery_saver";
+
+        cursor.addRow(new Object[]{
+                ID,      // Doc ID
+                TITLES[0], // Title
+                SUMMARY, // Summary on
+                SUMMARY, // summary off
+                WifiSettings.class.getName(),   // ClassName
+                BLANK,   // screen title
+                null,    // icon
+                BLANK,   // action
+                null,    // target package
+                BLANK,   // target class
+                key,     // Key
+                0,   // Payload Type
+                null     // Payload
+        });
+        List<SearchResult> results = mConverter.convertCursor(mSiteMapManager, cursor, BASE_RANK);
+
+        assertThat(results.get(0).rank).isEqualTo(SearchResult.TOP_RANK);
+    }
+
+    @Test
+    public void testNFCKey_PrioritizedResult() {
+        MatrixCursor cursor = new MatrixCursor(DatabaseResultLoader.SELECT_COLUMNS);
+        final String BLANK = "";
+        final String key = "toggle_nfc";
+
+        cursor.addRow(new Object[]{
+                ID,      // Doc ID
+                TITLES[0], // Title
+                SUMMARY, // Summary on
+                SUMMARY, // summary off
+                WifiSettings.class.getName(),   // ClassName
+                BLANK,   // screen title
+                null,    // icon
+                BLANK,   // action
+                null,    // target package
+                BLANK,   // target class
+                key,     // Key
+                0,   // Payload Type
+                null     // Payload
+        });
+        List<SearchResult> results = mConverter.convertCursor(mSiteMapManager, cursor, BASE_RANK);
+
+        assertThat(results.get(0).rank).isEqualTo(SearchResult.TOP_RANK);
+    }
+
+    @Test
+    public void testDataSaverKey_PrioritizedResult() {
+        MatrixCursor cursor = new MatrixCursor(DatabaseResultLoader.SELECT_COLUMNS);
+        final String BLANK = "";
+        final String key = "restrict_background";
+
+        cursor.addRow(new Object[]{
+                ID,      // Doc ID
+                TITLES[0], // Title
+                SUMMARY, // Summary on
+                SUMMARY, // summary off
+                WifiSettings.class.getName(),   // ClassName
+                BLANK,   // screen title
+                null,    // icon
+                BLANK,   // action
+                null,    // target package
+                BLANK,   // target class
+                key,     // Key
+                0,   // Payload Type
+                null     // Payload
+        });
+        List<SearchResult> results = mConverter.convertCursor(mSiteMapManager, cursor, BASE_RANK);
+
+        assertThat(results.get(0).rank).isEqualTo(SearchResult.TOP_RANK);
+    }
+
+    @Test
+    public void testDataUsageKey_PrioritizedResult() {
+        MatrixCursor cursor = new MatrixCursor(DatabaseResultLoader.SELECT_COLUMNS);
+        final String BLANK = "";
+        final String key = "data_usage_enable";
+
+        cursor.addRow(new Object[]{
+                ID,      // Doc ID
+                TITLES[0], // Title
+                SUMMARY, // Summary on
+                SUMMARY, // summary off
+                WifiSettings.class.getName(),   // ClassName
+                BLANK,   // screen title
+                null,    // icon
+                BLANK,   // action
+                null,    // target package
+                BLANK,   // target class
+                key,     // Key
+                0,   // Payload Type
+                null     // Payload
+        });
+        List<SearchResult> results = mConverter.convertCursor(mSiteMapManager, cursor, BASE_RANK);
+
+        assertThat(results.get(0).rank).isEqualTo(SearchResult.TOP_RANK);
+    }
+
+    @Test
+    public void testRoamingKey_PrioritizedResult() {
+        MatrixCursor cursor = new MatrixCursor(DatabaseResultLoader.SELECT_COLUMNS);
+        final String BLANK = "";
+        final String key = "button_roaming_key";
+
+        cursor.addRow(new Object[]{
+                ID,      // Doc ID
+                TITLES[0], // Title
+                SUMMARY, // Summary on
+                SUMMARY, // summary off
+                WifiSettings.class.getName(),   // ClassName
+                BLANK,   // screen title
+                null,    // icon
+                BLANK,   // action
+                null,    // target package
+                BLANK,   // target class
+                key,     // Key
+                0,   // Payload Type
+                null     // Payload
+        });
+        List<SearchResult> results = mConverter.convertCursor(mSiteMapManager, cursor, BASE_RANK);
+
+        assertThat(results.get(0).rank).isEqualTo(SearchResult.TOP_RANK);
+    }
+
+    // End of temporary tests
+
     private MatrixCursor getDummyCursor() {
         return getDummyCursor(true /* hasIcon */);
     }