Merge "Mark AccessibilitySettings#update methods as protected."
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index c526d6f..5e4f1e8 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -109,7 +109,7 @@
         <!-- Settings -->
 
         <activity android:name="Settings"
-                android:taskAffinity="com.android.settings"
+                android:taskAffinity="com.android.settings.root"
                 android:label="@string/settings_label_launcher"
                 android:launchMode="singleTask">
             <intent-filter android:priority="1">
@@ -122,7 +122,7 @@
 
         <!-- Alias for launcher activity only, as this belongs to each profile. -->
         <activity-alias android:name="Settings"
-                android:taskAffinity="com.android.settings"
+                android:taskAffinity="com.android.settings.root"
                 android:label="@string/settings_label_launcher"
                 android:launchMode="singleTask"
                 android:targetActivity="Settings">
@@ -143,8 +143,7 @@
 
         <activity android:name=".SubSettings"
                 android:taskAffinity="com.android.settings"
-                android:parentActivityName="Settings">
-        </activity>
+                android:parentActivityName="Settings" />
 
         <activity android:name=".shortcut.CreateShortcut"
                   android:label="@string/settings_shortcut">
@@ -155,11 +154,12 @@
         </activity>
 
         <!-- Wireless Controls -->
-        <activity android:name=".Settings$NetworkDashboardActivity"
-            android:taskAffinity="com.android.settings"
+        <activity
+            android:name=".Settings$NetworkDashboardActivity"
             android:label="@string/network_dashboard_title"
             android:icon="@drawable/ic_homepage_network"
-            android:parentActivityName="Settings">
+            android:parentActivityName="Settings"
+            android:taskAffinity="com.android.settings">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.WIRELESS_SETTINGS" />
                 <action android:name="android.settings.AIRPLANE_MODE_SETTINGS" />
@@ -181,15 +181,20 @@
                 android:value="true" />
         </activity>
 
-        <activity android:name=".Settings$ConnectedDeviceDashboardActivity"
-            android:taskAffinity="com.android.settings"
+        <activity
+            android:name=".Settings$ConnectedDeviceDashboardActivity"
             android:label="@string/connected_devices_dashboard_title"
             android:icon="@drawable/ic_homepage_connected_device"
+            android:taskAffinity="com.android.settings"
             android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.NFC_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
+            <intent-filter android:priority="1">
+                <action android:name="android.settings.BLUETOOTH_SETTINGS" />
+                <category android:name="android.intent.category.DEFAULT" />
+            </intent-filter>
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -206,12 +211,13 @@
                 android:value="true" />
         </activity>
 
-        <activity android:name=".Settings$ConnectedDeviceDashboardActivityOld"
-                  android:enabled="false"
-                  android:taskAffinity="com.android.settings"
-                  android:label="@string/connected_devices_dashboard_title"
-                  android:icon="@drawable/ic_homepage_connected_device"
-                  android:parentActivityName="Settings">
+        <activity
+            android:name=".Settings$ConnectedDeviceDashboardActivityOld"
+            android:enabled="false"
+            android:label="@string/connected_devices_dashboard_title"
+            android:icon="@drawable/ic_homepage_connected_device"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.NFC_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -253,13 +259,13 @@
             </intent-filter>
         </activity>
 
-        <!-- Top-level settings -->
-
-        <activity android:name="Settings$WifiSettingsActivity"
-                android:taskAffinity=""
-                android:label="@string/wifi_settings"
-                android:icon="@drawable/ic_settings_wireless"
-                android:configChanges="orientation|keyboardHidden|screenSize">
+        <activity
+            android:name="Settings$WifiSettingsActivity"
+            android:label="@string/wifi_settings"
+            android:icon="@drawable/ic_settings_wireless"
+            android:configChanges="orientation|keyboardHidden|screenSize"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.WIFI_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -278,21 +284,10 @@
                        android:value="content://com.android.settings.slices/wifi" />
         </activity>
 
-        <!-- Keep compatibility with old shortcuts. -->
-        <activity-alias android:name=".wifi.WifiSettings"
-                android:taskAffinity="com.android.settings"
-                android:label="@string/wifi_settings"
-                android:icon="@drawable/ic_settings_wireless"
-                android:targetActivity="Settings$WifiSettingsActivity"
-                android:configChanges="orientation|keyboardHidden|screenSize"
-                android:exported="true">
-            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
-                android:value="com.android.settings.wifi.WifiSettings" />
-        </activity-alias>
-
-        <activity android:name=".wifi.WifiPickerActivity"
-                android:taskAffinity="com.android.settings"
-                android:parentActivityName="Settings">
+        <activity
+            android:name=".wifi.WifiPickerActivity"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="android.net.wifi.PICK_WIFI_NETWORK" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -305,12 +300,13 @@
                 android:value="true" />
         </activity>
 
-        <activity android:name="Settings$ConfigureWifiSettingsActivity"
-                android:taskAffinity="com.android.settings"
-                android:label="@string/wifi_configure_settings_preference_title"
-                android:icon="@drawable/ic_settings_wireless"
-                android:configChanges="orientation|keyboardHidden|screenSize"
-                android:parentActivityName="Settings$WifiSettingsActivity">
+        <activity
+            android:name="Settings$ConfigureWifiSettingsActivity"
+            android:label="@string/wifi_configure_settings_preference_title"
+            android:icon="@drawable/ic_settings_wireless"
+            android:configChanges="orientation|keyboardHidden|screenSize"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.WIFI_IP_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -326,12 +322,13 @@
                 android:value="true" />
         </activity>
 
-        <activity android:name="Settings$SavedAccessPointsSettingsActivity"
-                android:taskAffinity="com.android.settings"
-                android:label="@string/wifi_saved_access_points_label"
-                android:icon="@drawable/ic_settings_wireless"
-                android:configChanges="orientation|keyboardHidden|screenSize"
-                android:parentActivityName="Settings$WifiSettingsActivity">
+        <activity
+            android:name="Settings$SavedAccessPointsSettingsActivity"
+            android:label="@string/wifi_saved_access_points_label"
+            android:icon="@drawable/ic_settings_wireless"
+            android:configChanges="orientation|keyboardHidden|screenSize"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.WIFI_SAVED_NETWORK_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -346,9 +343,7 @@
                 android:value="true" />
         </activity>
 
-        <activity android:name=".Settings$WifiInfoActivity"
-                android:taskAffinity="com.android.settings"
-                android:parentActivityName="Settings$WifiSettingsActivity">
+        <activity android:name=".Settings$WifiInfoActivity">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN"/>
                 <category android:name="android.intent.category.DEVELOPMENT_PREFERENCE" />
@@ -358,9 +353,7 @@
                        android:value="com.android.settings.wifi.WifiInfo" />
         </activity>
 
-        <activity android:name=".wifi.WifiConfigInfo"
-                android:taskAffinity="com.android.settings"
-                android:parentActivityName="Settings$WifiSettingsActivity">
+        <activity android:name=".wifi.WifiConfigInfo">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN"/>
                 <category android:name="android.intent.category.DEVELOPMENT_PREFERENCE" />
@@ -428,14 +421,13 @@
                        android:value="com.android.settings.ApnSettings" />
         </activity>
 
-        <activity android:name="Settings$BluetoothSettingsActivity"
-                android:label="@string/bluetooth_settings_title"
-                android:icon="@drawable/ic_settings_bluetooth"
-                android:taskAffinity="">
-            <intent-filter android:priority="1">
-                <action android:name="android.settings.BLUETOOTH_SETTINGS" />
-                <category android:name="android.intent.category.DEFAULT" />
-            </intent-filter>
+        <activity
+            android:name="Settings$BluetoothSettingsActivity"
+            android:label="@string/bluetooth_settings_title"
+            android:icon="@drawable/ic_settings_bluetooth"
+            android:enabled="false"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.VOICE_LAUNCH" />
@@ -446,10 +438,19 @@
                 android:value="com.android.settings.bluetooth.BluetoothSettings" />
         </activity>
 
+        <!-- Keep compatibility with old shortcuts. -->
+        <activity-alias android:name=".bluetooth.BluetoothSettings"
+                        android:label="@string/bluetooth_settings_title"
+                        android:targetActivity="Settings$BluetoothSettingsActivity"
+                        android:exported="true"
+                        android:clearTaskOnLaunch="true">
+            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
+                       android:value="com.android.settings.bluetooth.BluetoothSettings" />
+        </activity-alias>
+
         <activity android:name="Settings$AssistGestureSettingsActivity"
             android:label="@string/assist_gesture_title"
-            android:icon="@drawable/ic_settings_gestures"
-            android:taskAffinity="">
+            android:icon="@drawable/ic_settings_gestures">
             <intent-filter>
                 <action android:name="android.settings.ASSIST_GESTURE_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -458,18 +459,9 @@
                 android:value="com.android.settings.gestures.AssistGestureSettings" />
         </activity>
 
-        <!-- Keep compatibility with old shortcuts. -->
-        <activity-alias android:name=".bluetooth.BluetoothSettings"
-                android:label="@string/bluetooth_settings_title"
-                android:targetActivity="Settings$BluetoothSettingsActivity"
-                android:exported="true"
-                android:clearTaskOnLaunch="true">
-            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
-                android:value="com.android.settings.bluetooth.BluetoothSettings" />
-        </activity-alias>
-
         <activity android:name=".bluetooth.DevicePickerActivity"
                 android:label="@string/device_picker"
+                android:configChanges="orientation|keyboardHidden|screenSize"
                 android:clearTaskOnLaunch="true">
             <intent-filter>
                 <action android:name="android.bluetooth.devicepicker.action.LAUNCH" />
@@ -492,10 +484,12 @@
             </intent-filter>
         </activity>
 
-        <activity android:name="Settings$TetherSettingsActivity"
-                android:label="@string/tether_settings_title_all"
-                android:icon="@drawable/ic_settings_wireless"
-                android:taskAffinity="">
+        <activity
+            android:name="Settings$TetherSettingsActivity"
+            android:label="@string/tether_settings_title_all"
+            android:icon="@drawable/ic_settings_wireless"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -517,8 +511,8 @@
         </activity-alias>
 
         <activity android:name="Settings$WifiP2pSettingsActivity"
-                android:taskAffinity="com.android.settings"
-                android:parentActivityName="Settings$WifiSettingsActivity">
+                  android:taskAffinity="com.android.settings"
+                  android:parentActivityName="Settings">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -528,11 +522,12 @@
                 android:value="com.android.settings.wifi.p2p.WifiP2pSettings" />
         </activity>
 
-
-        <activity android:name="Settings$VpnSettingsActivity"
-                android:label="@string/vpn_settings_title"
-                android:icon="@drawable/ic_settings_wireless"
-                android:taskAffinity="">
+        <activity
+            android:name="Settings$VpnSettingsActivity"
+            android:label="@string/vpn_settings_title"
+            android:icon="@drawable/ic_settings_wireless"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.VPN_SETTINGS" />
                 <action android:name="android.net.vpn.SETTINGS" />
@@ -550,10 +545,12 @@
                 android:value="true" />
         </activity>
 
-        <activity android:name="Settings$DateTimeSettingsActivity"
-                android:label="@string/date_and_time"
-                android:icon="@drawable/ic_settings_date_time"
-                android:taskAffinity="">
+        <activity
+            android:name="Settings$DateTimeSettingsActivity"
+            android:label="@string/date_and_time"
+            android:icon="@drawable/ic_settings_date_time"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.DATE_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -575,11 +572,12 @@
                 android:value="true" />
         </activity>
 
-        <activity android:name="Settings$LocalePickerActivity"
-                android:label="@string/language_picker_title"
-                android:icon="@drawable/ic_settings_language"
-                android:taskAffinity="com.android.settings"
-                android:parentActivityName="Settings$LanguageAndInputSettingsActivity">
+        <activity
+            android:name="Settings$LocalePickerActivity"
+            android:label="@string/language_picker_title"
+            android:icon="@drawable/ic_settings_language"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings$LanguageAndInputSettingsActivity">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.LOCALE_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -595,11 +593,12 @@
                 android:value="true" />
         </activity>
 
-        <activity android:name=".Settings$LanguageAndInputSettingsActivity"
+        <activity
+            android:name=".Settings$LanguageAndInputSettingsActivity"
             android:label="@string/language_settings"
             android:icon="@drawable/ic_settings_language"
             android:taskAffinity="com.android.settings"
-            android:parentActivityName="Settings$SystemDashboardActivity">
+            android:parentActivityName="Settings">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.VOICE_LAUNCH" />
@@ -628,10 +627,11 @@
                 android:value="true" />
         </activity>
 
-        <activity android:name="Settings$ManageAssistActivity"
-                android:label="@string/assist_and_voice_input_title"
-                android:taskAffinity="com.android.settings"
-                android:parentActivityName="Settings$ManageApplicationsActivity">
+        <activity
+            android:name="Settings$ManageAssistActivity"
+            android:label="@string/assist_and_voice_input_title"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.VOICE_INPUT_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -680,10 +680,11 @@
                 android:value="com.android.settings.language.LanguageAndInputSettings" />
         </activity-alias>
 
-        <activity android:name="Settings$SpellCheckersSettingsActivity"
-                android:label="@string/spellcheckers_settings_title"
-                android:taskAffinity="com.android.settings"
-                android:parentActivityName="Settings$LanguageAndInputSettingsActivity">
+        <activity
+            android:name="Settings$SpellCheckersSettingsActivity"
+            android:label="@string/spellcheckers_settings_title"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.VOICE_LAUNCH" />
@@ -709,10 +710,11 @@
                 android:value="true" />
         </activity>
 
-        <activity android:name="Settings$UserDictionarySettingsActivity"
-                android:label="@string/user_dict_settings_title"
-                android:taskAffinity="com.android.settings"
-                android:parentActivityName="Settings$LanguageAndInputSettingsActivity">
+        <activity
+            android:name="Settings$UserDictionarySettingsActivity"
+            android:label="@string/user_dict_settings_title"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.USER_DICTIONARY_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -751,11 +753,13 @@
                 android:value="com.android.settings.UserDictionarySettings" />
         </activity-alias>
 
-        <activity android:name="Settings$ZenModeSettingsActivity"
-                android:label="@string/zen_mode_settings_title"
-                android:icon="@drawable/ic_settings_notifications"
-                android:exported="true"
-                android:taskAffinity="">
+        <activity
+            android:name="Settings$ZenModeSettingsActivity"
+            android:label="@string/zen_mode_settings_title"
+            android:icon="@drawable/ic_settings_notifications"
+            android:exported="true"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.ZEN_MODE_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -771,11 +775,13 @@
                 android:value="true" />
         </activity>
 
-        <activity android:name="Settings$ZenModeBehaviorSettingsActivity"
-                android:label="@string/zen_mode_behavior_settings_title"
-                android:icon="@drawable/ic_settings_notifications"
-                android:exported="true"
-                android:taskAffinity="">
+        <activity
+            android:name="Settings$ZenModeBehaviorSettingsActivity"
+            android:label="@string/zen_mode_behavior_settings_title"
+            android:icon="@drawable/ic_settings_notifications"
+            android:exported="true"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.ZEN_MODE_PRIORITY_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -786,11 +792,13 @@
                 android:value="true" />
         </activity>
 
-        <activity android:name="Settings$ZenModeAutomationSettingsActivity"
-                  android:label="@string/zen_mode_automation_settings_title"
-                  android:icon="@drawable/ic_settings_notifications"
-                  android:exported="true"
-                  android:taskAffinity="">
+        <activity
+            android:name="Settings$ZenModeAutomationSettingsActivity"
+            android:label="@string/zen_mode_automation_settings_title"
+            android:icon="@drawable/ic_settings_notifications"
+            android:exported="true"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.ZEN_MODE_AUTOMATION_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -807,8 +815,7 @@
 
         <activity android:name="Settings$WallpaperSettingsActivity"
                   android:label="@string/wallpaper_settings_fragment_title"
-                  android:icon="@drawable/ic_wallpaper"
-                  android:taskAffinity="">
+                  android:icon="@drawable/ic_wallpaper">
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                        android:value="com.android.settings.wallpaper.WallpaperTypeSettings" />
         </activity>
@@ -850,9 +857,11 @@
                        android:resource="@string/new_device_suggestion_summary" />
         </activity>
 
-        <activity android:name="Settings$ZenModeScheduleRuleSettingsActivity"
-                android:exported="true"
-                android:taskAffinity="">
+        <activity
+            android:name="Settings$ZenModeScheduleRuleSettingsActivity"
+            android:exported="true"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.ZEN_MODE_SCHEDULE_RULE_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -867,9 +876,11 @@
                 android:value="true" />
         </activity>
 
-        <activity android:name="Settings$ZenModeEventRuleSettingsActivity"
-                android:exported="true"
-                android:taskAffinity="">
+        <activity
+            android:name="Settings$ZenModeEventRuleSettingsActivity"
+            android:exported="true"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.ZEN_MODE_EVENT_RULE_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -884,9 +895,11 @@
                 android:value="true" />
         </activity>
 
-        <activity android:name="Settings$ZenModeExternalRuleSettingsActivity"
-                android:exported="true"
-                android:taskAffinity="">
+        <activity
+            android:name="Settings$ZenModeExternalRuleSettingsActivity"
+            android:exported="true"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.ZEN_MODE_EXTERNAL_RULE_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -901,10 +914,12 @@
                 android:value="true" />
         </activity>
 
-        <activity android:name="Settings$DisplaySettingsActivity"
-                android:label="@string/display_settings"
-                android:icon="@drawable/ic_homepage_display"
-                android:taskAffinity="">
+        <activity
+            android:name="Settings$DisplaySettingsActivity"
+            android:label="@string/display_settings"
+            android:icon="@drawable/ic_homepage_display"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="com.android.settings.DISPLAY_SETTINGS" />
                 <action android:name="android.settings.DISPLAY_SETTINGS" />
@@ -938,11 +953,13 @@
                 android:value="com.android.settings.DisplaySettings" />
         </activity-alias>
 
-        <activity android:name="Settings$NightDisplaySettingsActivity"
-                android:label="@string/night_display_title"
-                android:enabled="@*android:bool/config_nightDisplayAvailable"
-                android:icon="@drawable/ic_settings_night_display"
-                android:taskAffinity="">
+        <activity
+            android:name="Settings$NightDisplaySettingsActivity"
+            android:label="@string/night_display_title"
+            android:enabled="@*android:bool/config_nightDisplayAvailable"
+            android:icon="@drawable/ic_settings_night_display"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -958,9 +975,9 @@
                 android:value="true" />
         </activity>
 
-        <activity android:name="Settings$NightDisplaySuggestionActivity"
+        <activity
+            android:name="Settings$NightDisplaySuggestionActivity"
             android:enabled="@*android:bool/config_nightDisplayAvailable"
-            android:taskAffinity=""
             android:icon="@drawable/ic_settings_night_display">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
@@ -978,11 +995,13 @@
                 android:value="com.android.settings.display.NightDisplaySettings" />
         </activity>
 
-        <activity android:name="Settings$DeviceInfoSettingsActivity"
-                android:label="@string/device_info_settings"
-                android:icon="@drawable/ic_settings_about"
-                android:taskAffinity="com.android.settings"
-                android:parentActivityName="Settings">
+        <activity
+            android:name="Settings$DeviceInfoSettingsActivity"
+            android:label="@string/device_info_settings"
+            android:icon="@drawable/ic_settings_about"
+            android:taskAffinity="com.android.settings"
+            android:enabled="false"
+            android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.DEVICE_INFO_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -1005,7 +1024,6 @@
                 android:value="true" />
         </activity>
 
-
         <activity android:name=".Settings$MyDeviceInfoActivity"
                   android:label="@string/device_info_settings"
                   android:icon="@drawable/ic_settings_about"
@@ -1034,10 +1052,12 @@
                        android:value="true" />
         </activity>
 
-        <activity android:name="SettingsLicenseActivity"
-                android:label="@string/settings_license_activity_title"
-                android:theme="@android:style/Theme.DeviceDefault.Light.Panel"
-                android:configChanges="orientation|screenSize">
+        <activity
+            android:name="SettingsLicenseActivity"
+            android:label="@string/settings_license_activity_title"
+            android:configChanges="orientation|screenSize"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.LICENSE" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -1046,9 +1066,11 @@
                 android:value="true" />
         </activity>
 
-        <activity android:name="Settings$ManageApplicationsActivity"
-                android:label="@string/applications_settings"
-                android:taskAffinity="">
+        <activity
+            android:name="Settings$ManageApplicationsActivity"
+            android:label="@string/applications_settings"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.APPLICATION_SETTINGS" />
                 <action android:name="android.settings.MANAGE_APPLICATIONS_SETTINGS" />
@@ -1067,10 +1089,20 @@
                 android:value="true" />
         </activity>
 
-        <activity android:name="Settings$ManageDomainUrlsActivity"
-                  android:taskAffinity="com.android.settings"
-                  android:label="@string/domain_urls_title"
-                  android:icon="@drawable/ic_settings_memory">
+        <!-- Keep compatibility with old shortcuts. -->
+        <activity-alias android:name=".applications.ManageApplications"
+                        android:label="@string/applications_settings"
+                        android:exported="true"
+                        android:targetActivity="Settings$ManageApplicationsActivity">
+            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
+                       android:value="com.android.settings.applications.manageapplications.ManageApplications" />
+        </activity-alias>
+
+        <activity
+            android:name="Settings$ManageDomainUrlsActivity"
+            android:label="@string/domain_urls_title"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter>
                 <action android:name="android.settings.MANAGE_DOMAIN_URLS" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -1081,8 +1113,7 @@
 
         <activity android:name="Settings$MemorySettingsActivity"
                 android:label="@string/memory_settings_title"
-                android:icon="@drawable/ic_settings_memory"
-                android:taskAffinity="">
+                android:icon="@drawable/ic_settings_memory">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="com.android.settings.SHORTCUT" />
@@ -1102,9 +1133,11 @@
                        android:value="com.android.settings.applications.ProcessStatsUi" />
         </activity>
 
-        <activity android:name="Settings$HighPowerApplicationsActivity"
-                android:label="@string/high_power_apps"
-                android:taskAffinity="">
+        <activity
+            android:name="Settings$HighPowerApplicationsActivity"
+            android:label="@string/high_power_apps"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -1115,9 +1148,9 @@
                 android:value="true" />
         </activity>
 
-        <activity android:name=".datausage.AppDataUsageActivity"
-                android:taskAffinity=""
-                android:noHistory="true">
+        <activity
+            android:name=".datausage.AppDataUsageActivity"
+            android:noHistory="true">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -1125,10 +1158,10 @@
             </intent-filter>
         </activity>
 
-        <activity android:name=".fuelgauge.RequestIgnoreBatteryOptimizations"
-                android:label="@string/high_power_apps"
-                android:taskAffinity=""
-                android:theme="@*android:style/Theme.DeviceDefault.Light.Dialog.Alert">
+        <activity
+            android:name=".fuelgauge.RequestIgnoreBatteryOptimizations"
+            android:label="@string/high_power_apps"
+            android:theme="@*android:style/Theme.DeviceDefault.Light.Dialog.Alert">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -1136,15 +1169,6 @@
             </intent-filter>
         </activity>
 
-        <!-- Keep compatibility with old shortcuts. -->
-        <activity-alias android:name=".applications.ManageApplications"
-                android:label="@string/applications_settings"
-                android:exported="true"
-                android:targetActivity="Settings$ManageApplicationsActivity">
-            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
-                android:value="com.android.settings.applications.manageapplications.ManageApplications" />
-        </activity-alias>
-
         <!-- Provide direct entry into manage apps showing running services.
              This is for compatibility with old shortcuts. -->
         <activity-alias android:name=".RunningServices"
@@ -1170,10 +1194,7 @@
              InstalledAppDetails. -->
         <activity android:name=".applications.InstalledAppDetailsTop"
                   android:label="@string/application_info_label"
-                  android:exported="true"
-                  android:taskAffinity=""
-                  android:parentActivityName="Settings$ManageApplicationsActivity">
-        </activity>
+                  android:exported="true" />
 
         <!-- Keep compatibility with old shortcuts. -->
         <activity-alias android:name=".applications.InstalledAppDetails"
@@ -1205,10 +1226,11 @@
         </activity>
 
         <!-- Provide direct entry into manage apps showing storage usage of apps. -->
-        <activity android:name="Settings$StorageUseActivity"
-                android:label="@string/storageuse_settings_title"
-                android:taskAffinity=""
-                android:parentActivityName="Settings">
+        <activity
+            android:name="Settings$StorageUseActivity"
+            android:label="@string/storageuse_settings_title"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="android.intent.action.MANAGE_PACKAGE_STORAGE" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -1225,9 +1247,11 @@
                 android:value="true" />
         </activity>
 
-        <activity android:name="Settings$NotificationStationActivity"
-                android:label="@string/notification_log_title"
-                android:taskAffinity="">
+        <activity
+            android:name="Settings$NotificationStationActivity"
+            android:label="@string/notification_log_title"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -1249,7 +1273,6 @@
 
         <activity android:name="Settings$BackgroundCheckSummaryActivity"
                 android:label="@string/background_check_title"
-                android:taskAffinity=""
                 android:enabled="false">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
@@ -1259,11 +1282,13 @@
                 android:value="com.android.settings.applications.BackgroundCheckSummary" />
         </activity>
 
-        <activity android:name="Settings$LocationSettingsActivity"
-                android:label="@string/location_settings_title"
-                android:icon="@drawable/ic_settings_location"
-                android:configChanges="orientation|keyboardHidden|screenSize"
-                android:taskAffinity="">
+        <activity
+            android:name="Settings$LocationSettingsActivity"
+            android:label="@string/location_settings_title"
+            android:icon="@drawable/ic_settings_location"
+            android:configChanges="orientation|keyboardHidden|screenSize"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.LOCATION_SOURCE_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -1280,12 +1305,13 @@
                 android:value="true" />
         </activity>
 
-        <activity android:name=".Settings$SecurityDashboardActivity"
-                android:label="@string/security_settings_title"
-                android:icon="@drawable/ic_homepage_security"
-                android:configChanges="orientation|keyboardHidden|screenSize"
-                android:taskAffinity=""
-                android:parentActivityName="Settings">
+        <activity
+            android:name=".Settings$SecurityDashboardActivity"
+            android:label="@string/security_settings_title"
+            android:icon="@drawable/ic_homepage_security"
+            android:configChanges="orientation|keyboardHidden|screenSize"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.SECURITY_SETTINGS" />
                 <action android:name="android.credentials.UNLOCK" />
@@ -1322,10 +1348,12 @@
             </intent-filter>
         </activity>
 
-        <activity android:name="Settings$TrustedCredentialsSettingsActivity"
-                android:label="@string/trusted_credentials"
-                android:icon="@drawable/ic_settings_security"
-                android:taskAffinity="">
+        <activity
+            android:name="Settings$TrustedCredentialsSettingsActivity"
+            android:label="@string/trusted_credentials"
+            android:icon="@drawable/ic_settings_security"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="com.android.settings.TRUSTED_CREDENTIALS" />
                 <action android:name="com.android.settings.TRUSTED_CREDENTIALS_USER" />
@@ -1356,8 +1384,7 @@
 
         <activity android:name="SetFullBackupPassword"
                   android:label="@string/local_backup_password_title"
-                android:exported="false">
-        </activity>
+                  android:exported="false" />
 
         <activity android:name="CredentialStorage"
                 android:theme="@style/Transparent"
@@ -1371,10 +1398,11 @@
             </intent-filter>
         </activity>
 
-        <activity android:name="Settings$DeviceAdminSettingsActivity"
-                android:label="@string/device_admin_settings_title"
-                android:taskAffinity="com.android.settings"
-                android:parentActivityName=".Settings$SecurityDashboardActivity">
+        <activity
+            android:name="Settings$DeviceAdminSettingsActivity"
+            android:label="@string/device_admin_settings_title"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -1402,10 +1430,20 @@
             </intent-filter>
         </activity>
 
-        <activity android:name="Settings$UsageAccessSettingsActivity"
-                android:label="@string/usage_access_title"
-                android:taskAffinity="com.android.settings"
-                android:parentActivityName=".Settings$SecurityDashboardActivity">
+        <activity-alias android:name="SetProfileOwner"
+                        android:label="@string/profile_owner_add_title"
+                        android:targetActivity="DeviceAdminAdd">
+            <intent-filter android:priority="1000">
+                <action android:name="android.app.action.SET_PROFILE_OWNER" />
+                <category android:name="android.intent.category.DEFAULT" />
+            </intent-filter>
+        </activity-alias>
+
+        <activity
+            android:name="Settings$UsageAccessSettingsActivity"
+            android:label="@string/usage_access_title"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.USAGE_ACCESS_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -1418,15 +1456,6 @@
                 android:value="com.android.settings.applications.manageapplications.ManageApplications" />
         </activity>
 
-        <activity-alias android:name="SetProfileOwner"
-                android:label="@string/profile_owner_add_title"
-                android:targetActivity="DeviceAdminAdd">
-            <intent-filter android:priority="1000">
-                <action android:name="android.app.action.SET_PROFILE_OWNER" />
-                <category android:name="android.intent.category.DEFAULT" />
-            </intent-filter>
-        </activity-alias>
-
         <activity android:name="Settings$IccLockSettingsActivity"
                 android:label="@string/sim_lock_settings"
                 android:process="com.android.phone">
@@ -1439,11 +1468,13 @@
                 android:value="com.android.settings.IccLockSettings" />
         </activity>
 
-        <activity android:name="Settings$AccessibilitySettingsActivity"
-                android:label="@string/accessibility_settings"
-                android:icon="@drawable/ic_homepage_accessibility"
-                android:configChanges="orientation|keyboardHidden|screenSize"
-                android:taskAffinity="">
+        <activity
+            android:name="Settings$AccessibilitySettingsActivity"
+            android:label="@string/accessibility_settings"
+            android:icon="@drawable/ic_homepage_accessibility"
+            android:configChanges="orientation|keyboardHidden|screenSize"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.ACCESSIBILITY_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -1490,10 +1521,11 @@
                 android:value="true" />
         </activity>
 
-        <activity android:name="Settings$AccessibilityDaltonizerSettingsActivity"
-                android:label="@string/accessibility_display_daltonizer_preference_title"
-                android:taskAffinity="com.android.settings"
-                android:parentActivityName="Settings$AccessibilitySettingsActivity">
+        <activity
+            android:name="Settings$AccessibilityDaltonizerSettingsActivity"
+            android:label="@string/accessibility_display_daltonizer_preference_title"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="com.android.settings.ACCESSIBILITY_COLOR_SPACE_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -1508,10 +1540,11 @@
                 android:value="true" />
         </activity>
 
-        <activity android:name="Settings$CaptioningSettingsActivity"
-                android:label="@string/accessibility_captioning_title"
-                android:taskAffinity="com.android.settings"
-                android:parentActivityName="Settings$AccessibilitySettingsActivity">
+        <activity
+            android:name="Settings$CaptioningSettingsActivity"
+            android:label="@string/accessibility_captioning_title"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.CAPTIONING_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -1526,10 +1559,11 @@
                 android:value="true" />
         </activity>
 
-        <activity android:name="Settings$TextToSpeechSettingsActivity"
-                android:label="@string/tts_settings"
-                android:taskAffinity="com.android.settings"
-                android:parentActivityName="Settings$LanguageAndInputSettingsActivity">
+        <activity
+            android:name="Settings$TextToSpeechSettingsActivity"
+            android:label="@string/tts_settings"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="com.android.settings.TTS_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -1540,10 +1574,11 @@
                 android:value="true" />
         </activity>
 
-        <activity android:name="Settings$EnterprisePrivacySettingsActivity"
-                android:label="@string/enterprise_privacy_settings"
-                android:taskAffinity="com.android.settings"
-                android:parentActivityName=".Settings$SecurityDashboardActivity">
+        <activity
+            android:name="Settings$EnterprisePrivacySettingsActivity"
+            android:label="@string/enterprise_privacy_settings"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter>
                 <action android:name="android.settings.ENTERPRISE_PRIVACY_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -1552,8 +1587,6 @@
                 android:value="com.android.settings.enterprise.EnterprisePrivacySettings" />
         </activity>
 
-        <!-- Second and third-level settings -->
-
         <!-- Lock screen settings -->
         <activity android:name=".password.ConfirmDeviceCredentialActivity"
             android:exported="true"
@@ -1769,11 +1802,12 @@
         <activity android:name=".EncryptionInterstitial"
             android:theme="@style/GlifTheme.Light" />
 
-        <activity android:name=".Settings$StorageDashboardActivity"
-                android:label="@string/storage_settings"
-                android:icon="@drawable/ic_homepage_storage"
-                android:taskAffinity="com.android.settings"
-                android:parentActivityName="Settings">
+        <activity
+            android:name=".Settings$StorageDashboardActivity"
+            android:label="@string/storage_settings"
+            android:icon="@drawable/ic_homepage_storage"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.INTERNAL_STORAGE_SETTINGS" />
                 <action android:name="android.settings.MEMORY_CARD_SETTINGS" />
@@ -1797,18 +1831,18 @@
                 android:value="true" />
         </activity>
 
-        <activity android:name="Settings$PrivateVolumeSettingsActivity"
-                android:label="@string/storage_settings_title"
-                android:taskAffinity="com.android.settings"
-                android:parentActivityName="Settings$StorageDashboardActivity">
+        <activity
+            android:name="Settings$PrivateVolumeSettingsActivity"
+            android:label="@string/storage_settings_title">
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
-                android:value="com.android.settings.deviceinfo.PrivateVolumeSettings" />
+                       android:value="com.android.settings.deviceinfo.PrivateVolumeSettings" />
         </activity>
 
-        <activity android:name="Settings$PublicVolumeSettingsActivity"
-                android:label="@string/storage_settings_title"
-                android:taskAffinity="com.android.settings"
-                android:parentActivityName="Settings$StorageDashboardActivity">
+        <activity
+            android:name="Settings$PublicVolumeSettingsActivity"
+            android:label="@string/storage_settings_title"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter>
                 <action android:name="android.provider.action.DOCUMENT_ROOT_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -1821,12 +1855,11 @@
                 android:value="com.android.settings.deviceinfo.PublicVolumeSettings" />
         </activity>
 
-        <activity android:name="Settings$PrivateVolumeForgetActivity"
-                android:label="@string/storage_settings_title"
-                android:taskAffinity="com.android.settings"
-                android:parentActivityName="Settings$StorageDashboardActivity"
-                android:exported="true"
-                android:permission="android.permission.MOUNT_UNMOUNT_FILESYSTEMS">
+        <activity
+            android:name="Settings$PrivateVolumeForgetActivity"
+            android:label="@string/storage_settings_title"
+            android:exported="true"
+            android:permission="android.permission.MOUNT_UNMOUNT_FILESYSTEMS">
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                 android:value="com.android.settings.deviceinfo.PrivateVolumeForget" />
         </activity>
@@ -1898,12 +1931,13 @@
                        android:value="com.android.settings.ApnEditor" />
         </activity>
 
-        <activity android:name="Settings$DevelopmentSettingsDashboardActivity"
-                  android:label="@string/development_settings_title"
-                  android:icon="@drawable/ic_settings_development"
-                  android:taskAffinity="com.android.settings"
-                  android:parentActivityName="Settings"
-                  android:enabled="false">
+        <activity
+            android:name="Settings$DevelopmentSettingsDashboardActivity"
+            android:label="@string/development_settings_title"
+            android:icon="@drawable/ic_settings_development"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings"
+            android:enabled="false">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.APPLICATION_DEVELOPMENT_SETTINGS" />
                 <action android:name="com.android.settings.APPLICATION_DEVELOPMENT_SETTINGS" />
@@ -1936,11 +1970,12 @@
             </intent-filter>
         </activity>
 
-        <activity android:name="Settings$PrintSettingsActivity"
-                android:label="@string/print_settings"
-                android:icon="@drawable/ic_settings_print"
-                android:taskAffinity="com.android.settings"
-                android:parentActivityName="Settings">
+        <activity
+            android:name="Settings$PrintSettingsActivity"
+            android:label="@string/print_settings"
+            android:icon="@drawable/ic_settings_print"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.ACTION_PRINT_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -1950,11 +1985,6 @@
                 <category android:name="android.intent.category.DEFAULT" />
                 <category android:name="android.intent.category.VOICE_LAUNCH" />
             </intent-filter>
-            <intent-filter android:priority="2">
-                <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.device" />
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                 android:value="com.android.settings.print.PrintSettingsFragment" />
         </activity>
@@ -1977,10 +2007,7 @@
                   android:theme="@android:style/Theme.DeviceDefault.Light.Dialog" />
 
         <activity android:name="Settings$WebViewAppPickerActivity"
-                  android:label="@string/select_webview_provider_dialog_title">
-        </activity>
-
-        <!-- Bluetooth stuff -->
+                  android:label="@string/select_webview_provider_dialog_title" />
 
         <activity android:name=".bluetooth.BluetoothPairingDialog"
                   android:excludeFromRecents="true"
@@ -2085,10 +2112,11 @@
         </activity>
 
         <!-- NFC settings -->
-        <activity android:name="Settings$AndroidBeamSettingsActivity"
-                android:label="@string/android_beam_settings_title"
-                android:taskAffinity="com.android.settings"
-                android:parentActivityName="Settings$ConnectedDeviceDashboardActivity">
+        <activity
+            android:name="Settings$AndroidBeamSettingsActivity"
+            android:label="@string/android_beam_settings_title"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.NFCSHARING_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -2103,10 +2131,12 @@
                 android:value="true" />
         </activity>
 
-        <activity android:name="Settings$WifiDisplaySettingsActivity"
-                android:label="@string/wifi_display_settings_title"
-                android:icon="@drawable/ic_cast_24dp"
-                android:taskAffinity="">
+        <activity
+            android:name="Settings$WifiDisplaySettingsActivity"
+            android:label="@string/wifi_display_settings_title"
+            android:icon="@drawable/ic_cast_24dp"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.CAST_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -2124,17 +2154,9 @@
                 android:value="com.android.settings.wfd.WifiDisplaySettings" />
         </activity>
 
-        <activity android:name="Display" android:label="@string/display_label"
-                android:configChanges="fontScale"
-                android:taskAffinity="com.android.settings"
-                android:parentActivityName="Settings">
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.DEVELOPMENT_PREFERENCE" />
-            </intent-filter>
-        </activity>
-
-        <activity android:name="RadioInfo" android:label="@string/phone_info_label"
+        <activity
+            android:name="RadioInfo"
+            android:label="@string/phone_info_label"
             android:process="com.android.phone">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
@@ -2190,7 +2212,8 @@
             </intent-filter>
         </activity>
 
-        <activity android:name="UsageStatsActivity" android:label="@string/usage_stats_label"
+        <activity android:name="UsageStatsActivity"
+                  android:label="@string/usage_stats_label"
                   android:taskAffinity="com.android.settings"
                   android:parentActivityName="Settings">
             <intent-filter>
@@ -2199,10 +2222,13 @@
             </intent-filter>
         </activity>
 
-        <activity android:name="Settings$PowerUsageSummaryActivity"
-                android:label="@string/power_usage_summary_title"
-                android:icon="@drawable/ic_homepage_battery"
-                android:enabled="false">
+        <activity
+            android:name="Settings$PowerUsageSummaryActivity"
+            android:label="@string/power_usage_summary_title"
+            android:icon="@drawable/ic_homepage_battery"
+            android:enabled="false"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="android.intent.action.POWER_USAGE_SUMMARY" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -2221,18 +2247,11 @@
                 android:value="com.android.settings.fuelgauge.PowerUsageSummary" />
         </activity>
 
-        <!-- Keep compatibility with old shortcuts. -->
-        <activity-alias android:name=".fuelgauge.PowerUsageSummary"
-                android:label="@string/power_usage_summary_title"
-                android:exported="true"
-                android:targetActivity="Settings$PowerUsageSummaryActivity">
-            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
-                android:value="com.android.settings.fuelgauge.PowerUsageSummary" />
-        </activity-alias>
-
         <activity android:name=".Settings$PowerUsageSummaryLegacyActivity"
                   android:label="@string/power_usage_summary_title"
-                  android:icon="@drawable/ic_homepage_battery">
+                  android:icon="@drawable/ic_homepage_battery"
+                  android:taskAffinity="com.android.settings"
+                  android:parentActivityName="Settings">
             <intent-filter>
                 <action android:name="android.intent.action.POWER_USAGE_SUMMARY" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -2246,10 +2265,12 @@
                        android:value="com.android.settings.fuelgauge.PowerUsageSummaryLegacy" />
         </activity>
 
-        <activity android:name="Settings$BatterySaverSettingsActivity"
-                android:label="@string/battery_saver"
-                android:icon="@drawable/ic_settings_battery"
-                android:taskAffinity="">
+        <activity
+            android:name="Settings$BatterySaverSettingsActivity"
+            android:label="@string/battery_saver"
+            android:icon="@drawable/ic_settings_battery"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.BATTERY_SAVER_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -2271,9 +2292,10 @@
             </intent-filter>
         </activity>
 
-        <activity android:name="Settings$AccountSyncSettingsActivity"
+        <activity
+            android:name="Settings$AccountSyncSettingsActivity"
             android:label="@string/account_sync_settings_title"
-            android:taskAffinity=""
+            android:taskAffinity="com.android.settings"
             android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.ACCOUNT_SYNC_SETTINGS" />
@@ -2288,9 +2310,10 @@
             <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
                 android:value="true" />
         </activity>
-        <activity android:name="Settings$ManagedProfileSettingsActivity"
+        <activity
+            android:name="Settings$ManagedProfileSettingsActivity"
             android:label="@string/managed_profile_settings_title"
-            android:taskAffinity=""
+            android:taskAffinity="com.android.settings"
             android:parentActivityName="Settings"
             android:permission="android.permission.MANAGE_USERS">
             <intent-filter android:priority="1">
@@ -2301,12 +2324,13 @@
                 android:value="com.android.settings.accounts.ManagedProfileSettings" />
         </activity>
 
-        <activity android:name="com.android.settings.accounts.AddAccountSettings"
+        <activity
+            android:name="com.android.settings.accounts.AddAccountSettings"
             android:theme="@android:style/Theme.Translucent.NoTitleBar"
             android:configChanges="orientation|keyboardHidden|screenSize"
             android:label="@string/header_add_an_account"
             android:taskAffinity="com.android.settings"
-            android:parentActivityName=".Settings$AccountDashboardActivity">
+            android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.ADD_ACCOUNT_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -2383,33 +2407,14 @@
                 android:value="com.android.settings.security.CryptKeeperSettings" />
         </activity>
 
-        <activity android:name="Settings$DataPlanUsageSummaryActivity"
-                android:label="@string/data_usage_summary_title"
-                android:icon="@drawable/ic_settings_data_usage"
-                android:taskAffinity="">
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.DEFAULT" />
-                <category android:name="com.android.settings.SHORTCUT" />
-            </intent-filter>
-            <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.wireless" />
-            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
-                    android:value="com.android.settings.datausage.DataPlanUsageSummary" />
-        </activity>
-
-        <activity android:name="Settings$DataUsageSummaryActivity"
-                android:label="@string/data_usage_summary_title"
-                android:icon="@drawable/ic_settings_data_usage"
-                android:taskAffinity="">
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.DEFAULT" />
-                <category android:name="com.android.settings.SHORTCUT" />
-            </intent-filter>
+        <activity
+            android:name="Settings$DataUsageSummaryActivity"
+            android:label="@string/data_usage_summary_title"
+            android:icon="@drawable/ic_settings_data_usage"
+            android:enabled="false"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
+            <!-- TODO(b/70950124): add shortcut intent-filter -->
             <intent-filter android:priority="10">
                 <action android:name="com.android.settings.action.SETTINGS" />
             </intent-filter>
@@ -2419,9 +2424,31 @@
                 android:value="com.android.settings.datausage.DataUsageSummary" />
         </activity>
 
-        <activity android:name="Settings$MobileDataUsageListActivity"
-                  android:label="@string/cellular_data_usage"
-                  android:taskAffinity="">
+        <activity
+            android:name="Settings$DataUsageSummaryLegacyActivity"
+            android:label="@string/data_usage_summary_title"
+            android:icon="@drawable/ic_settings_data_usage"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.DEFAULT" />
+                <category android:name="com.android.settings.SHORTCUT" />
+            </intent-filter>
+            <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.wireless" />
+            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
+                       android:value="com.android.settings.datausage.DataUsageSummaryLegacy" />
+        </activity>
+
+        <activity
+            android:name="Settings$MobileDataUsageListActivity"
+            android:label="@string/cellular_data_usage"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.MOBILE_DATA_USAGE" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -2430,10 +2457,12 @@
                        android:value="com.android.settings.datausage.DataUsageList" />
         </activity>
 
-        <activity android:name="Settings$DreamSettingsActivity"
-                android:label="@string/screensaver_settings_title"
-                android:icon="@drawable/ic_settings_display"
-                android:taskAffinity="">
+        <activity
+            android:name="Settings$DreamSettingsActivity"
+            android:label="@string/screensaver_settings_title"
+            android:icon="@drawable/ic_settings_display"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.DREAM_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -2449,10 +2478,12 @@
                 android:value="true" />
         </activity>
 
-        <activity android:name="Settings$UserSettingsActivity"
-                android:label="@string/user_settings_title"
-                android:icon="@drawable/ic_settings_multiuser"
-                android:taskAffinity="">
+        <activity
+            android:name="Settings$UserSettingsActivity"
+            android:label="@string/user_settings_title"
+            android:icon="@drawable/ic_settings_multiuser"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.USER_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -2472,10 +2503,12 @@
                 android:value="true" />
         </activity>
 
-        <activity android:name="Settings$PaymentSettingsActivity"
-                android:label="@string/nfc_payment_settings_title"
-                android:icon="@drawable/ic_settings_nfc_payment"
-                android:taskAffinity="">
+        <activity
+            android:name="Settings$PaymentSettingsActivity"
+            android:label="@string/nfc_payment_settings_title"
+            android:icon="@drawable/ic_settings_nfc_payment"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.NFC_PAYMENT_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -2504,7 +2537,7 @@
 
         <activity android:name=".nfc.HowItWorks"
                   android:label="@string/nfc_payment_settings_title"
-                  android:parentActivityName="Settings$PaymentSettingsActivity">
+                  android:parentActivityName="Settings$PaymentSettingsActivity"
                   android:excludeFromRecents="true">
         </activity>
 
@@ -2518,9 +2551,11 @@
             </intent-filter>
         </activity>
 
-        <activity android:name="Settings$NotificationAccessSettingsActivity"
-                  android:label="@string/manage_notification_access_title"
-                  android:taskAffinity="">
+        <activity
+            android:name="Settings$NotificationAccessSettingsActivity"
+            android:label="@string/manage_notification_access_title"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -2533,9 +2568,11 @@
                        android:value="com.android.settings.notification.NotificationAccessSettings" />
         </activity>
 
-        <activity android:name="Settings$VrListenersSettingsActivity"
-                  android:label="@string/vr_listeners_title"
-                  android:taskAffinity="">
+        <activity
+            android:name="Settings$VrListenersSettingsActivity"
+            android:label="@string/vr_listeners_title"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.VR_LISTENER_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -2548,9 +2585,11 @@
                        android:value="com.android.settings.applications.VrListenerSettings" />
         </activity>
 
-        <activity android:name="Settings$PictureInPictureSettingsActivity"
+        <activity
+            android:name="Settings$PictureInPictureSettingsActivity"
             android:label="@string/picture_in_picture_title"
-            android:taskAffinity="">
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.PICTURE_IN_PICTURE_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -2563,9 +2602,11 @@
                 android:value="com.android.settings.applications.appinfo.PictureInPictureSettings" />
         </activity>
 
-        <activity android:name="Settings$AppPictureInPictureSettingsActivity"
+        <activity
+            android:name="Settings$AppPictureInPictureSettingsActivity"
             android:label="@string/picture_in_picture_title"
-            android:taskAffinity="">
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter>
                 <action android:name="android.settings.PICTURE_IN_PICTURE_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -2575,9 +2616,11 @@
                 android:value="com.android.settings.applications.appinfo.PictureInPictureDetails" />
         </activity>
 
-        <activity android:name="Settings$ZenAccessSettingsActivity"
-                  android:label="@string/manage_zen_access_title"
-                  android:taskAffinity="">
+        <activity
+            android:name="Settings$ZenAccessSettingsActivity"
+            android:label="@string/manage_zen_access_title"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.NOTIFICATION_POLICY_ACCESS_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -2590,10 +2633,12 @@
                        android:value="com.android.settings.notification.ZenAccessSettings" />
         </activity>
 
-        <activity android:name="Settings$ConfigureNotificationSettingsActivity"
-                android:label="@string/configure_notification_settings"
-                android:exported="true"
-                android:taskAffinity="">
+        <activity
+            android:name="Settings$ConfigureNotificationSettingsActivity"
+            android:label="@string/configure_notification_settings"
+            android:exported="true"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.NOTIFICATION_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -2615,11 +2660,13 @@
         </activity>
 
         <!-- Keep compatibility with old shortcuts. -->
-        <activity android:name="Settings$SoundSettingsActivity"
-                android:label="@string/sound_settings"
-                android:icon="@drawable/ic_homepage_sound"
-                android:taskAffinity=""
-                android:exported="true">
+        <activity
+            android:name="Settings$SoundSettingsActivity"
+            android:label="@string/sound_settings"
+            android:icon="@drawable/ic_homepage_sound"
+            android:exported="true"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="com.android.settings.SOUND_SETTINGS" />
                 <action android:name="android.settings.SOUND_SETTINGS" />
@@ -2645,15 +2692,6 @@
                 android:resource="@string/sound_dashboard_summary"/>
         </activity>
 
-        <!-- Keep compatibility with old shortcuts. -->
-        <activity-alias android:name="SoundSettings"
-                android:label="@string/sound_settings"
-                android:exported="true"
-                android:targetActivity="Settings$SoundSettingsActivity">
-            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
-                android:value="com.android.settings.notification.SoundSettings" />
-        </activity-alias>
-
         <!-- Show application-level notification settings (app passed in as extras) -->
         <activity android:name="Settings$AppNotificationSettingsActivity"
                 android:exported="true">
@@ -2680,7 +2718,6 @@
                        android:value="com.android.settings.notification.ChannelGroupNotificationSettings" />
         </activity>
 
-
         <!-- Show channel-level notification settings (channel passed in as extras) -->
         <activity android:name="Settings$ChannelNotificationSettingsActivity"
                   android:exported="true">
@@ -2697,10 +2734,12 @@
         </activity>
 
         <!-- Show Manual (from settings item) -->
-        <activity android:name="ManualDisplayActivity"
-                  android:label="@string/manual"
-                  android:taskAffinity=""
-                  android:enabled="@bool/config_show_manual">
+        <activity
+            android:name="ManualDisplayActivity"
+            android:label="@string/manual"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings"
+            android:enabled="@bool/config_show_manual">
             <intent-filter>
                 <action android:name="android.settings.SHOW_MANUAL" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -2710,10 +2749,12 @@
         </activity>
 
         <!-- Show regulatory info (from settings item or dialing "*#07#") -->
-        <activity android:name="RegulatoryInfoDisplayActivity"
-                  android:label="@string/regulatory_labels"
-                  android:taskAffinity=""
-                  android:enabled="@bool/config_show_regulatory_info">
+        <activity
+            android:name="RegulatoryInfoDisplayActivity"
+            android:label="@string/regulatory_labels"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings"
+            android:enabled="@bool/config_show_regulatory_info">
             <intent-filter>
                 <action android:name="android.settings.SHOW_REGULATORY_INFO" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -2772,10 +2813,12 @@
                 android:resource="@xml/file_paths" />
         </provider>
 
-        <activity android:name="Settings$SimSettingsActivity"
-                android:label="@string/sim_settings_title"
-                android:icon="@drawable/ic_settings_sim"
-                android:taskAffinity="">
+        <activity
+            android:name="Settings$SimSettingsActivity"
+            android:label="@string/sim_settings_title"
+            android:icon="@drawable/ic_settings_sim"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="com.android.settings.sim.SIM_SUB_INFO_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -2797,11 +2840,11 @@
 
         <activity android:name=".sim.SimPreferenceDialog"
             android:theme="@*android:style/Theme.DeviceDefault.Settings.Dialog.NoActionBar"
-            android:excludeFromRecents="true">
-        </activity>
+            android:excludeFromRecents="true" />
 
-        <activity android:name=".wifi.RequestToggleWiFiActivity"
-                  android:theme="@android:style/Theme.DeviceDefault.Light.Dialog.Alert"
+        <activity
+            android:name=".wifi.RequestToggleWiFiActivity"
+            android:theme="@android:style/Theme.DeviceDefault.Light.Dialog.Alert"
             android:excludeFromRecents="true"
             android:permission="android.permission.CHANGE_WIFI_STATE">
             <intent-filter>
@@ -2811,7 +2854,8 @@
             </intent-filter>
         </activity>
 
-        <activity android:name=".wifi.WifiDialogActivity"
+        <activity
+            android:name=".wifi.WifiDialogActivity"
             android:label=""
             android:theme="@style/Transparent"
             android:excludeFromRecents="true"
@@ -2833,9 +2877,11 @@
             </intent-filter>
         </activity>
 
-        <activity android:name="Settings$WifiCallingSettingsActivity"
-                  android:label="@string/wifi_calling_settings_title"
-                  android:taskAffinity="">
+        <activity
+            android:name="Settings$WifiCallingSettingsActivity"
+            android:label="@string/wifi_calling_settings_title"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <action android:name="android.settings.WIFI_CALLING_SETTINGS" />
@@ -2843,21 +2889,20 @@
                 <category android:name="android.intent.category.VOICE_LAUNCH" />
             </intent-filter>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
-                       android:value="com.android.settings.WifiCallingSettings" />
+                       android:value="com.android.settings.wifi.calling.WifiCallingSettings" />
             <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
                        android:value="true" />
         </activity>
 
-        <activity android:name=".wifi.WifiCallingSuggestionActivity"
+        <activity android:name=".wifi.calling.WifiCallingSuggestionActivity"
                   android:label="@string/wifi_calling_settings_title"
-                  android:icon="@drawable/ic_settings_wireless"
-                  android:taskAffinity="">
+                  android:icon="@drawable/ic_settings_wireless">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="com.android.settings.suggested.category.FIRST_IMPRESSION" />
             </intent-filter>
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
-                       android:value="com.android.settings.WifiCallingSettings" />
+                       android:value="com.android.settings.wifi.calling.WifiCallingSettings" />
             <meta-data android:name="com.android.settings.dismiss"
                 android:value="10,14,30" />
             <meta-data android:name="com.android.settings.title"
@@ -2887,9 +2932,11 @@
             </intent-filter>
         </provider>
 
-        <activity android:name="Settings$OverlaySettingsActivity"
-                android:label="@string/draw_overlay"
-                android:taskAffinity="">
+        <activity
+            android:name="Settings$OverlaySettingsActivity"
+            android:label="@string/draw_overlay"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.action.MANAGE_OVERLAY_PERMISSION" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -2898,9 +2945,11 @@
                 android:value="com.android.settings.applications.manageapplications.ManageApplications" />
         </activity>
 
-        <activity android:name="Settings$AppDrawOverlaySettingsActivity"
-                android:label="@string/draw_overlay"
-                android:taskAffinity="">
+        <activity
+            android:name="Settings$AppDrawOverlaySettingsActivity"
+            android:label="@string/draw_overlay"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.action.MANAGE_OVERLAY_PERMISSION" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -2910,9 +2959,11 @@
                 android:value="com.android.settings.applications.appinfo.DrawOverlayDetails" />
         </activity>
 
-        <activity android:name="Settings$WriteSettingsActivity"
-                android:label="@string/write_settings_title"
-                android:taskAffinity="">
+        <activity
+            android:name="Settings$WriteSettingsActivity"
+            android:label="@string/write_settings_title"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.action.MANAGE_WRITE_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -2921,10 +2972,11 @@
                 android:value="com.android.settings.applications.manageapplications.ManageApplications" />
         </activity>
 
-
-        <activity android:name="Settings$AppWriteSettingsActivity"
-                  android:label="@string/write_settings_title"
-                  android:taskAffinity="">
+        <activity
+            android:name="Settings$AppWriteSettingsActivity"
+            android:label="@string/write_settings_title"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.action.MANAGE_WRITE_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -2934,9 +2986,11 @@
                        android:value="com.android.settings.applications.appinfo.WriteSettingsDetails" />
         </activity>
 
-        <activity android:name="Settings$ManageExternalSourcesActivity"
-                android:label="@string/install_other_apps"
-                android:taskAffinity="">
+        <activity
+            android:name="Settings$ManageExternalSourcesActivity"
+            android:label="@string/install_other_apps"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.MANAGE_UNKNOWN_APP_SOURCES" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -2967,10 +3021,12 @@
             </intent-filter>
         </activity>
 
-        <activity android:name="Settings$AdvancedAppsActivity"
-                  android:taskAffinity=""
-                  android:exported="true"
-                  android:label="@string/app_default_dashboard_title">
+        <activity
+            android:name="Settings$AdvancedAppsActivity"
+            android:exported="true"
+            android:label="@string/app_default_dashboard_title"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.MANAGE_DEFAULT_APPS_SETTINGS" />
                 <action android:name="android.settings.HOME_SETTINGS" />
@@ -3026,10 +3082,12 @@
                        android:value="true" />
         </activity>
 
-        <activity android:name="Settings$AutomaticStorageManagerSettingsActivity"
-                  android:exported="@bool/config_storage_manager_settings_enabled"
-                  android:label="@string/automatic_storage_manager_settings"
-                  android:taskAffinity="">
+        <activity
+            android:name="Settings$AutomaticStorageManagerSettingsActivity"
+            android:exported="@bool/config_storage_manager_settings_enabled"
+            android:label="@string/automatic_storage_manager_settings"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.STORAGE_MANAGER_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -3037,12 +3095,13 @@
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                        android:value="com.android.settings.deletionhelper.AutomaticStorageManagerSettings" />
         </activity>
-        <!-- Information architecture host activities -->
 
-        <!-- 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_homepage_apps">
+        <activity
+            android:name=".Settings$AppAndNotificationDashboardActivity"
+            android:label="@string/app_and_notification_dashboard_title"
+            android:icon="@drawable/ic_homepage_apps"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter android:priority="9">
                 <action android:name="com.android.settings.action.SETTINGS"/>
             </intent-filter>
@@ -3054,9 +3113,12 @@
                        android:resource="@string/app_and_notification_dashboard_summary"/>
         </activity>
 
-        <activity android:name=".Settings$AccountDashboardActivity"
-                  android:label="@string/account_dashboard_title"
-                  android:icon="@drawable/ic_homepage_accounts">
+        <activity
+            android:name=".Settings$AccountDashboardActivity"
+            android:label="@string/account_dashboard_title"
+            android:icon="@drawable/ic_homepage_accounts"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter android:priority="3">
                 <action android:name="com.android.settings.action.SETTINGS"/>
             </intent-filter>
@@ -3070,9 +3132,12 @@
                        android:value="com.android.settings.category.ia.homepage"/>
         </activity>
 
-        <activity android:name=".Settings$SystemDashboardActivity"
-                  android:label="@string/header_category_system"
-                  android:icon="@drawable/ic_homepage_system_dashboard">
+        <activity
+            android:name=".Settings$SystemDashboardActivity"
+            android:label="@string/header_category_system"
+            android:icon="@drawable/ic_homepage_system_dashboard"
+            android:taskAffinity="com.android.settings"
+            android:parentActivityName="Settings">
             <intent-filter android:priority="-1">
                 <action android:name="com.android.settings.action.SETTINGS"/>
             </intent-filter>
@@ -3102,8 +3167,6 @@
                        android:resource="@string/support_summary"/>
         </activity>
 
-        <!-- End of information architecture host activities -->
-
         <service
             android:name=".SettingsDumpService"
             android:exported="true"
diff --git a/PREUPLOAD.cfg b/PREUPLOAD.cfg
index 62a2e43..8af69c7 100644
--- a/PREUPLOAD.cfg
+++ b/PREUPLOAD.cfg
@@ -1,5 +1,3 @@
 [Hook Scripts]
-checkstyle_hook = ${REPO_ROOT}/prebuilts/checkstyle/checkstyle.py --sha ${PREUPLOAD_COMMIT}
-                  -fw src/com/android/settings/print/
 checkcolor_hook = ${REPO_ROOT}/prebuilts/checkcolor/checkcolor.py -p .
 
diff --git a/res/drawable-hdpi/ic_wps_dark.png b/res/drawable-hdpi/ic_wps_dark.png
deleted file mode 100644
index 918b0cc..0000000
--- a/res/drawable-hdpi/ic_wps_dark.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_wps_light.png b/res/drawable-hdpi/ic_wps_light.png
deleted file mode 100644
index 5ad9f3e..0000000
--- a/res/drawable-hdpi/ic_wps_light.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_wps_dark.png b/res/drawable-mdpi/ic_wps_dark.png
deleted file mode 100644
index 77d73a8..0000000
--- a/res/drawable-mdpi/ic_wps_dark.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_wps_light.png b/res/drawable-mdpi/ic_wps_light.png
deleted file mode 100644
index ef560fa..0000000
--- a/res/drawable-mdpi/ic_wps_light.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_wps_dark.png b/res/drawable-xhdpi/ic_wps_dark.png
deleted file mode 100644
index 3ea4a3b..0000000
--- a/res/drawable-xhdpi/ic_wps_dark.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_wps_light.png b/res/drawable-xhdpi/ic_wps_light.png
deleted file mode 100644
index f913d2c..0000000
--- a/res/drawable-xhdpi/ic_wps_light.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_wps_dark.png b/res/drawable-xxhdpi/ic_wps_dark.png
deleted file mode 100644
index 8b38db8..0000000
--- a/res/drawable-xxhdpi/ic_wps_dark.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_wps_light.png b/res/drawable-xxhdpi/ic_wps_light.png
deleted file mode 100644
index 0084175..0000000
--- a/res/drawable-xxhdpi/ic_wps_light.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable/ic_sms_mirroring_24dp.xml b/res/drawable/ic_sms_mirroring_24dp.xml
deleted file mode 100644
index 5fe3003..0000000
--- a/res/drawable/ic_sms_mirroring_24dp.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"
-        android:tint="?android:attr/colorControlNormal">
-    <path
-        android:fillColor="#FF000000"
-        android:pathData="M20,2C21.1,2 22,2.9 22,4L22,16C22,17.1 21.1,18 20,18L6,18L2,22L2.01,4C2.01,2.9 2.9,2 4,2L20,2ZM8,8L4,12L8,16L8,13L14,13L14,11L8,11L8,8ZM19.666,7.872L16.038,4.372L16.038,6.997L10,6.997L10,9L16.038,9L16.038,11.372L19.666,7.872Z"/>
-</vector>
diff --git a/res/layout/data_plans_sync_time_preference.xml b/res/layout/data_plans_sync_time_preference.xml
deleted file mode 100644
index bb9da90..0000000
--- a/res/layout/data_plans_sync_time_preference.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.
--->
-
-<!-- Shows the data plans sync time -->
-<TextView
-        xmlns:android="http://schemas.android.com/apk/res/android"
-        android:id="@android:id/title"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:paddingStart="@dimen/preference_no_icon_padding_start"
-        android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
-        android:gravity="end"
-        android:textColor="?android:attr/textColorSecondary"/>
diff --git a/res/layout/data_usage_summary_preference.xml b/res/layout/data_usage_summary_preference.xml
new file mode 100644
index 0000000..445e7cd
--- /dev/null
+++ b/res/layout/data_usage_summary_preference.xml
@@ -0,0 +1,112 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+     Copyright (C) 2018 The Android Open Source Project
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at"+
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:paddingStart="@dimen/preference_no_icon_padding_start"
+    android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
+    android:orientation="vertical"
+    android:background="@drawable/selectable_card_grey"
+    android:selectable="false"
+    style="@style/EntityHeader">
+
+    <TextView
+        android:id="@+id/usage_title"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:textAppearance="?android:attr/textAppearanceListItemSecondary"
+        android:textColor="?android:attr/textColorSecondary"
+        android:paddingBottom="5dp"
+        android:text="@string/data_usage_title" />
+
+    <TextView
+        android:id="@android:id/title"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginBottom="5dp"
+        android:fontFamily="@*android:string/config_headlineFontFamily"
+        android:textColor="?android:attr/colorAccent"
+        android:textAppearance="@android:style/TextAppearance.Material.Large" />
+
+    <TextView
+        android:id="@android:id/summary"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:textAppearance="?android:attr/textAppearanceListItemSecondary"
+        android:textColor="?android:attr/textColorSecondary"
+        android:paddingBottom="5dp" />
+
+    <com.android.settings.widget.LinearColorBar
+        android:id="@+id/color_bar"
+        android:layout_width="match_parent"
+        android:layout_height="28dp" />
+
+    <LinearLayout
+        android:id="@+id/label_bar"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:paddingTop="2dp"
+        android:orientation="horizontal">
+
+        <TextView android:id="@android:id/text1"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:textAppearance="?android:attr/textAppearanceListItemSecondary"
+            android:textColor="?android:attr/textColorSecondary" />
+
+        <Space
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:layout_weight="1" />
+
+        <TextView android:id="@android:id/text2"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:textAppearance="?android:attr/textAppearanceListItemSecondary"
+            android:textColor="?android:attr/textColorSecondary" />
+
+    </LinearLayout>
+
+    <TextView
+        android:id="@+id/cycle_left_time"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:paddingBottom="5dp" />
+
+    <TextView
+        android:id="@+id/carrier_and_update"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:paddingBottom="5dp" />
+
+    <Button
+        android:id="@+id/launch_mdp_app_button"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_gravity="left"
+        android:text="@string/launch_mdp_app_text"
+        style="@style/ActionPrimaryButton" />
+
+    <TextView
+        android:id="@+id/data_limits"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:paddingBottom="5dp" />
+
+</LinearLayout>
+
diff --git a/res/layout/manage_data_plans_preference.xml b/res/layout/manage_data_plans_preference.xml
deleted file mode 100644
index 0db5698..0000000
--- a/res/layout/manage_data_plans_preference.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-     Copyright (C) 2017 The Android Open Source Project
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at"+
-
-     http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-
-<FrameLayout
-        xmlns:android="http://schemas.android.com/apk/res/android"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:paddingStart="@dimen/preference_no_icon_padding_start"
-        android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
-        android:paddingTop="8dp"
-        android:paddingBottom="16dp">
-    <Button
-            android:id="@+id/manage_data_plans"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:text="@string/data_plan_usage_manage_plans_button_text"
-            android:textAllCaps="true"
-            style="@style/ActionPrimaryButton" />
-</FrameLayout>
diff --git a/res/layout/search_feedback.xml b/res/layout/preference_widget_gear_no_bg.xml
similarity index 64%
copy from res/layout/search_feedback.xml
copy to res/layout/preference_widget_gear_no_bg.xml
index cdb0545..89d34d4 100644
--- a/res/layout/search_feedback.xml
+++ b/res/layout/preference_widget_gear_no_bg.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2017 The Android Open Source Project
+<!-- Copyright (C) 2018 The Android Open Source Project
 
      Licensed under the Apache License, Version 2.0 (the "License");
      you may not use this file except in compliance with the License.
@@ -14,10 +14,14 @@
      limitations under the License.
 -->
 
-<View
+<!-- Settings button -->
+<ImageView
     xmlns:android="http://schemas.android.com/apk/res/android"
-    android:id="@+id/feedback_popup"
-    android:layout_width="0dp"
-    android:layout_height="0dp"
-    android:visibility="gone">
-</View>
+    android:id="@+id/settings_button"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:layout_gravity="center"
+    android:scaleType="center"
+    android:src="@drawable/ic_settings"
+    android:contentDescription="@string/settings_button" />
+
diff --git a/res/layout/search_breadcrumb_view.xml b/res/layout/search_breadcrumb_view.xml
deleted file mode 100644
index 08a2651..0000000
--- a/res/layout/search_breadcrumb_view.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.
-  -->
-
-<TextView
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    android:id="@+id/breadcrumb"
-    android:layout_width="wrap_content"
-    android:layout_height="wrap_content"
-    android:paddingTop="5dp"
-    android:textAppearance="?android:attr/textAppearanceListItemSecondary"
-    android:textColor="?android:attr/textColorSecondary"
-    android:ellipsize="marquee"/>
diff --git a/res/layout/search_inline_switch_item.xml b/res/layout/search_inline_switch_item.xml
deleted file mode 100644
index 8f050a3..0000000
--- a/res/layout/search_inline_switch_item.xml
+++ /dev/null
@@ -1,60 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2016 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-          http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-
-<LinearLayout
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="match_parent"
-    android:layout_height="wrap_content"
-    android:minHeight="?android:attr/listPreferredItemHeight"
-    android:paddingTop="16dp"
-    android:paddingBottom="16dp"
-    android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
-    android:background="?android:attr/selectableItemBackground"
-    android:clipToPadding="false">
-
-    <include layout="@layout/search_icon_view"/>
-
-    <LinearLayout
-        android:layout_width="0dp"
-        android:layout_height="wrap_content"
-        android:layout_weight="1"
-        android:orientation="vertical">
-
-        <TextView
-            android:id="@android:id/title"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:singleLine="true"
-            android:textAppearance="?android:attr/textAppearanceListItem"
-            android:ellipsize="marquee"/>
-
-        <TextView
-            android:id="@android:id/summary"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:singleLine="true"
-            android:textAppearance="?android:attr/textAppearanceListItemSecondary"/>
-
-        <include layout="@layout/search_breadcrumb_view"/>
-    </LinearLayout>
-
-    <Switch
-        android:id="@+id/switchView"
-        android:layout_width="wrap_content"
-        android:layout_height="match_parent"
-        android:gravity="top"
-        android:paddingStart="16dp"/>
-</LinearLayout>
diff --git a/res/layout/search_intent_item.xml b/res/layout/search_intent_item.xml
deleted file mode 100644
index 6bc00ad..0000000
--- a/res/layout/search_intent_item.xml
+++ /dev/null
@@ -1,54 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2016 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-          http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-
-<LinearLayout
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="match_parent"
-    android:layout_height="wrap_content"
-    android:minHeight="?android:attr/listPreferredItemHeight"
-    android:paddingTop="16dp"
-    android:paddingBottom="16dp"
-    android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
-    android:background="?android:attr/selectableItemBackground"
-    android:clipToPadding="false">
-
-    <include layout="@layout/search_icon_view"/>
-
-    <LinearLayout
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_weight="1"
-        android:orientation="vertical">
-
-        <TextView
-            android:id="@android:id/title"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:singleLine="true"
-            android:textAppearance="?android:attr/textAppearanceListItem"
-            android:ellipsize="marquee"/>
-
-        <TextView
-            android:id="@android:id/summary"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:singleLine="true"
-            android:textAppearance="?android:attr/textAppearanceListItemSecondary"
-            android:ellipsize="marquee"/>
-
-        <include layout="@layout/search_breadcrumb_view"/>
-    </LinearLayout>
-</LinearLayout>
diff --git a/res/layout/search_panel.xml b/res/layout/search_panel.xml
deleted file mode 100644
index 10c2a00..0000000
--- a/res/layout/search_panel.xml
+++ /dev/null
@@ -1,107 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2016 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-          http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-<LinearLayout
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
-    android:id="@+id/search_panel"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:orientation="vertical">
-
-    <FrameLayout
-        android:id="@+id/search_bar_container"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:background="@color/suggestion_condition_background">
-        <android.support.v7.widget.CardView
-            android:id="@+id/search_bar"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_margin="@dimen/search_bar_margin"
-            app:cardCornerRadius="2dp"
-            app:cardBackgroundColor="?android:attr/colorBackground"
-            app:cardElevation="2dp">
-            <Toolbar
-                android:id="@+id/search_toolbar"
-                android:layout_width="match_parent"
-                android:layout_height="@dimen/search_bar_height"
-                android:background="?android:attr/selectableItemBackground"
-                android:contentInsetStart="0dp"
-                android:contentInsetStartWithNavigation="0dp"
-                android:theme="?android:attr/actionBarTheme">
-                <SearchView
-                    android:id="@+id/search_view"
-                    android:layout_width="match_parent"
-                    android:layout_height="match_parent"
-                    android:iconifiedByDefault="false"
-                    android:imeOptions="actionSearch|flagNoExtractUi"
-                    android:searchIcon="@null"/>
-            </Toolbar>
-        </android.support.v7.widget.CardView>
-    </FrameLayout>
-
-    <FrameLayout
-        android:id="@+id/layout_results"
-        android:layout_width="match_parent"
-        android:layout_height="0dp"
-        android:layout_weight="1"
-        android:orientation="vertical">
-
-        <!-- Padding is included in the background -->
-        <android.support.v7.widget.RecyclerView
-            android:id="@+id/list_results"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:paddingStart="@dimen/dashboard_padding_start"
-            android:paddingEnd="@dimen/dashboard_padding_end"
-            android:paddingTop="@dimen/dashboard_padding_top"
-            android:paddingBottom="@dimen/dashboard_padding_bottom"
-            android:scrollbarStyle="outsideOverlay"
-            android:scrollbars="vertical"/>
-
-        <LinearLayout
-            android:id="@+id/no_results_layout"
-            android:layout_width="match_parent"
-            android:layout_height="match_parent"
-            android:paddingTop="35dp"
-            android:orientation="vertical"
-            android:visibility="gone">
-
-            <Space
-                android:layout_width="match_parent"
-                android:layout_height="?android:attr/actionBarSize"/>
-
-            <ImageView
-                android:layout_height="wrap_content"
-                android:layout_width="wrap_content"
-                android:layout_gravity="center_horizontal"
-                android:src="@drawable/empty_search_results"/>
-
-            <TextView
-                android:layout_height="wrap_content"
-                android:layout_width="match_parent"
-                android:paddingTop="24dp"
-                android:textSize="18sp"
-                android:text="@string/search_settings_no_results"
-                android:gravity="center"/>
-
-        </LinearLayout>
-
-    </FrameLayout>
-
-    <include layout="@layout/search_feedback"/>
-
-</LinearLayout>
diff --git a/res/layout/settings_main_dashboard.xml b/res/layout/settings_main_dashboard.xml
index 4f8c308..10ff2ee 100644
--- a/res/layout/settings_main_dashboard.xml
+++ b/res/layout/settings_main_dashboard.xml
@@ -43,7 +43,6 @@
                 android:background="?android:attr/selectableItemBackground"
                 android:contentInsetStartWithNavigation="64dp"
                 android:navigationIcon="@drawable/ic_search_24dp"
-                android:navigationContentDescription="@string/search_menu"
                 android:theme="?android:attr/actionBarTheme">
                 <TextView
                     android:id="@+id/search_action_bar_title"
diff --git a/res/layout/styled_switch_bar.xml b/res/layout/styled_switch_bar.xml
index 1777c0f..3baaac3 100644
--- a/res/layout/styled_switch_bar.xml
+++ b/res/layout/styled_switch_bar.xml
@@ -16,13 +16,13 @@
 
 <!-- For use in a LayoutPreference -->
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-              android:layout_height="0px"
-              android:layout_width="match_parent"
-              android:layout_weight="1" >
+              android:layout_height="wrap_content"
+              android:layout_width="match_parent" >
 
     <com.android.settings.widget.SwitchBar
         android:id="@+id/switch_bar"
-        android:layout_height="?android:attr/actionBarSize"
+        android:minHeight="?android:attr/actionBarSize"
+        android:layout_height="wrap_content"
         android:layout_width="match_parent"
         android:paddingStart="0dp"
         android:theme="?attr/switchBarTheme" />
diff --git a/res/layout/suggestion_tile.xml b/res/layout/suggestion_tile.xml
index fa3f3af..850e55a 100644
--- a/res/layout/suggestion_tile.xml
+++ b/res/layout/suggestion_tile.xml
@@ -52,6 +52,7 @@
                 android:layout_alignParentEnd="true"
                 android:layout_marginTop="8dp"
                 android:layout_marginEnd="8dp"
+                android:contentDescription="@string/dlg_close"
                 android:src="@drawable/ic_suggestion_close_button"/>
 
         </RelativeLayout>
diff --git a/res/layout/suggestion_tile_with_button.xml b/res/layout/suggestion_tile_with_button.xml
index de3494a..8fb8e84 100644
--- a/res/layout/suggestion_tile_with_button.xml
+++ b/res/layout/suggestion_tile_with_button.xml
@@ -52,6 +52,7 @@
                 android:layout_alignParentEnd="true"
                 android:layout_marginTop="8dp"
                 android:layout_marginEnd="8dp"
+                android:contentDescription="@string/dlg_close"
                 android:src="@drawable/ic_suggestion_close_button"/>
 
         </RelativeLayout>
diff --git a/res/layout/two_state_button.xml b/res/layout/two_state_button.xml
new file mode 100644
index 0000000..22bf2bd
--- /dev/null
+++ b/res/layout/two_state_button.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  Copyright (C) 2018 The Android Open Source Project
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+  -->
+
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:orientation="horizontal"
+    android:gravity="bottom"
+    android:paddingStart="72dp"
+    android:paddingEnd="72dp"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+    <Button
+        android:id="@+id/state_on_button"
+        style="@style/ActionPrimaryButton"
+        android:layout_width="0dp"
+        android:layout_weight="1"
+        android:layout_height="wrap_content"
+        android:layout_gravity="center"
+        android:paddingEnd="8dp" />
+
+    <Button
+        android:id="@+id/state_off_button"
+        style="@style/ActionSecondaryButton"
+        android:layout_width="0dp"
+        android:layout_weight="1"
+        android:layout_height="wrap_content"
+        android:layout_gravity="center"
+        android:paddingEnd="8dp" />
+
+</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/wifi_wps_dialog.xml b/res/layout/wifi_wps_dialog.xml
deleted file mode 100644
index a86823d..0000000
--- a/res/layout/wifi_wps_dialog.xml
+++ /dev/null
@@ -1,66 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2012 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-          http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-
-<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
-         android:layout_width="300sp"
-         android:layout_height="wrap_content">
-
-    <LinearLayout
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:padding="8dip"
-            android:orientation="vertical">
-
-        <TextView
-                android:id="@+id/wps_dialog_txt"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:layout_marginTop="8dip" />
-
-        <ImageView
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_gravity="center"
-                android:layout_marginTop="8dip"
-                android:src="?attr/ic_wps" />
-
-        <ProgressBar
-                android:id="@+id/wps_timeout_bar"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:layout_marginTop="20dip"
-                style="?android:attr/progressBarStyleHorizontal" />
-
-        <ProgressBar
-                android:id="@+id/wps_progress_bar"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:layout_marginTop="20dip"
-                style="?android:attr/progressBarStyle" />
-
-        <RelativeLayout
-                android:gravity="center"
-                android:layout_width="fill_parent"
-                android:layout_height="wrap_content">
-
-            <Button
-                    android:id="@+id/wps_dialog_btn"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:text="@string/cancel" />
-        </RelativeLayout>
-    </LinearLayout>
-</ScrollView>
diff --git a/res/values-fr-rCA/strings.xml b/res/values-fr-rCA/strings.xml
index 9935755..d225295 100644
--- a/res/values-fr-rCA/strings.xml
+++ b/res/values-fr-rCA/strings.xml
@@ -781,9 +781,7 @@
     <string name="wifi_configure_settings_preference_summary_wakeup_on" msgid="646393113104367290">"Le Wi-Fi se réactive automatiquement"</string>
     <string name="wifi_configure_settings_preference_summary_wakeup_off" msgid="2782566279864356713">"Le Wi-Fi ne se réactive pas automatiquement"</string>
     <string name="wifi_access_points" msgid="7053990007031968609">"Réseaux Wi-Fi"</string>
-    <string name="wifi_menu_wps_pbc" msgid="2668564692207863017">"Bouton commande WPS"</string>
     <string name="wifi_menu_more_options" msgid="2448097861752719396">"Plus d\'options"</string>
-    <string name="wifi_menu_wps_pin" msgid="6426448256268695933">"Saisie NIP WPS"</string>
     <string name="wifi_menu_p2p" msgid="7619851399250896797">"Wi-Fi Direct"</string>
     <string name="wifi_menu_scan" msgid="1470911530412095868">"Scanner"</string>
     <string name="wifi_menu_advanced" msgid="7522252991919573664">"Options avancées"</string>
@@ -801,19 +799,6 @@
     <string name="wifi_show_advanced" msgid="3409422789616520979">"Options avancées"</string>
     <string name="wifi_advanced_toggle_description_expanded" msgid="2380600578544493084">"Liste déroulante Options avancées. Touchez deux fois pour la réduire."</string>
     <string name="wifi_advanced_toggle_description_collapsed" msgid="1463812308429197263">"Liste déroulante Options avancées. Touchez deux fois pour la développer."</string>
-    <string name="wifi_wps_setup_title" msgid="8207552222481570175">"Configuration Wi-Fi protégée"</string>
-    <string name="wifi_wps_setup_msg" msgid="315174329121275092">"Démarrage de la configuration WPS…"</string>
-    <string name="wifi_wps_onstart_pbc" msgid="817003360936932340">"Appuyez sur le bouton « Configuration Wi-Fi protégée » de votre routeur. Celui-ci peut s\'appeler « WPS » ou contenir ce symbole :"</string>
-    <string name="wifi_wps_onstart_pin" msgid="223344506445335358">"Saisissez le code d\'accès « <xliff:g id="NUMBER">%1$s</xliff:g> » sur votre routeur Wi-Fi. La configuration peut prendre jusqu\'à deux minutes."</string>
-    <string name="wifi_wps_complete" msgid="2388138550456729134">"Configuration WPS réussie. Connexion au réseau en cours…"</string>
-    <string name="wifi_wps_connected" msgid="7153432445748931183">"Connecté au réseau Wi-Fi « <xliff:g id="NETWORK_NAME">%s</xliff:g> »"</string>
-    <string name="wifi_wps_in_progress" msgid="3372311348221357944">"La configuration WPS est déjà en cours et peut prendre jusqu\'à deux minutes."</string>
-    <string name="wifi_wps_failed_generic" msgid="5668775022238832527">"Échec de la configuration WPS. Veuillez réessayer dans quelques minutes."</string>
-    <string name="wifi_wps_failed_wep" msgid="2702820087105284461">"La configuration de sécurité du routeur sans fil (WEP) n\'est pas compatible."</string>
-    <string name="wifi_wps_failed_tkip" msgid="4282401586860713349">"La configuration de sécurité du routeur sans fil (TKIP) n\'est pas compatible."</string>
-    <string name="wifi_wps_failed_auth" msgid="1174614355181181958">"Échec de l\'authentification. Veuillez réessayer."</string>
-    <string name="wifi_wps_failed_overlap" msgid="5159533685596844778">"Une autre session WPS a été détectée. Veuillez réessayer dans quelques minutes."</string>
-    <string name="wifi_wps_failed_wifi_disconnected" msgid="3829472117754104164">"Wi-Fi déconnecté. La configuration du WPS a été annulée."</string>
     <string name="wifi_ssid" msgid="5519636102673067319">"Nom du réseau"</string>
     <string name="wifi_ssid_hint" msgid="897593601067321355">"Saisissez le SSID"</string>
     <string name="wifi_security" msgid="6603611185592956936">"Sécurité"</string>
@@ -939,8 +924,10 @@
     <string name="wifi_hotspot_configure_ap_text_summary" msgid="5560680057727007011">"Point d\'accès AndroidAP WPA2 PSK"</string>
     <string name="wifi_tether_configure_ssid_default" msgid="8467525402622138547">"AndroidHotspot"</string>
     <string name="wifi_calling_settings_title" msgid="4102921303993404577">"Appels Wi-Fi"</string>
-    <string name="wifi_calling_suggestion_title" msgid="9008010480466359578">"Activer les appels Wi-Fi"</string>
-    <string name="wifi_calling_suggestion_summary" msgid="4277772016570248405">"Étendre la couverture avec les appels Wi-Fi"</string>
+    <!-- no translation found for wifi_calling_suggestion_title (7766895085362824508) -->
+    <skip />
+    <!-- no translation found for wifi_calling_suggestion_summary (6460250990899143406) -->
+    <skip />
     <string name="wifi_calling_mode_title" msgid="2164073796253284289">"Préférences d\'appel"</string>
     <string name="wifi_calling_mode_dialog_title" msgid="8149690312199253909">"Mode d\'appel Wi-Fi"</string>
     <string name="wifi_calling_roaming_mode_title" msgid="1565039047187685115">"Préférences d\'itinérance"</string>
@@ -1030,9 +1017,6 @@
     <string name="accessibility_work_account_title" msgid="1231830766637939527">"Compte professionnel - <xliff:g id="MANAGED_BY">%s</xliff:g>"</string>
     <string name="accessibility_personal_account_title" msgid="2169071663029067826">"Compte personnel - <xliff:g id="MANAGED_BY">%s</xliff:g>"</string>
     <string name="search_settings" msgid="1910951467596035063">"Rechercher"</string>
-    <string name="search_settings_summary" msgid="9205656546570654169">"Configurer les paramètres et l\'historique de recherche"</string>
-    <string name="search_settings_no_results" msgid="8799027492641230999">"Aucun résultat"</string>
-    <string name="search_clear_history" msgid="4196658962573162457">"Effacer l\'historique"</string>
     <string name="display_settings" msgid="7965901687241669598">"Affichage"</string>
     <string name="accelerometer_title" msgid="7854608399547349157">"Rotation auto de l\'écran"</string>
     <string name="color_mode_title" msgid="9186249332902370471">"Couleurs"</string>
@@ -1891,6 +1875,12 @@
     <string name="accessibility_display_inversion_preference_subtitle" msgid="7052959202195368109">"Pourrait nuire aux performances"</string>
     <string name="accessibility_autoclick_preference_title" msgid="7014499339068449623">"Cliquer lorsque curseur arrête"</string>
     <string name="accessibility_autoclick_delay_preference_title" msgid="3962261178385106006">"Délai précédant le clic"</string>
+    <!-- no translation found for accessibility_vibration_settings_title (3453277326300320803) -->
+    <skip />
+    <!-- no translation found for accessibility_notification_vibration_title (660829933960942244) -->
+    <skip />
+    <!-- no translation found for accessibility_touch_vibration_title (7931823772673770492) -->
+    <skip />
     <string name="accessibility_service_master_switch_title" msgid="6835441300276358239">"Utiliser le service"</string>
     <string name="accessibility_daltonizer_master_switch_title" msgid="8655284637968823154">"Utiliser la correction des couleurs"</string>
     <string name="accessibility_caption_master_switch_title" msgid="4010227386676077826">"Utiliser les légendes"</string>
@@ -1918,6 +1908,22 @@
       <item quantity="one">Très long délai (<xliff:g id="CLICK_DELAY_LABEL_1">%1$d</xliff:g> ms)</item>
       <item quantity="other">Très long délai (<xliff:g id="CLICK_DELAY_LABEL_1">%1$d</xliff:g> ms)</item>
     </plurals>
+    <!-- no translation found for accessibility_vibration_summary_off (1753566394591809629) -->
+    <skip />
+    <!-- no translation found for accessibility_vibration_summary_low (7628418309029013867) -->
+    <skip />
+    <!-- no translation found for accessibility_vibration_summary_medium (3422136736880414093) -->
+    <skip />
+    <!-- no translation found for accessibility_vibration_summary_high (3239807793182635729) -->
+    <skip />
+    <!-- no translation found for accessibility_vibration_intensity_off (4613890213008630847) -->
+    <skip />
+    <!-- no translation found for accessibility_vibration_intensity_low (2017572546489862987) -->
+    <skip />
+    <!-- no translation found for accessibility_vibration_intensity_medium (3782136025830279769) -->
+    <skip />
+    <!-- no translation found for accessibility_vibration_intensity_high (2543921139337952491) -->
+    <skip />
     <string name="accessibility_menu_item_settings" msgid="3344942964710773365">"Paramètres"</string>
     <string name="accessibility_feature_state_on" msgid="2864292320042673806">"Activé"</string>
     <string name="accessibility_feature_state_off" msgid="4172584906487070211">"Désactivé"</string>
@@ -2067,6 +2073,24 @@
     <string name="battery_tip_dialog_message" product="default" msgid="6744251070067861233">"Votre téléphone a été utilisé intensément, et cela a consommé beaucoup d\'énergie. Sa pile fonctionne correctement.\n\nVotre téléphone a été utilisé pendant environ <xliff:g id="HOUR">%1$s</xliff:g> depuis sa dernière charge complète.\n\n Usage total :"</string>
     <string name="battery_tip_dialog_message" product="tablet" msgid="7091442312127403445">"Votre tablette a été utilisée intensément, et cela a consommé beaucoup d\'énergie. Sa pile fonctionne correctement.\n\nVotre tablette a été utilisée pendant environ <xliff:g id="HOUR">%1$s</xliff:g> depuis sa dernière charge complète.\n\n Usage total :"</string>
     <string name="battery_tip_dialog_message" product="device" msgid="7621045312469814256">"Votre appareil a été utilisé intensément, et cela a consommé beaucoup d\'énergie. Sa pile fonctionne correctement.\n\nVotre appareil a été utilisé pendant environ <xliff:g id="HOUR">%1$s</xliff:g> depuis sa dernière charge complète.\n\n Usage total :"</string>
+    <!-- no translation found for battery_tip_restrict_title (467228882789275512) -->
+    <!-- no translation found for battery_tip_restrict_handled_title (5203646029862183763) -->
+    <!-- no translation found for battery_tip_restrict_summary (9128154370135347093) -->
+    <!-- no translation found for battery_tip_restrict_handled_summary (29466713333477274) -->
+    <skip />
+    <!-- no translation found for battery_tip_restrict_app_dialog_title (8130618585820429591) -->
+    <!-- no translation found for battery_tip_restrict_app_dialog_message (5818730114373015028) -->
+    <skip />
+    <!-- no translation found for battery_tip_restrict_app_dialog_ok (8291115820018013353) -->
+    <skip />
+    <!-- no translation found for battery_tip_unrestrict_app_dialog_title (4550106794311784978) -->
+    <skip />
+    <!-- no translation found for battery_tip_unrestrict_app_dialog_message (4836135946080501395) -->
+    <skip />
+    <!-- no translation found for battery_tip_unrestrict_app_dialog_ok (6022058431218137646) -->
+    <skip />
+    <!-- no translation found for battery_tip_unrestrict_app_dialog_cancel (9062797114255859496) -->
+    <skip />
     <string name="smart_battery_manager_title" msgid="5677222263071864438">"Gestionnaire de pile intelligent"</string>
     <string name="smart_battery_title" msgid="7014692334636228916">"Gérer automatiquement la pile"</string>
     <string name="smart_battery_summary" msgid="6435844879637999044">"Ajuster automatiquement la consommation d\'énergie des applications en fonction de l\'utilisation"</string>
@@ -2172,6 +2196,8 @@
     <string name="battery_detail_power_percentage" msgid="8064814503316094497">"<xliff:g id="PERCENT">%1$s</xliff:g> de l\'utilisation totale par les applications (<xliff:g id="POWER">%2$d</xliff:g> mAh)"</string>
     <string name="battery_detail_info_title" msgid="8227822131405620369">"Depuis la charge complète"</string>
     <string name="battery_detail_manage_title" msgid="9094314252105828014">"Gérer l\'utilisation de la pile"</string>
+    <!-- no translation found for advanced_battery_graph_subtext (5621073891377915877) -->
+    <skip />
     <string name="estimated_time_left" msgid="7514194472683370877">"Durée restante estimée"</string>
     <string name="estimated_charging_time_left" msgid="5614442409326164691">"Jusqu\'à la charge complète"</string>
     <string name="estimated_time_description" msgid="8760210909000037089">"La durée estimée peut changer en fonction de l\'utilisation"</string>
@@ -2182,7 +2208,14 @@
     <string name="process_kernel_label" msgid="3916858646836739323">"Système d\'exploitation Android"</string>
     <string name="process_mediaserver_label" msgid="6500382062945689285">"Serveur multimédia"</string>
     <string name="process_dex2oat_label" msgid="2592408651060518226">"Optimisation des applications"</string>
-    <string name="battery_saver" msgid="8172485772238572153">"Économie d\'énergie"</string>
+    <!-- no translation found for battery_saver (6002143200184768727) -->
+    <skip />
+    <!-- no translation found for battery_saver_auto_title (6896506441192920565) -->
+    <skip />
+    <!-- no translation found for battery_saver_auto_summary (8715989830471454219) -->
+    <skip />
+    <!-- no translation found for battery_saver_seekbar_title (3428789387167865312) -->
+    <skip />
     <string name="battery_saver_master_switch_title" msgid="622539414546588436">"Utiliser le mode Économie d\'énergie"</string>
     <string name="battery_saver_turn_on_automatically_title" msgid="9023847300114669426">"Activer automatiquement"</string>
     <string name="battery_saver_turn_on_automatically_never" msgid="6610846456314373">"Jamais"</string>
@@ -2425,7 +2458,6 @@
     <string name="misc_files_selected_count" msgid="4647048020823912088">"<xliff:g id="NUMBER">%1$d</xliff:g> fichiers sélectionnés sur <xliff:g id="TOTAL">%2$d</xliff:g>"</string>
     <string name="misc_files_selected_count_bytes" msgid="2876232009069114352">"<xliff:g id="NUMBER">%1$s</xliff:g> sur <xliff:g id="TOTAL">%2$s</xliff:g>"</string>
     <string name="select_all" msgid="1562774643280376715">"Tout sélectionner"</string>
-    <string name="data_plan_usage_manage_plans_button_text" msgid="8997761990902708162">"Gérer les forfaits"</string>
     <string name="data_usage_summary_title" msgid="3804110657238092929">"Utilisation des données"</string>
     <string name="data_usage_app_summary_title" msgid="4147258989837459172">"Util. données aplication"</string>
     <string name="data_usage_accounting" msgid="7170028915873577387">"La manière dont le fournisseur de services effectue les calcul des données peut être différente."</string>
@@ -2472,6 +2504,8 @@
     <string name="data_usage_enable_mobile" msgid="986782622560157977">"Données mobiles"</string>
     <string name="data_usage_enable_3g" msgid="6304006671869578254">"Données 2G-3G"</string>
     <string name="data_usage_enable_4g" msgid="3635854097335036738">"Données 4G"</string>
+    <!-- no translation found for data_roaming_enable_mobile (1523331545457578362) -->
+    <skip />
     <string name="data_usage_forground_label" msgid="7654319010655983591">"Premier plan :"</string>
     <string name="data_usage_background_label" msgid="2722008379947694926">"Arrière-plan :"</string>
     <string name="data_usage_app_settings" msgid="2279171379771253165">"Paramètres de l\'application"</string>
@@ -2815,8 +2849,7 @@
     <string name="app_and_notification_dashboard_title" msgid="7838365599185397539">"Applications et notifications"</string>
     <string name="app_and_notification_dashboard_summary" msgid="2363314178802548682">"Autorisations, applications par défaut"</string>
     <string name="account_dashboard_title" msgid="5895948991491438911">"Comptes"</string>
-    <!-- no translation found for account_dashboard_default_summary (3998347400161811075) -->
-    <skip />
+    <string name="account_dashboard_default_summary" msgid="3998347400161811075">"Aucun compte ajouté"</string>
     <string name="app_default_dashboard_title" msgid="7342549305933047317">"Applications par défaut"</string>
     <string name="system_dashboard_summary" msgid="5797743225249766685">"Langues, sauvegardes, mises à jour"</string>
     <string name="search_results_title" msgid="1796252422574886932">"Paramètres"</string>
@@ -2943,6 +2976,13 @@
     <string name="zen_mode_settings_dnd_automatic_rule_app" msgid="1721179577382915270">"Le mode Ne pas déranger a été activé par une application (<xliff:g id="APP_NAME">%s</xliff:g>)"</string>
     <string name="zen_interruption_level_priority" msgid="2078370238113347720">"Priorités seulement"</string>
     <string name="zen_mode_and_condition" msgid="4927230238450354412">"<xliff:g id="ZEN_MODE">%1$s</xliff:g>. <xliff:g id="EXIT_CONDITION">%2$s</xliff:g>"</string>
+    <!-- no translation found for zen_mode_sound_summary_on (9067685807840094102) -->
+    <skip />
+    <!-- no translation found for zen_mode_sound_summary_off_with_info (2348629457144123849) -->
+    <skip />
+    <!-- no translation found for zen_mode_sound_summary_off (4375814717589425561) -->
+    <skip />
+    <!-- no translation found for zen_mode_sound_summary_summary_off_info (8115159143760078050) -->
     <string name="sound_work_settings" msgid="6774324553228566442">"Sons du profil professionnel"</string>
     <string name="work_use_personal_sounds_title" msgid="1148331221338458874">"Utiliser sons du profil perso"</string>
     <string name="work_use_personal_sounds_summary" msgid="6207040454949823153">"Les sons du profil professionnel sont les mêmes que ceux du profil personnel"</string>
@@ -2959,20 +2999,22 @@
     <string name="other_sound_category_preference_title" msgid="2521096636124314015">"Autres sons et vibrations"</string>
     <string name="configure_notification_settings" msgid="7616737397127242615">"Notifications"</string>
     <string name="recent_notifications" msgid="5660639387705060156">"Envoyées récemment"</string>
-    <!-- no translation found for recent_notifications_see_all_title (3935564140468680831) -->
-    <skip />
+    <string name="recent_notifications_see_all_title" msgid="3935564140468680831">"Afficher toutes les applications"</string>
     <string name="advanced_section_header" msgid="8833934850242546903">"Paramètres avancés"</string>
     <string name="profile_section_header" msgid="2320848161066912001">"Notifications professionnelles"</string>
     <string name="notification_badging_title" msgid="5938709971403474078">"Autoriser points de notification"</string>
     <string name="notification_pulse_title" msgid="1905382958860387030">"Faire clignoter le voyant"</string>
-    <string name="lock_screen_notifications_title" msgid="6173076173408887213">"À l\'écran de verrouillage"</string>
+    <!-- no translation found for lock_screen_notifications_title (2583595963286467672) -->
+    <skip />
     <string name="lock_screen_notifications_summary_show" msgid="6407527697810672847">"Afficher tout le contenu des notifications"</string>
-    <string name="lock_screen_notifications_summary_hide" msgid="7891552853357258782">"Masquer le contenu sensible des notifications"</string>
+    <!-- no translation found for lock_screen_notifications_summary_hide (8301305044690264958) -->
+    <skip />
     <string name="lock_screen_notifications_summary_disable" msgid="859628910427886715">"N\'afficher aucune notification"</string>
     <string name="lock_screen_notifications_interstitial_message" msgid="6164532459432182244">"Lorsque votre appareil est verrouillé, comment voulez-vous que les notifications s\'affichent?"</string>
     <string name="lock_screen_notifications_interstitial_title" msgid="1416589393106326972">"Notifications"</string>
     <string name="lock_screen_notifications_summary_show_profile" msgid="835870815661120772">"Afficher tout le contenu des notif. professionn."</string>
-    <string name="lock_screen_notifications_summary_hide_profile" msgid="256116258285695645">"Masquer contenu sensible des notif. professionn."</string>
+    <!-- no translation found for lock_screen_notifications_summary_hide_profile (2005907007779384635) -->
+    <skip />
     <string name="lock_screen_notifications_summary_disable_profile" msgid="4080720698960233358">"N\'afficher aucune notification professionnelle"</string>
     <string name="lock_screen_notifications_interstitial_message_profile" msgid="8307705621027472346">"Lorsque votre appareil est verrouillé, comment voulez-vous que les notifications de profil s\'affichent?"</string>
     <string name="lock_screen_notifications_interstitial_title_profile" msgid="3169806586032521333">"Notifications de profil"</string>
@@ -2983,8 +3025,9 @@
     <string name="notification_importance_title" msgid="4368578960344731828">"Comportement"</string>
     <string name="notification_importance_unspecified" msgid="6622173510486113958">"Autoriser le son"</string>
     <string name="notification_importance_blocked" msgid="7938180808339386300">"Ne jamais afficher les notifications"</string>
-    <string name="notification_importance_min" msgid="5455049524984686275">"Aucun son ni interruption visuelle"</string>
-    <string name="notification_importance_low" msgid="8881468429453766553">"Aucun son"</string>
+    <!-- no translation found for notification_importance_min (9054819132085066824) -->
+    <skip />
+    <string name="notification_importance_low" msgid="2445139943005315690">"Affichage silencieux"</string>
     <string name="notification_importance_default" msgid="5958338024601957516">"Émettre un son"</string>
     <string name="notification_importance_high" msgid="2082429479238228527">"Émettre un son et s\'afficher à l\'écran"</string>
     <string name="notification_importance_high_silent" msgid="2667033773703765252">"Afficher sur l\'écran"</string>
@@ -3059,7 +3102,8 @@
     <string name="notification_channel_badge_title" msgid="2240827899882847087">"Afficher le point de notification"</string>
     <string name="app_notification_override_dnd_title" msgid="7867458246395884830">"Ignorer le mode Ne pas déranger"</string>
     <string name="app_notification_override_dnd_summary" msgid="3516007157020189746">"Activer les notifications de cette application même lorsque l\'option Ne pas déranger est définie sur Prioritaires uniquement"</string>
-    <string name="app_notification_visibility_override_title" msgid="2187232730902430718">"À l\'écran de verrouillage"</string>
+    <!-- no translation found for app_notification_visibility_override_title (7821124557634786985) -->
+    <skip />
     <string name="app_notification_row_banned" msgid="5983655258784814773">"Bloqué"</string>
     <string name="app_notification_row_priority" msgid="7723839972982746568">"Priorité"</string>
     <string name="app_notification_row_sensitive" msgid="1809610030432329940">"Sensible"</string>
@@ -3324,43 +3368,28 @@
     <string name="decline_remote_bugreport_action" msgid="518720235407565134">"Refuser"</string>
     <string name="usb_use_charging_only" msgid="2180443097365214467">"Charger cet appareil"</string>
     <string name="usb_use_charging_only_desc" msgid="3066256793008540627">"Charger cet appareil seulement"</string>
-    <!-- no translation found for usb_use_power_only (6449381364444187612) -->
-    <skip />
-    <!-- no translation found for usb_use_power_only_desc (5674490059427055197) -->
-    <skip />
-    <!-- no translation found for usb_use_file_transfers (1223134119354320726) -->
-    <skip />
+    <string name="usb_use_power_only" msgid="6449381364444187612">"Chargement de l\'appareil connecté"</string>
+    <string name="usb_use_power_only_desc" msgid="5674490059427055197">"D\'autres paramètres ne sont pas accessibles lorsque l\'appareil est allumé"</string>
+    <string name="usb_use_file_transfers" msgid="1223134119354320726">"Transfert de fichiers"</string>
     <string name="usb_use_file_transfers_desc" msgid="4235764784331804488">"Transférer des fichiers vers un autre appareil"</string>
-    <!-- no translation found for usb_use_photo_transfers (8192719651229326283) -->
-    <skip />
+    <string name="usb_use_photo_transfers" msgid="8192719651229326283">"PTP"</string>
     <string name="usb_use_photo_transfers_desc" msgid="2963034811151325996">"Transferer des photos ou des fichiers si MTP n\'est pas pris en charge (PTP)"</string>
-    <!-- no translation found for usb_use_tethering (3944506882789422118) -->
-    <skip />
+    <string name="usb_use_tethering" msgid="3944506882789422118">"Partage de connexion par USB"</string>
     <string name="usb_use_MIDI" msgid="5116404702692483166">"MIDI"</string>
     <string name="usb_use_MIDI_desc" msgid="8473936990076693175">"Utiliser cet appareil en tant que MIDI"</string>
     <string name="usb_use" msgid="3372728031108932425">"Utiliser la connexion USB pour :"</string>
-    <!-- no translation found for usb_use_also (557340935190819370) -->
-    <skip />
+    <string name="usb_use_also" msgid="557340935190819370">"Aussi utiliser la connexion USB pour"</string>
     <string name="usb_pref" msgid="1400617804525116158">"USB"</string>
     <string name="usb_summary_charging_only" msgid="7544327009143659751">"Chargement de l\'appareil"</string>
-    <!-- no translation found for usb_summary_power_only (1996391096369798526) -->
-    <skip />
-    <!-- no translation found for usb_summary_file_transfers (6925168380589489645) -->
-    <skip />
-    <!-- no translation found for usb_summary_tether (951190049557074535) -->
-    <skip />
-    <!-- no translation found for usb_summary_photo_transfers (665584667685030007) -->
-    <skip />
-    <!-- no translation found for usb_summary_MIDI (2399066753961085360) -->
-    <skip />
-    <!-- no translation found for usb_summary_file_transfers_power (7700800611455849806) -->
-    <skip />
-    <!-- no translation found for usb_summary_tether_power (5825335393952752238) -->
-    <skip />
-    <!-- no translation found for usb_summary_photo_transfers_power (6826058111908423069) -->
-    <skip />
-    <!-- no translation found for usb_summary_MIDI_power (3308250484012677596) -->
-    <skip />
+    <string name="usb_summary_power_only" msgid="1996391096369798526">"Chargement de l\'appareil connecté"</string>
+    <string name="usb_summary_file_transfers" msgid="6925168380589489645">"Transfert de fichiers"</string>
+    <string name="usb_summary_tether" msgid="951190049557074535">"Partage de connexion par USB"</string>
+    <string name="usb_summary_photo_transfers" msgid="665584667685030007">"PTP"</string>
+    <string name="usb_summary_MIDI" msgid="2399066753961085360">"MIDI"</string>
+    <string name="usb_summary_file_transfers_power" msgid="7700800611455849806">"Transfert de fichiers et alimentation"</string>
+    <string name="usb_summary_tether_power" msgid="5825335393952752238">"Partage de connexion par USB et alimentation"</string>
+    <string name="usb_summary_photo_transfers_power" msgid="6826058111908423069">"PTP et alimentation"</string>
+    <string name="usb_summary_MIDI_power" msgid="3308250484012677596">"MIDI et alimentation"</string>
     <string name="sms_mirroring_pref" msgid="6475043279147376031">"Duplication de messages texte"</string>
     <string name="background_check_pref" msgid="7550258400138010979">"Vérification en arrière-plan"</string>
     <string name="background_check_title" msgid="4534254315824525593">"Accès complet à l\'arrière-plan"</string>
@@ -3474,10 +3503,8 @@
     <string name="location_on_summary" msgid="4083334422422067511">"ACTIVÉ"</string>
     <string name="location_off_summary" msgid="6474350053215707957">"DÉSACTIVÉ"</string>
     <string name="backup_disabled" msgid="485189128759595412">"Sauvegardes désactivées"</string>
-    <!-- no translation found for android_version_summary (2935995161657697278) -->
-    <skip />
-    <!-- no translation found for android_version_pending_update_summary (487831391976523090) -->
-    <skip />
+    <string name="android_version_summary" msgid="2935995161657697278">"Mis à jour vers Android <xliff:g id="VERSION">%1$s</xliff:g>"</string>
+    <string name="android_version_pending_update_summary" msgid="487831391976523090">"Mise à jour disponible"</string>
     <string name="disabled_by_policy_title" msgid="627023216027648534">"Action interdite"</string>
     <string name="disabled_by_policy_title_adjust_volume" msgid="7399450998356045023">"Impossible de modifier le volume"</string>
     <string name="disabled_by_policy_title_outgoing_calls" msgid="7919816644946067058">"Les appels sont désactivés"</string>
@@ -3498,8 +3525,7 @@
     <string name="condition_hotspot_summary" msgid="3433182779269409683">"Le point d\'accès Wi-Fi mobile « <xliff:g id="ID_1">%1$s</xliff:g> » est actif. Le Wi-Fi est désactivé pour cet appareil."</string>
     <string name="condition_airplane_title" msgid="287356299107070503">"Le mode Avion est activé"</string>
     <string name="condition_airplane_summary" msgid="3738805058182535606">"Le Wi-Fi, le Bluetooth et le réseau cellulaire sont désactivés. Vous ne pouvez pas faire d\'appels téléphoniques ni vous connecter à Internet."</string>
-    <!-- no translation found for condition_zen_title (2897779738211625) -->
-    <skip />
+    <string name="condition_zen_title" msgid="2897779738211625">"Mode Ne pas déranger activé"</string>
     <string name="condition_battery_title" msgid="3272131008388575349">"Économie d\'énergie activée"</string>
     <string name="condition_battery_summary" msgid="4418839236027977450">"Les performances sont réduites. Les services de localisation et les données en arrière-plan sont désactivés."</string>
     <string name="condition_cellular_title" msgid="1327317003797575735">"Données cellulaires désactivées"</string>
@@ -3564,6 +3590,20 @@
       <item quantity="one"><xliff:g id="COUNT">%1$d</xliff:g> application est autorisée à ignorer les restrictions lorsque la fonction Économiseur de données est activée</item>
       <item quantity="other"><xliff:g id="COUNT">%1$d</xliff:g> applications sont autorisées à ignorer les restrictions lorsque la fonction Économiseur de données est activée</item>
     </plurals>
+    <!-- no translation found for data_usage_title (3659356290392241789) -->
+    <skip />
+    <!-- no translation found for data_used (5116389957228457203) -->
+    <skip />
+    <!-- no translation found for data_remaining (8998091725895502181) -->
+    <skip />
+    <!-- no translation found for cycle_left_time_text (8501602478371081001) -->
+    <skip />
+    <!-- no translation found for carrier_and_update_text (4534395723031386923) -->
+    <skip />
+    <!-- no translation found for no_carrier_update_text (6879630084452907385) -->
+    <skip />
+    <!-- no translation found for launch_mdp_app_text (7527361210375612985) -->
+    <skip />
     <string name="data_saver_title" msgid="398458827917495765">"Économiseur de données"</string>
     <string name="unrestricted_data_saver" msgid="952796077540228711">"Données sans restrictions"</string>
     <string name="restrict_background_blacklisted" msgid="3995443391711013068">"Les données en arrière-plan sont désactivées"</string>
@@ -3583,6 +3623,10 @@
     <string name="battery_saver_off_summary" msgid="8309471955051162327">"Désactivé : <xliff:g id="ID_1">%1$s</xliff:g>"</string>
     <string name="battery_saver_desc_turn_on_auto_never" msgid="6715896635178578813">"Ne jamais activer automatiquement"</string>
     <string name="battery_saver_desc_turn_on_auto_pct" msgid="7472323223085636533">"Activer automatiquement à %1$s de charge restant"</string>
+    <!-- no translation found for battery_saver_button_turn_on (3699954061337848832) -->
+    <skip />
+    <!-- no translation found for battery_saver_button_turn_off (5916996792004611890) -->
+    <skip />
     <string name="not_battery_optimizing" msgid="5362861851864837617">"L\'optimisation de la pile n\'est pas utilisée"</string>
     <string name="lockscreen_remote_input" msgid="969871538778211843">"Si l\'appareil est verrouillé, empêcher l\'entrée de réponses ou de texte dans les notifications"</string>
     <string name="default_spell_checker" msgid="8506899870026026660">"Correcteur ortho par défaut"</string>
@@ -3836,4 +3880,6 @@
     <string name="my_device_info_device_name_preference_title" msgid="7104085224684165324">"Nom de l\'appareil"</string>
     <string name="bluetooth_on_while_driving_pref" msgid="2460847604498343330">"Utiliser le Bluetooth lors de la conduite"</string>
     <string name="bluetooth_on_while_driving_summary" msgid="3196190732516898541">"Activer automatiquement le Bluetooth lorsque vous conduisez"</string>
+    <!-- no translation found for dev_android_o_battery_settings_title (2926578228655006762) -->
+    <skip />
 </resources>
diff --git a/res/values-mk/strings.xml b/res/values-mk/strings.xml
index 58a06fe..dd52d46 100644
--- a/res/values-mk/strings.xml
+++ b/res/values-mk/strings.xml
@@ -781,9 +781,7 @@
     <string name="wifi_configure_settings_preference_summary_wakeup_on" msgid="646393113104367290">"Wi‑Fi се вклучува повторно автоматски"</string>
     <string name="wifi_configure_settings_preference_summary_wakeup_off" msgid="2782566279864356713">"Wi‑Fi не се вклучува повторно автоматски"</string>
     <string name="wifi_access_points" msgid="7053990007031968609">"Wi-Fi мрежи"</string>
-    <string name="wifi_menu_wps_pbc" msgid="2668564692207863017">"Копче WPS Push"</string>
     <string name="wifi_menu_more_options" msgid="2448097861752719396">"Повеќе опции"</string>
-    <string name="wifi_menu_wps_pin" msgid="6426448256268695933">"Запис на PIN за WPS"</string>
     <string name="wifi_menu_p2p" msgid="7619851399250896797">"Wi‑Fi Direct"</string>
     <string name="wifi_menu_scan" msgid="1470911530412095868">"Скенирај"</string>
     <string name="wifi_menu_advanced" msgid="7522252991919573664">"Напредни"</string>
@@ -801,19 +799,6 @@
     <string name="wifi_show_advanced" msgid="3409422789616520979">"Напредни опции"</string>
     <string name="wifi_advanced_toggle_description_expanded" msgid="2380600578544493084">"Паѓачки список „Напредни опции“. Допрете двапати за да се собере."</string>
     <string name="wifi_advanced_toggle_description_collapsed" msgid="1463812308429197263">"Паѓачки список „Напредни опции“. Допрете двапати за да се прошири."</string>
-    <string name="wifi_wps_setup_title" msgid="8207552222481570175">"Заштитено подесување на Wi-Fi"</string>
-    <string name="wifi_wps_setup_msg" msgid="315174329121275092">"Се вклучува WPS…"</string>
-    <string name="wifi_wps_onstart_pbc" msgid="817003360936932340">"Притиснете го копчето „Заштитено поставување на Wi-Fi“ на рутерот. Тоа може да се нарекува „WPS“ или да се означи со овој симбол:"</string>
-    <string name="wifi_wps_onstart_pin" msgid="223344506445335358">"Внесете PIN <xliff:g id="NUMBER">%1$s</xliff:g> на вашиот Wi-Fi насочувач. Подесувањето може да трае и до две минути за да се заврши."</string>
-    <string name="wifi_wps_complete" msgid="2388138550456729134">"WPS успеа. Се поврзува со мрежата…"</string>
-    <string name="wifi_wps_connected" msgid="7153432445748931183">"Поврзано со Wi-Fi мрежа <xliff:g id="NETWORK_NAME">%s</xliff:g>"</string>
-    <string name="wifi_wps_in_progress" msgid="3372311348221357944">"WPS е веќе во тек и може да потрае и до две минути за да се заврши"</string>
-    <string name="wifi_wps_failed_generic" msgid="5668775022238832527">"WPS не успеа. Обидете се повторно за неколку минути."</string>
-    <string name="wifi_wps_failed_wep" msgid="2702820087105284461">"Подесувањето на безбеден безжичен рутер (WEP) не е поддржано"</string>
-    <string name="wifi_wps_failed_tkip" msgid="4282401586860713349">"Подесувањето на безбеден безжичен рутер (TKIP) не е поддржано"</string>
-    <string name="wifi_wps_failed_auth" msgid="1174614355181181958">"Автентикацијата не успеа. Обидете се повторно."</string>
-    <string name="wifi_wps_failed_overlap" msgid="5159533685596844778">"Откриена е друга WPS сесија. Обидете се повторно за неколку минути."</string>
-    <string name="wifi_wps_failed_wifi_disconnected" msgid="3829472117754104164">"Wi‑Fi е исклучена. Поставувањето на WPS е откажано."</string>
     <string name="wifi_ssid" msgid="5519636102673067319">"Име на мрежа"</string>
     <string name="wifi_ssid_hint" msgid="897593601067321355">"Внеси SSID"</string>
     <string name="wifi_security" msgid="6603611185592956936">"Безбедност"</string>
@@ -939,8 +924,10 @@
     <string name="wifi_hotspot_configure_ap_text_summary" msgid="5560680057727007011">"Точка на пристап AndroidAP WPA2 PSK"</string>
     <string name="wifi_tether_configure_ssid_default" msgid="8467525402622138547">"AndroidHotspot"</string>
     <string name="wifi_calling_settings_title" msgid="4102921303993404577">"Повикување преку Wi-Fi"</string>
-    <string name="wifi_calling_suggestion_title" msgid="9008010480466359578">"Вклучете Повици преку Wi-Fi"</string>
-    <string name="wifi_calling_suggestion_summary" msgid="4277772016570248405">"Зголемете ја покриеноста со повикување преку Wi-Fi"</string>
+    <!-- no translation found for wifi_calling_suggestion_title (7766895085362824508) -->
+    <skip />
+    <!-- no translation found for wifi_calling_suggestion_summary (6460250990899143406) -->
+    <skip />
     <string name="wifi_calling_mode_title" msgid="2164073796253284289">"Параметар за повикување"</string>
     <string name="wifi_calling_mode_dialog_title" msgid="8149690312199253909">"Режим – повикување преку Wi-Fi"</string>
     <string name="wifi_calling_roaming_mode_title" msgid="1565039047187685115">"Поставки за роаминг"</string>
@@ -1030,9 +1017,6 @@
     <string name="accessibility_work_account_title" msgid="1231830766637939527">"Работна сметка - <xliff:g id="MANAGED_BY">%s</xliff:g>"</string>
     <string name="accessibility_personal_account_title" msgid="2169071663029067826">"Лична сметка - <xliff:g id="MANAGED_BY">%s</xliff:g>"</string>
     <string name="search_settings" msgid="1910951467596035063">"Пребарај"</string>
-    <string name="search_settings_summary" msgid="9205656546570654169">"Управувај со подесувањата за пребарување и историја"</string>
-    <string name="search_settings_no_results" msgid="8799027492641230999">"Нема резултати"</string>
-    <string name="search_clear_history" msgid="4196658962573162457">"Исчисти ја историјата"</string>
     <string name="display_settings" msgid="7965901687241669598">"Приказ"</string>
     <string name="accelerometer_title" msgid="7854608399547349157">"Автоматско ротирање на екранот"</string>
     <string name="color_mode_title" msgid="9186249332902370471">"Бои"</string>
@@ -1891,6 +1875,12 @@
     <string name="accessibility_display_inversion_preference_subtitle" msgid="7052959202195368109">"Може да влијае на изведбата"</string>
     <string name="accessibility_autoclick_preference_title" msgid="7014499339068449623">"Кликнување откако покажувачот ќе престане да се движи"</string>
     <string name="accessibility_autoclick_delay_preference_title" msgid="3962261178385106006">"Одложување пред кликнување"</string>
+    <!-- no translation found for accessibility_vibration_settings_title (3453277326300320803) -->
+    <skip />
+    <!-- no translation found for accessibility_notification_vibration_title (660829933960942244) -->
+    <skip />
+    <!-- no translation found for accessibility_touch_vibration_title (7931823772673770492) -->
+    <skip />
     <string name="accessibility_service_master_switch_title" msgid="6835441300276358239">"Користи ја услугата"</string>
     <string name="accessibility_daltonizer_master_switch_title" msgid="8655284637968823154">"Користи корекција на боите"</string>
     <string name="accessibility_caption_master_switch_title" msgid="4010227386676077826">"Користи титлови"</string>
@@ -1918,6 +1908,22 @@
       <item quantity="one">Многу долго задржување (<xliff:g id="CLICK_DELAY_LABEL_1">%1$d</xliff:g> ms)</item>
       <item quantity="other">Многу долго задржување (<xliff:g id="CLICK_DELAY_LABEL_1">%1$d</xliff:g> ms)</item>
     </plurals>
+    <!-- no translation found for accessibility_vibration_summary_off (1753566394591809629) -->
+    <skip />
+    <!-- no translation found for accessibility_vibration_summary_low (7628418309029013867) -->
+    <skip />
+    <!-- no translation found for accessibility_vibration_summary_medium (3422136736880414093) -->
+    <skip />
+    <!-- no translation found for accessibility_vibration_summary_high (3239807793182635729) -->
+    <skip />
+    <!-- no translation found for accessibility_vibration_intensity_off (4613890213008630847) -->
+    <skip />
+    <!-- no translation found for accessibility_vibration_intensity_low (2017572546489862987) -->
+    <skip />
+    <!-- no translation found for accessibility_vibration_intensity_medium (3782136025830279769) -->
+    <skip />
+    <!-- no translation found for accessibility_vibration_intensity_high (2543921139337952491) -->
+    <skip />
     <string name="accessibility_menu_item_settings" msgid="3344942964710773365">"Поставки"</string>
     <string name="accessibility_feature_state_on" msgid="2864292320042673806">"Вклучено"</string>
     <string name="accessibility_feature_state_off" msgid="4172584906487070211">"Исклучено"</string>
@@ -2067,6 +2073,24 @@
     <string name="battery_tip_dialog_message" product="default" msgid="6744251070067861233">"Вашиот телефон се користел интензивно што значително ја испразнило батеријата. Батеријата е исправна.\n\n Телефонот се користел околу <xliff:g id="HOUR">%1$s</xliff:g> од последното целосно полнење.\n\n Вкупно користење:"</string>
     <string name="battery_tip_dialog_message" product="tablet" msgid="7091442312127403445">"Вашиот таблет се користел интензивно што значително ја испразнило батеријата. Батеријата е исправна.\n\n Таблетот се користел околу <xliff:g id="HOUR">%1$s</xliff:g> од последното целосно полнење.\n\n Вкупно користење:"</string>
     <string name="battery_tip_dialog_message" product="device" msgid="7621045312469814256">"Вашиот уред се користел интензивно што значително ја испразнило батеријата. Батеријата е исправна.\n\n Уредот се користел околу <xliff:g id="HOUR">%1$s</xliff:g> од последното целосно полнење.\n\n Вкупно користење:"</string>
+    <!-- no translation found for battery_tip_restrict_title (467228882789275512) -->
+    <!-- no translation found for battery_tip_restrict_handled_title (5203646029862183763) -->
+    <!-- no translation found for battery_tip_restrict_summary (9128154370135347093) -->
+    <!-- no translation found for battery_tip_restrict_handled_summary (29466713333477274) -->
+    <skip />
+    <!-- no translation found for battery_tip_restrict_app_dialog_title (8130618585820429591) -->
+    <!-- no translation found for battery_tip_restrict_app_dialog_message (5818730114373015028) -->
+    <skip />
+    <!-- no translation found for battery_tip_restrict_app_dialog_ok (8291115820018013353) -->
+    <skip />
+    <!-- no translation found for battery_tip_unrestrict_app_dialog_title (4550106794311784978) -->
+    <skip />
+    <!-- no translation found for battery_tip_unrestrict_app_dialog_message (4836135946080501395) -->
+    <skip />
+    <!-- no translation found for battery_tip_unrestrict_app_dialog_ok (6022058431218137646) -->
+    <skip />
+    <!-- no translation found for battery_tip_unrestrict_app_dialog_cancel (9062797114255859496) -->
+    <skip />
     <string name="smart_battery_manager_title" msgid="5677222263071864438">"Паметен управник со батерија"</string>
     <string name="smart_battery_title" msgid="7014692334636228916">"Автоматско управување со батерија"</string>
     <string name="smart_battery_summary" msgid="6435844879637999044">"Автоматски приспособувај го користењето на батеријата по апликација врз основа на користењето"</string>
@@ -2172,6 +2196,8 @@
     <string name="battery_detail_power_percentage" msgid="8064814503316094497">"<xliff:g id="PERCENT">%1$s</xliff:g> од вкупната употреба на апликациите (<xliff:g id="POWER">%2$d</xliff:g>mAh)"</string>
     <string name="battery_detail_info_title" msgid="8227822131405620369">"Употреба по целосно полнење"</string>
     <string name="battery_detail_manage_title" msgid="9094314252105828014">"Управување со употребата на батеријата"</string>
+    <!-- no translation found for advanced_battery_graph_subtext (5621073891377915877) -->
+    <skip />
     <string name="estimated_time_left" msgid="7514194472683370877">"Проценето преостанато време"</string>
     <string name="estimated_charging_time_left" msgid="5614442409326164691">"До целосно полнење"</string>
     <string name="estimated_time_description" msgid="8760210909000037089">"Приближното време може да се промени во зависност од употребата"</string>
@@ -2182,7 +2208,14 @@
     <string name="process_kernel_label" msgid="3916858646836739323">"Оперативен систем Android"</string>
     <string name="process_mediaserver_label" msgid="6500382062945689285">"Mediaserver"</string>
     <string name="process_dex2oat_label" msgid="2592408651060518226">"Оптимизација на апликација"</string>
-    <string name="battery_saver" msgid="8172485772238572153">"Штедач на батерија"</string>
+    <!-- no translation found for battery_saver (6002143200184768727) -->
+    <skip />
+    <!-- no translation found for battery_saver_auto_title (6896506441192920565) -->
+    <skip />
+    <!-- no translation found for battery_saver_auto_summary (8715989830471454219) -->
+    <skip />
+    <!-- no translation found for battery_saver_seekbar_title (3428789387167865312) -->
+    <skip />
     <string name="battery_saver_master_switch_title" msgid="622539414546588436">"Користи го штедачот на батерија"</string>
     <string name="battery_saver_turn_on_automatically_title" msgid="9023847300114669426">"Вклучи автоматски"</string>
     <string name="battery_saver_turn_on_automatically_never" msgid="6610846456314373">"Никогаш"</string>
@@ -2425,7 +2458,6 @@
     <string name="misc_files_selected_count" msgid="4647048020823912088">"избрани <xliff:g id="NUMBER">%1$d</xliff:g> од <xliff:g id="TOTAL">%2$d</xliff:g>"</string>
     <string name="misc_files_selected_count_bytes" msgid="2876232009069114352">"<xliff:g id="NUMBER">%1$s</xliff:g> од <xliff:g id="TOTAL">%2$s</xliff:g>"</string>
     <string name="select_all" msgid="1562774643280376715">"Избери сè"</string>
-    <string name="data_plan_usage_manage_plans_button_text" msgid="8997761990902708162">"Управувајте со пакетите"</string>
     <string name="data_usage_summary_title" msgid="3804110657238092929">"Потрошен интернет"</string>
     <string name="data_usage_app_summary_title" msgid="4147258989837459172">"Сообраќај по аплик."</string>
     <string name="data_usage_accounting" msgid="7170028915873577387">"Пресметувањето податоци на операторот може да се разликува од вашиот уред."</string>
@@ -2472,6 +2504,8 @@
     <string name="data_usage_enable_mobile" msgid="986782622560157977">"Мобилен интернет"</string>
     <string name="data_usage_enable_3g" msgid="6304006671869578254">"2G-3G податоци"</string>
     <string name="data_usage_enable_4g" msgid="3635854097335036738">"4G податоци"</string>
+    <!-- no translation found for data_roaming_enable_mobile (1523331545457578362) -->
+    <skip />
     <string name="data_usage_forground_label" msgid="7654319010655983591">"Преден план:"</string>
     <string name="data_usage_background_label" msgid="2722008379947694926">"Заднина:"</string>
     <string name="data_usage_app_settings" msgid="2279171379771253165">"Поставки на апликација"</string>
@@ -2815,8 +2849,7 @@
     <string name="app_and_notification_dashboard_title" msgid="7838365599185397539">"Апликации и известувања"</string>
     <string name="app_and_notification_dashboard_summary" msgid="2363314178802548682">"Дозволи, стандардни апликации"</string>
     <string name="account_dashboard_title" msgid="5895948991491438911">"Сметки"</string>
-    <!-- no translation found for account_dashboard_default_summary (3998347400161811075) -->
-    <skip />
+    <string name="account_dashboard_default_summary" msgid="3998347400161811075">"Нема додадени сметки"</string>
     <string name="app_default_dashboard_title" msgid="7342549305933047317">"Стандардни апликации"</string>
     <string name="system_dashboard_summary" msgid="5797743225249766685">"Јазици, време, бекап и ажурирања"</string>
     <string name="search_results_title" msgid="1796252422574886932">"Поставки"</string>
@@ -2943,6 +2976,13 @@
     <string name="zen_mode_settings_dnd_automatic_rule_app" msgid="1721179577382915270">"Дадена апликација <xliff:g id="APP_NAME">%s</xliff:g> го вклучи режимот „Не вознемирувај“ автоматски"</string>
     <string name="zen_interruption_level_priority" msgid="2078370238113347720">"Само приоритетно"</string>
     <string name="zen_mode_and_condition" msgid="4927230238450354412">"<xliff:g id="ZEN_MODE">%1$s</xliff:g>. <xliff:g id="EXIT_CONDITION">%2$s</xliff:g>"</string>
+    <!-- no translation found for zen_mode_sound_summary_on (9067685807840094102) -->
+    <skip />
+    <!-- no translation found for zen_mode_sound_summary_off_with_info (2348629457144123849) -->
+    <skip />
+    <!-- no translation found for zen_mode_sound_summary_off (4375814717589425561) -->
+    <skip />
+    <!-- no translation found for zen_mode_sound_summary_summary_off_info (8115159143760078050) -->
     <string name="sound_work_settings" msgid="6774324553228566442">"Звуци на работниот профил"</string>
     <string name="work_use_personal_sounds_title" msgid="1148331221338458874">"Користи звуци од личен профил"</string>
     <string name="work_use_personal_sounds_summary" msgid="6207040454949823153">"Звуците се исти за работниот и личниот профил"</string>
@@ -2959,20 +2999,22 @@
     <string name="other_sound_category_preference_title" msgid="2521096636124314015">"Други звуци и вибрации"</string>
     <string name="configure_notification_settings" msgid="7616737397127242615">"Известувања"</string>
     <string name="recent_notifications" msgid="5660639387705060156">"Неодамна испратени"</string>
-    <!-- no translation found for recent_notifications_see_all_title (3935564140468680831) -->
-    <skip />
+    <string name="recent_notifications_see_all_title" msgid="3935564140468680831">"Приказ на сите апликации"</string>
     <string name="advanced_section_header" msgid="8833934850242546903">"Напредни"</string>
     <string name="profile_section_header" msgid="2320848161066912001">"Известувања за работен профил"</string>
     <string name="notification_badging_title" msgid="5938709971403474078">"Дозволи точки за известување"</string>
     <string name="notification_pulse_title" msgid="1905382958860387030">"Трепкај со сијаличката"</string>
-    <string name="lock_screen_notifications_title" msgid="6173076173408887213">"На заклучениот екран"</string>
+    <!-- no translation found for lock_screen_notifications_title (2583595963286467672) -->
+    <skip />
     <string name="lock_screen_notifications_summary_show" msgid="6407527697810672847">"Прикажи ја целата содржина од известувањето"</string>
-    <string name="lock_screen_notifications_summary_hide" msgid="7891552853357258782">"Сокриј содржина на чувствителни известувања"</string>
+    <!-- no translation found for lock_screen_notifications_summary_hide (8301305044690264958) -->
+    <skip />
     <string name="lock_screen_notifications_summary_disable" msgid="859628910427886715">"Воопшто не прикажувај известувања"</string>
     <string name="lock_screen_notifications_interstitial_message" msgid="6164532459432182244">"Кога уредот е заклучен, како сакате да се прикажуваат известувањата?"</string>
     <string name="lock_screen_notifications_interstitial_title" msgid="1416589393106326972">"Известувања"</string>
     <string name="lock_screen_notifications_summary_show_profile" msgid="835870815661120772">"Прикажи ги известувањата од раб. профил целосно"</string>
-    <string name="lock_screen_notifications_summary_hide_profile" msgid="256116258285695645">"Сокриј чувствителни содржини на извест. од работа"</string>
+    <!-- no translation found for lock_screen_notifications_summary_hide_profile (2005907007779384635) -->
+    <skip />
     <string name="lock_screen_notifications_summary_disable_profile" msgid="4080720698960233358">"Не прикажувај известувања од работниот профил"</string>
     <string name="lock_screen_notifications_interstitial_message_profile" msgid="8307705621027472346">"Кога уредот е заклучен, како сакате да се прикажуваат известувањата на профилот?"</string>
     <string name="lock_screen_notifications_interstitial_title_profile" msgid="3169806586032521333">"Известувања на профилот"</string>
@@ -2983,8 +3025,9 @@
     <string name="notification_importance_title" msgid="4368578960344731828">"Однесување"</string>
     <string name="notification_importance_unspecified" msgid="6622173510486113958">"Дозволете звук"</string>
     <string name="notification_importance_blocked" msgid="7938180808339386300">"Никогаш не прикажувај известувања"</string>
-    <string name="notification_importance_min" msgid="5455049524984686275">"Без звук или визуелен прекин"</string>
-    <string name="notification_importance_low" msgid="8881468429453766553">"Без звук"</string>
+    <!-- no translation found for notification_importance_min (9054819132085066824) -->
+    <skip />
+    <string name="notification_importance_low" msgid="2445139943005315690">"Прикажи тивко"</string>
     <string name="notification_importance_default" msgid="5958338024601957516">"Испушти звук"</string>
     <string name="notification_importance_high" msgid="2082429479238228527">"Испушти звук и прикажи го на екранот"</string>
     <string name="notification_importance_high_silent" msgid="2667033773703765252">"Прикажи го на екранот"</string>
@@ -3059,7 +3102,8 @@
     <string name="notification_channel_badge_title" msgid="2240827899882847087">"Прикажи точка за известување"</string>
     <string name="app_notification_override_dnd_title" msgid="7867458246395884830">"Отфрли го Не вознемирувај"</string>
     <string name="app_notification_override_dnd_summary" msgid="3516007157020189746">"Оставете ги известувањава да продолжат да прекинуваат кога опцијата Не вознемирувај е поставена на Само приоритетни"</string>
-    <string name="app_notification_visibility_override_title" msgid="2187232730902430718">"На заклучениот екран"</string>
+    <!-- no translation found for app_notification_visibility_override_title (7821124557634786985) -->
+    <skip />
     <string name="app_notification_row_banned" msgid="5983655258784814773">"Блокирана"</string>
     <string name="app_notification_row_priority" msgid="7723839972982746568">"Приоритет"</string>
     <string name="app_notification_row_sensitive" msgid="1809610030432329940">"Чувствителна"</string>
@@ -3324,43 +3368,28 @@
     <string name="decline_remote_bugreport_action" msgid="518720235407565134">"Одбиј"</string>
     <string name="usb_use_charging_only" msgid="2180443097365214467">"Полнење на уредов"</string>
     <string name="usb_use_charging_only_desc" msgid="3066256793008540627">"Само ја полни батеријата"</string>
-    <!-- no translation found for usb_use_power_only (6449381364444187612) -->
-    <skip />
-    <!-- no translation found for usb_use_power_only_desc (5674490059427055197) -->
-    <skip />
-    <!-- no translation found for usb_use_file_transfers (1223134119354320726) -->
-    <skip />
+    <string name="usb_use_power_only" msgid="6449381364444187612">"Полнење поврзан уред"</string>
+    <string name="usb_use_power_only_desc" msgid="5674490059427055197">"Другите поставки не се достапни кога е вклучено"</string>
+    <string name="usb_use_file_transfers" msgid="1223134119354320726">"Пренос на датотеки"</string>
     <string name="usb_use_file_transfers_desc" msgid="4235764784331804488">"Пренесете ги датотеките на друг уред"</string>
-    <!-- no translation found for usb_use_photo_transfers (8192719651229326283) -->
-    <skip />
+    <string name="usb_use_photo_transfers" msgid="8192719651229326283">"PTP"</string>
     <string name="usb_use_photo_transfers_desc" msgid="2963034811151325996">"Пренесувај фотографии или датотеки ако не е подржан MTP (PTP)"</string>
-    <!-- no translation found for usb_use_tethering (3944506882789422118) -->
-    <skip />
+    <string name="usb_use_tethering" msgid="3944506882789422118">"Врзување преку USB"</string>
     <string name="usb_use_MIDI" msgid="5116404702692483166">"МИДИ"</string>
     <string name="usb_use_MIDI_desc" msgid="8473936990076693175">"Користете го уредов како MIDI"</string>
     <string name="usb_use" msgid="3372728031108932425">"Користи USB за"</string>
-    <!-- no translation found for usb_use_also (557340935190819370) -->
-    <skip />
+    <string name="usb_use_also" msgid="557340935190819370">"Користење на USB и за"</string>
     <string name="usb_pref" msgid="1400617804525116158">"USB"</string>
     <string name="usb_summary_charging_only" msgid="7544327009143659751">"Полнење на уредот"</string>
-    <!-- no translation found for usb_summary_power_only (1996391096369798526) -->
-    <skip />
-    <!-- no translation found for usb_summary_file_transfers (6925168380589489645) -->
-    <skip />
-    <!-- no translation found for usb_summary_tether (951190049557074535) -->
-    <skip />
-    <!-- no translation found for usb_summary_photo_transfers (665584667685030007) -->
-    <skip />
-    <!-- no translation found for usb_summary_MIDI (2399066753961085360) -->
-    <skip />
-    <!-- no translation found for usb_summary_file_transfers_power (7700800611455849806) -->
-    <skip />
-    <!-- no translation found for usb_summary_tether_power (5825335393952752238) -->
-    <skip />
-    <!-- no translation found for usb_summary_photo_transfers_power (6826058111908423069) -->
-    <skip />
-    <!-- no translation found for usb_summary_MIDI_power (3308250484012677596) -->
-    <skip />
+    <string name="usb_summary_power_only" msgid="1996391096369798526">"Се полни поврзаниот уред"</string>
+    <string name="usb_summary_file_transfers" msgid="6925168380589489645">"Пренос на датотеки"</string>
+    <string name="usb_summary_tether" msgid="951190049557074535">"Врзување преку USB"</string>
+    <string name="usb_summary_photo_transfers" msgid="665584667685030007">"PTP"</string>
+    <string name="usb_summary_MIDI" msgid="2399066753961085360">"MIDI"</string>
+    <string name="usb_summary_file_transfers_power" msgid="7700800611455849806">"Пренос на датотеки и полнење уред"</string>
+    <string name="usb_summary_tether_power" msgid="5825335393952752238">"Врзување преку USB и полнење уред"</string>
+    <string name="usb_summary_photo_transfers_power" msgid="6826058111908423069">"PTP и полнење уред"</string>
+    <string name="usb_summary_MIDI_power" msgid="3308250484012677596">"MIDI и полнење уред"</string>
     <string name="sms_mirroring_pref" msgid="6475043279147376031">"Отсликување SMS-пораки"</string>
     <string name="background_check_pref" msgid="7550258400138010979">"Проверка на заднината"</string>
     <string name="background_check_title" msgid="4534254315824525593">"Целосен пристап до заднината"</string>
@@ -3474,10 +3503,8 @@
     <string name="location_on_summary" msgid="4083334422422067511">"ВКЛУЧЕНО"</string>
     <string name="location_off_summary" msgid="6474350053215707957">"ИСКЛУЧЕНО"</string>
     <string name="backup_disabled" msgid="485189128759595412">"Бекапот е оневозможен"</string>
-    <!-- no translation found for android_version_summary (2935995161657697278) -->
-    <skip />
-    <!-- no translation found for android_version_pending_update_summary (487831391976523090) -->
-    <skip />
+    <string name="android_version_summary" msgid="2935995161657697278">"Ажурирано на Android <xliff:g id="VERSION">%1$s</xliff:g>"</string>
+    <string name="android_version_pending_update_summary" msgid="487831391976523090">"Достапно е ажурирање"</string>
     <string name="disabled_by_policy_title" msgid="627023216027648534">"Дејството не е дозволено"</string>
     <string name="disabled_by_policy_title_adjust_volume" msgid="7399450998356045023">"Не може да се промени јачината на звукот"</string>
     <string name="disabled_by_policy_title_outgoing_calls" msgid="7919816644946067058">"Повикувањето не е дозволено"</string>
@@ -3498,8 +3525,7 @@
     <string name="condition_hotspot_summary" msgid="3433182779269409683">"Преносливата Wi-Fi-точка на пристап <xliff:g id="ID_1">%1$s</xliff:g> е активна. Wi-Fi за овој уред е исклучен."</string>
     <string name="condition_airplane_title" msgid="287356299107070503">"Авионскиот режим е вклучен"</string>
     <string name="condition_airplane_summary" msgid="3738805058182535606">"Wi-Fi, Bluetooth и мобилната мрежа се исклучени. Не може да воспоставувате телефонски повици или да се поврзувате на интернет."</string>
-    <!-- no translation found for condition_zen_title (2897779738211625) -->
-    <skip />
+    <string name="condition_zen_title" msgid="2897779738211625">"Вклучено е „Не вознемирувај“"</string>
     <string name="condition_battery_title" msgid="3272131008388575349">"Штедачот на батерија е вклучен"</string>
     <string name="condition_battery_summary" msgid="4418839236027977450">"Изведбата е намалена. Услугите според локација и податоците од заднина се исклучени."</string>
     <string name="condition_cellular_title" msgid="1327317003797575735">"Мобилниот интернет е исклучен"</string>
@@ -3564,6 +3590,20 @@
       <item quantity="one"><xliff:g id="COUNT">%1$d</xliff:g> апликација има дозвола да користи неограничен интернет кога е вклучен Штедачот на интернет</item>
       <item quantity="other"><xliff:g id="COUNT">%1$d</xliff:g> апликации имаат дозвола да користат неограничен интернет кога е вклучен Штедачот на интернет</item>
     </plurals>
+    <!-- no translation found for data_usage_title (3659356290392241789) -->
+    <skip />
+    <!-- no translation found for data_used (5116389957228457203) -->
+    <skip />
+    <!-- no translation found for data_remaining (8998091725895502181) -->
+    <skip />
+    <!-- no translation found for cycle_left_time_text (8501602478371081001) -->
+    <skip />
+    <!-- no translation found for carrier_and_update_text (4534395723031386923) -->
+    <skip />
+    <!-- no translation found for no_carrier_update_text (6879630084452907385) -->
+    <skip />
+    <!-- no translation found for launch_mdp_app_text (7527361210375612985) -->
+    <skip />
     <string name="data_saver_title" msgid="398458827917495765">"Штедач на интернет"</string>
     <string name="unrestricted_data_saver" msgid="952796077540228711">"Неограничен интернет"</string>
     <string name="restrict_background_blacklisted" msgid="3995443391711013068">"Исклучен сообраќај во заднина"</string>
@@ -3583,6 +3623,10 @@
     <string name="battery_saver_off_summary" msgid="8309471955051162327">"Исклучен/<xliff:g id="ID_1">%1$s</xliff:g>"</string>
     <string name="battery_saver_desc_turn_on_auto_never" msgid="6715896635178578813">"Никогаш не вклучувај автоматски"</string>
     <string name="battery_saver_desc_turn_on_auto_pct" msgid="7472323223085636533">"Вклучи автоматски при %1$s батерија"</string>
+    <!-- no translation found for battery_saver_button_turn_on (3699954061337848832) -->
+    <skip />
+    <!-- no translation found for battery_saver_button_turn_off (5916996792004611890) -->
+    <skip />
     <string name="not_battery_optimizing" msgid="5362861851864837617">"Не се користи оптимизација на батеријата"</string>
     <string name="lockscreen_remote_input" msgid="969871538778211843">"Ако уредот е заклучен, спречете внесување одговори или друг текст во известувања"</string>
     <string name="default_spell_checker" msgid="8506899870026026660">"Стандард. проверка на правопис"</string>
@@ -3836,4 +3880,6 @@
     <string name="my_device_info_device_name_preference_title" msgid="7104085224684165324">"Име на уред"</string>
     <string name="bluetooth_on_while_driving_pref" msgid="2460847604498343330">"Користење Bluetooth при возење"</string>
     <string name="bluetooth_on_while_driving_summary" msgid="3196190732516898541">"Вклучување Bluetooth автоматски при возење"</string>
+    <!-- no translation found for dev_android_o_battery_settings_title (2926578228655006762) -->
+    <skip />
 </resources>
diff --git a/res/values-sw400dp/dimens.xml b/res/values-sw400dp/dimens.xml
index 8d45dd4..6a02422 100755
--- a/res/values-sw400dp/dimens.xml
+++ b/res/values-sw400dp/dimens.xml
@@ -23,8 +23,6 @@
     <dimen name="support_escalation_card_padding_end">56dp</dimen>
 
     <!-- Suggestion cards-->
-    <dimen name="suggestion_card_width_one_card">384dp</dimen>
-    <dimen name="suggestion_card_width_two_cards">188dp</dimen>
     <dimen name="suggestion_card_width_multiple_cards">180dp</dimen>
     <dimen name="suggestion_card_padding_bottom_one_card">22dp</dimen>
 
diff --git a/res/values-uz/strings.xml b/res/values-uz/strings.xml
index 0041d4c..303f7de 100644
--- a/res/values-uz/strings.xml
+++ b/res/values-uz/strings.xml
@@ -347,10 +347,8 @@
     <string name="owner_info_settings_title" msgid="5530285568897386122">"Qulflangan ekran ustidagi matn"</string>
     <string name="security_enable_widgets_title" msgid="2754833397070967846">"Vidjetlarni yoqish"</string>
     <string name="security_enable_widgets_disabled_summary" msgid="6392489775303464905">"Administrator tomonidan o‘chirilgan"</string>
-    <!-- no translation found for lockdown_settings_title (7393790212603280213) -->
-    <skip />
-    <!-- no translation found for lockdown_settings_summary (8678086272188880615) -->
-    <skip />
+    <string name="lockdown_settings_title" msgid="7393790212603280213">"Qulflash funksiyasini ko‘rsatish"</string>
+    <string name="lockdown_settings_summary" msgid="8678086272188880615">"Kengaytirilgan ruxsat va barmoq izi bilan qulfni ochishni faolsizlantiradigan quvvat tugmasi funksiyasini ko‘rsatish."</string>
     <string name="owner_info_settings_summary" msgid="7472393443779227052">"Yo‘q"</string>
     <string name="owner_info_settings_status" msgid="120407527726476378">"<xliff:g id="COUNT_0">%1$d</xliff:g> / <xliff:g id="COUNT_1">%2$d</xliff:g>"</string>
     <string name="owner_info_settings_edit_text_hint" msgid="7591869574491036360">"M-n: Alisherning Android telefoni"</string>
@@ -471,17 +469,14 @@
     <string name="crypt_keeper_data_corrupt_summary" product="tablet" msgid="840107296925798402">"Siz kiritgan parol to‘g‘ri, biroq planshetdagi ma’lumotlar shikastlangan.\n\nPlanshetdan foydalanishda davom etish uchun uning zavod sozlamalarini tiklashingiz lozim. Shundan so‘ng, Google hisobingizga zaxiralangan barcha ma’lumotlaringizni qayta tiklab olishingiz mumkin bo‘ladi."</string>
     <string name="crypt_keeper_data_corrupt_summary" product="default" msgid="8843311420059663824">"Siz kiritgan parol to‘g‘ri, biroq telefondagi ma’lumotlar shikastlangan.\n\nTelefondan foydalanishda davom etish uchun uning zavod sozlamalarini tiklashingiz lozim. Shundan so‘ng, Google hisobingizga zaxiralangan barcha ma’lumotlaringizni qayta tiklab olishingiz mumkin bo‘ladi."</string>
     <string name="crypt_keeper_switch_input_method" msgid="4168332125223483198">"Yozish usulini o‘zgartirish"</string>
-    <!-- no translation found for suggested_lock_settings_title (8195437597439375655) -->
-    <skip />
-    <!-- no translation found for suggested_lock_settings_summary (7915739444107426777) -->
-    <skip />
-    <!-- no translation found for suggested_lock_settings_summary (9202820303111653610) -->
-    <skip />
-    <!-- no translation found for suggested_lock_settings_summary (1252628838133344781) -->
-    <skip />
-    <!-- no translation found for suggested_fingerprint_lock_settings_title (414499342011664436) -->
-    <skip />
-    <string name="suggested_fingerprint_lock_settings_summary" msgid="2149569133725273864">"Barmoq izingiz bilan oching"</string>
+    <string name="suggested_lock_settings_title" msgid="8195437597439375655">"Ekran qulfini sozlash"</string>
+    <string name="suggested_lock_settings_summary" product="tablet" msgid="7915739444107426777">"Planshetingizni begonalardan himoyalang"</string>
+    <string name="suggested_lock_settings_summary" product="device" msgid="9202820303111653610">"Qurilmangizni begonalardan himoyalang"</string>
+    <string name="suggested_lock_settings_summary" product="default" msgid="1252628838133344781">"Telefoningizni begonalardan himoyalang"</string>
+    <string name="suggested_fingerprint_lock_settings_title" msgid="414499342011664436">"Barmoq izi skaneri"</string>
+    <string name="suggested_fingerprint_lock_settings_summary" product="tablet" msgid="2149569133725273864">"Barmoq izingiz bilan oching"</string>
+    <string name="suggested_fingerprint_lock_settings_summary" product="device" msgid="2149569133725273864">"Barmoq izingiz bilan oching"</string>
+    <string name="suggested_fingerprint_lock_settings_summary" product="default" msgid="2149569133725273864">"Barmoq izingiz bilan oching"</string>
     <string name="lock_settings_picker_title" msgid="1095755849152582712">"Ekran qulfini tanlang"</string>
     <string name="lock_settings_picker_title_profile" msgid="8822511284992306796">"Ishchi profil qulfini tanlang"</string>
     <string name="setup_lock_settings_picker_title" product="tablet" msgid="90329443364067215">"Planshetingizni himoyalang"</string>
@@ -786,9 +781,7 @@
     <string name="wifi_configure_settings_preference_summary_wakeup_on" msgid="646393113104367290">"Wi-Fi avtomatik tarzda qayta yoqiladi"</string>
     <string name="wifi_configure_settings_preference_summary_wakeup_off" msgid="2782566279864356713">"Wi‑Fi avtomatik tarzda qayta yoqilmaydi"</string>
     <string name="wifi_access_points" msgid="7053990007031968609">"Wi‑Fi tarmoqlari"</string>
-    <string name="wifi_menu_wps_pbc" msgid="2668564692207863017">"WPS tugmasi"</string>
     <string name="wifi_menu_more_options" msgid="2448097861752719396">"Ko‘proq tanlamalar"</string>
-    <string name="wifi_menu_wps_pin" msgid="6426448256268695933">"WPS PIN-kodini kiritish"</string>
     <string name="wifi_menu_p2p" msgid="7619851399250896797">"Wi‑Fi Direct"</string>
     <string name="wifi_menu_scan" msgid="1470911530412095868">"Qidiruv"</string>
     <string name="wifi_menu_advanced" msgid="7522252991919573664">"Qo‘shimcha funksiyalar"</string>
@@ -806,19 +799,6 @@
     <string name="wifi_show_advanced" msgid="3409422789616520979">"Kengaytirilgan sozlamalar"</string>
     <string name="wifi_advanced_toggle_description_expanded" msgid="2380600578544493084">"Qo‘shimcha parametrlar pastga ochiluvchi ro‘yxatda joylashgan. Yig‘ish uchun ikki marta bosing."</string>
     <string name="wifi_advanced_toggle_description_collapsed" msgid="1463812308429197263">"Qo‘shimcha parametrlar pastga ochiluvchi ro‘yxatda joylashgan. Yoyish uchun ikki marta bosing."</string>
-    <string name="wifi_wps_setup_title" msgid="8207552222481570175">"Wi‑Fi himoyalangan sozlash"</string>
-    <string name="wifi_wps_setup_msg" msgid="315174329121275092">"WPS‘ni boshlamoqda…"</string>
-    <string name="wifi_wps_onstart_pbc" msgid="817003360936932340">"Routerdagi “Wi‑Fi xavfsiz sozlash” tugmasini bosing. U “WPS” deb nomlangan bo‘lishi yoki quyidagi belgi bilan ko‘rsatilgan bo‘lishi mumkin:"</string>
-    <string name="wifi_wps_onstart_pin" msgid="223344506445335358">"Wi-Fi routerdagi <xliff:g id="NUMBER">%1$s</xliff:g> PIN-kodini kiriting. Sozlash ikki daqiqagacha vaqt oladi."</string>
-    <string name="wifi_wps_complete" msgid="2388138550456729134">"WPS muvaffaqiyatli amalga oshdi. Tarmoqqa ulanmoqda…"</string>
-    <string name="wifi_wps_connected" msgid="7153432445748931183">"<xliff:g id="NETWORK_NAME">%s</xliff:g> Wi-Fi tarmog‘iga ulangan"</string>
-    <string name="wifi_wps_in_progress" msgid="3372311348221357944">"WPS allaqachon bajarilmoqda va u taxminan 2 daqiqada yakunlanadi"</string>
-    <string name="wifi_wps_failed_generic" msgid="5668775022238832527">"WPS bajarilmadi. Iltimos, bir necha daqiqadan so‘ng yana takrorlang."</string>
-    <string name="wifi_wps_failed_wep" msgid="2702820087105284461">"Simsiz router xavfsizlik sozlamasi (WEP) qo‘llab-quvvatlanmaydi"</string>
-    <string name="wifi_wps_failed_tkip" msgid="4282401586860713349">"Simsiz router xavfsizlik sozlamasi (TKIP) qo‘llab-quvvatlanmaydi"</string>
-    <string name="wifi_wps_failed_auth" msgid="1174614355181181958">"Tasdiqlanmadi. Iltimos, yana takrorlang."</string>
-    <string name="wifi_wps_failed_overlap" msgid="5159533685596844778">"Boshqa WPS sessiyasi aniqlandi. Iltimos, bir necha daqiqadan so‘ng yana takrorlang."</string>
-    <string name="wifi_wps_failed_wifi_disconnected" msgid="3829472117754104164">"Wi‑Fi aloqasi uzildi. WPS parametrini sozlash bekor qilindi."</string>
     <string name="wifi_ssid" msgid="5519636102673067319">"Tarmoq nomi"</string>
     <string name="wifi_ssid_hint" msgid="897593601067321355">"Tarmoq nomini (SSID) kiriting"</string>
     <string name="wifi_security" msgid="6603611185592956936">"Himoya"</string>
@@ -944,8 +924,9 @@
     <string name="wifi_hotspot_configure_ap_text_summary" msgid="5560680057727007011">"AndroidAP WPA2 PSK hotspot"</string>
     <string name="wifi_tether_configure_ssid_default" msgid="8467525402622138547">"AndroidHotspot"</string>
     <string name="wifi_calling_settings_title" msgid="4102921303993404577">"Wi-Fi qo‘ng‘iroq"</string>
-    <string name="wifi_calling_suggestion_title" msgid="9008010480466359578">"Wi-Fi qo‘ng‘iroqni yoqing"</string>
-    <!-- no translation found for wifi_calling_suggestion_summary (4277772016570248405) -->
+    <!-- no translation found for wifi_calling_suggestion_title (7766895085362824508) -->
+    <skip />
+    <!-- no translation found for wifi_calling_suggestion_summary (6460250990899143406) -->
     <skip />
     <string name="wifi_calling_mode_title" msgid="2164073796253284289">"Qo‘ng‘iroqlar sozlamalari"</string>
     <string name="wifi_calling_mode_dialog_title" msgid="8149690312199253909">"Wi-Fi qo‘ng‘iroq rejimi"</string>
@@ -1036,9 +1017,6 @@
     <string name="accessibility_work_account_title" msgid="1231830766637939527">"Ishchi hisob – <xliff:g id="MANAGED_BY">%s</xliff:g>"</string>
     <string name="accessibility_personal_account_title" msgid="2169071663029067826">"Shaxsiy hisob – <xliff:g id="MANAGED_BY">%s</xliff:g>"</string>
     <string name="search_settings" msgid="1910951467596035063">"Qidiruv"</string>
-    <string name="search_settings_summary" msgid="9205656546570654169">"Qidiruv sozlamalari va tarix boshqaruvi"</string>
-    <string name="search_settings_no_results" msgid="8799027492641230999">"Hech narsa topilmadi"</string>
-    <string name="search_clear_history" msgid="4196658962573162457">"Jurnalni tozalash"</string>
     <string name="display_settings" msgid="7965901687241669598">"Ekran"</string>
     <string name="accelerometer_title" msgid="7854608399547349157">"Ekranning avtomatik burilishi"</string>
     <string name="color_mode_title" msgid="9186249332902370471">"Ranglar"</string>
@@ -1199,8 +1177,7 @@
     <string name="status_network_type" msgid="3279383550222116235">"Mobil tarmoq turi"</string>
     <string name="status_latest_area_info" msgid="7222470836568238054">"Operator ma‘lumoti"</string>
     <string name="status_data_state" msgid="5503181397066522950">"Mobil tarmoq ahvoli"</string>
-    <!-- no translation found for status_esim_id (6456255368300906317) -->
-    <skip />
+    <string name="status_esim_id" msgid="6456255368300906317">"EID"</string>
     <string name="status_service_state" msgid="2323931627519429503">"Xizmat holati"</string>
     <string name="status_signal_strength" msgid="3732655254188304547">"Signal darajasi"</string>
     <string name="status_roaming" msgid="2638800467430913403">"Rouming"</string>
@@ -1388,8 +1365,7 @@
     <string name="reset_network_title" msgid="6166025966016873843">"Wi-Fi, mobil internet va Bluetooth parametrlarini tiklash"</string>
     <string name="reset_network_desc" msgid="5547979398298881406">"Bu barcha tarmoq sozlamalarini, jumladan, mazkur sozlamalarni asliga qaytaradi:\n\n"<li>"Wi‑Fi"</li>\n<li>"Mobil internet"</li>\n<li>"Bluetooth"</li></string>
     <string name="reset_esim_title" msgid="5914265121343650792">"Shuningdek, eSIM kartalar asliga qaytarilsin"</string>
-    <!-- no translation found for reset_esim_desc (6412324670559060446) -->
-    <skip />
+    <string name="reset_esim_desc" msgid="6412324670559060446">"Telefondan barcha eSIM kartalarni tozalash. Bunda mobil xizmat tarif rejalari bekor qilinmaydi. Aloqa operatoriga murojaat qilib eSIMni qayta yuklab olishingiz mumkin."</string>
     <string name="reset_network_button_text" msgid="2035676527471089853">"Sozlamalarni tiklash"</string>
     <string name="reset_network_final_desc" msgid="6388371121099245116">"Barcha tarmoq sozlamalari qayta tiklansinmi? Bu amalni ortga qaytarib bo‘lmaydi!"</string>
     <string name="reset_network_final_button_text" msgid="1797434793741744635">"Sozlamalarni tiklash"</string>
@@ -1899,6 +1875,12 @@
     <string name="accessibility_display_inversion_preference_subtitle" msgid="7052959202195368109">"Unumdorligiga ta’sir qilishi mumkin"</string>
     <string name="accessibility_autoclick_preference_title" msgid="7014499339068449623">"Kursor harakatlanishdan to‘xtagandan keyin bosing"</string>
     <string name="accessibility_autoclick_delay_preference_title" msgid="3962261178385106006">"Bosishdan oldin biroz kuting"</string>
+    <!-- no translation found for accessibility_vibration_settings_title (3453277326300320803) -->
+    <skip />
+    <!-- no translation found for accessibility_notification_vibration_title (660829933960942244) -->
+    <skip />
+    <!-- no translation found for accessibility_touch_vibration_title (7931823772673770492) -->
+    <skip />
     <string name="accessibility_service_master_switch_title" msgid="6835441300276358239">"Xizmatdan foydalanish"</string>
     <string name="accessibility_daltonizer_master_switch_title" msgid="8655284637968823154">"Rangni tuzatish funksiyasidan foydalanish"</string>
     <string name="accessibility_caption_master_switch_title" msgid="4010227386676077826">"Taglavhalardan foydalanish"</string>
@@ -1926,6 +1908,22 @@
       <item quantity="other">Juda uzoq kechikish bilan (<xliff:g id="CLICK_DELAY_LABEL_1">%1$d</xliff:g> ms)</item>
       <item quantity="one">Juda uzoq kechikish bilan (<xliff:g id="CLICK_DELAY_LABEL_0">%1$d</xliff:g> ms)</item>
     </plurals>
+    <!-- no translation found for accessibility_vibration_summary_off (1753566394591809629) -->
+    <skip />
+    <!-- no translation found for accessibility_vibration_summary_low (7628418309029013867) -->
+    <skip />
+    <!-- no translation found for accessibility_vibration_summary_medium (3422136736880414093) -->
+    <skip />
+    <!-- no translation found for accessibility_vibration_summary_high (3239807793182635729) -->
+    <skip />
+    <!-- no translation found for accessibility_vibration_intensity_off (4613890213008630847) -->
+    <skip />
+    <!-- no translation found for accessibility_vibration_intensity_low (2017572546489862987) -->
+    <skip />
+    <!-- no translation found for accessibility_vibration_intensity_medium (3782136025830279769) -->
+    <skip />
+    <!-- no translation found for accessibility_vibration_intensity_high (2543921139337952491) -->
+    <skip />
     <string name="accessibility_menu_item_settings" msgid="3344942964710773365">"Sozlamalar"</string>
     <string name="accessibility_feature_state_on" msgid="2864292320042673806">"Yoniq"</string>
     <string name="accessibility_feature_state_off" msgid="4172584906487070211">"O‘chiq"</string>
@@ -2089,6 +2087,24 @@
     <!-- String.format failed for translation -->
     <!-- no translation found for battery_tip_dialog_message (7621045312469814256) -->
     <skip />
+    <!-- no translation found for battery_tip_restrict_title (467228882789275512) -->
+    <!-- no translation found for battery_tip_restrict_handled_title (5203646029862183763) -->
+    <!-- no translation found for battery_tip_restrict_summary (9128154370135347093) -->
+    <!-- no translation found for battery_tip_restrict_handled_summary (29466713333477274) -->
+    <skip />
+    <!-- no translation found for battery_tip_restrict_app_dialog_title (8130618585820429591) -->
+    <!-- no translation found for battery_tip_restrict_app_dialog_message (5818730114373015028) -->
+    <skip />
+    <!-- no translation found for battery_tip_restrict_app_dialog_ok (8291115820018013353) -->
+    <skip />
+    <!-- no translation found for battery_tip_unrestrict_app_dialog_title (4550106794311784978) -->
+    <skip />
+    <!-- no translation found for battery_tip_unrestrict_app_dialog_message (4836135946080501395) -->
+    <skip />
+    <!-- no translation found for battery_tip_unrestrict_app_dialog_ok (6022058431218137646) -->
+    <skip />
+    <!-- no translation found for battery_tip_unrestrict_app_dialog_cancel (9062797114255859496) -->
+    <skip />
     <string name="smart_battery_manager_title" msgid="5677222263071864438">"Batareya quvvatini tejash"</string>
     <string name="smart_battery_title" msgid="7014692334636228916">"Energiya iste’molini avtomatik nazorat qilish"</string>
     <string name="smart_battery_summary" msgid="6435844879637999044">"Ilovalarning energiya iste’molini avtomatik nazorat qilish"</string>
@@ -2200,6 +2216,8 @@
     <!-- no translation found for battery_detail_info_title (8227822131405620369) -->
     <skip />
     <string name="battery_detail_manage_title" msgid="9094314252105828014">"Batareya sarfini boshqarish"</string>
+    <!-- no translation found for advanced_battery_graph_subtext (5621073891377915877) -->
+    <skip />
     <string name="estimated_time_left" msgid="7514194472683370877">"Taxminiy qolgan vaqt"</string>
     <string name="estimated_charging_time_left" msgid="5614442409326164691">"Quvvati to‘lishigacha qolgan vaqt"</string>
     <string name="estimated_time_description" msgid="8760210909000037089">"Hisob-kitob natijasi foydalanish intensivligiga qarab o‘zgarishi mumkin"</string>
@@ -2210,7 +2228,14 @@
     <string name="process_kernel_label" msgid="3916858646836739323">"Android OS"</string>
     <string name="process_mediaserver_label" msgid="6500382062945689285">"Mediaserver"</string>
     <string name="process_dex2oat_label" msgid="2592408651060518226">"Ilovalarni optimallashtirish"</string>
-    <string name="battery_saver" msgid="8172485772238572153">"Quvvat tejash"</string>
+    <!-- no translation found for battery_saver (6002143200184768727) -->
+    <skip />
+    <!-- no translation found for battery_saver_auto_title (6896506441192920565) -->
+    <skip />
+    <!-- no translation found for battery_saver_auto_summary (8715989830471454219) -->
+    <skip />
+    <!-- no translation found for battery_saver_seekbar_title (3428789387167865312) -->
+    <skip />
     <string name="battery_saver_master_switch_title" msgid="622539414546588436">"Quvvat tejash funksiyasidan foydalanish"</string>
     <string name="battery_saver_turn_on_automatically_title" msgid="9023847300114669426">"Avtomatik yoqish"</string>
     <string name="battery_saver_turn_on_automatically_never" msgid="6610846456314373">"Hech qachon"</string>
@@ -2399,12 +2424,9 @@
     <string name="sync_is_failing" msgid="1591561768344128377">"Sinxronizatsiyada muammo bor. Tez orada qayta tiklanadi."</string>
     <string name="add_account_label" msgid="7811707265834013767">"Hisob qo‘shish"</string>
     <string name="managed_profile_not_available_label" msgid="852263300911325904">"Ishchi profil hali mavjud emas"</string>
-    <!-- no translation found for work_mode_label (7157582467956920750) -->
-    <skip />
-    <!-- no translation found for work_mode_on_summary (3628349169847990263) -->
-    <skip />
-    <!-- no translation found for work_mode_off_summary (2657138190560082508) -->
-    <skip />
+    <string name="work_mode_label" msgid="7157582467956920750">"Ishchi profil"</string>
+    <string name="work_mode_on_summary" msgid="3628349169847990263">"Tashkilotingiz tomonidan boshqariladi"</string>
+    <string name="work_mode_off_summary" msgid="2657138190560082508">"Ilovalar va bildirishnomalar o‘chiq"</string>
     <string name="remove_managed_profile_label" msgid="3856519337797285325">"Ishchi profilni o‘chirish"</string>
     <string name="background_data" msgid="5779592891375473817">"Ma’lumotlarni fonda yuklash"</string>
     <string name="background_data_summary" msgid="8328521479872763452">"Ilovalar sinxronlanishi, ma’lumotlarni istalgan paytda jo‘natishi va qabul qilishi mumkin"</string>
@@ -2456,7 +2478,6 @@
     <string name="misc_files_selected_count" msgid="4647048020823912088">"Tanlandi: <xliff:g id="NUMBER">%1$d</xliff:g>/<xliff:g id="TOTAL">%2$d</xliff:g>"</string>
     <string name="misc_files_selected_count_bytes" msgid="2876232009069114352">"<xliff:g id="TOTAL">%2$s</xliff:g>dan <xliff:g id="NUMBER">%1$s</xliff:g>tasi"</string>
     <string name="select_all" msgid="1562774643280376715">"Hammasini belgilash"</string>
-    <string name="data_plan_usage_manage_plans_button_text" msgid="8997761990902708162">"Tarif rejalarini boshqarish"</string>
     <string name="data_usage_summary_title" msgid="3804110657238092929">"Trafik sarfi"</string>
     <string name="data_usage_app_summary_title" msgid="4147258989837459172">"Ilova sarflagan trafik"</string>
     <string name="data_usage_accounting" msgid="7170028915873577387">"Aloqa operatorining hisob-kitobi qurilmanikidan farq qilishi mumkin."</string>
@@ -2503,6 +2524,8 @@
     <string name="data_usage_enable_mobile" msgid="986782622560157977">"Mobil trafik"</string>
     <string name="data_usage_enable_3g" msgid="6304006671869578254">"2G-3G trafik"</string>
     <string name="data_usage_enable_4g" msgid="3635854097335036738">"4G trafik"</string>
+    <!-- no translation found for data_roaming_enable_mobile (1523331545457578362) -->
+    <skip />
     <string name="data_usage_forground_label" msgid="7654319010655983591">"Faol rejim:"</string>
     <string name="data_usage_background_label" msgid="2722008379947694926">"Orqa fon rejimi:"</string>
     <string name="data_usage_app_settings" msgid="2279171379771253165">"Ilova sozlamalari"</string>
@@ -2655,8 +2678,7 @@
       <item quantity="other">Sertifikatlarni tekshirish</item>
       <item quantity="one">Sertifikatni tekshirish</item>
     </plurals>
-    <!-- no translation found for user_settings_title (3493908927709169019) -->
-    <skip />
+    <string name="user_settings_title" msgid="3493908927709169019">"Bir nechta foydalanuvchi"</string>
     <string name="user_list_title" msgid="7937158411137563543">"Foydalanuvchilar &amp; profillar"</string>
     <string name="user_add_user_or_profile_menu" msgid="6923838875175259418">"Foydalanuvchi yoki profil qo‘shish"</string>
     <string name="user_add_user_menu" msgid="1675956975014862382">"Foydalanuvchi qo‘shish"</string>
@@ -2846,8 +2868,8 @@
     <string name="connected_devices_dashboard_no_nfc_summary" msgid="9106040742715366495">"Bluetooth, Cast"</string>
     <string name="app_and_notification_dashboard_title" msgid="7838365599185397539">"Ilovalar va bildirishnomalar"</string>
     <string name="app_and_notification_dashboard_summary" msgid="2363314178802548682">"Ruxsatnomalar, birlamchi ilovalar"</string>
-    <!-- no translation found for account_dashboard_title (5895948991491438911) -->
-    <skip />
+    <string name="account_dashboard_title" msgid="5895948991491438911">"Hisoblar"</string>
+    <string name="account_dashboard_default_summary" msgid="3998347400161811075">"Hech qanday hisob qo‘shilmagan"</string>
     <string name="app_default_dashboard_title" msgid="7342549305933047317">"Birlamchi ilovalar"</string>
     <string name="system_dashboard_summary" msgid="5797743225249766685">"Tillar, vaqt, zaxira, yangilanishlar"</string>
     <string name="search_results_title" msgid="1796252422574886932">"Sozlamalar"</string>
@@ -2901,6 +2923,7 @@
     <string name="keywords_sim_status" msgid="1474422416860990564">"tarmoq, mobil tarmoq holati, xizmat holati, signal kuchi, mobil tarmoq turi, rouming, iccid"</string>
     <string name="keywords_model_and_hardware" msgid="1459248377212829642">"seriya raqami, apparat versiyasi"</string>
     <string name="keywords_android_version" msgid="9069747153590902819">"android tizimi xavfsizligi uchun yangilanish, aloqa moduli versiyasi, yadro versiyasi"</string>
+    <string name="keywords_ambient_display_screen" msgid="5874969496073249362">"Ekranning avtomatik yonishi, ekran qulfi"</string>
     <string name="setup_wifi_nfc_tag" msgid="9028353016222911016">"Wi-Fi’ni sozlash u-n NFC yorliq"</string>
     <string name="write_tag" msgid="8571858602896222537">"Yozish"</string>
     <string name="status_awaiting_tap" msgid="2130145523773160617">"Yozish uchun yorliq ustiga bosing…"</string>
@@ -2954,10 +2977,8 @@
     <string name="zen_mode_automation_settings_title" msgid="2517800938791944915">"Avtomatik yoqish"</string>
     <string name="zen_mode_automation_settings_page_title" msgid="7069221762714457987">"Avtomatik qoidalar"</string>
     <string name="zen_mode_automatic_rule_settings_page_title" msgid="9041488774587594301">"Avtomatik qoida"</string>
-    <!-- no translation found for zen_mode_automation_suggestion_title (4321254843908888574) -->
-    <skip />
-    <!-- no translation found for zen_mode_automation_suggestion_summary (6223252025075862701) -->
-    <skip />
+    <string name="zen_mode_automation_suggestion_title" msgid="4321254843908888574">"Muayyan vaqtlarda ovozsiz qilish"</string>
+    <string name="zen_mode_automation_suggestion_summary" msgid="6223252025075862701">"Bezovta qilmaslik qoidalari"</string>
     <string name="zen_mode_use_automatic_rule" msgid="4509513632574025380">"Qoidadan foydalanish"</string>
     <string name="zen_mode_option_important_interruptions" msgid="3903928008177972500">"Faqat muhimlari"</string>
     <string name="zen_mode_option_alarms" msgid="5785372117288803600">"Faqat signallar"</string>
@@ -2975,6 +2996,13 @@
     <string name="zen_mode_settings_dnd_automatic_rule_app" msgid="1721179577382915270">"Bezovta qilinmasin rejimi <xliff:g id="APP_NAME">%s</xliff:g> ilovasi tomonidan yoqilgan"</string>
     <string name="zen_interruption_level_priority" msgid="2078370238113347720">"Faqat muhimlari"</string>
     <string name="zen_mode_and_condition" msgid="4927230238450354412">"<xliff:g id="ZEN_MODE">%1$s</xliff:g>. <xliff:g id="EXIT_CONDITION">%2$s</xliff:g>"</string>
+    <!-- no translation found for zen_mode_sound_summary_on (9067685807840094102) -->
+    <skip />
+    <!-- no translation found for zen_mode_sound_summary_off_with_info (2348629457144123849) -->
+    <skip />
+    <!-- no translation found for zen_mode_sound_summary_off (4375814717589425561) -->
+    <skip />
+    <!-- no translation found for zen_mode_sound_summary_summary_off_info (8115159143760078050) -->
     <string name="sound_work_settings" msgid="6774324553228566442">"Ishchi profil ovozlari"</string>
     <string name="work_use_personal_sounds_title" msgid="1148331221338458874">"Shaxsiy profil ovozlaridan foydalanish"</string>
     <string name="work_use_personal_sounds_summary" msgid="6207040454949823153">"Tovushlar ishchi va shaxsiy profillar uchun bir xil"</string>
@@ -2991,18 +3019,22 @@
     <string name="other_sound_category_preference_title" msgid="2521096636124314015">"Boshqa tovush va tebranishlar"</string>
     <string name="configure_notification_settings" msgid="7616737397127242615">"Bildirishnomalar"</string>
     <string name="recent_notifications" msgid="5660639387705060156">"Yaqinda yuborilgan"</string>
+    <string name="recent_notifications_see_all_title" msgid="3935564140468680831">"Barcha ilovalar"</string>
     <string name="advanced_section_header" msgid="8833934850242546903">"Kengaytirilgan sozlamalar"</string>
     <string name="profile_section_header" msgid="2320848161066912001">"Ishga oid bildirishnomalar"</string>
     <string name="notification_badging_title" msgid="5938709971403474078">"Bildirishnoma belgisi"</string>
     <string name="notification_pulse_title" msgid="1905382958860387030">"Indikator"</string>
-    <string name="lock_screen_notifications_title" msgid="6173076173408887213">"Qulflangan ekranda"</string>
+    <!-- no translation found for lock_screen_notifications_title (2583595963286467672) -->
+    <skip />
     <string name="lock_screen_notifications_summary_show" msgid="6407527697810672847">"Bildirishnomalar to‘liq chiqsin"</string>
-    <string name="lock_screen_notifications_summary_hide" msgid="7891552853357258782">"Maxfiy axborotlar berkitilsin"</string>
+    <!-- no translation found for lock_screen_notifications_summary_hide (8301305044690264958) -->
+    <skip />
     <string name="lock_screen_notifications_summary_disable" msgid="859628910427886715">"Bildirishnomalar chiqmasin"</string>
     <string name="lock_screen_notifications_interstitial_message" msgid="6164532459432182244">"Qurilmangiz qulflanganda, bildirishnomalar qanday ko‘rsatilsin?"</string>
     <string name="lock_screen_notifications_interstitial_title" msgid="1416589393106326972">"Bildirishnomalar"</string>
     <string name="lock_screen_notifications_summary_show_profile" msgid="835870815661120772">"Ishchi bildirishnomalar to‘liq ko‘rsatilsin"</string>
-    <string name="lock_screen_notifications_summary_hide_profile" msgid="256116258285695645">"Maxfiy ishchi profil bildirishnomalari berkitilsin"</string>
+    <!-- no translation found for lock_screen_notifications_summary_hide_profile (2005907007779384635) -->
+    <skip />
     <string name="lock_screen_notifications_summary_disable_profile" msgid="4080720698960233358">"Ishchi profil bildirishnomalari ko‘rsatilmasin"</string>
     <string name="lock_screen_notifications_interstitial_message_profile" msgid="8307705621027472346">"Qurilmangiz qulflanganda, profil bildirishnomalari qanday ko‘rsatilsin?"</string>
     <string name="lock_screen_notifications_interstitial_title_profile" msgid="3169806586032521333">"Profil bildirishnomalari"</string>
@@ -3013,8 +3045,9 @@
     <string name="notification_importance_title" msgid="4368578960344731828">"Xatti-harakatlar"</string>
     <string name="notification_importance_unspecified" msgid="6622173510486113958">"Ovozga ruxsat berish"</string>
     <string name="notification_importance_blocked" msgid="7938180808339386300">"Bildirishnomalar hech qachon ko‘rsatilmasin"</string>
-    <string name="notification_importance_min" msgid="5455049524984686275">"Bildirishnomalarsiz"</string>
-    <string name="notification_importance_low" msgid="8881468429453766553">"Ovozsiz"</string>
+    <!-- no translation found for notification_importance_min (9054819132085066824) -->
+    <skip />
+    <string name="notification_importance_low" msgid="2445139943005315690">"Ovozsiz"</string>
     <string name="notification_importance_default" msgid="5958338024601957516">"Ovozli"</string>
     <string name="notification_importance_high" msgid="2082429479238228527">"Ovoz va qalqib chiquvchi oyna"</string>
     <string name="notification_importance_high_silent" msgid="2667033773703765252">"Ekranga qalqib chiqish"</string>
@@ -3089,7 +3122,8 @@
     <string name="notification_channel_badge_title" msgid="2240827899882847087">"Bildirishnoma belgisini ko‘rsatish"</string>
     <string name="app_notification_override_dnd_title" msgid="7867458246395884830">"Bezovta qilinmasin rejimi ustidan yozish"</string>
     <string name="app_notification_override_dnd_summary" msgid="3516007157020189746">"Bezovta qilinmasin rejimida faqat muhim bildirishnomalarga ruxsat berilgan bo‘lsa, ushbu bildirishnomalarga ham ruxsat beriladi"</string>
-    <string name="app_notification_visibility_override_title" msgid="2187232730902430718">"Qulflangan ekranda"</string>
+    <!-- no translation found for app_notification_visibility_override_title (7821124557634786985) -->
+    <skip />
     <string name="app_notification_row_banned" msgid="5983655258784814773">"Bloklangan"</string>
     <string name="app_notification_row_priority" msgid="7723839972982746568">"Muhimlik darajasi"</string>
     <string name="app_notification_row_sensitive" msgid="1809610030432329940">"Maxfiy"</string>
@@ -3354,21 +3388,28 @@
     <string name="decline_remote_bugreport_action" msgid="518720235407565134">"Rad etish"</string>
     <string name="usb_use_charging_only" msgid="2180443097365214467">"Shu qurilmani quvvatlash"</string>
     <string name="usb_use_charging_only_desc" msgid="3066256793008540627">"Faqat shu qurilmani quvvatlash"</string>
-    <string name="usb_use_power_only" msgid="6426550616883919530">"Quvvat uzatish"</string>
-    <string name="usb_use_power_only_desc" msgid="3461232831015575152">"Boshqa ulangan qurilmani quvvatlash. Faqat USB orqali quvvatlash mumkin bo‘lgan qurilmalarda ishlaydi."</string>
-    <string name="usb_use_file_transfers" msgid="7409600791007250137">"Fayl uzatish"</string>
+    <string name="usb_use_power_only" msgid="6449381364444187612">"Ulangan qurilma quvvatlanmoqda"</string>
+    <string name="usb_use_power_only_desc" msgid="5674490059427055197">"Yoniqligida boshqa sozlamalar ishlamaydi"</string>
+    <string name="usb_use_file_transfers" msgid="1223134119354320726">"Fayl uzatish"</string>
     <string name="usb_use_file_transfers_desc" msgid="4235764784331804488">"Boshqa qurilmaga fayl o‘tkazish"</string>
-    <string name="usb_use_photo_transfers" msgid="7794775645350330454">"Rasm uzatish (PTP)"</string>
+    <string name="usb_use_photo_transfers" msgid="8192719651229326283">"PTP"</string>
     <string name="usb_use_photo_transfers_desc" msgid="2963034811151325996">"Agar MTP qo‘llab-quvvatlanmasa, surat yoki fayllarni o‘tkazish (PTP)"</string>
-    <string name="usb_use_MIDI" msgid="870922185938298263">"MIDI sifatida foydalanish"</string>
+    <string name="usb_use_tethering" msgid="3944506882789422118">"USB modem"</string>
+    <string name="usb_use_MIDI" msgid="5116404702692483166">"MIDI"</string>
     <string name="usb_use_MIDI_desc" msgid="8473936990076693175">"Bu qurilmadan MIDI sifatida foydalanish"</string>
-    <string name="usb_use" msgid="3256040963685055320">"USB ulanish maqsadi"</string>
+    <string name="usb_use" msgid="3372728031108932425">"USBdan foydalanish"</string>
+    <string name="usb_use_also" msgid="557340935190819370">"USB ulanish maqsadi"</string>
     <string name="usb_pref" msgid="1400617804525116158">"USB"</string>
     <string name="usb_summary_charging_only" msgid="7544327009143659751">"Shu qurilmani quvvatlash"</string>
-    <string name="usb_summary_power_only" msgid="3629517713817003738">"Quvvat uzatish"</string>
-    <string name="usb_summary_file_transfers" msgid="6435943692610175111">"Fayllarni o‘tkazish"</string>
-    <string name="usb_summary_photo_transfers" msgid="8440204169576585250">"Rasm uzatish (PTP)"</string>
-    <string name="usb_summary_MIDI" msgid="5687906612187885908">"MIDI sifatida foydalanish"</string>
+    <string name="usb_summary_power_only" msgid="1996391096369798526">"Ulangan qurilma quvvatlanmoqda"</string>
+    <string name="usb_summary_file_transfers" msgid="6925168380589489645">"Fayl uzatish"</string>
+    <string name="usb_summary_tether" msgid="951190049557074535">"USB modem"</string>
+    <string name="usb_summary_photo_transfers" msgid="665584667685030007">"PTP"</string>
+    <string name="usb_summary_MIDI" msgid="2399066753961085360">"MIDI"</string>
+    <string name="usb_summary_file_transfers_power" msgid="7700800611455849806">"Fayl va quvvat uzatish"</string>
+    <string name="usb_summary_tether_power" msgid="5825335393952752238">"USB modem va quvvat uzatish"</string>
+    <string name="usb_summary_photo_transfers_power" msgid="6826058111908423069">"PTP va quvvat uzatish"</string>
+    <string name="usb_summary_MIDI_power" msgid="3308250484012677596">"MIDI va quvvat uzatish"</string>
     <string name="sms_mirroring_pref" msgid="6475043279147376031">"SMS translatsiyasi"</string>
     <string name="background_check_pref" msgid="7550258400138010979">"Fonda tekshirish"</string>
     <string name="background_check_title" msgid="4534254315824525593">"Butun fonga ruxsat"</string>
@@ -3477,14 +3518,13 @@
     <string name="display_dashboard_summary" msgid="4145888780290131488">"Fon rasmi, uyqu rejimi, shrift o‘lchami"</string>
     <string name="display_summary_example" msgid="9102633726811090523">"10 daqiqa nofaollikdan keyin uyqu rejimiga o‘tish"</string>
     <string name="memory_summary" msgid="8080825904671961872">"O‘rtacha <xliff:g id="USED_MEMORY">%1$s</xliff:g> ishlatilmoqda, jami: <xliff:g id="TOTAL_MEMORY">%2$s</xliff:g>"</string>
-    <string name="users_and_accounts_summary" msgid="245282689646897882">"Joriy foydalanuvchi: <xliff:g id="USER_NAME">%1$s</xliff:g>"</string>
     <string name="users_summary" msgid="1674864467098487328">"Siz <xliff:g id="USER_NAME">%1$s</xliff:g> sifatida kirgansiz"</string>
     <string name="payment_summary" msgid="3472482669588561110">"Birlamchi ilova: <xliff:g id="APP_NAME">%1$s</xliff:g>"</string>
-    <!-- no translation found for location_on_summary (4083334422422067511) -->
-    <skip />
+    <string name="location_on_summary" msgid="4083334422422067511">"YONIQ"</string>
     <string name="location_off_summary" msgid="6474350053215707957">"O‘CHIQ"</string>
     <string name="backup_disabled" msgid="485189128759595412">"Zaxiralash o‘chirilgan"</string>
-    <string name="about_summary" msgid="924181828102801010">"Android <xliff:g id="VERSION">%1$s</xliff:g> versiyasiga yangilandi"</string>
+    <string name="android_version_summary" msgid="2935995161657697278">"Android <xliff:g id="VERSION">%1$s</xliff:g> versiyasiga yangilandi"</string>
+    <string name="android_version_pending_update_summary" msgid="487831391976523090">"Yangilanish chiqdi"</string>
     <string name="disabled_by_policy_title" msgid="627023216027648534">"Bu amalga ruxsat berilmagan"</string>
     <string name="disabled_by_policy_title_adjust_volume" msgid="7399450998356045023">"Tovush balandligini o‘zgartirib bo‘lmadi"</string>
     <string name="disabled_by_policy_title_outgoing_calls" msgid="7919816644946067058">"Chaqiruvga ruxsat berilmagan"</string>
@@ -3505,7 +3545,7 @@
     <string name="condition_hotspot_summary" msgid="3433182779269409683">"Wi-Fi ulanish nuqtasi (<xliff:g id="ID_1">%1$s</xliff:g>) yoniq. Bu qurilmada Wi-Fi aloqasi o‘chiq."</string>
     <string name="condition_airplane_title" msgid="287356299107070503">"Parvoz rejimi yoqilgan"</string>
     <string name="condition_airplane_summary" msgid="3738805058182535606">"Wi-Fi, Bluetooth va mobil internet o‘chirilgan. Qo‘ng‘iroqlarni amalga oshira olmaysiz yoki internetga ulana olmaysiz."</string>
-    <string name="condition_zen_title" msgid="2679168532600816392">"Bezovta qilinmasin yoqilgan (<xliff:g id="ID_1">%1$s</xliff:g>)"</string>
+    <string name="condition_zen_title" msgid="2897779738211625">"Bezovta qilinmasin rejimi yoniq"</string>
     <string name="condition_battery_title" msgid="3272131008388575349">"Quvvat tejash rejimi yoniq"</string>
     <string name="condition_battery_summary" msgid="4418839236027977450">"Unumdorlik kamayadi. Joylashuv xizmatlari va fondagi internet o‘chiriladi."</string>
     <string name="condition_cellular_title" msgid="1327317003797575735">"Mobil internet o‘chiq"</string>
@@ -3515,8 +3555,7 @@
     <string name="condition_work_title" msgid="7293722361184366648">"Ishchi profil o‘chirilgan"</string>
     <string name="condition_work_summary" msgid="7543202177571590378">"Ishchi profil bilan bog‘liq ilovalar, fonda sinxronlash va boshqa funksiyalar o‘chirib qo‘yildi."</string>
     <string name="night_display_suggestion_title" msgid="6602129097059325291">"Tungi rejim jadvalini sozlash"</string>
-    <!-- no translation found for night_display_suggestion_summary (228346372178218442) -->
-    <skip />
+    <string name="night_display_suggestion_summary" msgid="228346372178218442">"Har tunda ekran rangini avtomatik o‘zgartirish"</string>
     <string name="condition_night_display_title" msgid="5599814941976856183">"Tungi rejim yoqilgan"</string>
     <string name="condition_night_display_summary" msgid="5443722724310650381">"Ekran qizg‘ish tusga kirdi. Bu osonroq uyquga ketishga yordamlashadi."</string>
     <string name="suggestions_title_v2" msgid="5601181602924147569">"Taklif etiladi"</string>
@@ -3571,6 +3610,20 @@
       <item quantity="other">Trafik tejash rejimi yoniqligida <xliff:g id="COUNT">%1$d</xliff:g> ta ilova internet-trafikdan cheklovsiz foydalanishi mumkin</item>
       <item quantity="one">Trafik tejash rejimi yoniqligida 1 ta ilova internet-trafikdan cheklovsiz foydalanishi mumkin</item>
     </plurals>
+    <!-- no translation found for data_usage_title (3659356290392241789) -->
+    <skip />
+    <!-- no translation found for data_used (5116389957228457203) -->
+    <skip />
+    <!-- no translation found for data_remaining (8998091725895502181) -->
+    <skip />
+    <!-- no translation found for cycle_left_time_text (8501602478371081001) -->
+    <skip />
+    <!-- no translation found for carrier_and_update_text (4534395723031386923) -->
+    <skip />
+    <!-- no translation found for no_carrier_update_text (6879630084452907385) -->
+    <skip />
+    <!-- no translation found for launch_mdp_app_text (7527361210375612985) -->
+    <skip />
     <string name="data_saver_title" msgid="398458827917495765">"Trafik tejash"</string>
     <string name="unrestricted_data_saver" msgid="952796077540228711">"Cheklanmagan mobil internet"</string>
     <string name="restrict_background_blacklisted" msgid="3995443391711013068">"Fondagi internet o‘chiq"</string>
@@ -3590,6 +3643,10 @@
     <string name="battery_saver_off_summary" msgid="8309471955051162327">"O‘chiq / <xliff:g id="ID_1">%1$s</xliff:g>"</string>
     <string name="battery_saver_desc_turn_on_auto_never" msgid="6715896635178578813">"Hech qachon avtomatik yoqilmasin"</string>
     <string name="battery_saver_desc_turn_on_auto_pct" msgid="7472323223085636533">"Batareya quvvati %1$s qolganda avtomatik yoqilsin"</string>
+    <!-- no translation found for battery_saver_button_turn_on (3699954061337848832) -->
+    <skip />
+    <!-- no translation found for battery_saver_button_turn_off (5916996792004611890) -->
+    <skip />
     <string name="not_battery_optimizing" msgid="5362861851864837617">"Batareya quvvati tejalmayapti"</string>
     <string name="lockscreen_remote_input" msgid="969871538778211843">"Qurilma qulflangan bo‘lsa, bildirishnomalarda matn kiritish taqiqlansin"</string>
     <string name="default_spell_checker" msgid="8506899870026026660">"Birlamchi imlo tekshirgich"</string>
@@ -3650,6 +3707,7 @@
     <string name="quick_settings_developer_tiles" msgid="5947788063262762448">"Tezkor sozlamalarning dasturchi tugmalari"</string>
     <string name="window_trace_quick_settings_title" msgid="3839917000546526898">"Oyna trassirovkasi"</string>
     <string name="layer_trace_quick_settings_title" msgid="876797401275734018">"Yuza trassirovkasi"</string>
+    <string name="support_country_format" msgid="4502523713489559595">"<xliff:g id="COUNTRY">%1$s</xliff:g> – <xliff:g id="LANGUAGE">%2$s</xliff:g>"</string>
     <string name="managed_profile_settings_title" msgid="2729481936758125054">"Ishchi profil sozlamalari"</string>
     <string name="managed_profile_contact_search_title" msgid="6034734926815544221">"Kontaktlarni qidirish"</string>
     <string name="managed_profile_contact_search_summary" msgid="5431253552272970512">"Tashkilot nomi bo‘yicha qidiruvda qo‘ng‘iroq qiluvchi abonent va uning kontaktini aniqlashga ruxsat berish"</string>
@@ -3834,20 +3892,14 @@
     <string name="show_first_crash_dialog_summary" msgid="703224456285060428">"Ilova ishdan chiqqanda har safar muloqot oynasi ko‘rsatilsin"</string>
     <string name="directory_access" msgid="4722237210725864244">"Kataloglarga kirish"</string>
     <string name="keywords_directory_access" msgid="360557532842445280">"kataloglarga kirish"</string>
-    <!-- no translation found for directory_on_volume (1246959267814974387) -->
-    <skip />
-    <!-- no translation found for my_device_info_title (5512426315065239032) -->
-    <skip />
-    <!-- no translation found for my_device_info_title (7850936731324591758) -->
-    <skip />
-    <!-- no translation found for my_device_info_title (5512071003076176919) -->
-    <skip />
-    <!-- no translation found for my_device_info_account_preference_title (342933638925781861) -->
-    <skip />
-    <!-- no translation found for my_device_info_device_name_preference_title (7104085224684165324) -->
-    <skip />
-    <!-- no translation found for bluetooth_on_while_driving_pref (2460847604498343330) -->
-    <skip />
-    <!-- no translation found for bluetooth_on_while_driving_summary (3196190732516898541) -->
+    <string name="directory_on_volume" msgid="1246959267814974387">"<xliff:g id="VOLUME">%1$s</xliff:g> (<xliff:g id="DIRECTORY">%2$s</xliff:g>)"</string>
+    <string name="my_device_info_title" product="default" msgid="5512426315065239032">"Telefonim"</string>
+    <string name="my_device_info_title" product="tablet" msgid="7850936731324591758">"Planshetim"</string>
+    <string name="my_device_info_title" product="device" msgid="5512071003076176919">"Qurilmam"</string>
+    <string name="my_device_info_account_preference_title" msgid="342933638925781861">"Hisob"</string>
+    <string name="my_device_info_device_name_preference_title" msgid="7104085224684165324">"Qurilma nomi"</string>
+    <string name="bluetooth_on_while_driving_pref" msgid="2460847604498343330">"Avtomobilda Bluetoothni yoqish"</string>
+    <string name="bluetooth_on_while_driving_summary" msgid="3196190732516898541">"Avtomobilda harakatlanayotganda Bluetooth aloqasini avtomatik ravishda yoqish"</string>
+    <!-- no translation found for dev_android_o_battery_settings_title (2926578228655006762) -->
     <skip />
 </resources>
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index 2d48e42..d37091c 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -162,4 +162,12 @@
         <attr name="showPercentString" format="boolean" />
         <attr name="thickness" format="dimension" />
     </declare-styleable>
+
+    <!-- For TwoStatesButtonPreference -->
+    <declare-styleable name="TwoStateButtonPreference">
+        <attr name="textOn" format="reference" />
+        <attr name="textOff" format="reference" />
+    </declare-styleable>
+
+    <attr name="twoStateButtonPreferenceStyle" format="reference" />
 </resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index fbc7490..6ede7c6 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -304,8 +304,6 @@
 
     <!-- Suggestion cards size and padding -->
     <dimen name="suggestion_card_icon_size">24dp</dimen>
-    <dimen name="suggestion_card_width_one_card">332dp</dimen>
-    <dimen name="suggestion_card_width_two_cards">162dp</dimen>
     <dimen name="suggestion_card_width_multiple_cards">156dp</dimen>
     <dimen name="suggestion_card_outer_margin">14dp</dimen>
     <dimen name="suggestion_card_inner_margin">12dp</dimen>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 7abcc97..7d4b3e9 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1154,7 +1154,7 @@
     <string name="setup_lock_settings_picker_title" product="default">Protect your phone</string>
 
     <!-- Message shown when setting up screen lock, prompting user to choose the their backup screen lock method [CHAR LIMIT=NONE] -->
-    <string name="lock_settings_picker_fingerprint_added_security_message">For added security, set a backup screen lock.</string>
+    <string name="lock_settings_picker_fingerprint_added_security_message">For added security, set a backup screen lock</string>
 
     <!-- Description text for screen in setup wizard asking user to set up screen lock, explaining to the user how setting up a screen lock protect them from losing data. (tablet) [CHAR LIMIT=NONE] -->
     <string name="setup_lock_settings_picker_message" product="tablet">Prevent others from using this tablet without your permission by activating device protection features. Choose the screen lock you want to use.</string>
@@ -1845,12 +1845,8 @@
     <string name="wifi_configure_settings_preference_summary_wakeup_off">Wi\u2011Fi doesn\u0027t turn back on automatically</string>
     <!-- Header for the list of wifi networks-->
     <string name="wifi_access_points">Wi\u2011Fi networks</string>
-    <!-- Menu option to do WPS Push Button [CHAR LIMIT=25]-->
-    <string name="wifi_menu_wps_pbc">WPS Push Button</string>
     <!-- Content description for menu button in Wifi setup. Not shown on the screen. [CHAR LIMIT=NONE] -->
     <string name="wifi_menu_more_options">More options</string>
-    <!-- Menu option to do WPS Pin Entry [CHAR LIMIT=25]-->
-    <string name="wifi_menu_wps_pin">WPS Pin Entry</string>
     <!-- Menu option to launch Wi-Fi Direct settings [CHAR LIMIT=20]-->
     <string name="wifi_menu_p2p">Wi\u2011Fi Direct</string>
     <!-- Menu option to scan Wi-Fi networks -->
@@ -1887,32 +1883,6 @@
     <string name="wifi_advanced_toggle_description_expanded">Drop down list Advanced Options. Double-tap to collapse.</string>
     <!-- Message for talkback to say when Advanced Options is collapsed [CHAR LIMIT=NONE] -->
     <string name="wifi_advanced_toggle_description_collapsed">Drop down list Advanced Options. Double-tap to expand.</string>
-    <!-- Title for the WPS setup dialog [CHAR LIMIT=50] -->
-    <string name="wifi_wps_setup_title">Wi\u2011Fi Protected Setup</string>
-    <!-- Message in WPS dialog at start up [CHAR LIMIT=150] -->
-    <string name="wifi_wps_setup_msg">Starting WPS\u2026</string>
-    <!-- Message in WPS dialog for PBC after start up [CHAR LIMIT=150] -->
-    <string name="wifi_wps_onstart_pbc">Press the Wi\u2011Fi Protected Setup button on your router. It may be called \u201cWPS\u201d or marked with this symbol:</string>
-    <!-- Message in WPS dialog for PIN after start up [CHAR LIMIT=150] -->
-    <string name="wifi_wps_onstart_pin">Enter pin <xliff:g id="number">%1$s</xliff:g> on your Wi\u2011Fi router. The setup can take up to two minutes to complete.</string>
-    <!-- Text displayed when WPS succeeds [CHAR LIMIT=150] -->
-    <string name="wifi_wps_complete">WPS succeeded. Connecting to the network\u2026</string>
-    <!-- Text displayed when Wi-Fi is connected through WPS [CHAR LIMIT=150] -->
-    <string name="wifi_wps_connected">Connected to Wi\u2011Fi network <xliff:g id="network_name">%s</xliff:g></string>
-    <!-- Text displayed when WPS setup is in progress [CHAR LIMIT=150] -->
-    <string name="wifi_wps_in_progress">WPS is already in progress and can take up to two minutes to complete</string>
-    <!-- Text displayed when WPS fails to start [CHAR LIMIT=150] -->
-    <string name="wifi_wps_failed_generic">WPS failed. Please try again in a few minutes.</string>
-    <!-- Text displayed when WPS fails due to WEP [CHAR LIMIT=150] -->
-    <string name="wifi_wps_failed_wep">The wireless router security setting (WEP) is not supported</string>
-    <!-- Text displayed when WPS fails to TKIP [CHAR LIMIT=150] -->
-    <string name="wifi_wps_failed_tkip">The wireless router security setting (TKIP) is not supported</string>
-    <!-- Text displayed when WPS fails due to authentication issues [CHAR LIMIT=150] -->
-    <string name="wifi_wps_failed_auth">Authentication failure. Please try again.</string>
-    <!-- Text displayed when WPS fails due to another session [CHAR LIMIT=150] -->
-    <string name="wifi_wps_failed_overlap">Another WPS session was detected. Please try again in a few minutes.</string>
-    <!-- Text displayed when WPS fails due to wifi disconnected [CHAR LIMIT=150] -->
-    <string name="wifi_wps_failed_wifi_disconnected">Wi\u2011Fi disconnected. WPS setup canceled.</string>
     <!-- Label for the SSID of the network -->
     <string name="wifi_ssid">Network name</string>
     <!-- Hint for a text field to enter the SSID of a hidden wifi network. [CHAR LIMIT=35] -->
@@ -2423,13 +2393,6 @@
 
     <!-- Main Settings screen, setting option name to go into search settings -->
     <string name="search_settings">Search</string>
-    <!-- Main Settings screen, setting option summary to go into search settings -->
-    <string name="search_settings_summary">Manage search settings and history</string>
-    <!-- There are no search results for the user's search [CHAR LIMIT=NONE]-->
-    <string name="search_settings_no_results">No results</string>
-
-    <!-- Button to clear all search history in Settings [CHAR LIMIT=40]-->
-    <string name="search_clear_history">Clear history</string>
 
     <!-- Display settings --><skip/>
     <!-- Sound & display settings screen, section header for settings related to display -->
@@ -3514,19 +3477,19 @@
 
     <!-- Lock Pattern settings -->
     <!-- Header on first screen of choose password/PIN flow [CHAR LIMIT=40] -->
-    <string name="lockpassword_choose_your_screen_lock_header">Set a screen lock</string>
+    <string name="lockpassword_choose_your_screen_lock_header">Set screen lock</string>
     <!-- Message on first screen of choose password flow [CHAR LIMIT=NONE] -->
-    <string name="lockpassword_choose_your_password_message">For security, set a password</string>
+    <string name="lockpassword_choose_your_password_message">For security, set password</string>
     <!-- Header on first screen of choose password/PIN as backup for fingerprint flow. If this string cannot be translated in under 40 characters, please translate "Set fingerprint backup" [CHAR LIMIT=40] -->
-    <string name="lockpassword_choose_your_password_header_for_fingerprint">To use fingerprint, set a password</string>
+    <string name="lockpassword_choose_your_password_header_for_fingerprint">To use fingerprint, set password</string>
     <!-- Header on first screen of choose pattern as backup for fingerprint flow. If this string cannot be translated in under 40 characters, please translate "Set fingerprint backup" [CHAR LIMIT=40] -->
-    <string name="lockpassword_choose_your_pattern_header_for_fingerprint">To use fingerprint, set a pattern</string>
+    <string name="lockpassword_choose_your_pattern_header_for_fingerprint">To use fingerprint, set pattern</string>
     <!-- Message on first screen of choose PIN flow [CHAR LIMIT=NONE] -->
-    <string name="lockpassword_choose_your_pin_message">For security, set a PIN</string>
+    <string name="lockpassword_choose_your_pin_message">For security, set PIN</string>
     <!-- Header on first screen of choose password/PIN as backup for fingerprint flow. If this string cannot be translated in under 40 characters, please translate "Set fingerprint backup" [CHAR LIMIT=40] -->
-    <string name="lockpassword_choose_your_pin_header_for_fingerprint">To use fingerprint, set a PIN</string>
+    <string name="lockpassword_choose_your_pin_header_for_fingerprint">To use fingerprint, set PIN</string>
     <!-- Message on first screen of choose pattern flow [CHAR LIMIT=NONE] -->
-    <string name="lockpassword_choose_your_pattern_message">For security, set a pattern</string>
+    <string name="lockpassword_choose_your_pattern_message">For security, set pattern</string>
     <!-- Header on password confirm screen [CHAR LIMIT=40] -->
     <string name="lockpassword_confirm_your_password_header">Re-enter your password</string>
     <!-- Header on pattern confirm screen [CHAR LIMIT=30] -->
@@ -5140,6 +5103,9 @@
     <!-- Title for the battery management group [CHAR LIMIT=40] -->
     <string name ="battery_detail_manage_title">Manage battery usage</string>
 
+    <!-- Graph subtext displayed to user when enhanced battery estimate is being used [CHAR LIMIT=120] -->
+    <string name="advanced_battery_graph_subtext">Battery left estimate is based on your device usage</string>
+
     <!-- Description for battery time left, i.e. 50min Estimated time left. [CHAR LIMIT=80]-->
     <string name="estimated_time_left">Estimated time left</string>
 
@@ -5166,8 +5132,17 @@
     <!-- Label for dex2oat process in battery usage used for the optimization of one or more apps -->
     <string name="process_dex2oat_label">App optimization</string>
 
-    <!-- [CHAR_LIMIT=40] Battery saver: Label for feature, title + menu item -->
-    <string name="battery_saver">Battery Saver</string>
+    <!-- Battery saver: Label for feature, title + menu item [CHAR_LIMIT=40] -->
+    <string name="battery_saver">Reduced power mode</string>
+
+    <!-- Battery saver: Label for preference to turn on battery saver automatically when battery is low [CHAR_LIMIT=40] -->
+    <string name="battery_saver_auto_title">Schedule</string>
+
+    <!-- Battery saver: Summary for preference to turn on battery saver automatically when battery is low [CHAR_LIMIT=40] -->
+    <string name="battery_saver_auto_summary">Turn on Reduced power mode automatically when battery is low</string>
+
+    <!-- Battery saver: Label for seekbar to change battery saver threshold [CHAR_LIMIT=40] -->
+    <string name="battery_saver_seekbar_title">Turn on automatically at <xliff:g id="percent">%1$s</xliff:g></string>
 
     <!-- Used in the Battery Saver settings screen to control turning on/off the feature entirely -->
     <string name="battery_saver_master_switch_title">Use Battery Saver</string>
@@ -5770,9 +5745,6 @@
     <!--  action to select all [CHAR LIMIT=30] -->
     <string name="select_all">Select all</string>
 
-    <!-- A button that gets displayed in data plan usage preference in settings page to manage data plans [CHAR LIMIT=25] -->
-    <string name="data_plan_usage_manage_plans_button_text">Manage plans</string>
-
     <!-- Activity title for network data usage summary. [CHAR LIMIT=25] -->
     <string name="data_usage_summary_title">Data usage</string>
     <!-- Activity title for Appk data usage summary. [CHAR LIMIT=25] -->
@@ -5872,6 +5844,8 @@
     <string name="data_usage_enable_3g">2G-3G data</string>
     <!-- Toggle switch title for enabling 4G data network connection. [CHAR LIMIT=32] -->
     <string name="data_usage_enable_4g">4G data</string>
+    <!-- Toggle switch title for enabling roaming on the primary data SIM card. [CHAR LIMIT=32] -->
+    <string name="data_roaming_enable_mobile">Roaming</string>
 
     <!-- Data Usage Foreground label.  [CHAR LIMIT=40] -->
     <string name="data_usage_forground_label">Foreground:</string>
@@ -6504,6 +6478,7 @@
     <string name="help_uri_process_stats_apps" translatable="false"></string>
     <string name="help_uri_private_dns" translatable="false"></string>
     <string name="help_uri_about_phone_v2" translatable="false"></string>
+    <string name="help_uri_wifi_calling" translatable="false"></string>
 
     <!-- User account title [CHAR LIMIT=30] -->
     <string name="user_account_title">Account for content</string>
@@ -7081,7 +7056,7 @@
     <string name="notification_pulse_title">Blink light</string>
 
     <!-- Configure Notifications: Title for the option controlling notifications on the lockscreen. [CHAR LIMIT=30] -->
-    <string name="lock_screen_notifications_title">On the lock screen</string>
+    <string name="lock_screen_notifications_title">On lock screen</string>
 
     <!-- Configure Notifications: Value for lockscreen notifications:  all information will be
          shown in notifications shown on a secure lock screen
@@ -7091,7 +7066,7 @@
     <!-- Configure Notifications: Value for lockscreen notifications: sensitive information will be
          hidden or redacted from notifications shown on a secure lock screen
          [CHAR LIMIT=50] -->
-    <string name="lock_screen_notifications_summary_hide">Hide sensitive notification content</string>
+    <string name="lock_screen_notifications_summary_hide">Hide sensitive content</string>
 
     <!-- Configure Notifications: Value for lockscreen notifications: notifications will not appear on a secure lock screen
          [CHAR LIMIT=50] -->
@@ -7111,7 +7086,7 @@
     <!-- Configure Notifications: Value for lockscreen notifications: sensitive information will be
          hidden or redacted from work notifications shown on a secure lock screen
          [CHAR LIMIT=50] -->
-    <string name="lock_screen_notifications_summary_hide_profile">Hide sensitive work notification content</string>
+    <string name="lock_screen_notifications_summary_hide_profile">Hide sensitive work content</string>
 
     <!-- Configure Notifications: Value for lockscreen notifications: work notifications will not appear on a secure lock screen
          [CHAR LIMIT=50] -->
@@ -7371,7 +7346,7 @@
     <string name="app_notification_override_dnd_summary">Let these notifications continue to interrupt when Do Not Disturb is set to Priority Only</string>
 
     <!-- [CHAR LIMIT=NONE] App notification settings: Visibility override option title -->
-    <string name="app_notification_visibility_override_title">On the lock screen</string>
+    <string name="app_notification_visibility_override_title">On lock screen</string>
 
     <!-- [CHAR LIMIT=20] Notification settings: App notifications row summary when allowed -->
     <string name="app_notification_row_banned">Blocked</string>
@@ -8155,9 +8130,6 @@
          and powering other device [CHAR LIMIT=NONE] -->
     <string name="usb_summary_MIDI_power">MIDI and supplying power</string>
 
-    <!-- Settings item title for SMS Mirroring preference [CHAR LIMIT=35] -->
-    <string name="sms_mirroring_pref">SMS Mirroring</string>
-
     <!-- Settings item title for background check prefs [CHAR LIMIT=35] -->
     <string name="background_check_pref">Background check</string>
 
@@ -8508,7 +8480,7 @@
     <!-- Summary of condition that airplane mode is on [CHAR LIMIT=NONE] -->
     <string name="condition_airplane_summary">Wi-Fi, Bluetooth, and mobile network are turned off. You can\'t make phone calls or connect to the internet.</string>
 
-    <!-- Title of condition that do not disturb is on [CHAR LIMIT=30] -->
+    <!-- Title of condition that do not disturb is on [CHAR LIMIT=36] -->
     <string name="condition_zen_title">Do Not Disturb is on</string>
 
     <!-- Title of condition that battery saver is on [CHAR LIMIT=30] -->
@@ -8683,6 +8655,27 @@
         <item quantity="other"><xliff:g id="count" example="10">%1$d</xliff:g> apps allowed to use unrestricted data when Data Saver is on</item>
     </plurals>
 
+    <!-- Data usage title text [CHAR LIMIT=30] -->
+    <string name="data_usage_title">Primary data</string>
+
+    <!-- Data usage string [CHAR LIMIT=30] -->
+    <string name="data_used"><xliff:g name="bytes" example="2 GB">^1</xliff:g> used</string>
+
+    <!-- Optional part of data usage showing the remaining amount [CHAR LIMIT=30] -->
+    <string name="data_remaining"><xliff:g name="bytes" example="2 GB">, ^1</xliff:g> left</string>
+
+    <!-- Informational text about time left in billing cycle [CHAR LIMIT=30] -->
+    <string name="cycle_left_time_text"><xliff:g name="time" example="2d">%1$s</xliff:g> left in this cycle</string>
+
+    <!-- Informational text about carrier and update time [CHAR LIMIT=30] -->
+    <string name="carrier_and_update_text">Updated by <xliff:g name="carrier" example="T-mobile">%1$s</xliff:g> <xliff:g name="time" example="3m">%2$s</xliff:g></string>
+
+    <!-- Informational text about update time only, without carrier [CHAR LIMIT=30] -->
+    <string name="no_carrier_update_text">Updated <xliff:g name="time" example="3m">%1$s</xliff:g></string>
+
+    <!-- Button to launch external data plan app [CHAR LIMIT=30] -->
+    <string name="launch_mdp_app_text">VIEW PLAN</string>
+
     <!-- Name of Data Saver screens [CHAR LIMIT=30] -->
     <string name="data_saver_title">Data saver</string>
 
@@ -8740,6 +8733,12 @@
     <!-- [CHAR_LIMIT=NONE] Battery saver: Description for automatic entry option: pct% battery -->
     <string name="battery_saver_desc_turn_on_auto_pct">Turn on automatically at %1$s battery</string>
 
+    <!--  Battery saver: Label for button that will turn on battery saver. [CHAR LIMIT=30] -->
+    <string name="battery_saver_button_turn_on">Turn on now</string>
+
+    <!--  Battery saver: Label for button that will turn off battery saver. [CHAR LIMIT=30] -->
+    <string name="battery_saver_button_turn_off">Turn off now</string>
+
     <!-- [CHAR_LIMIT=NONE] Label for when app is ignoring battery optimizations -->
     <string name="not_battery_optimizing">Not using battery optimization</string>
 
@@ -9294,6 +9293,9 @@
     <!-- Help URI, USB Audio [DO NOT TRANSLATE] -->
     <string name="help_url_audio_accessory_not_supported" translatable="false"></string>
 
+    <!-- Help URI, battery saver page [DO NOT TRANSLATE] -->
+    <string name="help_url_battery_saver_settings" translatable="false"></string>
+
     <!-- Title label for new device suggestion, which is displayed in Settings homepage [CHAR LIMIT=100] -->
     <string name="new_device_suggestion_title">What\'s new and exciting?</string>
 
@@ -9358,4 +9360,6 @@
     <!-- Settings item summary for automatic Bluetooth on while driving preference [CHAR LIMIT=100] -->
     <string name="bluetooth_on_while_driving_summary">Turn on Bluetooth automatically when driving</string>
 
+    <!-- Title for item to go to old battery settings page when clicking [CHAR LIMIT=100] -->
+    <string name="dev_android_o_battery_settings_title">See Android 8.0 battery settings</string>
 </resources>
diff --git a/res/values/styles_preference.xml b/res/values/styles_preference.xml
index 056d55a..5fe1ef4 100644
--- a/res/values/styles_preference.xml
+++ b/res/values/styles_preference.xml
@@ -36,4 +36,8 @@
         <item name="android:widgetLayout">@layout/preference_widget_sync_toggle</item>
     </style>
 
+    <style name="TwoStateButtonPreference" parent="Preference.SettingsBase">
+        <item name="android:layout">@layout/two_state_button</item>
+    </style>
+
 </resources>
\ No newline at end of file
diff --git a/res/values/themes.xml b/res/values/themes.xml
index e0f3989..a8ceca3 100644
--- a/res/values/themes.xml
+++ b/res/values/themes.xml
@@ -17,7 +17,6 @@
 <resources>
     <attr name="fingerprint_layout_theme" format="reference" />
     <attr name="ic_menu_moreoverflow" format="reference" />
-    <attr name="ic_wps" format="reference" />
     <attr name="side_margin" format="reference|dimension" />
     <attr name="wifi_signal_color" format="reference" />
 
@@ -28,7 +27,6 @@
         <item name="*android:preferencePanelStyle">@*android:style/PreferencePanel.Dialog</item>
         <item name="fingerprint_layout_theme">@style/FingerprintLayoutTheme</item>
         <item name="ic_menu_moreoverflow">@*android:drawable/ic_menu_moreoverflow_material</item>
-        <item name="ic_wps">@drawable/ic_wps_dark</item>
         <item name="side_margin">0dip</item>
         <item name="wifi_signal_color">@color/setup_wizard_wifi_color_dark</item>
         <item name="wifi_signal">@drawable/wifi_signal</item>
@@ -47,7 +45,6 @@
         <item name="*android:preferencePanelStyle">@*android:style/PreferencePanel.Dialog</item>
         <item name="fingerprint_layout_theme">@style/FingerprintLayoutTheme</item>
         <item name="ic_menu_moreoverflow">@*android:drawable/ic_menu_moreoverflow_material</item>
-        <item name="ic_wps">@drawable/ic_wps_light</item>
         <item name="side_margin">0dip</item>
         <item name="wifi_signal_color">@color/setup_wizard_wifi_color_light</item>
         <item name="wifi_signal">@drawable/wifi_signal</item>
@@ -65,7 +62,6 @@
         <item name="*android:preferencePanelStyle">@*android:style/PreferencePanel.Dialog</item>
         <item name="fingerprint_layout_theme">@style/FingerprintLayoutTheme</item>
         <item name="ic_menu_moreoverflow">@*android:drawable/ic_menu_moreoverflow_material</item>
-        <item name="ic_wps">@drawable/ic_wps_dark</item>
         <item name="side_margin">0dip</item>
         <item name="wifi_signal_color">@color/setup_wizard_wifi_color_dark</item>
         <item name="wifi_signal">@drawable/wifi_signal</item>
@@ -84,7 +80,6 @@
         <item name="*android:preferencePanelStyle">@*android:style/PreferencePanel.Dialog</item>
         <item name="fingerprint_layout_theme">@style/FingerprintLayoutTheme</item>
         <item name="ic_menu_moreoverflow">@*android:drawable/ic_menu_moreoverflow_material</item>
-        <item name="ic_wps">@drawable/ic_wps_light</item>
         <item name="side_margin">0dip</item>
         <item name="wifi_signal_color">@color/setup_wizard_wifi_color_light</item>
         <item name="wifi_signal">@drawable/wifi_signal</item>
@@ -102,7 +97,6 @@
         <item name="*android:preferencePanelStyle">@*android:style/PreferencePanel.Dialog</item>
         <item name="fingerprint_layout_theme">@style/FingerprintLayoutTheme</item>
         <item name="ic_menu_moreoverflow">@*android:drawable/ic_menu_moreoverflow_material</item>
-        <item name="ic_wps">@drawable/ic_wps_dark</item>
         <item name="side_margin">0dip</item>
         <item name="wifi_signal_color">@color/setup_wizard_wifi_color_dark</item>
         <item name="wifi_signal">@drawable/wifi_signal</item>
@@ -121,7 +115,6 @@
         <item name="*android:preferencePanelStyle">@*android:style/PreferencePanel.Dialog</item>
         <item name="fingerprint_layout_theme">@style/FingerprintLayoutTheme</item>
         <item name="ic_menu_moreoverflow">@*android:drawable/ic_menu_moreoverflow_material</item>
-        <item name="ic_wps">@drawable/ic_wps_light</item>
         <item name="side_margin">0dip</item>
         <item name="wifi_signal_color">@color/setup_wizard_wifi_color_light</item>
         <item name="wifi_signal">@drawable/wifi_signal</item>
@@ -183,6 +176,7 @@
         <item name="preferenceFragmentStyle">@style/SettingsPreferenceFragmentStyle</item>
         <item name="apnPreferenceStyle">@style/ApnPreference</item>
         <item name="seekBarPreferenceStyle">@style/SettingsSeekBarPreference</item>
+        <item name="twoStateButtonPreferenceStyle">@style/TwoStateButtonPreference</item>
     </style>
 
     <style name="PreferenceTheme.SetupWizard" parent="PreferenceTheme">
@@ -221,7 +215,6 @@
 
         <item name="fingerprint_layout_theme">@style/FingerprintLayoutTheme</item>
         <item name="ic_menu_moreoverflow">@*android:drawable/ic_menu_moreoverflow_holo_dark</item>
-        <item name="ic_wps">@drawable/ic_wps_light</item>
         <item name="wifi_signal">@drawable/wifi_signal</item>
         <item name="wifi_signal_color">?android:attr/colorAccent</item>
         <item name="wifi_friction">@drawable/wifi_friction</item>
diff --git a/res/xml/battery_saver_settings.xml b/res/xml/battery_saver_settings.xml
index 1720c73..4397199 100644
--- a/res/xml/battery_saver_settings.xml
+++ b/res/xml/battery_saver_settings.xml
@@ -14,14 +14,37 @@
      limitations under the License.
 -->
 
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
-        android:title="@string/battery_saver"
-        android:key="battery_saver">
+<PreferenceScreen
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:settings="http://schemas.android.com/apk/res-auto"
+    android:title="@string/battery_saver"
+    android:key="battery_saver">
 
     <!-- Turn on automatically -->
-    <DropDownPreference
-            android:key="turn_on_automatically"
-            android:title="@string/battery_saver_turn_on_automatically_title"
-            android:summary="%s" />
+    <SwitchPreference
+        android:key="auto_battery_saver"
+        android:title="@string/battery_saver_auto_title"
+        android:summary="@string/battery_saver_auto_summary"
+        settings:controller="com.android.settings.fuelgauge.batterysaver.AutoBatterySaverPreferenceController"/>
+
+    <com.android.settings.widget.SeekBarPreference
+        android:key="battery_saver_seek_bar"
+        android:title="@string/battery_saver_seekbar_title"
+        android:max="75"
+        android:min="5"/>
+
+    <com.android.settings.widget.TwoStateButtonPreference
+        android:key="battery_saver_button_container"
+        android:selectable="false"
+        settings:textOn="@string/battery_saver_button_turn_on"
+        settings:textOff="@string/battery_saver_button_turn_off"/>
+
+    <PreferenceCategory
+        android:key="battery_saver_footer">
+        <com.android.settingslib.widget.FooterPreference
+            android:key="battery_saver_footer_preference"
+            android:title="@*android:string/battery_saver_description"
+            android:selectable="false"/>
+    </PreferenceCategory>
 
 </PreferenceScreen>
diff --git a/res/xml/connected_devices_advanced.xml b/res/xml/connected_devices_advanced.xml
index 0b75abf..a5d48fd 100644
--- a/res/xml/connected_devices_advanced.xml
+++ b/res/xml/connected_devices_advanced.xml
@@ -25,8 +25,8 @@
       android:title="@string/bluetooth_settings_title"
       android:icon="@drawable/ic_settings_bluetooth"
       android:summary="@string/bluetooth_pref_summary"
-      settings:controller="com.android.settings.bluetooth.BluetoothSwitchPreferenceController"
-      android:order="-7"/>
+      android:order="-7"
+      settings:controller="com.android.settings.bluetooth.BluetoothSwitchPreferenceController"/>
 
     <SwitchPreference
         android:key="toggle_nfc"
@@ -42,21 +42,23 @@
         android:icon="@drawable/ic_android"
         android:order="-4"/>
 
-    <Preference
-        android:key="sms_mirroring"
-        android:title="@string/sms_mirroring_pref"
-        android:icon="@drawable/ic_sms_mirroring_24dp"
-        android:summary="@string/summary_placeholder"
-        android:order="-3"/>
-
     <SwitchPreference
         android:key="bluetooth_on_while_driving"
         android:title="@string/bluetooth_on_while_driving_pref"
         android:icon="@drawable/ic_settings_bluetooth"
         android:summary="@string/bluetooth_on_while_driving_summary"
+        settings:controller="com.android.settings.connecteddevice.BluetoothOnWhileDrivingPreferenceController"
         android:order="-2"/>
 
     <Preference
+        android:key="connected_device_printing"
+        android:title="@string/print_settings"
+        android:summary="@string/summary_placeholder"
+        android:icon="@drawable/ic_settings_print"
+        android:fragment="com.android.settings.print.PrintSettingsFragment"
+        android:order="-1"/>
+
+    <Preference
         android:key="bt_received_files"
         android:icon="@drawable/ic_folder_vd_theme_24"
         android:title="@string/bluetooth_show_received_files" />
diff --git a/res/xml/connected_devices_old.xml b/res/xml/connected_devices_old.xml
index cc7b5b4..1b69fe1 100644
--- a/res/xml/connected_devices_old.xml
+++ b/res/xml/connected_devices_old.xml
@@ -40,13 +40,6 @@
         android:order="-4"/>
 
     <Preference
-        android:key="sms_mirroring"
-        android:title="@string/sms_mirroring_pref"
-        android:icon="@drawable/ic_sms_mirroring_24dp"
-        android:summary="@string/summary_placeholder"
-        android:order="-3"/>
-
-    <Preference
         android:key="usb_mode"
         android:title="@string/usb_pref"
         android:icon="@drawable/ic_usb"
diff --git a/res/xml/data_plan_usage_cell_data_preference_screen.xml b/res/xml/data_plan_usage_cell_data_preference_screen.xml
deleted file mode 100644
index 08f21c5..0000000
--- a/res/xml/data_plan_usage_cell_data_preference_screen.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.
--->
-
-<PreferenceScreen
-        xmlns:android="http://schemas.android.com/apk/res/android"
-        android:title="@string/data_usage_summary_title">
-
-    <com.android.settings.datausage.TemplatePreferenceCategory
-            android:key="data_usage_mobile_category"
-            android:title="@string/data_usage_tab_mobile">
-
-        <com.android.settings.datausage.CellDataPreference
-                android:key="data_usage_enable"
-                android:title="@string/data_usage_enable_mobile" />
-    </com.android.settings.datausage.TemplatePreferenceCategory>
-
-</PreferenceScreen>
diff --git a/res/xml/data_usage.xml b/res/xml/data_usage.xml
index 958459c..88d7f32 100644
--- a/res/xml/data_usage.xml
+++ b/res/xml/data_usage.xml
@@ -20,24 +20,8 @@
     android:key="data_usage_screen"
     android:title="@string/data_usage_summary_title">
 
-    <PreferenceCategory
-        android:key="data_usage_category"
-        android:title="@string/usage">
-
-        <com.android.settings.SummaryPreference
+    <com.android.settings.datausage.DataUsageSummaryPreference
             android:key="status_header"
             android:selectable="false" />
 
-        <Preference
-            android:key="limit_summary"
-            android:selectable="false"
-            settings:allowDividerBelow="true" />
-
-        <com.android.settings.datausage.DataSaverPreference
-            android:key="restrict_background"
-            android:title="@string/data_saver_title"
-            android:fragment="com.android.settings.datausage.DataSaverSummary" />
-
-    </PreferenceCategory>
-
 </PreferenceScreen>
diff --git a/res/xml/data_usage_legacy.xml b/res/xml/data_usage_legacy.xml
new file mode 100644
index 0000000..958459c
--- /dev/null
+++ b/res/xml/data_usage_legacy.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2016 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<PreferenceScreen
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:settings="http://schemas.android.com/apk/res-auto"
+    android:key="data_usage_screen"
+    android:title="@string/data_usage_summary_title">
+
+    <PreferenceCategory
+        android:key="data_usage_category"
+        android:title="@string/usage">
+
+        <com.android.settings.SummaryPreference
+            android:key="status_header"
+            android:selectable="false" />
+
+        <Preference
+            android:key="limit_summary"
+            android:selectable="false"
+            settings:allowDividerBelow="true" />
+
+        <com.android.settings.datausage.DataSaverPreference
+            android:key="restrict_background"
+            android:title="@string/data_saver_title"
+            android:fragment="com.android.settings.datausage.DataSaverSummary" />
+
+    </PreferenceCategory>
+
+</PreferenceScreen>
diff --git a/res/xml/development_settings.xml b/res/xml/development_settings.xml
index 5a0d249..a88a97b 100644
--- a/res/xml/development_settings.xml
+++ b/res/xml/development_settings.xml
@@ -77,6 +77,11 @@
             android:fragment="com.android.settings.applications.RunningServices" />
 
         <Preference
+            android:key="android_o_battery_settings"
+            android:fragment="com.android.settings.fuelgauge.PowerUsageSummaryLegacy"
+            android:title="@string/dev_android_o_battery_settings_title" />
+
+        <Preference
             android:key="convert_to_file_encryption"
             android:title="@string/convert_to_file_encryption"
             android:summary="@string/convert_to_file_encryption_enabled"
@@ -471,7 +476,6 @@
             android:entries="@array/app_process_limit_entries"
             android:entryValues="@array/app_process_limit_values" />
 
-
         <Preference
             android:key="background_check"
             android:fragment="com.android.settings.applications.appops.BackgroundCheckSummary"
diff --git a/res/xml/display_settings.xml b/res/xml/display_settings.xml
index 4d0c992..3cafc3f 100644
--- a/res/xml/display_settings.xml
+++ b/res/xml/display_settings.xml
@@ -43,8 +43,9 @@
     <com.android.settingslib.RestrictedSwitchPreference
         android:key="auto_brightness"
         android:title="@string/auto_brightness_title"
-        settings:keywords="@string/keywords_display_auto_brightness"
         android:summary="@string/auto_brightness_summary"
+        settings:keywords="@string/keywords_display_auto_brightness"
+        settings:controller="com.android.settings.display.AutoBrightnessPreferenceController"
         settings:useAdminDisabledSummary="true"
         settings:userRestriction="no_config_brightness" />
 
diff --git a/res/xml/power_usage_summary.xml b/res/xml/power_usage_summary.xml
index d7c3c39..fbe4e0d 100644
--- a/res/xml/power_usage_summary.xml
+++ b/res/xml/power_usage_summary.xml
@@ -23,7 +23,7 @@
 
     <com.android.settings.applications.LayoutPreference
         android:key="battery_header"
-        android:selectable="true"
+        android:selectable="false"
         android:layout="@layout/battery_header"/>
 
     <PreferenceCategory
@@ -34,7 +34,7 @@
         android:key="power_management">
 
         <com.android.settings.widget.MasterSwitchPreference
-            android:fragment="com.android.settings.fuelgauge.BatterySaverSettings"
+            android:fragment="com.android.settings.fuelgauge.batterysaver.BatterySaverSettings"
             android:key="battery_saver_summary"
             android:title="@string/battery_saver"/>
 
diff --git a/res/xml/power_usage_summary_legacy.xml b/res/xml/power_usage_summary_legacy.xml
index 0038cc0..059c737 100644
--- a/res/xml/power_usage_summary_legacy.xml
+++ b/res/xml/power_usage_summary_legacy.xml
@@ -51,7 +51,7 @@
         android:title="@string/battery_power_management">
 
         <com.android.settings.widget.MasterSwitchPreference
-            android:fragment="com.android.settings.fuelgauge.BatterySaverSettings"
+            android:fragment="com.android.settings.fuelgauge.batterysaver.BatterySaverSettings"
             android:key="battery_saver_summary"
             android:title="@string/battery_saver"/>
 
diff --git a/res/xml/print_settings.xml b/res/xml/print_settings.xml
index 75a767a..8d840d1 100644
--- a/res/xml/print_settings.xml
+++ b/res/xml/print_settings.xml
@@ -18,7 +18,7 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:settings="http://schemas.android.com/apk/res-auto"
     android:key="print_settings_screen"
-    android:title="@string/print_settings_title"
+    android:title="@string/print_settings"
     settings:keywords="@string/keywords_printing">
 
     <PreferenceCategory
diff --git a/res/xml/security_dashboard_settings.xml b/res/xml/security_dashboard_settings.xml
index dafd36c..00eaa7e 100644
--- a/res/xml/security_dashboard_settings.xml
+++ b/res/xml/security_dashboard_settings.xml
@@ -79,7 +79,8 @@
         <SwitchPreference
             android:key="visiblepattern_profile"
             android:summary="@string/summary_placeholder"
-            android:title="@string/lockpattern_settings_enable_visible_pattern_title_profile" />
+            android:title="@string/lockpattern_settings_enable_visible_pattern_title_profile"
+            settings:controller="com.android.settings.security.VisiblePatternProfilePreferenceController"/>
 
         <Preference
             android:key="fingerprint_settings_profile"
@@ -103,7 +104,8 @@
         <SwitchPreference
             android:key="show_password"
             android:title="@string/show_password"
-            android:summary="@string/show_password_summary" />
+            android:summary="@string/show_password_summary"
+            settings:controller="com.android.settings.security.ShowPasswordPreferenceController"/>
 
     </PreferenceCategory>
 
diff --git a/res/xml/security_lockscreen_settings.xml b/res/xml/security_lockscreen_settings.xml
index 1da1de5..3d3bfd0 100644
--- a/res/xml/security_lockscreen_settings.xml
+++ b/res/xml/security_lockscreen_settings.xml
@@ -16,6 +16,7 @@
 
 <PreferenceScreen
     xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:settings="http://schemas.android.com/apk/res-auto"
     android:key="security_lockscreen_settings_screen"
     android:title="@string/lockscreen_settings_title">
 
@@ -36,7 +37,8 @@
     <SwitchPreference
         android:key="security_setting_lockdown_enabled"
         android:title="@string/lockdown_settings_title"
-        android:summary="@string/lockdown_settings_summary" />
+        android:summary="@string/lockdown_settings_summary"
+        settings:controller="com.android.settings.security.LockdownButtonPreferenceController"/>
 
     <PreferenceCategory
         android:key="security_setting_lock_screen_notif_work_header"
diff --git a/res/xml/wifi_configure_settings.xml b/res/xml/wifi_configure_settings.xml
index 6993f26..eae6faa 100644
--- a/res/xml/wifi_configure_settings.xml
+++ b/res/xml/wifi_configure_settings.xml
@@ -64,14 +64,6 @@
             android:fragment="com.android.settings.wifi.p2p.WifiP2pSettings"/>
 
     <Preference
-            android:key="wps_push_button"
-            android:title="@string/wifi_menu_wps_pbc" />
-
-    <Preference
-            android:key="wps_pin_entry"
-            android:title="@string/wifi_menu_wps_pin" />
-
-    <Preference
             android:key="mac_address"
             android:title="@string/wifi_advanced_mac_address_title"/>
 
diff --git a/src/com/android/settings/ResetNetworkConfirm.java b/src/com/android/settings/ResetNetworkConfirm.java
index 78e8339..8d6700c 100644
--- a/src/com/android/settings/ResetNetworkConfirm.java
+++ b/src/com/android/settings/ResetNetworkConfirm.java
@@ -225,6 +225,7 @@
             mEraseEsimTask.cancel(true /* mayInterruptIfRunning */);
             mEraseEsimTask = null;
         }
+        super.onDestroy();
     }
 
     @Override
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index 741bfda..599d6fb 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -78,8 +78,8 @@
     public static class AccountSyncSettingsInAddAccountActivity extends SettingsActivity { /* empty */ }
     public static class CryptKeeperSettingsActivity extends SettingsActivity { /* empty */ }
     public static class DeviceAdminSettingsActivity extends SettingsActivity { /* empty */ }
-    public static class DataPlanUsageSummaryActivity extends SettingsActivity { /* empty */ }
     public static class DataUsageSummaryActivity extends SettingsActivity { /* empty */ }
+    public static class DataUsageSummaryLegacyActivity extends SettingsActivity { /* empty */ }
     public static class MobileDataUsageListActivity extends SettingsActivity { /* empty */ }
     public static class ConfigureWifiSettingsActivity extends SettingsActivity { /* empty */ }
     public static class SavedAccessPointsSettingsActivity extends SettingsActivity { /* empty */ }
diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java
index 3c18efb..76b48d1 100644
--- a/src/com/android/settings/SettingsActivity.java
+++ b/src/com/android/settings/SettingsActivity.java
@@ -16,6 +16,8 @@
 
 package com.android.settings;
 
+import static android.view.View.IMPORTANT_FOR_ACCESSIBILITY_NO;
+
 import android.app.ActionBar;
 import android.app.ActivityManager;
 import android.app.Fragment;
@@ -44,6 +46,7 @@
 import android.support.v7.preference.PreferenceManager;
 import android.text.TextUtils;
 import android.transition.TransitionManager;
+import android.util.FeatureFlagUtils;
 import android.util.Log;
 import android.view.View;
 import android.view.View.OnClickListener;
@@ -55,6 +58,7 @@
 import com.android.settings.Settings.WifiSettingsActivity;
 import com.android.settings.applications.manageapplications.ManageApplications;
 import com.android.settings.backup.BackupSettingsActivity;
+import com.android.settings.core.FeatureFlags;
 import com.android.settings.core.gateway.SettingsGateway;
 import com.android.settings.dashboard.DashboardFeatureProvider;
 import com.android.settings.dashboard.DashboardSummary;
@@ -80,8 +84,6 @@
 
     // Constants for state save/restore
     private static final String SAVE_KEY_CATEGORIES = ":settings:categories";
-    @VisibleForTesting
-    static final String SAVE_KEY_SHOW_HOME_AS_UP = ":settings:show_home_as_up";
 
     /**
      * When starting this activity, the invoking Intent can contain this extra
@@ -144,12 +146,10 @@
     public static final String EXTRA_HIDE_DRAWER = ":settings:hide_drawer";
 
     public static final String META_DATA_KEY_FRAGMENT_CLASS =
-        "com.android.settings.FRAGMENT_CLASS";
+            "com.android.settings.FRAGMENT_CLASS";
 
     private static final String EXTRA_UI_OPTIONS = "settings:ui_options";
 
-    private static final int REQUEST_SUGGESTION = 42;
-
     private String mFragmentClass;
 
     private CharSequence mInitialTitle;
@@ -181,9 +181,6 @@
 
     private Button mNextButton;
 
-    @VisibleForTesting
-    boolean mDisplayHomeAsUpEnabled;
-
     private boolean mIsShowingDashboard;
     private boolean mIsShortcut;
 
@@ -195,7 +192,6 @@
     private ArrayList<DashboardCategory> mCategories = new ArrayList<>();
 
     private DashboardFeatureProvider mDashboardFeatureProvider;
-    private ComponentName mCurrentSuggestion;
 
     public SwitchBar getSwitchBar() {
         return mSwitchBar;
@@ -308,9 +304,6 @@
                 mCategories.addAll(categories);
                 setTitleFromBackStack();
             }
-
-            mDisplayHomeAsUpEnabled = savedState.getBoolean(SAVE_KEY_SHOW_HOME_AS_UP);
-
         } else {
             launchSettingFragment(initialFragmentName, isSubSettings, intent);
         }
@@ -329,13 +322,14 @@
             // and goes to the search UI. Also set the background to null so there's no ripple.
             View navView = toolbar.getNavigationView();
             navView.setClickable(false);
+            navView.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
             navView.setBackground(null);
         }
 
         ActionBar actionBar = getActionBar();
         if (actionBar != null) {
-            actionBar.setDisplayHomeAsUpEnabled(mDisplayHomeAsUpEnabled);
-            actionBar.setHomeButtonEnabled(mDisplayHomeAsUpEnabled);
+            actionBar.setDisplayHomeAsUpEnabled(true);
+            actionBar.setHomeButtonEnabled(true);
             actionBar.setDisplayShowTitleEnabled(!mIsShowingDashboard);
         }
         mSwitchBar = findViewById(R.id.switch_bar);
@@ -350,21 +344,21 @@
             if (buttonBar != null) {
                 buttonBar.setVisibility(View.VISIBLE);
 
-                Button backButton = (Button)findViewById(R.id.back_button);
+                Button backButton = (Button) findViewById(R.id.back_button);
                 backButton.setOnClickListener(new OnClickListener() {
                     public void onClick(View v) {
                         setResult(RESULT_CANCELED, null);
                         finish();
                     }
                 });
-                Button skipButton = (Button)findViewById(R.id.skip_button);
+                Button skipButton = (Button) findViewById(R.id.skip_button);
                 skipButton.setOnClickListener(new OnClickListener() {
                     public void onClick(View v) {
                         setResult(RESULT_OK, null);
                         finish();
                     }
                 });
-                mNextButton = (Button)findViewById(R.id.next_button);
+                mNextButton = (Button) findViewById(R.id.next_button);
                 mNextButton.setOnClickListener(new OnClickListener() {
                     public void onClick(View v) {
                         setResult(RESULT_OK, null);
@@ -377,8 +371,7 @@
                     String buttonText = intent.getStringExtra(EXTRA_PREFS_SET_NEXT_TEXT);
                     if (TextUtils.isEmpty(buttonText)) {
                         mNextButton.setVisibility(View.GONE);
-                    }
-                    else {
+                    } else {
                         mNextButton.setText(buttonText);
                     }
                 }
@@ -386,8 +379,7 @@
                     String buttonText = intent.getStringExtra(EXTRA_PREFS_SET_BACK_TEXT);
                     if (TextUtils.isEmpty(buttonText)) {
                         backButton.setVisibility(View.GONE);
-                    }
-                    else {
+                    } else {
                         backButton.setText(buttonText);
                     }
                 }
@@ -405,26 +397,17 @@
     @VisibleForTesting
     void launchSettingFragment(String initialFragmentName, boolean isSubSettings, Intent intent) {
         if (!mIsShowingDashboard && initialFragmentName != null) {
-            // UP will be shown only if it is a sub settings
-            if (mIsShortcut) {
-                mDisplayHomeAsUpEnabled = isSubSettings;
-            } else if (isSubSettings) {
-                mDisplayHomeAsUpEnabled = true;
-            } else {
-                mDisplayHomeAsUpEnabled = false;
-            }
             setTitleFromIntent(intent);
 
             Bundle initialArguments = intent.getBundleExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS);
             switchToFragment(initialFragmentName, initialArguments, true, false,
-                mInitialTitleResId, mInitialTitle, false);
+                    mInitialTitleResId, mInitialTitle, false);
         } else {
             // Show search icon as up affordance if we are displaying the main Dashboard
-            mDisplayHomeAsUpEnabled = true;
             mInitialTitleResId = R.string.dashboard_title;
 
             switchToFragment(DashboardSummary.class.getName(), null /* args */, false, false,
-                mInitialTitleResId, mInitialTitle, false);
+                    mInitialTitleResId, mInitialTitle, false);
         }
     }
 
@@ -506,15 +489,6 @@
         if (mCategories.size() > 0) {
             outState.putParcelableArrayList(SAVE_KEY_CATEGORIES, mCategories);
         }
-
-        outState.putBoolean(SAVE_KEY_SHOW_HOME_AS_UP, mDisplayHomeAsUpEnabled);
-    }
-
-    @Override
-    protected void onRestoreInstanceState(Bundle savedInstanceState) {
-        super.onRestoreInstanceState(savedInstanceState);
-
-        mDisplayHomeAsUpEnabled = savedInstanceState.getBoolean(SAVE_KEY_SHOW_HOME_AS_UP);
     }
 
     @Override
@@ -607,17 +581,17 @@
      * single-pane mode, a new activity will be launched in which to show the
      * fragment.
      *
-     * @param fragmentClass Full name of the class implementing the fragment.
-     * @param args Any desired arguments to supply to the fragment.
-     * @param titleRes Optional resource identifier of the title of this
-     * fragment.
-     * @param titleText Optional text of the title of this fragment.
-     * @param resultTo Optional fragment that result data should be sent to.
-     * If non-null, resultTo.onActivityResult() will be called when this
-     * preference panel is done.  The launched panel must use
-     * {@link #finishPreferencePanel(Fragment, int, Intent)} when done.
+     * @param fragmentClass     Full name of the class implementing the fragment.
+     * @param args              Any desired arguments to supply to the fragment.
+     * @param titleRes          Optional resource identifier of the title of this
+     *                          fragment.
+     * @param titleText         Optional text of the title of this fragment.
+     * @param resultTo          Optional fragment that result data should be sent to.
+     *                          If non-null, resultTo.onActivityResult() will be called when this
+     *                          preference panel is done.  The launched panel must use
+     *                          {@link #finishPreferencePanel(Fragment, int, Intent)} when done.
      * @param resultRequestCode If resultTo is non-null, this is the caller's
-     * request code to be received with the result.
+     *                          request code to be received with the result.
      */
     public void startPreferencePanel(Fragment caller, String fragmentClass, Bundle args,
             int titleRes, CharSequence titleText, Fragment resultTo, int resultRequestCode) {
@@ -636,10 +610,10 @@
      * activity will be launched in which to show the fragment.
      *
      * @param fragmentClass Full name of the class implementing the fragment.
-     * @param args Any desired arguments to supply to the fragment.
-     * @param titleRes Optional resource identifier of the title of this fragment.
-     * @param titleText Optional text of the title of this fragment.
-     * @param userHandle The user for which the panel has to be started.
+     * @param args          Any desired arguments to supply to the fragment.
+     * @param titleRes      Optional resource identifier of the title of this fragment.
+     * @param titleText     Optional text of the title of this fragment.
+     * @param userHandle    The user for which the panel has to be started.
      */
     public void startPreferencePanelAsUser(Fragment caller, String fragmentClass,
             Bundle args, int titleRes, CharSequence titleText, UserHandle userHandle) {
@@ -673,11 +647,11 @@
     /**
      * Called by a preference panel fragment to finish itself.
      *
-     * @param caller The fragment that is asking to be finished.
+     * @param caller     The fragment that is asking to be finished.
      * @param resultCode Optional result code to send back to the original
-     * launching fragment.
+     *                   launching fragment.
      * @param resultData Optional result data to send back to the original
-     * launching fragment.
+     *                   launching fragment.
      */
     public void finishPreferencePanel(Fragment caller, int resultCode, Intent resultData) {
         setResult(resultCode, resultData);
@@ -688,8 +662,8 @@
      * Start a new fragment.
      *
      * @param fragment The fragment to start
-     * @param push If true, the current fragment will be pushed onto the back stack.  If false,
-     * the current fragment will be replaced.
+     * @param push     If true, the current fragment will be pushed onto the back stack.  If false,
+     *                 the current fragment will be replaced.
      */
     public void startPreferenceFragment(Fragment fragment, boolean push) {
         FragmentTransaction transaction = getFragmentManager().beginTransaction();
@@ -759,31 +733,11 @@
                 pm.hasSystemFeature(PackageManager.FEATURE_BLUETOOTH), isAdmin)
                 || somethingChanged;
 
-        boolean isDataPlanFeatureEnabled = FeatureFactory.getFactory(this)
-                .getDataPlanFeatureProvider()
-                .isEnabled();
-
-        // When the data plan feature flag is turned on we disable DataUsageSummaryActivity
-        // and enable DataPlanUsageSummaryActivity. When the feature flag is turned off we do the
-        // reverse.
-
-        // Disable DataUsageSummaryActivity if the data plan feature flag is turned on otherwise
-        // disable DataPlanUsageSummaryActivity.
-        somethingChanged = setTileEnabled(
-                new ComponentName(packageName,
-                        isDataPlanFeatureEnabled
-                                ? Settings.DataUsageSummaryActivity.class.getName()
-                                : Settings.DataPlanUsageSummaryActivity.class.getName()),
-                false /* enabled */,
-                isAdmin) || somethingChanged;
 
         // Enable DataUsageSummaryActivity if the data plan feature flag is turned on otherwise
         // enable DataPlanUsageSummaryActivity.
         somethingChanged = setTileEnabled(
-                new ComponentName(packageName,
-                        isDataPlanFeatureEnabled
-                                ? Settings.DataPlanUsageSummaryActivity.class.getName()
-                                : Settings.DataUsageSummaryActivity.class.getName()),
+                new ComponentName(packageName, Settings.DataUsageSummaryActivity.class.getName()),
                 Utils.isBandwidthControlEnabled() /* enabled */,
                 isAdmin) || somethingChanged;
 
@@ -819,6 +773,19 @@
                         Settings.PowerUsageSummaryLegacyActivity.class.getName()),
                 mBatteryPresent && !isBatterySettingsV2Enabled, isAdmin) || somethingChanged;
 
+        final boolean isDataUsageSettingsV2Enabled =
+                FeatureFlagUtils.isEnabled(this, FeatureFlags.DATA_USAGE_SETTINGS_V2);
+        // Enable new data usage page if v2 enabled
+        somethingChanged = setTileEnabled(new ComponentName(packageName,
+                        Settings.DataUsageSummaryActivity.class.getName()),
+                Utils.isBandwidthControlEnabled() && isDataUsageSettingsV2Enabled, isAdmin)
+                || somethingChanged;
+        // Enable legacy data usage page if v2 disabled
+        somethingChanged = setTileEnabled(new ComponentName(packageName,
+                        Settings.DataUsageSummaryLegacyActivity.class.getName()),
+                Utils.isBandwidthControlEnabled() && !isDataUsageSettingsV2Enabled, isAdmin)
+                || somethingChanged;
+
         somethingChanged = setTileEnabled(new ComponentName(packageName,
                         Settings.UserSettingsActivity.class.getName()),
                 UserHandle.MU_ENABLED && UserManager.supportsMultipleUsers()
@@ -835,13 +802,7 @@
                 !UserManager.isDeviceInDemoMode(this), isAdmin)
                 || somethingChanged;
 
-        somethingChanged = setTileEnabled(new ComponentName(packageName,
-                        Settings.PrintSettingsActivity.class.getName()),
-                pm.hasSystemFeature(PackageManager.FEATURE_PRINTING), isAdmin)
-                || somethingChanged;
-
         final boolean showDev = DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(this)
-                && !um.hasUserRestriction(UserManager.DISALLOW_DEBUGGING_FEATURES)
                 && !Utils.isMonkeyRunning();
 
         somethingChanged = setTileEnabled(new ComponentName(packageName,
@@ -937,29 +898,6 @@
         return mNextButton;
     }
 
-    @Override
-    public boolean shouldUpRecreateTask(Intent targetIntent) {
-        return super.shouldUpRecreateTask(new Intent(this, SettingsActivity.class));
-    }
-
-    public void startSuggestion(Intent intent) {
-        if (intent == null || ActivityManager.isUserAMonkey()) {
-            return;
-        }
-        mCurrentSuggestion = intent.getComponent();
-        startActivityForResult(intent, REQUEST_SUGGESTION);
-    }
-
-    @Override
-    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
-        if (requestCode == REQUEST_SUGGESTION && mCurrentSuggestion != null
-                && resultCode != RESULT_CANCELED) {
-            getPackageManager().setComponentEnabledSetting(mCurrentSuggestion,
-                    PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
-        }
-        super.onActivityResult(requestCode, resultCode, data);
-    }
-
     @VisibleForTesting
     Bitmap getBitmapFromXmlResource(int drawableRes) {
         Drawable drawable = getResources().getDrawable(drawableRes, getTheme());
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index f45ac5e..1a32127 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -52,11 +52,8 @@
 import android.graphics.drawable.BitmapDrawable;
 import android.graphics.drawable.Drawable;
 import android.hardware.fingerprint.FingerprintManager;
-import android.icu.text.MeasureFormat;
 import android.icu.text.RelativeDateTimeFormatter;
 import android.icu.text.RelativeDateTimeFormatter.RelativeUnit;
-import android.icu.util.Measure;
-import android.icu.util.MeasureUnit;
 import android.icu.util.ULocale;
 import android.net.ConnectivityManager;
 import android.net.LinkProperties;
@@ -88,8 +85,6 @@
 import android.telephony.TelephonyManager;
 import android.text.Spannable;
 import android.text.SpannableString;
-import android.text.SpannableStringBuilder;
-import android.text.Spanned;
 import android.text.TextUtils;
 import android.text.format.DateUtils;
 import android.text.style.TtsSpan;
@@ -112,6 +107,7 @@
 import com.android.settings.wrapper.FingerprintManagerWrapper;
 import com.android.settingslib.core.instrumentation.VisibilityLoggerMixin;
 
+import com.android.settingslib.utils.StringUtil;
 import java.net.InetAddress;
 import java.util.ArrayList;
 import java.util.Iterator;
@@ -138,10 +134,6 @@
 
     private static final String SETTINGS_PACKAGE_NAME = "com.android.settings";
 
-    private static final int SECONDS_PER_MINUTE = 60;
-    private static final int SECONDS_PER_HOUR = 60 * 60;
-    private static final int SECONDS_PER_DAY = 24 * 60 * 60;
-
     public static final String OS_PKG = "os";
 
     /**
@@ -772,113 +764,6 @@
     }
 
     /**
-     * Returns elapsed time for the given millis, in the following format:
-     * 2d 5h 40m 29s
-     * @param context the application context
-     * @param millis the elapsed time in milli seconds
-     * @param withSeconds include seconds?
-     * @return the formatted elapsed time
-     */
-    public static CharSequence formatElapsedTime(Context context, double millis,
-            boolean withSeconds) {
-        SpannableStringBuilder sb = new SpannableStringBuilder();
-        int seconds = (int) Math.floor(millis / 1000);
-        if (!withSeconds) {
-            // Round up.
-            seconds += 30;
-        }
-
-        int days = 0, hours = 0, minutes = 0;
-        if (seconds >= SECONDS_PER_DAY) {
-            days = seconds / SECONDS_PER_DAY;
-            seconds -= days * SECONDS_PER_DAY;
-        }
-        if (seconds >= SECONDS_PER_HOUR) {
-            hours = seconds / SECONDS_PER_HOUR;
-            seconds -= hours * SECONDS_PER_HOUR;
-        }
-        if (seconds >= SECONDS_PER_MINUTE) {
-            minutes = seconds / SECONDS_PER_MINUTE;
-            seconds -= minutes * SECONDS_PER_MINUTE;
-        }
-
-        final ArrayList<Measure> measureList = new ArrayList(4);
-        if (days > 0) {
-            measureList.add(new Measure(days, MeasureUnit.DAY));
-        }
-        if (hours > 0) {
-            measureList.add(new Measure(hours, MeasureUnit.HOUR));
-        }
-        if (minutes > 0) {
-            measureList.add(new Measure(minutes, MeasureUnit.MINUTE));
-        }
-        if (withSeconds && seconds > 0) {
-            measureList.add(new Measure(seconds, MeasureUnit.SECOND));
-        }
-        if (measureList.size() == 0) {
-            // Everything addable was zero, so nothing was added. We add a zero.
-            measureList.add(new Measure(0, withSeconds ? MeasureUnit.SECOND : MeasureUnit.MINUTE));
-        }
-        final Measure[] measureArray = measureList.toArray(new Measure[measureList.size()]);
-
-        final Locale locale = context.getResources().getConfiguration().locale;
-        final MeasureFormat measureFormat = MeasureFormat.getInstance(
-                locale, MeasureFormat.FormatWidth.NARROW);
-        sb.append(measureFormat.formatMeasures(measureArray));
-
-        if (measureArray.length == 1 && MeasureUnit.MINUTE.equals(measureArray[0].getUnit())) {
-            // Add ttsSpan if it only have minute value, because it will be read as "meters"
-            final TtsSpan ttsSpan = new TtsSpan.MeasureBuilder().setNumber(minutes)
-                    .setUnit("minute").build();
-            sb.setSpan(ttsSpan, 0, sb.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
-        }
-
-        return sb;
-    }
-
-    /**
-     * Returns relative time for the given millis in the past, in a short format such as "2 days
-     * ago", "5 hr. ago", "40 min. ago", or "29 sec. ago".
-     *
-     * <p>The unit is chosen to have good information value while only using one unit. So 27 hours
-     * and 50 minutes would be formatted as "28 hr. ago", while 50 hours would be formatted as
-     * "2 days ago".
-     *
-     * @param context the application context
-     * @param millis the elapsed time in milli seconds
-     * @param withSeconds include seconds?
-     * @return the formatted elapsed time
-     */
-    public static CharSequence formatRelativeTime(Context context, double millis,
-            boolean withSeconds) {
-        final int seconds = (int) Math.floor(millis / 1000);
-        final RelativeUnit unit;
-        final int value;
-        if (withSeconds && seconds < 2 * SECONDS_PER_MINUTE) {
-            unit = RelativeUnit.SECONDS;
-            value = seconds;
-        } else if (seconds < 2 * SECONDS_PER_HOUR) {
-            unit = RelativeUnit.MINUTES;
-            value = (seconds + SECONDS_PER_MINUTE / 2) / SECONDS_PER_MINUTE;
-        } else if (seconds < 2 * SECONDS_PER_DAY) {
-            unit = RelativeUnit.HOURS;
-            value = (seconds + SECONDS_PER_HOUR / 2) / SECONDS_PER_HOUR;
-        } else {
-            unit = RelativeUnit.DAYS;
-            value = (seconds + SECONDS_PER_DAY / 2) / SECONDS_PER_DAY;
-        }
-
-        final Locale locale = context.getResources().getConfiguration().locale;
-        final RelativeDateTimeFormatter formatter = RelativeDateTimeFormatter.getInstance(
-                ULocale.forLocale(locale),
-                null /* default NumberFormat */,
-                RelativeDateTimeFormatter.Style.SHORT,
-                android.icu.text.DisplayContext.CAPITALIZATION_FOR_MIDDLE_OF_SENTENCE);
-
-        return formatter.format(value, RelativeDateTimeFormatter.Direction.LAST, unit);
-    }
-
-    /**
      * Queries for the UserInfo of a user. Returns null if the user doesn't exist (was removed).
      * @param userManager Instance of UserManager
      * @param checkUser The user to check the existence of.
diff --git a/src/com/android/settings/accounts/AccountTypePreference.java b/src/com/android/settings/accounts/AccountTypePreference.java
index 1d39473..574cbd5 100644
--- a/src/com/android/settings/accounts/AccountTypePreference.java
+++ b/src/com/android/settings/accounts/AccountTypePreference.java
@@ -103,7 +103,8 @@
             }
             Utils.startWithFragment(getContext(), mFragment, mFragmentArguments,
                 null /* resultTo */, 0 /* resultRequestCode */, mTitleResPackageName,
-                mTitleResId, null /* title */, mMetricsCategory);
+                mTitleResId, null /* title */,false /* isShortCut */, mMetricsCategory,
+                    0 /* flag */);
             return true;
         }
         return false;
diff --git a/src/com/android/settings/applications/LayoutPreference.java b/src/com/android/settings/applications/LayoutPreference.java
index f2bd183..6940a4b 100644
--- a/src/com/android/settings/applications/LayoutPreference.java
+++ b/src/com/android/settings/applications/LayoutPreference.java
@@ -42,6 +42,24 @@
 
     public LayoutPreference(Context context, AttributeSet attrs) {
         super(context, attrs);
+        init(context, attrs, 0 /* defStyleAttr */);
+    }
+
+    public LayoutPreference(Context context, AttributeSet attrs, int defStyleAttr) {
+        super(context, attrs, defStyleAttr);
+        init(context, attrs, defStyleAttr);
+    }
+
+    public LayoutPreference(Context context, int resource) {
+        this(context, LayoutInflater.from(context).inflate(resource, null, false));
+    }
+
+    public LayoutPreference(Context context, View view) {
+        super(context);
+        setView(view);
+    }
+
+    private void init(Context context, AttributeSet attrs, int defStyleAttr) {
         TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Preference);
         mAllowDividerAbove = TypedArrayUtils.getBoolean(a, R.styleable.Preference_allowDividerAbove,
                 R.styleable.Preference_allowDividerAbove, false);
@@ -50,7 +68,7 @@
         a.recycle();
 
         a = context.obtainStyledAttributes(
-                attrs, com.android.internal.R.styleable.Preference, 0, 0);
+                attrs, com.android.internal.R.styleable.Preference, defStyleAttr, 0);
         int layoutResource = a.getResourceId(com.android.internal.R.styleable.Preference_layout,
                 0);
         if (layoutResource == 0) {
@@ -64,15 +82,6 @@
         setView(view);
     }
 
-    public LayoutPreference(Context context, int resource) {
-        this(context, LayoutInflater.from(context).inflate(resource, null, false));
-    }
-
-    public LayoutPreference(Context context, View view) {
-        super(context);
-        setView(view);
-    }
-
     private void setView(View view) {
         setLayoutResource(R.layout.layout_preference_frame);
         final ViewGroup allDetails = view.findViewById(R.id.all_details);
@@ -106,4 +115,4 @@
         return mRootView.findViewById(id);
     }
 
-}
+}
\ No newline at end of file
diff --git a/src/com/android/settings/applications/RecentAppsPreferenceController.java b/src/com/android/settings/applications/RecentAppsPreferenceController.java
index e15671b..b177225 100644
--- a/src/com/android/settings/applications/RecentAppsPreferenceController.java
+++ b/src/com/android/settings/applications/RecentAppsPreferenceController.java
@@ -38,13 +38,13 @@
 import android.util.Log;
 
 import com.android.settings.R;
-import com.android.settings.Utils;
 import com.android.settings.applications.appinfo.AppInfoDashboardFragment;
 import com.android.settings.core.PreferenceControllerMixin;
 import com.android.settings.widget.AppPreference;
 import com.android.settingslib.applications.AppUtils;
 import com.android.settingslib.applications.ApplicationsState;
 import com.android.settingslib.core.AbstractPreferenceController;
+import com.android.settingslib.utils.StringUtil;
 import com.android.settingslib.wrapper.PackageManagerWrapper;
 
 import java.util.ArrayList;
@@ -239,7 +239,7 @@
             pref.setKey(pkgName);
             pref.setTitle(appEntry.label);
             pref.setIcon(mIconDrawableFactory.getBadgedIcon(appEntry.info));
-            pref.setSummary(Utils.formatRelativeTime(mContext,
+            pref.setSummary(StringUtil.formatRelativeTime(mContext,
                     System.currentTimeMillis() - stat.getLastTimeUsed(), false));
             pref.setOrder(i);
             pref.setOnPreferenceClickListener(preference -> {
diff --git a/src/com/android/settings/backup/BackupSettingsHelper.java b/src/com/android/settings/backup/BackupSettingsHelper.java
index b0d6cf8..d0a029c 100644
--- a/src/com/android/settings/backup/BackupSettingsHelper.java
+++ b/src/com/android/settings/backup/BackupSettingsHelper.java
@@ -24,13 +24,12 @@
 import android.os.RemoteException;
 import android.os.ServiceManager;
 import android.os.UserHandle;
-import android.util.Log;
-
 import android.support.annotation.VisibleForTesting;
+import android.util.Log;
 
 import com.android.settings.R;
 import com.android.settings.Settings.PrivacySettingsActivity;
-import com.android.settingslib.drawer.SettingsDrawerActivity;
+
 import java.net.URISyntaxException;
 
 /**
@@ -153,8 +152,7 @@
 
     private Intent getIntentForDefaultBackupSettings() {
         // Extra needed by {@link SettingsDrawerActivity} to show the back button navigation.
-        return new Intent(mContext, PrivacySettingsActivity.class)
-                .putExtra(SettingsDrawerActivity.EXTRA_SHOW_MENU, true);
+        return new Intent(mContext, PrivacySettingsActivity.class);
     }
 
     /**
diff --git a/src/com/android/settings/connecteddevice/AdvancedConnectedDeviceDashboardFragment.java b/src/com/android/settings/connecteddevice/AdvancedConnectedDeviceDashboardFragment.java
index 9ac6ebd..32c2af7 100644
--- a/src/com/android/settings/connecteddevice/AdvancedConnectedDeviceDashboardFragment.java
+++ b/src/com/android/settings/connecteddevice/AdvancedConnectedDeviceDashboardFragment.java
@@ -29,6 +29,7 @@
 import com.android.settings.dashboard.DashboardFragment;
 import com.android.settings.nfc.NfcPreferenceController;
 import com.android.settings.overlay.FeatureFactory;
+import com.android.settings.print.PrintSettingPreferenceController;
 import com.android.settings.search.BaseSearchIndexProvider;
 import com.android.settingslib.core.AbstractPreferenceController;
 import com.android.settingslib.core.lifecycle.Lifecycle;
@@ -43,7 +44,6 @@
 public class AdvancedConnectedDeviceDashboardFragment extends DashboardFragment {
 
     private static final String TAG = "AdvancedConnectedDeviceFrag";
-    private UsbModePreferenceController mUsbPrefController;
 
     @Override
     public int getMetricsCategory() {
@@ -67,27 +67,32 @@
 
     @Override
     protected List<AbstractPreferenceController> getPreferenceControllers(Context context) {
+        return buildControllers(context, getLifecycle());
+    }
+
+    private static List<AbstractPreferenceController> buildControllers(Context context,
+            Lifecycle lifecycle) {
         final List<AbstractPreferenceController> controllers = new ArrayList<>();
-        final Lifecycle lifecycle = getLifecycle();
         final NfcPreferenceController nfcPreferenceController =
                 new NfcPreferenceController(context);
-        lifecycle.addObserver(nfcPreferenceController);
         controllers.add(nfcPreferenceController);
-        mUsbPrefController = new UsbModePreferenceController(context, new UsbBackend(context));
-        lifecycle.addObserver(mUsbPrefController);
-        controllers.add(mUsbPrefController);
+        controllers.add(new UsbModePreferenceController(
+                context, new UsbBackend(context), lifecycle));
         final BluetoothSwitchPreferenceController bluetoothPreferenceController =
                 new BluetoothSwitchPreferenceController(context);
-        lifecycle.addObserver(bluetoothPreferenceController);
         controllers.add(bluetoothPreferenceController);
 
-        SmsMirroringFeatureProvider smsMirroringFeatureProvider =
-                FeatureFactory.getFactory(context).getSmsMirroringFeatureProvider();
-        AbstractPreferenceController smsMirroringController =
-                smsMirroringFeatureProvider.getController(context);
-        controllers.add(smsMirroringController);
         controllers.add(new BluetoothFilesPreferenceController(context));
         controllers.add(new BluetoothOnWhileDrivingPreferenceController(context));
+        final PrintSettingPreferenceController printerController =
+                new PrintSettingPreferenceController(context);
+        if (lifecycle != null) {
+            lifecycle.addObserver(printerController);
+            lifecycle.addObserver(nfcPreferenceController);
+            lifecycle.addObserver(bluetoothPreferenceController);
+        }
+        controllers.add(printerController);
+
         return controllers;
     }
 
@@ -114,13 +119,13 @@
                     }
                     keys.add(BluetoothMasterSwitchPreferenceController.KEY_TOGGLE_BLUETOOTH);
 
-                    SmsMirroringFeatureProvider smsMirroringFeatureProvider =
-                            FeatureFactory.getFactory(context).getSmsMirroringFeatureProvider();
-                    SmsMirroringPreferenceController smsMirroringController =
-                            smsMirroringFeatureProvider.getController(context);
-                    smsMirroringController.updateNonIndexableKeys(keys);
-
                     return keys;
                 }
+
+                @Override
+                public List<AbstractPreferenceController> getPreferenceControllers(
+                        Context context) {
+                    return buildControllers(context, null /* lifecycle */);
+                }
             };
 }
diff --git a/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragmentOld.java b/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragmentOld.java
index bde5e81..54ae8f6 100644
--- a/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragmentOld.java
+++ b/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragmentOld.java
@@ -80,8 +80,8 @@
                 new NfcPreferenceController(context);
         lifecycle.addObserver(nfcPreferenceController);
         controllers.add(nfcPreferenceController);
-        mUsbPrefController = new UsbModePreferenceController(context, new UsbBackend(context));
-        lifecycle.addObserver(mUsbPrefController);
+        mUsbPrefController = new UsbModePreferenceController(context, new UsbBackend(context),
+                lifecycle);
         controllers.add(mUsbPrefController);
         final BluetoothMasterSwitchPreferenceController bluetoothPreferenceController =
                 new BluetoothMasterSwitchPreferenceController(
@@ -90,11 +90,6 @@
         lifecycle.addObserver(bluetoothPreferenceController);
         controllers.add(bluetoothPreferenceController);
 
-        SmsMirroringFeatureProvider smsMirroringFeatureProvider =
-                FeatureFactory.getFactory(context).getSmsMirroringFeatureProvider();
-        AbstractPreferenceController smsMirroringController =
-                smsMirroringFeatureProvider.getController(context);
-        controllers.add(smsMirroringController);
         return controllers;
     }
 
@@ -157,12 +152,6 @@
                     }
                     keys.add(BluetoothMasterSwitchPreferenceController.KEY_TOGGLE_BLUETOOTH);
 
-                    SmsMirroringFeatureProvider smsMirroringFeatureProvider =
-                            FeatureFactory.getFactory(context).getSmsMirroringFeatureProvider();
-                    SmsMirroringPreferenceController smsMirroringController =
-                            smsMirroringFeatureProvider.getController(context);
-                    smsMirroringController.updateNonIndexableKeys(keys);
-
                     return keys;
                 }
             };
diff --git a/src/com/android/settings/connecteddevice/SmsMirroringFeatureProvider.java b/src/com/android/settings/connecteddevice/SmsMirroringFeatureProvider.java
deleted file mode 100644
index 9064c81..0000000
--- a/src/com/android/settings/connecteddevice/SmsMirroringFeatureProvider.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.connecteddevice;
-
-import android.content.Context;
-
-public interface SmsMirroringFeatureProvider {
-
-    /** Returns whether to show SMS mirroring. */
-    boolean shouldShowSmsMirroring(Context context);
-
-    /** Returns a preference controller for SMS mirroring. */
-    SmsMirroringPreferenceController getController(Context context);
-}
diff --git a/src/com/android/settings/connecteddevice/SmsMirroringFeatureProviderImpl.java b/src/com/android/settings/connecteddevice/SmsMirroringFeatureProviderImpl.java
deleted file mode 100644
index c41d8f5..0000000
--- a/src/com/android/settings/connecteddevice/SmsMirroringFeatureProviderImpl.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.settings.connecteddevice;
-
-import android.content.Context;
-
-public class SmsMirroringFeatureProviderImpl implements SmsMirroringFeatureProvider {
-    @Override
-    public boolean shouldShowSmsMirroring(Context context) {
-        return false;
-    }
-
-    @Override
-    public SmsMirroringPreferenceController getController(Context context) {
-        return new SmsMirroringPreferenceController(context);
-    }
-}
-
diff --git a/src/com/android/settings/connecteddevice/SmsMirroringPreferenceController.java b/src/com/android/settings/connecteddevice/SmsMirroringPreferenceController.java
deleted file mode 100644
index c293481..0000000
--- a/src/com/android/settings/connecteddevice/SmsMirroringPreferenceController.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.settings.connecteddevice;
-
-import android.content.Context;
-
-import com.android.settings.core.PreferenceControllerMixin;
-import com.android.settings.overlay.FeatureFactory;
-import com.android.settingslib.core.AbstractPreferenceController;
-
-public class SmsMirroringPreferenceController extends AbstractPreferenceController
-        implements PreferenceControllerMixin {
-
-    static final String KEY_SMS_MIRRORING = "sms_mirroring";
-
-    private SmsMirroringFeatureProvider mFeatureProvider;
-
-    public SmsMirroringPreferenceController(Context context) {
-        super(context);
-        mFeatureProvider = FeatureFactory.getFactory(context).getSmsMirroringFeatureProvider();
-    }
-
-    @Override
-    public boolean isAvailable() {
-        return mFeatureProvider.shouldShowSmsMirroring(mContext);
-    }
-
-    @Override
-    public String getPreferenceKey() {
-        return KEY_SMS_MIRRORING;
-    }
-}
diff --git a/src/com/android/settings/connecteddevice/usb/UsbModePreferenceController.java b/src/com/android/settings/connecteddevice/usb/UsbModePreferenceController.java
index e342460..d7624f0 100644
--- a/src/com/android/settings/connecteddevice/usb/UsbModePreferenceController.java
+++ b/src/com/android/settings/connecteddevice/usb/UsbModePreferenceController.java
@@ -23,6 +23,7 @@
 import com.android.settings.R;
 import com.android.settings.core.PreferenceControllerMixin;
 import com.android.settingslib.core.AbstractPreferenceController;
+import com.android.settingslib.core.lifecycle.Lifecycle;
 import com.android.settingslib.core.lifecycle.LifecycleObserver;
 import com.android.settingslib.core.lifecycle.events.OnPause;
 import com.android.settingslib.core.lifecycle.events.OnResume;
@@ -37,12 +38,16 @@
     UsbConnectionBroadcastReceiver mUsbReceiver;
     private Preference mUsbPreference;
 
-    public UsbModePreferenceController(Context context, UsbBackend usbBackend) {
+    public UsbModePreferenceController(Context context, UsbBackend usbBackend,
+            Lifecycle lifecycle) {
         super(context);
         mUsbBackend = usbBackend;
         mUsbReceiver = new UsbConnectionBroadcastReceiver(mContext, (connected, newMode) -> {
             updateSummary(mUsbPreference, connected, newMode);
         }, mUsbBackend);
+        if (lifecycle != null) {
+            lifecycle.addObserver(this);
+        }
     }
 
     @Override
diff --git a/src/com/android/settings/core/BasePreferenceController.java b/src/com/android/settings/core/BasePreferenceController.java
index 01d98b8..777f3dd 100644
--- a/src/com/android/settings/core/BasePreferenceController.java
+++ b/src/com/android/settings/core/BasePreferenceController.java
@@ -21,6 +21,7 @@
 import com.android.settings.search.ResultPayload;
 import com.android.settings.search.SearchIndexableRaw;
 import com.android.settingslib.core.AbstractPreferenceController;
+import com.android.settingslib.core.lifecycle.Lifecycle;
 
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
@@ -30,6 +31,8 @@
  * Abstract class to consolidate utility between preference controllers and act as an interface
  * for Slices. The abstract classes that inherit from this class will act as the direct interfaces
  * for each type when plugging into Slices.
+ *
+ * TODO (b/73074893) Add Lifecycle Setting method.
  */
 public abstract class BasePreferenceController extends AbstractPreferenceController {
 
@@ -68,6 +71,8 @@
 
     protected final String mPreferenceKey;
 
+    protected Lifecycle mLifecycle;
+
     public BasePreferenceController(Context context, String preferenceKey) {
         super(context);
         mPreferenceKey = preferenceKey;
diff --git a/src/com/android/settings/core/FeatureFlags.java b/src/com/android/settings/core/FeatureFlags.java
index 8fa1bb3..fd756df 100644
--- a/src/com/android/settings/core/FeatureFlags.java
+++ b/src/com/android/settings/core/FeatureFlags.java
@@ -26,4 +26,5 @@
     public static final String ZONE_PICKER_V2 = "settings_zone_picker_v2";
     public static final String ABOUT_PHONE_V2 = "settings_about_phone_v2";
     public static final String BLUETOOTH_WHILE_DRIVING = "settings_bluetooth_while_driving";
+    public static final String DATA_USAGE_SETTINGS_V2 = "settings_data_usage_v2";
 }
diff --git a/src/com/android/settings/core/gateway/SettingsGateway.java b/src/com/android/settings/core/gateway/SettingsGateway.java
index f43c3c8..c75b0c6 100644
--- a/src/com/android/settings/core/gateway/SettingsGateway.java
+++ b/src/com/android/settings/core/gateway/SettingsGateway.java
@@ -28,21 +28,21 @@
 import com.android.settings.TestingSettings;
 import com.android.settings.TetherSettings;
 import com.android.settings.TrustedCredentialsSettings;
-import com.android.settings.WifiCallingSettings;
+import com.android.settings.wifi.calling.WifiCallingSettings;
 import com.android.settings.accessibility.AccessibilitySettings;
 import com.android.settings.accessibility.AccessibilitySettingsForSetupWizard;
 import com.android.settings.accessibility.CaptionPropertiesFragment;
 import com.android.settings.accessibility.ToggleDaltonizerPreferenceFragment;
+import com.android.settings.accounts.AccountDashboardFragment;
 import com.android.settings.accounts.AccountSyncSettings;
 import com.android.settings.accounts.ChooseAccountActivity;
 import com.android.settings.accounts.ManagedProfileSettings;
-import com.android.settings.accounts.AccountDashboardFragment;
 import com.android.settings.applications.AppAndNotificationDashboardFragment;
 import com.android.settings.applications.DefaultAppSettings;
+import com.android.settings.applications.DirectoryAccessDetails;
 import com.android.settings.applications.ManageDomainUrls;
 import com.android.settings.applications.ProcessStatsSummary;
 import com.android.settings.applications.ProcessStatsUi;
-import com.android.settings.applications.DirectoryAccessDetails;
 import com.android.settings.applications.UsageAccessDetails;
 import com.android.settings.applications.VrListenerSettings;
 import com.android.settings.applications.appinfo.AppInfoDashboardFragment;
@@ -59,9 +59,9 @@
 import com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment;
 import com.android.settings.connecteddevice.ConnectedDeviceDashboardFragmentOld;
 import com.android.settings.connecteddevice.usb.UsbDetailsFragment;
-import com.android.settings.datausage.DataPlanUsageSummary;
 import com.android.settings.datausage.DataUsageList;
 import com.android.settings.datausage.DataUsageSummary;
+import com.android.settings.datausage.DataUsageSummaryLegacy;
 import com.android.settings.deletionhelper.AutomaticStorageManagerSettings;
 import com.android.settings.development.DevelopmentSettingsDashboardFragment;
 import com.android.settings.deviceinfo.DeviceInfoSettings;
@@ -74,7 +74,7 @@
 import com.android.settings.dream.DreamSettings;
 import com.android.settings.enterprise.EnterprisePrivacySettings;
 import com.android.settings.fuelgauge.AdvancedPowerUsageDetail;
-import com.android.settings.fuelgauge.BatterySaverSettings;
+import com.android.settings.fuelgauge.batterysaver.BatterySaverSettings;
 import com.android.settings.fuelgauge.PowerUsageSummary;
 import com.android.settings.fuelgauge.PowerUsageSummaryLegacy;
 import com.android.settings.gestures.AssistGestureSettings;
@@ -187,8 +187,8 @@
             PickupGestureSettings.class.getName(),
             DoubleTwistGestureSettings.class.getName(),
             CryptKeeperSettings.class.getName(),
-            DataPlanUsageSummary.class.getName(),
             DataUsageSummary.class.getName(),
+            DataUsageSummaryLegacy.class.getName(),
             DreamSettings.class.getName(),
             UserSettings.class.getName(),
             NotificationAccessSettings.class.getName(),
@@ -273,7 +273,6 @@
             SupportDashboardActivity.class.getName(),
             // Home page > Network & Internet
             Settings.WifiSettingsActivity.class.getName(),
-            Settings.DataPlanUsageSummaryActivity.class.getName(),
             Settings.DataUsageSummaryActivity.class.getName(),
             Settings.SimSettingsActivity.class.getName(),
             // Home page > Connected devices
diff --git a/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java b/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
index 086a131..3ed76d8 100644
--- a/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
+++ b/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
@@ -33,21 +33,18 @@
 import android.support.v7.preference.Preference;
 import android.text.TextUtils;
 import android.util.ArrayMap;
-import android.util.FeatureFlagUtils;
 import android.util.Log;
 import android.util.Pair;
 
 import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
 import com.android.settings.R;
 import com.android.settings.SettingsActivity;
-import com.android.settings.core.FeatureFlags;
 import com.android.settings.overlay.FeatureFactory;
 import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
 import com.android.settingslib.core.instrumentation.VisibilityLoggerMixin;
 import com.android.settingslib.drawer.CategoryManager;
 import com.android.settingslib.drawer.DashboardCategory;
 import com.android.settingslib.drawer.ProfileSelectDialog;
-import com.android.settingslib.drawer.SettingsDrawerActivity;
 import com.android.settingslib.drawer.Tile;
 import com.android.settingslib.drawer.TileUtils;
 import com.android.settingslib.utils.ThreadUtils;
@@ -212,7 +209,6 @@
         final Intent intent = new Intent(tile.intent)
                 .putExtra(VisibilityLoggerMixin.EXTRA_SOURCE_METRICS_CATEGORY,
                         MetricsEvent.DASHBOARD_SUMMARY)
-                .putExtra(SettingsDrawerActivity.EXTRA_SHOW_MENU, true)
                 .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
         launchIntentOrSelectProfile(activity, tile, intent, MetricsEvent.DASHBOARD_SUMMARY);
     }
diff --git a/src/com/android/settings/dashboard/DashboardSummary.java b/src/com/android/settings/dashboard/DashboardSummary.java
index 690c795..8ddef1c 100644
--- a/src/com/android/settings/dashboard/DashboardSummary.java
+++ b/src/com/android/settings/dashboard/DashboardSummary.java
@@ -55,7 +55,7 @@
         FocusListener, SuggestionControllerMixin.SuggestionControllerHost {
     public static final boolean DEBUG = false;
     private static final boolean DEBUG_TIMING = false;
-    private static final int MAX_WAIT_MILLIS = 700;
+    private static final int MAX_WAIT_MILLIS = 3000;
     private static final String TAG = "DashboardSummary";
 
     private static final String EXTRA_SCROLL_POSITION = "scroll_position";
diff --git a/src/com/android/settings/dashboard/conditional/BatterySaverCondition.java b/src/com/android/settings/dashboard/conditional/BatterySaverCondition.java
index 7feac23..7877f9d 100644
--- a/src/com/android/settings/dashboard/conditional/BatterySaverCondition.java
+++ b/src/com/android/settings/dashboard/conditional/BatterySaverCondition.java
@@ -20,7 +20,7 @@
 import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
 import com.android.settings.R;
 import com.android.settings.Utils;
-import com.android.settings.fuelgauge.BatterySaverSettings;
+import com.android.settings.fuelgauge.batterysaver.BatterySaverSettings;
 
 public class BatterySaverCondition extends Condition {
     public BatterySaverCondition(ConditionManager manager) {
diff --git a/src/com/android/settings/dashboard/suggestions/SuggestionAdapter.java b/src/com/android/settings/dashboard/suggestions/SuggestionAdapter.java
index 62bc148..b24a914 100644
--- a/src/com/android/settings/dashboard/suggestions/SuggestionAdapter.java
+++ b/src/com/android/settings/dashboard/suggestions/SuggestionAdapter.java
@@ -23,12 +23,15 @@
 import android.graphics.drawable.Icon;
 import android.os.Bundle;
 import android.service.settings.suggestions.Suggestion;
+import android.support.annotation.VisibleForTesting;
 import android.support.v7.widget.RecyclerView;
 import android.text.TextUtils;
+import android.util.DisplayMetrics;
 import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
+import android.view.WindowManager;
 import android.widget.ImageView;
 import android.widget.LinearLayout;
 
@@ -117,7 +120,7 @@
         mConfig.setCardLayout(holder, suggestionCount, position);
         final Icon icon = suggestion.getIcon();
         final Drawable drawable = mCache.getIcon(icon);
-        if ((suggestion.getFlags() & Suggestion.FLAG_ICON_TINTABLE) != 0) {
+        if (drawable != null && (suggestion.getFlags() & Suggestion.FLAG_ICON_TINTABLE) != 0) {
             drawable.setTint(Utils.getColorAccent(mContext));
         }
         holder.icon.setImageDrawable(drawable);
@@ -226,28 +229,27 @@
         return mSuggestions;
     }
 
-    private static class CardConfig {
+    @VisibleForTesting
+    static class CardConfig {
         // Card start/end margin
         private final int mMarginInner;
         private final int mMarginOuter;
-        // Card width for different numbers of cards
-        private final int mWidthSingleCard;
-        private final int mWidthTwoCards;
+        // Card width if there are more than 2 cards
         private final int mWidthMultipleCards;
         // padding between icon and title
         private final int mPaddingTitleTopSingleCard;
         private final int mPaddingTitleTopMultipleCards;
+        private final WindowManager mWindowManager;
 
         private static CardConfig sConfig;
 
         private CardConfig(Context context) {
+            mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
             final Resources res = context.getResources();
             mMarginInner =
                 res.getDimensionPixelOffset(R.dimen.suggestion_card_inner_margin);
             mMarginOuter =
                 res.getDimensionPixelOffset(R.dimen.suggestion_card_outer_margin);
-            mWidthSingleCard = res.getDimensionPixelOffset(R.dimen.suggestion_card_width_one_card);
-            mWidthTwoCards = res.getDimensionPixelOffset(R.dimen.suggestion_card_width_two_cards);
             mWidthMultipleCards =
                 res.getDimensionPixelOffset(R.dimen.suggestion_card_width_multiple_cards);
             mPaddingTitleTopSingleCard =
@@ -263,12 +265,12 @@
             return sConfig;
         }
 
-        private void setCardLayout(DashboardItemHolder holder, int suggestionCount,
-            int position) {
+        @VisibleForTesting
+        void setCardLayout(DashboardItemHolder holder, int suggestionCount, int position) {
             final LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
                 suggestionCount == 1
-                    ? mWidthSingleCard : suggestionCount == 2
-                    ? mWidthTwoCards : mWidthMultipleCards,
+                    ? LinearLayout.LayoutParams.MATCH_PARENT : suggestionCount == 2
+                    ? getWidthForTwoCrads() : mWidthMultipleCards,
                 LinearLayout.LayoutParams.WRAP_CONTENT);
             if (suggestionCount == 1) {
                 params.setMarginStart(mMarginOuter);
@@ -281,6 +283,16 @@
             holder.itemView.setLayoutParams(params);
         }
 
+        private int getWidthForTwoCrads() {
+            return (getScreenWidth() - mMarginInner - mMarginOuter * 2) / 2;
+        }
+
+        @VisibleForTesting
+        int getScreenWidth() {
+            final DisplayMetrics metrics = new DisplayMetrics();
+            mWindowManager.getDefaultDisplay().getMetrics(metrics);
+            return metrics.widthPixels;
+        }
     }
 
 }
diff --git a/src/com/android/settings/dashboard/suggestions/SuggestionFeatureProviderImpl.java b/src/com/android/settings/dashboard/suggestions/SuggestionFeatureProviderImpl.java
index 8523273..07ffb8a 100644
--- a/src/com/android/settings/dashboard/suggestions/SuggestionFeatureProviderImpl.java
+++ b/src/com/android/settings/dashboard/suggestions/SuggestionFeatureProviderImpl.java
@@ -37,7 +37,7 @@
 import com.android.settings.password.ScreenLockSuggestionActivity;
 import com.android.settings.support.NewDeviceIntroSuggestionActivity;
 import com.android.settings.wallpaper.WallpaperSuggestionActivity;
-import com.android.settings.wifi.WifiCallingSuggestionActivity;
+import com.android.settings.wifi.calling.WifiCallingSuggestionActivity;
 import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
 import com.android.settingslib.drawer.Tile;
 import com.android.settingslib.suggestions.SuggestionControllerMixin;
diff --git a/src/com/android/settings/datausage/DataPlanFeatureProvider.java b/src/com/android/settings/datausage/DataPlanFeatureProvider.java
deleted file mode 100644
index eb5b48f..0000000
--- a/src/com/android/settings/datausage/DataPlanFeatureProvider.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.datausage;
-
-/**
- * Feature provider for data plan feature.
- */
-public interface DataPlanFeatureProvider {
-  /**
-   * @return whether data plan feature is enabled.
-   */
-  boolean isEnabled();
-}
diff --git a/src/com/android/settings/datausage/DataPlanFeatureProviderImpl.java b/src/com/android/settings/datausage/DataPlanFeatureProviderImpl.java
deleted file mode 100644
index d5f435c..0000000
--- a/src/com/android/settings/datausage/DataPlanFeatureProviderImpl.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.datausage;
-
-import android.os.SystemProperties;
-
-/**
- * Impl for data plan feature provider.
- */
-public final class DataPlanFeatureProviderImpl implements DataPlanFeatureProvider {
-  private static final String ENABLE_SETTINGS_DATA_PLAN = "enable.settings.data.plan";
-
-  @Override
-  public boolean isEnabled() {
-    return SystemProperties.getBoolean(ENABLE_SETTINGS_DATA_PLAN, false /* default */);
-  }
-}
diff --git a/src/com/android/settings/datausage/DataPlanSummaryPreference.java b/src/com/android/settings/datausage/DataPlanSummaryPreference.java
deleted file mode 100644
index f48e04d..0000000
--- a/src/com/android/settings/datausage/DataPlanSummaryPreference.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the
- * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package com.android.settings.datausage;
-
-import android.content.Context;
-import android.support.annotation.ColorRes;
-import android.support.v7.preference.Preference;
-import android.support.v7.preference.PreferenceViewHolder;
-import android.util.AttributeSet;
-import android.widget.TextView;
-import com.android.settings.R;
-import com.android.settings.widget.DonutView;
-
-/**
- * Provides a summary of data plans as preferences on settings page.
- */
-public final class DataPlanSummaryPreference extends Preference {
-    private String mName;
-    private String mDescription;
-    private double mPercentageUsage;
-    private int mUsageTextColor;
-    private int mMeterBackgroundColor;
-    private int mMeterConsumedColor;
-
-    public DataPlanSummaryPreference(Context context) {
-        super(context);
-        setLayoutResource(R.layout.settings_data_plan_summary_preference);
-    }
-
-    public DataPlanSummaryPreference(Context context, AttributeSet attrs) {
-        super(context, attrs);
-        setLayoutResource(R.layout.settings_data_plan_summary_preference);
-    }
-
-    public void setName(String planName) {
-        mName = planName;
-        notifyChanged();
-    }
-
-    public void setDescription(String planDescription) {
-        mDescription = planDescription;
-        notifyChanged();
-    }
-
-    public void setPercentageUsage(double percentageUsage) {
-        mPercentageUsage = percentageUsage;
-        notifyChanged();
-    }
-
-    public void setUsageTextColor(@ColorRes int planUsageTextColor) {
-        mUsageTextColor = planUsageTextColor;
-        notifyChanged();
-    }
-
-    public void setMeterBackgroundColor(@ColorRes int meterBackgroundColor) {
-        mMeterBackgroundColor = meterBackgroundColor;
-        notifyChanged();
-    }
-
-    public void setMeterConsumedColor(@ColorRes int meterConsumedColor) {
-        mMeterConsumedColor = meterConsumedColor;
-        notifyChanged();
-    }
-
-    @Override
-    public void onBindViewHolder(PreferenceViewHolder holder) {
-        super.onBindViewHolder(holder);
-        holder.setDividerAllowedAbove(false);
-        TextView titleView = (TextView) holder.findViewById(android.R.id.title);
-        titleView.setTextColor(mUsageTextColor);
-        ((TextView) holder.findViewById(android.R.id.text1)).setText(mName);
-        ((TextView) holder.findViewById(android.R.id.text2)).setText(mDescription);
-        DonutView donutView = (DonutView) holder.findViewById(R.id.donut);
-        donutView.setPercentage(mPercentageUsage);
-        donutView.setMeterBackgroundColor(mMeterBackgroundColor);
-        donutView.setMeterConsumedColor(mMeterConsumedColor);
-    }
-}
diff --git a/src/com/android/settings/datausage/DataPlanUsageSummary.java b/src/com/android/settings/datausage/DataPlanUsageSummary.java
deleted file mode 100644
index 9489322..0000000
--- a/src/com/android/settings/datausage/DataPlanUsageSummary.java
+++ /dev/null
@@ -1,359 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the
- * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package com.android.settings.datausage;
-
-import static android.net.NetworkPolicy.LIMIT_DISABLED;
-
-import android.annotation.IdRes;
-import android.app.Activity;
-import android.content.Context;
-import android.content.Intent;
-import android.net.NetworkPolicy;
-import android.net.NetworkPolicyManager;
-import android.net.NetworkTemplate;
-import android.net.wifi.WifiConfiguration;
-import android.net.wifi.WifiManager;
-import android.os.Bundle;
-import android.os.UserManager;
-import android.provider.Settings;
-import android.support.annotation.VisibleForTesting;
-import android.support.v7.preference.Preference;
-import android.support.v7.preference.PreferenceCategory;
-import android.support.v7.preference.PreferenceScreen;
-import android.telephony.SubscriptionInfo;
-import android.telephony.SubscriptionManager;
-import android.text.TextUtils;
-import android.text.format.Formatter;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.MenuItem;
-import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.settings.R;
-import com.android.settings.Utils;
-import com.android.settings.dashboard.SummaryLoader;
-import com.android.settingslib.NetworkPolicyEditor;
-import com.android.settingslib.net.DataUsageController;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @deprecated This fragment was supposed to be new version of {@link DataUsageSummary} however
- * unfinished and used nowhere. Keep it in case we may bring it back someday.
- */
-@Deprecated
-public class DataPlanUsageSummary extends DataUsageBase {
-
-    public static final String KEY_DATA_PLAN_USAGE = "data_plan_usage";
-
-    public static final String KEY_STATUS_HEADER = "status_header";
-    public static final String KEY_LIMIT_SUMMARY = "plan_summary";
-
-    // Mobile data keys
-    public static final String KEY_MOBILE_USAGE_TITLE = "data_usage_mobile_category";
-    public static final String KEY_MOBILE_DATA_USAGE_TOGGLE = "data_usage_enable";
-
-    // Wifi keys
-    public static final String KEY_WIFI_USAGE_TITLE = "wifi_category";
-    public static final String KEY_WIFI_DATA_USAGE = "wifi_data_usage";
-    public static final String KEY_NETWORK_RESTRICTIONS = "network_restrictions";
-
-    private DataUsageController mDataUsageController;
-    private DataUsageInfoController mDataInfoController;
-    private List<DataPlanSummaryPreference> mDataPlanSummaryPreferenceList;
-    private Preference mLimitPreference;
-    private NetworkTemplate mDefaultTemplate;
-    private NetworkRestrictionsPreference mNetworkRestrictionPreference;
-    private WifiManager mWifiManager;
-    private NetworkPolicyEditor mPolicyEditor;
-
-    @Override
-    public int getHelpResource() {
-        return R.string.help_url_data_usage;
-    }
-
-    @Override
-    public void onCreate(Bundle bundle) {
-        super.onCreate(bundle);
-
-        final Context context = getContext();
-        NetworkPolicyManager policyManager = NetworkPolicyManager.from(context);
-        mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
-        mPolicyEditor = new NetworkPolicyEditor(policyManager);
-        mDataUsageController = new DataUsageController(context);
-        mDataInfoController = new DataUsageInfoController();
-
-        int defaultSubId = DataUsageUtils.getDefaultSubscriptionId(context);
-        boolean hasMobileData = DataUsageUtils.hasMobileData(context);
-        if (defaultSubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
-            hasMobileData = false;
-        }
-        mDefaultTemplate = DataUsageUtils.getDefaultTemplate(context, defaultSubId);
-
-        if (hasMobileData) {
-            addDataPlanSection(defaultSubId);
-        }
-
-        if (DataUsageUtils.hasWifiRadio(context)) {
-            addWifiSection();
-        }
-
-        if (hasEthernet(context)) {
-            addEthernetSection();
-        }
-        setHasOptionsMenu(true);
-    }
-
-    @Override
-    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
-        if (UserManager.get(getContext()).isAdminUser()) {
-            inflater.inflate(R.menu.data_usage, menu);
-        }
-        super.onCreateOptionsMenu(menu, inflater);
-    }
-
-    @Override
-    public boolean onOptionsItemSelected(MenuItem item) {
-        switch (item.getItemId()) {
-            case R.id.data_usage_menu_cellular_networks: {
-                final Intent intent = new Intent(Settings.ACTION_NETWORK_OPERATOR_SETTINGS);
-                startActivity(intent);
-                return true;
-            }
-        }
-        return false;
-    }
-
-    private void addDataPlanSection(int defaultSubId) {
-        Context context = getPrefContext();
-        addPreferencesFromResource(R.xml.data_plan_usage);
-        PreferenceScreen screen = getPreferenceScreen();
-        screen.setTitle(context.getString(R.string.data_usage_summary_title));
-
-        PreferenceCategory preferenceCategory =
-                (PreferenceCategory) findPreference(KEY_DATA_PLAN_USAGE);
-        screen.addPreference(preferenceCategory);
-
-        Preference dataPlansSyncTimePreference = new Preference(context);
-        dataPlansSyncTimePreference.setLayoutResource(R.layout.data_plans_sync_time_preference);
-        dataPlansSyncTimePreference.setTitle(MockDataPlanUsage.SYNC_TIME);
-        preferenceCategory.addPreference(dataPlansSyncTimePreference);
-
-        mDataPlanSummaryPreferenceList = new ArrayList<>(MockDataPlanUsage.DATA_PLAN_USAGES.length);
-        for (int i = 0; i < MockDataPlanUsage.DATA_PLAN_USAGES.length; i++) {
-            DataPlanSummaryPreference dataPlanSummaryPreference =
-                    new DataPlanSummaryPreference(context);
-            dataPlanSummaryPreference.setKey(KEY_STATUS_HEADER + (i + 1));
-            mDataPlanSummaryPreferenceList.add(dataPlanSummaryPreference);
-            preferenceCategory.addPreference(dataPlanSummaryPreference);
-        }
-
-        Preference preference = new Preference(context);
-        preference.setLayoutResource(R.layout.manage_data_plans_preference);
-        preferenceCategory.addPreference(preference);
-        setPreferenceScreen(screen);
-
-        mLimitPreference = findPreference(KEY_LIMIT_SUMMARY);
-        List<SubscriptionInfo> subscriptions =
-                services.mSubscriptionManager.getActiveSubscriptionInfoList();
-
-        if (subscriptions == null || subscriptions.isEmpty()) {
-            addMobileSection(defaultSubId);
-        }
-
-        for (int i = 0, subscriptionsSize = subscriptions != null ? subscriptions.size() : 0;
-                i < subscriptionsSize; i++) {
-            SubscriptionInfo subInfo = subscriptions.get(i);
-            if (subscriptionsSize > 1) {
-                addMobileSection(subInfo.getSubscriptionId(), subInfo);
-            } else {
-                addMobileSection(subInfo.getSubscriptionId());
-            }
-        }
-    }
-
-    private void addMobileSection(int subId) {
-        addMobileSection(subId, null);
-    }
-
-    private void addMobileSection(int subId, SubscriptionInfo subInfo) {
-        TemplatePreferenceCategory category = (TemplatePreferenceCategory)
-                inflatePreferences(R.xml.data_plan_usage_cell_data_preference_screen);
-        category.setTemplate(getNetworkTemplate(subId), subId, services);
-        category.pushTemplates(services);
-        if (subInfo != null && !TextUtils.isEmpty(subInfo.getDisplayName())) {
-            Preference title = category.findPreference(KEY_MOBILE_USAGE_TITLE);
-            title.setTitle(subInfo.getDisplayName());
-        }
-    }
-
-    private void addWifiSection() {
-        TemplatePreferenceCategory category = (TemplatePreferenceCategory)
-                inflatePreferences(R.xml.data_usage_wifi);
-        category.setTemplate(NetworkTemplate.buildTemplateWifiWildcard(), 0 /* subId */, services);
-        mNetworkRestrictionPreference =
-                (NetworkRestrictionsPreference) category.findPreference(KEY_NETWORK_RESTRICTIONS);
-    }
-
-    private void addEthernetSection() {
-        TemplatePreferenceCategory category = (TemplatePreferenceCategory)
-                inflatePreferences(R.xml.data_usage_ethernet);
-        category.setTemplate(NetworkTemplate.buildTemplateEthernet(), 0 /* subId */, services);
-    }
-
-    private Preference inflatePreferences(@IdRes int resId) {
-        PreferenceScreen rootPreferences = getPreferenceManager().inflateFromResource(
-                getPrefContext(), resId, null);
-        Preference pref = rootPreferences.getPreference(0);
-        rootPreferences.removeAll();
-
-        PreferenceScreen screen = getPreferenceScreen();
-        pref.setOrder(screen.getPreferenceCount());
-        screen.addPreference(pref);
-
-        return pref;
-    }
-
-    private NetworkTemplate getNetworkTemplate(int subscriptionId) {
-        NetworkTemplate mobileAll = NetworkTemplate.buildTemplateMobileAll(
-                services.mTelephonyManager.getSubscriberId(subscriptionId));
-        return NetworkTemplate.normalize(mobileAll,
-                services.mTelephonyManager.getMergedSubscriberIds());
-    }
-
-    @Override
-    public void onResume() {
-        super.onResume();
-        updateState();
-    }
-
-    private void updateState() {
-        DataUsageController.DataUsageInfo info = mDataUsageController.getDataUsageInfo(
-                mDefaultTemplate);
-
-        Context context = getContext();
-        mDataInfoController.updateDataLimit(info,
-                services.mPolicyEditor.getPolicy(mDefaultTemplate));
-
-        // TODO(b/63391323): Get rid of MockDataPlanUsage once we integrate with data plan APIs
-        if (mDataPlanSummaryPreferenceList != null && !mDataPlanSummaryPreferenceList.isEmpty()) {
-            MockDataPlanUsage[] dataPlanUsages = MockDataPlanUsage.getDataPlanUsage();
-            for (int i = 0; i < dataPlanUsages.length; i++) {
-                DataPlanSummaryPreference dataPlanSummaryPreference =
-                        mDataPlanSummaryPreferenceList.get(i);
-                MockDataPlanUsage dataPlanUsage = dataPlanUsages[i];
-                dataPlanSummaryPreference.setTitle(dataPlanUsage.mUsage);
-                dataPlanSummaryPreference.setUsageTextColor(dataPlanUsage.mUsageTextColor);
-                dataPlanSummaryPreference.setName(dataPlanUsage.mName);
-                dataPlanSummaryPreference.setPercentageUsage(dataPlanUsage.mPercentageUsage);
-                dataPlanSummaryPreference
-                        .setMeterBackgroundColor(dataPlanUsage.mMeterBackgroundColor);
-                dataPlanSummaryPreference.setMeterConsumedColor(dataPlanUsage.mMeterConsumedColor);
-                dataPlanSummaryPreference.setDescription(dataPlanUsage.mDescription);
-            }
-        }
-
-        if (mLimitPreference != null && (info.warningLevel > 0 || info.limitLevel > 0)) {
-            String warning = Formatter.formatFileSize(context, info.warningLevel);
-            String limit = Formatter.formatFileSize(context, info.limitLevel);
-            mLimitPreference.setSummary(getString(info.limitLevel <= 0 ? R.string.cell_warning_only
-                    : R.string.cell_warning_and_limit, warning, limit));
-        } else if (mLimitPreference != null) {
-            mLimitPreference.setSummary(null);
-        }
-
-        updateNetworkRestrictionSummary(mNetworkRestrictionPreference);
-
-        PreferenceScreen screen = getPreferenceScreen();
-        for (int i = 1, preferenceCount = screen.getPreferenceCount(); i < preferenceCount; i++) {
-            ((TemplatePreferenceCategory) screen.getPreference(i)).pushTemplates(services);
-        }
-    }
-
-    @Override
-    public int getMetricsCategory() {
-        return MetricsEvent.DATA_USAGE_SUMMARY;
-    }
-
-    @VisibleForTesting
-    void updateNetworkRestrictionSummary(NetworkRestrictionsPreference preference) {
-        if (preference == null) {
-            return;
-        }
-        mPolicyEditor.read();
-        int count = 0;
-        List<WifiConfiguration> configuredNetworks = mWifiManager.getConfiguredNetworks();
-        for (int i = 0, configuredNetworksSize = configuredNetworks.size();
-                i < configuredNetworksSize; i++) {
-            WifiConfiguration config = configuredNetworks.get(i);
-            if (isMetered(config)) {
-                count++;
-            }
-        }
-        preference.setSummary(getResources().getQuantityString(
-                R.plurals.network_restrictions_summary, count, count));
-    }
-
-    @VisibleForTesting
-    boolean isMetered(WifiConfiguration config) {
-        if (config.SSID == null) {
-            return false;
-        }
-        final String networkId = config.isPasspoint() ? config.providerFriendlyName : config.SSID;
-        final NetworkPolicy policy =
-                mPolicyEditor.getPolicyMaybeUnquoted(NetworkTemplate.buildTemplateWifi(networkId));
-        if (policy == null) {
-            return false;
-        }
-        if (policy.limitBytes != LIMIT_DISABLED) {
-            return true;
-        }
-        return policy.metered;
-    }
-
-    private static class SummaryProvider
-            implements SummaryLoader.SummaryProvider {
-
-        private final Activity mActivity;
-        private final SummaryLoader mSummaryLoader;
-        private final DataUsageController mDataController;
-
-        public SummaryProvider(Activity activity, SummaryLoader summaryLoader) {
-            mActivity = activity;
-            mSummaryLoader = summaryLoader;
-            mDataController = new DataUsageController(activity);
-        }
-
-        @Override
-        public void setListening(boolean listening) {
-            if (listening) {
-                DataUsageController.DataUsageInfo info = mDataController.getDataUsageInfo();
-                String used;
-                if (info == null) {
-                    used = Formatter.formatFileSize(mActivity, 0);
-                } else if (info.limitLevel <= 0) {
-                    used = Formatter.formatFileSize(mActivity, info.usageLevel);
-                } else {
-                    used = Utils.formatPercentage(info.usageLevel, info.limitLevel);
-                }
-                mSummaryLoader.setSummary(this,
-                        mActivity.getString(R.string.data_usage_summary_format, used));
-            }
-        }
-    }
-
-    public static final SummaryLoader.SummaryProviderFactory SUMMARY_PROVIDER_FACTORY
-            = SummaryProvider::new;
-}
-
diff --git a/src/com/android/settings/datausage/DataUsageSummary.java b/src/com/android/settings/datausage/DataUsageSummary.java
index b63cee3..339de7c 100644
--- a/src/com/android/settings/datausage/DataUsageSummary.java
+++ b/src/com/android/settings/datausage/DataUsageSummary.java
@@ -18,7 +18,6 @@
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.Intent;
-import android.net.NetworkPolicyManager;
 import android.net.NetworkTemplate;
 import android.os.Bundle;
 import android.os.UserManager;
@@ -28,6 +27,7 @@
 import android.support.v7.preference.PreferenceScreen;
 import android.telephony.SubscriptionInfo;
 import android.telephony.SubscriptionManager;
+import android.telephony.SubscriptionPlan;
 import android.text.BidiFormatter;
 import android.text.Spannable;
 import android.text.SpannableString;
@@ -40,7 +40,6 @@
 
 import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
 import com.android.settings.R;
-import com.android.settings.SummaryPreference;
 import com.android.settings.Utils;
 import com.android.settings.dashboard.SummaryLoader;
 import com.android.settings.search.BaseSearchIndexProvider;
@@ -65,7 +64,6 @@
     public static final String KEY_RESTRICT_BACKGROUND = "restrict_background";
 
     private static final String KEY_STATUS_HEADER = "status_header";
-    private static final String KEY_LIMIT_SUMMARY = "limit_summary";
 
     // Mobile data keys
     public static final String KEY_MOBILE_USAGE_TITLE = "mobile_category";
@@ -77,13 +75,9 @@
     public static final String KEY_WIFI_USAGE_TITLE = "wifi_category";
     public static final String KEY_WIFI_DATA_USAGE = "wifi_data_usage";
 
-    private DataUsageController mDataUsageController;
-    private DataUsageInfoController mDataInfoController;
-    private SummaryPreference mSummaryPreference;
-    private Preference mLimitPreference;
+    private DataUsageSummaryPreference mSummaryPreference;
+    private DataUsageSummaryPreferenceController mSummaryController;
     private NetworkTemplate mDefaultTemplate;
-    private int mDataUsageTemplate;
-    private NetworkPolicyEditor mPolicyEditor;
 
     @Override
     public int getHelpResource() {
@@ -95,25 +89,20 @@
         super.onCreate(icicle);
 
         final Context context = getContext();
-        NetworkPolicyManager policyManager = NetworkPolicyManager.from(context);
-        mPolicyEditor = new NetworkPolicyEditor(policyManager);
 
         boolean hasMobileData = DataUsageUtils.hasMobileData(context);
-        mDataUsageController = new DataUsageController(context);
-        mDataInfoController = new DataUsageInfoController();
 
         int defaultSubId = DataUsageUtils.getDefaultSubscriptionId(context);
         if (defaultSubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
             hasMobileData = false;
         }
         mDefaultTemplate = DataUsageUtils.getDefaultTemplate(context, defaultSubId);
-        mSummaryPreference = (SummaryPreference) findPreference(KEY_STATUS_HEADER);
+        mSummaryPreference = (DataUsageSummaryPreference) findPreference(KEY_STATUS_HEADER);
 
         if (!hasMobileData || !isAdmin()) {
             removePreference(KEY_RESTRICT_BACKGROUND);
         }
         if (hasMobileData) {
-            mLimitPreference = findPreference(KEY_LIMIT_SUMMARY);
             List<SubscriptionInfo> subscriptions =
                     services.mSubscriptionManager.getActiveSubscriptionInfoList();
             if (subscriptions == null || subscriptions.size() == 0) {
@@ -127,10 +116,6 @@
                     addMobileSection(subInfo.getSubscriptionId());
                 }
             }
-            mSummaryPreference.setSelectable(true);
-        } else {
-            removePreference(KEY_LIMIT_SUMMARY);
-            mSummaryPreference.setSelectable(false);
         }
         boolean hasWifiRadio = DataUsageUtils.hasWifiRadio(context);
         if (hasWifiRadio) {
@@ -139,10 +124,6 @@
         if (hasEthernet(context)) {
             addEthernetSection();
         }
-        mDataUsageTemplate = hasMobileData ? R.string.cell_data_template
-                : hasWifiRadio ? R.string.wifi_data_template
-                : R.string.ethernet_data_template;
-
         setHasOptionsMenu(true);
     }
 
@@ -189,7 +170,11 @@
 
     @Override
     protected List<AbstractPreferenceController> getPreferenceControllers(Context context) {
-        return null;
+        final ArrayList<AbstractPreferenceController> controllers = new ArrayList<>();
+        mSummaryController =
+                new DataUsageSummaryPreferenceController(context);
+        controllers.add(mSummaryController);
+        return controllers;
     }
 
     private void addMobileSection(int subId) {
@@ -269,36 +254,6 @@
     }
 
     private void updateState() {
-        DataUsageController.DataUsageInfo info = mDataUsageController.getDataUsageInfo(
-                mDefaultTemplate);
-        Context context = getContext();
-        mDataInfoController.updateDataLimit(info,
-                services.mPolicyEditor.getPolicy(mDefaultTemplate));
-
-        if (mSummaryPreference != null) {
-            mSummaryPreference.setTitle(
-                    formatUsage(context, getString(mDataUsageTemplate), info.usageLevel));
-            final long limit = mDataInfoController.getSummaryLimit(info);
-            mSummaryPreference.setSummary(info.period);
-            if (limit <= 0) {
-                mSummaryPreference.setChartEnabled(false);
-            } else {
-                mSummaryPreference.setChartEnabled(true);
-                mSummaryPreference.setLabels(Formatter.formatFileSize(context, 0),
-                        Formatter.formatFileSize(context, limit));
-                mSummaryPreference.setRatios(info.usageLevel / (float) limit, 0,
-                        (limit - info.usageLevel) / (float) limit);
-            }
-        }
-        if (mLimitPreference != null && (info.warningLevel > 0 || info.limitLevel > 0)) {
-            String warning = Formatter.formatFileSize(context, info.warningLevel);
-            String limit = Formatter.formatFileSize(context, info.limitLevel);
-            mLimitPreference.setSummary(getString(info.limitLevel <= 0 ? R.string.cell_warning_only
-                    : R.string.cell_warning_and_limit, warning, limit));
-        } else if (mLimitPreference != null) {
-            mLimitPreference.setSummary(null);
-        }
-
         PreferenceScreen screen = getPreferenceScreen();
         for (int i = 1; i < screen.getPreferenceCount(); i++) {
             ((TemplatePreferenceCategory) screen.getPreference(i)).pushTemplates(services);
@@ -323,6 +278,7 @@
     @Override
     public void updateDataUsage() {
         updateState();
+        mSummaryController.updateState(mSummaryPreference);
     }
 
     private static class SummaryProvider
@@ -341,17 +297,39 @@
         @Override
         public void setListening(boolean listening) {
             if (listening) {
-                DataUsageController.DataUsageInfo info = mDataController.getDataUsageInfo();
-                String used;
-                if (info == null) {
-                    used = Formatter.formatFileSize(mActivity, 0);
-                } else if (info.limitLevel <= 0) {
-                    used = Formatter.formatFileSize(mActivity, info.usageLevel);
-                } else {
-                    used = Utils.formatPercentage(info.usageLevel, info.limitLevel);
-                }
                 mSummaryLoader.setSummary(this,
-                        mActivity.getString(R.string.data_usage_summary_format, used));
+                        mActivity.getString(R.string.data_usage_summary_format, formatUsedData()));
+            }
+        }
+
+        private String formatUsedData() {
+            SubscriptionManager subscriptionManager = (SubscriptionManager) mActivity
+                .getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE);
+            int defaultSubId = subscriptionManager.getDefaultSubscriptionId();
+            if (defaultSubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
+                return formatFallbackData();
+            }
+            SubscriptionPlan dfltPlan = DataUsageSummaryPreferenceController
+                    .getPrimaryPlan(subscriptionManager, defaultSubId);
+            if (dfltPlan == null) {
+                return formatFallbackData();
+            }
+            if (DataUsageSummaryPreferenceController.unlimited(dfltPlan.getDataLimitBytes())) {
+                return Formatter.formatFileSize(mActivity, dfltPlan.getDataUsageBytes());
+            } else {
+                return Utils.formatPercentage(dfltPlan.getDataUsageBytes(),
+                    dfltPlan.getDataLimitBytes());
+            }
+        }
+
+        private String formatFallbackData() {
+            DataUsageController.DataUsageInfo info = mDataController.getDataUsageInfo();
+            if (info == null) {
+                return Formatter.formatFileSize(mActivity, 0);
+            } else if (info.limitLevel <= 0) {
+                return Formatter.formatFileSize(mActivity, info.usageLevel);
+            } else {
+                return Utils.formatPercentage(info.usageLevel, info.limitLevel);
             }
         }
     }
diff --git a/src/com/android/settings/datausage/DataUsageSummaryLegacy.java b/src/com/android/settings/datausage/DataUsageSummaryLegacy.java
new file mode 100644
index 0000000..6a241eb
--- /dev/null
+++ b/src/com/android/settings/datausage/DataUsageSummaryLegacy.java
@@ -0,0 +1,408 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package com.android.settings.datausage;
+
+import android.app.Activity;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.net.NetworkPolicyManager;
+import android.net.NetworkTemplate;
+import android.os.Bundle;
+import android.os.UserManager;
+import android.provider.SearchIndexableResource;
+import android.support.annotation.VisibleForTesting;
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceScreen;
+import android.telephony.SubscriptionInfo;
+import android.telephony.SubscriptionManager;
+import android.text.BidiFormatter;
+import android.text.Spannable;
+import android.text.SpannableString;
+import android.text.TextUtils;
+import android.text.format.Formatter;
+import android.text.style.RelativeSizeSpan;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+
+import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+import com.android.settings.R;
+import com.android.settings.SummaryPreference;
+import com.android.settings.Utils;
+import com.android.settings.dashboard.SummaryLoader;
+import com.android.settings.search.BaseSearchIndexProvider;
+import com.android.settings.search.Indexable;
+import com.android.settingslib.NetworkPolicyEditor;
+import com.android.settingslib.core.AbstractPreferenceController;
+import com.android.settingslib.net.DataUsageController;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Legacy {@link DataUsageSummary} fragment.
+ */
+public class DataUsageSummaryLegacy extends DataUsageBaseFragment implements Indexable,
+        DataUsageEditController {
+
+    private static final String TAG = "DataUsageSummaryLegacy";
+
+    static final boolean LOGD = false;
+
+    public static final String KEY_RESTRICT_BACKGROUND = "restrict_background";
+
+    private static final String KEY_STATUS_HEADER = "status_header";
+    private static final String KEY_LIMIT_SUMMARY = "limit_summary";
+
+    // Mobile data keys
+    public static final String KEY_MOBILE_USAGE_TITLE = "mobile_category";
+    public static final String KEY_MOBILE_DATA_USAGE_TOGGLE = "data_usage_enable";
+    public static final String KEY_MOBILE_DATA_USAGE = "cellular_data_usage";
+    public static final String KEY_MOBILE_BILLING_CYCLE = "billing_preference";
+
+    // Wifi keys
+    public static final String KEY_WIFI_USAGE_TITLE = "wifi_category";
+    public static final String KEY_WIFI_DATA_USAGE = "wifi_data_usage";
+
+    private DataUsageController mDataUsageController;
+    private DataUsageInfoController mDataInfoController;
+    private SummaryPreference mSummaryPreference;
+    private Preference mLimitPreference;
+    private NetworkTemplate mDefaultTemplate;
+    private int mDataUsageTemplate;
+    private NetworkPolicyEditor mPolicyEditor;
+
+    @Override
+    public int getHelpResource() {
+        return R.string.help_url_data_usage;
+    }
+
+    @Override
+    public void onCreate(Bundle icicle) {
+        super.onCreate(icicle);
+
+        final Context context = getContext();
+        NetworkPolicyManager policyManager = NetworkPolicyManager.from(context);
+        mPolicyEditor = new NetworkPolicyEditor(policyManager);
+
+        boolean hasMobileData = DataUsageUtils.hasMobileData(context);
+        mDataUsageController = new DataUsageController(context);
+        mDataInfoController = new DataUsageInfoController();
+
+        int defaultSubId = DataUsageUtils.getDefaultSubscriptionId(context);
+        if (defaultSubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
+            hasMobileData = false;
+        }
+        mDefaultTemplate = DataUsageUtils.getDefaultTemplate(context, defaultSubId);
+        mSummaryPreference = (SummaryPreference) findPreference(KEY_STATUS_HEADER);
+
+        if (!hasMobileData || !isAdmin()) {
+            removePreference(KEY_RESTRICT_BACKGROUND);
+        }
+        if (hasMobileData) {
+            mLimitPreference = findPreference(KEY_LIMIT_SUMMARY);
+            List<SubscriptionInfo> subscriptions =
+                    services.mSubscriptionManager.getActiveSubscriptionInfoList();
+            if (subscriptions == null || subscriptions.size() == 0) {
+                addMobileSection(defaultSubId);
+            }
+            for (int i = 0; subscriptions != null && i < subscriptions.size(); i++) {
+                SubscriptionInfo subInfo = subscriptions.get(i);
+                if (subscriptions.size() > 1) {
+                    addMobileSection(subInfo.getSubscriptionId(), subInfo);
+                } else {
+                    addMobileSection(subInfo.getSubscriptionId());
+                }
+            }
+            mSummaryPreference.setSelectable(true);
+        } else {
+            removePreference(KEY_LIMIT_SUMMARY);
+            mSummaryPreference.setSelectable(false);
+        }
+        boolean hasWifiRadio = DataUsageUtils.hasWifiRadio(context);
+        if (hasWifiRadio) {
+            addWifiSection();
+        }
+        if (hasEthernet(context)) {
+            addEthernetSection();
+        }
+        mDataUsageTemplate = hasMobileData ? R.string.cell_data_template
+                : hasWifiRadio ? R.string.wifi_data_template
+                : R.string.ethernet_data_template;
+
+        setHasOptionsMenu(true);
+    }
+
+    @Override
+    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+        if (UserManager.get(getContext()).isAdminUser()) {
+            inflater.inflate(R.menu.data_usage, menu);
+        }
+        super.onCreateOptionsMenu(menu, inflater);
+    }
+
+    @Override
+    public boolean onOptionsItemSelected(MenuItem item) {
+        switch (item.getItemId()) {
+            case R.id.data_usage_menu_cellular_networks: {
+                final Intent intent = new Intent(Intent.ACTION_MAIN);
+                intent.setComponent(new ComponentName("com.android.phone",
+                        "com.android.phone.MobileNetworkSettings"));
+                startActivity(intent);
+                return true;
+            }
+        }
+        return false;
+    }
+
+    @Override
+    public boolean onPreferenceTreeClick(Preference preference) {
+        if (preference == findPreference(KEY_STATUS_HEADER)) {
+            BillingCycleSettings.BytesEditorFragment.show(this, false);
+            return false;
+        }
+        return super.onPreferenceTreeClick(preference);
+    }
+
+    @Override
+    protected int getPreferenceScreenResId() {
+        return R.xml.data_usage_legacy;
+    }
+
+    @Override
+    protected String getLogTag() {
+        return TAG;
+    }
+
+    @Override
+    protected List<AbstractPreferenceController> getPreferenceControllers(Context context) {
+        return null;
+    }
+
+    private void addMobileSection(int subId) {
+        addMobileSection(subId, null);
+    }
+
+    private void addMobileSection(int subId, SubscriptionInfo subInfo) {
+        TemplatePreferenceCategory category = (TemplatePreferenceCategory)
+                inflatePreferences(R.xml.data_usage_cellular);
+        category.setTemplate(getNetworkTemplate(subId), subId, services);
+        category.pushTemplates(services);
+        if (subInfo != null && !TextUtils.isEmpty(subInfo.getDisplayName())) {
+            Preference title  = category.findPreference(KEY_MOBILE_USAGE_TITLE);
+            title.setTitle(subInfo.getDisplayName());
+        }
+    }
+
+    private void addWifiSection() {
+        TemplatePreferenceCategory category = (TemplatePreferenceCategory)
+                inflatePreferences(R.xml.data_usage_wifi);
+        category.setTemplate(NetworkTemplate.buildTemplateWifiWildcard(), 0, services);
+    }
+
+    private void addEthernetSection() {
+        TemplatePreferenceCategory category = (TemplatePreferenceCategory)
+                inflatePreferences(R.xml.data_usage_ethernet);
+        category.setTemplate(NetworkTemplate.buildTemplateEthernet(), 0, services);
+    }
+
+    private Preference inflatePreferences(int resId) {
+        PreferenceScreen rootPreferences = getPreferenceManager().inflateFromResource(
+                getPrefContext(), resId, null);
+        Preference pref = rootPreferences.getPreference(0);
+        rootPreferences.removeAll();
+
+        PreferenceScreen screen = getPreferenceScreen();
+        pref.setOrder(screen.getPreferenceCount());
+        screen.addPreference(pref);
+
+        return pref;
+    }
+
+    private NetworkTemplate getNetworkTemplate(int subscriptionId) {
+        NetworkTemplate mobileAll = NetworkTemplate.buildTemplateMobileAll(
+                services.mTelephonyManager.getSubscriberId(subscriptionId));
+        return NetworkTemplate.normalize(mobileAll,
+                services.mTelephonyManager.getMergedSubscriberIds());
+    }
+
+    @Override
+    public void onResume() {
+        super.onResume();
+        updateState();
+    }
+
+    @VisibleForTesting
+    static CharSequence formatUsage(Context context, String template, long usageLevel) {
+        final float LARGER_SIZE = 1.25f * 1.25f;  // (1/0.8)^2
+        final float SMALLER_SIZE = 1.0f / LARGER_SIZE;  // 0.8^2
+        final int FLAGS = Spannable.SPAN_INCLUSIVE_INCLUSIVE;
+
+        final Formatter.BytesResult usedResult = Formatter.formatBytes(context.getResources(),
+                usageLevel, Formatter.FLAG_CALCULATE_ROUNDED);
+        final SpannableString enlargedValue = new SpannableString(usedResult.value);
+        enlargedValue.setSpan(new RelativeSizeSpan(LARGER_SIZE), 0, enlargedValue.length(), FLAGS);
+
+        final SpannableString amountTemplate = new SpannableString(
+                context.getString(com.android.internal.R.string.fileSizeSuffix)
+                .replace("%1$s", "^1").replace("%2$s", "^2"));
+        final CharSequence formattedUsage = TextUtils.expandTemplate(amountTemplate,
+                enlargedValue, usedResult.units);
+
+        final SpannableString fullTemplate = new SpannableString(template);
+        fullTemplate.setSpan(new RelativeSizeSpan(SMALLER_SIZE), 0, fullTemplate.length(), FLAGS);
+        return TextUtils.expandTemplate(fullTemplate,
+                BidiFormatter.getInstance().unicodeWrap(formattedUsage.toString()));
+    }
+
+    private void updateState() {
+        DataUsageController.DataUsageInfo info = mDataUsageController.getDataUsageInfo(
+                mDefaultTemplate);
+        Context context = getContext();
+        mDataInfoController.updateDataLimit(info,
+                services.mPolicyEditor.getPolicy(mDefaultTemplate));
+
+        if (mSummaryPreference != null) {
+            mSummaryPreference.setTitle(
+                    formatUsage(context, getString(mDataUsageTemplate), info.usageLevel));
+            final long limit = mDataInfoController.getSummaryLimit(info);
+            mSummaryPreference.setSummary(info.period);
+            if (limit <= 0) {
+                mSummaryPreference.setChartEnabled(false);
+            } else {
+                mSummaryPreference.setChartEnabled(true);
+                mSummaryPreference.setLabels(Formatter.formatFileSize(context, 0),
+                        Formatter.formatFileSize(context, limit));
+                mSummaryPreference.setRatios(info.usageLevel / (float) limit, 0,
+                        (limit - info.usageLevel) / (float) limit);
+            }
+        }
+        if (mLimitPreference != null && (info.warningLevel > 0 || info.limitLevel > 0)) {
+            String warning = Formatter.formatFileSize(context, info.warningLevel);
+            String limit = Formatter.formatFileSize(context, info.limitLevel);
+            mLimitPreference.setSummary(getString(info.limitLevel <= 0 ? R.string.cell_warning_only
+                    : R.string.cell_warning_and_limit, warning, limit));
+        } else if (mLimitPreference != null) {
+            mLimitPreference.setSummary(null);
+        }
+
+        PreferenceScreen screen = getPreferenceScreen();
+        for (int i = 1; i < screen.getPreferenceCount(); i++) {
+            ((TemplatePreferenceCategory) screen.getPreference(i)).pushTemplates(services);
+        }
+    }
+
+    @Override
+    public int getMetricsCategory() {
+        return MetricsEvent.DATA_USAGE_SUMMARY;
+    }
+
+    @Override
+    public NetworkPolicyEditor getNetworkPolicyEditor() {
+        return services.mPolicyEditor;
+    }
+
+    @Override
+    public NetworkTemplate getNetworkTemplate() {
+        return mDefaultTemplate;
+    }
+
+    @Override
+    public void updateDataUsage() {
+        updateState();
+    }
+
+    private static class SummaryProvider
+            implements SummaryLoader.SummaryProvider {
+
+        private final Activity mActivity;
+        private final SummaryLoader mSummaryLoader;
+        private final DataUsageController mDataController;
+
+        public SummaryProvider(Activity activity, SummaryLoader summaryLoader) {
+            mActivity = activity;
+            mSummaryLoader = summaryLoader;
+            mDataController = new DataUsageController(activity);
+        }
+
+        @Override
+        public void setListening(boolean listening) {
+            if (listening) {
+                DataUsageController.DataUsageInfo info = mDataController.getDataUsageInfo();
+                String used;
+                if (info == null) {
+                    used = Formatter.formatFileSize(mActivity, 0);
+                } else if (info.limitLevel <= 0) {
+                    used = Formatter.formatFileSize(mActivity, info.usageLevel);
+                } else {
+                    used = Utils.formatPercentage(info.usageLevel, info.limitLevel);
+                }
+                mSummaryLoader.setSummary(this,
+                        mActivity.getString(R.string.data_usage_summary_format, used));
+            }
+        }
+    }
+
+    public static final SummaryLoader.SummaryProviderFactory SUMMARY_PROVIDER_FACTORY
+        = SummaryProvider::new;
+
+    /**
+     * For search
+     */
+    public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+        new BaseSearchIndexProvider() {
+
+            @Override
+            public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
+                    boolean enabled) {
+                List<SearchIndexableResource> resources = new ArrayList<>();
+                SearchIndexableResource resource = new SearchIndexableResource(context);
+                resource.xmlResId = R.xml.data_usage;
+                resources.add(resource);
+
+                resource = new SearchIndexableResource(context);
+                resource.xmlResId = R.xml.data_usage_cellular;
+                resources.add(resource);
+
+                resource = new SearchIndexableResource(context);
+                resource.xmlResId = R.xml.data_usage_wifi;
+                resources.add(resource);
+
+                return resources;
+            }
+
+            @Override
+            public List<String> getNonIndexableKeys(Context context) {
+                List<String> keys = super.getNonIndexableKeys(context);
+
+                if (!DataUsageUtils.hasMobileData(context)) {
+                    keys.add(KEY_MOBILE_USAGE_TITLE);
+                    keys.add(KEY_MOBILE_DATA_USAGE_TOGGLE);
+                    keys.add(KEY_MOBILE_DATA_USAGE);
+                    keys.add(KEY_MOBILE_BILLING_CYCLE);
+                }
+
+                if (!DataUsageUtils.hasWifiRadio(context)) {
+                    keys.add(KEY_WIFI_DATA_USAGE);
+                }
+
+                // This title is named Wifi, and will confuse users.
+                keys.add(KEY_WIFI_USAGE_TITLE);
+
+                return keys;
+            }
+        };
+}
diff --git a/src/com/android/settings/datausage/DataUsageSummaryPreference.java b/src/com/android/settings/datausage/DataUsageSummaryPreference.java
new file mode 100644
index 0000000..984df02
--- /dev/null
+++ b/src/com/android/settings/datausage/DataUsageSummaryPreference.java
@@ -0,0 +1,117 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.datausage;
+
+import android.content.Context;
+import android.content.Intent;
+import android.support.v7.preference.PreferenceViewHolder;
+import android.util.AttributeSet;
+import android.view.View;
+import android.widget.Button;
+import android.widget.TextView;
+
+import com.android.settings.R;
+import com.android.settings.SummaryPreference;
+import com.android.settingslib.utils.StringUtil;
+
+import libcore.util.Objects;
+
+/**
+ * Provides a summary of data usage.
+ */
+public class DataUsageSummaryPreference extends SummaryPreference {
+
+    private int mNumPlans;
+    /** The ending time of the billing cycle in milliseconds since epoch. */
+    private long mCycleEndTimeMs;
+    /** The time of the last update in standard milliseconds since the epoch */
+    private long mSnapshotTimeMs;
+    /** Name of carrier, or null if not available */
+    private CharSequence mCarrierName;
+    private String mLimitInfoText;
+    private Intent mLaunchIntent;
+
+    public DataUsageSummaryPreference(Context context, AttributeSet attrs) {
+        super(context, attrs);
+        setLayoutResource(R.layout.data_usage_summary_preference);
+    }
+
+    public void setLimitInfo(String text) {
+        if (!Objects.equal(text, mLimitInfoText)) {
+            mLimitInfoText = text;
+            notifyChanged();
+        }
+    }
+
+    public void setUsageInfo(long cycleEnd, long snapshotTime, CharSequence carrierName,
+            int numPlans, Intent launchIntent) {
+        mCycleEndTimeMs = cycleEnd;
+        mSnapshotTimeMs = snapshotTime;
+        mCarrierName = carrierName;
+        mNumPlans = numPlans;
+        mLaunchIntent = launchIntent;
+        notifyChanged();
+    }
+
+    @Override
+    public void onBindViewHolder(PreferenceViewHolder holder) {
+        super.onBindViewHolder(holder);
+
+        TextView usageTitle = (TextView) holder.findViewById(R.id.usage_title);
+        usageTitle.setVisibility(mNumPlans > 1 ? View.VISIBLE : View.GONE);
+
+        TextView cycleTime = (TextView) holder.findViewById(R.id.cycle_left_time);
+        cycleTime.setText(getContext().getString(R.string.cycle_left_time_text,
+                StringUtil.formatElapsedTime(getContext(),
+                        mCycleEndTimeMs - System.currentTimeMillis(),false /* withSeconds */)));
+
+        TextView carrierInfo = (TextView) holder.findViewById(R.id.carrier_and_update);
+        setCarrierInfo(carrierInfo, mCarrierName, mSnapshotTimeMs);
+
+        Button launchButton = (Button) holder.findViewById(R.id.launch_mdp_app_button);
+        launchButton.setOnClickListener((view) -> {
+            getContext().sendBroadcast(mLaunchIntent);
+        });
+        if (mLaunchIntent != null) {
+            launchButton.setVisibility(View.VISIBLE);
+        } else {
+            launchButton.setVisibility(View.GONE);
+        }
+
+        TextView limitInfo = (TextView) holder.findViewById(R.id.data_limits);
+        limitInfo.setVisibility(
+                mLimitInfoText == null || mLimitInfoText.isEmpty() ? View.GONE : View.VISIBLE);
+        limitInfo.setText(mLimitInfoText);
+    }
+
+    private void setCarrierInfo(TextView carrierInfo, CharSequence carrierName, long updateAge) {
+        if (mNumPlans > 0 && updateAge >= 0L) {
+            carrierInfo.setVisibility(View.VISIBLE);
+            if (carrierName != null) {
+                carrierInfo.setText(getContext().getString(R.string.carrier_and_update_text,
+                        carrierName, StringUtil.formatRelativeTime(
+                                getContext(), updateAge, false /* withSeconds */)));
+            } else {
+                carrierInfo.setText(getContext().getString(R.string.no_carrier_update_text,
+                        StringUtil.formatRelativeTime(
+                                getContext(), updateAge, false /* withSeconds */)));
+            }
+        } else {
+            carrierInfo.setVisibility(View.GONE);
+        }
+    }
+}
\ No newline at end of file
diff --git a/src/com/android/settings/datausage/DataUsageSummaryPreferenceController.java b/src/com/android/settings/datausage/DataUsageSummaryPreferenceController.java
new file mode 100644
index 0000000..11da829
--- /dev/null
+++ b/src/com/android/settings/datausage/DataUsageSummaryPreferenceController.java
@@ -0,0 +1,286 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.datausage;
+
+import android.content.Context;
+import android.content.Intent;
+import android.net.NetworkPolicyManager;
+import android.net.NetworkTemplate;
+import android.support.annotation.VisibleForTesting;
+import android.support.v7.preference.Preference;
+import android.telephony.SubscriptionInfo;
+import android.telephony.SubscriptionManager;
+import android.telephony.SubscriptionPlan;
+import android.text.BidiFormatter;
+import android.text.Spannable;
+import android.text.SpannableString;
+import android.text.TextUtils;
+import android.text.format.Formatter;
+import android.text.style.RelativeSizeSpan;
+import android.util.Log;
+import android.util.RecurrenceRule;
+
+import com.android.internal.util.CollectionUtils;
+import com.android.settings.R;
+import com.android.settings.core.BasePreferenceController;
+import com.android.settingslib.NetworkPolicyEditor;
+import com.android.settingslib.net.DataUsageController;
+
+import java.util.List;
+
+/**
+ * This is the controller for the top of the data usage screen that retrieves carrier data from the
+ * new subscriptions framework API if available. The controller reads subscription information from
+ * the framework and falls back to legacy usage data if none are available.
+ */
+public class DataUsageSummaryPreferenceController extends BasePreferenceController {
+
+    private static final String TAG = "DataUsageController";
+    private static final String KEY = "status_header";
+    private static final long PETA = 1000000000000000L;
+    private static final float RELATIVE_SIZE_LARGE = 1.25f * 1.25f;  // (1/0.8)^2
+    private static final float RELATIVE_SIZE_SMALL = 1.0f / RELATIVE_SIZE_LARGE;  // 0.8^2
+
+    private final DataUsageController mDataUsageController;
+    private final DataUsageInfoController mDataInfoController;
+    private final NetworkTemplate mDefaultTemplate;
+    private final NetworkPolicyEditor mPolicyEditor;
+    private final int mDataUsageTemplate;
+    private final boolean mHasMobileData;
+    private final SubscriptionManager mSubscriptionManager;
+
+    /** Name of the carrier, or null if not available */
+    private CharSequence mCarrierName;
+
+    /** The number of registered plans, [0,N] */
+    private int mDataplanCount;
+
+    /** The time of the last update in milliseconds since the epoch, or -1 if unknown */
+    private long mSnapshotTime;
+
+    /**
+     * The size of the first registered plan if one exists or the size of the warning if it is set.
+     * -1 if no information is available.
+     */
+    private long mDataplanSize;
+    /** The number of bytes used since the start of the cycle. */
+    private long mDataplanUse;
+    /** The starting time of the billing cycle in ms since the epoch */
+    private long mCycleStart;
+    /** The ending time of the billing cycle in ms since the epoch */
+    private long mCycleEnd;
+
+    private Intent mManageSubscriptionIntent;
+
+    public DataUsageSummaryPreferenceController(Context context) {
+        super(context, KEY);
+
+        final int defaultSubId = DataUsageUtils.getDefaultSubscriptionId(context);
+        mDefaultTemplate = DataUsageUtils.getDefaultTemplate(context, defaultSubId);
+        NetworkPolicyManager policyManager = NetworkPolicyManager.from(context);
+        mPolicyEditor = new NetworkPolicyEditor(policyManager);
+
+        mHasMobileData = DataUsageUtils.hasMobileData(context)
+                && defaultSubId != SubscriptionManager.INVALID_SUBSCRIPTION_ID;
+
+        mDataUsageController = new DataUsageController(context);
+        mDataInfoController = new DataUsageInfoController();
+
+        if (mHasMobileData) {
+            mDataUsageTemplate = R.string.cell_data_template;
+        } else if (DataUsageUtils.hasWifiRadio(context)) {
+            mDataUsageTemplate = R.string.wifi_data_template;
+        } else {
+            mDataUsageTemplate = R.string.ethernet_data_template;
+        }
+
+        mSubscriptionManager = (SubscriptionManager)
+                mContext.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE);
+    }
+
+    @VisibleForTesting
+    DataUsageSummaryPreferenceController(
+            Context context,
+            DataUsageController dataUsageController,
+            DataUsageInfoController dataInfoController,
+            NetworkTemplate defaultTemplate,
+            NetworkPolicyEditor policyEditor,
+            int dataUsageTemplate,
+            boolean hasMobileData,
+            SubscriptionManager subscriptionManager) {
+        super(context, KEY);
+        mDataUsageController = dataUsageController;
+        mDataInfoController = dataInfoController;
+        mDefaultTemplate = defaultTemplate;
+        mPolicyEditor = policyEditor;
+        mDataUsageTemplate = dataUsageTemplate;
+        mHasMobileData = hasMobileData;
+        mSubscriptionManager = subscriptionManager;
+    }
+
+    @VisibleForTesting
+    void setPlanValues(int dataPlanCount, long dataPlanSize, long dataPlanUse) {
+        mDataplanCount = dataPlanCount;
+        mDataplanSize = dataPlanSize;
+        mDataplanUse = dataPlanUse;
+    }
+
+    @VisibleForTesting
+    void setCarrierValues(String carrierName, long snapshotTime, long cycleEnd, Intent intent) {
+        mCarrierName = carrierName;
+        mSnapshotTime = snapshotTime;
+        mCycleEnd = cycleEnd;
+        mManageSubscriptionIntent = intent;
+    }
+
+    @Override
+    public int getAvailabilityStatus() {
+        return AVAILABLE;
+    }
+
+    @Override
+    public void updateState(Preference preference) {
+        DataUsageSummaryPreference summaryPreference = (DataUsageSummaryPreference) preference;
+        DataUsageController.DataUsageInfo info = mDataUsageController.getDataUsageInfo(
+                mDefaultTemplate);
+
+        mDataInfoController.updateDataLimit(info, mPolicyEditor.getPolicy(mDefaultTemplate));
+
+        if (mSubscriptionManager != null) {
+            refreshDataplanInfo(info);
+        }
+
+        if (mDataplanCount == 0 && (info.warningLevel > 0 || info.limitLevel > 0)) {
+            final String warning = Formatter.formatFileSize(mContext, info.warningLevel);
+            final String limit = Formatter.formatFileSize(mContext, info.limitLevel);
+            summaryPreference.setLimitInfo(mContext.getString(info.limitLevel <= 0
+                    ? R.string.cell_warning_only
+                    : R.string.cell_warning_and_limit, warning, limit));
+        } else {
+            summaryPreference.setLimitInfo(null);
+        }
+
+        final StringBuilder title = new StringBuilder();
+        if (mHasMobileData) {
+            title.append(formatUsage(mContext, mContext.getString(R.string.data_used),
+                    mDataplanUse));
+            if (mDataplanCount >= 0 && mDataplanSize > 0L) {
+                title.append(formatUsage(mContext, mContext.getString(R.string.data_remaining),
+                        mDataplanSize - mDataplanUse));
+            }
+        } else {
+            title.append(formatUsage(mContext, mContext.getString(mDataUsageTemplate),
+                    mDataplanUse));
+        }
+        summaryPreference.setTitle(title.toString());
+
+        if (mDataplanSize <= 0) {
+            summaryPreference.setChartEnabled(false);
+        } else {
+            summaryPreference.setChartEnabled(true);
+            summaryPreference.setLabels(Formatter.formatFileSize(mContext, 0 /* sizeBytes */),
+                    Formatter.formatFileSize(mContext, mDataplanSize));
+            summaryPreference.setRatios(mDataplanUse / (float) mDataplanSize, 0 /* middle */,
+                    (mDataplanSize - mDataplanUse) / (float) mDataplanSize);
+        }
+        summaryPreference.setUsageInfo(mCycleEnd, mSnapshotTime, mCarrierName,
+                mDataplanCount, mManageSubscriptionIntent);
+    }
+
+    // TODO(b/70950124) add test for this method once the robolectric shadow run script is
+    // completed (b/3526807)
+    private void refreshDataplanInfo(DataUsageController.DataUsageInfo info) {
+        // reset data before overwriting
+        mCarrierName = null;
+        mDataplanCount = 0;
+        mDataplanSize = mDataInfoController.getSummaryLimit(info);
+        mDataplanUse = info.usageLevel;
+        mCycleStart = info.cycleStart;
+        mCycleEnd = info.cycleEnd;
+        mSnapshotTime = -1L;
+
+        final int defaultSubId = SubscriptionManager.getDefaultSubscriptionId();
+        final SubscriptionInfo subInfo = mSubscriptionManager.getDefaultDataSubscriptionInfo();
+        if (subInfo != null && mHasMobileData) {
+            mCarrierName = subInfo.getCarrierName();
+            List<SubscriptionPlan> plans = mSubscriptionManager.getSubscriptionPlans(defaultSubId);
+            final SubscriptionPlan primaryPlan = getPrimaryPlan(mSubscriptionManager, defaultSubId);
+            if (primaryPlan != null) {
+                mDataplanCount = plans.size();
+                mDataplanSize = primaryPlan.getDataLimitBytes();
+                if (unlimited(mDataplanSize)) {
+                    mDataplanSize = 0L;
+                }
+                mDataplanUse = primaryPlan.getDataUsageBytes();
+
+                RecurrenceRule rule = primaryPlan.getCycleRule();
+                if (rule != null && rule.start != null && rule.end != null) {
+                    mCycleStart = rule.start.toEpochSecond() * 1000L;
+                    mCycleEnd = rule.end.toEpochSecond() * 1000L;
+                }
+                mSnapshotTime = System.currentTimeMillis() - primaryPlan.getDataUsageTime();
+            }
+        }
+        mManageSubscriptionIntent =
+                mSubscriptionManager.createManageSubscriptionIntent(defaultSubId);
+        Log.i(TAG, "Have " + mDataplanCount + " plans, dflt sub-id " + defaultSubId
+                + ", intent " + mManageSubscriptionIntent);
+    }
+
+    public static SubscriptionPlan getPrimaryPlan(SubscriptionManager subManager, int primaryId) {
+        List<SubscriptionPlan> plans = subManager.getSubscriptionPlans(primaryId);
+        if (CollectionUtils.isEmpty(plans)) {
+            return null;
+        }
+        // First plan in the list is the primary plan
+        SubscriptionPlan plan = plans.get(0);
+        return plan.getDataLimitBytes() > 0
+                && saneSize(plan.getDataUsageBytes())
+                && plan.getCycleRule() != null ? plan : null;
+    }
+
+    private static boolean saneSize(long value) {
+        return value >= 0L && value < PETA;
+    }
+
+    public static boolean unlimited(long size) {
+        return size == SubscriptionPlan.BYTES_UNLIMITED;
+    }
+
+    @VisibleForTesting
+    private static CharSequence formatUsage(Context context, String template, long usageLevel) {
+        final int FLAGS = Spannable.SPAN_INCLUSIVE_INCLUSIVE;
+
+        final Formatter.BytesResult usedResult = Formatter.formatBytes(context.getResources(),
+                usageLevel, Formatter.FLAG_CALCULATE_ROUNDED);
+        final SpannableString enlargedValue = new SpannableString(usedResult.value);
+        enlargedValue.setSpan(
+                new RelativeSizeSpan(RELATIVE_SIZE_LARGE), 0, enlargedValue.length(), FLAGS);
+
+        final SpannableString amountTemplate = new SpannableString(
+                context.getString(com.android.internal.R.string.fileSizeSuffix)
+                        .replace("%1$s", "^1").replace("%2$s", "^2"));
+        final CharSequence formattedUsage = TextUtils.expandTemplate(amountTemplate,
+                enlargedValue, usedResult.units);
+
+        final SpannableString fullTemplate = new SpannableString(template);
+        fullTemplate.setSpan(
+                new RelativeSizeSpan(RELATIVE_SIZE_SMALL), 0, fullTemplate.length(), FLAGS);
+        return TextUtils.expandTemplate(fullTemplate,
+                BidiFormatter.getInstance().unicodeWrap(formattedUsage.toString()));
+    }
+}
diff --git a/src/com/android/settings/datausage/MockDataPlanUsage.java b/src/com/android/settings/datausage/MockDataPlanUsage.java
deleted file mode 100644
index e3aa97a..0000000
--- a/src/com/android/settings/datausage/MockDataPlanUsage.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the
- * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package com.android.settings.datausage;
-
-import android.graphics.Color;
-
-/**
- * Mock data plan usage data.
- */
-@Deprecated // This class is only needed because we don't have working API yet.
-final class MockDataPlanUsage {
-    static final MockDataPlanUsage[] DATA_PLAN_USAGES = new MockDataPlanUsage[3];
-    static final String SYNC_TIME = "Today 12:24pm";
-    final String mUsage;
-    final int mUsageTextColor;
-    final String mName;
-    final double mPercentageUsage;
-    final int mMeterBackgroundColor;
-    final int mMeterConsumedColor;
-    final String mDescription;
-
-    private MockDataPlanUsage(String usage, int usageTextColor, String name,
-            double percentageUsage, int meterBackgroundColor, int meterConsumedColor,
-            String description) {
-        mUsage = usage;
-        mUsageTextColor = usageTextColor;
-        mName = name;
-        mPercentageUsage = percentageUsage;
-        mMeterBackgroundColor = meterBackgroundColor;
-        mMeterConsumedColor = meterConsumedColor;
-        mDescription = description;
-    }
-
-    static MockDataPlanUsage[] getDataPlanUsage() {
-        DATA_PLAN_USAGES[0] = new MockDataPlanUsage("100 MB and 14 days left",
-                Color.parseColor("#FF5C94F1"), "GigaMaxLite / 1GB", 0.27D,
-                Color.parseColor("#FFDBDCDC"), Color.parseColor("#FF5C94F1"),
-                "Premium plan from Telekomsel");
-
-        DATA_PLAN_USAGES[1] = new MockDataPlanUsage("1.25 GB and 14 days left",
-                Color.parseColor("#FF673AB7"), "GigaMaxLite 4G / 5GB", 0.47D,
-                Color.parseColor("#FFDBDCDC"), Color.parseColor("#FF673AB7"),
-                "Plenty of 4G data");
-
-        DATA_PLAN_USAGES[2] = new MockDataPlanUsage("700 MB and 14 days left",
-                Color.parseColor("#FF4CAF50"), "GigaMaxLite Video / 7GB", 0.67D,
-                Color.parseColor("#FFDBDCDC"), Color.parseColor("#FF4CAF50"),
-                "Use certain video apps for free");
-        return DATA_PLAN_USAGES;
-    }
-}
diff --git a/src/com/android/settings/datetime/timezone/TimeZoneAdapter.java b/src/com/android/settings/datetime/timezone/TimeZoneAdapter.java
index 79075ca..62fc8c9 100644
--- a/src/com/android/settings/datetime/timezone/TimeZoneAdapter.java
+++ b/src/com/android/settings/datetime/timezone/TimeZoneAdapter.java
@@ -35,6 +35,7 @@
 import java.util.Collections;
 import java.util.Date;
 import java.util.List;
+import java.util.Locale;
 
 /**
  * Adapter for showing {@link TimeZoneInfo} objects in a recycler view.
@@ -55,7 +56,11 @@
     TimeZoneAdapter(View.OnClickListener onClickListener, Context context) {
         mOnClickListener = onClickListener;
         mContext = context;
-        mTimeFormat = DateFormat.getTimeInstance(SimpleDateFormat.SHORT);
+        // Use android.text.format.DateFormat to observe 24-hour settings and find the best pattern
+        // using ICU with skeleton.
+        mTimeFormat = new SimpleDateFormat(
+                android.text.format.DateFormat.getTimeFormatString(context),
+                Locale.getDefault());
         mDateFormat = DateFormat.getDateInstance(SimpleDateFormat.MEDIUM);
         mDateFormat.setContext(DisplayContext.CAPITALIZATION_NONE);
         mCurrentTimeZone = TimeZone.getDefault().getID();
diff --git a/src/com/android/settings/deviceinfo/StorageSettings.java b/src/com/android/settings/deviceinfo/StorageSettings.java
index efcf03d..2093469 100644
--- a/src/com/android/settings/deviceinfo/StorageSettings.java
+++ b/src/com/android/settings/deviceinfo/StorageSettings.java
@@ -236,7 +236,6 @@
                 Intent intent = Utils.onBuildStartFragmentIntent(getActivity(),
                         StorageDashboardFragment.class.getName(), args, null,
                         R.string.storage_settings, null, false, getMetricsCategory());
-                intent.putExtra(SettingsDrawerActivity.EXTRA_SHOW_MENU, true);
                 getActivity().startActivity(intent);
                 finish();
             }
diff --git a/src/com/android/settings/deviceinfo/aboutphone/MyDeviceInfoFragment.java b/src/com/android/settings/deviceinfo/aboutphone/MyDeviceInfoFragment.java
index bb95228..03b69a5 100644
--- a/src/com/android/settings/deviceinfo/aboutphone/MyDeviceInfoFragment.java
+++ b/src/com/android/settings/deviceinfo/aboutphone/MyDeviceInfoFragment.java
@@ -21,6 +21,7 @@
 import android.app.Activity;
 import android.app.Fragment;
 import android.content.Context;
+import android.content.Intent;
 import android.content.pm.UserInfo;
 import android.os.Bundle;
 import android.os.UserManager;
@@ -126,6 +127,16 @@
         return controllers;
     }
 
+    @Override
+    public void onActivityResult(int requestCode, int resultCode, Intent data) {
+        final BuildNumberPreferenceController buildNumberPreferenceController =
+            getPreferenceController(BuildNumberPreferenceController.class);
+        if (buildNumberPreferenceController.onActivityResult(requestCode, resultCode, data)) {
+            return;
+        }
+        super.onActivityResult(requestCode, resultCode, data);
+    }
+
     private void initHeader() {
         // TODO: Migrate into its own controller.
         final LayoutPreference headerPreference =
diff --git a/src/com/android/settings/deviceinfo/storage/UserProfileController.java b/src/com/android/settings/deviceinfo/storage/UserProfileController.java
index 4870e7e..c9fe54e 100644
--- a/src/com/android/settings/deviceinfo/storage/UserProfileController.java
+++ b/src/com/android/settings/deviceinfo/storage/UserProfileController.java
@@ -85,7 +85,6 @@
             Intent intent = Utils.onBuildStartFragmentIntent(mContext,
                     StorageProfileFragment.class.getName(), args, null, 0,
                     mUser.name, false, MetricsProto.MetricsEvent.DEVICEINFO_STORAGE);
-            intent.putExtra(SettingsDrawerActivity.EXTRA_SHOW_MENU, true);
             mContext.startActivity(intent);
             return true;
         }
diff --git a/src/com/android/settings/display/AmbientDisplaySettings.java b/src/com/android/settings/display/AmbientDisplaySettings.java
index 187325c..3cac078 100644
--- a/src/com/android/settings/display/AmbientDisplaySettings.java
+++ b/src/com/android/settings/display/AmbientDisplaySettings.java
@@ -79,7 +79,7 @@
     protected List<AbstractPreferenceController> getPreferenceControllers(Context context) {
         return buildPreferenceControllers(context, getLifecycle(),
                 new AmbientDisplayConfiguration(context), mMetricsFeatureProvider,
-                () -> { updatePreferenceStates(); });
+                this::updatePreferenceStates);
     }
 
     @Override
diff --git a/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetail.java b/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetail.java
index e073456..981b0dc 100644
--- a/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetail.java
+++ b/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetail.java
@@ -58,6 +58,7 @@
 import com.android.settingslib.applications.ApplicationsState;
 import com.android.settingslib.core.AbstractPreferenceController;
 
+import com.android.settingslib.utils.StringUtil;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -284,10 +285,10 @@
         final int powerMah = bundle.getInt(EXTRA_POWER_USAGE_AMOUNT);
         mForegroundPreference.setSummary(
                 TextUtils.expandTemplate(getText(R.string.battery_used_for),
-                        Utils.formatElapsedTime(context, foregroundTimeMs, false)));
+                        StringUtil.formatElapsedTime(context, foregroundTimeMs, false)));
         mBackgroundPreference.setSummary(
                 TextUtils.expandTemplate(getText(R.string.battery_active_for),
-                        Utils.formatElapsedTime(context, backgroundTimeMs, false)));
+                        StringUtil.formatElapsedTime(context, backgroundTimeMs, false)));
         mPowerUsagePreference.setSummary(
                 getString(R.string.battery_detail_power_percentage, usagePercent, powerMah));
     }
diff --git a/src/com/android/settings/fuelgauge/BatteryAppListPreferenceController.java b/src/com/android/settings/fuelgauge/BatteryAppListPreferenceController.java
index 91f35e2..2f93d0a 100644
--- a/src/com/android/settings/fuelgauge/BatteryAppListPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/BatteryAppListPreferenceController.java
@@ -18,7 +18,6 @@
 package com.android.settings.fuelgauge;
 
 import android.app.Activity;
-import android.app.Fragment;
 import android.content.Context;
 import android.graphics.drawable.Drawable;
 import android.os.BatteryStats;
@@ -31,7 +30,6 @@
 import android.support.v14.preference.PreferenceFragment;
 import android.support.v7.preference.Preference;
 import android.support.v7.preference.PreferenceGroup;
-import android.support.v7.preference.PreferenceManager;
 import android.support.v7.preference.PreferenceScreen;
 import android.text.TextUtils;
 import android.text.format.DateUtils;
@@ -48,16 +46,14 @@
 import com.android.settings.SettingsActivity;
 import com.android.settings.core.FeatureFlags;
 import com.android.settings.core.PreferenceControllerMixin;
-import com.android.settings.Utils;
 import com.android.settings.fuelgauge.anomaly.Anomaly;
-import com.android.settings.overlay.FeatureFactory;
 import com.android.settingslib.core.AbstractPreferenceController;
-import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
 import com.android.settingslib.core.lifecycle.Lifecycle;
 import com.android.settingslib.core.lifecycle.LifecycleObserver;
 import com.android.settingslib.core.lifecycle.events.OnDestroy;
 import com.android.settingslib.core.lifecycle.events.OnPause;
 
+import com.android.settingslib.utils.StringUtil;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -66,7 +62,8 @@
  */
 public class BatteryAppListPreferenceController extends AbstractPreferenceController
         implements PreferenceControllerMixin, LifecycleObserver, OnPause, OnDestroy {
-    private static final boolean USE_FAKE_DATA = true;
+    @VisibleForTesting
+    static final boolean USE_FAKE_DATA = false;
     private static final int MAX_ITEMS_TO_LIST = USE_FAKE_DATA ? 30 : 10;
     private static final int MIN_AVERAGE_POWER_THRESHOLD_MILLI_AMP = 10;
     private static final int STATS_TYPE = BatteryStats.STATS_SINCE_CHARGED;
@@ -362,8 +359,8 @@
         // Only show summary when usage time is longer than one minute
         final long usageTimeMs = sipper.usageTimeMs;
         if (usageTimeMs >= DateUtils.MINUTE_IN_MILLIS) {
-            final CharSequence timeSequence = Utils.formatElapsedTime(mContext, usageTimeMs,
-                    false);
+            final CharSequence timeSequence =
+                StringUtil.formatElapsedTime(mContext, usageTimeMs, false);
             preference.setSummary(
                     (sipper.drainType != DrainType.APP || mBatteryUtils.shouldHideSipper(sipper))
                             ? timeSequence
diff --git a/src/com/android/settings/fuelgauge/BatteryBroadcastReceiver.java b/src/com/android/settings/fuelgauge/BatteryBroadcastReceiver.java
index d0f4080..ca4742d 100644
--- a/src/com/android/settings/fuelgauge/BatteryBroadcastReceiver.java
+++ b/src/com/android/settings/fuelgauge/BatteryBroadcastReceiver.java
@@ -27,7 +27,7 @@
 
 /**
  * Use this broadcastReceiver to listen to the battery change, and it will invoke
- * {@link OnBatteryChangedListener} if any of the followings has been changed:
+ * {@link OnBatteryChangedListener} if any of the following has been changed:
  *
  * 1. Battery level(e.g. 100%->99%)
  * 2. Battery status(e.g. plugged->unplugged)
@@ -35,7 +35,14 @@
  */
 public class BatteryBroadcastReceiver extends BroadcastReceiver {
 
-    interface OnBatteryChangedListener {
+    /**
+     * Callback when the following has been changed:
+     *
+     * Battery level(e.g. 100%->99%)
+     * Battery status(e.g. plugged->unplugged)
+     * Battery saver(e.g. off->on)
+     */
+    public interface OnBatteryChangedListener {
         void onBatteryChanged();
     }
 
diff --git a/src/com/android/settings/fuelgauge/BatteryInfo.java b/src/com/android/settings/fuelgauge/BatteryInfo.java
index 6384130..43465ab 100644
--- a/src/com/android/settings/fuelgauge/BatteryInfo.java
+++ b/src/com/android/settings/fuelgauge/BatteryInfo.java
@@ -25,7 +25,6 @@
 import android.os.Bundle;
 import android.os.SystemClock;
 import android.support.annotation.WorkerThread;
-import android.text.TextUtils;
 import android.text.format.Formatter;
 import android.util.SparseIntArray;
 
@@ -34,8 +33,14 @@
 import com.android.settings.graph.UsageView;
 import com.android.settings.overlay.FeatureFactory;
 import com.android.settingslib.R;
+import com.android.settingslib.utils.PowerUtil;
+import com.android.settingslib.utils.StringUtil;
+import java.util.concurrent.TimeUnit;
 
 public class BatteryInfo {
+    private static final long SEVEN_MINUTES_MICROS = TimeUnit.MINUTES.toMicros(7);
+    private static final long FIFTEEN_MINUTES_MICROS = TimeUnit.MINUTES.toMicros(15);
+    private static final long ONE_DAY_MICROS = TimeUnit.DAYS.toMicros(1);
 
     public CharSequence chargeLabel;
     public CharSequence remainingLabel;
@@ -100,7 +105,7 @@
                         if (lastTime >= 0) {
                             points.put(lastTime, lastLevel);
                             points.put((int) (timePeriod +
-                                            BatteryUtils.convertUsToMs(remainingTimeUs)),
+                                            PowerUtil.convertUsToMs(remainingTimeUs)),
                                     mCharging ? 100 : 0);
                         }
                     }
@@ -160,7 +165,7 @@
                 PowerUsageFeatureProvider provider =
                         FeatureFactory.getFactory(context).getPowerUsageFeatureProvider(context);
                 final long elapsedRealtimeUs =
-                        BatteryUtils.convertMsToUs(SystemClock.elapsedRealtime());
+                        PowerUtil.convertMsToUs(SystemClock.elapsedRealtime());
 
                 Intent batteryBroadcast = context.registerReceiver(null,
                         new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
@@ -176,7 +181,7 @@
                                 .logRuntime(LOG_TAG, "time for enhanced BatteryInfo", startTime);
                         return BatteryInfo.getBatteryInfo(context, batteryBroadcast, stats,
                                 elapsedRealtimeUs, shortString,
-                                BatteryUtils.convertMsToUs(estimate.estimateMillis),
+                                PowerUtil.convertMsToUs(estimate.estimateMillis),
                                 estimate.isBasedOnUsage);
                     }
                 }
@@ -217,53 +222,61 @@
 
         info.statusLabel = Utils.getBatteryStatus(resources, batteryBroadcast);
         if (!info.mCharging) {
-            if (drainTimeUs > 0) {
-                info.remainingTimeUs = drainTimeUs;
-                CharSequence timeString = Utils.formatElapsedTime(context,
-                        BatteryUtils.convertUsToMs(drainTimeUs), false /* withSeconds */);
-                info.remainingLabel = TextUtils.expandTemplate(context.getText(shortString ?
-                                R.string.power_remaining_duration_only_short :
-                         (basedOnUsage ?
-                                R.string.power_remaining_duration_only_enhanced :
-                                R.string.power_remaining_duration_only)), timeString);
-                info.chargeLabel = TextUtils.expandTemplate(context.getText(
-                        shortString ?
-                                R.string.power_discharging_duration_short :
-                                basedOnUsage ?
-                                        R.string.power_discharging_duration_enhanced :
-                                        R.string.power_discharging_duration),
-                        info.batteryPercentString, timeString);
-            } else {
-                info.remainingLabel = null;
-                info.chargeLabel = info.batteryPercentString;
-            }
+            updateBatteryInfoDischarging(context, shortString, drainTimeUs, basedOnUsage, info);
         } else {
-            final long chargeTime = stats.computeChargeTimeRemaining(elapsedRealtimeUs);
-            final int status = batteryBroadcast.getIntExtra(BatteryManager.EXTRA_STATUS,
-                    BatteryManager.BATTERY_STATUS_UNKNOWN);
-            info.discharging = false;
-            if (chargeTime > 0 && status != BatteryManager.BATTERY_STATUS_FULL) {
-                info.remainingTimeUs = chargeTime;
-                CharSequence timeString = Utils.formatElapsedTime(context,
-                        BatteryUtils.convertUsToMs(chargeTime), false /* withSeconds */);
-                int resId = R.string.power_charging_duration;
-                info.remainingLabel = TextUtils.expandTemplate(context.getText(
-                        R.string.power_remaining_charging_duration_only), timeString);
-                info.chargeLabel = TextUtils.expandTemplate(context.getText(resId),
-                        info.batteryPercentString, timeString);
-            } else {
-                final String chargeStatusLabel = resources.getString(
-                        R.string.battery_info_status_charging_lower);
-                info.remainingLabel = null;
-                info.chargeLabel = info.batteryLevel == 100 ? info.batteryPercentString :
-                        resources.getString(R.string.power_charging, info.batteryPercentString,
-                                chargeStatusLabel);
-            }
+            updateBatteryInfoCharging(context, batteryBroadcast, stats, elapsedRealtimeUs, info);
         }
         BatteryUtils.logRuntime(LOG_TAG, "time for getBatteryInfo", startTime);
         return info;
     }
 
+    private static void updateBatteryInfoCharging(Context context, Intent batteryBroadcast,
+            BatteryStats stats, long elapsedRealtimeUs, BatteryInfo info) {
+        final Resources resources = context.getResources();
+        final long chargeTime = stats.computeChargeTimeRemaining(elapsedRealtimeUs);
+        final int status = batteryBroadcast.getIntExtra(BatteryManager.EXTRA_STATUS,
+                BatteryManager.BATTERY_STATUS_UNKNOWN);
+        info.discharging = false;
+        if (chargeTime > 0 && status != BatteryManager.BATTERY_STATUS_FULL) {
+            info.remainingTimeUs = chargeTime;
+            CharSequence timeString = StringUtil.formatElapsedTime(context,
+                    PowerUtil.convertUsToMs(info.remainingTimeUs), false /* withSeconds */);
+            int resId = R.string.power_charging_duration;
+            info.remainingLabel = context.getString(
+                    R.string.power_remaining_charging_duration_only, timeString);
+            info.chargeLabel = context.getString(resId, info.batteryPercentString, timeString);
+        } else {
+            final String chargeStatusLabel = resources.getString(
+                    R.string.battery_info_status_charging_lower);
+            info.remainingLabel = null;
+            info.chargeLabel = info.batteryLevel == 100 ? info.batteryPercentString :
+                    resources.getString(R.string.power_charging, info.batteryPercentString,
+                            chargeStatusLabel);
+        }
+    }
+
+    private static void updateBatteryInfoDischarging(Context context, boolean shortString,
+            long drainTimeUs, boolean basedOnUsage, BatteryInfo info) {
+        if (drainTimeUs > 0) {
+            info.remainingTimeUs = drainTimeUs;
+            info.remainingLabel = PowerUtil.getBatteryRemainingStringFormatted(
+                    context,
+                    PowerUtil.convertUsToMs(drainTimeUs),
+                    null /* percentageString */,
+                    basedOnUsage && !shortString
+            );
+            info.chargeLabel = PowerUtil.getBatteryRemainingStringFormatted(
+                    context,
+                    PowerUtil.convertUsToMs(drainTimeUs),
+                    info.batteryPercentString,
+                    basedOnUsage && !shortString
+            );
+        } else {
+            info.remainingLabel = null;
+            info.chargeLabel = info.batteryPercentString;
+        }
+    }
+
     public interface BatteryDataParser {
         void onParsingStarted(long startTime, long endTime);
 
diff --git a/src/com/android/settings/fuelgauge/BatterySaverReceiver.java b/src/com/android/settings/fuelgauge/BatterySaverReceiver.java
index 2254438..300dc0f 100644
--- a/src/com/android/settings/fuelgauge/BatterySaverReceiver.java
+++ b/src/com/android/settings/fuelgauge/BatterySaverReceiver.java
@@ -69,7 +69,7 @@
         mBatterySaverListener = lsn;
     }
 
-    interface BatterySaverListener {
+    public interface BatterySaverListener {
         void onPowerSaveModeChanged();
         void onBatteryChanged(boolean pluggedIn);
     }
diff --git a/src/com/android/settings/fuelgauge/BatterySaverSettings.java b/src/com/android/settings/fuelgauge/BatterySaverSettings.java
deleted file mode 100644
index 2a4fd6e..0000000
--- a/src/com/android/settings/fuelgauge/BatterySaverSettings.java
+++ /dev/null
@@ -1,253 +0,0 @@
-/*
- * Copyright (C) 2014 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.fuelgauge;
-
-import android.content.ContentResolver;
-import android.content.Context;
-import android.content.res.Resources;
-import android.database.ContentObserver;
-import android.net.Uri;
-import android.os.AsyncTask;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.PowerManager;
-import android.provider.SearchIndexableResource;
-import android.provider.Settings;
-import android.provider.Settings.Global;
-import android.support.annotation.VisibleForTesting;
-import android.util.Log;
-import android.widget.Switch;
-
-import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.internal.util.ArrayUtils;
-import com.android.settings.R;
-import com.android.settings.SettingsActivity;
-import com.android.settings.SettingsPreferenceFragment;
-import com.android.settings.Utils;
-import com.android.settings.dashboard.conditional.BatterySaverCondition;
-import com.android.settings.dashboard.conditional.ConditionManager;
-import com.android.settings.notification.SettingPref;
-import com.android.settings.search.BaseSearchIndexProvider;
-import com.android.settings.search.Indexable;
-import com.android.settings.widget.SwitchBar;
-
-import java.util.Arrays;
-import java.util.List;
-
-public class BatterySaverSettings extends SettingsPreferenceFragment
-        implements SwitchBar.OnSwitchChangeListener, BatterySaverReceiver.BatterySaverListener,
-        Indexable {
-    private static final String TAG = "BatterySaverSettings";
-    private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
-    private static final String KEY_TURN_ON_AUTOMATICALLY = "turn_on_automatically";
-    private static final long WAIT_FOR_SWITCH_ANIM = 500;
-
-    private final Handler mHandler = new Handler();
-    private final SettingsObserver mSettingsObserver = new SettingsObserver(mHandler);
-
-    @VisibleForTesting
-    SwitchBar mSwitchBar;
-    private Context mContext;
-    private boolean mCreated;
-    private SettingPref mTriggerPref;
-    private Switch mSwitch;
-    private boolean mValidListener;
-    private PowerManager mPowerManager;
-    private BatterySaverReceiver mReceiver;
-
-    @Override
-    public int getMetricsCategory() {
-        return MetricsEvent.FUELGAUGE_BATTERY_SAVER;
-    }
-
-    @Override
-    public void onActivityCreated(Bundle savedInstanceState) {
-        super.onActivityCreated(savedInstanceState);
-        if (mCreated) {
-            mSwitchBar.show();
-            return;
-        }
-        mCreated = true;
-        addPreferencesFromResource(R.xml.battery_saver_settings);
-        mFooterPreferenceMixin.createFooterPreference()
-                .setTitle(com.android.internal.R.string.battery_saver_description);
-        mContext = getActivity();
-        mSwitchBar = ((SettingsActivity) mContext).getSwitchBar();
-        mSwitchBar.setSwitchBarText(R.string.battery_saver_master_switch_title,
-                R.string.battery_saver_master_switch_title);
-        mSwitch = mSwitchBar.getSwitch();
-        mSwitchBar.show();
-
-        int[] levelChoices = getResources().getIntArray(R.array.battery_saver_trigger_values);
-        final int currentThreshold = Global.getInt(mContext.getContentResolver(),
-                Global.LOW_POWER_MODE_TRIGGER_LEVEL, 0);
-        levelChoices = ArrayUtils.appendInt(levelChoices, currentThreshold);
-        Arrays.sort(levelChoices);
-
-        mTriggerPref = new SettingPref(SettingPref.TYPE_GLOBAL, KEY_TURN_ON_AUTOMATICALLY,
-                Global.LOW_POWER_MODE_TRIGGER_LEVEL,
-                0, /*default*/
-                levelChoices) {
-            @Override
-            protected String getCaption(Resources res, int value) {
-                if (value > 0 && value <= 100) {
-                    return res.getString(R.string.battery_saver_turn_on_automatically_pct,
-                            Utils.formatPercentage(value));
-                }
-                return res.getString(R.string.battery_saver_turn_on_automatically_never);
-            }
-        };
-        mTriggerPref.init(this);
-
-        mPowerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
-        mReceiver = new BatterySaverReceiver(mContext);
-        mReceiver.setBatterySaverListener(this);
-    }
-
-    @Override
-    public void onDestroyView() {
-        super.onDestroyView();
-        mSwitchBar.hide();
-    }
-
-    @Override
-    public void onResume() {
-        super.onResume();
-        mSettingsObserver.setListening(true);
-        mReceiver.setListening(true);
-        if (!mValidListener) {
-            mSwitchBar.addOnSwitchChangeListener(this);
-            mValidListener = true;
-        }
-        updateSwitch();
-    }
-
-    @Override
-    public void onPause() {
-        super.onPause();
-        mSettingsObserver.setListening(false);
-        mReceiver.setListening(false);
-        if (mValidListener) {
-            mSwitchBar.removeOnSwitchChangeListener(this);
-            mValidListener = false;
-        }
-    }
-
-    @Override
-    public void onSwitchChanged(Switch switchView, boolean isChecked) {
-        mHandler.removeCallbacks(mStartMode);
-        if (isChecked) {
-            mHandler.postDelayed(mStartMode, WAIT_FOR_SWITCH_ANIM);
-        } else {
-            if (DEBUG) Log.d(TAG, "Stopping low power mode from settings");
-            trySetPowerSaveMode(false);
-        }
-    }
-
-    private void trySetPowerSaveMode(boolean mode) {
-        if (!mPowerManager.setPowerSaveMode(mode)) {
-            if (DEBUG) Log.d(TAG, "Setting mode failed, fallback to current value");
-            mHandler.post(mUpdateSwitch);
-        }
-        // TODO: Remove once broadcast is in place.
-        ConditionManager.get(getContext()).getCondition(BatterySaverCondition.class).refreshState();
-    }
-
-    private void updateSwitch() {
-        final boolean mode = mPowerManager.isPowerSaveMode();
-        if (DEBUG) Log.d(TAG, "updateSwitch: isChecked=" + mSwitch.isChecked() + " mode=" + mode);
-        if (mode == mSwitch.isChecked()) return;
-
-        // set listener to null so that that code below doesn't trigger onCheckedChanged()
-        if (mValidListener) {
-            mSwitchBar.removeOnSwitchChangeListener(this);
-        }
-        mSwitch.setChecked(mode);
-        if (mValidListener) {
-            mSwitchBar.addOnSwitchChangeListener(this);
-        }
-    }
-
-    private final Runnable mUpdateSwitch = new Runnable() {
-        @Override
-        public void run() {
-            updateSwitch();
-        }
-    };
-
-    private final Runnable mStartMode = new Runnable() {
-        @Override
-        public void run() {
-            AsyncTask.execute(new Runnable() {
-                @Override
-                public void run() {
-                    if (DEBUG) Log.d(TAG, "Starting low power mode from settings");
-                    trySetPowerSaveMode(true);
-                }
-            });
-        }
-    };
-
-    @Override
-    public void onPowerSaveModeChanged() {
-        mHandler.post(mUpdateSwitch);
-    }
-
-    @Override
-    public void onBatteryChanged(boolean pluggedIn) {
-        mSwitchBar.setEnabled(!pluggedIn);
-    }
-
-    private final class SettingsObserver extends ContentObserver {
-        private final Uri LOW_POWER_MODE_TRIGGER_LEVEL_URI
-                = Global.getUriFor(Global.LOW_POWER_MODE_TRIGGER_LEVEL);
-
-        public SettingsObserver(Handler handler) {
-            super(handler);
-        }
-
-        @Override
-        public void onChange(boolean selfChange, Uri uri) {
-            if (LOW_POWER_MODE_TRIGGER_LEVEL_URI.equals(uri)) {
-                mTriggerPref.update(mContext);
-            }
-        }
-
-        public void setListening(boolean listening) {
-            final ContentResolver cr = getContentResolver();
-            if (listening) {
-                cr.registerContentObserver(LOW_POWER_MODE_TRIGGER_LEVEL_URI, false, this);
-            } else {
-                cr.unregisterContentObserver(this);
-            }
-        }
-    }
-
-    /**
-     * For Search.
-     */
-    public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
-            new BaseSearchIndexProvider() {
-                @Override
-                public List<SearchIndexableResource> getXmlResourcesToIndex(
-                        Context context, boolean enabled) {
-                    final SearchIndexableResource sir = new SearchIndexableResource(context);
-                    sir.xmlResId = R.xml.battery_saver_settings;
-                    return Arrays.asList(sir);
-                }
-            };
-}
diff --git a/src/com/android/settings/fuelgauge/BatteryUtils.java b/src/com/android/settings/fuelgauge/BatteryUtils.java
index 5738c29..da9b705 100644
--- a/src/com/android/settings/fuelgauge/BatteryUtils.java
+++ b/src/com/android/settings/fuelgauge/BatteryUtils.java
@@ -43,6 +43,7 @@
 import com.android.settings.fuelgauge.anomaly.Anomaly;
 import com.android.settings.overlay.FeatureFactory;
 
+import com.android.settingslib.utils.PowerUtil;
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.util.Collections;
@@ -68,19 +69,18 @@
         int BACKGROUND = 2;
         int ALL = 3;
     }
-
     private static final String TAG = "BatteryUtils";
 
     private static final int MIN_POWER_THRESHOLD_MILLI_AMP = 5;
+
     private static final int SECONDS_IN_HOUR = 60 * 60;
     private static BatteryUtils sInstance;
-
     private PackageManager mPackageManager;
+
     private AppOpsManager mAppOpsManager;
     private Context mContext;
     @VisibleForTesting
     PowerUsageFeatureProvider mPowerUsageFeatureProvider;
-
     public static BatteryUtils getInstance(Context context) {
         if (sInstance == null || sInstance.isDataCorrupted()) {
             sInstance = new BatteryUtils(context);
@@ -131,29 +131,30 @@
 
         // Return the min value of STATE_TOP time and foreground activity time, since both of these
         // time have some errors
-        return convertUsToMs(
+        return PowerUtil.convertUsToMs(
                 Math.min(timeUs, getForegroundActivityTotalTimeUs(uid, rawRealTimeUs)));
     }
 
     private long getScreenUsageTimeMs(BatteryStats.Uid uid, int which) {
-        final long rawRealTimeUs = convertMsToUs(SystemClock.elapsedRealtime());
+        final long rawRealTimeUs = PowerUtil.convertMsToUs(SystemClock.elapsedRealtime());
         return getScreenUsageTimeMs(uid, which, rawRealTimeUs);
     }
 
     private long getProcessBackgroundTimeMs(BatteryStats.Uid uid, int which) {
-        final long rawRealTimeUs = convertMsToUs(SystemClock.elapsedRealtime());
+        final long rawRealTimeUs = PowerUtil.convertMsToUs(SystemClock.elapsedRealtime());
         final long timeUs = uid.getProcessStateTime(
                 BatteryStats.Uid.PROCESS_STATE_BACKGROUND, rawRealTimeUs, which);
 
         Log.v(TAG, "package: " + mPackageManager.getNameForUid(uid.getUid()));
         Log.v(TAG, "background time(us): " + timeUs);
-        return convertUsToMs(timeUs);
+        return PowerUtil.convertUsToMs(timeUs);
     }
 
     private long getProcessForegroundTimeMs(BatteryStats.Uid uid, int which) {
-        final long rawRealTimeUs = convertMsToUs(SystemClock.elapsedRealtime());
+        final long rawRealTimeUs = PowerUtil.convertMsToUs(SystemClock.elapsedRealtime());
         return getScreenUsageTimeMs(uid, which, rawRealTimeUs)
-                + convertUsToMs(getForegroundServiceTotalTimeUs(uid, rawRealTimeUs));
+                + PowerUtil.convertUsToMs(
+                        getForegroundServiceTotalTimeUs(uid, rawRealTimeUs));
     }
 
     /**
@@ -267,9 +268,10 @@
      */
     public long calculateRunningTimeBasedOnStatsType(BatteryStatsHelper batteryStatsHelper,
             int statsType) {
-        final long elapsedRealtimeUs = convertMsToUs(SystemClock.elapsedRealtime());
+        final long elapsedRealtimeUs = PowerUtil.convertMsToUs(
+                SystemClock.elapsedRealtime());
         // Return the battery time (millisecond) on status mStatsType
-        return convertUsToMs(
+        return PowerUtil.convertUsToMs(
                 batteryStatsHelper.getStats().computeBatteryRealtime(elapsedRealtimeUs, statsType));
 
     }
@@ -390,25 +392,15 @@
         }
     }
 
-    public static long convertUsToMs(long timeUs) {
-        return timeUs / 1000;
-    }
-
-    public static long convertMsToUs(long timeMs) {
-        return timeMs * 1000;
-    }
-
     public void setForceAppStandby(int uid, String packageName,
             int mode) {
         final boolean isPreOApp = isLegacyApp(packageName);
         if (isPreOApp) {
             // Control whether app could run in the background if it is pre O app
-            mAppOpsManager.setMode(AppOpsManager.OP_RUN_IN_BACKGROUND, uid, packageName,
-                    mode);
+            mAppOpsManager.setMode(AppOpsManager.OP_RUN_IN_BACKGROUND, uid, packageName, mode);
         }
         // Control whether app could run jobs in the background
-        mAppOpsManager.setMode(AppOpsManager.OP_RUN_ANY_IN_BACKGROUND, uid, packageName,
-                mode);
+        mAppOpsManager.setMode(AppOpsManager.OP_RUN_ANY_IN_BACKGROUND, uid, packageName, mode);
     }
 
     public void initBatteryStatsHelper(BatteryStatsHelper statsHelper, Bundle bundle,
@@ -425,7 +417,8 @@
         // Stuff we always need to get BatteryInfo
         final Intent batteryBroadcast = mContext.registerReceiver(null,
                 new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
-        final long elapsedRealtimeUs = BatteryUtils.convertMsToUs(SystemClock.elapsedRealtime());
+        final long elapsedRealtimeUs = PowerUtil.convertMsToUs(
+                SystemClock.elapsedRealtime());
         BatteryInfo batteryInfo;
 
         // 0 means we are discharging, anything else means charging
@@ -443,7 +436,7 @@
         if (estimate != null) {
             batteryInfo = BatteryInfo.getBatteryInfo(mContext, batteryBroadcast, stats,
                     elapsedRealtimeUs, false /* shortString */,
-                    BatteryUtils.convertMsToUs(estimate.estimateMillis),
+                    PowerUtil.convertMsToUs(estimate.estimateMillis),
                     estimate.isBasedOnUsage);
         } else {
             batteryInfo = BatteryInfo.getBatteryInfo(mContext, batteryBroadcast, stats,
diff --git a/src/com/android/settings/fuelgauge/DebugEstimatesLoader.java b/src/com/android/settings/fuelgauge/DebugEstimatesLoader.java
index e58ccd3..509f967 100644
--- a/src/com/android/settings/fuelgauge/DebugEstimatesLoader.java
+++ b/src/com/android/settings/fuelgauge/DebugEstimatesLoader.java
@@ -22,6 +22,7 @@
 import android.os.SystemClock;
 import com.android.internal.os.BatteryStatsHelper;
 import com.android.settings.overlay.FeatureFactory;
+import com.android.settingslib.utils.PowerUtil;
 import com.android.settingslib.utils.AsyncLoader;
 import java.util.ArrayList;
 import java.util.List;
@@ -46,7 +47,8 @@
                 FeatureFactory.getFactory(context).getPowerUsageFeatureProvider(context);
 
         // get stuff we'll need for both BatteryInfo
-        final long elapsedRealtimeUs = BatteryUtils.convertMsToUs(SystemClock.elapsedRealtime());
+        final long elapsedRealtimeUs = PowerUtil.convertMsToUs(
+                SystemClock.elapsedRealtime());
         Intent batteryBroadcast = getContext().registerReceiver(null,
                 new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
         BatteryStats stats = mStatsHelper.getStats();
@@ -60,7 +62,7 @@
         }
         BatteryInfo newInfo = BatteryInfo.getBatteryInfo(getContext(), batteryBroadcast, stats,
                 elapsedRealtimeUs, false,
-                BatteryUtils.convertMsToUs(estimate.estimateMillis),
+                PowerUtil.convertMsToUs(estimate.estimateMillis),
                 estimate.isBasedOnUsage);
 
         List<BatteryInfo> infos = new ArrayList<>();
diff --git a/src/com/android/settings/fuelgauge/InactiveApps.java b/src/com/android/settings/fuelgauge/InactiveApps.java
index f91a5c6..ac09a57 100644
--- a/src/com/android/settings/fuelgauge/InactiveApps.java
+++ b/src/com/android/settings/fuelgauge/InactiveApps.java
@@ -16,12 +16,21 @@
 
 package com.android.settings.fuelgauge;
 
+import static android.app.usage.UsageStatsManager.STANDBY_BUCKET_ACTIVE;
+import static android.app.usage.UsageStatsManager.STANDBY_BUCKET_EXEMPTED;
+import static android.app.usage.UsageStatsManager.STANDBY_BUCKET_FREQUENT;
+import static android.app.usage.UsageStatsManager.STANDBY_BUCKET_NEVER;
+import static android.app.usage.UsageStatsManager.STANDBY_BUCKET_RARE;
+import static android.app.usage.UsageStatsManager.STANDBY_BUCKET_WORKING_SET;
+
 import android.app.usage.UsageStatsManager;
 import android.content.Context;
 import android.content.Intent;
 import android.content.pm.PackageManager;
 import android.content.pm.ResolveInfo;
+import android.content.res.Resources;
 import android.os.Bundle;
+import android.support.v7.preference.ListPreference;
 import android.support.v7.preference.Preference;
 import android.support.v7.preference.Preference.OnPreferenceClickListener;
 import android.support.v7.preference.PreferenceGroup;
@@ -29,10 +38,22 @@
 import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
 import com.android.settings.R;
 import com.android.settings.SettingsPreferenceFragment;
+import com.android.settings.widget.RadioButtonPreference;
 
 import java.util.List;
 
-public class InactiveApps extends SettingsPreferenceFragment implements OnPreferenceClickListener {
+public class InactiveApps extends SettingsPreferenceFragment
+        implements Preference.OnPreferenceChangeListener {
+
+    private static final CharSequence[] SETTABLE_BUCKETS_NAMES =
+            {"ACTIVE", "WORKING_SET", "FREQUENT", "RARE"};
+
+    private static final CharSequence[] SETTABLE_BUCKETS_VALUES = {
+            Integer.toString(STANDBY_BUCKET_ACTIVE),
+            Integer.toString(STANDBY_BUCKET_WORKING_SET),
+            Integer.toString(STANDBY_BUCKET_FREQUENT),
+            Integer.toString(STANDBY_BUCKET_RARE)
+    };
 
     private UsageStatsManager mUsageStats;
 
@@ -68,29 +89,51 @@
         List<ResolveInfo> apps = pm.queryIntentActivities(launcherIntent, 0);
         for (ResolveInfo app : apps) {
             String packageName = app.activityInfo.applicationInfo.packageName;
-            Preference p = new Preference(getPrefContext());
+            ListPreference p = new ListPreference(getPrefContext());
             p.setTitle(app.loadLabel(pm));
             p.setIcon(app.loadIcon(pm));
             p.setKey(packageName);
+            p.setEntries(SETTABLE_BUCKETS_NAMES);
+            p.setEntryValues(SETTABLE_BUCKETS_VALUES);
             updateSummary(p);
-            p.setOnPreferenceClickListener(this);
+            p.setOnPreferenceChangeListener(this);
 
             screen.addPreference(p);
         }
     }
 
-    private void updateSummary(Preference p) {
-        boolean inactive = mUsageStats.isAppInactive(p.getKey());
-        p.setSummary(inactive
-                ? R.string.inactive_app_inactive_summary
-                : R.string.inactive_app_active_summary);
+    static String bucketToName(int bucket) {
+        switch (bucket) {
+            case STANDBY_BUCKET_EXEMPTED: return "EXEMPTED";
+            case STANDBY_BUCKET_ACTIVE: return "ACTIVE";
+            case STANDBY_BUCKET_WORKING_SET: return "WORKING_SET";
+            case STANDBY_BUCKET_FREQUENT: return "FREQUENT";
+            case STANDBY_BUCKET_RARE: return "RARE";
+            case STANDBY_BUCKET_NEVER: return "NEVER";
+        }
+        return "";
+    }
+
+    private void updateSummary(ListPreference p) {
+        final Resources res = getActivity().getResources();
+        final int appBucket = mUsageStats.getAppStandbyBucket(p.getKey());
+        final String bucketName = bucketToName(appBucket);
+        p.setSummary(res.getString(R.string.standby_bucket_summary, bucketName));
+        // Buckets outside of the range of the dynamic ones are only used for special
+        // purposes and can either not be changed out of, or might have undesirable
+        // side-effects in combination with other assumptions.
+        final boolean changeable = appBucket >= STANDBY_BUCKET_ACTIVE
+                && appBucket <= STANDBY_BUCKET_RARE;
+        if (changeable) {
+            p.setValue(Integer.toString(appBucket));
+        }
+        p.setEnabled(changeable);
     }
 
     @Override
-    public boolean onPreferenceClick(Preference preference) {
-        String packageName = preference.getKey();
-        mUsageStats.setAppInactive(packageName, !mUsageStats.isAppInactive(packageName));
-        updateSummary(preference);
+    public boolean onPreferenceChange(Preference preference, Object newValue) {
+        mUsageStats.setAppStandbyBucket(preference.getKey(), Integer.parseInt((String) newValue));
+        updateSummary((ListPreference) preference);
         return false;
     }
 }
diff --git a/src/com/android/settings/fuelgauge/PowerUsageAdvanced.java b/src/com/android/settings/fuelgauge/PowerUsageAdvanced.java
index 6ed92a7..25351d3 100644
--- a/src/com/android/settings/fuelgauge/PowerUsageAdvanced.java
+++ b/src/com/android/settings/fuelgauge/PowerUsageAdvanced.java
@@ -47,6 +47,7 @@
 import com.android.settings.search.BaseSearchIndexProvider;
 import com.android.settingslib.core.AbstractPreferenceController;
 
+import com.android.settingslib.utils.StringUtil;
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.util.ArrayList;
@@ -318,7 +319,7 @@
             return;
         }
         if (usageData.usageList.size() <= 1) {
-            CharSequence timeSequence = Utils.formatElapsedTime(getContext(),
+            CharSequence timeSequence = StringUtil.formatElapsedTime(getContext(),
                     usageData.totalUsageTimeMs, false);
             usageData.summary = usageData.usageType == UsageType.IDLE ? timeSequence
                     : TextUtils.expandTemplate(getText(R.string.battery_used_for), timeSequence);
diff --git a/src/com/android/settings/fuelgauge/PowerUsageSummary.java b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
index 2a841f9..659166a 100644
--- a/src/com/android/settings/fuelgauge/PowerUsageSummary.java
+++ b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
@@ -37,10 +37,7 @@
 import android.view.View.OnLongClickListener;
 import android.widget.TextView;
 
-import com.android.internal.hardware.AmbientDisplayConfiguration;
 import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.internal.os.BatterySipper;
-import com.android.internal.os.BatterySipper.DrainType;
 import com.android.settings.R;
 import com.android.settings.Settings.HighPowerApplicationsActivity;
 import com.android.settings.SettingsActivity;
@@ -48,10 +45,7 @@
 import com.android.settings.applications.LayoutPreference;
 import com.android.settings.applications.manageapplications.ManageApplications;
 import com.android.settings.dashboard.SummaryLoader;
-import com.android.settings.display.AmbientDisplayPreferenceController;
-import com.android.settings.display.AutoBrightnessPreferenceController;
 import com.android.settings.display.BatteryPercentagePreferenceController;
-import com.android.settings.display.TimeoutPreferenceController;
 import com.android.settings.fuelgauge.anomaly.Anomaly;
 import com.android.settings.fuelgauge.anomaly.AnomalyDetectionPolicy;
 import com.android.settings.fuelgauge.batterytip.BatteryTipLoader;
@@ -63,6 +57,8 @@
 import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
 import com.android.settingslib.core.lifecycle.Lifecycle;
 
+import com.android.settingslib.utils.PowerUtil;
+import com.android.settingslib.utils.StringUtil;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
@@ -72,7 +68,7 @@
  * consumed since the last time it was unplugged.
  */
 public class PowerUsageSummary extends PowerUsageBase implements OnLongClickListener,
-        OnClickListener, BatteryTipPreferenceController.BatteryTipListener {
+        BatteryTipPreferenceController.BatteryTipListener {
 
     static final String TAG = "PowerUsageSummary";
 
@@ -80,7 +76,6 @@
     private static final String KEY_APP_LIST = "app_list";
     private static final String KEY_BATTERY_HEADER = "battery_header";
     private static final String KEY_BATTERY_TIP = "battery_tip";
-    private static final String KEY_SHOW_ALL_APPS = "show_all_apps";
 
     private static final String KEY_SCREEN_USAGE = "screen_usage";
     private static final String KEY_TIME_SINCE_LAST_FULL_CHARGE = "last_full_charge";
@@ -91,9 +86,6 @@
     @VisibleForTesting
     static final int BATTERY_TIP_LOADER = 2;
     private static final int MENU_STATS_TYPE = Menu.FIRST;
-    @VisibleForTesting
-    static final int MENU_HIGH_POWER_APPS = Menu.FIRST + 3;
-    private static final int MENU_HELP = Menu.FIRST + 5;
     public static final int DEBUG_INFO_LOADER = 3;
 
     @VisibleForTesting
@@ -165,12 +157,12 @@
                     // be unplugged for a period of time before being willing ot make an estimate.
                     summary1.setText(mPowerFeatureProvider.getOldEstimateDebugString(
                             Formatter.formatShortElapsedTime(getContext(),
-                                    BatteryUtils.convertUsToMs(oldInfo.remainingTimeUs))));
+                                    PowerUtil.convertUsToMs(oldInfo.remainingTimeUs))));
 
                     // for this one we can just set the string directly
                     summary2.setText(mPowerFeatureProvider.getEnhancedEstimateDebugString(
                             Formatter.formatShortElapsedTime(getContext(),
-                                    BatteryUtils.convertUsToMs(newInfo.remainingTimeUs))));
+                                    PowerUtil.convertUsToMs(newInfo.remainingTimeUs))));
 
                     batteryView.setBatteryLevel(oldInfo.batteryLevel);
                     batteryView.setCharging(!oldInfo.discharging);
@@ -225,15 +217,6 @@
     }
 
     @Override
-    public boolean onPreferenceTreeClick(Preference preference) {
-        if (KEY_BATTERY_HEADER.equals(preference.getKey())) {
-            performBatteryHeaderClick();
-            return true;
-        }
-        return super.onPreferenceTreeClick(preference);
-    }
-
-    @Override
     protected String getLogTag() {
         return TAG;
     }
@@ -271,8 +254,6 @@
                     .setAlphabeticShortcut('t');
         }
 
-        menu.add(Menu.NONE, MENU_HIGH_POWER_APPS, Menu.NONE, R.string.high_power_apps);
-
         super.onCreateOptionsMenu(menu, inflater);
     }
 
@@ -297,36 +278,11 @@
                 }
                 refreshUi();
                 return true;
-            case MENU_HIGH_POWER_APPS:
-                Bundle args = new Bundle();
-                args.putString(ManageApplications.EXTRA_CLASSNAME,
-                        HighPowerApplicationsActivity.class.getName());
-                sa.startPreferencePanel(this, ManageApplications.class.getName(), args,
-                        R.string.high_power_apps, null, null, 0);
-                metricsFeatureProvider.action(context,
-                        MetricsEvent.ACTION_SETTINGS_MENU_BATTERY_OPTIMIZATION);
-                return true;
             default:
                 return super.onOptionsItemSelected(item);
         }
     }
 
-    private void performBatteryHeaderClick() {
-        if (mPowerFeatureProvider.isAdvancedUiEnabled()) {
-            Utils.startWithFragment(getContext(), PowerUsageAdvanced.class.getName(), null,
-                    null, 0, R.string.advanced_battery_title, null, getMetricsCategory());
-        } else {
-            mStatsHelper.storeStatsHistoryInFile(BatteryHistoryDetail.BATTERY_HISTORY_FILE);
-            Bundle args = new Bundle(2);
-            args.putString(BatteryHistoryDetail.EXTRA_STATS,
-                    BatteryHistoryDetail.BATTERY_HISTORY_FILE);
-            args.putParcelable(BatteryHistoryDetail.EXTRA_BROADCAST,
-                    mStatsHelper.getBatteryBroadcast());
-            Utils.startWithFragment(getContext(), BatteryHistoryDetail.class.getName(), args,
-                    null, 0, R.string.history_details_title, null, getMetricsCategory());
-        }
-    }
-
     protected void refreshUi() {
         final Context context = getContext();
         if (context == null) {
@@ -340,10 +296,10 @@
         final long lastFullChargeTime = mBatteryUtils.calculateLastFullChargeTime(mStatsHelper,
                 System.currentTimeMillis());
         updateLastFullChargePreference(lastFullChargeTime);
-        mScreenUsagePref.setSubtitle(Utils.formatElapsedTime(getContext(),
+        mScreenUsagePref.setSubtitle(StringUtil.formatElapsedTime(getContext(),
                 mBatteryUtils.calculateScreenUsageTime(mStatsHelper), false));
 
-        final CharSequence timeSequence = Utils.formatRelativeTime(context, lastFullChargeTime,
+        final CharSequence timeSequence = StringUtil.formatRelativeTime(context, lastFullChargeTime,
                 false);
         mBatteryAppListPreferenceController.refreshAppListGroup(mStatsHelper,
                 false /* showAllApps */, timeSequence);
@@ -366,7 +322,7 @@
 
     @VisibleForTesting
     void updateLastFullChargePreference(long timeMs) {
-        final CharSequence timeSequence = Utils.formatRelativeTime(getContext(), timeMs, false);
+        final CharSequence timeSequence = StringUtil.formatRelativeTime(getContext(), timeMs, false);
         mLastFullChargePref.setSubtitle(timeSequence);
     }
 
@@ -405,12 +361,9 @@
         getLoaderManager().restartLoader(BATTERY_INFO_LOADER, Bundle.EMPTY,
                 mBatteryInfoLoaderCallbacks);
         if (mPowerFeatureProvider.isEstimateDebugEnabled()) {
-            // Unfortunately setting a long click listener on a view means it will no
-            // longer pass the regular click event to the parent, so we have to register
-            // a regular click listener as well.
+            // Set long click action for summary to show debug info
             View header = mBatteryLayoutPref.findViewById(R.id.summary1);
             header.setOnLongClickListener(this);
-            header.setOnClickListener(this);
         }
     }
 
@@ -422,11 +375,6 @@
     }
 
     @Override
-    public void onClick(View view) {
-        performBatteryHeaderClick();
-    }
-
-    @Override
     protected void restartBatteryStatsLoader() {
         restartBatteryStatsLoader(true /* clearHeader */);
     }
diff --git a/src/com/android/settings/fuelgauge/PowerUsageSummaryLegacy.java b/src/com/android/settings/fuelgauge/PowerUsageSummaryLegacy.java
index 605591d..e6c4923 100644
--- a/src/com/android/settings/fuelgauge/PowerUsageSummaryLegacy.java
+++ b/src/com/android/settings/fuelgauge/PowerUsageSummaryLegacy.java
@@ -69,6 +69,8 @@
 import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
 import com.android.settingslib.core.AbstractPreferenceController;
 
+import com.android.settingslib.utils.PowerUtil;
+import com.android.settingslib.utils.StringUtil;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -210,12 +212,12 @@
                     // be unplugged for a period of time before being willing ot make an estimate.
                     summary1.setText(mPowerFeatureProvider.getOldEstimateDebugString(
                             Formatter.formatShortElapsedTime(getContext(),
-                                    BatteryUtils.convertUsToMs(oldInfo.remainingTimeUs))));
+                                    PowerUtil.convertUsToMs(oldInfo.remainingTimeUs))));
 
                     // for this one we can just set the string directly
                     summary2.setText(mPowerFeatureProvider.getEnhancedEstimateDebugString(
                             Formatter.formatShortElapsedTime(getContext(),
-                                    BatteryUtils.convertUsToMs(newInfo.remainingTimeUs))));
+                                    PowerUtil.convertUsToMs(newInfo.remainingTimeUs))));
 
                     batteryView.setBatteryLevel(oldInfo.batteryLevel);
                     batteryView.setCharging(!oldInfo.discharging);
@@ -524,7 +526,7 @@
         updateScreenPreference();
         updateLastFullChargePreference(lastFullChargeTime);
 
-        final CharSequence timeSequence = Utils.formatRelativeTime(context, lastFullChargeTime,
+        final CharSequence timeSequence = StringUtil.formatRelativeTime(context, lastFullChargeTime,
                 false);
         final int resId = mShowAllApps ? R.string.power_usage_list_summary_device
                 : R.string.power_usage_list_summary;
@@ -653,12 +655,13 @@
                 mStatsHelper.getUsageList(), DrainType.SCREEN);
         final long usageTimeMs = sipper != null ? sipper.usageTimeMs : 0;
 
-        mScreenUsagePref.setSubtitle(Utils.formatElapsedTime(getContext(), usageTimeMs, false));
+        mScreenUsagePref.setSubtitle(
+            StringUtil.formatElapsedTime(getContext(), usageTimeMs, false));
     }
 
     @VisibleForTesting
     void updateLastFullChargePreference(long timeMs) {
-        final CharSequence timeSequence = Utils.formatRelativeTime(getContext(), timeMs, false);
+        final CharSequence timeSequence = StringUtil.formatRelativeTime(getContext(), timeMs, false);
         mLastFullChargePref.setSubtitle(timeSequence);
     }
 
@@ -685,8 +688,8 @@
         // Only show summary when usage time is longer than one minute
         final long usageTimeMs = sipper.usageTimeMs;
         if (usageTimeMs >= DateUtils.MINUTE_IN_MILLIS) {
-            final CharSequence timeSequence = Utils.formatElapsedTime(getContext(), usageTimeMs,
-                    false);
+            final CharSequence timeSequence =
+                    StringUtil.formatElapsedTime(getContext(), usageTimeMs, false);
             preference.setSummary(
                     (sipper.drainType != DrainType.APP || mBatteryUtils.shouldHideSipper(sipper))
                             ? timeSequence
diff --git a/src/com/android/settings/fuelgauge/batterysaver/AutoBatterySaverPreferenceController.java b/src/com/android/settings/fuelgauge/batterysaver/AutoBatterySaverPreferenceController.java
new file mode 100644
index 0000000..4d3dd31
--- /dev/null
+++ b/src/com/android/settings/fuelgauge/batterysaver/AutoBatterySaverPreferenceController.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.fuelgauge.batterysaver;
+
+import android.content.Context;
+import android.provider.Settings;
+import android.support.annotation.VisibleForTesting;
+import android.support.v14.preference.SwitchPreference;
+import android.support.v7.preference.Preference;
+
+import com.android.settings.core.BasePreferenceController;
+import com.android.settings.core.TogglePreferenceController;
+
+/**
+ * Controller that update whether to turn on battery saver automatically
+ */
+public class AutoBatterySaverPreferenceController extends TogglePreferenceController implements
+        Preference.OnPreferenceChangeListener {
+    private static final int LOW_POWER_MODE_TRIGGER_THRESHOLD = 15;
+
+    @VisibleForTesting
+    static final String KEY_AUTO_BATTERY_SAVER = "auto_battery_saver";
+
+    public AutoBatterySaverPreferenceController(Context context) {
+        super(context, KEY_AUTO_BATTERY_SAVER);
+    }
+
+    @Override
+    public int getAvailabilityStatus() {
+        return AVAILABLE;
+    }
+
+    @Override
+    public boolean isChecked() {
+        return Settings.Global.getInt(mContext.getContentResolver(),
+                Settings.Global.LOW_POWER_MODE_TRIGGER_LEVEL, 0) != 0;
+    }
+
+    @Override
+    public boolean setChecked(boolean isChecked) {
+        Settings.Global.putInt(mContext.getContentResolver(),
+                Settings.Global.LOW_POWER_MODE_TRIGGER_LEVEL,
+                isChecked
+                        ? LOW_POWER_MODE_TRIGGER_THRESHOLD
+                        : 0);
+        return true;
+    }
+}
diff --git a/src/com/android/settings/fuelgauge/batterysaver/AutoBatterySeekBarPreferenceController.java b/src/com/android/settings/fuelgauge/batterysaver/AutoBatterySeekBarPreferenceController.java
new file mode 100644
index 0000000..1c787ab
--- /dev/null
+++ b/src/com/android/settings/fuelgauge/batterysaver/AutoBatterySeekBarPreferenceController.java
@@ -0,0 +1,135 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.fuelgauge.batterysaver;
+
+import android.content.ContentResolver;
+import android.content.Context;
+import android.database.ContentObserver;
+import android.net.Uri;
+import android.os.Handler;
+import android.provider.Settings;
+import android.support.annotation.VisibleForTesting;
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceScreen;
+
+import com.android.settings.R;
+import com.android.settings.Utils;
+import com.android.settings.core.BasePreferenceController;
+import com.android.settings.widget.SeekBarPreference;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+import com.android.settingslib.core.lifecycle.LifecycleObserver;
+import com.android.settingslib.core.lifecycle.events.OnStart;
+import com.android.settingslib.core.lifecycle.events.OnStop;
+
+/**
+ * Controller that update the battery saver seekbar
+ */
+public class AutoBatterySeekBarPreferenceController extends BasePreferenceController implements
+        LifecycleObserver, OnStart, OnStop, SeekBarPreference.OnPreferenceChangeListener {
+    @VisibleForTesting
+    static final String KEY_AUTO_BATTERY_SEEK_BAR = "battery_saver_seek_bar";
+    private SeekBarPreference mPreference;
+    private AutoBatterySaverSettingObserver mContentObserver;
+
+    public AutoBatterySeekBarPreferenceController(Context context, Lifecycle lifecycle) {
+        super(context, KEY_AUTO_BATTERY_SEEK_BAR);
+        mContentObserver = new AutoBatterySaverSettingObserver(new Handler());
+        if (lifecycle != null) {
+            lifecycle.addObserver(this);
+        }
+    }
+
+    @Override
+    public void displayPreference(PreferenceScreen screen) {
+        super.displayPreference(screen);
+        mPreference = (SeekBarPreference) screen.findPreference(
+                KEY_AUTO_BATTERY_SEEK_BAR);
+        updatePreference(mPreference);
+    }
+
+    @Override
+    public int getAvailabilityStatus() {
+        return AVAILABLE;
+    }
+
+    @Override
+    public void updateState(Preference preference) {
+        super.updateState(preference);
+        updatePreference(preference);
+    }
+
+    @Override
+    public void onStart() {
+        mContentObserver.registerContentObserver();
+    }
+
+    @Override
+    public void onStop() {
+        mContentObserver.unRegisterContentObserver();
+    }
+
+    @Override
+    public boolean onPreferenceChange(Preference preference, Object newValue) {
+        final int progress = (int) newValue;
+        Settings.Global.putInt(mContext.getContentResolver(),
+                Settings.Global.LOW_POWER_MODE_TRIGGER_LEVEL, progress);
+        return true;
+    }
+
+    @VisibleForTesting
+    void updatePreference(Preference preference) {
+        final ContentResolver contentResolver = mContext.getContentResolver();
+        final int level = Settings.Global.getInt(contentResolver,
+                Settings.Global.LOW_POWER_MODE_TRIGGER_LEVEL, 0);
+        if (level == 0) {
+            preference.setVisible(false);
+        } else {
+            preference.setVisible(true);
+            preference.setTitle(mContext.getString(R.string.battery_saver_seekbar_title,
+                    Utils.formatPercentage(level)));
+            ((SeekBarPreference) preference).setProgress(level);
+        }
+    }
+
+    /**
+     * Observer that listens to change from {@link Settings.Global.LOW_POWER_MODE_TRIGGER_LEVEL}
+     */
+    private final class AutoBatterySaverSettingObserver extends ContentObserver {
+        private final Uri mUri = Settings.Global.getUriFor(
+                Settings.Global.LOW_POWER_MODE_TRIGGER_LEVEL);
+        private final ContentResolver mContentResolver;
+
+        public AutoBatterySaverSettingObserver(Handler handler) {
+            super(handler);
+            mContentResolver = mContext.getContentResolver();
+        }
+
+        public void registerContentObserver() {
+            mContentResolver.registerContentObserver(mUri, false, this);
+        }
+
+        public void unRegisterContentObserver() {
+            mContentResolver.unregisterContentObserver(this);
+        }
+
+        @Override
+        public void onChange(boolean selfChange, Uri uri, int userId) {
+            if (mUri.equals(uri)) {
+                updatePreference(mPreference);
+            }
+        }
+    }
+}
diff --git a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceController.java b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceController.java
new file mode 100644
index 0000000..1d427c9
--- /dev/null
+++ b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceController.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.fuelgauge.batterysaver;
+
+import android.content.Context;
+import android.os.PowerManager;
+import android.support.annotation.VisibleForTesting;
+import android.support.v7.preference.Preference;
+
+import com.android.settings.fuelgauge.BatteryBroadcastReceiver;
+import com.android.settings.fuelgauge.BatterySaverReceiver;
+import com.android.settings.widget.TwoStateButtonPreferenceController;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+import com.android.settingslib.core.lifecycle.LifecycleObserver;
+import com.android.settingslib.core.lifecycle.events.OnStart;
+import com.android.settingslib.core.lifecycle.events.OnStop;
+
+/**
+ * Controller to update the battery saver button
+ */
+public class BatterySaverButtonPreferenceController extends
+        TwoStateButtonPreferenceController implements
+        LifecycleObserver, OnStart, OnStop, BatterySaverReceiver.BatterySaverListener {
+    private static final String KEY = "battery_saver_button_container";
+    private BatterySaverReceiver mBatterySaverReceiver;
+    @VisibleForTesting
+    PowerManager mPowerManager;
+
+    public BatterySaverButtonPreferenceController(Context context, Lifecycle lifecycle) {
+        super(context, KEY);
+        mPowerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
+        mBatterySaverReceiver = new BatterySaverReceiver(context);
+        mBatterySaverReceiver.setBatterySaverListener(this);
+        if (lifecycle != null) {
+            lifecycle.addObserver(this);
+        }
+    }
+
+    @Override
+    public void onStart() {
+        mBatterySaverReceiver.setListening(true);
+    }
+
+    @Override
+    public void onStop() {
+        mBatterySaverReceiver.setListening(false);
+    }
+
+    @Override
+    public void updateState(Preference preference) {
+        super.updateState(preference);
+        setButtonVisibility(!mPowerManager.isPowerSaveMode());
+    }
+
+    @Override
+    public int getAvailabilityStatus() {
+        return AVAILABLE;
+    }
+
+    @Override
+    public void onButtonClicked(boolean stateOn) {
+        mPowerManager.setPowerSaveMode(stateOn);
+    }
+
+    @Override
+    public void onPowerSaveModeChanged() {
+        setButtonVisibility(!mPowerManager.isPowerSaveMode());
+    }
+
+    @Override
+    public void onBatteryChanged(boolean pluggedIn) {
+        setButtonEnabled(!pluggedIn);
+    }
+}
\ No newline at end of file
diff --git a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverSettings.java b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverSettings.java
new file mode 100644
index 0000000..2340675
--- /dev/null
+++ b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverSettings.java
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2014 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.fuelgauge.batterysaver;
+
+import android.content.Context;
+import android.os.Bundle;
+import android.os.PowerManager;
+import android.provider.SearchIndexableResource;
+import android.provider.Settings.Global;
+import android.support.annotation.VisibleForTesting;
+import android.util.Log;
+
+import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+import com.android.internal.util.ArrayUtils;
+import com.android.settings.R;
+import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.search.BaseSearchIndexProvider;
+import com.android.settings.search.Indexable;
+import com.android.settingslib.core.AbstractPreferenceController;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Battery saver settings page
+ */
+public class BatterySaverSettings extends DashboardFragment {
+    private static final String TAG = "BatterySaverSettings";
+
+    @Override
+    public void onActivityCreated(Bundle savedInstanceState) {
+        super.onActivityCreated(savedInstanceState);
+    }
+
+    @Override
+    public int getMetricsCategory() {
+        return MetricsEvent.FUELGAUGE_BATTERY_SAVER;
+    }
+
+    @Override
+    protected int getPreferenceScreenResId() {
+        return R.xml.battery_saver_settings;
+    }
+
+    @Override
+    protected String getLogTag() {
+        return TAG;
+    }
+
+    @Override
+    protected List<AbstractPreferenceController> getPreferenceControllers(Context context) {
+        return buildPreferenceControllers(context, getLifecycle());
+    }
+
+    @Override
+    public int getHelpResource() {
+        return R.string.help_url_battery_saver_settings;
+    }
+
+    private static List<AbstractPreferenceController> buildPreferenceControllers(
+            Context context, Lifecycle lifecycle) {
+        final List<AbstractPreferenceController> controllers = new ArrayList<>();
+        controllers.add(new AutoBatterySaverPreferenceController(context));
+        controllers.add(new AutoBatterySeekBarPreferenceController(context, lifecycle));
+        controllers.add(new BatterySaverButtonPreferenceController(context, lifecycle));
+        return controllers;
+    }
+
+    /**
+     * For Search.
+     */
+    public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+            new BaseSearchIndexProvider() {
+                @Override
+                public List<SearchIndexableResource> getXmlResourcesToIndex(
+                        Context context, boolean enabled) {
+                    final SearchIndexableResource sir = new SearchIndexableResource(context);
+                    sir.xmlResId = R.xml.battery_saver_settings;
+                    return Arrays.asList(sir);
+                }
+
+                @Override
+                public List<AbstractPreferenceController> getPreferenceControllers(Context context) {
+                    return buildPreferenceControllers(context, null);
+                }
+            };
+}
diff --git a/src/com/android/settings/fuelgauge/batterytip/AnomalyDatabaseHelper.java b/src/com/android/settings/fuelgauge/batterytip/AnomalyDatabaseHelper.java
index a13df25..645ba16 100644
--- a/src/com/android/settings/fuelgauge/batterytip/AnomalyDatabaseHelper.java
+++ b/src/com/android/settings/fuelgauge/batterytip/AnomalyDatabaseHelper.java
@@ -19,10 +19,14 @@
 import android.content.Context;
 import android.database.sqlite.SQLiteDatabase;
 import android.database.sqlite.SQLiteOpenHelper;
+import android.support.annotation.IntDef;
 import android.util.Log;
 
 import com.android.settings.fuelgauge.anomaly.Anomaly;
 
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
 /**
  * Database controls the anomaly logging(e.g. packageName, anomalyType and time)
  */
@@ -30,7 +34,17 @@
     private static final String TAG = "BatteryDatabaseHelper";
 
     private static final String DATABASE_NAME = "battery_settings.db";
-    private static final int DATABASE_VERSION = 1;
+    private static final int DATABASE_VERSION = 2;
+
+    @Retention(RetentionPolicy.SOURCE)
+    @IntDef({State.NEW,
+            State.HANDLED,
+            State.AUTO_HANDLED})
+    public @interface State {
+        int NEW = 0;
+        int HANDLED = 1;
+        int AUTO_HANDLED = 2;
+    }
 
     public interface Tables {
         String TABLE_ANOMALY = "anomaly";
@@ -47,6 +61,11 @@
          */
         String ANOMALY_TYPE = "anomaly_type";
         /**
+         * The state of the anomaly app
+         * @see State
+         */
+        String ANOMALY_STATE = "anomaly_state";
+        /**
          * The time when anomaly happens
          */
         String TIME_STAMP_MS = "time_stamp_ms";
@@ -59,6 +78,8 @@
                     " TEXT, " +
                     AnomalyColumns.ANOMALY_TYPE +
                     " INTEGER, " +
+                    AnomalyColumns.ANOMALY_STATE +
+                    " INTEGER, " +
                     AnomalyColumns.TIME_STAMP_MS +
                     " INTEGER)";
 
diff --git a/src/com/android/settings/fuelgauge/batterytip/BatteryDatabaseManager.java b/src/com/android/settings/fuelgauge/batterytip/BatteryDatabaseManager.java
index f87501f..2019b9d 100644
--- a/src/com/android/settings/fuelgauge/batterytip/BatteryDatabaseManager.java
+++ b/src/com/android/settings/fuelgauge/batterytip/BatteryDatabaseManager.java
@@ -17,6 +17,8 @@
 package com.android.settings.fuelgauge.batterytip;
 
 import static com.android.settings.fuelgauge.batterytip.AnomalyDatabaseHelper.AnomalyColumns
+        .ANOMALY_STATE;
+import static com.android.settings.fuelgauge.batterytip.AnomalyDatabaseHelper.AnomalyColumns
         .PACKAGE_NAME;
 import static com.android.settings.fuelgauge.batterytip.AnomalyDatabaseHelper.AnomalyColumns
         .ANOMALY_TYPE;
@@ -28,8 +30,10 @@
 import android.content.Context;
 import android.database.Cursor;
 import android.database.sqlite.SQLiteDatabase;
+import android.text.TextUtils;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 
 /**
@@ -55,22 +59,24 @@
             values.put(PACKAGE_NAME, packageName);
             values.put(ANOMALY_TYPE, type);
             values.put(TIME_STAMP_MS, timestampMs);
-
+            values.put(ANOMALY_STATE, AnomalyDatabaseHelper.State.NEW);
             db.insert(TABLE_ANOMALY, null, values);
         }
     }
 
     /**
-     * Query all the anomalies that happened after {@code timestampMs}.
+     * Query all the anomalies that happened after {@code timestampMsAfter} and with {@code state}.
      */
-    public List<AppInfo> queryAllAnomaliesAfter(long timestampMs) {
+    public List<AppInfo> queryAllAnomalies(long timestampMsAfter, int state) {
         final List<AppInfo> appInfos = new ArrayList<>();
         try (SQLiteDatabase db = mDatabaseHelper.getReadableDatabase()) {
             final String[] projection = {PACKAGE_NAME, ANOMALY_TYPE};
             final String orderBy = AnomalyDatabaseHelper.AnomalyColumns.TIME_STAMP_MS + " DESC";
 
-            try (Cursor cursor = db.query(TABLE_ANOMALY, projection, TIME_STAMP_MS + " > ?",
-                    new String[]{String.valueOf(timestampMs)}, null, null, orderBy)) {
+            try (Cursor cursor = db.query(TABLE_ANOMALY, projection,
+                    TIME_STAMP_MS + " > ? AND " + ANOMALY_STATE + " = ? ",
+                    new String[]{String.valueOf(timestampMsAfter), String.valueOf(state)}, null,
+                    null, orderBy)) {
                 while (cursor.moveToNext()) {
                     AppInfo appInfo = new AppInfo.Builder()
                             .setPackageName(cursor.getString(cursor.getColumnIndex(PACKAGE_NAME)))
@@ -90,4 +96,26 @@
                     new String[]{String.valueOf(timestampMs)});
         }
     }
+
+    /**
+     * Update the type of anomalies to {@code state}
+     *
+     * @param appInfos represents the anomalies
+     * @param state    which state to update to
+     */
+    public void updateAnomalies(List<AppInfo> appInfos, int state) {
+        if (!appInfos.isEmpty()) {
+            final int size = appInfos.size();
+            final String[] whereArgs = new String[size];
+            for (int i = 0; i < size; i++) {
+                whereArgs[i] = appInfos.get(i).packageName;
+            }
+            try (SQLiteDatabase db = mDatabaseHelper.getWritableDatabase()) {
+                final ContentValues values = new ContentValues();
+                values.put(ANOMALY_STATE, state);
+                db.update(TABLE_ANOMALY, values, PACKAGE_NAME + " IN (" + TextUtils.join(",",
+                        Collections.nCopies(appInfos.size(), "?")) + ")", whereArgs);
+            }
+        }
+    }
 }
diff --git a/src/com/android/settings/fuelgauge/batterytip/BatteryTipDialogFragment.java b/src/com/android/settings/fuelgauge/batterytip/BatteryTipDialogFragment.java
index 66ce3ca..d93b589 100644
--- a/src/com/android/settings/fuelgauge/batterytip/BatteryTipDialogFragment.java
+++ b/src/com/android/settings/fuelgauge/batterytip/BatteryTipDialogFragment.java
@@ -36,6 +36,7 @@
 import com.android.settings.fuelgauge.batterytip.tips.HighUsageTip;
 import com.android.settings.fuelgauge.batterytip.tips.RestrictAppTip;
 import com.android.settings.fuelgauge.batterytip.tips.UnrestrictAppTip;
+import com.android.settingslib.utils.StringUtil;
 
 import java.util.List;
 
@@ -83,7 +84,8 @@
 
                 return new AlertDialog.Builder(context)
                         .setMessage(getString(R.string.battery_tip_dialog_message,
-                                Utils.formatElapsedTime(context, highUsageTip.getScreenTimeMs(),
+                                StringUtil.formatElapsedTime(
+                                        context, highUsageTip.getScreenTimeMs(),
                                         false /* withSeconds */)))
                         .setView(view)
                         .setPositiveButton(android.R.string.ok, null)
diff --git a/src/com/android/settings/fuelgauge/batterytip/BatteryTipLoader.java b/src/com/android/settings/fuelgauge/batterytip/BatteryTipLoader.java
index a615841..ebb4790 100644
--- a/src/com/android/settings/fuelgauge/batterytip/BatteryTipLoader.java
+++ b/src/com/android/settings/fuelgauge/batterytip/BatteryTipLoader.java
@@ -71,7 +71,7 @@
         tips.add(new SmartBatteryDetector(policy, context.getContentResolver()).detect());
         tips.add(new EarlyWarningDetector(policy, context).detect());
         tips.add(new SummaryDetector(policy).detect());
-        tips.add(new RestrictAppDetector(policy).detect());
+        tips.add(new RestrictAppDetector(context, policy).detect());
 
         Collections.sort(tips);
         return tips;
diff --git a/src/com/android/settings/fuelgauge/batterytip/HighUsageAdapter.java b/src/com/android/settings/fuelgauge/batterytip/HighUsageAdapter.java
index 6c129d8..d982280 100644
--- a/src/com/android/settings/fuelgauge/batterytip/HighUsageAdapter.java
+++ b/src/com/android/settings/fuelgauge/batterytip/HighUsageAdapter.java
@@ -30,6 +30,7 @@
 import com.android.settings.R;
 import com.android.settings.Utils;
 
+import com.android.settingslib.utils.StringUtil;
 import java.util.List;
 
 /**
@@ -78,7 +79,7 @@
                         UserHandle.myUserId()));
         holder.appName.setText(Utils.getApplicationLabel(mContext, app.packageName));
         if (app.screenOnTimeMs != 0) {
-            holder.appTime.setText(Utils.formatElapsedTime(mContext, app.screenOnTimeMs, false));
+            holder.appTime.setText(StringUtil.formatElapsedTime(mContext, app.screenOnTimeMs, false));
         }
     }
 
diff --git a/src/com/android/settings/fuelgauge/batterytip/actions/RestrictAppAction.java b/src/com/android/settings/fuelgauge/batterytip/actions/RestrictAppAction.java
index 9c49822..886a6d5 100644
--- a/src/com/android/settings/fuelgauge/batterytip/actions/RestrictAppAction.java
+++ b/src/com/android/settings/fuelgauge/batterytip/actions/RestrictAppAction.java
@@ -21,7 +21,9 @@
 import android.support.annotation.VisibleForTesting;
 
 import com.android.settings.fuelgauge.BatteryUtils;
+import com.android.settings.fuelgauge.batterytip.AnomalyDatabaseHelper;
 import com.android.settings.fuelgauge.batterytip.AppInfo;
+import com.android.settings.fuelgauge.batterytip.BatteryDatabaseManager;
 import com.android.settings.fuelgauge.batterytip.tips.RestrictAppTip;
 
 import java.util.List;
@@ -32,12 +34,15 @@
 public class RestrictAppAction extends BatteryTipAction {
     private RestrictAppTip mRestrictAppTip;
     @VisibleForTesting
+    BatteryDatabaseManager mBatteryDatabaseManager;
+    @VisibleForTesting
     BatteryUtils mBatteryUtils;
 
     public RestrictAppAction(Context context, RestrictAppTip tip) {
         super(context);
         mRestrictAppTip = tip;
         mBatteryUtils = BatteryUtils.getInstance(context);
+        mBatteryDatabaseManager = new BatteryDatabaseManager(context);
     }
 
     /**
@@ -53,5 +58,7 @@
             mBatteryUtils.setForceAppStandby(mBatteryUtils.getPackageUid(packageName), packageName,
                     AppOpsManager.MODE_IGNORED);
         }
+
+        mBatteryDatabaseManager.updateAnomalies(appInfos, AnomalyDatabaseHelper.State.HANDLED);
     }
 }
diff --git a/src/com/android/settings/fuelgauge/batterytip/detectors/RestrictAppDetector.java b/src/com/android/settings/fuelgauge/batterytip/detectors/RestrictAppDetector.java
index 46e241a..e3c9b9e 100644
--- a/src/com/android/settings/fuelgauge/batterytip/detectors/RestrictAppDetector.java
+++ b/src/com/android/settings/fuelgauge/batterytip/detectors/RestrictAppDetector.java
@@ -16,7 +16,13 @@
 
 package com.android.settings.fuelgauge.batterytip.detectors;
 
+import android.content.Context;
+import android.support.annotation.VisibleForTesting;
+import android.text.format.DateUtils;
+
+import com.android.settings.fuelgauge.batterytip.AnomalyDatabaseHelper;
 import com.android.settings.fuelgauge.batterytip.AppInfo;
+import com.android.settings.fuelgauge.batterytip.BatteryDatabaseManager;
 import com.android.settings.fuelgauge.batterytip.BatteryTipPolicy;
 import com.android.settings.fuelgauge.batterytip.tips.BatteryTip;
 import com.android.settings.fuelgauge.batterytip.tips.RestrictAppTip;
@@ -29,18 +35,47 @@
  * {@link BatteryTipDetector} since it need the most up-to-date {@code visibleTips}
  */
 public class RestrictAppDetector implements BatteryTipDetector {
+    @VisibleForTesting
+    static final boolean USE_FAKE_DATA = false;
     private BatteryTipPolicy mPolicy;
+    @VisibleForTesting
+    BatteryDatabaseManager mBatteryDatabaseManager;
 
-    public RestrictAppDetector(BatteryTipPolicy policy) {
+    public RestrictAppDetector(Context context, BatteryTipPolicy policy) {
         mPolicy = policy;
+        mBatteryDatabaseManager = new BatteryDatabaseManager(context);
     }
 
     @Override
     public BatteryTip detect() {
-        // TODO(b/70570352): Detect restrict apps here, get data from database
+        if (USE_FAKE_DATA) {
+            return getFakeData();
+        }
+        if (mPolicy.appRestrictionEnabled) {
+            // TODO(b/72385333): hook up the query timestamp to server side
+            final long oneDayBeforeMs = System.currentTimeMillis() - DateUtils.DAY_IN_MILLIS;
+            final List<AppInfo> highUsageApps = mBatteryDatabaseManager.queryAllAnomalies(
+                    oneDayBeforeMs, AnomalyDatabaseHelper.State.NEW);
+            if (!highUsageApps.isEmpty()) {
+                // If there are new anomalies, show them
+                return new RestrictAppTip(BatteryTip.StateType.NEW, highUsageApps);
+            } else {
+                // Otherwise, show auto-handled one if it exists
+                final List<AppInfo> autoHandledApps = mBatteryDatabaseManager.queryAllAnomalies(
+                        oneDayBeforeMs, AnomalyDatabaseHelper.State.AUTO_HANDLED);
+                return new RestrictAppTip(autoHandledApps.isEmpty() ? BatteryTip.StateType.INVISIBLE
+                        : BatteryTip.StateType.HANDLED, autoHandledApps);
+            }
+        } else {
+            return new RestrictAppTip(BatteryTip.StateType.INVISIBLE, new ArrayList<>());
+        }
+    }
+
+    private BatteryTip getFakeData() {
         final List<AppInfo> highUsageApps = new ArrayList<>();
-        return new RestrictAppTip(
-                highUsageApps.isEmpty() ? BatteryTip.StateType.INVISIBLE : BatteryTip.StateType.NEW,
-                highUsageApps);
+        highUsageApps.add(new AppInfo.Builder()
+                .setPackageName("com.android.settings")
+                .build());
+        return new RestrictAppTip(BatteryTip.StateType.NEW, highUsageApps);
     }
 }
diff --git a/src/com/android/settings/fuelgauge/batterytip/tips/HighUsageTip.java b/src/com/android/settings/fuelgauge/batterytip/tips/HighUsageTip.java
index 2aabf98..6091131 100644
--- a/src/com/android/settings/fuelgauge/batterytip/tips/HighUsageTip.java
+++ b/src/com/android/settings/fuelgauge/batterytip/tips/HighUsageTip.java
@@ -22,9 +22,9 @@
 import android.support.annotation.VisibleForTesting;
 
 import com.android.settings.R;
-import com.android.settings.Utils;
 import com.android.settings.fuelgauge.batterytip.AppInfo;
 
+import com.android.settingslib.utils.StringUtil;
 import java.util.List;
 
 /**
@@ -65,7 +65,7 @@
     @Override
     public CharSequence getSummary(Context context) {
         return context.getString(R.string.battery_tip_high_usage_summary,
-                Utils.formatElapsedTime(context, mScreenTimeMs, false));
+                StringUtil.formatElapsedTime(context, mScreenTimeMs, false));
     }
 
     @Override
diff --git a/src/com/android/settings/fuelgauge/batterytip/tips/RestrictAppTip.java b/src/com/android/settings/fuelgauge/batterytip/tips/RestrictAppTip.java
index 1d84d7f..a40f292 100644
--- a/src/com/android/settings/fuelgauge/batterytip/tips/RestrictAppTip.java
+++ b/src/com/android/settings/fuelgauge/batterytip/tips/RestrictAppTip.java
@@ -81,7 +81,14 @@
 
     @Override
     public void updateState(BatteryTip tip) {
-        mState = tip.mState;
+        if (tip.mState == StateType.NEW) {
+            // Display it if new anomaly comes
+            mState = StateType.NEW;
+            mRestrictAppList = ((RestrictAppTip) tip).mRestrictAppList;
+        } else if (mState == StateType.NEW && tip.mState == StateType.INVISIBLE) {
+            // If anomaly becomes invisible, show it as handled
+            mState = StateType.HANDLED;
+        }
     }
 
     public List<AppInfo> getRestrictAppList() {
diff --git a/src/com/android/settings/gestures/DoubleTapScreenPreferenceController.java b/src/com/android/settings/gestures/DoubleTapScreenPreferenceController.java
index 5412f36..aa08e6f 100644
--- a/src/com/android/settings/gestures/DoubleTapScreenPreferenceController.java
+++ b/src/com/android/settings/gestures/DoubleTapScreenPreferenceController.java
@@ -102,4 +102,9 @@
         return new InlineSwitchPayload(SECURE_KEY, ResultPayload.SettingsSource.SECURE,
                 ON /* onValue */, intent, isAvailable(), ON /* defaultValue */);
     }
+
+    @Override
+    protected boolean canHandleClicks() {
+        return !mAmbientConfig.alwaysOnEnabled(mUserId);
+    }
 }
\ No newline at end of file
diff --git a/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java b/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java
index 279dcd3..ce5e1d1 100644
--- a/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java
+++ b/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java
@@ -46,6 +46,7 @@
 import com.android.settingslib.applications.AppUtils;
 import com.android.settingslib.applications.ApplicationsState;
 import com.android.settingslib.core.AbstractPreferenceController;
+import com.android.settingslib.utils.StringUtil;
 import com.android.settingslib.wrapper.PackageManagerWrapper;
 
 import java.util.ArrayList;
@@ -229,7 +230,7 @@
             pref.setKey(pkgName);
             pref.setTitle(appEntry.label);
             pref.setIcon(mIconDrawableFactory.getBadgedIcon(appEntry.info));
-            pref.setSummary(Utils.formatRelativeTime(mContext,
+            pref.setSummary(StringUtil.formatRelativeTime(mContext,
                     System.currentTimeMillis() - app.getLastNotified(), false));
             pref.setOrder(i);
             Bundle args = new Bundle();
diff --git a/src/com/android/settings/notification/VisibilityPreferenceController.java b/src/com/android/settings/notification/VisibilityPreferenceController.java
index 62ca183..dac90ef 100644
--- a/src/com/android/settings/notification/VisibilityPreferenceController.java
+++ b/src/com/android/settings/notification/VisibilityPreferenceController.java
@@ -84,14 +84,17 @@
                                 | DevicePolicyManager.KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS);
             }
 
-            final String summaryHideEntry =
-                    mContext.getString(R.string.lock_screen_notifications_summary_hide);
-            final String summaryHideEntryValue = Integer.toString(Notification.VISIBILITY_PRIVATE);
-            entries.add(summaryHideEntry);
-            values.add(summaryHideEntryValue);
-            setRestrictedIfNotificationFeaturesDisabled(pref,
-                    summaryHideEntry, summaryHideEntryValue,
-                    DevicePolicyManager.KEYGUARD_DISABLE_SECURE_NOTIFICATIONS);
+            if (getLockscreenNotificationsEnabled()) {
+                final String summaryHideEntry =
+                        mContext.getString(R.string.lock_screen_notifications_summary_hide);
+                final String summaryHideEntryValue = Integer.toString(
+                        Notification.VISIBILITY_PRIVATE);
+                entries.add(summaryHideEntry);
+                values.add(summaryHideEntryValue);
+                setRestrictedIfNotificationFeaturesDisabled(pref,
+                        summaryHideEntry, summaryHideEntryValue,
+                        DevicePolicyManager.KEYGUARD_DISABLE_SECURE_NOTIFICATIONS);
+            }
             entries.add(mContext.getString(R.string.lock_screen_notifications_summary_disable));
             values.add(Integer.toString(Notification.VISIBILITY_SECRET));
             pref.setEntries(entries.toArray(new CharSequence[entries.size()]));
diff --git a/src/com/android/settings/overlay/FeatureFactory.java b/src/com/android/settings/overlay/FeatureFactory.java
index 80d435f..7cf437f 100644
--- a/src/com/android/settings/overlay/FeatureFactory.java
+++ b/src/com/android/settings/overlay/FeatureFactory.java
@@ -24,16 +24,14 @@
 import com.android.settings.accounts.AccountFeatureProvider;
 import com.android.settings.applications.ApplicationFeatureProvider;
 import com.android.settings.bluetooth.BluetoothFeatureProvider;
-import com.android.settings.connecteddevice.SmsMirroringFeatureProvider;
 import com.android.settings.dashboard.DashboardFeatureProvider;
 import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
-import com.android.settings.datausage.DataPlanFeatureProvider;
 import com.android.settings.enterprise.EnterprisePrivacyFeatureProvider;
 import com.android.settings.fuelgauge.PowerUsageFeatureProvider;
 import com.android.settings.gestures.AssistGestureFeatureProvider;
 import com.android.settings.localepicker.LocaleFeatureProvider;
-import com.android.settings.security.SecurityFeatureProvider;
 import com.android.settings.search.SearchFeatureProvider;
+import com.android.settings.security.SecurityFeatureProvider;
 import com.android.settings.slices.SlicesFeatureProvider;
 import com.android.settings.users.UserFeatureProvider;
 import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
@@ -104,10 +102,6 @@
 
     public abstract BluetoothFeatureProvider getBluetoothFeatureProvider(Context context);
 
-    public abstract DataPlanFeatureProvider getDataPlanFeatureProvider();
-
-    public abstract SmsMirroringFeatureProvider getSmsMirroringFeatureProvider();
-
     public abstract SlicesFeatureProvider getSlicesFeatureProvider();
 
     public abstract AccountFeatureProvider getAccountFeatureProvider();
diff --git a/src/com/android/settings/overlay/FeatureFactoryImpl.java b/src/com/android/settings/overlay/FeatureFactoryImpl.java
index 55f408d..5fc8627 100644
--- a/src/com/android/settings/overlay/FeatureFactoryImpl.java
+++ b/src/com/android/settings/overlay/FeatureFactoryImpl.java
@@ -29,14 +29,10 @@
 import com.android.settings.applications.ApplicationFeatureProviderImpl;
 import com.android.settings.bluetooth.BluetoothFeatureProvider;
 import com.android.settings.bluetooth.BluetoothFeatureProviderImpl;
-import com.android.settings.connecteddevice.SmsMirroringFeatureProvider;
-import com.android.settings.connecteddevice.SmsMirroringFeatureProviderImpl;
 import com.android.settings.dashboard.DashboardFeatureProvider;
 import com.android.settings.dashboard.DashboardFeatureProviderImpl;
 import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
 import com.android.settings.dashboard.suggestions.SuggestionFeatureProviderImpl;
-import com.android.settings.datausage.DataPlanFeatureProvider;
-import com.android.settings.datausage.DataPlanFeatureProviderImpl;
 import com.android.settings.enterprise.EnterprisePrivacyFeatureProvider;
 import com.android.settings.enterprise.EnterprisePrivacyFeatureProviderImpl;
 import com.android.settings.fuelgauge.PowerUsageFeatureProvider;
@@ -77,8 +73,6 @@
     private AssistGestureFeatureProvider mAssistGestureFeatureProvider;
     private UserFeatureProvider mUserFeatureProvider;
     private BluetoothFeatureProvider mBluetoothFeatureProvider;
-    private DataPlanFeatureProvider mDataPlanFeatureProvider;
-    private SmsMirroringFeatureProvider mSmsMirroringFeatureProvider;
     private SlicesFeatureProvider mSlicesFeatureProvider;
     private AccountFeatureProvider mAccountFeatureProvider;
 
@@ -192,14 +186,6 @@
     }
 
     @Override
-    public DataPlanFeatureProvider getDataPlanFeatureProvider() {
-        if (mDataPlanFeatureProvider == null) {
-            mDataPlanFeatureProvider = new DataPlanFeatureProviderImpl();
-        }
-        return mDataPlanFeatureProvider;
-    }
-
-    @Override
     public AssistGestureFeatureProvider getAssistGestureFeatureProvider() {
         if (mAssistGestureFeatureProvider == null) {
             mAssistGestureFeatureProvider = new AssistGestureFeatureProviderImpl();
@@ -208,14 +194,6 @@
     }
 
     @Override
-    public SmsMirroringFeatureProvider getSmsMirroringFeatureProvider() {
-        if (mSmsMirroringFeatureProvider == null) {
-            mSmsMirroringFeatureProvider = new SmsMirroringFeatureProviderImpl();
-        }
-        return mSmsMirroringFeatureProvider;
-    }
-
-    @Override
     public SlicesFeatureProvider getSlicesFeatureProvider() {
         if (mSlicesFeatureProvider == null) {
             mSlicesFeatureProvider = new SlicesFeatureProviderImpl();
diff --git a/src/com/android/settings/print/PrintSettingPreferenceController.java b/src/com/android/settings/print/PrintSettingPreferenceController.java
new file mode 100644
index 0000000..bb8a81e
--- /dev/null
+++ b/src/com/android/settings/print/PrintSettingPreferenceController.java
@@ -0,0 +1,135 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.print;
+
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.print.PrintJob;
+import android.print.PrintJobId;
+import android.print.PrintJobInfo;
+import android.print.PrintManager;
+import android.printservice.PrintServiceInfo;
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceScreen;
+
+import com.android.settings.R;
+import com.android.settings.core.BasePreferenceController;
+import com.android.settings.wrapper.PrintManagerWrapper;
+import com.android.settingslib.core.lifecycle.LifecycleObserver;
+import com.android.settingslib.core.lifecycle.events.OnStart;
+import com.android.settingslib.core.lifecycle.events.OnStop;
+
+import java.util.List;
+
+/**
+ * {@link BasePreferenceController} for Print settings.
+ */
+public class PrintSettingPreferenceController extends BasePreferenceController implements
+        LifecycleObserver, OnStart, OnStop, PrintManager.PrintJobStateChangeListener {
+
+    private final PackageManager mPackageManager;
+    private PrintManagerWrapper mPrintManager;
+    private Preference mPreference;
+
+    public PrintSettingPreferenceController(Context context) {
+        super(context, "connected_device_printing" /* preferenceKey */);
+        mPackageManager = context.getPackageManager();
+        mPrintManager = new PrintManagerWrapper(context);
+    }
+
+    @Override
+    public int getAvailabilityStatus() {
+        return mPackageManager.hasSystemFeature(PackageManager.FEATURE_PRINTING)
+                ? AVAILABLE : DISABLED_UNSUPPORTED;
+    }
+
+    @Override
+    public void displayPreference(PreferenceScreen screen) {
+        super.displayPreference(screen);
+        mPreference = screen.findPreference(getPreferenceKey());
+    }
+
+    @Override
+    public void onStart() {
+        mPrintManager.addPrintJobStateChanegListener(this);
+    }
+
+    @Override
+    public void onStop() {
+        mPrintManager.removePrintJobStateChangeListener(this);
+    }
+
+    @Override
+    public void onPrintJobStateChanged(PrintJobId printJobId) {
+        updateState(mPreference);
+    }
+
+    @Override
+    public void updateState(Preference preference) {
+        if (preference == null) {
+            return;
+        }
+        preference.setSummary(getSummary());
+    }
+
+    @Override
+    public String getSummary() {
+        final List<PrintJob> printJobs = mPrintManager.getPrintJobs();
+
+        int numActivePrintJobs = 0;
+        if (printJobs != null) {
+            for (PrintJob job : printJobs) {
+                if (shouldShowToUser(job.getInfo())) {
+                    numActivePrintJobs++;
+                }
+            }
+        }
+
+        if (numActivePrintJobs > 0) {
+            return mContext.getResources().getQuantityString(
+                    R.plurals.print_jobs_summary, numActivePrintJobs, numActivePrintJobs);
+        } else {
+            final List<PrintServiceInfo> services =
+                    mPrintManager.getPrintServices(PrintManager.ENABLED_SERVICES);
+            if (services == null || services.isEmpty()) {
+                return mContext.getString(R.string.print_settings_summary_no_service);
+            } else {
+                final int count = services.size();
+                return mContext.getResources().getQuantityString(
+                        R.plurals.print_settings_summary, count, count);
+            }
+        }
+    }
+
+    /**
+     * Should the print job the shown to the user in the settings app.
+     *
+     * @param printJob The print job in question.
+     * @return true iff the print job should be shown.
+     */
+    static boolean shouldShowToUser(PrintJobInfo printJob) {
+        switch (printJob.getState()) {
+            case PrintJobInfo.STATE_QUEUED:
+            case PrintJobInfo.STATE_STARTED:
+            case PrintJobInfo.STATE_BLOCKED:
+            case PrintJobInfo.STATE_FAILED: {
+                return true;
+            }
+        }
+        return false;
+    }
+}
diff --git a/src/com/android/settings/print/PrintSettingsFragment.java b/src/com/android/settings/print/PrintSettingsFragment.java
index 56bebcc..21ee360 100644
--- a/src/com/android/settings/print/PrintSettingsFragment.java
+++ b/src/com/android/settings/print/PrintSettingsFragment.java
@@ -16,6 +16,8 @@
 
 package com.android.settings.print;
 
+import static com.android.settings.print.PrintSettingPreferenceController.shouldShowToUser;
+
 import android.app.LoaderManager.LoaderCallbacks;
 import android.content.ActivityNotFoundException;
 import android.content.AsyncTaskLoader;
@@ -37,7 +39,6 @@
 import android.printservice.PrintServiceInfo;
 import android.provider.SearchIndexableResource;
 import android.provider.Settings;
-import android.support.annotation.VisibleForTesting;
 import android.support.v7.preference.Preference;
 import android.support.v7.preference.PreferenceCategory;
 import android.text.TextUtils;
@@ -52,7 +53,6 @@
 
 import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
 import com.android.settings.R;
-import com.android.settings.dashboard.SummaryLoader;
 import com.android.settings.search.BaseSearchIndexProvider;
 import com.android.settings.search.Indexable;
 import com.android.settings.utils.ProfileSettingsPreferenceFragment;
@@ -131,11 +131,6 @@
     }
 
     @Override
-    public void onStop() {
-        super.onStop();
-    }
-
-    @Override
     public void onViewCreated(View view, Bundle savedInstanceState) {
         super.onViewCreated(view, savedInstanceState);
         ViewGroup contentRoot = (ViewGroup) getListView().getParent();
@@ -359,7 +354,7 @@
                                     printJob.getCreationTime(), printJob.getCreationTime(),
                                     DateFormat.SHORT, DateFormat.SHORT)));
 
-                    TypedArray a = getActivity().obtainStyledAttributes(new int[]{
+                    TypedArray a = getActivity().obtainStyledAttributes(new int[] {
                             android.R.attr.colorControlNormal});
                     int tintColor = a.getColor(0, 0);
                     a.recycle();
@@ -494,136 +489,17 @@
         }
     }
 
-    /**
-     * Should the print job the shown to the user in the settings app.
-     *
-     * @param printJob The print job in question.
-     * @return true iff the print job should be shown.
-     */
-    private static boolean shouldShowToUser(PrintJobInfo printJob) {
-        switch (printJob.getState()) {
-            case PrintJobInfo.STATE_QUEUED:
-            case PrintJobInfo.STATE_STARTED:
-            case PrintJobInfo.STATE_BLOCKED:
-            case PrintJobInfo.STATE_FAILED: {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    /**
-     * Provider for the print settings summary
-     */
-    @VisibleForTesting
-    static class PrintSummaryProvider
-            implements SummaryLoader.SummaryProvider, PrintJobStateChangeListener {
-        private final Context mContext;
-        private final PrintManagerWrapper mPrintManager;
-        private final SummaryLoader mSummaryLoader;
-
-        /**
-         * Create a new {@link PrintSummaryProvider}.
-         *
-         * @param context       The context this provider is for
-         * @param summaryLoader The summary load using this provider
-         */
-        PrintSummaryProvider(Context context, SummaryLoader summaryLoader,
-                PrintManagerWrapper printManager) {
-            mContext = context;
-            mSummaryLoader = summaryLoader;
-            mPrintManager = printManager;
-        }
-
-        @Override
-        public void setListening(boolean isListening) {
-            if (mPrintManager != null) {
-                if (isListening) {
-                    mPrintManager.addPrintJobStateChanegListner(this);
-                    onPrintJobStateChanged(null);
-                } else {
-                    mPrintManager.removePrintJobStateChangeListener(this);
-                }
-            }
-        }
-
-        @Override
-        public void onPrintJobStateChanged(PrintJobId printJobId) {
-            final List<PrintJob> printJobs = mPrintManager.getPrintJobs();
-
-            int numActivePrintJobs = 0;
-            if (printJobs != null) {
-                for (PrintJob job : printJobs) {
-                    if (shouldShowToUser(job.getInfo())) {
-                        numActivePrintJobs++;
-                    }
-                }
-            }
-
-            if (numActivePrintJobs > 0) {
-                mSummaryLoader.setSummary(this, mContext.getResources().getQuantityString(
-                        R.plurals.print_jobs_summary, numActivePrintJobs, numActivePrintJobs));
-            } else {
-                List<PrintServiceInfo> services =
-                        mPrintManager.getPrintServices(PrintManager.ENABLED_SERVICES);
-                if (services == null || services.isEmpty()) {
-                    mSummaryLoader.setSummary(this,
-                            mContext.getString(R.string.print_settings_summary_no_service));
-                } else {
-                    final int count = services.size();
-                    mSummaryLoader.setSummary(this,
-                            mContext.getResources().getQuantityString(
-                                    R.plurals.print_settings_summary, count, count));
-                }
-            }
-        }
-
-        static class PrintManagerWrapper {
-
-            private final PrintManager mPrintManager;
-
-            PrintManagerWrapper(Context context) {
-                mPrintManager = ((PrintManager) context.getSystemService(Context.PRINT_SERVICE))
-                        .getGlobalPrintManagerForUser(context.getUserId());
-            }
-
-            public List<PrintServiceInfo> getPrintServices(int selectionFlags) {
-                return mPrintManager.getPrintServices(selectionFlags);
-            }
-
-            public void addPrintJobStateChanegListner(PrintJobStateChangeListener listener) {
-                mPrintManager.addPrintJobStateChangeListener(listener);
-            }
-
-            public void removePrintJobStateChangeListener(PrintJobStateChangeListener listener) {
-                mPrintManager.removePrintJobStateChangeListener(listener);
-            }
-
-            public List<PrintJob> getPrintJobs() {
-                return mPrintManager.getPrintJobs();
-            }
-        }
-    }
-
-    /**
-     * A factory for {@link PrintSummaryProvider providers} the settings app can use to read the
-     * print summary.
-     */
-    public static final SummaryLoader.SummaryProviderFactory SUMMARY_PROVIDER_FACTORY =
-            (activity, summaryLoader) -> new PrintSummaryProvider(activity, summaryLoader,
-                    new PrintSummaryProvider.PrintManagerWrapper(activity));
-
     public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
             new BaseSearchIndexProvider() {
 
-        @Override
-        public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
-                boolean enabled) {
-            List<SearchIndexableResource> indexables = new ArrayList<>();
-            SearchIndexableResource indexable = new SearchIndexableResource(context);
-            indexable.xmlResId = R.xml.print_settings;
-            indexables.add(indexable);
-            return indexables;
-        }
-    };
+                @Override
+                public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
+                        boolean enabled) {
+                    List<SearchIndexableResource> indexables = new ArrayList<>();
+                    SearchIndexableResource indexable = new SearchIndexableResource(context);
+                    indexable.xmlResId = R.xml.print_settings;
+                    indexables.add(indexable);
+                    return indexables;
+                }
+            };
 }
diff --git a/src/com/android/settings/search/CursorToSearchResultConverter.java b/src/com/android/settings/search/CursorToSearchResultConverter.java
deleted file mode 100644
index 8e5577d..0000000
--- a/src/com/android/settings/search/CursorToSearchResultConverter.java
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.android.settings.search;
-
-import static com.android.settings.search.DatabaseResultLoader.BASE_RANKS;
-import static com.android.settings.search.SearchResult.TOP_RANK;
-
-import android.content.Context;
-import android.content.pm.PackageManager;
-import android.content.res.Resources;
-import android.database.Cursor;
-import android.graphics.drawable.Drawable;
-import android.os.BadParcelableException;
-import android.text.TextUtils;
-import android.util.Log;
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Controller to Build search results from {@link Cursor} Objects.
- *
- * Each converted {@link Cursor} has the following fields:
- * - String Title
- * - String Summary
- * - int rank
- * - {@link Drawable} icon
- * - {@link ResultPayload} payload
- */
-public class CursorToSearchResultConverter {
-
-    private static final String TAG = "CursorConverter";
-
-    /**
-     * These indices are used to match the columns of the this loader's SELECT statement.
-     * These are not necessarily the same order nor similar coverage as the schema defined in
-     * IndexDatabaseHelper
-     */
-    public static final int COLUMN_INDEX_ID = 0;
-    public static final int COLUMN_INDEX_TITLE = 1;
-    public static final int COLUMN_INDEX_SUMMARY_ON = 2;
-    public static final int COLUMN_INDEX_SUMMARY_OFF = 3;
-    public static final int COLUMN_INDEX_CLASS_NAME = 4;
-    public static final int COLUMN_INDEX_SCREEN_TITLE = 5;
-    public static final int COLUMN_INDEX_ICON = 6;
-    public static final int COLUMN_INDEX_INTENT_ACTION = 7;
-    public static final int COLUMN_INDEX_INTENT_ACTION_TARGET_PACKAGE = 8;
-    public static final int COLUMN_INDEX_INTENT_ACTION_TARGET_CLASS = 9;
-    public static final int COLUMN_INDEX_KEY = 10;
-    public static final int COLUMN_INDEX_PAYLOAD_TYPE = 11;
-    public static final int COLUMN_INDEX_PAYLOAD = 12;
-
-    private final Context mContext;
-
-    private final int LONG_TITLE_LENGTH = 20;
-
-    private static final String[] whiteList = {
-            "main_toggle_wifi",
-            "main_toggle_bluetooth",
-            "main_toggle_bluetooth_obsolete",
-            "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) {
-        mContext = context;
-    }
-
-    public Set<SearchResult> convertCursor(Cursor cursorResults, int baseRank) {
-        if (cursorResults == null) {
-            return null;
-        }
-        final Map<String, Context> contextMap = new HashMap<>();
-        final Set<SearchResult> results = new HashSet<>();
-
-        while (cursorResults.moveToNext()) {
-            SearchResult result = buildSingleSearchResultFromCursor(contextMap, cursorResults,
-                    baseRank);
-            if (result != null) {
-                results.add(result);
-            }
-        }
-        return results;
-    }
-
-    public static ResultPayload getUnmarshalledPayload(byte[] marshalledPayload,
-            int payloadType) {
-        try {
-            switch (payloadType) {
-                case ResultPayload.PayloadType.INTENT:
-                    return ResultPayloadUtils.unmarshall(marshalledPayload,
-                            ResultPayload.CREATOR);
-                case ResultPayload.PayloadType.INLINE_SWITCH:
-                    return ResultPayloadUtils.unmarshall(marshalledPayload,
-                            InlineSwitchPayload.CREATOR);
-                case ResultPayload.PayloadType.INLINE_LIST:
-                    return ResultPayloadUtils.unmarshall(marshalledPayload,
-                            InlineListPayload.CREATOR);
-            }
-        } catch (BadParcelableException e) {
-            Log.w(TAG, "Error creating parcelable: " + e);
-        }
-        return null;
-    }
-
-    private SearchResult buildSingleSearchResultFromCursor(Map<String, Context> contextMap,
-            Cursor cursor, int baseRank) {
-        final int docId = cursor.getInt(COLUMN_INDEX_ID);
-        final String pkgName = cursor.getString(COLUMN_INDEX_INTENT_ACTION_TARGET_PACKAGE);
-        final String title = cursor.getString(COLUMN_INDEX_TITLE);
-        final String summaryOn = cursor.getString(COLUMN_INDEX_SUMMARY_ON);
-        final String className = cursor.getString(COLUMN_INDEX_CLASS_NAME);
-        final String key = cursor.getString(COLUMN_INDEX_KEY);
-        final String iconResStr = cursor.getString(COLUMN_INDEX_ICON);
-        final int payloadType = cursor.getInt(COLUMN_INDEX_PAYLOAD_TYPE);
-        final byte[] marshalledPayload = cursor.getBlob(COLUMN_INDEX_PAYLOAD);
-        final ResultPayload payload = getUnmarshalledPayload(marshalledPayload, payloadType);
-
-        final int rank = getRank(title, baseRank, key);
-
-        final SearchResult.Builder builder = new SearchResult.Builder()
-                .setStableId(docId)
-                .setTitle(title)
-                .setSummary(summaryOn)
-                .setRank(rank)
-                .setIcon(getIconForPackage(contextMap, pkgName, className, iconResStr))
-                .setPayload(payload);
-        return builder.build();
-    }
-
-    private Drawable getIconForPackage(Map<String, Context> contextMap, String pkgName,
-            String className, String iconResStr) {
-        final int iconId = TextUtils.isEmpty(iconResStr)
-                ? 0 : Integer.parseInt(iconResStr);
-        Drawable icon;
-        Context packageContext;
-        if (iconId == 0) {
-            icon = null;
-        } else {
-            if (TextUtils.isEmpty(className) && !TextUtils.isEmpty(pkgName)) {
-                packageContext = contextMap.get(pkgName);
-                if (packageContext == null) {
-                    try {
-                        packageContext = mContext.createPackageContext(pkgName, 0);
-                    } catch (PackageManager.NameNotFoundException e) {
-                        Log.e(TAG, "Cannot create Context for package: " + pkgName);
-                        return null;
-                    }
-                    contextMap.put(pkgName, packageContext);
-                }
-            } else {
-                packageContext = mContext;
-            }
-            try {
-                icon = packageContext.getDrawable(iconId);
-            } catch (Resources.NotFoundException nfe) {
-                icon = null;
-            }
-        }
-        return icon;
-    }
-
-
-    /** Uses the breadcrumbs to determine the offset to the base rank.
-     *  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 is longer than 20
-     *
-     *  If the query matches A, set it to TOP_RANK
-     *  If the query matches B, the offset is 0.
-     *  If the query matches C, the offset is 1
-
-     * @param title of the result.
-     * @param baseRank of the result. Lower if it's a better result.
-     * @return
-     */
-    private int getRank(String title, int baseRank, String key) {
-        // The result can only be prioritized if it is a top ranked result.
-        if (prioritySettings.contains(key) && baseRank < BASE_RANKS[1]) {
-            return TOP_RANK;
-        }
-        if (title.length() > LONG_TITLE_LENGTH) {
-            return baseRank + 1;
-        }
-        return baseRank;
-    }
-}
\ No newline at end of file
diff --git a/src/com/android/settings/search/DatabaseIndexingManager.java b/src/com/android/settings/search/DatabaseIndexingManager.java
index 7b9a635..0c02b67 100644
--- a/src/com/android/settings/search/DatabaseIndexingManager.java
+++ b/src/com/android/settings/search/DatabaseIndexingManager.java
@@ -18,10 +18,10 @@
 package com.android.settings.search;
 
 
-import static com.android.settings.search.CursorToSearchResultConverter.COLUMN_INDEX_ID;
-import static com.android.settings.search.CursorToSearchResultConverter
+import static com.android.settings.search.DatabaseResultLoader.COLUMN_INDEX_ID;
+import static com.android.settings.search.DatabaseResultLoader
         .COLUMN_INDEX_INTENT_ACTION_TARGET_PACKAGE;
-import static com.android.settings.search.CursorToSearchResultConverter.COLUMN_INDEX_KEY;
+import static com.android.settings.search.DatabaseResultLoader.COLUMN_INDEX_KEY;
 import static com.android.settings.search.DatabaseResultLoader.SELECT_COLUMNS;
 import static com.android.settings.search.IndexDatabaseHelper.IndexColumns.CLASS_NAME;
 import static com.android.settings.search.IndexDatabaseHelper.IndexColumns.DATA_ENTRIES;
diff --git a/src/com/android/settings/search/DatabaseResultLoader.java b/src/com/android/settings/search/DatabaseResultLoader.java
index 3b5cc47..7902eef 100644
--- a/src/com/android/settings/search/DatabaseResultLoader.java
+++ b/src/com/android/settings/search/DatabaseResultLoader.java
@@ -43,14 +43,11 @@
     };
 
     /**
-     * Base ranks defines the best possible rank based on what the query matches.
-     * If the query matches the prefix of the first word in the title, the best rank it can be
-     * is 1
-     * If the query matches the prefix of the other words in the title, the best rank it can be
-     * is 3
-     * If the query only matches the summary, the best rank it can be is 7
-     * If the query only matches keywords or entries, the best rank it can be is 9
+     * These indices are used to match the columns of the this loader's SELECT statement.
+     * These are not necessarily the same order nor similar coverage as the schema defined in
+     * IndexDatabaseHelper
      */
-    public static final int[] BASE_RANKS = {1, 3, 7, 9};
-
+    public static final int COLUMN_INDEX_ID = 0;
+    public static final int COLUMN_INDEX_INTENT_ACTION_TARGET_PACKAGE = 8;
+    public static final int COLUMN_INDEX_KEY = 10;
 }
\ No newline at end of file
diff --git a/src/com/android/settings/search/SearchIndexableResourcesImpl.java b/src/com/android/settings/search/SearchIndexableResourcesImpl.java
index bcf412c..55235a4 100644
--- a/src/com/android/settings/search/SearchIndexableResourcesImpl.java
+++ b/src/com/android/settings/search/SearchIndexableResourcesImpl.java
@@ -22,6 +22,7 @@
 import com.android.settings.DisplaySettings;
 import com.android.settings.LegalSettings;
 import com.android.settings.connecteddevice.ConnectedDeviceDashboardFragmentOld;
+import com.android.settings.datausage.DataUsageSummaryLegacy;
 import com.android.settings.deviceinfo.aboutphone.MyDeviceInfoFragment;
 import com.android.settings.accessibility.AccessibilitySettings;
 import com.android.settings.accessibility.AccessibilityShortcutPreferenceFragment;
@@ -50,7 +51,7 @@
 import com.android.settings.display.ScreenZoomSettings;
 import com.android.settings.dream.DreamSettings;
 import com.android.settings.enterprise.EnterprisePrivacySettings;
-import com.android.settings.fuelgauge.BatterySaverSettings;
+import com.android.settings.fuelgauge.batterysaver.BatterySaverSettings;
 import com.android.settings.fuelgauge.PowerUsageAdvanced;
 import com.android.settings.fuelgauge.PowerUsageSummary;
 import com.android.settings.fuelgauge.SmartBatterySettings;
@@ -112,6 +113,7 @@
         addIndex(BluetoothSettings.class);
         addIndex(SimSettings.class);
         addIndex(DataUsageSummary.class);
+        addIndex(DataUsageSummaryLegacy.class);
         addIndex(ScreenZoomSettings.class);
         addIndex(DisplaySettings.class);
         addIndex(AmbientDisplaySettings.class);
diff --git a/src/com/android/settings/search/SearchResult.java b/src/com/android/settings/search/SearchResult.java
deleted file mode 100644
index d96661a..0000000
--- a/src/com/android/settings/search/SearchResult.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.android.settings.search;
-
-import android.graphics.drawable.Drawable;
-import android.text.TextUtils;
-import android.util.Log;
-
-import java.util.List;
-
-/**
- * Data class as an interface for all Search Results.
- */
-public class SearchResult implements Comparable<SearchResult> {
-
-    private static final String TAG = "SearchResult";
-
-    /**
-     * 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 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.
-     * Intent Results: Displays as the primary
-     */
-    public final CharSequence title;
-
-    /**
-     * Summary / subtitle text
-     * Intent Results: Displays the text underneath the title
-     */
-    final public CharSequence summary;
-
-    /**
-     * An ordered list of the information hierarchy.
-     * Intent Results: Displayed a hierarchy of selections to reach the setting from the home screen
-     */
-    public final List<String> breadcrumbs;
-
-    /**
-     * A suggestion for the ranking of the result.
-     * Based on Settings Rank:
-     * 1 is a near perfect match
-     * 9 is the weakest match
-     * TODO subject to change
-     */
-    public final int rank;
-
-    /**
-     * Identifier for the recycler view adapter.
-     */
-    @ResultPayload.PayloadType
-    public final int viewType;
-
-    /**
-     * Metadata for the specific result types.
-     */
-    public final ResultPayload payload;
-
-    /**
-     * Result's icon.
-     */
-    public final Drawable icon;
-
-    /**
-     * Stable id for this object.
-     */
-    public final int stableId;
-
-    protected SearchResult(Builder builder) {
-        stableId = builder.mStableId;
-        title = builder.mTitle;
-        summary = builder.mSummary;
-        breadcrumbs = builder.mBreadcrumbs;
-        rank = builder.mRank;
-        icon = builder.mIcon;
-        payload = builder.mResultPayload;
-        viewType = payload.getType();
-    }
-
-    @Override
-    public int compareTo(SearchResult searchResult) {
-        if (searchResult == null) {
-            return -1;
-        }
-        return this.rank - searchResult.rank;
-    }
-
-    @Override
-    public boolean equals(Object that) {
-        if (this == that) {
-            return true;
-        }
-        if (!(that instanceof SearchResult)) {
-            return false;
-        }
-        return this.stableId == ((SearchResult) that).stableId;
-    }
-
-    @Override
-    public int hashCode() {
-        return stableId;
-    }
-
-    public static class Builder {
-        protected CharSequence mTitle;
-        protected CharSequence mSummary;
-        protected List<String> mBreadcrumbs;
-        protected int mRank = 42;
-        protected ResultPayload mResultPayload;
-        protected Drawable mIcon;
-        protected int mStableId;
-
-        public Builder setTitle(CharSequence title) {
-            mTitle = title;
-            return this;
-        }
-
-        public Builder setSummary(CharSequence summary) {
-            mSummary = summary;
-            return this;
-        }
-
-        public Builder addBreadcrumbs(List<String> breadcrumbs) {
-            mBreadcrumbs = breadcrumbs;
-            return this;
-        }
-
-        public Builder setRank(int rank) {
-            if (rank >= 0 && rank <= 9) {
-                mRank = rank;
-            }
-            return this;
-        }
-
-        public Builder setIcon(Drawable icon) {
-            mIcon = icon;
-            return this;
-        }
-
-        public Builder setPayload(ResultPayload payload) {
-            mResultPayload = payload;
-            return this;
-        }
-
-        public Builder setStableId(int stableId) {
-            mStableId = stableId;
-            return this;
-        }
-
-        public SearchResult build() {
-            // Check that all of the mandatory fields are set.
-            if (TextUtils.isEmpty(mTitle)) {
-                throw new IllegalStateException("SearchResult missing title argument");
-            } else if (mStableId == 0) {
-                Log.v(TAG, "No stable ID on SearchResult with title: " + mTitle);
-                throw new IllegalStateException("SearchResult missing stableId argument");
-            } else if (mResultPayload == null) {
-                throw new IllegalStateException("SearchResult missing Payload argument");
-            }
-            return new SearchResult(this);
-        }
-    }
-}
\ No newline at end of file
diff --git a/src/com/android/settings/search/actionbar/SearchMenuController.java b/src/com/android/settings/search/actionbar/SearchMenuController.java
index f3a9285..1729ccd 100644
--- a/src/com/android/settings/search/actionbar/SearchMenuController.java
+++ b/src/com/android/settings/search/actionbar/SearchMenuController.java
@@ -28,6 +28,7 @@
 import com.android.settings.overlay.FeatureFactory;
 import com.android.settings.search.SearchFeatureProvider;
 import com.android.settingslib.core.lifecycle.LifecycleObserver;
+import com.android.settingslib.core.lifecycle.ObservableFragment;
 import com.android.settingslib.core.lifecycle.ObservablePreferenceFragment;
 import com.android.settingslib.core.lifecycle.events.OnCreateOptionsMenu;
 
@@ -41,6 +42,10 @@
         host.getLifecycle().addObserver(new SearchMenuController(host));
     }
 
+    public static void init(@NonNull ObservableFragment host) {
+        host.getLifecycle().addObserver(new SearchMenuController(host));
+    }
+
     private SearchMenuController(@NonNull Fragment host) {
         mHost = host;
     }
diff --git a/src/com/android/settings/security/VisiblePatternProfilePreferenceController.java b/src/com/android/settings/security/VisiblePatternProfilePreferenceController.java
index a9e56f4..55448e2 100644
--- a/src/com/android/settings/security/VisiblePatternProfilePreferenceController.java
+++ b/src/com/android/settings/security/VisiblePatternProfilePreferenceController.java
@@ -44,6 +44,11 @@
 
     private Preference mPreference;
 
+    public VisiblePatternProfilePreferenceController(Context context) {
+         this(context, null /* lifecycle */);
+    }
+
+    // TODO (b/73074893) Replace this constructor without Lifecycle using setter method instead.
     public VisiblePatternProfilePreferenceController(Context context, Lifecycle lifecycle) {
         super(context, KEY_VISIBLE_PATTERN_PROFILE);
         mUm = (UserManager) context.getSystemService(Context.USER_SERVICE);
diff --git a/src/com/android/settings/security/trustagent/ManageTrustAgentsPreferenceController.java b/src/com/android/settings/security/trustagent/ManageTrustAgentsPreferenceController.java
index 5bb8f75..3e39860 100644
--- a/src/com/android/settings/security/trustagent/ManageTrustAgentsPreferenceController.java
+++ b/src/com/android/settings/security/trustagent/ManageTrustAgentsPreferenceController.java
@@ -20,7 +20,6 @@
 import android.os.UserHandle;
 import android.support.annotation.VisibleForTesting;
 import android.support.v7.preference.Preference;
-import android.support.v7.preference.PreferenceScreen;
 
 import com.android.internal.widget.LockPatternUtils;
 import com.android.settings.R;
@@ -52,21 +51,18 @@
     }
 
     @Override
-    public void displayPreference(PreferenceScreen screen) {
-        super.displayPreference(screen);
-        final Preference preference = screen.findPreference(getPreferenceKey());
-        if (preference == null) {
-            return;
-        }
+    public void updateState(Preference preference) {
         final int numberOfTrustAgent = getTrustAgentCount();
         if (!mLockPatternUtils.isSecure(MY_USER_ID)) {
             preference.setEnabled(false);
             preference.setSummary(R.string.disabled_because_no_backup_security);
         } else if (numberOfTrustAgent > 0) {
+            preference.setEnabled(true);
             preference.setSummary(mContext.getResources().getQuantityString(
                     R.plurals.manage_trust_agents_summary_on,
                     numberOfTrustAgent, numberOfTrustAgent));
         } else {
+            preference.setEnabled(true);
             preference.setSummary(R.string.manage_trust_agents_summary);
         }
     }
diff --git a/src/com/android/settings/support/actionbar/HelpMenuController.java b/src/com/android/settings/support/actionbar/HelpMenuController.java
index a95d44e..1188fc2 100644
--- a/src/com/android/settings/support/actionbar/HelpMenuController.java
+++ b/src/com/android/settings/support/actionbar/HelpMenuController.java
@@ -27,6 +27,7 @@
 
 import com.android.settingslib.HelpUtils;
 import com.android.settingslib.core.lifecycle.LifecycleObserver;
+import com.android.settingslib.core.lifecycle.ObservableFragment;
 import com.android.settingslib.core.lifecycle.ObservablePreferenceFragment;
 import com.android.settingslib.core.lifecycle.events.OnCreateOptionsMenu;
 
@@ -41,6 +42,10 @@
         host.getLifecycle().addObserver(new HelpMenuController(host));
     }
 
+    public static void init(@NonNull ObservableFragment host) {
+        host.getLifecycle().addObserver(new HelpMenuController(host));
+    }
+
     private HelpMenuController(@NonNull Fragment host) {
         mHost = host;
     }
diff --git a/src/com/android/settings/users/AutoSyncWorkDataPreferenceController.java b/src/com/android/settings/users/AutoSyncWorkDataPreferenceController.java
index 1970195..5e8ad2c 100644
--- a/src/com/android/settings/users/AutoSyncWorkDataPreferenceController.java
+++ b/src/com/android/settings/users/AutoSyncWorkDataPreferenceController.java
@@ -17,6 +17,7 @@
 
 import android.app.Fragment;
 import android.content.Context;
+import android.os.UserHandle;
 
 import com.android.settings.Utils;
 
@@ -34,4 +35,10 @@
     public String getPreferenceKey() {
         return KEY_AUTO_SYNC_WORK_ACCOUNT;
     }
+
+    @Override
+    public boolean isAvailable() {
+        return mUserHandle != null && !mUserManager.isManagedProfile() && !mUserManager.isLinkedUser()
+                && mUserManager.getProfiles(UserHandle.myUserId()).size() > 1;
+    }
 }
diff --git a/src/com/android/settings/wallpaper/WallpaperSuggestionActivity.java b/src/com/android/settings/wallpaper/WallpaperSuggestionActivity.java
index 77142ed..8d798b1 100644
--- a/src/com/android/settings/wallpaper/WallpaperSuggestionActivity.java
+++ b/src/com/android/settings/wallpaper/WallpaperSuggestionActivity.java
@@ -59,7 +59,8 @@
     @VisibleForTesting
     public static boolean isSuggestionComplete(Context context) {
         final WallpaperManagerWrapper manager = new WallpaperManagerWrapper(context);
-        return manager.getWallpaperId(WallpaperManager.FLAG_SYSTEM) > 0;
+        return manager.isWallpaperServiceEnabled() ? manager.getWallpaperId(
+                WallpaperManager.FLAG_SYSTEM) > 0 : false;
     }
 
 }
diff --git a/src/com/android/settings/widget/MasterCheckBoxPreference.java b/src/com/android/settings/widget/MasterCheckBoxPreference.java
index 552f51c..fceeac2 100644
--- a/src/com/android/settings/widget/MasterCheckBoxPreference.java
+++ b/src/com/android/settings/widget/MasterCheckBoxPreference.java
@@ -83,6 +83,7 @@
         if (mCheckBox != null) {
             mCheckBox.setContentDescription(getTitle());
             mCheckBox.setChecked(mChecked);
+            mCheckBox.setEnabled(mEnableCheckBox);
         }
     }
 
diff --git a/src/com/android/settings/widget/SeekBarPreference.java b/src/com/android/settings/widget/SeekBarPreference.java
index ee7d4b8..5af21b3 100644
--- a/src/com/android/settings/widget/SeekBarPreference.java
+++ b/src/com/android/settings/widget/SeekBarPreference.java
@@ -40,6 +40,7 @@
 
     private int mProgress;
     private int mMax;
+    private int mMin;
     private boolean mTrackingTouch;
 
     private boolean mContinuousUpdates;
@@ -55,6 +56,7 @@
         TypedArray a = context.obtainStyledAttributes(
                 attrs, com.android.internal.R.styleable.ProgressBar, defStyleAttr, defStyleRes);
         setMax(a.getInt(com.android.internal.R.styleable.ProgressBar_max, mMax));
+        setMin(a.getInt(com.android.internal.R.styleable.ProgressBar_min, mMin));
         a.recycle();
 
         a = context.obtainStyledAttributes(attrs,
@@ -94,6 +96,7 @@
                 com.android.internal.R.id.seekbar);
         mSeekBar.setOnSeekBarChangeListener(this);
         mSeekBar.setMax(mMax);
+        mSeekBar.setMin(mMin);
         mSeekBar.setProgress(mProgress);
         mSeekBar.setEnabled(isEnabled());
         final CharSequence title = getTitle();
@@ -154,10 +157,21 @@
         }
     }
 
+    public void setMin(int min) {
+        if (min != mMin) {
+            mMin = min;
+            notifyChanged();
+        }
+    }
+
     public int getMax() {
         return mMax;
     }
 
+    public int getMin() {
+        return mMin;
+    }
+
     public void setProgress(int progress) {
         setProgress(progress, true);
     }
@@ -187,8 +201,8 @@
         if (progress > mMax) {
             progress = mMax;
         }
-        if (progress < 0) {
-            progress = 0;
+        if (progress < mMin) {
+            progress = mMin;
         }
         if (progress != mProgress) {
             mProgress = progress;
@@ -257,6 +271,7 @@
         final SavedState myState = new SavedState(superState);
         myState.progress = mProgress;
         myState.max = mMax;
+        myState.min = mMin;
         return myState;
     }
 
@@ -273,6 +288,7 @@
         super.onRestoreInstanceState(myState.getSuperState());
         mProgress = myState.progress;
         mMax = myState.max;
+        mMin = myState.min;
         notifyChanged();
     }
 
@@ -285,6 +301,7 @@
     private static class SavedState extends BaseSavedState {
         int progress;
         int max;
+        int min;
 
         public SavedState(Parcel source) {
             super(source);
@@ -292,6 +309,7 @@
             // Restore the click counter
             progress = source.readInt();
             max = source.readInt();
+            min = source.readInt();
         }
 
         @Override
@@ -301,6 +319,7 @@
             // Save the click counter
             dest.writeInt(progress);
             dest.writeInt(max);
+            dest.writeInt(min);
         }
 
         public SavedState(Parcelable superState) {
diff --git a/src/com/android/settings/widget/TwoStateButtonPreference.java b/src/com/android/settings/widget/TwoStateButtonPreference.java
new file mode 100644
index 0000000..6b5fbbb
--- /dev/null
+++ b/src/com/android/settings/widget/TwoStateButtonPreference.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.widget;
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.support.v4.content.res.TypedArrayUtils;
+import android.util.AttributeSet;
+import android.widget.Button;
+
+import com.android.settings.R;
+import com.android.settings.applications.LayoutPreference;
+
+/**
+ * Preference that presents a button with two states(On vs Off)
+ */
+public class TwoStateButtonPreference extends LayoutPreference {
+    public TwoStateButtonPreference(Context context, AttributeSet attrs) {
+        super(context, attrs, TypedArrayUtils.getAttr(
+                context, R.attr.twoStateButtonPreferenceStyle, android.R.attr.preferenceStyle));
+
+        if (attrs != null) {
+            final TypedArray styledAttrs = context.obtainStyledAttributes(attrs,
+                    R.styleable.TwoStateButtonPreference);
+            final int textOnId = styledAttrs.getResourceId(
+                    R.styleable.TwoStateButtonPreference_textOn,
+                    R.string.summary_placeholder);
+            final int textOffId = styledAttrs.getResourceId(
+                    R.styleable.TwoStateButtonPreference_textOff,
+                    R.string.summary_placeholder);
+            styledAttrs.recycle();
+
+            final Button buttonOn = getStateOnButton();
+            buttonOn.setText(textOnId);
+            final Button buttonOff = getStateOffButton();
+            buttonOff.setText(textOffId);
+        }
+    }
+
+    public Button getStateOnButton() {
+        return findViewById(R.id.state_on_button);
+    }
+
+
+    public Button getStateOffButton() {
+        return findViewById(R.id.state_off_button);
+    }
+}
\ No newline at end of file
diff --git a/src/com/android/settings/widget/TwoStateButtonPreferenceController.java b/src/com/android/settings/widget/TwoStateButtonPreferenceController.java
new file mode 100644
index 0000000..47699ef
--- /dev/null
+++ b/src/com/android/settings/widget/TwoStateButtonPreferenceController.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.widget;
+
+import android.content.Context;
+import android.support.v7.preference.PreferenceScreen;
+import android.view.View;
+import android.widget.Button;
+
+import com.android.settings.R;
+import com.android.settings.core.BasePreferenceController;
+
+/**
+ * Controller to update the button with two states(On vs Off).
+ */
+public abstract class TwoStateButtonPreferenceController extends BasePreferenceController
+        implements View.OnClickListener {
+    private Button mButtonOn;
+    private Button mButtonOff;
+
+    public TwoStateButtonPreferenceController(Context context, String key) {
+        super(context, key);
+    }
+
+    @Override
+    public void displayPreference(PreferenceScreen screen) {
+        super.displayPreference(screen);
+        final TwoStateButtonPreference preference =
+                (TwoStateButtonPreference) screen.findPreference(getPreferenceKey());
+        mButtonOn = preference.getStateOnButton();
+        mButtonOn.setOnClickListener(this);
+        mButtonOff = preference.getStateOffButton();
+        mButtonOff.setOnClickListener(this);
+    }
+
+    protected void setButtonVisibility(boolean stateOn) {
+        if (stateOn) {
+            mButtonOff.setVisibility(View.GONE);
+            mButtonOn.setVisibility(View.VISIBLE);
+        } else {
+            mButtonOff.setVisibility(View.VISIBLE);
+            mButtonOn.setVisibility(View.GONE);
+        }
+    }
+
+    protected void setButtonEnabled(boolean enabled) {
+        mButtonOn.setEnabled(enabled);
+        mButtonOff.setEnabled(enabled);
+    }
+
+    @Override
+    public void onClick(View v) {
+        final boolean stateOn = v.getId() == R.id.state_on_button;
+        onButtonClicked(stateOn);
+    }
+
+    /**
+     * Callback when button is clicked
+     *
+     * @param stateOn {@code true} if stateOn button is clicked, otherwise it means stateOff
+     *                button is clicked
+     */
+    public abstract void onButtonClicked(boolean stateOn);
+}
\ No newline at end of file
diff --git a/src/com/android/settings/wifi/ConfigureWifiSettings.java b/src/com/android/settings/wifi/ConfigureWifiSettings.java
index b359bf3..1607b74 100644
--- a/src/com/android/settings/wifi/ConfigureWifiSettings.java
+++ b/src/com/android/settings/wifi/ConfigureWifiSettings.java
@@ -92,8 +92,6 @@
         controllers.add(new WifiInfoPreferenceController(context, getLifecycle(), wifiManager));
         controllers.add(new CellularFallbackPreferenceController(context));
         controllers.add(new WifiP2pPreferenceController(context, getLifecycle(), wifiManager));
-        controllers.add(new WpsPreferenceController(
-                context, getLifecycle(), wifiManager, getFragmentManager()));
         return controllers;
     }
 
diff --git a/src/com/android/settings/wifi/ConnectedAccessPointPreference.java b/src/com/android/settings/wifi/ConnectedAccessPointPreference.java
index 6b9c788..514525c 100644
--- a/src/com/android/settings/wifi/ConnectedAccessPointPreference.java
+++ b/src/com/android/settings/wifi/ConnectedAccessPointPreference.java
@@ -36,6 +36,7 @@
     public ConnectedAccessPointPreference(AccessPoint accessPoint, Context context,
             UserBadgeCache cache, @DrawableRes int iconResId, boolean forSavedNetworks) {
         super(accessPoint, context, cache, iconResId, forSavedNetworks);
+        setWidgetLayoutResource(R.layout.preference_widget_gear_no_bg);
     }
 
     public void setOnGearClickListener(OnGearClickListener l) {
@@ -44,26 +45,6 @@
     }
 
     @Override
-    protected int getSecondTargetResId() {
-        return R.layout.preference_widget_gear;
-    }
-
-    @Override
-    protected boolean shouldHideSecondTarget() {
-        return mOnGearClickListener == null;
-    }
-
-    @Override
-    public void onBindViewHolder(PreferenceViewHolder holder) {
-        super.onBindViewHolder(holder);
-        final View gear = holder.findViewById(R.id.settings_button);
-        if (gear != null) {
-            gear.setOnClickListener(this);
-        }
-        setDividerVisibility(holder, View.VISIBLE);
-    }
-
-    @Override
     public void onClick(View v) {
         if (v.getId() == R.id.settings_button) {
             if (mOnGearClickListener != null) {
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index 22f8c43..69dc130 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -85,16 +85,12 @@
 
     private static final String TAG = "WifiSettings";
 
-    /* package */ static final int MENU_ID_WPS_PBC = Menu.FIRST;
-    private static final int MENU_ID_WPS_PIN = Menu.FIRST + 1;
     private static final int MENU_ID_CONNECT = Menu.FIRST + 6;
     private static final int MENU_ID_FORGET = Menu.FIRST + 7;
     private static final int MENU_ID_MODIFY = Menu.FIRST + 8;
     private static final int MENU_ID_WRITE_NFC = Menu.FIRST + 9;
 
     public static final int WIFI_DIALOG_ID = 1;
-    /* package */ static final int WPS_PBC_DIALOG_ID = 2;
-    private static final int WPS_PIN_DIALOG_ID = 3;
     private static final int WRITE_NFC_DIALOG_ID = 6;
 
     // Instance state keys
@@ -109,6 +105,10 @@
     private static final String PREF_KEY_CONFIGURE_WIFI_SETTINGS = "configure_settings";
     private static final String PREF_KEY_SAVED_NETWORKS = "saved_networks";
 
+    private static boolean isVerboseLoggingEnabled() {
+        return WifiTracker.sVerboseLogging || Log.isLoggable(TAG, Log.VERBOSE);
+    }
+
     private final Runnable mUpdateAccessPointsRunnable = () -> {
         updateAccessPointPreferences();
     };
@@ -371,7 +371,7 @@
         }
         setProgressBarVisible(true);
         mWifiTracker.forceUpdate();
-        if (WifiTracker.sVerboseLogging) {
+        if (isVerboseLoggingEnabled()) {
             Log.i(TAG, "WifiSettings force update APs: " + mWifiTracker.getAccessPoints());
         }
         getView().removeCallbacks(mUpdateAccessPointsRunnable);
@@ -460,24 +460,6 @@
     }
 
     @Override
-    public boolean onOptionsItemSelected(MenuItem item) {
-        // If the user is not allowed to configure wifi, do not handle menu selections.
-        if (mIsRestricted) {
-            return false;
-        }
-
-        switch (item.getItemId()) {
-            case MENU_ID_WPS_PBC:
-                showDialog(WPS_PBC_DIALOG_ID);
-                return true;
-            case MENU_ID_WPS_PIN:
-                showDialog(WPS_PIN_DIALOG_ID);
-                return true;
-        }
-        return super.onOptionsItemSelected(item);
-    }
-
-    @Override
     public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo info) {
             Preference preference = (Preference) view.getTag();
 
@@ -635,10 +617,6 @@
 
                 mSelectedAccessPoint = mDlgAccessPoint;
                 return mDialog;
-            case WPS_PBC_DIALOG_ID:
-                return new WpsDialog(getActivity(), WpsInfo.PBC);
-            case WPS_PIN_DIALOG_ID:
-                return new WpsDialog(getActivity(), WpsInfo.DISPLAY);
             case WRITE_NFC_DIALOG_ID:
                 if (mSelectedAccessPoint != null) {
                     mWifiToNfcDialog = new WriteWifiConfigToNfcDialog(
@@ -660,10 +638,6 @@
         switch (dialogId) {
             case WIFI_DIALOG_ID:
                 return MetricsEvent.DIALOG_WIFI_AP_EDIT;
-            case WPS_PBC_DIALOG_ID:
-                return MetricsEvent.DIALOG_WIFI_PBC;
-            case WPS_PIN_DIALOG_ID:
-                return MetricsEvent.DIALOG_WIFI_PIN;
             case WRITE_NFC_DIALOG_ID:
                 return MetricsEvent.DIALOG_WIFI_WRITE_NFC;
             default:
@@ -762,7 +736,7 @@
         }
         // AccessPoints are sorted by the WifiTracker
         final List<AccessPoint> accessPoints = mWifiTracker.getAccessPoints();
-        if (WifiTracker.sVerboseLogging) {
+        if (isVerboseLoggingEnabled()) {
             Log.i(TAG, "updateAccessPoints called for: " + accessPoints);
         }
 
@@ -884,13 +858,14 @@
                 connectedAp);
 
         // Launch details page on click.
-        pref.setOnGearClickListener(l -> {
+        pref.setOnPreferenceClickListener(preference -> {
             pref.getAccessPoint().saveWifiState(pref.getExtras());
 
             SettingsActivity activity = (SettingsActivity) WifiSettings.this.getActivity();
             activity.startPreferencePanel(this,
                     WifiNetworkDetailsFragment.class.getName(), pref.getExtras(),
                     -1 /* resId */, pref.getTitle(), null, 0 /* resultRequestCode */);
+            return true;
         });
 
         pref.refresh();
diff --git a/src/com/android/settings/wifi/WpsDialog.java b/src/com/android/settings/wifi/WpsDialog.java
deleted file mode 100644
index 440b72d..0000000
--- a/src/com/android/settings/wifi/WpsDialog.java
+++ /dev/null
@@ -1,297 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.settings.wifi;
-
-import android.app.AlertDialog;
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.net.NetworkInfo;
-import android.net.NetworkInfo.DetailedState;
-import android.net.wifi.WifiInfo;
-import android.net.wifi.WifiManager;
-import android.net.wifi.WpsInfo;
-import android.os.Bundle;
-import android.os.Handler;
-import android.view.View;
-import android.widget.Button;
-import android.widget.ProgressBar;
-import android.widget.TextView;
-
-import com.android.settings.R;
-
-import java.util.Timer;
-import java.util.TimerTask;
-
-
-/**
- * Dialog to show WPS progress.
- */
-public class WpsDialog extends AlertDialog {
-
-    private final static String TAG = "WpsDialog";
-    private static final String DIALOG_STATE = "android:dialogState";
-    private static final String DIALOG_MSG_STRING = "android:dialogMsg";
-
-    private View mView;
-    private TextView mTextView;
-    private ProgressBar mTimeoutBar;
-    private ProgressBar mProgressBar;
-    private Button mButton;
-    private Timer mTimer;
-
-    private static final int WPS_TIMEOUT_S = 120;
-
-    private WifiManager mWifiManager;
-    private WifiManager.WpsCallback mWpsListener;
-    private int mWpsSetup;
-
-    private final IntentFilter mFilter;
-    private BroadcastReceiver mReceiver;
-
-    private Context mContext;
-    private Handler mHandler = new Handler();
-    private String mMsgString = "";
-
-    private enum DialogState {
-        WPS_INIT,
-        WPS_START,
-        WPS_COMPLETE,
-        CONNECTED, //WPS + IP config is done
-        WPS_FAILED
-    }
-    DialogState mDialogState = DialogState.WPS_INIT;
-
-    public WpsDialog(Context context, int wpsSetup) {
-        super(context);
-        mContext = context;
-        mWpsSetup = wpsSetup;
-
-        class WpsListener extends WifiManager.WpsCallback {
-
-            public void onStarted(String pin) {
-                if (pin != null) {
-                    updateDialog(DialogState.WPS_START, String.format(
-                            mContext.getString(R.string.wifi_wps_onstart_pin), pin));
-                } else {
-                    updateDialog(DialogState.WPS_START, mContext.getString(
-                            R.string.wifi_wps_onstart_pbc));
-                }
-            }
-
-            public void onSucceeded() {
-                updateDialog(DialogState.WPS_COMPLETE,
-                        mContext.getString(R.string.wifi_wps_complete));
-            }
-
-            public void onFailed(int reason) {
-                String msg;
-                switch (reason) {
-                    case WifiManager.WPS_OVERLAP_ERROR:
-                        msg = mContext.getString(R.string.wifi_wps_failed_overlap);
-                        break;
-                    case WifiManager.WPS_WEP_PROHIBITED:
-                        msg = mContext.getString(R.string.wifi_wps_failed_wep);
-                        break;
-                    case WifiManager.WPS_TKIP_ONLY_PROHIBITED:
-                        msg = mContext.getString(R.string.wifi_wps_failed_tkip);
-                        break;
-                    case WifiManager.IN_PROGRESS:
-                        msg = mContext.getString(R.string.wifi_wps_in_progress);
-                        break;
-                    default:
-                        msg = mContext.getString(R.string.wifi_wps_failed_generic);
-                        break;
-                }
-                updateDialog(DialogState.WPS_FAILED, msg);
-            }
-        }
-
-        mWpsListener = new WpsListener();
-
-
-        mFilter = new IntentFilter();
-        mFilter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);
-        mFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
-        mReceiver = new BroadcastReceiver() {
-            @Override
-            public void onReceive(Context context, Intent intent) {
-                handleEvent(context, intent);
-            }
-        };
-        setCanceledOnTouchOutside(false);
-    }
-
-    @Override
-    public Bundle onSaveInstanceState () {
-        Bundle bundle  = super.onSaveInstanceState();
-        bundle.putString(DIALOG_STATE, mDialogState.toString());
-        bundle.putString(DIALOG_MSG_STRING, mMsgString.toString());
-        return bundle;
-    }
-
-    @Override
-    public void onRestoreInstanceState(Bundle savedInstanceState) {
-        if (savedInstanceState != null) {
-            super.onRestoreInstanceState(savedInstanceState);
-            DialogState dialogState = mDialogState.valueOf(savedInstanceState.getString(DIALOG_STATE));
-            String msg = savedInstanceState.getString(DIALOG_MSG_STRING);
-            updateDialog(dialogState, msg);
-            if (dialogState == DialogState.WPS_START) {
-                startWps();
-            }
-        }
-    }
-
-    @Override
-    protected void onCreate(Bundle savedInstanceState) {
-        mView = getLayoutInflater().inflate(R.layout.wifi_wps_dialog, null);
-
-        mTextView = (TextView) mView.findViewById(R.id.wps_dialog_txt);
-        mTextView.setText(R.string.wifi_wps_setup_msg);
-
-        mTimeoutBar = ((ProgressBar) mView.findViewById(R.id.wps_timeout_bar));
-        mTimeoutBar.setMax(WPS_TIMEOUT_S);
-        mTimeoutBar.setProgress(0);
-
-        mProgressBar = ((ProgressBar) mView.findViewById(R.id.wps_progress_bar));
-        mProgressBar.setVisibility(View.GONE);
-
-        mButton = ((Button) mView.findViewById(R.id.wps_dialog_btn));
-        mButton.setText(R.string.wifi_cancel);
-        mButton.setOnClickListener(new View.OnClickListener() {
-            @Override
-            public void onClick(View v) {
-                dismiss();
-            }
-        });
-
-        mWifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
-
-        setView(mView);
-        if (savedInstanceState == null) {
-            startWps();
-        }
-        super.onCreate(savedInstanceState);
-    }
-
-    @Override
-    protected void onStart() {
-        /*
-         * increment timeout bar per second.
-         */
-        mTimer = new Timer(false);
-        mTimer.schedule(new TimerTask() {
-            @Override
-            public void run() {
-                mHandler.post(new Runnable() {
-
-                    @Override
-                    public void run() {
-                        mTimeoutBar.incrementProgressBy(1);
-                    }
-                });
-            }
-        }, 1000, 1000);
-
-        mContext.registerReceiver(mReceiver, mFilter);
-
-    }
-
-    @Override
-    protected void onStop() {
-        if (mDialogState != DialogState.WPS_COMPLETE) {
-            mWifiManager.cancelWps(null);
-        }
-
-        if (mReceiver != null) {
-            mContext.unregisterReceiver(mReceiver);
-            mReceiver = null;
-        }
-
-        if (mTimer != null) {
-            mTimer.cancel();
-        }
-    }
-
-    private void updateDialog(final DialogState state, final String msg) {
-        if (mDialogState.ordinal() >= state.ordinal()) {
-            //ignore.
-            return;
-        }
-        mDialogState = state;
-        mMsgString = msg;
-
-        mHandler.post(new Runnable() {
-                @Override
-                public void run() {
-                    switch(state) {
-                        case WPS_COMPLETE:
-                            mTimeoutBar.setVisibility(View.GONE);
-                            mProgressBar.setVisibility(View.VISIBLE);
-                            break;
-                        case CONNECTED:
-                        case WPS_FAILED:
-                            mButton.setText(mContext.getString(R.string.dlg_ok));
-                            mTimeoutBar.setVisibility(View.GONE);
-                            mProgressBar.setVisibility(View.GONE);
-                            if (mReceiver != null) {
-                                mContext.unregisterReceiver(mReceiver);
-                                mReceiver = null;
-                            }
-                            break;
-                    }
-                    mTextView.setText(msg);
-                }
-            });
-   }
-
-    private void handleEvent(Context context, Intent intent) {
-        String action = intent.getAction();
-        if (WifiManager.WIFI_STATE_CHANGED_ACTION.equals(action)) {
-            final int state = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE,
-                    WifiManager.WIFI_STATE_UNKNOWN);
-            if (state == WifiManager.WIFI_STATE_DISABLED) {
-                if (mTimer != null) {
-                    mTimer.cancel();
-                    mTimer = null;
-                }
-                String msg = mContext.getString(R.string.wifi_wps_failed_wifi_disconnected);
-                updateDialog(DialogState.WPS_FAILED, msg);
-            }
-        } else if (WifiManager.NETWORK_STATE_CHANGED_ACTION.equals(action)) {
-            NetworkInfo info = (NetworkInfo) intent.getParcelableExtra(
-                    WifiManager.EXTRA_NETWORK_INFO);
-            final NetworkInfo.DetailedState state = info.getDetailedState();
-            if (state == DetailedState.CONNECTED &&
-                    mDialogState == DialogState.WPS_COMPLETE) {
-                WifiInfo wifiInfo = mWifiManager.getConnectionInfo();
-                if (wifiInfo != null) {
-                    String msg = String.format(mContext.getString(
-                            R.string.wifi_wps_connected), wifiInfo.getSSID());
-                    updateDialog(DialogState.CONNECTED, msg);
-                }
-            }
-        }
-    }
-
-    private void startWps() {
-        WpsInfo wpsConfig = new WpsInfo();
-        wpsConfig.setup = mWpsSetup;
-        mWifiManager.startWps(wpsConfig, mWpsListener);
-    }
-}
diff --git a/src/com/android/settings/wifi/WpsPreferenceController.java b/src/com/android/settings/wifi/WpsPreferenceController.java
deleted file mode 100644
index f636593..0000000
--- a/src/com/android/settings/wifi/WpsPreferenceController.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.settings.wifi;
-
-import android.app.Dialog;
-import android.app.FragmentManager;
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.net.wifi.WifiManager;
-import android.net.wifi.WpsInfo;
-import android.os.Bundle;
-import android.support.annotation.VisibleForTesting;
-import android.support.v7.preference.Preference;
-import android.support.v7.preference.PreferenceScreen;
-
-import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.settings.core.PreferenceControllerMixin;
-import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
-import com.android.settingslib.core.AbstractPreferenceController;
-import com.android.settingslib.core.lifecycle.Lifecycle;
-import com.android.settingslib.core.lifecycle.LifecycleObserver;
-import com.android.settingslib.core.lifecycle.events.OnPause;
-import com.android.settingslib.core.lifecycle.events.OnResume;
-
-/**
- * {@link PreferenceControllerMixin} that shows Dialog for WPS progress. Disabled when Wi-Fi is off.
- */
-public class WpsPreferenceController extends AbstractPreferenceController
-        implements PreferenceControllerMixin, LifecycleObserver, OnPause, OnResume {
-
-    private static final String KEY_WPS_PUSH = "wps_push_button";
-    private static final String KEY_WPS_PIN = "wps_pin_entry";
-
-    private final WifiManager mWifiManager;
-    private final FragmentManager mFragmentManager;
-    @VisibleForTesting
-    final BroadcastReceiver mReceiver = new BroadcastReceiver() {
-        @Override
-        public void onReceive(Context context, Intent intent) {
-            togglePreferences();
-        }
-    };
-    private final IntentFilter mFilter = new IntentFilter(WifiManager.WIFI_STATE_CHANGED_ACTION);
-
-    private Preference mWpsPushPref;
-    private Preference mWpsPinPref;
-
-    public WpsPreferenceController(
-            Context context,
-            Lifecycle lifecycle,
-            WifiManager wifiManager,
-            FragmentManager fragmentManager) {
-        super(context);
-        mWifiManager = wifiManager;
-        mFragmentManager = fragmentManager;
-        lifecycle.addObserver(this);
-    }
-
-    @Override
-    public boolean isAvailable() {
-        // Always show preference.
-        return true;
-    }
-
-    @Override
-    public String getPreferenceKey() {
-        // Returns null because this controller contains more than 1 preference.
-        return null;
-    }
-
-    @Override
-    public void displayPreference(PreferenceScreen screen) {
-        super.displayPreference(screen);
-        mWpsPushPref = screen.findPreference(KEY_WPS_PUSH);
-        mWpsPinPref = screen.findPreference(KEY_WPS_PIN);
-        if (mWpsPushPref == null || mWpsPinPref == null) {
-            return;
-        }
-        // WpsDialog: Create the dialog like WifiSettings does.
-        mWpsPushPref.setOnPreferenceClickListener((arg) -> {
-                    WpsFragment wpsFragment = new WpsFragment(WpsInfo.PBC);
-                    wpsFragment.show(mFragmentManager, KEY_WPS_PUSH);
-                    return true;
-                }
-        );
-
-        // WpsDialog: Create the dialog like WifiSettings does.
-        mWpsPinPref.setOnPreferenceClickListener((arg) -> {
-            WpsFragment wpsFragment = new WpsFragment(WpsInfo.DISPLAY);
-            wpsFragment.show(mFragmentManager, KEY_WPS_PIN);
-            return true;
-        });
-        togglePreferences();
-    }
-
-    @Override
-    public void onResume() {
-        mContext.registerReceiver(mReceiver, mFilter);
-    }
-
-    @Override
-    public void onPause() {
-        mContext.unregisterReceiver(mReceiver);
-    }
-
-    private void togglePreferences() {
-        if (mWpsPushPref != null && mWpsPinPref != null) {
-            boolean enabled = mWifiManager.isWifiEnabled();
-            mWpsPushPref.setEnabled(enabled);
-            mWpsPinPref.setEnabled(enabled);
-        }
-    }
-
-    /**
-     * Fragment for Dialog to show WPS progress.
-     */
-    public static class WpsFragment extends InstrumentedDialogFragment {
-        private static int mWpsSetup;
-
-        // Public default constructor is required for rotation.
-        public WpsFragment() {
-            super();
-        }
-
-        public WpsFragment(int wpsSetup) {
-            super();
-            mWpsSetup = wpsSetup;
-        }
-
-        @Override
-        public int getMetricsCategory() {
-            return MetricsEvent.DIALOG_WPS_SETUP;
-        }
-
-        @Override
-        public Dialog onCreateDialog(Bundle savedInstanceState) {
-            return new WpsDialog(getActivity(), mWpsSetup);
-        }
-    }
-}
diff --git a/src/com/android/settings/WifiCallingSettings.java b/src/com/android/settings/wifi/calling/WifiCallingSettings.java
similarity index 80%
rename from src/com/android/settings/WifiCallingSettings.java
rename to src/com/android/settings/wifi/calling/WifiCallingSettings.java
index e872fb8..7bab07a 100644
--- a/src/com/android/settings/WifiCallingSettings.java
+++ b/src/com/android/settings/wifi/calling/WifiCallingSettings.java
@@ -14,11 +14,10 @@
  * limitations under the License.
  */
 
-package com.android.settings;
+package com.android.settings.wifi.calling;
 
 import android.app.Fragment;
 import android.app.FragmentManager;
-import android.content.Context;
 import android.os.Bundle;
 import android.support.v13.app.FragmentPagerAdapter;
 import android.telephony.SubscriptionInfo;
@@ -28,9 +27,13 @@
 import android.view.View;
 import android.view.ViewGroup;
 
-import com.android.ims.ImsConfig;
 import com.android.ims.ImsManager;
 import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+import com.android.settings.R;
+import com.android.settings.core.InstrumentedFragment;
+import com.android.settings.search.actionbar.SearchMenuController;
+import com.android.settings.support.actionbar.HelpMenuController;
+import com.android.settings.support.actionbar.HelpResourceProvider;
 import com.android.settings.widget.RtlCompatibleViewPager;
 import com.android.settings.widget.SlidingTabLayout;
 
@@ -40,7 +43,7 @@
  * "Wi-Fi Calling settings" screen. This is the container fragment which holds
  * {@link WifiCallingSettingsForSub} fragments.
  */
-public class WifiCallingSettings extends SettingsPreferenceFragment {
+public class WifiCallingSettings extends InstrumentedFragment implements HelpResourceProvider {
     private static final String TAG = "WifiCallingSettings";
     private List<SubscriptionInfo> mSil;
 
@@ -71,6 +74,10 @@
     @Override
     public void onCreate(Bundle icicle) {
         super.onCreate(icicle);
+        setHasOptionsMenu(true);
+        SearchMenuController.init(this /* host */);
+        HelpMenuController.init(this /* host */);
+
         // TODO: besides in onCreate, we should also update subList when SIM / Sub status
         // changes.
         updateSubList();
@@ -87,6 +94,11 @@
         }
     }
 
+    @Override
+    public int getHelpResource() {
+        return R.string.help_uri_wifi_calling;
+    }
+
     private final class WifiCallingViewPagerAdapter extends FragmentPagerAdapter {
         private final RtlCompatibleViewPager mViewPager;
 
@@ -105,6 +117,7 @@
         public Fragment getItem(int position) {
             Log.d(TAG, "Adapter getItem " + position);
             final Bundle args = new Bundle();
+            args.putBoolean(SearchMenuController.NEED_SEARCH_ICON_IN_ACTION_BAR, false);
             args.putInt(WifiCallingSettingsForSub.FRAGMENT_BUNDLE_SUBID,
                     mSil.get(position).getSubscriptionId());
             WifiCallingSettingsForSub fragment = new WifiCallingSettingsForSub();
@@ -132,26 +145,6 @@
         }
     }
 
-    public static int getWfcModeSummary(Context context, int wfcMode) {
-        int resId = com.android.internal.R.string.wifi_calling_off_summary;
-        if (ImsManager.isWfcEnabledByUser(context)) {
-            switch (wfcMode) {
-                case ImsConfig.WfcModeFeatureValueConstants.WIFI_ONLY:
-                    resId = com.android.internal.R.string.wfc_mode_wifi_only_summary;
-                    break;
-                case ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED:
-                    resId = com.android.internal.R.string.wfc_mode_cellular_preferred_summary;
-                    break;
-                case ImsConfig.WfcModeFeatureValueConstants.WIFI_PREFERRED:
-                    resId = com.android.internal.R.string.wfc_mode_wifi_preferred_summary;
-                    break;
-                default:
-                    Log.e(TAG, "Unexpected WFC mode value: " + wfcMode);
-            }
-        }
-        return resId;
-    }
-
     private void updateSubList() {
         mSil = SubscriptionManager.from(getActivity()).getActiveSubscriptionInfoList();
 
@@ -159,7 +152,7 @@
         if (mSil == null) {
             return;
         }
-        for (int i = 0; i < mSil.size();) {
+        for (int i = 0; i < mSil.size(); ) {
             ImsManager imsManager = ImsManager.getInstance(getActivity(),
                     mSil.get(i).getSimSlotIndex());
             if (!imsManager.isWfcEnabledByPlatform()) {
diff --git a/src/com/android/settings/WifiCallingSettingsForSub.java b/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java
similarity index 98%
rename from src/com/android/settings/WifiCallingSettingsForSub.java
rename to src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java
index ba5ba84..2bfd796 100644
--- a/src/com/android/settings/WifiCallingSettingsForSub.java
+++ b/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.settings;
+package com.android.settings.wifi.calling;
 
 import android.app.Activity;
 import android.app.AlertDialog;
@@ -45,6 +45,10 @@
 import com.android.ims.ImsManager;
 import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
 import com.android.internal.telephony.Phone;
+import com.android.settings.R;
+import com.android.settings.SettingsActivity;
+import com.android.settings.SettingsPreferenceFragment;
+import com.android.settings.Utils;
 import com.android.settings.widget.SwitchBar;
 
 /**
@@ -54,7 +58,7 @@
 public class WifiCallingSettingsForSub extends SettingsPreferenceFragment
         implements SwitchBar.OnSwitchChangeListener,
         Preference.OnPreferenceChangeListener {
-    private static final String TAG = "WifiCallingSettingsForSub";
+    private static final String TAG = "WifiCallingForSub";
 
     //String keys for preference lookup
     private static final String BUTTON_WFC_MODE = "wifi_calling_mode";
@@ -130,12 +134,6 @@
         }
     };
 
-    @Override
-    public int getHelpResource() {
-        // Helper resource is already defined in the container fragment.
-        return 0;
-    }
-
     private final OnPreferenceClickListener mUpdateAddressListener =
             new OnPreferenceClickListener() {
                 /*
@@ -226,8 +224,7 @@
 
         // SubId should always be specified when creating this fragment. Either through
         // fragment.setArguments() or through savedInstanceState.
-        if (getArguments() != null && getArguments().containsKey(FRAGMENT_BUNDLE_SUBID))
-        {
+        if (getArguments() != null && getArguments().containsKey(FRAGMENT_BUNDLE_SUBID)) {
             mSubId = getArguments().getInt(FRAGMENT_BUNDLE_SUBID);
         } else if (savedInstanceState != null) {
             mSubId = savedInstanceState.getInt(
diff --git a/src/com/android/settings/wifi/WifiCallingSuggestionActivity.java b/src/com/android/settings/wifi/calling/WifiCallingSuggestionActivity.java
similarity index 96%
rename from src/com/android/settings/wifi/WifiCallingSuggestionActivity.java
rename to src/com/android/settings/wifi/calling/WifiCallingSuggestionActivity.java
index c3c7adb..9a50a83 100644
--- a/src/com/android/settings/wifi/WifiCallingSuggestionActivity.java
+++ b/src/com/android/settings/wifi/calling/WifiCallingSuggestionActivity.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.settings.wifi;
+package com.android.settings.wifi.calling;
 
 import android.content.Context;
 
diff --git a/src/com/android/settings/wrapper/PrintManagerWrapper.java b/src/com/android/settings/wrapper/PrintManagerWrapper.java
new file mode 100644
index 0000000..d05eaed
--- /dev/null
+++ b/src/com/android/settings/wrapper/PrintManagerWrapper.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.wrapper;
+
+import android.content.Context;
+import android.print.PrintJob;
+import android.print.PrintManager;
+import android.printservice.PrintServiceInfo;
+
+import java.util.List;
+
+/**
+ * Wrapper class for {@link PrintManager}. This is necessary to increase testability in Robolectric.
+ */
+public class PrintManagerWrapper {
+
+    private final PrintManager mPrintManager;
+
+    public PrintManagerWrapper(Context context) {
+        mPrintManager = ((PrintManager) context.getSystemService(Context.PRINT_SERVICE))
+                .getGlobalPrintManagerForUser(context.getUserId());
+    }
+
+    public List<PrintServiceInfo> getPrintServices(int selectionFlags) {
+        return mPrintManager.getPrintServices(selectionFlags);
+    }
+
+    public void addPrintJobStateChanegListener(PrintManager.PrintJobStateChangeListener listener) {
+        mPrintManager.addPrintJobStateChangeListener(listener);
+    }
+
+    public void removePrintJobStateChangeListener(
+            PrintManager.PrintJobStateChangeListener listener) {
+        mPrintManager.removePrintJobStateChangeListener(listener);
+    }
+
+    public List<PrintJob> getPrintJobs() {
+        return mPrintManager.getPrintJobs();
+    }
+}
diff --git a/src/com/android/settings/wrapper/WallpaperManagerWrapper.java b/src/com/android/settings/wrapper/WallpaperManagerWrapper.java
index 89015e5..eabc5bb 100644
--- a/src/com/android/settings/wrapper/WallpaperManagerWrapper.java
+++ b/src/com/android/settings/wrapper/WallpaperManagerWrapper.java
@@ -22,12 +22,23 @@
 public class WallpaperManagerWrapper {
 
     private final WallpaperManager mWallpaperManager;
+    private final boolean mWallpaperServiceEnabled;
 
     public WallpaperManagerWrapper(Context context) {
-        mWallpaperManager = (WallpaperManager) context.getSystemService(Context.WALLPAPER_SERVICE);
+        mWallpaperServiceEnabled = context.getResources().getBoolean(
+                com.android.internal.R.bool.config_enableWallpaperService);
+        mWallpaperManager = mWallpaperServiceEnabled ? (WallpaperManager) context.getSystemService(
+                Context.WALLPAPER_SERVICE) : null;
+    }
+
+    public boolean isWallpaperServiceEnabled() {
+        return mWallpaperServiceEnabled;
     }
 
     public int getWallpaperId(int which) {
+        if (!mWallpaperServiceEnabled) {
+            throw new RuntimeException("This device does not have wallpaper service enabled.");
+        }
         return mWallpaperManager.getWallpaperId(which);
     }
 }
diff --git a/tests/robotests/assets/grandfather_not_implementing_indexable b/tests/robotests/assets/grandfather_not_implementing_indexable
index ece35fb..748dc94 100644
--- a/tests/robotests/assets/grandfather_not_implementing_indexable
+++ b/tests/robotests/assets/grandfather_not_implementing_indexable
@@ -15,7 +15,6 @@
 com.android.settings.inputmethod.UserDictionaryList
 com.android.settings.datausage.DataSaverSummary
 com.android.settings.datausage.AppDataUsage
-com.android.settings.datausage.DataPlanUsageSummary
 com.android.settings.accessibility.FontSizePreferenceFragmentForSetupWizard
 com.android.settings.applications.ManageDomainUrls
 com.android.settings.applications.appinfo.WriteSettingsDetails
@@ -61,8 +60,7 @@
 com.android.settings.applications.appinfo.PictureInPictureDetails
 com.android.settings.ApnSettings
 com.android.settings.PrivacySettings
-com.android.settings.WifiCallingSettings
-com.android.settings.WifiCallingSettingsForSub
+com.android.settings.wifi.calling.WifiCallingSettingsForSub
 com.android.settings.password.SetupChooseLockGeneric$SetupChooseLockGenericFragment
 com.android.settings.SetupRedactionInterstitial$SetupRedactionInterstitialFragment
 com.android.settings.security.trustagent.TrustAgentSettings
@@ -72,4 +70,4 @@
 com.android.settings.ApnEditor
 com.android.settings.UserCredentialsSettings
 com.android.settings.TestingSettings
-com.android.settings.applications.DirectoryAccessDetails
\ No newline at end of file
+com.android.settings.applications.DirectoryAccessDetails
diff --git a/tests/robotests/assets/grandfather_slice_controller_not_in_xml b/tests/robotests/assets/grandfather_slice_controller_not_in_xml
new file mode 100644
index 0000000..f11027e
--- /dev/null
+++ b/tests/robotests/assets/grandfather_slice_controller_not_in_xml
@@ -0,0 +1 @@
+com.android.settings.testutils.FakeToggleController
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/SettingsActivityTest.java b/tests/robotests/src/com/android/settings/SettingsActivityTest.java
index 509ecda..25abd4d 100644
--- a/tests/robotests/src/com/android/settings/SettingsActivityTest.java
+++ b/tests/robotests/src/com/android/settings/SettingsActivityTest.java
@@ -16,7 +16,6 @@
 
 package com.android.settings;
 
-import static com.google.common.truth.Truth.assertThat;
 import static org.mockito.ArgumentMatchers.nullable;
 import static org.mockito.Matchers.anyInt;
 import static org.mockito.Mockito.doReturn;
@@ -28,17 +27,14 @@
 import android.app.ActivityManager;
 import android.app.FragmentManager;
 import android.app.FragmentTransaction;
-import android.content.Context;
 import android.content.Intent;
 import android.graphics.Bitmap;
-import android.os.Bundle;
 
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
 
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.mockito.Answers;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 import org.robolectric.RuntimeEnvironment;
@@ -48,9 +44,6 @@
 @Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
 public class SettingsActivityTest {
 
-    @Mock(answer = Answers.RETURNS_DEEP_STUBS)
-    private Context mContext;
-
     @Mock
     private FragmentManager mFragmentManager;
     @Mock
@@ -84,13 +77,4 @@
 
         verify(mTaskDescription).setIcon(nullable(Bitmap.class));
     }
-
-    @Test
-    public void testSaveState_EnabledHomeSaved() {
-        mActivity.mDisplayHomeAsUpEnabled = true;
-        Bundle bundle = new Bundle();
-        mActivity.saveState(bundle);
-
-        assertThat((boolean) bundle.get(SettingsActivity.SAVE_KEY_SHOW_HOME_AS_UP)).isTrue();
-    }
 }
diff --git a/tests/robotests/src/com/android/settings/UtilsTest.java b/tests/robotests/src/com/android/settings/UtilsTest.java
index fb571bb..d1c4a55 100644
--- a/tests/robotests/src/com/android/settings/UtilsTest.java
+++ b/tests/robotests/src/com/android/settings/UtilsTest.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package com.android.settings;
 
 import static com.google.common.truth.Truth.assertThat;
@@ -25,9 +41,7 @@
 import android.os.storage.DiskInfo;
 import android.os.storage.StorageManager;
 import android.os.storage.VolumeInfo;
-import android.text.SpannableStringBuilder;
 import android.text.format.DateUtils;
-import android.text.style.TtsSpan;
 import android.util.IconDrawableFactory;
 import android.widget.EditText;
 import android.widget.TextView;
@@ -35,6 +49,7 @@
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
 import com.android.settings.wrapper.DevicePolicyManagerWrapper;
 
+import com.android.settingslib.utils.StringUtil;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -110,175 +125,6 @@
     }
 
     @Test
-    public void testFormatElapsedTime_WithSeconds_ShowSeconds() {
-        final double testMillis = 5 * DateUtils.MINUTE_IN_MILLIS + 30 * DateUtils.SECOND_IN_MILLIS;
-        final String expectedTime = "5m 30s";
-
-        assertThat(Utils.formatElapsedTime(mContext, testMillis, true).toString()).isEqualTo(
-                expectedTime);
-    }
-
-    @Test
-    public void testFormatElapsedTime_NoSeconds_DoNotShowSeconds() {
-        final double testMillis = 5 * DateUtils.MINUTE_IN_MILLIS + 30 * DateUtils.SECOND_IN_MILLIS;
-        final String expectedTime = "6m";
-
-        assertThat(Utils.formatElapsedTime(mContext, testMillis, false).toString()).isEqualTo(
-                expectedTime);
-    }
-
-    @Test
-    public void testFormatElapsedTime_TimeMoreThanOneDay_ShowCorrectly() {
-        final double testMillis = 2 * DateUtils.DAY_IN_MILLIS
-                + 4 * DateUtils.HOUR_IN_MILLIS + 15 * DateUtils.MINUTE_IN_MILLIS;
-        final String expectedTime = "2d 4h 15m";
-
-        assertThat(Utils.formatElapsedTime(mContext, testMillis, false).toString()).isEqualTo(
-                expectedTime);
-    }
-
-    @Test
-    public void testFormatElapsedTime_ZeroFieldsInTheMiddleDontShow() {
-        final double testMillis = 2 * DateUtils.DAY_IN_MILLIS + 15 * DateUtils.MINUTE_IN_MILLIS;
-        final String expectedTime = "2d 15m";
-
-        assertThat(Utils.formatElapsedTime(mContext, testMillis, false).toString()).isEqualTo(
-                expectedTime);
-    }
-
-    @Test
-    public void testFormatElapsedTime_FormatZero_WithSeconds() {
-        final double testMillis = 0;
-        final String expectedTime = "0s";
-
-        assertThat(Utils.formatElapsedTime(mContext, testMillis, true).toString()).isEqualTo(
-                expectedTime);
-    }
-
-    @Test
-    public void testFormatElapsedTime_FormatZero_NoSeconds() {
-        final double testMillis = 0;
-        final String expectedTime = "0m";
-
-        assertThat(Utils.formatElapsedTime(mContext, testMillis, false).toString()).isEqualTo(
-                expectedTime);
-    }
-
-    @Test
-    public void testFormatElapsedTime_onlyContainsMinute_hasTtsSpan() {
-        final double testMillis = 15 * DateUtils.MINUTE_IN_MILLIS;
-
-        final CharSequence charSequence = Utils.formatElapsedTime(mContext, testMillis, false);
-        assertThat(charSequence).isInstanceOf(SpannableStringBuilder.class);
-
-        final SpannableStringBuilder expectedString = (SpannableStringBuilder) charSequence;
-        final TtsSpan[] ttsSpans = expectedString.getSpans(0, expectedString.length(),
-                TtsSpan.class);
-
-        assertThat(ttsSpans).asList().hasSize(1);
-        assertThat(ttsSpans[0].getType()).isEqualTo(TtsSpan.TYPE_MEASURE);
-    }
-
-    @Test
-    public void testFormatRelativeTime_WithSeconds_ShowSeconds() {
-        final double testMillis = 40 * DateUtils.SECOND_IN_MILLIS;
-        final String expectedTime = "40 sec. ago";
-
-        assertThat(Utils.formatRelativeTime(mContext, testMillis, true).toString()).isEqualTo(
-                expectedTime);
-    }
-
-    @Test
-    public void testFormatRelativeTime_NoSeconds_DoNotShowSeconds() {
-        final double testMillis = 40 * DateUtils.SECOND_IN_MILLIS;
-        final String expectedTime = "1 min. ago";
-
-        assertThat(Utils.formatRelativeTime(mContext, testMillis, false).toString()).isEqualTo(
-                expectedTime);
-    }
-
-    @Test
-    public void testFormatRelativeTime_LessThanTwoMinutes_withSeconds() {
-        final double testMillis = 119 * DateUtils.SECOND_IN_MILLIS;
-        final String expectedTime = "119 sec. ago";
-
-        assertThat(Utils.formatRelativeTime(mContext, testMillis, true).toString()).isEqualTo(
-                expectedTime);
-    }
-
-    @Test
-    public void testFormatRelativeTime_LessThanTwoMinutes_NoSeconds() {
-        final double testMillis = 119 * DateUtils.SECOND_IN_MILLIS;
-        final String expectedTime = "2 min. ago";
-
-        assertThat(Utils.formatRelativeTime(mContext, testMillis, false).toString()).isEqualTo(
-                expectedTime);
-    }
-
-    @Test
-    public void testFormatRelativeTime_TwoMinutes_withSeconds() {
-        final double testMillis = 2 * DateUtils.MINUTE_IN_MILLIS;
-        final String expectedTime = "2 min. ago";
-
-        assertThat(Utils.formatRelativeTime(mContext, testMillis, true).toString()).isEqualTo(
-                expectedTime);
-    }
-
-    @Test
-    public void testFormatRelativeTime_LessThanTwoHours_withSeconds() {
-        final double testMillis = 119 * DateUtils.MINUTE_IN_MILLIS;
-        final String expectedTime = "119 min. ago";
-
-        assertThat(Utils.formatRelativeTime(mContext, testMillis, true).toString()).isEqualTo(
-                expectedTime);
-    }
-
-    @Test
-    public void testFormatRelativeTime_TwoHours_withSeconds() {
-        final double testMillis = 2 * DateUtils.HOUR_IN_MILLIS;
-        final String expectedTime = "2 hr. ago";
-
-        assertThat(Utils.formatRelativeTime(mContext, testMillis, true).toString()).isEqualTo(
-                expectedTime);
-    }
-
-    @Test
-    public void testFormatRelativeTime_LessThanTwoDays_withSeconds() {
-        final double testMillis = 47 * DateUtils.HOUR_IN_MILLIS;
-        final String expectedTime = "47 hr. ago";
-
-        assertThat(Utils.formatRelativeTime(mContext, testMillis, true).toString()).isEqualTo(
-                expectedTime);
-    }
-
-    @Test
-    public void testFormatRelativeTime_TwoDays_withSeconds() {
-        final double testMillis = 2 * DateUtils.DAY_IN_MILLIS;
-        final String expectedTime = "2 days ago";
-
-        assertThat(Utils.formatRelativeTime(mContext, testMillis, true).toString()).isEqualTo(
-                expectedTime);
-    }
-
-    @Test
-    public void testFormatRelativeTime_FormatZero_WithSeconds() {
-        final double testMillis = 0;
-        final String expectedTime = "0 sec. ago";
-
-        assertThat(Utils.formatRelativeTime(mContext, testMillis, true).toString()).isEqualTo(
-                expectedTime);
-    }
-
-    @Test
-    public void testFormatRelativeTime_FormatZero_NoSeconds() {
-        final double testMillis = 0;
-        final String expectedTime = "0 min. ago";
-
-        assertThat(Utils.formatRelativeTime(mContext, testMillis, false).toString()).isEqualTo(
-                expectedTime);
-    }
-
-    @Test
     public void testInitializeVolumeDoesntBreakOnNullVolume() {
         VolumeInfo info = new VolumeInfo("id", 0, new DiskInfo("id", 0), "");
         StorageManager storageManager = mock(StorageManager.class, RETURNS_DEEP_STUBS);
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/AppMemoryPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/AppMemoryPreferenceControllerTest.java
index fd136c1..532522c 100644
--- a/tests/robotests/src/com/android/settings/applications/appinfo/AppMemoryPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/AppMemoryPreferenceControllerTest.java
@@ -37,7 +37,9 @@
 import com.android.settings.applications.ProcStatsData;
 import com.android.settings.applications.ProcessStatsDetail;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.testutils.shadow.ShadowUserManager;
 
+import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -48,7 +50,9 @@
 import org.robolectric.util.ReflectionHelpers;
 
 @RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION, shadows = {
+        ShadowUserManager.class
+})
 public class AppMemoryPreferenceControllerTest {
 
     @Mock
@@ -67,6 +71,7 @@
     public void setUp() {
         MockitoAnnotations.initMocks(this);
         mContext = RuntimeEnvironment.application;
+        ShadowUserManager.getShadow().setIsAdminUser(true);
         mController =
                 spy(new AppMemoryPreferenceController(mContext, mFragment, null /* lifecycle */));
         when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
@@ -75,6 +80,11 @@
         when(mFragment.getActivity()).thenReturn(mActivity);
     }
 
+    @After
+    public void tearDown() {
+        ShadowUserManager.getShadow().reset();
+    }
+
     @Test
     public void getAvailabilityStatus_developmentSettingsEnabled_shouldReturnAvailable() {
         Settings.Global.putInt(mContext.getContentResolver(),
diff --git a/tests/robotests/src/com/android/settings/backup/BackupSettingsHelperTest.java b/tests/robotests/src/com/android/settings/backup/BackupSettingsHelperTest.java
index 9de0c6a..4e5428c 100644
--- a/tests/robotests/src/com/android/settings/backup/BackupSettingsHelperTest.java
+++ b/tests/robotests/src/com/android/settings/backup/BackupSettingsHelperTest.java
@@ -16,6 +16,14 @@
 
 package com.android.settings.backup;
 
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.anyInt;
+import static org.mockito.Mockito.anyString;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
 import android.app.backup.BackupManager;
 import android.app.backup.IBackupManager;
 import android.content.ComponentName;
@@ -26,6 +34,10 @@
 import android.os.IBinder;
 import android.os.RemoteException;
 
+import com.android.settings.R;
+import com.android.settings.TestConfig;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -36,19 +48,6 @@
 import org.robolectric.annotation.Implementation;
 import org.robolectric.annotation.Implements;
 
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Mockito.anyInt;
-import static org.mockito.Mockito.anyString;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import com.android.settings.R;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settings.TestConfig;
-import com.android.settingslib.drawer.SettingsDrawerActivity;
-
 @RunWith(SettingsRobolectricTestRunner.class)
 @Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
         shadows = {BackupSettingsHelperTest.ShadowBackupManagerStub.class})
@@ -263,8 +262,6 @@
 
         assertThat(backupIntent.getComponent().getClassName()).isEqualTo(
                 DEFAULT_SETTINGS_CLASSNAME);
-        assertThat(backupIntent.getExtras().getBoolean(
-                SettingsDrawerActivity.EXTRA_SHOW_MENU)).isTrue();
     }
 
     @Test
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsHeaderControllerTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsHeaderControllerTest.java
index ab338a1..0129b1c 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsHeaderControllerTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsHeaderControllerTest.java
@@ -80,7 +80,7 @@
      */
     @Test
     public void testContextMock() {
-        assertThat(mContext.getString(R.string.bluetooth_connected)).isEqualTo("Connected");
+        assertThat(mContext.getString(R.string.bluetooth_connected)).isNotNull();
     }
 
     @Test
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/AdvancedConnectedDeviceDashboardFragmentTest.java b/tests/robotests/src/com/android/settings/connecteddevice/AdvancedConnectedDeviceDashboardFragmentTest.java
index 37ccb76..9f1409c 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/AdvancedConnectedDeviceDashboardFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/AdvancedConnectedDeviceDashboardFragmentTest.java
@@ -16,7 +16,6 @@
 package com.android.settings.connecteddevice;
 
 import static com.google.common.truth.Truth.assertThat;
-
 import static org.mockito.Mockito.when;
 
 import android.content.Context;
@@ -24,9 +23,6 @@
 import android.provider.SearchIndexableResource;
 
 import com.android.settings.TestConfig;
-import com.android.settings.core.PreferenceControllerMixin;
-import com.android.settings.nfc.NfcPreferenceController;
-import com.android.settings.testutils.FakeFeatureFactory;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
 import com.android.settings.testutils.XmlTestUtils;
 import com.android.settingslib.drawer.CategoryKey;
@@ -52,38 +48,14 @@
     @Mock
     private PackageManager mManager;
 
-    private FakeFeatureFactory mFeatureFactory;
-    private SmsMirroringFeatureProvider mFeatureProvider;
     private AdvancedConnectedDeviceDashboardFragment mFragment;
-    private TestSmsMirroringPreferenceController mSmsMirroringPreferenceController;
-
-    private static final class TestSmsMirroringPreferenceController
-            extends SmsMirroringPreferenceController implements PreferenceControllerMixin {
-
-        private boolean mIsAvailable;
-
-        public TestSmsMirroringPreferenceController(Context context) {
-            super(context);
-        }
-
-        @Override
-        public boolean isAvailable() {
-            return mIsAvailable;
-        }
-    }
 
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
-        mFeatureFactory = FakeFeatureFactory.setupForTest();
-        mFeatureProvider = mFeatureFactory.smsMirroringFeatureProvider;
 
         mFragment = new AdvancedConnectedDeviceDashboardFragment();
-        when(mContext.getPackageManager()).thenReturn(mManager);
-
-        mSmsMirroringPreferenceController = new TestSmsMirroringPreferenceController(mContext);
-        when(mFeatureProvider.getController(mContext)).thenReturn(
-                mSmsMirroringPreferenceController);
+        when(mContext.getApplicationContext().getPackageManager()).thenReturn(mManager);
     }
 
     @Test
@@ -102,52 +74,6 @@
     }
 
     @Test
-    public void testSearchIndexProvider_NoNfc_KeyAdded() {
-        when(mManager.hasSystemFeature(PackageManager.FEATURE_NFC)).thenReturn(false);
-        final List<String> keys = mFragment.SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(
-                mContext);
-
-        assertThat(keys).isNotNull();
-        assertThat(keys).contains(NfcPreferenceController.KEY_TOGGLE_NFC);
-        assertThat(keys).contains(NfcPreferenceController.KEY_ANDROID_BEAM_SETTINGS);
-    }
-
-    @Test
-    public void testSearchIndexProvider_NFC_KeyNotAdded() {
-        when(mManager.hasSystemFeature(PackageManager.FEATURE_NFC)).thenReturn(true);
-        final List<String> keys = mFragment.SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(
-                mContext);
-
-        assertThat(keys).isNotNull();
-        assertThat(keys).doesNotContain(NfcPreferenceController.KEY_TOGGLE_NFC);
-        assertThat(keys).doesNotContain(NfcPreferenceController.KEY_ANDROID_BEAM_SETTINGS);
-    }
-
-    @Test
-    public void testSearchIndexProvider_NoSmsMirroring_KeyAdded() {
-        when(mFeatureProvider.shouldShowSmsMirroring(mContext)).thenReturn(false);
-        mSmsMirroringPreferenceController.mIsAvailable = false;
-
-        final List<String> keys = mFragment.SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(
-                mContext);
-
-        assertThat(keys).isNotNull();
-        assertThat(keys).contains(mSmsMirroringPreferenceController.getPreferenceKey());
-    }
-
-    @Test
-    public void testSearchIndexProvider_SmsMirroring_KeyNotAdded() {
-        when(mFeatureProvider.shouldShowSmsMirroring(mContext)).thenReturn(true);
-        mSmsMirroringPreferenceController.mIsAvailable = true;
-
-        final List<String> keys = mFragment.SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(
-                mContext);
-
-        assertThat(keys).isNotNull();
-        assertThat(keys).doesNotContain(mSmsMirroringPreferenceController.getPreferenceKey());
-    }
-
-    @Test
     public void testGetCategoryKey_returnCategoryDevice() {
         assertThat(mFragment.getCategoryKey()).isEqualTo(CategoryKey.CATEGORY_DEVICE);
     }
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment2Test.java b/tests/robotests/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment2Test.java
index 1bc8a1b..3eacd7a 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment2Test.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment2Test.java
@@ -60,37 +60,15 @@
     private PackageManager mManager;
 
     private FakeFeatureFactory mFeatureFactory;
-    private SmsMirroringFeatureProvider mFeatureProvider;
     private ConnectedDeviceDashboardFragmentOld mFragment;
-    private TestSmsMirroringPreferenceController mSmsMirroringPreferenceController;
-
-    private static final class TestSmsMirroringPreferenceController
-            extends SmsMirroringPreferenceController implements PreferenceControllerMixin {
-
-        private boolean mIsAvailable;
-
-        public TestSmsMirroringPreferenceController(Context context) {
-            super(context);
-        }
-
-        @Override
-        public boolean isAvailable() {
-            return mIsAvailable;
-        }
-    }
 
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
         mFeatureFactory = FakeFeatureFactory.setupForTest();
-        mFeatureProvider = mFeatureFactory.smsMirroringFeatureProvider;
 
         mFragment = new ConnectedDeviceDashboardFragmentOld();
         when(mContext.getPackageManager()).thenReturn(mManager);
-
-        mSmsMirroringPreferenceController = new TestSmsMirroringPreferenceController(mContext);
-        when(mFeatureProvider.getController(mContext)).thenReturn(
-                mSmsMirroringPreferenceController);
     }
 
     @Test
@@ -131,30 +109,6 @@
     }
 
     @Test
-    public void testSearchIndexProvider_NoSmsMirroring_KeyAdded() {
-        when(mFeatureProvider.shouldShowSmsMirroring(mContext)).thenReturn(false);
-        mSmsMirroringPreferenceController.mIsAvailable = false;
-
-        final List<String> keys = mFragment.SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(
-                mContext);
-
-        assertThat(keys).isNotNull();
-        assertThat(keys).contains(mSmsMirroringPreferenceController.getPreferenceKey());
-    }
-
-    @Test
-    public void testSearchIndexProvider_SmsMirroring_KeyNotAdded() {
-        when(mFeatureProvider.shouldShowSmsMirroring(mContext)).thenReturn(true);
-        mSmsMirroringPreferenceController.mIsAvailable = true;
-
-        final List<String> keys = mFragment.SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(
-                mContext);
-
-        assertThat(keys).isNotNull();
-        assertThat(keys).doesNotContain(mSmsMirroringPreferenceController.getPreferenceKey());
-    }
-
-    @Test
     public void testNonIndexableKeys_existInXmlLayout() {
         final Context context = RuntimeEnvironment.application;
         when(mManager.hasSystemFeature(PackageManager.FEATURE_NFC)).thenReturn(false);
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbModePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbModePreferenceControllerTest.java
index d15a57f..a1c599f 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbModePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbModePreferenceControllerTest.java
@@ -1,12 +1,15 @@
 package com.android.settings.connecteddevice.usb;
 
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Answers.RETURNS_DEEP_STUBS;
+import static org.mockito.Mockito.when;
+
 import android.content.Context;
 import android.support.v7.preference.Preference;
-import android.support.v7.preference.PreferenceScreen;
 
 import com.android.settings.R;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
 import com.android.settings.TestConfig;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -16,20 +19,12 @@
 import org.robolectric.annotation.Config;
 import org.robolectric.shadows.ShadowApplication;
 
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Answers.RETURNS_DEEP_STUBS;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.when;
-import static org.mockito.Mockito.verify;
-
 @RunWith(SettingsRobolectricTestRunner.class)
 @Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
 public class UsbModePreferenceControllerTest {
 
     @Mock(answer = RETURNS_DEEP_STUBS)
     private UsbBackend mUsbBackend;
-    @Mock(answer = RETURNS_DEEP_STUBS)
-    private PreferenceScreen mScreen;
     @Mock
     private UsbConnectionBroadcastReceiver mUsbConnectionBroadcastReceiver;
 
@@ -40,7 +35,7 @@
     public void setUp() {
         MockitoAnnotations.initMocks(this);
         mContext = ShadowApplication.getInstance().getApplicationContext();
-        mController = new UsbModePreferenceController(mContext, mUsbBackend);
+        mController = new UsbModePreferenceController(mContext, mUsbBackend, null /* lifecycle */);
         mController.mUsbReceiver = mUsbConnectionBroadcastReceiver;
     }
 
diff --git a/tests/robotests/src/com/android/settings/core/BasePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/core/BasePreferenceControllerTest.java
index da2197c..c0ac961 100644
--- a/tests/robotests/src/com/android/settings/core/BasePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/core/BasePreferenceControllerTest.java
@@ -16,14 +16,11 @@
 package com.android.settings.core;
 
 import static com.android.settings.core.BasePreferenceController.AVAILABLE;
-import static com.android.settings.core.BasePreferenceController
-        .DISABLED_DEPENDENT_SETTING;
+import static com.android.settings.core.BasePreferenceController.DISABLED_DEPENDENT_SETTING;
 import static com.android.settings.core.BasePreferenceController.DISABLED_FOR_USER;
 import static com.android.settings.core.BasePreferenceController.DISABLED_UNSUPPORTED;
 import static com.android.settings.core.BasePreferenceController.UNAVAILABLE_UNKNOWN;
-
 import static com.google.common.truth.Truth.assertThat;
-
 import static org.mockito.Mockito.when;
 
 import com.android.settings.TestConfig;
@@ -41,7 +38,7 @@
 public class BasePreferenceControllerTest {
 
     @Mock
-    BasePreferenceController mPreferenceController;
+    private BasePreferenceController mPreferenceController;
 
     @Before
     public void setUp() {
diff --git a/tests/robotests/src/com/android/settings/dashboard/DashboardAdapterTest.java b/tests/robotests/src/com/android/settings/dashboard/DashboardAdapterTest.java
index d25969e..cc25b5d 100644
--- a/tests/robotests/src/com/android/settings/dashboard/DashboardAdapterTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/DashboardAdapterTest.java
@@ -35,6 +35,7 @@
 import android.util.DisplayMetrics;
 import android.view.LayoutInflater;
 import android.view.View;
+import android.view.WindowManager;
 import android.widget.TextView;
 
 import com.android.settings.R;
@@ -77,6 +78,8 @@
     private Condition mCondition;
     @Mock
     private Resources mResources;
+    @Mock
+    private WindowManager mWindowManager;
     private FakeFeatureFactory mFactory;
     private DashboardAdapter mDashboardAdapter;
     private List<Condition> mConditionList;
@@ -87,6 +90,7 @@
         mFactory = FakeFeatureFactory.setupForTest();
         when(mFactory.dashboardFeatureProvider.shouldTintIcon()).thenReturn(true);
 
+        when(mContext.getSystemService(Context.WINDOW_SERVICE)).thenReturn(mWindowManager);
         when(mContext.getResources()).thenReturn(mResources);
         when(mResources.getQuantityString(any(int.class), any(int.class), any()))
                 .thenReturn("");
diff --git a/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionAdapterTest.java b/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionAdapterTest.java
index fc773a7..4ff09c1 100644
--- a/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionAdapterTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/suggestions/SuggestionAdapterTest.java
@@ -28,12 +28,15 @@
 
 import android.app.PendingIntent;
 import android.content.Context;
+import android.content.res.Resources;
 import android.content.res.TypedArray;
 import android.graphics.drawable.Drawable;
 import android.graphics.drawable.Icon;
 import android.service.settings.suggestions.Suggestion;
+import android.view.Display;
 import android.view.LayoutInflater;
 import android.view.View;
+import android.view.WindowManager;
 import android.widget.FrameLayout;
 import android.widget.LinearLayout;
 
@@ -67,17 +70,33 @@
     private SettingsActivity mActivity;
     @Mock
     private SuggestionControllerMixin mSuggestionControllerMixin;
+    @Mock
+    private Resources mResources;
+    @Mock
+    private WindowManager mWindowManager;
+
     private FakeFeatureFactory mFeatureFactory;
     private Context mContext;
     private SuggestionAdapter mSuggestionAdapter;
     private DashboardAdapter.DashboardItemHolder mSuggestionHolder;
     private List<Suggestion> mOneSuggestion;
     private List<Suggestion> mTwoSuggestions;
+    private SuggestionAdapter.CardConfig mConfig;
 
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
         mContext = spy(RuntimeEnvironment.application);
+        when(mActivity.getSystemService(Context.WINDOW_SERVICE)).thenReturn(mWindowManager);
+        when(mActivity.getResources()).thenReturn(mResources);
+        when(mResources.getDimensionPixelOffset(R.dimen.suggestion_card_inner_margin))
+            .thenReturn(10);
+        when(mResources.getDimensionPixelOffset(R.dimen.suggestion_card_outer_margin))
+            .thenReturn(20);
+        when(mResources.getDimensionPixelOffset(R.dimen.suggestion_card_width_multiple_cards))
+            .thenReturn(120);
+        mConfig = spy(SuggestionAdapter.CardConfig.get(mActivity));
+
         mFeatureFactory = FakeFeatureFactory.setupForTest();
 
         final Suggestion suggestion1 = new Suggestion.Builder("id1")
@@ -275,6 +294,57 @@
         verify(drawable).setTint(colorAccent);
     }
 
+    @Test
+    public void onBindViewHolder_closeButtonShouldHaveContentDescription()
+        throws PendingIntent.CanceledException {
+        final List<Suggestion> suggestions = makeSuggestions("pkg1");
+        setupSuggestions(mActivity, suggestions);
+
+        mSuggestionAdapter.onBindViewHolder(mSuggestionHolder, 0);
+
+        assertThat(
+            mSuggestionHolder.itemView.findViewById(R.id.close_button).getContentDescription())
+            .isNotNull();
+    }
+
+    @Test
+    public void setCardLayout_oneCard_shouldSetCardWidthToMatchParent() {
+        final List<Suggestion> suggestions = makeSuggestions("pkg1");
+        setupSuggestions(mContext, suggestions);
+
+        mConfig.setCardLayout(mSuggestionHolder, 1, 0);
+
+        assertThat(mSuggestionHolder.itemView.getLayoutParams().width)
+            .isEqualTo(LinearLayout.LayoutParams.MATCH_PARENT);
+    }
+
+    @Test
+    public void setCardLayout_twoCards_shouldSetCardWidthToHalfScreenMinusPadding() {
+        final List<Suggestion> suggestions = makeSuggestions("pkg1");
+        setupSuggestions(mContext, suggestions);
+        doReturn(200).when(mConfig).getScreenWidth();
+
+        mConfig.setCardLayout(mSuggestionHolder, 2, 0);
+
+        /*
+         * card width = (screen width - left margin - inner margin - right margin) / 2
+         *            = (200 - 20 - 10 - 20) / 2
+         *            = 75
+         */
+        assertThat(mSuggestionHolder.itemView.getLayoutParams().width).isEqualTo(75);
+    }
+
+
+    @Test
+    public void setCardLayout_multipleCards_shouldSetCardWidthFromResource() {
+        final List<Suggestion> suggestions = makeSuggestions("pkg1");
+        setupSuggestions(mContext, suggestions);
+
+        mConfig.setCardLayout(mSuggestionHolder, 3, 0);
+
+        assertThat(mSuggestionHolder.itemView.getLayoutParams().width).isEqualTo(120);
+    }
+
     private void setupSuggestions(Context context, List<Suggestion> suggestions) {
         mSuggestionAdapter = new SuggestionAdapter(context, mSuggestionControllerMixin,
             null /* savedInstanceState */, null /* callback */, null /* lifecycle */);
diff --git a/tests/robotests/src/com/android/settings/datausage/DataPlanSummaryPreferenceTest.java b/tests/robotests/src/com/android/settings/datausage/DataPlanSummaryPreferenceTest.java
deleted file mode 100644
index 9ddce53..0000000
--- a/tests/robotests/src/com/android/settings/datausage/DataPlanSummaryPreferenceTest.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-package com.android.settings.datausage;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import android.content.Context;
-import android.graphics.Color;
-import android.support.v7.preference.PreferenceViewHolder;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-import com.android.settings.R;
-import com.android.settings.TestConfig;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settings.testutils.shadow.SettingsShadowResources;
-import com.android.settings.widget.DonutView;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.robolectric.RuntimeEnvironment;
-import org.robolectric.annotation.Config;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
-        shadows = {
-                SettingsShadowResources.class,
-                SettingsShadowResources.SettingsShadowTheme.class
-        }
-)
-public final class DataPlanSummaryPreferenceTest {
-
-    private static final String TEST_PLAN_USAGE = "Test plan usage";
-    private static final String TEST_PLAN_NAME = "Test plan name";
-    private static final String TEST_PLAN_DESCRIPTION = "Test plan description";
-    private static int sPlanUsageTextColor;
-    private static int sMeterBackgroundColor;
-    private static int sMeterConsumedColor;
-
-    @BeforeClass
-    public static void beforeClass() {
-        sPlanUsageTextColor = Color.parseColor("#FF5C94F1");
-        sMeterBackgroundColor = Color.parseColor("#FFDBDCDC");
-        sMeterConsumedColor = Color.parseColor("#FF5C94F1");
-    }
-
-    private DataPlanSummaryPreference mPreference;
-    private PreferenceViewHolder mHolder;
-
-    @Before
-    public void setUp() {
-        SettingsShadowResources.overrideResource(
-                com.android.internal.R.string.config_headlineFontFamily, "");
-        Context context = RuntimeEnvironment.application;
-        mPreference = new DataPlanSummaryPreference(context);
-        LayoutInflater inflater = LayoutInflater.from(context);
-        View view = inflater.inflate(mPreference.getLayoutResource(),
-                new LinearLayout(context), false);
-        mHolder = PreferenceViewHolder.createInstanceForTests(view);
-    }
-
-    @After
-    public void tearDown() {
-        SettingsShadowResources.reset();
-    }
-
-    @Test
-    public void shouldRender_withoutData() {
-        mPreference.onBindViewHolder(mHolder);
-
-        TextView planUsageTextView = (TextView) mHolder.findViewById(android.R.id.title);
-        assertThat(planUsageTextView.getText().toString()).isEmpty();
-        TextView planNameTextView = (TextView) mHolder.findViewById(android.R.id.text1);
-        assertThat(planNameTextView.getText().toString()).isEmpty();
-        TextView planDescriptionTextView = (TextView) mHolder.findViewById(android.R.id.text2);
-        assertThat(planDescriptionTextView.getText().toString()).isEmpty();
-    }
-
-    @Test
-    public void shouldRender_withData() {
-        mPreference.setTitle(TEST_PLAN_USAGE);
-        mPreference.setUsageTextColor(sPlanUsageTextColor);
-        mPreference.setName(TEST_PLAN_NAME);
-        mPreference.setDescription(TEST_PLAN_DESCRIPTION);
-        mPreference.setPercentageUsage(0.25D);
-        mPreference.setMeterBackgroundColor(sMeterBackgroundColor);
-        mPreference.setMeterConsumedColor(sMeterConsumedColor);
-
-        mPreference.onBindViewHolder(mHolder);
-
-        TextView planUsageTextView = (TextView) mHolder.findViewById(android.R.id.title);
-        assertThat(planUsageTextView.getTextColors().getDefaultColor())
-                .isEqualTo(sPlanUsageTextColor);
-        assertThat(planUsageTextView.getText()).isEqualTo(TEST_PLAN_USAGE);
-
-        TextView planNameTextView = (TextView) mHolder.findViewById(android.R.id.text1);
-        assertThat(planNameTextView.getText()).isEqualTo(TEST_PLAN_NAME);
-
-        TextView planDescriptionTextView = (TextView) mHolder.findViewById(android.R.id.text2);
-        assertThat(planDescriptionTextView.getText()).isEqualTo(TEST_PLAN_DESCRIPTION);
-
-        DonutView donutView = (DonutView) mHolder.findViewById(R.id.donut);
-        assertThat(donutView.getMeterBackgroundColor()).isEqualTo(sMeterBackgroundColor);
-        assertThat(donutView.getMeterConsumedColor()).isEqualTo(sMeterConsumedColor);
-    }
-}
diff --git a/tests/robotests/src/com/android/settings/datausage/DataPlanUsageSummaryTest.java b/tests/robotests/src/com/android/settings/datausage/DataPlanUsageSummaryTest.java
deleted file mode 100644
index 748c317..0000000
--- a/tests/robotests/src/com/android/settings/datausage/DataPlanUsageSummaryTest.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-
-package com.android.settings.datausage;
-
-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.doReturn;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.content.Context;
-import android.net.ConnectivityManager;
-import android.net.NetworkPolicy;
-import android.net.wifi.WifiConfiguration;
-import android.net.wifi.WifiManager;
-import com.android.settings.R;
-import com.android.settings.TestConfig;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settingslib.NetworkPolicyEditor;
-import java.util.ArrayList;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.annotation.Config;
-import org.robolectric.shadows.ShadowApplication;
-import org.robolectric.util.ReflectionHelpers;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
-public class DataPlanUsageSummaryTest {
-    @Mock
-    private ConnectivityManager mManager;
-
-    private Context mContext;
-    private DataPlanUsageSummary mDataUsageSummary;
-    private NetworkPolicyEditor mPolicyEditor;
-    private WifiConfiguration mWifiConfiguration;
-    private NetworkPolicy mNetworkPolicy;
-
-    @Before
-    public void setUp() {
-        MockitoAnnotations.initMocks(this);
-        ShadowApplication shadowContext = ShadowApplication.getInstance();
-        shadowContext.setSystemService(Context.CONNECTIVITY_SERVICE, mManager);
-        mContext = shadowContext.getApplicationContext();
-        when(mManager.isNetworkSupported(anyInt())).thenReturn(true);
-    }
-
-    @Test
-    public void testUpdateNetworkRestrictionSummary_shouldSetSummary() {
-        mDataUsageSummary = spy(new DataPlanUsageSummary());
-        NetworkRestrictionsPreference preference = mock(NetworkRestrictionsPreference.class);
-        mPolicyEditor = mock(NetworkPolicyEditor.class);
-        WifiManager wifiManager = mock(WifiManager.class);
-        ReflectionHelpers.setField(mDataUsageSummary, "mPolicyEditor", mPolicyEditor);
-        ReflectionHelpers.setField(mDataUsageSummary, "mWifiManager", wifiManager);
-        when(wifiManager.getConfiguredNetworks()).thenReturn(new ArrayList<>());
-        doReturn(mContext.getResources()).when(mDataUsageSummary).getResources();
-
-        mDataUsageSummary.updateNetworkRestrictionSummary(preference);
-
-        verify(preference).setSummary(mContext.getResources().getQuantityString(
-                R.plurals.network_restrictions_summary, 0, 0));
-    }
-
-    @Test
-    public void testIsMetered_noSsid_shouldReturnFalse() {
-        initTest();
-
-        assertThat(mDataUsageSummary.isMetered(mWifiConfiguration)).isFalse();
-    }
-
-    @Test
-    public void testIsMetered_noNetworkPolicy_shouldReturnFalse() {
-        initTest();
-        mWifiConfiguration.SSID = "network1";
-        doReturn(null).when(mPolicyEditor).getPolicyMaybeUnquoted(any());
-
-        assertThat(mDataUsageSummary.isMetered(mWifiConfiguration)).isFalse();
-    }
-
-    @Test
-    public void testIsMetered_policyHasLimit_shouldReturnTrue() {
-        initTest();
-        mWifiConfiguration.SSID = "network1";
-        mNetworkPolicy = mock(NetworkPolicy.class);
-        mNetworkPolicy.limitBytes = 100;
-        doReturn(mNetworkPolicy).when(mPolicyEditor).getPolicyMaybeUnquoted(any());
-
-        assertThat(mDataUsageSummary.isMetered(mWifiConfiguration)).isTrue();
-    }
-
-    @Test
-    public void testIsMetered_noPolicyLimit_shouldReturnMeteredValue() {
-        initTest();
-        mWifiConfiguration.SSID = "network1";
-        mNetworkPolicy = mock(NetworkPolicy.class);
-        mNetworkPolicy.limitBytes = NetworkPolicy.LIMIT_DISABLED;
-        doReturn(mNetworkPolicy).when(mPolicyEditor).getPolicyMaybeUnquoted(any());
-
-        mNetworkPolicy.metered = true;
-        assertThat(mDataUsageSummary.isMetered(mWifiConfiguration)).isTrue();
-
-        mNetworkPolicy.metered = false;
-        assertThat(mDataUsageSummary.isMetered(mWifiConfiguration)).isFalse();
-    }
-
-    private void initTest() {
-        mDataUsageSummary = new DataPlanUsageSummary();
-        mPolicyEditor = mock(NetworkPolicyEditor.class);
-        ReflectionHelpers.setField(mDataUsageSummary, "mPolicyEditor", mPolicyEditor);
-        mWifiConfiguration = mock(WifiConfiguration.class);
-    }
-}
diff --git a/tests/robotests/src/com/android/settings/datausage/DataPlansSyncTimePreferenceTest.java b/tests/robotests/src/com/android/settings/datausage/DataPlansSyncTimePreferenceTest.java
deleted file mode 100644
index ba2d5f1..0000000
--- a/tests/robotests/src/com/android/settings/datausage/DataPlansSyncTimePreferenceTest.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-
-package com.android.settings.datausage;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import android.content.Context;
-import android.support.v7.preference.Preference;
-import android.support.v7.preference.PreferenceViewHolder;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-import com.android.settings.R;
-import com.android.settings.TestConfig;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.robolectric.RuntimeEnvironment;
-import org.robolectric.annotation.Config;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
-public final class DataPlansSyncTimePreferenceTest {
-    private static final String SYNC_TIME = "Today 12:24pm";
-
-    private Preference mPreference;
-    private PreferenceViewHolder mHolder;
-
-    @Before
-    public void setUp() {
-        Context context = RuntimeEnvironment.application;
-        mPreference = new Preference(context);
-        mPreference.setLayoutResource(R.layout.data_plans_sync_time_preference);
-
-        LayoutInflater inflater = LayoutInflater.from(context);
-        View view = inflater.inflate(mPreference.getLayoutResource(),
-                new LinearLayout(context), false);
-        mHolder = PreferenceViewHolder.createInstanceForTests(view);
-    }
-
-    @Test
-    public void shouldRender_withData() {
-        mPreference.setTitle(SYNC_TIME);
-
-        mPreference.onBindViewHolder(mHolder);
-
-        TextView syncTimeTextView = (TextView) mHolder.findViewById(android.R.id.title);
-        assertThat(syncTimeTextView.getText()).isEqualTo(SYNC_TIME);
-    }
-}
diff --git a/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryLegacyTest.java b/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryLegacyTest.java
new file mode 100644
index 0000000..ad1defb
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryLegacyTest.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.settings.datausage;
+
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.net.ConnectivityManager;
+import android.net.wifi.WifiConfiguration;
+import android.net.wifi.WifiManager;
+import android.text.format.Formatter;
+
+import com.android.settings.R;
+import com.android.settings.TestConfig;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.testutils.shadow.SettingsShadowResources;
+import com.android.settingslib.NetworkPolicyEditor;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.annotation.Config;
+import org.robolectric.shadows.ShadowApplication;
+import org.robolectric.util.ReflectionHelpers;
+
+import java.util.ArrayList;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class DataUsageSummaryLegacyTest {
+    @Mock
+    private ConnectivityManager mManager;
+    private Context mContext;
+
+    /**
+     * This set up is contrived to get a passing test so that the build doesn't block without tests.
+     * These tests should be updated as code gets refactored to improve testability.
+     */
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+        ShadowApplication shadowContext = ShadowApplication.getInstance();
+        shadowContext.setSystemService(Context.CONNECTIVITY_SERVICE, mManager);
+        mContext = shadowContext.getApplicationContext();
+        when(mManager.isNetworkSupported(anyInt())).thenReturn(true);
+    }
+
+    @Test
+    @Config(shadows = {
+            SettingsShadowResources.class,
+            SettingsShadowResources.SettingsShadowTheme.class
+    })
+    public void formatUsage_shouldLookLikeFormatFileSize() {
+        SettingsShadowResources.overrideResource(com.android.internal.R.string.fileSizeSuffix,
+                "%1$s %2$s");
+        final long usage = 2147483648L; // 2GB
+        final String formattedUsage =
+                DataUsageSummaryLegacy.formatUsage(mContext, "^1", usage).toString();
+        final String formattedAsFileSize = Formatter.formatFileSize(mContext, usage);
+        assertThat(formattedUsage).isEqualTo(formattedAsFileSize);
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceControllerTest.java
new file mode 100644
index 0000000..ea1d29b
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceControllerTest.java
@@ -0,0 +1,175 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.datausage;
+
+import android.content.Context;
+import android.content.Intent;
+import android.net.NetworkTemplate;
+
+import com.android.settings.R;
+import com.android.settings.TestConfig;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settingslib.NetworkPolicyEditor;
+import com.android.settingslib.net.DataUsageController;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+import java.util.concurrent.TimeUnit;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class DataUsageSummaryPreferenceControllerTest {
+    private static final long UPDATE_BACKOFF_MS = TimeUnit.MINUTES.toMillis(13);
+    private static final long CYCLE_BACKOFF_MS = TimeUnit.DAYS.toMillis(6);
+    private static final long CYCLE_LENGTH_MS = TimeUnit.DAYS.toMillis(30);
+    private static final long USAGE1 =  373000000L;
+    private static final long LIMIT1 = 1000000000L;
+    private static final String CARRIER_NAME = "z-mobile";
+    private static final String PERIOD = "Feb";
+
+    @Mock
+    private DataUsageController mDataUsageController;
+    @Mock
+    private DataUsageInfoController mDataInfoController;
+    @Mock
+    private DataUsageSummaryPreference mSummaryPreference;
+    @Mock
+    private NetworkPolicyEditor mPolicyEditor;
+    @Mock
+    private NetworkTemplate mNetworkTemplate;
+
+    private Context mContext;
+    private DataUsageSummaryPreferenceController mController;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+        mContext = RuntimeEnvironment.application;
+
+        mController = new DataUsageSummaryPreferenceController(
+                mContext,
+                mDataUsageController,
+                mDataInfoController,
+                mNetworkTemplate,
+                mPolicyEditor,
+                R.string.cell_data_template,
+                true,
+                null);
+    }
+
+    @Test
+    public void testSummaryUpdate_onePlan_basic() {
+        final long now = System.currentTimeMillis();
+        final DataUsageController.DataUsageInfo info = createTestDataUsageInfo(now);
+
+        final Intent intent = new Intent();
+
+        when(mDataUsageController.getDataUsageInfo()).thenReturn(info);
+        mController.setPlanValues(1 /* dataPlanCount */, LIMIT1, USAGE1);
+        mController.setCarrierValues(CARRIER_NAME, now - UPDATE_BACKOFF_MS, info.cycleEnd, intent);
+
+        mController.updateState(mSummaryPreference);
+        verify(mSummaryPreference).setLimitInfo(null);
+        verify(mSummaryPreference).setUsageInfo(info.cycleEnd, now - UPDATE_BACKOFF_MS,
+                CARRIER_NAME, 1 /* numPlans */, intent);
+        verify(mSummaryPreference).setChartEnabled(true);
+    }
+
+    @Test
+    public void testSummaryUpdate_noPlan_basic() {
+        final long now = System.currentTimeMillis();
+        final DataUsageController.DataUsageInfo info = createTestDataUsageInfo(now);
+
+        final Intent intent = new Intent();
+
+        when(mDataUsageController.getDataUsageInfo(any())).thenReturn(info);
+        mController.setPlanValues(0 /* dataPlanCount */, LIMIT1, USAGE1);
+        mController.setCarrierValues(CARRIER_NAME, now - UPDATE_BACKOFF_MS, info.cycleEnd, intent);
+
+        mController.updateState(mSummaryPreference);
+        verify(mSummaryPreference).setLimitInfo("500 MB Data warning / 1.00 GB Data limit");
+        verify(mSummaryPreference).setUsageInfo(info.cycleEnd, now - UPDATE_BACKOFF_MS,
+                CARRIER_NAME, 0 /* numPlans */, intent);
+        verify(mSummaryPreference).setChartEnabled(true);
+    }
+
+    @Test
+    public void testSummaryUpdate_noCarrier_basic() {
+        final long now = System.currentTimeMillis();
+        final DataUsageController.DataUsageInfo info = createTestDataUsageInfo(now);
+
+        when(mDataUsageController.getDataUsageInfo(any())).thenReturn(info);
+        mController.setPlanValues(0 /* dataPlanCount */, LIMIT1, USAGE1);
+        mController.setCarrierValues(null /* carrierName */, -1L /* snapshotTime */,
+                info.cycleEnd, null /* intent */);
+        mController.updateState(mSummaryPreference);
+
+        verify(mSummaryPreference).setLimitInfo("500 MB Data warning / 1.00 GB Data limit");
+        verify(mSummaryPreference).setUsageInfo(
+                info.cycleEnd,
+                -1L /* snapshotTime */,
+                null /* carrierName */,
+                0 /* numPlans */,
+                null /* launchIntent */);
+        verify(mSummaryPreference).setChartEnabled(true);
+    }
+
+    @Test
+    public void testSummaryUpdate_noPlanData_basic() {
+        final long now = System.currentTimeMillis();
+
+        final DataUsageController.DataUsageInfo info = createTestDataUsageInfo(now);
+
+        when(mDataUsageController.getDataUsageInfo(any())).thenReturn(info);
+        mController.setPlanValues(0 /* dataPlanCount */, -1L /* dataPlanSize */, USAGE1);
+        mController.setCarrierValues(null /* carrierName */, -1L /* snapshotTime */,
+                info.cycleEnd, null /* intent */);
+        mController.updateState(mSummaryPreference);
+
+        verify(mSummaryPreference).setLimitInfo("500 MB Data warning / 1.00 GB Data limit");
+        verify(mSummaryPreference).setUsageInfo(
+                info.cycleEnd,
+                -1L /* snapshotTime */,
+                null /* carrierName */,
+                0 /* numPlans */,
+                null /* launchIntent */);
+        verify(mSummaryPreference).setChartEnabled(false);
+    }
+
+    private DataUsageController.DataUsageInfo createTestDataUsageInfo(long now) {
+        DataUsageController.DataUsageInfo info = new DataUsageController.DataUsageInfo();
+        info.carrier = CARRIER_NAME;
+        info.period = PERIOD;
+        info.startDate = now;
+        info.limitLevel = LIMIT1;
+        info.warningLevel = LIMIT1 >> 1;
+        info.usageLevel = USAGE1;
+        info.cycleStart = now - CYCLE_BACKOFF_MS;
+        info.cycleEnd = info.cycleStart + CYCLE_LENGTH_MS;
+        return info;
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceTest.java b/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceTest.java
new file mode 100644
index 0000000..769d9e7
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceTest.java
@@ -0,0 +1,172 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.settings.datausage;
+
+import android.content.Context;
+import android.content.Intent;
+import android.support.v7.preference.PreferenceViewHolder;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.Button;
+import android.widget.TextView;
+
+import com.android.settings.R;
+import com.android.settings.TestConfig;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.testutils.shadow.SettingsShadowResourcesImpl;
+import com.android.settingslib.utils.StringUtil;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.spy;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION, shadows =
+        SettingsShadowResourcesImpl.class)
+public class DataUsageSummaryPreferenceTest {
+    private static final long CYCLE_DURATION_MILLIS = 1000000000L;
+    private static final long UPDATE_LAG_MILLIS = 10000000L;
+    private static final String DUMMY_CARRIER = "z-mobile";
+
+    private Context mContext;
+    private PreferenceViewHolder mHolder;
+    private DataUsageSummaryPreference mSummaryPreference;
+    private TextView mUsageTitle;
+    private TextView mCycleTime;
+    private TextView mCarrierInfo;
+    private TextView mDataLimits;
+    private Button mLaunchButton;
+
+    private long mCycleEnd;
+    private long mUpdateTime;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+        mContext = spy(RuntimeEnvironment.application);
+        mSummaryPreference = new DataUsageSummaryPreference(mContext, null /* attrs */);
+        LayoutInflater inflater = LayoutInflater.from(mContext);
+        View view = inflater.inflate(mSummaryPreference.getLayoutResource(), null /* root */,
+                false /* attachToRoot */);
+
+        mHolder = PreferenceViewHolder.createInstanceForTests(view);
+
+        final long now = System.currentTimeMillis();
+        mCycleEnd = now + CYCLE_DURATION_MILLIS;
+        mUpdateTime = now - UPDATE_LAG_MILLIS;
+    }
+
+    @Test
+    public void testSetUsageInfo_withLaunchIntent_launchButtonShown() {
+        mSummaryPreference.setUsageInfo(mCycleEnd, mUpdateTime, DUMMY_CARRIER, 0 /* numPlans */,
+                new Intent());
+
+        bindViewHolder();
+        assertThat(mLaunchButton.getVisibility()).isEqualTo(View.VISIBLE);
+    }
+
+    @Test
+    public void testSetUsageInfo_withoutLaunchIntent_launchButtonNotShown() {
+        mSummaryPreference.setUsageInfo(mCycleEnd, mUpdateTime, DUMMY_CARRIER, 0 /* numPlans */,
+                null /* launchIntent */);
+
+        bindViewHolder();
+        assertThat(mLaunchButton.getVisibility()).isEqualTo(View.GONE);
+    }
+
+    @Test
+    public void testSetUsageInfo_withDataPlans_carrierInfoShown() {
+        mSummaryPreference.setUsageInfo(mCycleEnd, mUpdateTime, DUMMY_CARRIER, 1 /* numPlans */,
+                new Intent());
+
+        bindViewHolder();
+        assertThat(mCarrierInfo.getVisibility()).isEqualTo(View.VISIBLE);
+    }
+
+    @Test
+    public void testSetUsageInfo_withNoDataPlans_carrierInfoNotShown() {
+        mSummaryPreference.setUsageInfo(mCycleEnd, mUpdateTime, DUMMY_CARRIER, 0 /* numPlans */,
+                new Intent());
+
+        bindViewHolder();
+        assertThat(mCarrierInfo.getVisibility()).isEqualTo(View.GONE);
+    }
+
+    @Test
+    public void testSetUsageInfo_withNoDataPlans_usageTitleNotShown() {
+        mSummaryPreference.setUsageInfo(mCycleEnd, mUpdateTime, DUMMY_CARRIER, 0 /* numPlans */,
+                new Intent());
+
+        bindViewHolder();
+        assertThat(mUsageTitle.getVisibility()).isEqualTo(View.GONE);
+    }
+
+    @Test
+    public void testSetUsageInfo_withMultipleDataPlans_usageTitleShown() {
+        mSummaryPreference.setUsageInfo(mCycleEnd, mUpdateTime, DUMMY_CARRIER, 2 /* numPlans */,
+                new Intent());
+
+        bindViewHolder();
+        assertThat(mUsageTitle.getVisibility()).isEqualTo(View.VISIBLE);
+    }
+
+    @Test
+    public void testSetUsageInfo_cycleRemainingTimeShown() {
+        mSummaryPreference.setUsageInfo(mCycleEnd, mUpdateTime, DUMMY_CARRIER, 0 /* numPlans */,
+                new Intent());
+        String cyclePrefix = StringUtil.formatElapsedTime(mContext, CYCLE_DURATION_MILLIS,
+                false /* withSeconds */).toString();
+        String text = mContext.getString(R.string.cycle_left_time_text, cyclePrefix);
+
+        bindViewHolder();
+        assertThat(mCycleTime.getVisibility()).isEqualTo(View.VISIBLE);
+        assertThat(mCycleTime.getText()).isEqualTo(text);
+    }
+
+    @Test
+    public void testSetLimitInfo_withLimitInfo_dataLimitsShown() {
+        final String limitText = "test limit text";
+        mSummaryPreference.setLimitInfo(limitText);
+
+        bindViewHolder();
+        assertThat(mDataLimits.getVisibility()).isEqualTo(View.VISIBLE);
+        assertThat(mDataLimits.getText()).isEqualTo(limitText);
+    }
+
+    @Test
+    public void testSetLimitInfo_withNullLimitInfo_dataLimitsNotShown() {
+        mSummaryPreference.setLimitInfo(null);
+
+        bindViewHolder();
+        assertThat(mDataLimits.getVisibility()).isEqualTo(View.GONE);
+    }
+
+    private void bindViewHolder() {
+        mSummaryPreference.onBindViewHolder(mHolder);
+        mUsageTitle = (TextView) mHolder.findViewById(R.id.usage_title);
+        mCycleTime = (TextView) mHolder.findViewById(R.id.cycle_left_time);
+        mCarrierInfo = (TextView) mHolder.findViewById(R.id.carrier_and_update);
+        mDataLimits = (TextView) mHolder.findViewById(R.id.data_limits);
+        mLaunchButton = (Button) mHolder.findViewById(R.id.launch_mdp_app_button);
+    }
+}
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/datausage/ManageDataPlansPreferenceTest.java b/tests/robotests/src/com/android/settings/datausage/ManageDataPlansPreferenceTest.java
deleted file mode 100644
index 6eff393..0000000
--- a/tests/robotests/src/com/android/settings/datausage/ManageDataPlansPreferenceTest.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-
-package com.android.settings.datausage;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import android.content.Context;
-import android.support.v7.preference.Preference;
-import android.support.v7.preference.PreferenceViewHolder;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.widget.Button;
-import android.widget.LinearLayout;
-import com.android.settings.R;
-import com.android.settings.TestConfig;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.robolectric.RuntimeEnvironment;
-import org.robolectric.annotation.Config;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
-public final class ManageDataPlansPreferenceTest {
-    private Preference mPreference;
-    private PreferenceViewHolder mHolder;
-    private Context mContext;
-
-    @Before
-    public void setUp() {
-        mContext = RuntimeEnvironment.application;
-        mPreference = new Preference(mContext);
-        mPreference.setLayoutResource(R.layout.manage_data_plans_preference);
-        LayoutInflater inflater = LayoutInflater.from(mContext);
-        View view = inflater.inflate(mPreference.getLayoutResource(),
-                new LinearLayout(mContext), false);
-        mHolder = PreferenceViewHolder.createInstanceForTests(view);
-    }
-
-    @Test
-    public void shouldRender_withData() {
-        mPreference.onBindViewHolder(mHolder);
-        Button managePlanButton = (Button) mHolder.findViewById(R.id.manage_data_plans);
-        assertThat(managePlanButton.getText())
-                .isEqualTo(mContext.getString(R.string.data_plan_usage_manage_plans_button_text));
-    }
-}
diff --git a/tests/robotests/src/com/android/settings/datetime/timezone/TimeZoneAdapterTest.java b/tests/robotests/src/com/android/settings/datetime/timezone/TimeZoneAdapterTest.java
index 5f29a0b..1377f1d 100644
--- a/tests/robotests/src/com/android/settings/datetime/timezone/TimeZoneAdapterTest.java
+++ b/tests/robotests/src/com/android/settings/datetime/timezone/TimeZoneAdapterTest.java
@@ -15,13 +15,18 @@
  */
 package com.android.settings.datetime.timezone;
 
+import android.content.Context;
 import android.icu.util.TimeZone;
+import android.provider.Settings;
 import android.text.TextUtils;
 import android.view.View;
 import android.widget.FrameLayout;
+
 import com.android.settings.TestConfig;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
 import com.android.settings.testutils.shadow.SettingsShadowResources;
+
+import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -29,8 +34,11 @@
 import org.mockito.MockitoAnnotations;
 import org.robolectric.RuntimeEnvironment;
 import org.robolectric.annotation.Config;
+import org.robolectric.annotation.Implementation;
+import org.robolectric.annotation.Implements;
 
 import java.util.Collections;
+import java.util.Locale;
 
 import static com.google.common.truth.Truth.assertThat;
 
@@ -38,17 +46,39 @@
 @Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
         shadows = {
                 SettingsShadowResources.class,
-                SettingsShadowResources.SettingsShadowTheme.class})
+                SettingsShadowResources.SettingsShadowTheme.class,
+                TimeZoneAdapterTest.ShadowDataFormat.class})
 public class TimeZoneAdapterTest {
     @Mock
     private View.OnClickListener mOnClickListener;
 
     private TimeZoneAdapter mTimeZoneAdapter;
 
+    private Context mContext;
+    private Locale mDefaultLocale;
+
     @Before
-    public void setUp() {
+    public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
-        mTimeZoneAdapter = new TimeZoneAdapter(mOnClickListener, RuntimeEnvironment.application);
+        mContext = RuntimeEnvironment.application;
+        mTimeZoneAdapter = new TimeZoneAdapter(mOnClickListener, mContext);
+        mDefaultLocale = Locale.getDefault();
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        Locale.setDefault(mDefaultLocale);
+    }
+
+    @Implements(android.text.format.DateFormat.class)
+    public static class ShadowDataFormat {
+
+        public static String mTimeFormatString = "";
+
+        @Implementation
+        public static String getTimeFormatString(Context context) {
+            return mTimeFormatString;
+        }
     }
 
     @Test
@@ -89,6 +119,38 @@
         assertThat(viewHolder.mDstView.getVisibility()).isEqualTo(View.GONE);
     }
 
+    @Test
+    public void bindViewHolder_on24Hour() {
+        Locale.setDefault(Locale.US);
+        ShadowDataFormat.mTimeFormatString = "HH:mm";
+        mTimeZoneAdapter = new TimeZoneAdapter(mOnClickListener, mContext);
+
+        final TimeZoneInfo tzi = dummyTimeZoneInfo(TimeZone.getTimeZone("Etc/UTC"));
+        mTimeZoneAdapter.setTimeZoneInfos(Collections.singletonList(tzi));
+
+        final FrameLayout parent = new FrameLayout(RuntimeEnvironment.application);
+
+        final ViewHolder viewHolder = (ViewHolder) mTimeZoneAdapter.createViewHolder(parent, TimeZoneAdapter.VIEW_TYPE_NORMAL);
+        mTimeZoneAdapter.bindViewHolder(viewHolder, 0);
+        assertThat(viewHolder.mTimeView.getText().toString()).hasLength(5);
+    }
+
+    @Test
+    public void bindViewHolder_on12Hour() {
+        Locale.setDefault(Locale.US);
+        ShadowDataFormat.mTimeFormatString = "hh:mm a";
+        mTimeZoneAdapter = new TimeZoneAdapter(mOnClickListener, mContext);
+
+        final TimeZoneInfo tzi = dummyTimeZoneInfo(TimeZone.getTimeZone("Etc/UTC"));
+        mTimeZoneAdapter.setTimeZoneInfos(Collections.singletonList(tzi));
+
+        final FrameLayout parent = new FrameLayout(RuntimeEnvironment.application);
+
+        final ViewHolder viewHolder = (ViewHolder) mTimeZoneAdapter.createViewHolder(parent, TimeZoneAdapter.VIEW_TYPE_NORMAL);
+        mTimeZoneAdapter.bindViewHolder(viewHolder, 0);
+        assertThat(viewHolder.mTimeView.getText().toString()).hasLength(8);
+    }
+
     // Pick an arbitrary time zone that's not the current default.
     private static TimeZone getNonDefaultTimeZone() {
         final String[] availableIDs = TimeZone.getAvailableIDs();
diff --git a/tests/robotests/src/com/android/settings/development/DevelopmentSettingsDashboardFragmentTest.java b/tests/robotests/src/com/android/settings/development/DevelopmentSettingsDashboardFragmentTest.java
index 881ee84..640e9d5 100644
--- a/tests/robotests/src/com/android/settings/development/DevelopmentSettingsDashboardFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/development/DevelopmentSettingsDashboardFragmentTest.java
@@ -17,7 +17,6 @@
 package com.android.settings.development;
 
 import static com.google.common.truth.Truth.assertThat;
-
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.spy;
@@ -33,6 +32,7 @@
 import com.android.settings.TestConfig;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
 import com.android.settings.testutils.shadow.SettingsShadowResources;
+import com.android.settings.testutils.shadow.ShadowUserManager;
 import com.android.settings.widget.SwitchBar;
 import com.android.settings.widget.ToggleSwitch;
 import com.android.settingslib.development.AbstractEnableAdbPreferenceController;
@@ -52,7 +52,9 @@
 import java.util.List;
 
 @RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION, shadows = {
+        ShadowUserManager.class
+})
 public class DevelopmentSettingsDashboardFragmentTest {
 
     private SwitchBar mSwitchBar;
@@ -68,11 +70,13 @@
         mSwitch = mSwitchBar.getSwitch();
         mDashboard = spy(new DevelopmentSettingsDashboardFragment());
         ReflectionHelpers.setField(mDashboard, "mSwitchBar", mSwitchBar);
+        ShadowUserManager.getShadow().setIsAdminUser(true);
     }
 
     @After
     public void tearDown() {
         ShadowEnableDevelopmentSettingWarningDialog.reset();
+        ShadowUserManager.getShadow().reset();
     }
 
     @Test
@@ -101,7 +105,7 @@
             SettingsShadowResources.class,
             SettingsShadowResources.SettingsShadowTheme.class
     })
-    public void searchIndex_pageDisabled_shouldAddAllKeysToNonIndexable() {
+    public void searchIndex_pageDisabledBySetting_shouldAddAllKeysToNonIndexable() {
         final Context appContext = RuntimeEnvironment.application;
         DevelopmentSettingsEnabler.setDevelopmentSettingsEnabled(appContext, false);
 
@@ -109,7 +113,24 @@
                 DevelopmentSettingsDashboardFragment.SEARCH_INDEX_DATA_PROVIDER
                         .getNonIndexableKeys(appContext);
 
-        assertThat(nonIndexableKeys).contains("development_prefs_screen");
+        assertThat(nonIndexableKeys).contains("enable_adb");
+    }
+
+    @Test
+    @Config(shadows = {
+            SettingsShadowResources.class,
+            SettingsShadowResources.SettingsShadowTheme.class
+    })
+    public void searchIndex_pageDisabledForNonAdmin_shouldAddAllKeysToNonIndexable() {
+        final Context appContext = RuntimeEnvironment.application;
+        DevelopmentSettingsEnabler.setDevelopmentSettingsEnabled(appContext, true);
+        ShadowUserManager.getShadow().setIsAdminUser(false);
+
+        final List<String> nonIndexableKeys =
+                DevelopmentSettingsDashboardFragment.SEARCH_INDEX_DATA_PROVIDER
+                        .getNonIndexableKeys(appContext);
+
+        assertThat(nonIndexableKeys).contains("enable_adb");
     }
 
     @Test
diff --git a/tests/robotests/src/com/android/settings/development/DevelopmentSwitchBarControllerTest.java b/tests/robotests/src/com/android/settings/development/DevelopmentSwitchBarControllerTest.java
index a5dfa56..95fd0dd 100644
--- a/tests/robotests/src/com/android/settings/development/DevelopmentSwitchBarControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/DevelopmentSwitchBarControllerTest.java
@@ -28,6 +28,7 @@
 
 import com.android.settings.TestConfig;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.testutils.shadow.ShadowUserManager;
 import com.android.settings.testutils.shadow.ShadowUtils;
 import com.android.settings.widget.SwitchBar;
 import com.android.settingslib.core.lifecycle.Lifecycle;
@@ -47,7 +48,8 @@
 @RunWith(SettingsRobolectricTestRunner.class)
 @Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
         shadows = {
-                ShadowUtils.class
+                ShadowUtils.class,
+                ShadowUserManager.class
         })
 public class DevelopmentSwitchBarControllerTest {
 
@@ -63,6 +65,7 @@
     public void setUp() {
         MockitoAnnotations.initMocks(this);
         mContext = RuntimeEnvironment.application;
+        ShadowUserManager.getShadow().setIsAdminUser(true);
         mLifecycleOwner = () -> mLifecycle;
         mLifecycle = new Lifecycle(mLifecycleOwner);
         mSwitchBar = new SwitchBar(mContext);
@@ -72,6 +75,7 @@
     @After
     public void tearDown() {
         ShadowUtils.reset();
+        ShadowUserManager.getShadow().reset();
     }
 
     @Test
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/BuildNumberPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/BuildNumberPreferenceControllerTest.java
index ee5d5d0..17122ae 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/BuildNumberPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/BuildNumberPreferenceControllerTest.java
@@ -43,6 +43,7 @@
 import com.android.settings.testutils.FakeFeatureFactory;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
 import com.android.settings.testutils.shadow.ShadowUtils;
+import com.android.settings.testutils.shadow.ShadowUserManager;
 import com.android.settingslib.core.lifecycle.Lifecycle;
 import com.android.settingslib.development.DevelopmentSettingsEnabler;
 
@@ -60,7 +61,8 @@
 @RunWith(SettingsRobolectricTestRunner.class)
 @Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
         shadows = {
-                ShadowUtils.class
+                ShadowUtils.class,
+                ShadowUserManager.class,
         })
 public class BuildNumberPreferenceControllerTest {
 
@@ -84,6 +86,7 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
+        ShadowUserManager.getShadow().setIsAdminUser(true);
         mFactory = FakeFeatureFactory.setupForTest();
         mLifecycleOwner = () -> mLifecycle;
         mLifecycle = new Lifecycle(mLifecycleOwner);
@@ -98,6 +101,7 @@
     @After
     public void tearDown() {
         ShadowUtils.reset();
+        ShadowUserManager.getShadow().reset();
     }
 
     @Test
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/MyDeviceInfoFragmentTest.java b/tests/robotests/src/com/android/settings/deviceinfo/MyDeviceInfoFragmentTest.java
index 36f0662..8b21b74 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/MyDeviceInfoFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/MyDeviceInfoFragmentTest.java
@@ -21,15 +21,18 @@
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
 import android.app.Activity;
 import android.content.Context;
+import android.content.Intent;
 import android.os.Bundle;
 import android.support.v7.preference.PreferenceScreen;
 import android.telephony.TelephonyManager;
+import android.util.ArrayMap;
 
 import com.android.settings.deviceinfo.aboutphone.MyDeviceInfoFragment;
 import com.android.settings.TestConfig;
@@ -39,6 +42,7 @@
 import com.android.settings.testutils.shadow.SettingsShadowSystemProperties;
 import com.android.settings.testutils.shadow.ShadowConnectivityManager;
 import com.android.settings.testutils.shadow.ShadowUserManager;
+import com.android.settingslib.core.AbstractPreferenceController;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -48,6 +52,11 @@
 import org.robolectric.RuntimeEnvironment;
 import org.robolectric.annotation.Config;
 import org.robolectric.shadows.ShadowApplication;
+import org.robolectric.util.ReflectionHelpers;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
 
 @RunWith(SettingsRobolectricTestRunner.class)
 @Config(
@@ -97,4 +106,23 @@
 
         verify(mScreen).setInitialExpandedChildrenCount(Integer.MAX_VALUE);
     }
+
+    @Test
+    public void onActivityResult_shouldCallBuildNumberPreferenceController() {
+        final BuildNumberPreferenceController controller =
+            mock(BuildNumberPreferenceController.class);
+        final Map<Class, List<AbstractPreferenceController>> preferenceControllers =
+            new ArrayMap<>();
+        final List<AbstractPreferenceController> controllerList = new ArrayList<>();
+        controllerList.add(controller);
+        preferenceControllers.put(BuildNumberPreferenceController.class, controllerList);
+        ReflectionHelpers.setField(mSettings, "mPreferenceControllers", preferenceControllers);
+
+        final int requestCode = 1;
+        final int resultCode = 2;
+        final Intent data = new Intent();
+        mSettings.onActivityResult(requestCode, resultCode, data);
+
+        verify(controller).onActivityResult(requestCode, resultCode, data);
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatteryAppListPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryAppListPreferenceControllerTest.java
index a814989..cee84de 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatteryAppListPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatteryAppListPreferenceControllerTest.java
@@ -220,4 +220,9 @@
 
         assertThat(mPreferenceController.isAvailable()).isFalse();
     }
+
+    @Test
+    public void testNeverUseFakeData() {
+        assertThat(BatteryAppListPreferenceController.USE_FAKE_DATA).isFalse();
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatteryDatabaseManagerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryDatabaseManagerTest.java
index ac8800e..92332f2 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatteryDatabaseManagerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatteryDatabaseManagerTest.java
@@ -24,6 +24,7 @@
 import android.text.format.DateUtils;
 
 import com.android.settings.TestConfig;
+import com.android.settings.fuelgauge.batterytip.AnomalyDatabaseHelper;
 import com.android.settings.fuelgauge.batterytip.AppInfo;
 import com.android.settings.fuelgauge.batterytip.BatteryDatabaseManager;
 import com.android.settings.testutils.DatabaseTestUtils;
@@ -37,6 +38,7 @@
 import org.robolectric.RuntimeEnvironment;
 import org.robolectric.annotation.Config;
 
+import java.util.ArrayList;
 import java.util.List;
 
 @RunWith(RobolectricTestRunner.class)
@@ -71,28 +73,54 @@
         mBatteryDatabaseManager.insertAnomaly(PACKAGE_NAME_OLD, TYPE_OLD, TWO_DAYS_BEFORE);
 
         // In database, it contains two record
-        List<AppInfo> totalAppInfos = mBatteryDatabaseManager.queryAllAnomaliesAfter(0);
+        List<AppInfo> totalAppInfos = mBatteryDatabaseManager.queryAllAnomalies(0 /* timeMsAfter */,
+                AnomalyDatabaseHelper.State.NEW);
         assertThat(totalAppInfos).hasSize(2);
-        verifyAppInfo(totalAppInfos.get(0), PACKAGE_NAME_NEW, TYPE_NEW);
-        verifyAppInfo(totalAppInfos.get(1), PACKAGE_NAME_OLD, TYPE_OLD);
+        assertAppInfo(totalAppInfos.get(0), PACKAGE_NAME_NEW, TYPE_NEW);
+        assertAppInfo(totalAppInfos.get(1), PACKAGE_NAME_OLD, TYPE_OLD);
 
         // Only one record shows up if we query by timestamp
-        List<AppInfo> appInfos = mBatteryDatabaseManager.queryAllAnomaliesAfter(ONE_DAY_BEFORE);
+        List<AppInfo> appInfos = mBatteryDatabaseManager.queryAllAnomalies(ONE_DAY_BEFORE,
+                AnomalyDatabaseHelper.State.NEW);
         assertThat(appInfos).hasSize(1);
-        verifyAppInfo(appInfos.get(0), PACKAGE_NAME_NEW, TYPE_NEW);
+        assertAppInfo(appInfos.get(0), PACKAGE_NAME_NEW, TYPE_NEW);
 
         mBatteryDatabaseManager.deleteAllAnomaliesBeforeTimeStamp(ONE_DAY_BEFORE);
 
         // The obsolete record is removed from database
-        List<AppInfo> appInfos1 = mBatteryDatabaseManager.queryAllAnomaliesAfter(0);
+        List<AppInfo> appInfos1 = mBatteryDatabaseManager.queryAllAnomalies(0 /* timeMsAfter */,
+                AnomalyDatabaseHelper.State.NEW);
         assertThat(appInfos1).hasSize(1);
-        verifyAppInfo(appInfos1.get(0), PACKAGE_NAME_NEW, TYPE_NEW);
-
+        assertAppInfo(appInfos1.get(0), PACKAGE_NAME_NEW, TYPE_NEW);
     }
 
-    private void verifyAppInfo(final AppInfo appInfo, String packageName, int type) {
+    @Test
+    public void testUpdateAnomalies_updateSuccessfully() {
+        mBatteryDatabaseManager.insertAnomaly(PACKAGE_NAME_NEW, TYPE_NEW, NOW);
+        mBatteryDatabaseManager.insertAnomaly(PACKAGE_NAME_OLD, TYPE_OLD, NOW);
+        final AppInfo appInfo = new AppInfo.Builder().setPackageName(PACKAGE_NAME_OLD).build();
+        final List<AppInfo> updateAppInfos = new ArrayList<>();
+        updateAppInfos.add(appInfo);
+
+        // Change state of PACKAGE_NAME_OLD to handled
+        mBatteryDatabaseManager.updateAnomalies(updateAppInfos,
+                AnomalyDatabaseHelper.State.HANDLED);
+
+        // The state of PACKAGE_NAME_NEW is still new
+        List<AppInfo> newAppInfos = mBatteryDatabaseManager.queryAllAnomalies(ONE_DAY_BEFORE,
+                AnomalyDatabaseHelper.State.NEW);
+        assertThat(newAppInfos).hasSize(1);
+        assertAppInfo(newAppInfos.get(0), PACKAGE_NAME_NEW, TYPE_NEW);
+
+        // The state of PACKAGE_NAME_OLD is changed to handled
+        List<AppInfo> handledAppInfos = mBatteryDatabaseManager.queryAllAnomalies(ONE_DAY_BEFORE,
+                AnomalyDatabaseHelper.State.HANDLED);
+        assertThat(handledAppInfos).hasSize(1);
+        assertAppInfo(handledAppInfos.get(0), PACKAGE_NAME_OLD, TYPE_OLD);
+    }
+
+    private void assertAppInfo(final AppInfo appInfo, String packageName, int type) {
         assertThat(appInfo.packageName).isEqualTo(packageName);
         assertThat(appInfo.anomalyType).isEqualTo(type);
     }
-
 }
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatteryInfoTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryInfoTest.java
index 70958a9..45edb47 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatteryInfoTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatteryInfoTest.java
@@ -43,6 +43,9 @@
 import com.android.settings.testutils.FakeFeatureFactory;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
 
+import com.android.settingslib.R;
+import com.android.settingslib.utils.PowerUtil;
+import java.time.Duration;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -72,6 +75,8 @@
     public static final long TEST_CHARGE_TIME_REMAINING = TimeUnit.MINUTES.toMicros(1);
     public static final String TEST_CHARGE_TIME_REMAINING_STRINGIFIED =
             "1m left until fully charged";
+    public static final String TEST_BATTERY_LEVEL_10 = "10%";
+    public static final String FIFTEEN_MIN_FORMATTED = "15m";
     private Intent mDisChargingBatteryBroadcast;
     private Intent mChargingBatteryBroadcast;
     private Context mContext;
@@ -134,13 +139,15 @@
     }
 
     @Test
-    public void testGetBatteryInfo_basedOnUsageTrue_usesCorrectString() {
+    public void testGetBatteryInfo_basedOnUsageTrueMoreThanFifteenMinutes_usesCorrectString() {
         BatteryInfo info = BatteryInfo.getBatteryInfo(mContext, mDisChargingBatteryBroadcast,
                 mBatteryStats, SystemClock.elapsedRealtime() * 1000, false /* shortString */,
-                1000, true /* basedOnUsage */);
+                PowerUtil.convertMsToUs(Duration.ofHours(4).toMillis()),
+                true /* basedOnUsage */);
         BatteryInfo info2 = BatteryInfo.getBatteryInfo(mContext, mDisChargingBatteryBroadcast,
                 mBatteryStats, SystemClock.elapsedRealtime() * 1000, true /* shortString */,
-                1000, true /* basedOnUsage */);
+                PowerUtil.convertMsToUs(Duration.ofHours(4).toMillis()),
+                true /* basedOnUsage */);
 
         // We only add special mention for the long string
         assertThat(info.remainingLabel.toString()).contains(ENHANCED_STRING_SUFFIX);
@@ -149,6 +156,41 @@
     }
 
     @Test
+    public void testGetBatteryInfo_basedOnUsageTrueLessThanSevenMinutes_usesCorrectString() {
+        BatteryInfo info = BatteryInfo.getBatteryInfo(mContext, mDisChargingBatteryBroadcast,
+                mBatteryStats, SystemClock.elapsedRealtime() * 1000, false /* shortString */,
+                PowerUtil.convertMsToUs(Duration.ofMinutes(7).toMillis()),
+                true /* basedOnUsage */);
+        BatteryInfo info2 = BatteryInfo.getBatteryInfo(mContext, mDisChargingBatteryBroadcast,
+                mBatteryStats, SystemClock.elapsedRealtime() * 1000, true /* shortString */,
+                PowerUtil.convertMsToUs(Duration.ofMinutes(7).toMillis()),
+                true /* basedOnUsage */);
+
+        // These should be identical in either case
+        assertThat(info.remainingLabel.toString()).isEqualTo(
+                mContext.getString(R.string.power_remaining_duration_only_shutdown_imminent));
+        assertThat(info2.remainingLabel.toString()).isEqualTo(
+                mContext.getString(R.string.power_remaining_duration_only_shutdown_imminent));
+    }
+
+    @Test
+    public void testGetBatteryInfo_basedOnUsageTrueBetweenSevenAndFifteenMinutes_usesCorrectString() {
+        BatteryInfo info = BatteryInfo.getBatteryInfo(mContext, mDisChargingBatteryBroadcast,
+                mBatteryStats, SystemClock.elapsedRealtime() * 1000, false /* shortString */,
+                PowerUtil.convertMsToUs(Duration.ofMinutes(10).toMillis()),
+                true /* basedOnUsage */);
+
+        // Check that strings are showing less than 15 minutes remaining regardless of exact time.
+        assertThat(info.chargeLabel.toString()).isEqualTo(
+                mContext.getString(R.string.power_remaining_less_than_duration,
+                        TEST_BATTERY_LEVEL_10, FIFTEEN_MIN_FORMATTED));
+        assertThat(info.remainingLabel.toString()).isEqualTo(
+                mContext.getString(R.string.power_remaining_less_than_duration_only,
+                        FIFTEEN_MIN_FORMATTED));
+    }
+
+
+    @Test
     public void testGetBatteryInfo_basedOnUsageFalse_usesDefaultString() {
         BatteryInfo info = BatteryInfo.getBatteryInfo(mContext, mDisChargingBatteryBroadcast,
                 mBatteryStats, SystemClock.elapsedRealtime() * 1000, false /* shortString */,
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatterySaverSettingsTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatterySaverSettingsTest.java
deleted file mode 100644
index 0e32f6b..0000000
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatterySaverSettingsTest.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.settings.fuelgauge;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import android.content.Context;
-import android.provider.SearchIndexableResource;
-
-import com.android.settings.R;
-import com.android.settings.TestConfig;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settings.widget.SwitchBar;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.RuntimeEnvironment;
-import org.robolectric.annotation.Config;
-
-import java.util.List;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
-public class BatterySaverSettingsTest {
-    private Context mContext;
-    private BatterySaverSettings mBatterySaverSettings;
-
-    @Before
-    public void setUp() {
-        MockitoAnnotations.initMocks(this);
-
-        mContext = RuntimeEnvironment.application;
-        mBatterySaverSettings = new BatterySaverSettings();
-        mBatterySaverSettings.mSwitchBar = new SwitchBar(mContext);
-    }
-
-    @Test
-    public void testOnBatteryChanged_pluggedIn_setDisable() {
-        mBatterySaverSettings.onBatteryChanged(true /* pluggedIn */);
-
-        assertThat(mBatterySaverSettings.mSwitchBar.isEnabled()).isFalse();
-    }
-
-    @Test
-    public void testOnBatteryChanged_notPluggedIn_setEnable() {
-        mBatterySaverSettings.onBatteryChanged(false /* pluggedIn */);
-
-        assertThat(mBatterySaverSettings.mSwitchBar.isEnabled()).isTrue();
-    }
-
-    @Test
-    public void searchProvider_shouldIndexDefaultXml() {
-        final List<SearchIndexableResource> sir = mBatterySaverSettings.SEARCH_INDEX_DATA_PROVIDER
-                .getXmlResourcesToIndex(mContext, true /* enabled */);
-
-        assertThat(sir).hasSize(1);
-        assertThat(sir.get(0).xmlResId).isEqualTo(R.xml.battery_saver_settings);
-    }
-}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryLegacyTest.java b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryLegacyTest.java
index e707ede..a3786c2 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryLegacyTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryLegacyTest.java
@@ -55,7 +55,6 @@
 import com.android.settings.R;
 import com.android.settings.SettingsActivity;
 import com.android.settings.TestConfig;
-import com.android.settings.Utils;
 import com.android.settings.applications.LayoutPreference;
 import com.android.settings.fuelgauge.anomaly.Anomaly;
 import com.android.settings.fuelgauge.anomaly.AnomalyDetectionPolicy;
@@ -65,6 +64,7 @@
 import com.android.settings.testutils.shadow.SettingsShadowResources;
 import com.android.settingslib.core.AbstractPreferenceController;
 
+import com.android.settingslib.utils.StringUtil;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -367,8 +367,8 @@
     public void testUpdateScreenPreference_showCorrectSummary() {
         doReturn(mScreenBatterySipper).when(mFragment).findBatterySipperByType(any(), any());
         doReturn(mRealContext).when(mFragment).getContext();
-        final CharSequence expectedSummary = Utils.formatElapsedTime(mRealContext, USAGE_TIME_MS,
-                false);
+        final CharSequence expectedSummary =
+            StringUtil.formatElapsedTime(mRealContext, USAGE_TIME_MS, false);
 
         mFragment.updateScreenPreference();
 
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryTest.java b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryTest.java
index 35af8bb..32e2b0b 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryTest.java
@@ -15,8 +15,6 @@
  */
 package com.android.settings.fuelgauge;
 
-import static com.android.settings.fuelgauge.PowerUsageSummary.MENU_HIGH_POWER_APPS;
-
 import static com.google.common.truth.Truth.assertThat;
 
 import static org.mockito.Matchers.any;
@@ -108,14 +106,6 @@
 
     @Mock(answer = Answers.RETURNS_DEEP_STUBS)
     private Context mContext;
-    @Mock(answer = Answers.RETURNS_DEEP_STUBS)
-    private Menu mMenu;
-    @Mock
-    private MenuItem mToggleAppsMenu;
-    @Mock
-    private MenuItem mHighPowerMenu;
-    @Mock
-    private MenuInflater mMenuInflater;
     @Mock
     private BatterySipper mNormalBatterySipper;
     @Mock
@@ -169,7 +159,6 @@
         doReturn(mock(LoaderManager.class)).when(mFragment).getLoaderManager();
 
         when(mFragment.getActivity()).thenReturn(mSettingsActivity);
-        when(mHighPowerMenu.getItemId()).thenReturn(MENU_HIGH_POWER_APPS);
         when(mFeatureFactory.powerUsageFeatureProvider.getAdditionalBatteryInfoIntent())
                 .thenReturn(sAdditionalBatteryInfoIntent);
         when(mBatteryHelper.getTotalPower()).thenReturn(TOTAL_POWER);
@@ -205,14 +194,6 @@
     }
 
     @Test
-    public void testOptionsMenu_menuHighPower_metricEventInvoked() {
-        mFragment.onOptionsItemSelected(mHighPowerMenu);
-
-        verify(mFeatureFactory.metricsFeatureProvider).action(mContext,
-                MetricsProto.MetricsEvent.ACTION_SETTINGS_MENU_BATTERY_OPTIMIZATION);
-    }
-
-    @Test
     public void testUpdateLastFullChargePreference_showCorrectSummary() {
         doReturn(mRealContext).when(mFragment).getContext();
 
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/AutoBatterySaverPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/AutoBatterySaverPreferenceControllerTest.java
new file mode 100644
index 0000000..cabcdcf
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/AutoBatterySaverPreferenceControllerTest.java
@@ -0,0 +1,87 @@
+/*
+ * 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.fuelgauge.batterysaver;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+import android.provider.Settings;
+import android.support.v14.preference.SwitchPreference;
+
+import com.android.settings.TestConfig;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class AutoBatterySaverPreferenceControllerTest {
+
+    private AutoBatterySaverPreferenceController mController;
+    private Context mContext;
+    private SwitchPreference mPreference;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+
+        mContext = RuntimeEnvironment.application;
+        mPreference = new SwitchPreference(mContext);
+        mController = new AutoBatterySaverPreferenceController(mContext);
+    }
+
+    @Test
+    public void testUpdateState_lowPowerLevelZero_preferenceNotChecked() {
+        Settings.Global.putInt(mContext.getContentResolver(),
+                Settings.Global.LOW_POWER_MODE_TRIGGER_LEVEL, 0);
+        mController.updateState(mPreference);
+
+        assertThat(mPreference.isChecked()).isFalse();
+    }
+
+    @Test
+    public void testUpdateState_lowPowerLevelZero_preferenceChecked() {
+        Settings.Global.putInt(mContext.getContentResolver(),
+                Settings.Global.LOW_POWER_MODE_TRIGGER_LEVEL, 15);
+        mController.updateState(mPreference);
+
+        assertThat(mPreference.isChecked()).isTrue();
+    }
+
+    @Test
+    public void testOnPreferenceChange_turnOn_setValueNotZero() {
+        mController.onPreferenceChange(mPreference, true);
+
+        assertThat(Settings.Global.getInt(mContext.getContentResolver(),
+                Settings.Global.LOW_POWER_MODE_TRIGGER_LEVEL, 0)).isNotEqualTo(0);
+    }
+
+    @Test
+    public void testOnPreferenceChange_turnOff_setValueZero() {
+        mController.onPreferenceChange(mPreference, false);
+
+        assertThat(Settings.Global.getInt(mContext.getContentResolver(),
+                Settings.Global.LOW_POWER_MODE_TRIGGER_LEVEL, 0)).isEqualTo(0);
+    }
+
+}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/AutoBatterySeekBarPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/AutoBatterySeekBarPreferenceControllerTest.java
new file mode 100644
index 0000000..32a4fac
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/AutoBatterySeekBarPreferenceControllerTest.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.fuelgauge.batterysaver;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.arch.lifecycle.LifecycleOwner;
+import android.content.Context;
+import android.provider.Settings;
+import android.support.v14.preference.SwitchPreference;
+
+import com.android.settings.TestConfig;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.widget.SeekBarPreference;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class AutoBatterySeekBarPreferenceControllerTest {
+    private static final int TRIGGER_LEVEL = 15;
+
+    private AutoBatterySeekBarPreferenceController mController;
+    private Context mContext;
+    private SeekBarPreference mPreference;
+    private Lifecycle mLifecycle;
+    private LifecycleOwner mLifecycleOwner;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+        mLifecycleOwner = () -> mLifecycle;
+        mLifecycle = new Lifecycle(mLifecycleOwner);
+
+        mContext = RuntimeEnvironment.application;
+        mPreference = new SeekBarPreference(mContext);
+        mPreference.setMax(100);
+        mController = new AutoBatterySeekBarPreferenceController(mContext, mLifecycle);
+    }
+
+    @Test
+    public void testPreference_lowPowerLevelZero_preferenceInvisible() {
+        Settings.Global.putInt(mContext.getContentResolver(),
+                Settings.Global.LOW_POWER_MODE_TRIGGER_LEVEL, 0);
+
+        mController.updateState(mPreference);
+
+        assertThat(mPreference.isVisible()).isFalse();
+    }
+
+    @Test
+    public void testPreference_lowPowerLevelNotZero_updatePreference() {
+        Settings.Global.putInt(mContext.getContentResolver(),
+                Settings.Global.LOW_POWER_MODE_TRIGGER_LEVEL, TRIGGER_LEVEL);
+        mController.updateState(mPreference);
+
+        assertThat(mPreference.isVisible()).isTrue();
+        assertThat(mPreference.getTitle()).isEqualTo("Turn on automatically at 15%");
+        assertThat(mPreference.getProgress()).isEqualTo(TRIGGER_LEVEL);
+    }
+
+    @Test
+    public void testOnPreferenceChange_updateValue() {
+        Settings.Global.putInt(mContext.getContentResolver(),
+                Settings.Global.LOW_POWER_MODE_TRIGGER_LEVEL, 0);
+
+        mController.onPreferenceChange(mPreference, TRIGGER_LEVEL);
+
+        assertThat(Settings.Global.getInt(mContext.getContentResolver(),
+                Settings.Global.LOW_POWER_MODE_TRIGGER_LEVEL, 0)).isEqualTo(TRIGGER_LEVEL);
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceControllerTest.java
new file mode 100644
index 0000000..29f924f
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceControllerTest.java
@@ -0,0 +1,121 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package com.android.settings.fuelgauge.batterysaver;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+
+import android.arch.lifecycle.LifecycleOwner;
+import android.content.Context;
+import android.os.PowerManager;
+import android.support.v7.preference.PreferenceScreen;
+import android.view.View;
+import android.widget.Button;
+
+import com.android.settings.R;
+import com.android.settings.TestConfig;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.widget.TwoStateButtonPreference;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.Shadows;
+import org.robolectric.annotation.Config;
+import org.robolectric.shadows.ShadowPowerManager;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
+        shadows = com.android.settings.testutils.shadow.ShadowPowerManager.class)
+public class BatterySaverButtonPreferenceControllerTest {
+    private BatterySaverButtonPreferenceController mController;
+    private Context mContext;
+    private Lifecycle mLifecycle;
+    private LifecycleOwner mLifecycleOwner;
+    private Button mButtonOn;
+    private Button mButtonOff;
+    private ShadowPowerManager mShadowPowerManager;
+    @Mock
+    private TwoStateButtonPreference mPreference;
+    @Mock
+    private PreferenceScreen mPreferenceScreen;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+
+        mLifecycleOwner = () -> mLifecycle;
+        mLifecycle = new Lifecycle(mLifecycleOwner);
+        mContext = spy(RuntimeEnvironment.application);
+        PowerManager powerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
+        mShadowPowerManager = Shadows.shadowOf(powerManager);
+        doReturn(mPreference).when(mPreferenceScreen).findPreference(anyString());
+
+        mButtonOn = new Button(mContext);
+        mButtonOn.setId(R.id.state_on_button);
+        doReturn(mButtonOn).when(mPreference).getStateOnButton();
+        mButtonOff = new Button(mContext);
+        mButtonOff.setId(R.id.state_off_button);
+        doReturn(mButtonOff).when(mPreference).getStateOffButton();
+
+        mController = new BatterySaverButtonPreferenceController(mContext, mLifecycle);
+        mController.displayPreference(mPreferenceScreen);
+    }
+
+    @Test
+    public void testUpdateState_lowPowerOn_displayButtonOff() {
+        mShadowPowerManager.setIsPowerSaveMode(true);
+
+        mController.updateState(mPreference);
+
+        assertThat(mButtonOn.getVisibility()).isEqualTo(View.GONE);
+        assertThat(mButtonOff.getVisibility()).isEqualTo(View.VISIBLE);
+    }
+
+    @Test
+    public void testUpdateState_lowPowerOff_displayButtonOn() {
+        mShadowPowerManager.setIsPowerSaveMode(false);
+
+        mController.updateState(mPreference);
+
+        assertThat(mButtonOn.getVisibility()).isEqualTo(View.VISIBLE);
+        assertThat(mButtonOff.getVisibility()).isEqualTo(View.GONE);
+    }
+
+    @Test
+    public void testOnClick_clickButtonOn_setPowerSaveMode() {
+        mController.onClick(mButtonOn);
+
+        assertThat(mShadowPowerManager.isPowerSaveMode()).isTrue();
+    }
+
+    @Test
+    public void testOnClick_clickButtonOff_clearPowerSaveMode() {
+        mController.onClick(mButtonOff);
+
+        assertThat(mShadowPowerManager.isPowerSaveMode()).isFalse();
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/actions/RestrictAppActionTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/actions/RestrictAppActionTest.java
index 47785d5..728bbff 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/actions/RestrictAppActionTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/actions/RestrictAppActionTest.java
@@ -27,8 +27,10 @@
 import com.android.settings.fuelgauge.batterytip.AppInfo;
 import com.android.settings.fuelgauge.batterytip.tips.BatteryTip;
 import com.android.settings.fuelgauge.batterytip.tips.RestrictAppTip;
+import com.android.settings.testutils.DatabaseTestUtils;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
 
+import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -69,6 +71,11 @@
         mRestrictAppAction.mBatteryUtils = mBatteryUtils;
     }
 
+    @After
+    public void cleanUp() {
+        DatabaseTestUtils.clearDb(mContext);
+    }
+
     @Test
     public void testHandlePositiveAction() {
         mRestrictAppAction.handlePositiveAction();
@@ -79,5 +86,4 @@
                 eq(AppOpsManager.MODE_IGNORED));
     }
 
-
 }
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/detectors/RestrictAppDetectorTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/detectors/RestrictAppDetectorTest.java
new file mode 100644
index 0000000..6a25c6d
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/detectors/RestrictAppDetectorTest.java
@@ -0,0 +1,113 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.fuelgauge.batterytip.detectors;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Matchers.anyLong;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.spy;
+
+import android.content.Context;
+
+import com.android.settings.TestConfig;
+import com.android.settings.fuelgauge.batterytip.AnomalyDatabaseHelper;
+import com.android.settings.fuelgauge.batterytip.AppInfo;
+import com.android.settings.fuelgauge.batterytip.BatteryDatabaseManager;
+import com.android.settings.fuelgauge.batterytip.BatteryTipPolicy;
+import com.android.settings.fuelgauge.batterytip.tips.BatteryTip;
+import com.android.settings.testutils.DatabaseTestUtils;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class RestrictAppDetectorTest {
+    private static final String PACKAGE_NAME = "com.android.app";
+    private Context mContext;
+    private BatteryTipPolicy mPolicy;
+    private RestrictAppDetector mRestrictAppDetector;
+    private List<AppInfo> mAppInfoList;
+    @Mock
+    private BatteryDatabaseManager mBatteryDatabaseManager;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+
+        mAppInfoList = new ArrayList<>();
+        mAppInfoList.add(new AppInfo.Builder()
+                .setPackageName(PACKAGE_NAME)
+                .build());
+
+        mContext = RuntimeEnvironment.application;
+        mPolicy = spy(new BatteryTipPolicy(mContext));
+        mRestrictAppDetector = new RestrictAppDetector(mContext, mPolicy);
+        mRestrictAppDetector.mBatteryDatabaseManager = mBatteryDatabaseManager;
+    }
+
+    @After
+    public void cleanUp() {
+        DatabaseTestUtils.clearDb(mContext);
+    }
+
+    @Test
+    public void testDetect_hasAnomaly_tipNew() {
+        doReturn(mAppInfoList).when(mBatteryDatabaseManager).queryAllAnomalies(anyLong(),
+                eq(AnomalyDatabaseHelper.State.NEW));
+
+        assertThat(mRestrictAppDetector.detect().getState()).isEqualTo(BatteryTip.StateType.NEW);
+    }
+
+    @Test
+    public void testDetect_hasAutoHandledAnomaly_tipHandled() {
+        doReturn(new ArrayList<AppInfo>()).when(mBatteryDatabaseManager).queryAllAnomalies(
+                anyLong(), eq(AnomalyDatabaseHelper.State.NEW));
+        doReturn(mAppInfoList).when(mBatteryDatabaseManager).queryAllAnomalies(anyLong(),
+                eq(AnomalyDatabaseHelper.State.AUTO_HANDLED));
+
+        assertThat(mRestrictAppDetector.detect().getState()).isEqualTo(
+                BatteryTip.StateType.HANDLED);
+    }
+
+    @Test
+    public void testDetect_noAnomaly_tipInvisible() {
+        doReturn(new ArrayList<AppInfo>()).when(mBatteryDatabaseManager).queryAllAnomalies(
+                anyLong(), anyInt());
+
+        assertThat(mRestrictAppDetector.detect().getState()).isEqualTo(
+                BatteryTip.StateType.INVISIBLE);
+    }
+
+    @Test
+    public void testUseFakeData_alwaysFalse() {
+        assertThat(RestrictAppDetector.USE_FAKE_DATA).isFalse();
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/tips/RestrictAppTipTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/tips/RestrictAppTipTest.java
index e1dea17..74536a5 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/tips/RestrictAppTipTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/tips/RestrictAppTipTest.java
@@ -49,6 +49,7 @@
     private Context mContext;
     private RestrictAppTip mNewBatteryTip;
     private RestrictAppTip mHandledBatteryTip;
+    private RestrictAppTip mInvisibleBatteryTip;
     private List<AppInfo> mUsageAppList;
     @Mock
     private ApplicationInfo mApplicationInfo;
@@ -71,6 +72,7 @@
                 .build());
         mNewBatteryTip = new RestrictAppTip(BatteryTip.StateType.NEW, mUsageAppList);
         mHandledBatteryTip = new RestrictAppTip(BatteryTip.StateType.HANDLED, mUsageAppList);
+        mInvisibleBatteryTip = new RestrictAppTip(BatteryTip.StateType.INVISIBLE, mUsageAppList);
     }
 
     @Test
@@ -108,4 +110,20 @@
         assertThat(mHandledBatteryTip.getSummary(mContext)).isEqualTo(
                 "App changes are in progress");
     }
+
+    @Test
+    public void testUpdate_anomalyBecomeInvisible_stateHandled() {
+        mNewBatteryTip.updateState(mInvisibleBatteryTip);
+
+        assertThat(mNewBatteryTip.getState()).isEqualTo(BatteryTip.StateType.HANDLED);
+    }
+
+    @Test
+    public void testUpdate_newAnomalyComes_stateNew() {
+        mInvisibleBatteryTip.updateState(mNewBatteryTip);
+        assertThat(mInvisibleBatteryTip.getState()).isEqualTo(BatteryTip.StateType.NEW);
+
+        mHandledBatteryTip.updateState(mNewBatteryTip);
+        assertThat(mHandledBatteryTip.getState()).isEqualTo(BatteryTip.StateType.NEW);
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/gestures/DoubleTapScreenPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/DoubleTapScreenPreferenceControllerTest.java
index 8f06c40..74e1e5d 100644
--- a/tests/robotests/src/com/android/settings/gestures/DoubleTapScreenPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/DoubleTapScreenPreferenceControllerTest.java
@@ -161,4 +161,16 @@
         assertThat(DoubleTapScreenPreferenceController.isSuggestionComplete(
                 mAmbientDisplayConfiguration, prefs)).isTrue();
     }
+
+    @Test
+    public void canHandleClicks_falseWhenAlwaysOnEnabled() {
+        when(mAmbientDisplayConfiguration.alwaysOnEnabled(anyInt())).thenReturn(true);
+        assertThat(mController.canHandleClicks()).isFalse();
+    }
+
+    @Test
+    public void canHandleClicks_trueWhenAlwaysOnDisabled() {
+        when(mAmbientDisplayConfiguration.alwaysOnEnabled(anyInt())).thenReturn(false);
+        assertThat(mController.canHandleClicks()).isTrue();
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/notification/VisibilityPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/VisibilityPreferenceControllerTest.java
index 25dba80..d3863db 100644
--- a/tests/robotests/src/com/android/settings/notification/VisibilityPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/VisibilityPreferenceControllerTest.java
@@ -16,6 +16,7 @@
 
 package com.android.settings.notification;
 
+import static android.app.Notification.VISIBILITY_PRIVATE;
 import static android.app.NotificationChannel.DEFAULT_CHANNEL_ID;
 import static android.app.NotificationManager.IMPORTANCE_DEFAULT;
 import static android.app.NotificationManager.IMPORTANCE_MIN;
@@ -114,14 +115,14 @@
     }
 
     @Test
-    public void testNoCrashIfNoOnResume() throws Exception {
+    public void testNoCrashIfNoOnResume() {
         mController.isAvailable();
         mController.updateState(mock(RestrictedListPreference.class));
         mController.onPreferenceChange(mock(RestrictedListPreference.class), true);
     }
 
     @Test
-    public void testIsAvailable_notSecure() throws Exception {
+    public void testIsAvailable_notSecure() {
         when(mLockUtils.isSecure(anyInt())).thenReturn(false);
         NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
         NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
@@ -130,7 +131,7 @@
     }
 
     @Test
-    public void testIsAvailable_notIfNotImportant() throws Exception {
+    public void testIsAvailable_notIfNotImportant() {
         NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
         NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_MIN);
         mController.onResume(appRow, channel, null, null);
@@ -138,7 +139,7 @@
     }
 
     @Test
-    public void testIsAvailable() throws Exception {
+    public void testIsAvailable() {
         NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
         NotificationChannel channel =
                 new NotificationChannel(DEFAULT_CHANNEL_ID, "", IMPORTANCE_DEFAULT);
@@ -151,7 +152,7 @@
     }
 
     @Test
-    public void testUpdateState_disabledByAdmin_disableSecure() throws Exception {
+    public void testUpdateState_disabledByAdmin_disableSecure() {
         ShadowRestrictionUtils.setRestricted(true);
         UserInfo userInfo = new UserInfo(2, "user 2", UserInfo.FLAG_MANAGED_PROFILE);
         when(mUm.getUserInfo(anyInt())).thenReturn(userInfo);
@@ -173,7 +174,7 @@
     }
 
     @Test
-    public void testUpdateState_disabledByAdmin_disableUnredacted() throws Exception {
+    public void testUpdateState_disabledByAdmin_disableUnredacted() {
         ShadowRestrictionUtils.setRestricted(true);
         UserInfo userInfo = new UserInfo(2, "user 2", UserInfo.FLAG_MANAGED_PROFILE);
         when(mUm.getUserInfo(anyInt())).thenReturn(userInfo);
@@ -195,7 +196,7 @@
     }
 
     @Test
-    public void testUpdateState_noLockScreenNotificationsGlobally() throws Exception {
+    public void testUpdateState_noLockScreenNotificationsGlobally() {
         Settings.Secure.putInt(mContext.getContentResolver(),
                 Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 0);
 
@@ -211,10 +212,14 @@
         verify(pref, times(1)).setEntryValues(argumentCaptor.capture());
         assertFalse(toStringList(argumentCaptor.getValue())
                 .contains(String.valueOf(VISIBILITY_NO_OVERRIDE)));
+        assertFalse(toStringList(argumentCaptor.getValue())
+                .contains(String.valueOf(VISIBILITY_PRIVATE)));
     }
 
     @Test
-    public void testUpdateState_noPrivateLockScreenNotificationsGlobally() throws Exception {
+    public void testUpdateState_noPrivateLockScreenNotificationsGlobally() {
+        Settings.Secure.putInt(mContext.getContentResolver(),
+                Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, 1);
         Settings.Secure.putInt(mContext.getContentResolver(),
                 Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0);
 
@@ -228,12 +233,13 @@
         ArgumentCaptor<CharSequence[]> argumentCaptor =
             ArgumentCaptor.forClass(CharSequence[].class);
         verify(pref, times(1)).setEntryValues(argumentCaptor.capture());
+        assertEquals(2, toStringList(argumentCaptor.getValue()).size());
         assertFalse(toStringList(argumentCaptor.getValue())
                 .contains(String.valueOf(VISIBILITY_NO_OVERRIDE)));
     }
 
     @Test
-    public void testUpdateState_noGlobalRestriction() throws Exception {
+    public void testUpdateState_noGlobalRestriction() {
         NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
         NotificationChannel channel = mock(NotificationChannel.class);
         mController.onResume(appRow, channel, null, null);
@@ -247,7 +253,7 @@
         List<String> values = toStringList(argumentCaptor.getValue());
         assertEquals(3, values.size());
         assertTrue(values.contains(String.valueOf(VISIBILITY_NO_OVERRIDE)));
-        assertTrue(values.contains(String.valueOf(Notification.VISIBILITY_PRIVATE)));
+        assertTrue(values.contains(String.valueOf(VISIBILITY_PRIVATE)));
         assertTrue(values.contains(String.valueOf(Notification.VISIBILITY_SECRET)));
     }
 
@@ -260,7 +266,7 @@
     }
 
     @Test
-    public void testUpdateState_noChannelOverride() throws Exception {
+    public void testUpdateState_noChannelOverride() {
         Settings.Secure.putInt(mContext.getContentResolver(),
                 Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0);
 
@@ -275,11 +281,11 @@
         ArgumentCaptor<String> argumentCaptor = ArgumentCaptor.forClass(String.class);
         verify(pref, times(1)).setValue(argumentCaptor.capture());
 
-        assertEquals(String.valueOf(Notification.VISIBILITY_PRIVATE), argumentCaptor.getValue());
+        assertEquals(String.valueOf(VISIBILITY_PRIVATE), argumentCaptor.getValue());
     }
 
     @Test
-    public void testUpdateState_channelOverride() throws Exception {
+    public void testUpdateState_channelOverride() {
         Settings.Secure.putInt(mContext.getContentResolver(),
                 Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, 0);
 
@@ -310,7 +316,7 @@
         RestrictedListPreference pref = mock(RestrictedListPreference.class);
         mController.updateState(pref);
 
-        mController.onPreferenceChange(pref, String.valueOf(Notification.VISIBILITY_PRIVATE));
+        mController.onPreferenceChange(pref, String.valueOf(VISIBILITY_PRIVATE));
 
         assertEquals(VISIBILITY_NO_OVERRIDE, channel.getLockscreenVisibility());
         verify(mBackend, times(1)).updateChannel(any(), anyInt(), any());
diff --git a/tests/robotests/src/com/android/settings/print/PrintSettingsFragmentTest.java b/tests/robotests/src/com/android/settings/print/PrintSettingsFragmentTest.java
deleted file mode 100644
index cf34f45..0000000
--- a/tests/robotests/src/com/android/settings/print/PrintSettingsFragmentTest.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.print;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.app.Activity;
-import android.content.res.Resources;
-import android.print.PrintJob;
-import android.print.PrintJobInfo;
-import android.print.PrintManager;
-import android.printservice.PrintServiceInfo;
-
-import com.android.settings.R;
-import com.android.settings.TestConfig;
-import com.android.settings.dashboard.SummaryLoader;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.annotation.Config;
-
-import java.util.ArrayList;
-import java.util.List;
-
-
-@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
-public class PrintSettingsFragmentTest {
-
-    @Mock
-    private PrintSettingsFragment.PrintSummaryProvider.PrintManagerWrapper mPrintManager;
-    @Mock
-    private Activity mActivity;
-    @Mock
-    private Resources mRes;
-    @Mock
-    private SummaryLoader mSummaryLoader;
-    private SummaryLoader.SummaryProvider mSummaryProvider;
-
-    @Before
-    public void setUp() {
-        MockitoAnnotations.initMocks(this);
-        when(mActivity.getResources()).thenReturn(mRes);
-        mSummaryProvider = new PrintSettingsFragment.PrintSummaryProvider(mActivity, mSummaryLoader,
-                mPrintManager);
-    }
-
-    @Test
-    public void testSummary_hasActiveJob_shouldSetSummaryToNumberOfJobs() {
-        final List<PrintJob> printJobs = new ArrayList<>();
-        final PrintJob job = mock(PrintJob.class, Mockito.RETURNS_DEEP_STUBS);
-        printJobs.add(job);
-        when(job.getInfo().getState()).thenReturn(PrintJobInfo.STATE_STARTED);
-        when(mPrintManager.getPrintJobs()).thenReturn(printJobs);
-
-        mSummaryProvider.setListening(true);
-
-        verify(mRes).getQuantityString(R.plurals.print_jobs_summary, 1, 1);
-    }
-
-    @Test
-    public void testSummary_shouldSetSummaryToNumberOfPrintServices() {
-        final List<PrintServiceInfo> printServices = mock(List.class);
-        when(printServices.isEmpty()).thenReturn(false);
-        when(printServices.size()).thenReturn(2);
-        // 2 services
-        when(mPrintManager.getPrintServices(PrintManager.ENABLED_SERVICES))
-                .thenReturn(printServices);
-
-        mSummaryProvider.setListening(true);
-
-        verify(mRes).getQuantityString(R.plurals.print_settings_summary, 2, 2);
-
-        // No service
-        when(mPrintManager.getPrintServices(PrintManager.ENABLED_SERVICES)).thenReturn(null);
-
-        mSummaryProvider.setListening(true);
-
-        verify(mActivity).getString(R.string.print_settings_summary_no_service);
-    }
-}
diff --git a/tests/robotests/src/com/android/settings/print/PrintSettingsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/print/PrintSettingsPreferenceControllerTest.java
new file mode 100644
index 0000000..de1625b
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/print/PrintSettingsPreferenceControllerTest.java
@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.print;
+
+import static android.arch.lifecycle.Lifecycle.Event.ON_START;
+import static android.arch.lifecycle.Lifecycle.Event.ON_STOP;
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.arch.lifecycle.LifecycleOwner;
+import android.content.Context;
+import android.print.PrintJob;
+import android.print.PrintJobInfo;
+import android.print.PrintManager;
+import android.printservice.PrintServiceInfo;
+import android.support.v7.preference.Preference;
+
+import com.android.settings.R;
+import com.android.settings.TestConfig;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.wrapper.PrintManagerWrapper;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+import org.robolectric.util.ReflectionHelpers;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class PrintSettingsPreferenceControllerTest {
+
+    @Mock
+    private PrintManagerWrapper mPrintManager;
+    private Context mContext;
+    private Preference mPreference;
+    private PrintSettingPreferenceController mController;
+    private LifecycleOwner mLifecycleOwner;
+    private Lifecycle mLifecycle;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+        mContext = RuntimeEnvironment.application;
+        mPreference = new Preference(mContext);
+        mController = new PrintSettingPreferenceController(mContext);
+        mLifecycleOwner = () -> mLifecycle;
+        mLifecycle = new Lifecycle(mLifecycleOwner);
+        ReflectionHelpers.setField(mController, "mPrintManager", mPrintManager);
+        mLifecycle.addObserver(mController);
+    }
+
+    @Test
+    public void onStartStop_shouldRegisterPrintStateListener() {
+        mLifecycle.handleLifecycleEvent(ON_START);
+        mLifecycle.handleLifecycleEvent(ON_STOP);
+
+        verify(mPrintManager).addPrintJobStateChanegListener(mController);
+        verify(mPrintManager).removePrintJobStateChangeListener(mController);
+    }
+
+    @Test
+    public void updateState_hasActiveJob_shouldSetSummaryToNumberOfJobs() {
+        final List<PrintJob> printJobs = new ArrayList<>();
+        final PrintJob job = mock(PrintJob.class, Mockito.RETURNS_DEEP_STUBS);
+        printJobs.add(job);
+        when(job.getInfo().getState()).thenReturn(PrintJobInfo.STATE_STARTED);
+        when(mPrintManager.getPrintJobs()).thenReturn(printJobs);
+
+        mController.updateState(mPreference);
+
+        assertThat(mPreference.getSummary())
+                .isEqualTo(mContext.getResources()
+                        .getQuantityString(R.plurals.print_jobs_summary, 1, 1));
+    }
+
+    @Test
+    public void updateState_shouldSetSummaryToNumberOfPrintServices() {
+        final List<PrintServiceInfo> printServices = mock(List.class);
+        when(printServices.isEmpty()).thenReturn(false);
+        when(printServices.size()).thenReturn(2);
+        // 2 services
+        when(mPrintManager.getPrintServices(PrintManager.ENABLED_SERVICES))
+                .thenReturn(printServices);
+
+        mController.updateState(mPreference);
+
+        assertThat(mPreference.getSummary())
+                .isEqualTo(mContext.getResources()
+                        .getQuantityString(R.plurals.print_settings_summary, 2, 2));
+
+        // No service
+        when(mPrintManager.getPrintServices(PrintManager.ENABLED_SERVICES)).thenReturn(null);
+
+        mController.updateState(mPreference);
+
+        assertThat(mPreference.getSummary())
+                .isEqualTo(mContext.getString(R.string.print_settings_summary_no_service));
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/search/BaseSearchIndexProviderTest.java b/tests/robotests/src/com/android/settings/search/BaseSearchIndexProviderTest.java
index 6c6d7ab..260e3ae 100644
--- a/tests/robotests/src/com/android/settings/search/BaseSearchIndexProviderTest.java
+++ b/tests/robotests/src/com/android/settings/search/BaseSearchIndexProviderTest.java
@@ -137,7 +137,6 @@
         final List<String> nonIndexableKeys = provider
                 .getNonIndexableKeys(RuntimeEnvironment.application);
 
-        assertThat(nonIndexableKeys).containsAllOf("status_header", "limit_summary",
-                "restrict_background");
+        assertThat(nonIndexableKeys).contains("status_header");
     }
 }
diff --git a/tests/robotests/src/com/android/settings/search/CursorToSearchResultConverterTest.java b/tests/robotests/src/com/android/settings/search/CursorToSearchResultConverterTest.java
deleted file mode 100644
index a1cafc5..0000000
--- a/tests/robotests/src/com/android/settings/search/CursorToSearchResultConverterTest.java
+++ /dev/null
@@ -1,347 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.android.settings.search;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import android.app.Activity;
-import android.content.Context;
-import android.content.Intent;
-import android.database.Cursor;
-import android.database.MatrixCursor;
-import android.graphics.drawable.Drawable;
-
-import com.android.settings.DisplaySettings;
-import com.android.settings.R;
-import com.android.settings.TestConfig;
-import com.android.settings.gestures.SwipeToNotificationSettings;
-import com.android.settings.search.ResultPayload.Availability;
-import com.android.settings.search.ResultPayload.PayloadType;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settings.wifi.WifiSettings;
-
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.Robolectric;
-import org.robolectric.annotation.Config;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Set;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
-public class CursorToSearchResultConverterTest {
-
-    private static final List<String> TITLES = Arrays.asList("title1", "title2", "title3");
-    private static final String SUMMARY = "summary";
-    private static final String TARGET_PACKAGE = "a.b.c";
-    private static final String TARGET_CLASS = "a.b.c.class";
-    private static final String KEY = "key";
-    private static final int ICON = R.drawable.ic_search_24dp;
-    private static final int BASE_RANK = 1;
-    private static Intent sIntent;
-
-    @BeforeClass
-    public static void beforeClass() {
-        sIntent = new Intent("com.android.settings");
-    }
-
-    private Drawable mDrawable;
-    private CursorToSearchResultConverter mConverter;
-
-    @Before
-    public void setUp() {
-        MockitoAnnotations.initMocks(this);
-        Context context = Robolectric.buildActivity(Activity.class).get();
-        mDrawable = context.getDrawable(ICON);
-        mConverter = new CursorToSearchResultConverter(context);
-    }
-
-    @Test
-    public void testParseCursor_MatchesIcon() {
-        final MatrixCursor cursor = new MatrixCursor(DatabaseResultLoader.SELECT_COLUMNS);
-        final byte[] payload = ResultPayloadUtils.marshall(new ResultPayload(sIntent));
-        final String BLANK = "";
-        cursor.addRow(new Object[] {
-                KEY.hashCode(),      // Doc ID
-                "Longer than 20 characters", // Title
-                SUMMARY, // Summary on
-                SUMMARY, // summary off
-                DisplaySettings.class.getName(),
-                BLANK,   // screen title
-                ICON,    // icon
-                BLANK,   // action
-                null,    // target package
-                BLANK,   // target class
-                KEY,   // Key
-                PayloadType.INTENT,       // Payload Type
-                payload     // Payload
-        });
-
-        final Set<SearchResult> results = mConverter.convertCursor(cursor, BASE_RANK);
-
-        for (SearchResult result : results) {
-            Drawable resultDrawable = result.icon;
-            assertThat(resultDrawable).isNotNull();
-            assertThat(resultDrawable.toString()).isEqualTo(mDrawable.toString());
-        }
-    }
-
-    @Test
-    public void testParseCursor_NoIcon() {
-        final Set<SearchResult> results = mConverter.convertCursor(
-                getDummyCursor("noIcon" /* key */, "" /* className */), BASE_RANK);
-        for (SearchResult result : results) {
-            assertThat(result.icon).isNull();
-        }
-    }
-
-    @Test
-    public void testParseCursor_MatchesPayloadType() {
-        final Set<SearchResult> results = mConverter.convertCursor(getDummyCursor(), BASE_RANK);
-        ResultPayload payload;
-        for (SearchResult result : results) {
-            payload = result.payload;
-            assertThat(payload.getType()).isEqualTo(PayloadType.INTENT);
-        }
-    }
-
-    @Test
-    public void testLongTitle_PenalizedInRank() {
-        final MatrixCursor cursor = new MatrixCursor(DatabaseResultLoader.SELECT_COLUMNS);
-        final byte[] payload = ResultPayloadUtils.marshall(new ResultPayload(sIntent));
-        final String BLANK = "";
-        cursor.addRow(new Object[] {
-                KEY.hashCode(),      // 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
-                KEY,   // Key
-                PayloadType.INTENT,       // Payload Type
-                payload     // Payload
-        });
-        final Set<SearchResult> results = mConverter.convertCursor(cursor, BASE_RANK);
-        for (SearchResult result : results) {
-            assertThat(result.rank).isEqualTo(BASE_RANK + 1);
-        }
-    }
-
-    @Test
-    public void testParseCursor_MatchesResultPayload() {
-        final Set<SearchResult> results = mConverter.convertCursor(getDummyCursor(), BASE_RANK);
-        ResultPayload payload;
-        for (SearchResult result : results) {
-            payload = result.payload;
-            Intent intent = payload.getIntent();
-            assertThat(intent.getAction()).isEqualTo(sIntent.getAction());
-        }
-    }
-
-
-    @Test
-    public void testParseCursor_MatchesInlineSwitchPayload() {
-        MatrixCursor cursor = new MatrixCursor(DatabaseResultLoader.SELECT_COLUMNS);
-        final String BLANK = "";
-        final String uri = "test.com";
-        final int type = ResultPayload.PayloadType.INLINE_SWITCH;
-        final int source = ResultPayload.SettingsSource.SECURE;
-        final String intentKey = "key";
-        final String intentVal = "value";
-        final Intent intent = new Intent();
-        intent.putExtra(intentKey, intentVal);
-        final InlineSwitchPayload payload = new InlineSwitchPayload(uri, source, 1 /* onValue */,
-                intent, true /* isDeviceSupported */, 0 /* defautValue */);
-
-        cursor.addRow(new Object[] {
-                KEY.hashCode(),      // Doc ID
-                TITLES.get(0), // Title
-                SUMMARY, // Summary on
-                SUMMARY, // summary off
-                SwipeToNotificationSettings.class.getName(),
-                BLANK,   // screen title
-                null,    // icon
-                BLANK,   // action
-                null,    // target package
-                BLANK,   // target class
-                KEY,   // Key
-                type,    // Payload Type
-                ResultPayloadUtils.marshall(payload) // Payload
-        });
-        final Set<SearchResult> results = mConverter.convertCursor(cursor, BASE_RANK);
-
-        for (SearchResult result : results) {
-            final InlineSwitchPayload newPayload = (InlineSwitchPayload) result.payload;
-            final Intent rebuiltIntent = newPayload.getIntent();
-            assertThat(newPayload.getKey()).isEqualTo(uri);
-            assertThat(newPayload.getType()).isEqualTo(type);
-            assertThat(newPayload.mSettingSource).isEqualTo(source);
-            assertThat(newPayload.isStandard()).isTrue();
-            assertThat(newPayload.getAvailability()).isEqualTo(Availability.AVAILABLE);
-            assertThat(rebuiltIntent.getStringExtra(intentKey)).isEqualTo(intentVal);
-        }
-    }
-
-    // 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() {
-        final String key = "main_toggle_wifi";
-        final Cursor cursor = getDummyCursor(key, WifiSettings.class.getName());
-        final Set<SearchResult> results = mConverter.convertCursor(cursor, BASE_RANK);
-
-        for (SearchResult result : results) {
-            assertThat(result.rank).isEqualTo(SearchResult.TOP_RANK);
-        }
-    }
-
-    @Test
-    public void testBluetoothKey_PrioritizedResult() {
-        final String key = "main_toggle_bluetooth";
-        final Cursor cursor = getDummyCursor(key, WifiSettings.class.getName());
-        final Set<SearchResult> results = mConverter.convertCursor(cursor, BASE_RANK);
-
-        for (SearchResult result : results) {
-            assertThat(result.rank).isEqualTo(SearchResult.TOP_RANK);
-        }
-    }
-
-    @Test
-    public void testAirplaneKey_PrioritizedResult() {
-        final String key = "toggle_airplane";
-        final Cursor cursor = getDummyCursor(key, WifiSettings.class.getName());
-        Set<SearchResult> results = mConverter.convertCursor(cursor, BASE_RANK);
-        for (SearchResult result : results) {
-            assertThat(result.rank).isEqualTo(SearchResult.TOP_RANK);
-        }
-    }
-
-    @Test
-    public void testHotspotKey_PrioritizedResult() {
-        final String key = "tether_settings";
-        final Cursor cursor = getDummyCursor(key, WifiSettings.class.getName());
-        final Set<SearchResult> results = mConverter.convertCursor(cursor, BASE_RANK);
-
-        for (SearchResult result : results) {
-            assertThat(result.rank).isEqualTo(SearchResult.TOP_RANK);
-        }
-    }
-
-    @Test
-    public void testBatterySaverKey_PrioritizedResult() {
-        final String key = "battery_saver";
-        final Cursor cursor = getDummyCursor(key, WifiSettings.class.getName());
-        final Set<SearchResult> results = mConverter.convertCursor(cursor, BASE_RANK);
-
-        for (SearchResult result : results) {
-            assertThat(result.rank).isEqualTo(SearchResult.TOP_RANK);
-        }
-    }
-
-    @Test
-    public void testNFCKey_PrioritizedResult() {
-        final String key = "toggle_nfc";
-        final Cursor cursor = getDummyCursor(key, WifiSettings.class.getName());
-        final Set<SearchResult> results = mConverter.convertCursor(cursor, BASE_RANK);
-
-        for (SearchResult result : results) {
-            assertThat(result.rank).isEqualTo(SearchResult.TOP_RANK);
-        }
-    }
-
-    @Test
-    public void testDataSaverKey_PrioritizedResult() {
-        final String key = "restrict_background";
-        final Cursor cursor = getDummyCursor(key, WifiSettings.class.getName());
-        final Set<SearchResult> results = mConverter.convertCursor(cursor, BASE_RANK);
-
-        for (SearchResult result : results) {
-            assertThat(result.rank).isEqualTo(SearchResult.TOP_RANK);
-        }
-    }
-
-    @Test
-    public void testDataUsageKey_PrioritizedResult() {
-        final String key = "data_usage_enable";
-        final Cursor cursor = getDummyCursor(key, WifiSettings.class.getName());
-        final Set<SearchResult> results = mConverter.convertCursor(cursor, BASE_RANK);
-        for (SearchResult result : results) {
-            assertThat(result.rank).isEqualTo(SearchResult.TOP_RANK);
-        }
-    }
-
-    @Test
-    public void testRoamingKey_PrioritizedResult() {
-        final String key = "button_roaming_key";
-        final Cursor cursor = getDummyCursor(key, WifiSettings.class.getName());
-        final Set<SearchResult> results = mConverter.convertCursor(cursor, BASE_RANK);
-
-        for (SearchResult result : results) {
-            assertThat(result.rank).isEqualTo(SearchResult.TOP_RANK);
-        }
-    }
-
-    // End of temporary tests
-
-    private MatrixCursor getDummyCursor() {
-        String[] keys = new String[] {KEY + "1", KEY + "2", KEY + "3"};
-        return getDummyCursor(keys, "" /* className */);
-    }
-
-    private MatrixCursor getDummyCursor(String key, String className) {
-        String[] keys = new String[] {key};
-        return getDummyCursor(keys, className);
-    }
-
-    private MatrixCursor getDummyCursor(String[] keys, String className) {
-        MatrixCursor cursor = new MatrixCursor(DatabaseResultLoader.SELECT_COLUMNS);
-        final String BLANK = "";
-        final byte[] payload = ResultPayloadUtils.marshall(new ResultPayload(sIntent));
-
-        for (int i = 0; i < keys.length; i++) {
-            ArrayList<Object> item = new ArrayList<>(DatabaseResultLoader.SELECT_COLUMNS.length);
-            item.add(keys[i].hashCode()); // Doc ID
-            item.add(TITLES.get(i)); // Title
-            item.add(SUMMARY); // Summary on
-            item.add(BLANK); // summary off
-            item.add(className); // classname
-            item.add(BLANK); // screen title
-            item.add(null); // Icon
-            item.add(sIntent.getAction()); // Intent action
-            item.add(TARGET_PACKAGE); // target package
-            item.add(TARGET_CLASS); // target class
-            item.add(keys[i]); // Key
-            item.add(Integer.toString(0));     // Payload Type
-            item.add(payload); // Payload
-
-            cursor.addRow(item);
-        }
-        return cursor;
-    }
-}
diff --git a/tests/robotests/src/com/android/settings/search/SearchResultBuilderTest.java b/tests/robotests/src/com/android/settings/search/SearchResultBuilderTest.java
deleted file mode 100644
index cd77b25..0000000
--- a/tests/robotests/src/com/android/settings/search/SearchResultBuilderTest.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.android.settings.search;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import android.content.Context;
-import android.content.Intent;
-import android.graphics.drawable.Drawable;
-
-import com.android.settings.R;
-import com.android.settings.TestConfig;
-import com.android.settings.search.SearchResult.Builder;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.robolectric.annotation.Config;
-import org.robolectric.shadows.ShadowApplication;
-
-import java.util.ArrayList;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
-public class SearchResultBuilderTest {
-
-    private static final String TITLE = "title";
-    private static final String SUMMARY = "summary";
-
-    private Builder mBuilder;
-    private ArrayList<String> mBreadcrumbs;
-    private int mRank;
-    private ResultPayload mResultPayload;
-    private Drawable mIcon;
-
-    @Before
-    public void setUp() {
-        mBuilder = new Builder();
-        mBreadcrumbs = new ArrayList<>();
-        mRank = 3;
-        mResultPayload = new ResultPayload(new Intent());
-
-        final Context context = ShadowApplication.getInstance().getApplicationContext();
-        mIcon = context.getDrawable(R.drawable.ic_search_24dp);
-    }
-
-    @Test
-    public void testAllInfo_BuildSearchResult() {
-        mBuilder.setTitle(TITLE)
-                .setSummary(SUMMARY)
-                .setRank(mRank)
-                .addBreadcrumbs(mBreadcrumbs)
-                .setIcon(mIcon)
-                .setPayload(mResultPayload)
-                .setStableId(1);
-        SearchResult result = mBuilder.build();
-
-        assertThat(result).isNotNull();
-        assertThat(result.title).isEqualTo(TITLE);
-        assertThat(result.summary).isEqualTo(SUMMARY);
-        assertThat(result.rank).isEqualTo(mRank);
-        assertThat(result.breadcrumbs).isEqualTo(mBreadcrumbs);
-        assertThat(result.icon).isEqualTo(mIcon);
-        assertThat(result.payload).isEqualTo(mResultPayload);
-    }
-
-    @Test(expected = IllegalStateException.class)
-    public void testNoStableId_BuildSearchResultException() {
-        mBuilder.setTitle(TITLE)
-                .setSummary(SUMMARY)
-                .setRank(mRank)
-                .addBreadcrumbs(mBreadcrumbs)
-                .setIcon(mIcon)
-                .setPayload(mResultPayload);
-
-        mBuilder.build();
-    }
-
-    @Test(expected = IllegalStateException.class)
-    public void testNoTitle_BuildSearchResultException() {
-        mBuilder.setSummary(SUMMARY)
-                .setRank(mRank)
-                .addBreadcrumbs(mBreadcrumbs)
-                .setIcon(mIcon)
-                .setPayload(mResultPayload)
-                .setStableId(1);
-
-        mBuilder.build();
-    }
-
-    @Test
-    public void testNoRank_BuildSearchResult_pass() {
-        mBuilder.setTitle(TITLE)
-                .setSummary(SUMMARY)
-                .addBreadcrumbs(mBreadcrumbs)
-                .setIcon(mIcon)
-                .setPayload(mResultPayload)
-                .setStableId(1);
-
-        assertThat(mBuilder.build()).isNotNull();
-    }
-
-    @Test
-    public void testNoIcon_BuildSearchResult_pass() {
-        mBuilder.setTitle(TITLE)
-                .setSummary(SUMMARY)
-                .setRank(mRank)
-                .addBreadcrumbs(mBreadcrumbs)
-                .setPayload(mResultPayload)
-                .setStableId(1);
-
-        assertThat(mBuilder.build()).isNotNull();
-    }
-
-    @Test(expected = IllegalStateException.class)
-    public void testNoPayload_BuildSearchResultException() {
-        mBuilder.setTitle(TITLE)
-                .setSummary(SUMMARY)
-                .setRank(mRank)
-                .addBreadcrumbs(mBreadcrumbs)
-                .setIcon(mIcon)
-                .setStableId(1);
-
-        mBuilder.build();
-    }
-}
-
-
diff --git a/tests/robotests/src/com/android/settings/search/actionbar/SearchMenuControllerTest.java b/tests/robotests/src/com/android/settings/search/actionbar/SearchMenuControllerTest.java
index e1c77cd..d6e8c63 100644
--- a/tests/robotests/src/com/android/settings/search/actionbar/SearchMenuControllerTest.java
+++ b/tests/robotests/src/com/android/settings/search/actionbar/SearchMenuControllerTest.java
@@ -18,6 +18,7 @@
 
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyZeroInteractions;
 import static org.mockito.Mockito.when;
 
 import android.os.Bundle;
@@ -27,6 +28,7 @@
 import com.android.settings.R;
 import com.android.settings.TestConfig;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settingslib.core.lifecycle.ObservableFragment;
 import com.android.settingslib.core.lifecycle.ObservablePreferenceFragment;
 
 import org.junit.Before;
@@ -42,26 +44,47 @@
 
     @Mock
     private Menu mMenu;
-    private TestFragment mHost;
+    private TestPreferenceFragment mPreferenceHost;
+    private ObservableFragment mHost;
 
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
-        mHost = new TestFragment();
+        mHost = new ObservableFragment();
+        mPreferenceHost = new TestPreferenceFragment();
+
+        when(mMenu.add(Menu.NONE, Menu.NONE, 0 /* order */, R.string.search_menu))
+                .thenReturn(mock(MenuItem.class));
     }
 
     @Test
-    public void init_shouldAddMenu() {
-        when(mMenu.add(Menu.NONE, Menu.NONE, 0 /* order */, R.string.search_menu))
-                .thenReturn(mock(MenuItem.class));
+    public void init_prefFragment_shouldAddMenu() {
+        SearchMenuController.init(mPreferenceHost);
+        mPreferenceHost.getLifecycle().onCreateOptionsMenu(mMenu, null /* inflater */);
 
+        verify(mMenu).add(Menu.NONE, Menu.NONE, 0 /* order */, R.string.search_menu);
+    }
+
+    @Test
+    public void init_observableFragment_shouldAddMenu() {
         SearchMenuController.init(mHost);
         mHost.getLifecycle().onCreateOptionsMenu(mMenu, null /* inflater */);
 
         verify(mMenu).add(Menu.NONE, Menu.NONE, 0 /* order */, R.string.search_menu);
     }
 
-    public static class TestFragment extends ObservablePreferenceFragment {
+    @Test
+    public void init_doNotNeedSearchIcon_shouldNotAddMenu() {
+        final Bundle args = new Bundle();
+        args.putBoolean(SearchMenuController.NEED_SEARCH_ICON_IN_ACTION_BAR, false);
+        mHost.setArguments(args);
+
+        SearchMenuController.init(mHost);
+        mHost.getLifecycle().onCreateOptionsMenu(mMenu, null /* inflater */);
+        verifyZeroInteractions(mMenu);
+    }
+
+    public static class TestPreferenceFragment extends ObservablePreferenceFragment {
 
         @Override
         public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
diff --git a/tests/robotests/src/com/android/settings/security/trustagent/ManageTrustAgentsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/security/trustagent/ManageTrustAgentsPreferenceControllerTest.java
index 42d640a..64a0cea 100644
--- a/tests/robotests/src/com/android/settings/security/trustagent/ManageTrustAgentsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/security/trustagent/ManageTrustAgentsPreferenceControllerTest.java
@@ -16,14 +16,12 @@
 
 package com.android.settings.security.trustagent;
 
-import static com.android.settings.core.BasePreferenceController.AVAILABLE;
 import static com.google.common.truth.Truth.assertThat;
 import static org.mockito.ArgumentMatchers.anyInt;
 import static org.mockito.Mockito.when;
 
 import android.content.Context;
 import android.support.v7.preference.Preference;
-import android.support.v7.preference.PreferenceScreen;
 
 import com.android.internal.widget.LockPatternUtils;
 import com.android.settings.R;
@@ -50,8 +48,6 @@
     private TrustAgentManager mTrustAgentManager;
     @Mock
     private LockPatternUtils mLockPatternUtils;
-    @Mock
-    private PreferenceScreen mScreen;
 
     private FakeFeatureFactory mFeatureFactory;
     private Context mContext;
@@ -70,8 +66,6 @@
         mController = new ManageTrustAgentsPreferenceController(mContext);
         mPreference = new Preference(mContext);
         mPreference.setKey(mController.getPreferenceKey());
-        when(mScreen.findPreference(mController.getPreferenceKey()))
-                .thenReturn(mPreference);
     }
 
     @Test
@@ -86,10 +80,10 @@
     }
 
     @Test
-    public void displayPreference_isNotSecure_shouldDisablePreference() {
+    public void updateState_isNotSecure_shouldDisablePreference() {
         when(mLockPatternUtils.isSecure(anyInt())).thenReturn(false);
 
-        mController.displayPreference(mScreen);
+        mController.updateState(mPreference);
 
         assertThat(mPreference.isEnabled()).isFalse();
         assertThat(mPreference.getSummary())
@@ -97,12 +91,12 @@
     }
 
     @Test
-    public void displayPreference_isSecure_noTrustAgent_shouldShowGenericSummary() {
+    public void updateState_isSecure_noTrustAgent_shouldShowGenericSummary() {
         when(mLockPatternUtils.isSecure(anyInt())).thenReturn(true);
         when(mTrustAgentManager.getActiveTrustAgents(mContext, mLockPatternUtils))
                 .thenReturn(new ArrayList<>());
 
-        mController.displayPreference(mScreen);
+        mController.updateState(mPreference);
 
         assertThat(mPreference.isEnabled()).isTrue();
         assertThat(mPreference.getSummary())
@@ -110,12 +104,12 @@
     }
 
     @Test
-    public void displayPreference_isSecure_hasTrustAgent_shouldShowDetailedSummary() {
+    public void updateState_isSecure_hasTrustAgent_shouldShowDetailedSummary() {
         when(mLockPatternUtils.isSecure(anyInt())).thenReturn(true);
         when(mTrustAgentManager.getActiveTrustAgents(mContext, mLockPatternUtils))
                 .thenReturn(Arrays.asList(new TrustAgentManager.TrustAgentComponentInfo()));
 
-        mController.displayPreference(mScreen);
+        mController.updateState(mPreference);
 
         assertThat(mPreference.isEnabled()).isTrue();
         assertThat(mPreference.getSummary())
diff --git a/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java b/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java
index 340d04b..3512ded 100644
--- a/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java
+++ b/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java
@@ -31,6 +31,7 @@
 
 import com.android.settings.TestConfig;
 import com.android.settings.testutils.DatabaseTestUtils;
+import com.android.settings.testutils.FakeToggleController;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
 
 import org.junit.After;
diff --git a/tests/robotests/src/com/android/settings/slices/SliceBroadcastReceiverTest.java b/tests/robotests/src/com/android/settings/slices/SliceBroadcastReceiverTest.java
index f5d5ff0..1c5899d 100644
--- a/tests/robotests/src/com/android/settings/slices/SliceBroadcastReceiverTest.java
+++ b/tests/robotests/src/com/android/settings/slices/SliceBroadcastReceiverTest.java
@@ -31,6 +31,7 @@
 import com.android.settings.search.SearchFeatureProvider;
 import com.android.settings.search.SearchFeatureProviderImpl;
 import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.FakeToggleController;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
 
 import org.junit.After;
diff --git a/tests/robotests/src/com/android/settings/slices/SliceBuilderUtilsTest.java b/tests/robotests/src/com/android/settings/slices/SliceBuilderUtilsTest.java
index 0923571..88e4695 100644
--- a/tests/robotests/src/com/android/settings/slices/SliceBuilderUtilsTest.java
+++ b/tests/robotests/src/com/android/settings/slices/SliceBuilderUtilsTest.java
@@ -29,6 +29,7 @@
 import com.android.settings.R;
 import com.android.settings.TestConfig;
 import com.android.settings.core.BasePreferenceController;
+import com.android.settings.testutils.FakeToggleController;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
 
 import org.junit.Before;
diff --git a/tests/robotests/src/com/android/settings/slices/SliceControllerInXmlTest.java b/tests/robotests/src/com/android/settings/slices/SliceControllerInXmlTest.java
new file mode 100644
index 0000000..66ed459
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/slices/SliceControllerInXmlTest.java
@@ -0,0 +1,201 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.settings.slices;
+
+import static com.android.settings.TestConfig.SDK_VERSION;
+
+import static com.google.common.truth.Truth.assertWithMessage;
+
+import static org.mockito.Mockito.spy;
+
+import android.content.Context;
+import android.content.res.XmlResourceParser;
+import android.provider.SearchIndexableResource;
+import android.text.TextUtils;
+import android.util.AttributeSet;
+import android.util.Xml;
+
+import com.android.settings.TestConfig;
+import com.android.settings.core.TogglePreferenceController;
+import com.android.settings.core.codeinspection.ClassScanner;
+import com.android.settings.core.codeinspection.CodeInspector;
+import com.android.settings.overlay.FeatureFactory;
+import com.android.settings.search.DatabaseIndexingUtils;
+import com.android.settings.search.Indexable;
+import com.android.settings.search.SearchFeatureProvider;
+import com.android.settings.search.SearchFeatureProviderImpl;
+import com.android.settings.search.XmlParserUtils;
+import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+import org.xmlpull.v1.XmlPullParser;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = SDK_VERSION)
+public class SliceControllerInXmlTest {
+
+    private static final List<Class> mSliceControllerClasses = new ArrayList<>(Arrays.asList(
+            TogglePreferenceController.class
+    ));
+
+    private final List<String> mXmlDeclaredControllers = new ArrayList<>();
+    private final List<String> mGrandfatheredClasses = new ArrayList<>();
+
+    private final String ERROR_MISSING_CONTROLLER =
+            "The following controllers were expected to be declared by "
+                    + "'settings:controller=Controller_Class_Name' in their corresponding Xml. "
+                    + "If it should not appear in XML, add the controller's classname to "
+                    + "grandfather_slice_controller_not_in_xml. Controllers:\n";
+
+    private Context mContext;
+
+    SearchFeatureProvider mSearchProvider;
+    private FakeFeatureFactory mFakeFeatureFactory;
+
+    @Before
+    public void setUp() {
+        mContext = spy(RuntimeEnvironment.application);
+
+        mSearchProvider = new SearchFeatureProviderImpl();
+        mFakeFeatureFactory = FakeFeatureFactory.setupForTest();
+        mFakeFeatureFactory.searchFeatureProvider = mSearchProvider;
+
+        CodeInspector.initializeGrandfatherList(mGrandfatheredClasses,
+                "grandfather_slice_controller_not_in_xml");
+        initDeclaredControllers();
+    }
+
+    private void initDeclaredControllers() {
+        final List<Integer> xmlResources = getIndexableXml();
+        XmlResourceParser parser;
+
+        for (int xmlResId : xmlResources) {
+            try {
+                parser = mContext.getResources().getXml(xmlResId);
+
+                int type;
+                while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
+                        && type != XmlPullParser.START_TAG) {
+                    // Parse next until start tag is found
+                }
+
+                final int outerDepth = parser.getDepth();
+                final AttributeSet attrs = Xml.asAttributeSet(parser);
+                String controllerClassName;
+                while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
+                        && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
+                    if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
+                        continue;
+                    }
+                    controllerClassName = XmlParserUtils.getController(mContext, attrs);
+
+                    if (!TextUtils.isEmpty(controllerClassName)) {
+                        mXmlDeclaredControllers.add(controllerClassName);
+                    }
+                }
+            } catch (Exception e) {
+                // Assume an issue with robolectric resources
+            }
+        }
+    }
+
+    @Test
+    public void testAllControllersDeclaredInXml() throws Exception {
+        final List<Class<?>> classes = new ClassScanner().getClassesForPackage(
+                mContext.getPackageName());
+        final List<String> missingControllersInXml = new ArrayList<>();
+
+        for (Class<?> clazz : classes) {
+            if (!isInlineSliceClass(clazz)) {
+                // Only care about inline-slice controller classes.
+                continue;
+            }
+
+            if (!mXmlDeclaredControllers.contains(clazz.getName())) {
+                // Class clazz should have been declared in XML (unless whitelisted).
+                missingControllersInXml.add(clazz.getName());
+            }
+        }
+
+        // Removed whitelisted classes
+        missingControllersInXml.removeAll(mGrandfatheredClasses);
+
+        final String missingControllerError = buildErrorMessage(ERROR_MISSING_CONTROLLER,
+                missingControllersInXml);
+
+        assertWithMessage(missingControllerError).that(missingControllersInXml).isEmpty();
+    }
+
+    private boolean isInlineSliceClass(Class clazz) {
+        while (clazz != null) {
+            clazz = clazz.getSuperclass();
+            if (mSliceControllerClasses.contains(clazz)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    private String buildErrorMessage(String errorSummary, List<String> errorClasses) {
+        final StringBuilder error = new StringBuilder(errorSummary);
+        for (String c : errorClasses) {
+            error.append(c).append("\n");
+        }
+        return error.toString();
+    }
+
+    private List<Integer> getIndexableXml() {
+        final List<Integer> xmlResSet = new ArrayList<>();
+
+        final Collection<Class> indexableClasses = FeatureFactory.getFactory(
+                mContext).getSearchFeatureProvider().getSearchIndexableResources()
+                .getProviderValues();
+
+        for (Class clazz : indexableClasses) {
+
+            Indexable.SearchIndexProvider provider = DatabaseIndexingUtils.getSearchIndexProvider(
+                    clazz);
+
+            if (provider == null) {
+                continue;
+            }
+
+            List<SearchIndexableResource> resources = provider.getXmlResourcesToIndex(mContext,
+                    true);
+
+            if (resources == null) {
+                continue;
+            }
+
+            for (SearchIndexableResource resource : resources) {
+                // Add '0's anyway. It won't break the test.
+                xmlResSet.add(resource.xmlResId);
+            }
+        }
+        return xmlResSet;
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/suggestions/SettingsSuggestionsTest.java b/tests/robotests/src/com/android/settings/suggestions/SettingsSuggestionsTest.java
index 677bf41..9dff925 100644
--- a/tests/robotests/src/com/android/settings/suggestions/SettingsSuggestionsTest.java
+++ b/tests/robotests/src/com/android/settings/suggestions/SettingsSuggestionsTest.java
@@ -68,7 +68,7 @@
 
     @Test
     public void wifiCallingSuggestion_isValid() {
-        assertSuggestionEquals("com.android.settings.wifi.WifiCallingSuggestionActivity",
+        assertSuggestionEquals("com.android.settings.wifi.calling.WifiCallingSuggestionActivity",
                 CATEGORY_FIRST_IMPRESSION,
                 R.string.wifi_calling_suggestion_title, R.string.wifi_calling_suggestion_summary);
     }
diff --git a/tests/robotests/src/com/android/settings/testutils/FakeFeatureFactory.java b/tests/robotests/src/com/android/settings/testutils/FakeFeatureFactory.java
index ad72e6b..6011640 100644
--- a/tests/robotests/src/com/android/settings/testutils/FakeFeatureFactory.java
+++ b/tests/robotests/src/com/android/settings/testutils/FakeFeatureFactory.java
@@ -24,10 +24,8 @@
 import com.android.settings.accounts.AccountFeatureProvider;
 import com.android.settings.applications.ApplicationFeatureProvider;
 import com.android.settings.bluetooth.BluetoothFeatureProvider;
-import com.android.settings.connecteddevice.SmsMirroringFeatureProvider;
 import com.android.settings.dashboard.DashboardFeatureProvider;
 import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
-import com.android.settings.datausage.DataPlanFeatureProvider;
 import com.android.settings.enterprise.EnterprisePrivacyFeatureProvider;
 import com.android.settings.fuelgauge.PowerUsageFeatureProvider;
 import com.android.settings.gestures.AssistGestureFeatureProvider;
@@ -62,8 +60,6 @@
     public final UserFeatureProvider userFeatureProvider;
     public final AssistGestureFeatureProvider assistGestureFeatureProvider;
     public final BluetoothFeatureProvider bluetoothFeatureProvider;
-    public final DataPlanFeatureProvider dataPlanFeatureProvider;
-    public final SmsMirroringFeatureProvider smsMirroringFeatureProvider;
     public final SlicesFeatureProvider slicesFeatureProvider;
     public SearchFeatureProvider searchFeatureProvider;
     public final AccountFeatureProvider mAccountFeatureProvider;
@@ -103,8 +99,6 @@
         userFeatureProvider = mock(UserFeatureProvider.class);
         assistGestureFeatureProvider = mock(AssistGestureFeatureProvider.class);
         bluetoothFeatureProvider = mock(BluetoothFeatureProvider.class);
-        dataPlanFeatureProvider = mock(DataPlanFeatureProvider.class);
-        smsMirroringFeatureProvider = mock(SmsMirroringFeatureProvider.class);
         slicesFeatureProvider = mock(SlicesFeatureProvider.class);
         mAccountFeatureProvider = mock(AccountFeatureProvider.class);
     }
@@ -175,21 +169,11 @@
     }
 
     @Override
-    public DataPlanFeatureProvider getDataPlanFeatureProvider() {
-        return dataPlanFeatureProvider;
-    }
-
-    @Override
     public AssistGestureFeatureProvider getAssistGestureFeatureProvider() {
         return assistGestureFeatureProvider;
     }
 
     @Override
-    public SmsMirroringFeatureProvider getSmsMirroringFeatureProvider() {
-        return smsMirroringFeatureProvider;
-    }
-
-    @Override
     public SlicesFeatureProvider getSlicesFeatureProvider() {
         return slicesFeatureProvider;
     }
diff --git a/tests/robotests/src/com/android/settings/slices/FakeToggleController.java b/tests/robotests/src/com/android/settings/testutils/FakeToggleController.java
similarity index 97%
rename from tests/robotests/src/com/android/settings/slices/FakeToggleController.java
rename to tests/robotests/src/com/android/settings/testutils/FakeToggleController.java
index 1b08e35..c984c6c 100644
--- a/tests/robotests/src/com/android/settings/slices/FakeToggleController.java
+++ b/tests/robotests/src/com/android/settings/testutils/FakeToggleController.java
@@ -15,7 +15,7 @@
  *
  */
 
-package com.android.settings.slices;
+package com.android.settings.testutils;
 
 import android.content.Context;
 import android.provider.Settings;
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowPowerManager.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowPowerManager.java
new file mode 100644
index 0000000..3bc807a
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowPowerManager.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package com.android.settings.testutils.shadow;
+
+import android.os.PowerManager;
+
+import org.robolectric.annotation.Implementation;
+import org.robolectric.annotation.Implements;
+
+@Implements(PowerManager.class)
+public class ShadowPowerManager extends org.robolectric.shadows.ShadowPowerManager {
+    @Implementation
+    public boolean setPowerSaveMode(boolean mode) {
+        setIsPowerSaveMode(mode);
+        return true;
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/users/AutoSyncWorkDataPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/users/AutoSyncWorkDataPreferenceControllerTest.java
index 19f3732..22dae37 100644
--- a/tests/robotests/src/com/android/settings/users/AutoSyncWorkDataPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/users/AutoSyncWorkDataPreferenceControllerTest.java
@@ -92,6 +92,21 @@
     }
 
     @Test
+    public void checkIsAvailable_null_workProfileUserHandle_shouldNotDisplay() {
+        when(mUserManager.isManagedProfile()).thenReturn(false);
+        when(mUserManager.isLinkedUser()).thenReturn(false);
+
+        final List<UserInfo> infos = new ArrayList<>();
+        infos.add(new UserInfo(UserHandle.USER_SYSTEM, "user 1", 0 /* flags */));
+        infos.add(new UserInfo(999, "xspace", 800010));
+        when(mUserManager.getProfiles(eq(UserHandle.USER_SYSTEM))).thenReturn(infos);
+        mController = new AutoSyncWorkDataPreferenceController(mContext, mFragment);
+
+        assertThat(mController.mUserHandle).isEqualTo(null);
+        assertThat(mController.isAvailable()).isFalse();
+    }
+
+    @Test
     public void multipleProfile_shouldInitWithWorkProfileUserHandle() {
         when(mUserManager.isManagedProfile()).thenReturn(false);
         when(mUserManager.isLinkedUser()).thenReturn(false);
diff --git a/tests/robotests/src/com/android/settings/wallpaper/WallpaperSuggestionActivityTest.java b/tests/robotests/src/com/android/settings/wallpaper/WallpaperSuggestionActivityTest.java
index ced4b0a..daaf4b3 100644
--- a/tests/robotests/src/com/android/settings/wallpaper/WallpaperSuggestionActivityTest.java
+++ b/tests/robotests/src/com/android/settings/wallpaper/WallpaperSuggestionActivityTest.java
@@ -17,12 +17,14 @@
 package com.android.settings.wallpaper;
 
 import static com.google.common.truth.Truth.assertThat;
+
 import static org.mockito.Mockito.when;
 import static org.robolectric.Shadows.shadowOf;
 
 import android.content.Context;
 import android.content.Intent;
 import android.content.pm.PackageManager;
+import android.content.res.Resources;
 
 import com.android.settings.SubSettings;
 import com.android.settings.TestConfig;
@@ -42,16 +44,16 @@
 import org.robolectric.shadows.ShadowActivity;
 
 @RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
-        shadows = {
-                WallpaperSuggestionActivityTest.ShadowWallpaperManagerWrapper.class
-        })
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
 public class WallpaperSuggestionActivityTest {
 
     @Mock
     private Context mContext;
     @Mock
     private PackageManager mPackageManager;
+    @Mock
+    private Resources mResources;
+
     private ActivityController<WallpaperSuggestionActivity> mController;
 
     @Before
@@ -72,6 +74,17 @@
     }
 
     @Test
+    public void wallpaperServiceEnabled_no_shouldReturnFalse() {
+        when(mContext.getResources()).thenReturn(mResources);
+        when(mResources.getBoolean(
+                com.android.internal.R.bool.config_enableWallpaperService)).thenReturn(false);
+
+        assertThat(WallpaperSuggestionActivity.isSuggestionComplete(mContext))
+                .isFalse();
+    }
+
+    @Test
+    @Config(shadows = WallpaperSuggestionActivityTest.ShadowWallpaperManagerWrapper.class)
     public void hasWallpaperSet_no_shouldReturnFalse() {
         ShadowWallpaperManagerWrapper.setWallpaperId(0);
 
@@ -80,6 +93,7 @@
     }
 
     @Test
+    @Config(shadows = WallpaperSuggestionActivityTest.ShadowWallpaperManagerWrapper.class)
     public void hasWallpaperSet_yes_shouldReturnTrue() {
         ShadowWallpaperManagerWrapper.setWallpaperId(100);
 
@@ -100,6 +114,15 @@
             sWallpaperId = 0;
         }
 
+        public void __constructor__(Context context) {
+
+        }
+
+        @Implementation
+        public boolean isWallpaperServiceEnabled() {
+            return true;
+        }
+
         @Implementation
         public int getWallpaperId(int which) {
             return sWallpaperId;
diff --git a/tests/robotests/src/com/android/settings/widget/MasterCheckBoxPreferenceTest.java b/tests/robotests/src/com/android/settings/widget/MasterCheckBoxPreferenceTest.java
index ac3e0b6..55ce27f 100644
--- a/tests/robotests/src/com/android/settings/widget/MasterCheckBoxPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/widget/MasterCheckBoxPreferenceTest.java
@@ -106,6 +106,24 @@
     }
 
     @Test
+    public void onBindViewHolder_shouldSetCheckboxEnabledState() {
+        final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(
+                LayoutInflater.from(mContext).inflate(
+                        R.layout.preference_widget_master_checkbox, null));
+        final CheckBox checkBox = (CheckBox) holder.findViewById(R.id.checkboxWidget);
+
+        mPreference.setCheckBoxEnabled(false);
+        mPreference.onBindViewHolder(holder);
+
+        assertThat(mPreference.isEnabled()).isTrue();
+        assertThat(checkBox.isEnabled()).isFalse();
+
+        mPreference.setCheckBoxEnabled(true);
+        assertThat(mPreference.isEnabled()).isTrue();
+        assertThat(checkBox.isEnabled()).isTrue();
+    }
+
+    @Test
     public void clickWidgetView_shouldToggleCheckBox() {
         final LayoutInflater inflater = LayoutInflater.from(mContext);
         final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(
diff --git a/tests/robotests/src/com/android/settings/widget/SeekBarPreferenceTest.java b/tests/robotests/src/com/android/settings/widget/SeekBarPreferenceTest.java
new file mode 100644
index 0000000..7a042a0
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/widget/SeekBarPreferenceTest.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.widget;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+import android.os.Parcelable;
+
+import com.android.settings.TestConfig;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class SeekBarPreferenceTest {
+    private static final int MAX = 75;
+    private static final int MIN = 5;
+    private static final int PROGRESS = 16;
+
+    private Context mContext;
+    private SeekBarPreference mSeekBarPreference;
+
+    @Before
+    public void setUp() {
+        mContext = RuntimeEnvironment.application;
+
+        mSeekBarPreference = new SeekBarPreference(mContext);
+        mSeekBarPreference.setMax(MAX);
+        mSeekBarPreference.setMin(MIN);
+        mSeekBarPreference.setProgress(PROGRESS);
+        mSeekBarPreference.setPersistent(false);
+    }
+
+    @Test
+    public void testSaveAndRestoreInstanceState() {
+        final Parcelable parcelable = mSeekBarPreference.onSaveInstanceState();
+
+        final SeekBarPreference preference = new SeekBarPreference(mContext);
+        preference.onRestoreInstanceState(parcelable);
+
+        assertThat(preference.getMax()).isEqualTo(MAX);
+        assertThat(preference.getMin()).isEqualTo(MIN);
+        assertThat(preference.getProgress()).isEqualTo(PROGRESS);
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/widget/TwoStateButtonPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/widget/TwoStateButtonPreferenceControllerTest.java
new file mode 100644
index 0000000..a289815
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/widget/TwoStateButtonPreferenceControllerTest.java
@@ -0,0 +1,121 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package com.android.settings.widget;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.spy;
+
+import android.content.Context;
+import android.support.v7.preference.PreferenceScreen;
+import android.view.View;
+import android.widget.Button;
+
+import com.android.settings.TestConfig;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class TwoStateButtonPreferenceControllerTest {
+    private static final String KEY = "pref_key";
+
+    @Mock
+    private PreferenceScreen mPreferenceScreen;
+    @Mock
+    private TwoStateButtonPreference mPreference;
+    private TwoStateButtonPreferenceController mController;
+    private Context mContext;
+    private Button mButtonOn;
+    private Button mButtonOff;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+        mContext = spy(RuntimeEnvironment.application);
+        doReturn(mPreference).when(mPreferenceScreen).findPreference(anyString());
+        mButtonOn = new Button(mContext);
+        doReturn(mButtonOn).when(mPreference).getStateOnButton();
+        mButtonOff = new Button(mContext);
+        doReturn(mButtonOff).when(mPreference).getStateOffButton();
+
+        mController = new TestButtonsPreferenceController(mContext, KEY);
+        mController.displayPreference(mPreferenceScreen);
+    }
+
+    @Test
+    public void testSetButtonVisibility_stateOn_onlyShowButtonOn() {
+        mController.setButtonVisibility(true /* stateOn */);
+
+        assertThat(mButtonOn.getVisibility()).isEqualTo(View.VISIBLE);
+        assertThat(mButtonOff.getVisibility()).isEqualTo(View.GONE);
+    }
+
+    @Test
+    public void testSetButtonVisibility_stateOff_onlyShowButtonOff() {
+        mController.setButtonVisibility(false /* stateOn */);
+
+        assertThat(mButtonOn.getVisibility()).isEqualTo(View.GONE);
+        assertThat(mButtonOff.getVisibility()).isEqualTo(View.VISIBLE);
+    }
+
+    @Test
+    public void testSetButtonEnabled_enabled_buttonEnabled() {
+        mController.setButtonEnabled(true /* enabled */);
+
+        assertThat(mButtonOn.isEnabled()).isTrue();
+        assertThat(mButtonOff.isEnabled()).isTrue();
+    }
+
+    @Test
+    public void testSetButtonEnabled_disabled_buttonDisabled() {
+        mController.setButtonEnabled(false /* enabled */);
+
+        assertThat(mButtonOn.isEnabled()).isFalse();
+        assertThat(mButtonOff.isEnabled()).isFalse();
+    }
+
+    /**
+     * Controller to test methods in {@link TwoStateButtonPreferenceController}
+     */
+    public static class TestButtonsPreferenceController extends
+            TwoStateButtonPreferenceController {
+
+        TestButtonsPreferenceController(Context context, String key) {
+            super(context, key);
+        }
+
+        @Override
+        public void onButtonClicked(boolean stateOn) {
+            //do nothing
+        }
+
+        @Override
+        public int getAvailabilityStatus() {
+            return AVAILABLE;
+        }
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/wifi/ConnectedAccessPointPreferenceTest.java b/tests/robotests/src/com/android/settings/wifi/ConnectedAccessPointPreferenceTest.java
index 2eaa587..c122a65 100644
--- a/tests/robotests/src/com/android/settings/wifi/ConnectedAccessPointPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/ConnectedAccessPointPreferenceTest.java
@@ -16,6 +16,8 @@
 
 package com.android.settings.wifi;
 
+import static com.google.common.truth.Truth.assertThat;
+
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.verify;
@@ -75,4 +77,9 @@
         verify(mOnGearClickListener, never()).onGearClick(mConnectedAccessPointPreference);
     }
 
+    @Test
+    public void testWidgetLayoutPreference() {
+        assertThat(mConnectedAccessPointPreference.getWidgetLayoutResource()).isEqualTo(
+                R.layout.preference_widget_gear_no_bg);
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/wifi/WpsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/WpsPreferenceControllerTest.java
deleted file mode 100644
index e4dfea4..0000000
--- a/tests/robotests/src/com/android/settings/wifi/WpsPreferenceControllerTest.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.settings.wifi;
-
-import static android.arch.lifecycle.Lifecycle.Event.ON_PAUSE;
-import static android.arch.lifecycle.Lifecycle.Event.ON_RESUME;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.app.FragmentManager;
-import android.arch.lifecycle.LifecycleOwner;
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.net.wifi.WifiManager;
-import android.support.v7.preference.Preference;
-import android.support.v7.preference.PreferenceScreen;
-
-import com.android.settings.TestConfig;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settingslib.core.lifecycle.Lifecycle;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Answers;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.annotation.Config;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
-public class WpsPreferenceControllerTest {
-
-    @Mock
-    private Context mContext;
-    @Mock(answer = Answers.RETURNS_DEEP_STUBS)
-    private WifiManager mWifiManager;
-    @Mock
-    private FragmentManager mFragmentManager;
-    @Mock
-    private PreferenceScreen mScreen;
-    @Mock
-    private Preference mWpsPushPref;
-    @Mock
-    private Preference mWpsPinPref;
-
-    private Lifecycle mLifecycle;
-    private LifecycleOwner mLifecycleOwner;
-    private WpsPreferenceController mController;
-
-    @Before
-    public void setUp() {
-        MockitoAnnotations.initMocks(this);
-        mLifecycleOwner = () -> mLifecycle;
-        mLifecycle = new Lifecycle(mLifecycleOwner);
-        when(mContext.getSystemService(WifiManager.class))
-                .thenReturn(mWifiManager);
-        when(mScreen.findPreference(anyString()))
-                .thenReturn(mWpsPushPref)
-                .thenReturn(mWpsPinPref);
-        mController = new WpsPreferenceController(
-                mContext, mLifecycle, mWifiManager, mFragmentManager);
-    }
-
-    @Test
-    public void testIsAvailable_shouldAlwaysReturnTrue() {
-        assertThat(mController.isAvailable()).isTrue();
-    }
-
-    @Test
-    public void testOnResume_shouldRegisterListener() {
-        mLifecycle.handleLifecycleEvent(ON_RESUME);
-        verify(mContext).registerReceiver(any(BroadcastReceiver.class), any(IntentFilter.class));
-    }
-    @Test
-    public void testOnPause_shouldUnregisterListener() {
-        mLifecycle.handleLifecycleEvent(ON_RESUME);
-        mLifecycle.handleLifecycleEvent(ON_PAUSE);
-        verify(mContext).unregisterReceiver(any(BroadcastReceiver.class));
-    }
-
-    @Test
-    public void testWifiStateChange_shouldToggleEnabledState() {
-        when(mWifiManager.isWifiEnabled()).thenReturn(true);
-
-        //Sets the preferences.
-        mController.displayPreference(mScreen);
-        verify(mWpsPushPref).setEnabled(true);
-        verify(mWpsPinPref).setEnabled(true);
-
-        Intent dummyIntent = new Intent();
-        mController.mReceiver.onReceive(mContext, dummyIntent);
-        verify(mWpsPushPref, times(2)).setEnabled(true);
-        verify(mWpsPinPref, times(2)).setEnabled(true);
-
-        when(mWifiManager.isWifiEnabled()).thenReturn(false);
-        mController.mReceiver.onReceive(mContext, dummyIntent);
-        verify(mWpsPushPref).setEnabled(false);
-        verify(mWpsPinPref).setEnabled(false);
-    }
-
-    @Test
-    public void testDisplayPreference_shouldSetPreferenceClickListenerAndToggleEnabledState() {
-        when(mWifiManager.isWifiEnabled()).thenReturn(true);
-        mController.displayPreference(mScreen);
-        verify(mWpsPushPref).setOnPreferenceClickListener(any());
-        verify(mWpsPinPref).setOnPreferenceClickListener(any());
-        verify(mWpsPushPref).setEnabled(true);
-        verify(mWpsPinPref).setEnabled(true);
-    }
-
-    @Test
-    public void testDisplayPreference_shouldDisablePreferenceWhenWifiDisabled() {
-        when(mWifiManager.isWifiEnabled()).thenReturn(false);
-        mController.displayPreference(mScreen);
-        verify(mWpsPushPref).setEnabled(false);
-        verify(mWpsPinPref).setEnabled(false);
-    }
-}
diff --git a/tests/unit/AndroidManifest.xml b/tests/unit/AndroidManifest.xml
index b22c01b..eccbac3 100644
--- a/tests/unit/AndroidManifest.xml
+++ b/tests/unit/AndroidManifest.xml
@@ -53,6 +53,15 @@
             <meta-data android:name="com.android.settings.summary" android:resource="@string/manufacturer_settings_summary" />
             <meta-data android:name="com.android.settings.icon" android:resource="@drawable/ic_settings_applications" />
         </activity>
+
+        <service android:name="com.android.settings.accounts.TestAuthService">
+            <intent-filter>
+                <action android:name="android.accounts.AccountAuthenticator" />
+            </intent-filter>
+            <meta-data android:name="android.accounts.AccountAuthenticator"
+                       android:resource="@xml/authenticator" />
+        </service>
+
     </application>
 
     <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
diff --git a/tests/unit/res/values/strings.xml b/tests/unit/res/values/strings.xml
index 35e201a..620bb04 100644
--- a/tests/unit/res/values/strings.xml
+++ b/tests/unit/res/values/strings.xml
@@ -28,4 +28,7 @@
     <string name="manufacturer_hello" translatable="false">Hello Manufacturer!</string>
     <string name="manufacturer_settings_title" translatable="false">Manufacturer</string>
     <string name="manufacturer_settings_summary" translatable="false">Manufacturer hook that can be used to start activity of choice</string>
+    <string name="account_auth_label" translatable="false">Settings Test Account</string>
+    <string name="account_type" translatable="false">com.settingstest.account-prefs</string>
+    <string name="account_pref_title" translatable="false">Test preference for external account</string>
 </resources>
diff --git a/res/xml/data_plan_usage.xml b/tests/unit/res/xml/account_preferences.xml
similarity index 72%
rename from res/xml/data_plan_usage.xml
rename to tests/unit/res/xml/account_preferences.xml
index 4691198..b391759 100644
--- a/res/xml/data_plan_usage.xml
+++ b/tests/unit/res/xml/account_preferences.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2017 The Android Open Source Project
+<!-- Copyright (C) 2018 The Android Open Source Project
 
      Licensed under the Apache License, Version 2.0 (the "License");
      you may not use this file except in compliance with the License.
@@ -13,13 +13,11 @@
      See the License for the specific language governing permissions and
      limitations under the License.
 -->
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
 
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
-        android:title="@string/data_usage_summary_title">
+    <SwitchPreference
+        android:key="account_test_switch"
+        android:title="@string/account_pref_title" />
 
-    <PreferenceCategory
-            android:key="data_plan_usage"
-            android:title="@string/usage">
-
-    </PreferenceCategory>
 </PreferenceScreen>
+
diff --git a/res/layout/search_feedback.xml b/tests/unit/res/xml/authenticator.xml
similarity index 69%
rename from res/layout/search_feedback.xml
rename to tests/unit/res/xml/authenticator.xml
index cdb0545..92bf774 100644
--- a/res/layout/search_feedback.xml
+++ b/tests/unit/res/xml/authenticator.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2017 The Android Open Source Project
+<!-- Copyright (C) 2018 The Android Open Source Project
 
      Licensed under the Apache License, Version 2.0 (the "License");
      you may not use this file except in compliance with the License.
@@ -13,11 +13,10 @@
      See the License for the specific language governing permissions and
      limitations under the License.
 -->
-
-<View
+<account-authenticator
     xmlns:android="http://schemas.android.com/apk/res/android"
-    android:id="@+id/feedback_popup"
-    android:layout_width="0dp"
-    android:layout_height="0dp"
-    android:visibility="gone">
-</View>
+    android:label="@string/account_auth_label"
+    android:icon="@drawable/ic_settings_applications"
+    android:accountType="@string/account_type"
+    android:accountPreferences="@xml/account_preferences" />
+
diff --git a/tests/unit/src/com/android/settings/accounts/AccountsSettingsTest.java b/tests/unit/src/com/android/settings/accounts/AccountsSettingsTest.java
new file mode 100644
index 0000000..7218efe
--- /dev/null
+++ b/tests/unit/src/com/android/settings/accounts/AccountsSettingsTest.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.settings.accounts;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.accounts.Account;
+import android.accounts.AccountManager;
+import android.content.Context;
+import android.content.Intent;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.filters.SmallTest;
+import android.support.test.runner.AndroidJUnit4;
+import android.support.test.uiautomator.UiDevice;
+import android.support.test.uiautomator.UiObject;
+import android.support.test.uiautomator.UiSelector;
+import android.support.test.uiautomator.UiScrollable;
+import android.support.test.uiautomator.UiObjectNotFoundException;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(AndroidJUnit4.class)
+@SmallTest
+public class AccountsSettingsTest {
+
+    private static final String ACCOUNTS = "Accounts";
+    private static final String ACCOUNT_TYPE = "com.settingstest.account-prefs";
+    private static final String PREF_TITLE = "Test preference for external account";
+
+    private UiDevice mDevice;
+    private Context mContext;
+    private String mTargetPackage;
+
+    @Before
+    public void setUp() {
+        mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
+        mContext = InstrumentationRegistry.getTargetContext();
+        mTargetPackage = mContext.getPackageName();
+    }
+
+    @Test
+    public void testExternalAccountInfoExists() throws UiObjectNotFoundException {
+        // add a test account
+        final String testAccountName = "Test Account";
+        final Account account = new Account(testAccountName, ACCOUNT_TYPE);
+        final AccountManager accountManager = AccountManager.get(mContext);
+        final boolean accountAdded =
+            accountManager.addAccountExplicitly(account, null /* password */, null /* userdata */);
+        assertThat(accountAdded).isTrue();
+
+        // launch Accounts Settings and select the test account
+        launchAccountsSettings();
+        mDevice.findObject(new UiSelector().text(testAccountName)).click();
+        final UiObject testPreference = mDevice.findObject(new UiSelector().text(PREF_TITLE));
+        // remove test account
+        accountManager.removeAccountExplicitly(account);
+
+        assertThat(testPreference.exists()).isTrue();
+    }
+
+    private void launchAccountsSettings() throws UiObjectNotFoundException  {
+        // launch settings
+        Intent settingsIntent = new Intent(Intent.ACTION_MAIN)
+            .addCategory(Intent.CATEGORY_LAUNCHER)
+            .setPackage(mTargetPackage)
+            .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+        mContext.startActivity(settingsIntent);
+        // selects Accounts
+        final UiScrollable settings = new UiScrollable(
+                new UiSelector().packageName(mTargetPackage).scrollable(true));
+        final String titleAccounts = ACCOUNTS;
+        settings.scrollTextIntoView(titleAccounts);
+        mDevice.findObject(new UiSelector().text(titleAccounts)).click();
+    }
+}
diff --git a/tests/unit/src/com/android/settings/accounts/Authenticator.java b/tests/unit/src/com/android/settings/accounts/Authenticator.java
new file mode 100644
index 0000000..a2413dc
--- /dev/null
+++ b/tests/unit/src/com/android/settings/accounts/Authenticator.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.settings.accounts;
+
+import android.accounts.AbstractAccountAuthenticator;
+import android.accounts.Account;
+import android.accounts.AccountAuthenticatorResponse;
+import android.accounts.AccountManager;
+import android.accounts.NetworkErrorException;
+import android.content.Context;
+import android.os.Bundle;
+
+public class Authenticator extends AbstractAccountAuthenticator {
+
+    public Authenticator(Context context) {
+        super(context);
+    }
+
+    @Override
+    public Bundle editProperties(AccountAuthenticatorResponse r, String s) {
+        return null;
+    }
+
+    @Override
+    public Bundle addAccount(AccountAuthenticatorResponse r, String s, String s2, String[] strings,
+            Bundle bundle) throws NetworkErrorException {
+        final Bundle result = new Bundle();
+        result.putString(AccountManager.KEY_ACCOUNT_NAME, "Test Account");
+        result.putString(AccountManager.KEY_ACCOUNT_TYPE, s);
+        return result;
+    }
+
+    @Override
+    public Bundle confirmCredentials(AccountAuthenticatorResponse r, Account account, Bundle bundle)
+            throws NetworkErrorException {
+        return null;
+    }
+
+    @Override
+    public Bundle getAuthToken(AccountAuthenticatorResponse r, Account account, String s,
+            Bundle bundle) throws NetworkErrorException {
+        return null;
+    }
+
+    @Override
+    public String getAuthTokenLabel(String s) {
+        return s;
+    }
+
+    @Override
+    public Bundle updateCredentials(AccountAuthenticatorResponse r, Account account, String s,
+            Bundle bundle) throws NetworkErrorException {
+        return null;
+    }
+
+    @Override
+    public Bundle hasFeatures(AccountAuthenticatorResponse r, Account account, String[] strings)
+            throws NetworkErrorException {
+        return null;
+    }
+}
diff --git a/tests/unit/src/com/android/settings/accounts/TestAuthService.java b/tests/unit/src/com/android/settings/accounts/TestAuthService.java
new file mode 100644
index 0000000..574e9b5
--- /dev/null
+++ b/tests/unit/src/com/android/settings/accounts/TestAuthService.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.settings.accounts;
+
+import android.app.Service;
+import android.content.Intent;
+import android.os.IBinder;
+
+public class TestAuthService extends Service {
+
+    private Authenticator mAuthenticator;
+
+    @Override
+    public void onCreate() {
+        mAuthenticator = new Authenticator(this);
+    }
+
+    @Override
+    public IBinder onBind(Intent intent) {
+        return mAuthenticator.getIBinder();
+    }
+
+}
diff --git a/tests/unit/src/com/android/settings/core/UniquePreferenceTest.java b/tests/unit/src/com/android/settings/core/UniquePreferenceTest.java
index 3daecce..aa1b55f 100644
--- a/tests/unit/src/com/android/settings/core/UniquePreferenceTest.java
+++ b/tests/unit/src/com/android/settings/core/UniquePreferenceTest.java
@@ -74,7 +74,6 @@
             "toggle_bluetooth",
             "toggle_nfc",
             "android_beam_settings",
-            "sms_mirroring",
             // Dup keys from About Phone v2 experiment.
             "ims_reg_state",
             "bt_address",
diff --git a/tests/unit/src/com/android/settings/users/UserSettingsTest.java b/tests/unit/src/com/android/settings/users/UserSettingsTest.java
index 213183a..2ecf161 100644
--- a/tests/unit/src/com/android/settings/users/UserSettingsTest.java
+++ b/tests/unit/src/com/android/settings/users/UserSettingsTest.java
@@ -15,34 +15,47 @@
  */
 package com.android.settings.users;
 
+import static com.google.common.truth.Truth.assertThat;
+
 import android.content.Context;
 import android.content.Intent;
+import android.support.test.InstrumentationRegistry;
 import android.support.test.filters.SmallTest;
+import android.support.test.runner.AndroidJUnit4;
 import android.support.test.uiautomator.UiDevice;
 import android.support.test.uiautomator.UiObject;
 import android.support.test.uiautomator.UiSelector;
 import android.support.test.uiautomator.UiScrollable;
-import android.test.InstrumentationTestCase;
+import android.support.test.uiautomator.UiObjectNotFoundException;
 
+import org.junit.Before;
 import org.junit.Test;
+import org.junit.runner.RunWith;
 
+@RunWith(AndroidJUnit4.class)
 @SmallTest
-public class UserSettingsTest extends InstrumentationTestCase {
+public class UserSettingsTest {
 
-    private static final String USER_AND_ACCOUNTS = "Users & accounts";
-    private static final String USERS = "Users";
+    private static final String SYSTEM = "System";
+    private static final String ADVANCED = "Advanced";
+    private static final String USERS = "Multiple users";
     private static final String EMERGNENCY_INFO = "Emergency information";
     private static final String ADD_USERS_WHEN_LOCKED = "Add users";
+    private static final String SWITCH_USER_BUTTON = "com.android.systemui:id/multi_user_switch";
+    private static final String SETTINGS_BUTTON = "com.android.systemui:id/settings_button";
+    private static final String PRIMARY_USER = "Owner";
+    private static final String GUEST_USER = "Guest";
+    private static final String ADD_GUEST = "Add guest";
+    private static final String CONTINUE = "Yes, continue";
 
     private UiDevice mDevice;
     private Context mContext;
     private String mTargetPackage;
 
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        mDevice = UiDevice.getInstance(getInstrumentation());
-        mContext = getInstrumentation().getTargetContext();
+    @Before
+    public void setUp() {
+        mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
+        mContext = InstrumentationRegistry.getTargetContext();
         mTargetPackage = mContext.getPackageName();
     }
 
@@ -51,7 +64,8 @@
         launchUserSettings();
         UiObject emergencyInfoPreference =
             mDevice.findObject(new UiSelector().text(EMERGNENCY_INFO));
-        assertFalse(emergencyInfoPreference.exists());
+
+        assertThat(emergencyInfoPreference.exists()).isFalse();
     }
 
     @Test
@@ -59,7 +73,32 @@
         launchUserSettings();
         UiObject addUsersPreference =
             mDevice.findObject(new UiSelector().text(ADD_USERS_WHEN_LOCKED));
-        assertFalse(addUsersPreference.exists());
+        assertThat(addUsersPreference.exists()).isFalse();
+    }
+
+    @Test
+    public void testUsersExistsOnSecondaryUser() throws Exception {
+        // switch to guest user
+        switchToOrCreateGuest();
+        // launch settings (launch from intent doesn't work, hence launch from quick settings)
+        mDevice.openQuickSettings();
+        mDevice.findObject(new UiSelector().resourceId(SETTINGS_BUTTON)).click();
+        // launch system settings and expand whole screen
+        final UiScrollable settings = new UiScrollable(
+            new UiSelector().packageName(mTargetPackage).scrollable(true));
+        final String titleSystem = SYSTEM;
+        settings.scrollTextIntoView(titleSystem);
+        mDevice.findObject(new UiSelector().text(titleSystem)).click();
+        mDevice.findObject(new UiSelector().text(ADVANCED)).click();
+
+        final boolean hasUsersSettings = mDevice.findObject(new UiSelector().text(USERS)).exists();
+
+        // switch back to primary user
+        mDevice.openQuickSettings();
+        mDevice.findObject(new UiSelector().resourceId(SWITCH_USER_BUTTON)).click();
+        mDevice.findObject(new UiSelector().text(PRIMARY_USER)).click();
+
+        assertThat(hasUsersSettings).isTrue();
     }
 
     private void launchSettings() {
@@ -67,17 +106,34 @@
                 .addCategory(Intent.CATEGORY_LAUNCHER)
                 .setPackage(mTargetPackage)
                 .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-        getInstrumentation().getContext().startActivity(settingsIntent);
+        mContext.startActivity(settingsIntent);
     }
 
     private void launchUserSettings() throws Exception  {
         launchSettings();
         final UiScrollable settings = new UiScrollable(
                 new UiSelector().packageName(mTargetPackage).scrollable(true));
-        final String titleUsersAndAccounts = USER_AND_ACCOUNTS;
-        settings.scrollTextIntoView(titleUsersAndAccounts);
-        mDevice.findObject(new UiSelector().text(titleUsersAndAccounts)).click();
+        final String titleSystem = SYSTEM;
+        settings.scrollTextIntoView(titleSystem);
+        mDevice.findObject(new UiSelector().text(titleSystem)).click();
+        mDevice.findObject(new UiSelector().text(ADVANCED)).click();
         mDevice.findObject(new UiSelector().text(USERS)).click();
     }
 
+    private void switchToOrCreateGuest() throws UiObjectNotFoundException {
+        mDevice.openQuickSettings();
+        mDevice.findObject(new UiSelector().resourceId(SWITCH_USER_BUTTON)).click();
+        // if no existing guest user, select "Add guest", otherwise select "Guest"
+        final UiObject addGuest = mDevice.findObject(new UiSelector().text(ADD_GUEST));
+        if (addGuest.exists()) {
+            addGuest.click();
+            mDevice.waitForIdle();
+            mDevice.pressBack();
+        } else {
+            mDevice.findObject(new UiSelector().text(GUEST_USER)).click();
+            mDevice.waitForIdle();
+            mDevice.findObject(new UiSelector().text(CONTINUE)).click();
+            mDevice.waitForIdle();
+        }
+    }
 }